Repository navigation
worker: each briefing asks agents to check up to two claims: disputed, or often read and not confirmed lately #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
60e9fb1
worker: a claim rated wrong leaves the briefing until a later used cl…
vu1n 2fbcaf9
worker: dispute ignores unmarked ratings and never shows the rater's …
vu1n 4f8c549
worker: briefing sections fill past disputed claims instead of losing…
vu1n 0ef0a49
worker: the dispute rule lives in SQL; briefing queries exclude dispu…
vu1n c511698
worker: claims can say how they are known; reads mark them apart from…
vu1n 313e89a
Merge remote-tracking branch 'origin/main' into claude/project-thread…
vu1n 7840687
Merge remote-tracking branch 'origin/main' into claude/project-thread…
vu1n 52f8fe9
worker: instructions lead with what memory is for; claim tool names f…
vu1n b0ee9a6
Merge remote-tracking branch 'origin/main' into claude/project-thread…
vu1n e551a67
worker: the briefing's lines share one size budget; unconfirmed user …
vu1n 6a853c0
Merge main
vu1n 93cacf3
worker: each briefing asks agents to check up to two claims: disputed…
vu1n File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Agents check memory as they read it: a briefing asks for a check of an accepted claim that is read | ||
| // often and hasn't held up in anyone's work lately, and a writable `used` takes it back off the list. | ||
| import assert from "node:assert/strict"; | ||
| import { test } from "node:test"; | ||
| import { type Caller, handleMcp } from "../src/mcp.ts"; | ||
| import { memoryD1 } from "./d1.ts"; | ||
|
|
||
| const OWNER: Caller = { user: "owner", agent: "claude" }; | ||
| const HEADING = "\n# check these if your work touches them, then rate them with `feedback`\n"; | ||
|
|
||
| async function setup() { | ||
| const db = memoryD1(); | ||
| await db.prepare("INSERT INTO projects(name, description, created_at) VALUES('kypp', '', '2026-11-06T00:00:00Z')").run(); | ||
| return db; | ||
| } | ||
|
|
||
| function agent(db: D1Database, session: string) { | ||
| return async (name: string, args: Record<string, unknown> = {}) => { | ||
| const req = new Request("https://k/mcp", { method: "POST", headers: { "X-Kypp-Project": "kypp", "Mcp-Session-Id": session }, | ||
| body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name, arguments: args } }) }); | ||
| return ((await (await handleMcp(req, db, OWNER, { s1: null })).json()) as any).result.content[0].text as string; | ||
| }; | ||
| } | ||
|
|
||
| test("an often-read claim nobody has confirmed lately moves to the check section until a used", async () => { | ||
| const db = await setup(); | ||
| const w = agent(db, "w"); | ||
| const id = (await w("correct", { subject: "wrangler port", content: "wrangler dev listens on 8787", type: "pitfall" })).split("\n")[0].trim(); | ||
| await w("correct", { subject: "deploys", content: "the worker deploys on merge to main", type: "procedure" }); | ||
| for (let i = 0; i < 9; i++) await agent(db, `r${i}`)("briefing"); | ||
|
|
||
| const before = await agent(db, "r9")("briefing"); | ||
| assert.ok(!before.includes(HEADING), "9 reads each is under the bar"); | ||
| const after = await agent(db, "r10")("briefing"); | ||
| const [settled, check] = after.split(HEADING); | ||
| assert.match(check, /wrangler port/); | ||
| assert.match(check, /deploys/); | ||
| assert.doesNotMatch(settled, /wrangler port|deploys/); | ||
|
|
||
| await agent(db, "r10")("feedback", { ratings: [{ handle: id, verdict: "used", note: "ran wrangler dev; it answered on 8787" }] }); | ||
| const [settled2, check2] = (await agent(db, "r11")("briefing")).split(HEADING); | ||
| assert.match(settled2, /wrangler port/); | ||
| assert.doesNotMatch(check2, /wrangler port/); | ||
| assert.match(check2, /deploys/); | ||
| }); | ||
|
|
||
| test("a briefing asks for at most two checks", async () => { | ||
| const db = await setup(); | ||
| const w = agent(db, "w"); | ||
| for (const s of ["a", "b", "c"]) await w("correct", { subject: `trap ${s}`, content: `lesson ${s}`, type: "pitfall" }); | ||
| for (let i = 0; i < 10; i++) await agent(db, `r${i}`)("briefing"); | ||
| const check = (await agent(db, "x")("briefing")).split(HEADING)[1]; | ||
| assert.equal(check.split("\n").filter((l) => /^[0-9a-f]{8} \[/.test(l)).length, 2); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2 Exclude the session's own disputes before applying the query limit
If the two highest-ranked disputed claims belong to the current session, the query returns only those two and
toCheckremoves both. Other eligible disputes are never considered, and stale accepted claims can take their slots despite the disputed-first rule. This affects both repo and room briefings. Apply the session exclusion in SQL before LIMIT, or fetch further eligible disputes after filtering, and add a regression test.