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

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:
2026-11-25 12:17:29 -05:00
co-authored by Claude Opus 5.5
parent 07c4a716bd
commit 4c69f9c163
10 changed files with 175 additions and 97 deletions
+19 -27
View File
@@ -207,7 +207,10 @@ async def test_directory_is_only_consulted_when_the_file_leaves_room():
@pytest.mark.asyncio
async def test_directory_hits_are_marked_nearby_not_here():
async def test_a_snippet_beside_the_file_is_named_by_id_not_given_a_line():
"""A snippet recorded in the same folder is offered for where it sits, so
it is named in one pointer line that says so, with the call that opens
it, and takes no line or budget from the menu."""
from grimoire.services import plugin_context as pc
async def _listing(uid, **kw):
@@ -221,7 +224,10 @@ async def test_directory_hits_are_marked_nearby_not_here():
patch.object(pc, "record_retrieval", MagicMock()), \
patch.object(pc, "owner_names_for", AsyncMock(return_value={})):
out = await pc.build_write_path_hint(1, "src/lib/x.py", code=REAL_CODE)
assert '#9 [nearby] "sibling helper"' in out["context"]
assert '#9 [' not in out["context"]
assert ("> Also recorded beside this file: snippets #9 (`get_snippet(id)`)"
in out["context"])
assert out["note_ids"] == []
@pytest.mark.asyncio
@@ -334,22 +340,12 @@ async def test_semantic_arm_only_asks_for_the_budget_the_place_arm_left():
@pytest.mark.asyncio
async def test_session_dedup_marks_the_reuse_arms_rather_than_silencing_them():
"""exclude_ids governs the REUSE classes — nearby and semantic. (The sync
class has its own channel; see the tests above.)
WHY A MARKER AND NOT SILENCE. Dropping the hit and pushing its id into the
search's `exclude_ids` means that the second time a record is the best
answer, the session gets silence, which reads exactly like "nothing is
recorded here". So the repeat is rendered with a `seen` marker, and the
ledger never reaches the query, so the score the search reports describes
the bar rather than a candidate set the caller had already edited.
Marked on BOTH reuse arms, which is what this asserts: one menu with two
rules — `seen` on the semantic hits, silence on the nearby ones — would
make the marker read as a complete account of what the session has met,
when it would only cover half the lines.
"""
async def test_a_snippet_beside_the_file_already_shown_is_not_named_again():
"""exclude_ids is the session's ledger. A snippet beside the file that
the session already has is in its context, so the pointer line does not
name it again; it is still withheld from the search by resemblance, since
the place lookup found it in this same call. (The sync class has its own
channel; see the tests above.)"""
from grimoire.services import plugin_context as pc
async def _listing(uid, **kw):
@@ -364,15 +360,11 @@ async def test_session_dedup_marks_the_reuse_arms_rather_than_silencing_them():
patch.object(pc, "semantic_search_notes", search), \
patch.object(pc, "record_retrieval", MagicMock()):
out = await pc.build_write_path_hint(1, "src/x.py", code=REAL_CODE, exclude_ids=[12])
assert out["note_ids"] == [12]
assert "seen" in next(
line for line in out["context"].splitlines() if "#12" in line
)
# #12 IS in this call's `exclude_ids`, and that is the other rule working:
# the place arm has just listed it, so the semantic arm must not list it
# again. What must never reach the query is the LEDGER, which is asserted
# on its own in tests/test_ledger_references_not_silence.py against a
# record this call has not otherwise rendered.
assert "#12" not in out["context"]
# #12 IS in this call's `exclude_ids` because the place lookup found it in
# this call, not because the ledger reached the query; that is asserted on
# its own in tests/test_ledger_references_not_silence.py against a record
# this call has not otherwise found.
assert 12 in search.await_args.kwargs["exclude_ids"]