feat(8815): a message that reads as another project's work asks the session to check before acting
CI & Build / TypeScript typecheck (push) Successful in 10s
CI & Build / Python lint (push) Successful in 1s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / integration (push) Successful in 2m57s
CI & Build / Build & push image (push) Successful in 35s

An operator running one session per project can type into the wrong
window, and nothing caught it: the message usually asks for work the
session can do in its own repo, so the project fence never fires.

The prompt lookup (/api/plugin/retrieve) now ranks the operator's own
words against every project's records (services/project_check.py). When
another project's records clearly win (best match >= 0.78, ahead of this
project's by 0.05, with at least 3 of the 12 nearest), a line leads the
payload, ahead of every rule, telling the session to ask the operator
whether the message was meant for it. Naming the other project halves the
margin but never flags alone; naming this project rules a flag out. A
message with no subject, or a session with no project, is not checked.

Each flag is a new `project_check` gate stop with both scores, asked once
per session per other project, read back in retrieval_telemetry's gates
block and in the web UI's gate readout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-05 22:21:49 -05:00
co-authored by Claude Opus 5.5
parent 72ef1bb45d
commit 58991038d8
8 changed files with 386 additions and 5 deletions
+14
View File
@@ -111,6 +111,20 @@ async def test_the_readout_counts_stops_reads_misfires_and_the_cap_per_gate_and_
assert out["complete_from"] is not None
async def test_a_project_check_needs_no_rule_is_asked_once_per_session_and_is_read_back():
uid = await _user()
assert not await gate_stops.asked(uid, "s-1", gate="project_check", target="6")
assert await gate_stops.record(uid, "s-1", gate="project_check", outcome="asked",
tool="prompt", target="6", at="0.860 vs 0.740")
assert await gate_stops.asked(uid, "s-1", gate="project_check", target="6")
# Another session, or another project, has not been asked.
assert not await gate_stops.asked(uid, "s-2", gate="project_check", target="6")
assert not await gate_stops.asked(uid, "s-1", gate="project_check", target="9")
out = await gate_stops.summary(uid, days=1)
assert out["by_gate"]["project_check"]["stops"] == 1
assert [(p["target"], p["asks"]) for p in out["project_check"]] == [("6", 1)]
async def test_stops_age_out_with_the_deliveries():
uid = await _user()
await gate_stops.record(uid, "s", gate="hold", outcome="stopped", tool="bash", rule_id=RULE)