Design-system delivery, the contrast fix, recall scoping, and backup coverage #93

Merged
bvandeusen merged 10 commits from dev into main 2026-07-31 23:21:25 -04:00
4 changed files with 24 additions and 6 deletions
Showing only changes of commit da2383b079 - Show all commits
+8 -3
View File
@@ -334,10 +334,15 @@ async def _reserve_slot_for_reuse(
note_type=_REUSE_KINDS, note_type=_REUSE_KINDS,
scope="browse", scope="browse",
) )
# Belt and braces on top of exclude_ids: a record already on the menu must # Verify the kind rather than trusting the query that asked for it, and
# never appear twice, and one slot is all this is entitled to. # dedup on top of exclude_ids. This slot exists FOR reuse kinds — a slot
# silently spent on something else is worse than no slot, because the line
# is indistinguishable from one that earned its place on score.
kept_ids = {int(n.id) for _s, n in kept} kept_ids = {int(n.id) for _s, n in kept}
fresh = [(s, n) for s, n in reuse if int(n.id) not in kept_ids][:1] fresh = [
(s, n) for s, n in reuse
if _record_kind(n) in _REUSE_KINDS and int(n.id) not in kept_ids
][:1]
if not fresh: if not fresh:
return kept return kept
+3
View File
@@ -25,6 +25,9 @@ def _note(nid, title, user_id=1):
# See the same note in test_write_path_trigger: an auto-created mock on # See the same note in test_write_path_trigger: an auto-created mock on
# `.data` is truthy and would leak into a rendered menu line (#2244). # `.data` is truthy and would leak into a rendered menu line (#2244).
n.data = None n.data = None
# And on `.is_task`, which the kind marker reads FIRST — truthy there makes
# every one of these snippets read as a task (#2246).
n.is_task, n.task_kind = False, "work"
return n return n
+3
View File
@@ -19,6 +19,9 @@ def _note(nid, title, user_id=1, note_type="note", is_task=False, task_kind="wor
# auto-MagicMock is truthy, so every line would read as another user's task. # auto-MagicMock is truthy, so every line would read as another user's task.
n.user_id = user_id n.user_id = user_id
n.note_type, n.is_task, n.task_kind = note_type, is_task, task_kind n.note_type, n.is_task, n.task_kind = note_type, is_task, task_kind
# The write-path menu reads note.data for a language tag; an auto-mock there
# is truthy and renders its repr into the marker.
n.data = None
return n return n
+10 -3
View File
@@ -23,13 +23,17 @@ def _snippet_item(nid, title, user_id=1):
return {"id": nid, "title": title, "user_id": user_id, "note_type": "snippet"} return {"id": nid, "title": title, "user_id": user_id, "note_type": "snippet"}
def _note(nid, title, user_id=1): def _note(nid, title, user_id=1, note_type="snippet", is_task=False, task_kind="work"):
n = MagicMock() n = MagicMock()
n.id, n.title, n.user_id = nid, title, user_id n.id, n.title, n.user_id = nid, title, user_id
# Explicitly None, not left to MagicMock's auto-attribute: the semantic arm # Explicitly None, not left to MagicMock's auto-attribute: the semantic arm
# reads `note.data` for the snippet's language (#2244), and an auto-created # reads `note.data` for the snippet's language (#2244), and an auto-created
# mock there is truthy, so it would render its repr into the menu line. # mock there is truthy, so it would render its repr into the menu line.
n.data = None n.data = None
# Same reasoning, second instance: since #2246 this arm returns issues and
# dev-logs too, so the line names the kind. An auto-mock `is_task` is truthy,
# which would label every snippet here "task".
n.note_type, n.is_task, n.task_kind = note_type, is_task, task_kind
return n return n
@@ -183,8 +187,11 @@ async def test_semantic_arm_is_snippet_only_and_browse_scoped():
patch.object(pc, "record_retrieval", MagicMock()): patch.object(pc, "record_retrieval", MagicMock()):
await pc.build_write_path_hint(1, "src/x.py", code=REAL_CODE) await pc.build_write_path_hint(1, "src/x.py", code=REAL_CODE)
kwargs = search.await_args.kwargs kwargs = search.await_args.kwargs
# Prior art means snippets — not the dev-log that happens to mention one. # Prior art is snippets AND recorded experience (#2246) — an issue saying
assert kwargs["note_type"] == "snippet" # "we tried this and it broke" belongs here. What stays out is the open
# to-do list, which resembles the code and answers nothing.
assert kwargs["note_type"] == ("snippet", "note")
assert kwargs["task_kind"] == "issue"
# Nobody asked for this, so it must not reach a one-to-one direct share. # Nobody asked for this, so it must not reach a one-to-one direct share.
assert kwargs["scope"] == "browse" assert kwargs["scope"] == "browse"