Skip to content

worker: defrag drafts corrections for disputed claims - #90

Merged
vu1n merged 14 commits into
mainfrom
claude/project-thread-ghkdsb
Nov 7, 2026
Merged

vu1n merged 14 commits into
mainfrom
claude/project-thread-ghkdsb

Conversation

@vu1n

@vu1n vu1n commented Nov 7, 2026

Copy link
Copy Markdown
Owner

The hourly defrag gains a rewrite step (worker/src/rewrite.ts). For each disputed claim (a session's standing wrong), a Workers AI text model (@cf/meta/llama-3.3-70b-instruct-fp8-fast, override KYPP_REWRITE_MODEL) drafts a corrected lesson from the writable raters' notes, or answers NONE. The draft passes the S1 write gate and lands as an unstamped candidate under the same subject (agent kypp-defrag, metadata.rewrite_of), so only later used ratings can accept it. The disputed claim is left as it was.

Bounds: at most REWRITE_BATCH (5) claims per pass; one attempt per newest standing wrong (metadata.rewrite_tried), including when the model fails; KYPP_REWRITE=off turns it off. Notes go only to the model, never to a reader, and the prompt marks them untrusted.

Contracts touched: defrag() takes an optional rewriter and returns rewritten; store.toRewrite/ratingNotes/rewriteTried; uses the existing AI binding.

Verification: npm run typecheck; npm test 399/399; new test/rewrite.test.ts (draft filed as candidate, one attempt per wrong and retry on a newer one, control-text draft refused, failing model, no rewriter, answer parsing); featuremap.py check clean.


Generated by Claude Code

@vu1n
vu1n merged commit b2d6d16 into main Nov 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant