feat(7832): records reach an edit and a message by structure first; resemblance offers notes
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Failing after 12s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Failing after 1m39s
CI & Build / integration (push) Successful in 2m17s
CI & Build / Build & push image (push) Skipped
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Failing after 12s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Failing after 1m39s
CI & Build / integration (push) Successful in 2m17s
CI & Build / Build & push image (push) Skipped
The kind×moment table's first measured defaults (baseline note #7892): - The edit door splits in two rows. work.change is what is recorded where the edit is (snippets beside the file, issues naming it or open in its area); work.change.similar is what the code resembles, notes by default. Issues and snippets no longer reach an edit by resemblance. - Snippets recorded beside the file are named by id in an "Also recorded beside this file" pointer line instead of taking menu lines. - The message door leaves lessons and issues out by default: a lesson arrives at its confirmed situation, an issue through its area or its id. Its lesson slot runs only for a user who turns lessons back on. - The static context teaches the new pointer line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1077,6 +1077,9 @@ def _rule_io() -> rp.RuleIO:
|
||||
# How a door's pointer line opens: records that cleared the floor and were
|
||||
# not shown. The static context teaches what a line opening this way means.
|
||||
POINTER_LEAD = "Also resembling this, not shown"
|
||||
# The write path's line naming snippets recorded beside the file being
|
||||
# written: offered for where they sit, so the lead says that, not resemblance.
|
||||
PLACE_POINTER_LEAD = "Also recorded beside this file"
|
||||
|
||||
|
||||
def _prior_art_line(item: dict, marker: str, owner: str | None, foreign_lang: str = "") -> str:
|
||||
@@ -1398,11 +1401,12 @@ async def build_write_path_hint(
|
||||
# `path` matches exact-or-under (see knowledge.py), and nothing sits under
|
||||
# a FILE path — so the file query returns precisely the snippets recorded
|
||||
# AT this path: the sync class. The directory query is the reuse-shaped
|
||||
# "nearby" arm, unchanged.
|
||||
# The kinds this user's write path considers (the kind×moment table).
|
||||
# The structural lookups below read it as the search by meaning does: a
|
||||
# kind turned off at this door is not offered here by any arm.
|
||||
kinds = await record_kinds.kinds_for(user_id, rp.WRITE_PATH.door)
|
||||
# "nearby" arm, named by id only.
|
||||
# The kinds the structural lookups below consider (the kind×moment table's
|
||||
# `work.change` row). The search by meaning reads its own row
|
||||
# (`work.change.similar`), so a kind can be offered where it is recorded
|
||||
# and not by resemblance.
|
||||
kinds = await record_kinds.kinds_for(user_id, record_kinds.WORK_CHANGE)
|
||||
here: list[dict] = []
|
||||
nearby: list[dict] = []
|
||||
try:
|
||||
@@ -1434,19 +1438,18 @@ async def build_write_path_hint(
|
||||
if nid not in sync_excluded and len(synced) < top_k:
|
||||
synced.append(item)
|
||||
|
||||
placed: list[tuple[str, dict]] = []
|
||||
# A snippet recorded beside the file is named by id, not given a line: it
|
||||
# is offered because of where it sits, not because it bears on this edit,
|
||||
# and the session is the one placed to judge whether it does. One already
|
||||
# shown this session is in context and is not named again.
|
||||
placed: list[int] = []
|
||||
for item in nearby:
|
||||
nid = int(item["id"])
|
||||
if nid in seen:
|
||||
continue
|
||||
seen.add(nid)
|
||||
# MARKED HERE TOO, not just on the semantic arm, because these are one
|
||||
# menu. A hint where some repeats carry `seen` and others are silently
|
||||
# dropped — decided by which arm happened to find them — is worse than
|
||||
# either rule applied consistently: the marker would read as a complete
|
||||
# account of what the session has met before, and it would not be one.
|
||||
item["seen"] = nid in excluded
|
||||
placed.append(("nearby · seen" if nid in excluded else "nearby", item))
|
||||
if nid not in excluded:
|
||||
placed.append(nid)
|
||||
|
||||
# --- arm 1b: issues linked by structure ---
|
||||
# An issue that names this file, or is open in its area, needs no
|
||||
@@ -1454,7 +1457,7 @@ async def build_write_path_hint(
|
||||
# search by meaning runs, and that search does not list it again.
|
||||
linked: list[tuple[str, dict]] = []
|
||||
if "task:issue" in kinds and project_id:
|
||||
room = min(LINKED_ISSUES_MAX, top_k - len(synced) - len(placed))
|
||||
room = min(LINKED_ISSUES_MAX, top_k - len(synced))
|
||||
for link, note in await record_links_svc.issues_for_path(
|
||||
user_id, project_id, path, limit=room, exclude=frozenset(seen),
|
||||
):
|
||||
@@ -1479,7 +1482,7 @@ async def build_write_path_hint(
|
||||
|
||||
# --- arm 2: by meaning ---
|
||||
scored: list[tuple[str, dict]] = []
|
||||
remaining = top_k - len(synced) - len(placed) - len(linked)
|
||||
remaining = top_k - len(synced) - len(linked)
|
||||
query = (code or "").strip()
|
||||
# Drop payloads too small to carry meaning before spending an embedding on
|
||||
# them — a one-line Edit is not a helper being rewritten, and its embedding
|
||||
@@ -1516,7 +1519,7 @@ async def build_write_path_hint(
|
||||
user_id=user_id, query=query, project_id=project_id,
|
||||
seen=frozenset(excluded), in_menu=frozenset(seen),
|
||||
still_scored=frozenset(pulled),
|
||||
kinds=kinds,
|
||||
kinds=await record_kinds.kinds_for(user_id, rp.WRITE_PATH.door),
|
||||
),
|
||||
floor=cfg["threshold"], budget=remaining, io=_note_io(),
|
||||
)
|
||||
@@ -1576,9 +1579,9 @@ async def build_write_path_hint(
|
||||
},
|
||||
))
|
||||
|
||||
# Structure first: what is linked to the file, then what sits beside it,
|
||||
# then what was found by meaning.
|
||||
menu = (linked + placed + scored)[:max(0, top_k - len(synced))]
|
||||
# Structure first: what is linked to the file, then what was found by
|
||||
# meaning. What sits beside the file is named in its own pointer line.
|
||||
menu = (linked + scored)[:max(0, top_k - len(synced))]
|
||||
|
||||
# The suggestion runs whether or not anything is rendered — after dedup,
|
||||
# the common case is a silent hint and a pulled canon being instantiated.
|
||||
@@ -1728,7 +1731,8 @@ async def build_write_path_hint(
|
||||
]
|
||||
|
||||
if (not staleness and not synced and not menu and not suggested
|
||||
and not divergence and not derive and not rule_lines and not pointers):
|
||||
and not divergence and not derive and not rule_lines and not pointers
|
||||
and not placed):
|
||||
if design_text or rulings["lines"]:
|
||||
return {
|
||||
**empty,
|
||||
@@ -1853,6 +1857,17 @@ async def build_write_path_hint(
|
||||
entry.append(f"> ↳ {passage}")
|
||||
parts[-1] = replace(parts[-1], text="\n".join(entry))
|
||||
|
||||
place_pointer = record_kinds.pointer_line({"snippet": placed}, PLACE_POINTER_LEAD)
|
||||
place_named: list[int] = []
|
||||
if place_pointer:
|
||||
place_named = place_pointer[1]
|
||||
lines.append(place_pointer[0])
|
||||
parts.append(hook_payload.Part(
|
||||
text=place_pointer[0], block="pointer",
|
||||
ids={hook_payload.NOTE: tuple(place_named)},
|
||||
))
|
||||
record_deliveries_svc.record(user_id, place_named, "write_path_place", way=POINTED)
|
||||
|
||||
pointer = record_kinds.pointer_line(pointers, POINTER_LEAD)
|
||||
if pointer:
|
||||
lines.append(pointer[0])
|
||||
@@ -1885,7 +1900,9 @@ async def build_write_path_hint(
|
||||
by_arm: dict[str, list[int]] = {}
|
||||
if sync_note_ids:
|
||||
by_arm["write_path_sync"] = list(sync_note_ids)
|
||||
for marker, item in menu:
|
||||
if place_named:
|
||||
by_arm["write_path_place"] = list(place_named)
|
||||
for _marker, item in menu:
|
||||
# A rendered repeat is not a new surfacing — same cut the log row
|
||||
# takes, so this table and `retrieval_logs` keep agreeing about the
|
||||
# same call. The semantic arm's rows (`write_path_semantic`)
|
||||
@@ -1895,8 +1912,6 @@ async def build_write_path_hint(
|
||||
continue
|
||||
if item.get("linked"):
|
||||
by_arm.setdefault("write_path_linked", []).append(int(item["id"]))
|
||||
elif marker.startswith("nearby"):
|
||||
by_arm.setdefault("write_path_place", []).append(int(item["id"]))
|
||||
for arm, ids in by_arm.items():
|
||||
record_surfaced(
|
||||
user_id=user_id, note_ids=ids, source=arm, project_id=project_id,
|
||||
|
||||
@@ -35,6 +35,27 @@ A door is a point where records are offered: a catalog moment
|
||||
(`work.change` before a write, `work.start` when a task is taken up), or the
|
||||
operator's message, which is when a session first hears what the work is and
|
||||
is not a moment rules mount on, so it has its own key (`message`).
|
||||
|
||||
One moment can have two doors when it finds records two ways. An edit is
|
||||
offered what sits where the edit is (`work.change`: snippets recorded at or
|
||||
beside the file, issues that name it or are open in its area) and what the
|
||||
code being written resembles (`work.change.similar`). The two make different
|
||||
claims: "this is recorded here" holds whatever the words are, and "this
|
||||
reads like what you are writing" holds only as far as resemblance is
|
||||
evidence. So each has its own row, and a kind can be on for one and off for
|
||||
the other.
|
||||
|
||||
WHAT THE DEFAULTS SAY
|
||||
|
||||
A kind is offered by resemblance only where resemblance is evidence for it.
|
||||
Notes are written in the words of the work they describe, so a note that
|
||||
reads like the work is usually about it. An issue, a lesson or a snippet
|
||||
resembles the words around it far more often than the work is its case,
|
||||
so each reaches the work through its structure instead: a snippet through
|
||||
the file it is recorded at, an issue through the file or area it names and
|
||||
when a task in its area is taken up, a lesson through the situation
|
||||
confirmed for it (`lesson_situations`), and any record when the work names
|
||||
its id.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -67,6 +88,8 @@ LABELS: dict[str, str] = {
|
||||
|
||||
SETTING_KEY = "record_kinds"
|
||||
MESSAGE = "message"
|
||||
WORK_CHANGE = "work.change"
|
||||
WORK_CHANGE_SIMILAR = "work.change.similar"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -85,21 +108,31 @@ class Door:
|
||||
|
||||
|
||||
DOORS: dict[str, Door] = {
|
||||
# Found by resemblance to the operator's words. Issues and lessons are
|
||||
# left out (see WHAT THE DEFAULTS SAY); a record the message names by id
|
||||
# is looked up whatever its kind.
|
||||
MESSAGE: Door(
|
||||
MESSAGE, "The operator's message", "once per operator turn",
|
||||
frozenset(KINDS), sources=("auto_inject", "lesson_slot"),
|
||||
frozenset(KINDS) - {"lesson", "task:issue"}, sources=("auto_inject", "lesson_slot"),
|
||||
),
|
||||
# What is about to be written: code to reuse, and what was already tried
|
||||
# (an issue, a dev-log, a lesson). The open to-do list resembles the code
|
||||
# and answers nothing, so work tasks are left out.
|
||||
# Not lessons: an edit's words resemble a lesson far more often than the
|
||||
# edit is its situation. A lesson reaches an edit through a situation
|
||||
# confirmed for it (`lesson_situations`), once per session.
|
||||
"work.change": Door(
|
||||
"work.change", "Altering the thing being worked on", "before every write or edit",
|
||||
frozenset({"snippet", "note", "task:issue"}),
|
||||
sources=("write_path_semantic", "write_path_place", "write_path_sync",
|
||||
"write_path_linked"),
|
||||
# What sits where the edit is: snippets recorded beside the file (named
|
||||
# by id), and issues that name the file or are open in its area. The
|
||||
# snippets recorded at the file itself are always shown: they are the
|
||||
# record of the code being changed.
|
||||
WORK_CHANGE: Door(
|
||||
WORK_CHANGE, "Altering the thing being worked on: what is recorded there",
|
||||
"before every write or edit",
|
||||
frozenset({"snippet", "task:issue"}),
|
||||
sources=("write_path_place", "write_path_sync", "write_path_linked"),
|
||||
),
|
||||
# What the code being written resembles. Notes only by default; the open
|
||||
# to-do list resembles the code and answers nothing, and the other kinds
|
||||
# reach an edit through the door above or their situation.
|
||||
WORK_CHANGE_SIMILAR: Door(
|
||||
WORK_CHANGE_SIMILAR, "Altering the thing being worked on: what it resembles",
|
||||
"before a write or edit long enough to compare",
|
||||
frozenset({"note"}),
|
||||
sources=("write_path_semantic",),
|
||||
),
|
||||
# Taking up a task: what is recorded in the task's own areas, named by id
|
||||
# in the reply that set it in progress. Notes for what is known there,
|
||||
|
||||
@@ -1172,7 +1172,7 @@ AUTO_INJECT = NoteArm(
|
||||
# 200:1 dilution a slot answers does not happen.
|
||||
WRITE_PATH = NoteArm(
|
||||
"write_path", surfaced_as="write_path_semantic",
|
||||
door="work.change", withholds=True, gated=True,
|
||||
door=record_kinds.WORK_CHANGE_SIMILAR, withholds=True, gated=True,
|
||||
tuning=Surface(
|
||||
name="write_path",
|
||||
floor_key="kb_writepath_threshold",
|
||||
@@ -1181,7 +1181,7 @@ WRITE_PATH = NoteArm(
|
||||
budget_default=3,
|
||||
budget_falls_back_to="kb_autoinject_top_k",
|
||||
asks="the code being written, rewritten as a concept query",
|
||||
over="snippets and recorded issues",
|
||||
over="the kinds its row of the record-kinds table allows (notes by default)",
|
||||
fires="before every Write and Edit",
|
||||
),
|
||||
declared=Declared("prior art offered when a file is about to be written"),
|
||||
|
||||
Reference in New Issue
Block a user