fix(8241,8242): a pointer line names a record once a session, and a place delivery is booked once
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Successful in 2m5s
CI & Build / integration (push) Successful in 1m57s
CI & Build / Build & push image (push) Successful in 20s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Successful in 2m5s
CI & Build / integration (push) Successful in 1m57s
CI & Build / Build & push image (push) Successful in 20s
The plugin ledger of what a session has seen holds only records given a line, so a record named by id came back on every edit and message (one handoff note 35 times in a session). Every pointer line now goes through _point, which asks the server delivery ledger what this session was already shown or pointed at and leaves those out. Snippets beside an edited file were booked both pushed (via record_surfaced) and pointed; record_surfaced now leaves write_path_place to its door. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -137,14 +137,18 @@ def record_surfaced(
|
||||
return
|
||||
_schedule(rows)
|
||||
# The same lines, against the session a plugin door is delivering to. A
|
||||
# synced skill is not a line in front of the session, so it is left out.
|
||||
# synced skill is not a line in front of the session, and a pointer is
|
||||
# booked as `pointed` by the door that names it, so both are left out.
|
||||
if source not in _NOT_A_LINE:
|
||||
from grimoire.services import record_deliveries
|
||||
record_deliveries.record(user_id, note_ids, source)
|
||||
|
||||
|
||||
# Surfacing sources that put nothing in front of the session as a line.
|
||||
_NOT_A_LINE = frozenset({"process_skill_sync"})
|
||||
# Surfacing sources that put nothing in front of the session as a line:
|
||||
# a synced skill, and the snippets beside an edited file, which are named by
|
||||
# id in a pointer line (its door records them as `pointed`). Booking these
|
||||
# as `pushed` too would count each delivery twice.
|
||||
_NOT_A_LINE = frozenset({"process_skill_sync", "write_path_place"})
|
||||
|
||||
|
||||
def record_pulled(
|
||||
|
||||
@@ -852,13 +852,12 @@ async def build_autoinject_hint(
|
||||
# What else cleared the floor, named by id only. Recorded as `pointed`
|
||||
# rather than surfaced: no line was spent on these, so an open that
|
||||
# follows says whether a pointer is enough.
|
||||
pointer = record_kinds.pointer_line(pointers, POINTER_LEAD)
|
||||
pointer = await _point(user_id, pointers, POINTER_LEAD, "auto_inject_pointer")
|
||||
if pointer:
|
||||
lines.append(pointer[0])
|
||||
parts.append(hook_payload.Part(
|
||||
text=pointer[0], block="pointer", ids={hook_payload.NOTE: tuple(pointer[1])},
|
||||
))
|
||||
record_deliveries_svc.record(user_id, pointer[1], "auto_inject_pointer", way=POINTED)
|
||||
|
||||
# A lookup, not a ranking, so it writes no retrieval_logs row — there is no
|
||||
# score or bar to tune — and its surfacings are its own source, which is
|
||||
@@ -877,6 +876,31 @@ async def build_autoinject_hint(
|
||||
}
|
||||
|
||||
|
||||
async def _point(
|
||||
user_id: int, pointers: dict[str, list[int]], lead: str, source: str,
|
||||
) -> tuple[str, list[int]] | None:
|
||||
"""One pointer line, naming each record at most once a session, booked
|
||||
under `source` as `pointed`; None when nothing is left to name.
|
||||
|
||||
A pointer is for a record the session has not met. The plugin's own
|
||||
ledger of what a session has seen holds only the records given a line,
|
||||
so without this a record named by id comes back on every edit and every
|
||||
message. A handoff note can then be named dozens of times in one session,
|
||||
and a line that repeats on every turn stops being read. The server's
|
||||
delivery ledger knows every record shown or pointed at in the session,
|
||||
whatever the plugin version, so that is what is asked. Outside a plugin
|
||||
request there is no session, nothing is left out, and nothing is booked.
|
||||
"""
|
||||
ids = [i for kind_ids in pointers.values() for i in kind_ids]
|
||||
had = await record_deliveries_svc.delivered_this_session(user_id, ids)
|
||||
if had:
|
||||
pointers = {k: [i for i in v if i not in had] for k, v in pointers.items()}
|
||||
pointer = record_kinds.pointer_line(pointers, lead)
|
||||
if pointer:
|
||||
record_deliveries_svc.record(user_id, pointer[1], source, way=POINTED)
|
||||
return pointer
|
||||
|
||||
|
||||
async def _origins(notes, project_id: int | None) -> dict[int, str]:
|
||||
"""{note id: project title} for the records here from a project other
|
||||
than the session's. Empty with no session project, where every record is
|
||||
@@ -1901,7 +1925,9 @@ 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_pointer = await _point(
|
||||
user_id, {"snippet": placed}, PLACE_POINTER_LEAD, "write_path_place",
|
||||
)
|
||||
place_named: list[int] = []
|
||||
if place_pointer:
|
||||
place_named = place_pointer[1]
|
||||
@@ -1910,15 +1936,13 @@ async def build_write_path_hint(
|
||||
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)
|
||||
pointer = await _point(user_id, pointers, POINTER_LEAD, "write_path_pointer")
|
||||
if pointer:
|
||||
lines.append(pointer[0])
|
||||
parts.append(hook_payload.Part(
|
||||
text=pointer[0], block="pointer", ids={hook_payload.NOTE: tuple(pointer[1])},
|
||||
))
|
||||
record_deliveries_svc.record(user_id, pointer[1], "write_path_pointer", way=POINTED)
|
||||
|
||||
if suggested:
|
||||
lines.append(_suggest_line(path, suggested))
|
||||
|
||||
Reference in New Issue
Block a user