feat(7835): what resembles the work but is not shown is named by id in one pointer line
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 35s
CI & Build / Python tests (push) Failing after 2m1s
CI & Build / integration (push) Successful in 2m20s
CI & Build / Build & push image (push) Skipped

A pointer before a payload:
- the notes arms fetch a few results past the menu; those that cleared
  the floor but were held back by the gate, the band or the budget are
  named by id per kind, with the call that opens each kind, in one line
  ("Also resembling this, not shown: ...") at the message and the write
  path;
- they are recorded in the record ledger as `pointed`, so an open that
  follows is counted apart from pushed lines;
- setting a task in progress returns records_in_area: the notes and open
  issues tagged to the task's areas, by id (a work.start row in the
  kind x moment table says which kinds; it answers in a tool reply, so it
  is shown as unmeasured).

The static context says what a pointer line means. Plugin version minted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 19:16:01 -05:00
co-authored by Claude Opus 5.5
parent a2e474f401
commit b68aefc109
17 changed files with 307 additions and 33 deletions
+6 -4
View File
@@ -390,10 +390,11 @@ def _default_record_kinds(request):
@pytest.fixture(autouse=True)
def _no_linked_issues(request):
"""Stub the write path's structural issue lookup to find nothing.
"""Stub the structural lookups (`record_links`) to find nothing.
It reads notes and task logs, which a unit test of the write path has
not written; a test about linked issues patches it with its own answer.
They read notes, task logs and areas, which a unit test of the write path
or of `update_task` has not written; a test about them patches its own
answer.
The integration lane runs the real query.
"""
if request.node.get_closest_marker("integration"):
@@ -401,7 +402,8 @@ def _no_linked_issues(request):
return
from grimoire.services import record_links
with patch.object(record_links, "issues_for_path", AsyncMock(return_value=[])):
with patch.object(record_links, "issues_for_path", AsyncMock(return_value=[])), \
patch.object(record_links, "area_records", AsyncMock(return_value={})):
yield
+21
View File
@@ -4,6 +4,7 @@ next; a closed one there, another project's and a plain task are
left out, as is everything for a reader without access; and a path is
matched literally."""
import pytest
from sqlalchemy import select
from grimoire.models import async_session
from grimoire.models.note import Note
@@ -78,3 +79,23 @@ async def test_the_limit_and_the_exclusions_hold():
assert await record_links.issues_for_path(uid, 0, PATH, limit=5) == []
# A reader who cannot read the project is shown none of its issues.
assert await record_links.issues_for_path(stranger, pid, PATH, limit=5) == []
async def test_a_tasks_areas_name_their_notes_and_open_issues_but_not_the_task_or_closed_work():
uid, pid, ids, stranger = await _world()
async with async_session() as s:
area = (await s.execute(
select(System.id).where(System.project_id == pid)
)).scalar_one()
task = Note(user_id=uid, project_id=pid, title="taking this up", status="in_progress",
task_kind="work")
note = Note(user_id=uid, project_id=pid, title="how locks work here", note_type="note")
s.add_all([task, note])
await s.flush()
s.add_all(RecordSystem(note_id=n, system_id=area) for n in (task.id, note.id))
await s.commit()
task_id, note_id = task.id, note.id
found = await record_links.area_records(uid, task_id, ["note", "task:issue"])
assert found == {"note": [note_id], "task:issue": [ids["open_area"]]}
assert await record_links.area_records(uid, task_id, ["note"]) == {"note": [note_id]}
assert await record_links.area_records(stranger, task_id, ["note", "task:issue"]) == {}
+37 -2
View File
@@ -154,9 +154,10 @@ async def test_this_responses_menu_is_withheld_but_a_pulled_one_is_still_scored(
)
(call,) = calls
# The listed one never reaches the search; the pulled one does, and the
# limit covers it so the menu still gets its full budget.
# limit covers it so the menu still gets its full budget, plus the
# pointer line's depth.
assert call["exclude_ids"] == {listed}
assert call["limit"] == 3
assert call["limit"] == 3 + rp.POINTER_DEPTH
assert [int(n.id) for _s, n in result.answered] == [pulled, 7]
assert [int(n.id) for _s, n in result.menu] == [7]
# Something was withheld after the search answered, so the score it
@@ -305,3 +306,37 @@ async def test_a_slot_whose_kind_the_door_turned_off_is_not_reserved():
# The reuse slot narrows to processes; the lesson slot does not run.
assert [c.get("note_type") for c in calls] == [None, ("process",)]
assert "lesson_slot" not in result.slot_ids
# ── the pointer: what cleared the floor and was not shown ─────────────────
@pytest.mark.asyncio
async def test_what_the_menu_did_not_show_is_kept_for_the_pointer_by_kind():
hits = [_note(1, 0.90), _note(2, 0.60), _note(3, 0.59, note_type="snippet"),
_note(4, 0.58, is_task=True, task_kind="issue"), _note(5, 0.57)]
result, _io_, _calls = await _run(
rp.WRITE_PATH, lambda kw: hits, budget=3, seen=frozenset({5}),
)
on_menu = {int(n.id) for _s, n in result.menu}
pointed = {i for ids in result.pointers.values() for i in ids}
assert not on_menu & pointed
# A record this session already has is not pointed at again.
assert 5 not in pointed
assert result.pointers.get("task:issue") == [4]
def test_the_pointer_line_names_ids_per_kind_with_the_call_that_opens_them():
from grimoire.services import record_kinds
line, ids = record_kinds.pointer_line(
{"task:issue": [4, 8, 9, 12], "snippet": [3]}, "Also resembling this, not shown",
)
assert line == (
"> Also resembling this, not shown: snippets #3 (`get_snippet(id)`); "
"4 issues #4, #8, #9 (`get_task(id)`). Open one if it may bear on the work."
)
assert ids == [3, 4, 8, 9]
assert record_kinds.pointer_line({}, "x") is None
capped, _ = record_kinds.pointer_line({"note": list(range(1, 21))}, "x", capped_at=20)
assert "20+ notes" in capped
+3 -1
View File
@@ -78,7 +78,9 @@ async def test_build_autoinject_hint_titles_only_with_margin_gate():
# Margin gate kept the top two, dropped the straggler.
assert out["note_ids"] == [11, 22]
assert '#11 [note] "Pool sizing decision" (0.80)' in out["context"]
assert "#33" not in out["context"]
# Below the band: not given a line, but named by id in the pointer.
assert '#33 [' not in out["context"]
assert "not shown: notes #33 (`get_note(id)`)" in out["context"]
# Title-first when the search reports no matched passage — which is this
# test, whose mock returns bare (score, note) pairs and fills no report.
# A record whose passage IS known gets it on a second line; that is
+4 -2
View File
@@ -327,7 +327,8 @@ async def test_semantic_arm_only_asks_for_the_budget_the_place_arm_left():
patch.object(pc, "semantic_search_notes", search), \
patch.object(pc, "record_retrieval", MagicMock()):
await pc.build_write_path_hint(1, "src/x.py", code=REAL_CODE)
assert search.await_args.kwargs["limit"] == 2
from grimoire.services.retrieval_pipeline import POINTER_DEPTH
assert search.await_args.kwargs["limit"] == 2 + POINTER_DEPTH
@pytest.mark.asyncio
@@ -1322,7 +1323,8 @@ async def test_a_pulled_snippet_already_seen_is_evidence_not_menu():
# nothing is dropped between the search and the menu.
kw = search.call_args.kwargs
assert 7 not in kw["exclude_ids"]
assert kw["limit"] == 3
from grimoire.services.retrieval_pipeline import POINTER_DEPTH
assert kw["limit"] == 3 + POINTER_DEPTH
# ...and the menu carries it, marked.
seven = next(line for line in out["context"].splitlines() if "#7" in line)
assert "seen" in seven