feat(curator): generalise integrity-repair escalation to all invariant kinds#13
Merged
Merged
Conversation
…t kinds
Today only broken wikilinks escalate into the Librarian->Scholar pipeline.
Extend the SAME mechanism (enqueue -> Librarian researches+proposes ->
Scholar executes) and the SAME in-flight concurrency guard to the other
two check_invariants kinds, kind-dispatched rather than copy-pasted:
- overcap_dir: a flat dir over MAX_FLAT_DIR_ENTRIES enqueues a repair
task; the Librarian proposes a split_folder / move_entry rebalance.
- bad_frontmatter: a missing/unparseable/incomplete frontmatter block
enqueues a task; the Librarian proposes an update_entry that
re-serialises valid frontmatter.
check_invariants now projects over a new structured check_invariants_detailed
that carries the (kind, file, target, context) needed to build a RepairTask.
The Scholar's post-write check escalates each over-cap / bad-frontmatter
violation through the existing repair_queue + in-flight guard
(_escalate_invariant_violation), leaving the violation on disk so it
re-detects and re-escalates until fixed (no max-attempts, no give-up).
The Librarian prompt's INTEGRITY-REPAIR section now dispatches on `kind`.
Also audit the Scholar prompt: the APPROVE-OR-VETO + salience-novelty
framing could wrongly veto a repair proposal as "not novel" / "duplicate".
Add an INTEGRITY-REPAIR PROPOSALS section that marks repair-originated
proposals (packets carrying repair_fingerprints) as verify-and-execute, not
novelty-judged, and have the salience filter skip them.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Generalises the just-merged broken-wikilink repair escalation so ALL three
check_invariantskinds flow through the SAME enqueue -> Librarian-proposes -> Scholar-executes pipeline and the SAME in-flight concurrency guard, kind-dispatched (one mechanism, not three copy-pasted paths).overcap_dir— a flat dir overMAX_FLAT_DIR_ENTRIESenqueues a repair task; the Librarian proposes asplit_folder/move_entryrebalance.bad_frontmatter— a missing / unparseable / incomplete frontmatter block enqueues a task; the Librarian proposes anupdate_entrythat re-serialises valid frontmatter.repair_fingerprints) are now explicitly verify-and-execute, not judged for novelty/dedupe, so the APPROVE-OR-VETO + salience-novelty framing can no longer wrongly veto a fix as "not novel"/"duplicate".How it works
scholar_prompt.check_invariants_detailed()returns structuredInvariantViolations carrying(repair_kind, file, target, context);check_invariants()is now a thin string-list projection over it (public contract preserved).repair_queue.RepairTask. The Scholar's post-write_check_invariants_safeescalates each via_escalate_invariant_violation, reusingRepairQueue.enqueue+ the in-flight fingerprint guard. Wikilinks (display-only here) still escalate via the dedicated deterministic repair pass; READMEs stay display-only (reconciler fixes them).review()'sfinally, exactly as for wikilinks.kindwith per-kind repair recipes.Test plan
uv run --frozen ruff check . && uv run --frozen ruff format --check .uv run --frozen pyright(0 errors)uv run --frozen pytest— 583 passed, 90.45% coverage (>=90%)check_invariants_detailedprojection + escalatable/display-only kinds.🤖 Generated with Claude Code