Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
chore(content-repair): measured models from the eval, notices, CHANGELOG, TODOS, test weights (#6377)
garrytan93dda4a1c9e8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex fbcc3b31fe..465f1f8172 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,41 @@ credits are retained; no result has been reassigned to another provider. Originaidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [0.60.132.0] - 2026-10-09++**Sync holds clear themselves. gbrain merges repeated fact tables, closes tables that were never ended, and removes stray `slug:` lines on its own; a repair model decides the cases that need judgment; a person is asked only when gbrain says so, in plain words, with the one command that applies what it proposes.**++A managed sync holds a file it cannot import instead of failing the run. Until now every content hold ended with "gbrain will not guess this repair" and an operator editing the file. On one brain five holds sat for 16 hours; the week before, an external agent made hundreds of fence and frontmatter repairs by hand against gbrain's error messages. This release adds a content-repair lane that clears those holds itself, under the preview → hash-bound apply → receipt contract fence repair already uses, and runs it in the maintenance cycle and from `gbrain sync unblock --apply`.++### What you'd see++- Two `## Facts` (or `## Takes`) tables in one section (`repeated_marker`) become one: later rows append in order, byte-identical rows are dropped and recorded, colliding numbers are renumbered with their `superseded by #N` references following, and the second heading goes. The validator proves every original row survived the merge. No model, no cost.+- A table that never got its end marker, with text after it (`unclosed_trailing_content`): on a private page gbrain adds the end marker after the last row. On a world-visible page those trailing lines would become visible to readers, so gbrain never does that unattended: the preview (`gbrain repair fences --source <id> --only <path>`) prints the exact lines and the apply command, and the hold reads `tail_exposure_approval` until you approve. A tail that holds a pipe goes to the repair model, which answers only prose / rows / unsure; rows or unsure is `unclosed_ambiguous_tail` with the exact edit.+- A frontmatter `slug:` naming another page (`frontmatter_slug_conflict`): when nothing can be merged into (no such page, or a page of another type with no title in common) gbrain removes the line itself. Otherwise the model reads both pages and answers remove the line, "these are the same thing, merge into X", or ask a person. A merge is **recommended, never executed**: the hold shows `merge_recommended` with the canonical page in plain words. New kind `gbrain repair slug-conflicts`.+- `gbrain repair content --source <id>` previews the whole lane (fences, then slug conflicts) with one hash per kind; `--apply --expect <h1>,<h2>` applies exactly that; `--max-usd` caps the run's model spend. `gbrain sync unblock --apply` now performs these repairs instead of refusing them and reports each path as `repaired`, `held`, `needs_human` or `skipped`; `--no-repair` restores the old behaviour, `--no-llm` keeps to the free tiers.+- The maintenance cycle gains a `content_repair` phase right after `fence_repair`. Every repair commit carries the trailer `gbrain-repair: <hold_code> <tier> <confidence>` and a receipt with the sha256 before and after; `git revert` of that commit restores the file and the hold re-screens.+- Which model may judge a slug conflict is measured, not assumed: `claude-opus-5-5`, `gpt-6.1-sol` and `claude-sonnet-5-5` each gave zero harmful answers on 48 preregistered pairs (never deleted a true duplicate's slug, never merged two different pages) and recognised 92%, 85% and 80% of true duplicates. `models.content_repair` overrides; the fence-repair caps (`fences.repair.max_usd_per_page` $0.30, `fences.repair.max_usd_per_day` $1.00) and ledger govern the whole lane, `fences.repair.llm false` turns its model tier off.++### What to watch for++- Fence merging and the private-page close also run on write paths under `fences.normalize` (default on), as every lossless Tier 1 rule does. A page that previously refused with `repeated_marker` now imports merged.+- `gbrain sync unblock --apply` writes repairs; before this release it refused repair-class holds and wrote nothing. Use `--no-repair` for the old behaviour.+- A hold the lane decided needs a person (`merge_recommended`, `content_repair_needs_human`, `tail_exposure_approval`, a manual fence reason) now reports `needs_human: true` in `gbrain sync status` with the paragraph in `human_reason`, and `unblock` lists it instead of retrying it.+- Page merges are not executed in this release; the hold names the canonical page and nothing is changed until a person merges by hand. The executor is a follow-up (TODOS.md).++### Itemized changes++- **`merge_fences` (`src/core/fence-repair/merge.ts`, `structure.ts`, `validate.ts`, `receipt.ts`).** Tier 1 merges balanced same-kind fences in one section; the validator pairs merged rows through the mapping (gate (e) accepts exactly the recorded duplicates; (b), (c), (d), (f) run per mapped row); the receipt carries occurrence identities. `FENCE_RULES_VERSION` 3 re-screens older holds.+- **`close_fence_trailing` and the tail classifier (`structure.ts`, `llm-tail.ts`, `repair-tiers.ts`, `hold-fix.ts`).** Gate (g) admits exactly the trailing lines the fix shows; the structural rule admits that fix only on a private page or under `approveTailExposure`, which explicit previews and `--expect` applies carry and unattended runs never do. New reasons `tail_exposure_approval` (actor user) and `unclosed_ambiguous_tail`; `unclosed_trailing_content` is now the Tier 3 tail question.+- **`slug-conflicts` kind (`src/core/repair/slug-conflicts.ts`, `src/core/content-repair/*`).** Alias-resolved identity, the two deterministic rules, the judgment prompt and parser (`JUDGMENT_PROMPT_VERSION` 1), the model call under `FENCE_REPAIR_LEDGER` with a memo keyed on both participants, `content_repair` receipts and the commit trailer through the coordinated `managed_file_repair` intent. Hold metadata gains `content_repair` (codes and slugs only), kept across a re-screen of the same bytes; `sync status` renders the paragraph from templates.+- **The lane (`src/core/repair/content-lane.ts`, `src/commands/repair-content.ts`, `src/core/cycle/content-repair.ts`, `sync-status.ts`).** `gbrain repair content`, the `content_repair` phase, `unblock --apply` repairs with structured per-path outcomes, and every hold surface routing fence and slug-conflict holds to the lane. An empty preview's hash binds "nothing to apply", so a lane apply with one hash per kind succeeds when a kind has no candidates.+- **Eval (`evals/content-repair-judgment/`).** 48 pairs, preregistration, harness, scorer; verdict mirrored in gbrain-evals.++### For contributors++- `test/fence-repair-merge.test.ts`, `test/fence-repair-llm-tail.test.ts`, `test/repair-slug-conflicts.test.ts`, `test/content-repair-judgment.test.ts`, `test/repair-content.test.ts`, `test/cycle-content-repair.test.ts`, `test/eval-content-repair-judgment.test.ts`; `sync-status-unblock`, `persistence-sync-holds`, `fence-repair-normalize`, `fence-repair-validate`, `fence-repair-reasons`, `sync-hold-surfaces` extended. Goldens regenerated: `test/fixtures/goldens/exports/types.json` (new codes in the `canonical` union, `RepairResult.preview_hash`, `outcome_items[].llm_usd`).+- Plan and review record: `docs/plans/2026-10-09-001-fix-content-repair-lane-6377-plan.md`.+## [0.60.130.0] - 2026-10-09**`gbrain import` is twice as fast, `gbrain extract all --source db` four times, and a managed `gbrain sync` stops running Git once per page. Every page, chunk, link and timeline row comes out the same.**diff --git a/TODOS.md b/TODOS.mdindex f02bacd035..31219b0752 100644--- a/TODOS.md+++ b/TODOS.md@@ -4,6 +4,7 @@Deferred by the plan (`docs/plans/2026-10-09-001-fix-content-repair-lane-6377-plan.md`, §2 B4 and §8 rows 4-7). The lane recommends a page merge and never executes one; interpretive frontmatter fixes stay consent-gated.+- [ ] **P3 — Judgment prompt v2: reciprocal duplicate notes mean agreement.** **What:** in the 2026-10-09 eval (gbrain-evals `docs/benchmarks/2026-10-09-content-repair-judgment.md`) nearly every true duplicate the models deferred was a pair whose two hygiene notes each read "Duplicate of the other"; the `why` sentences say the models read the identity as the same but the notes as disagreeing about which page is primary (prompt rule 2 → rule 8). **Fix:** a rule in `src/core/content-repair/judgment.ts` that treats reciprocal notes as agreement on identity (the canonical is then the page the path slug names, or the one with more content), bump `JUDGMENT_PROMPT_VERSION`, rerun the preregistered eval under the new version and update `CONTENT_REPAIR_MEASURED_MODELS` from it. **Effort:** S.- [ ] **P2 — A page merge executor for `merge_recommended` holds.** **What:** a `frontmatter_slug_conflict` hold whose two pages describe the same thing ends in `merge_recommended` (`meta.content_repair.action: merge_into`, the canonical slug on the hold, the paragraph in `sync status`), and a person merges the unique sections by hand. The only merge primitive is the phantom-redirect shape (`cycle/phantom-redirect.ts`, `phantom-redirect-managed.ts`), which refuses custom frontmatter and timeline residue; `deletePageThrough` is best-effort and takes no commit subject. **Fix (Codex's requirements, outside review of the plan):** a coordinated two-page intent that binds both page ids, both revisions, the source incarnation, the owner epoch and both file hashes, so a concurrent writer on either page fails the merge instead of being overwritten; withdrawals moved before facts (a withdrawn claim must stay withdrawn after the merge); metadata, visibility, tags and timeline rows preserved or the merge refused (never silently dropped, never loosened); a revision-bound deletion of the duplicate with a redirect alias left behind; database-aware recovery for a merge that dies between the two writes (the recovery path finds both halves from the receipt, not from the files); and a concurrent-writer test that edits the duplicate between the plan and the apply and proves nothing is lost. The eval's hard-failure rule (`evals/content-repair-judgment/`) gates which model may recommend a merge; the executor runs only on a recommendation the user approved by hash. Until then `gbrain sync status` names the canonical page and nothing is merged.- [ ] **P3 — Unattended interpretation of recoverable frontmatter.** **What:** the issue's brain needed 198 YAML frontmatter repairs in one week (`invalid_frontmatter` with `needs_interpretation`: folded title lines, duplicated keys, unclosed lists), each applied by an external agent against `gbrain repair frontmatter --include-ambiguous`; the lane leaves them consent-gated because every one changes what the file says. **Fix:** classify the recoverable shapes whose interpretation is unique (a continuation line that can only belong to the previous key, a duplicate key with byte-identical values) and let the lane apply those unattended with a receipt, keeping the rest (`ambiguous_identity_key`, `ambiguous_protected_key`, a duplicate key with two values) on the hash-bound consent path; measure on the issue's week of repairs before turning any shape on by default.diff --git a/scripts/test-weights.json b/scripts/test-weights.jsonindex 3594956e34..2de4fbd877 100644--- a/scripts/test-weights.json+++ b/scripts/test-weights.json@@ -485,6 +485,7 @@"test/console-prefix.test.ts": 2,"test/consolidate-valid-until.test.ts": 583,"test/content-hash-parity-3694.test.ts": 391,+ "test/content-repair-judgment.test.ts": 200,"test/content-sanity-gbrain-fences-5822.test.ts": 446,"test/content-sanity-literals.test.ts": 4,"test/content-sanity.test.ts": 15,@@ -551,6 +552,7 @@"test/cycle-auto-think-config-zero.test.ts": 1,"test/cycle-consolidate-threshold-5363.test.ts": 365,"test/cycle-consolidate.test.ts": 1999,+ "test/cycle-content-repair.test.ts": 3000,"test/cycle-conversation-facts-backfill.test.ts": 3650,"test/cycle-date-consistency.test.ts": 431,"test/cycle-date.test.ts": 2,@@ -916,6 +918,7 @@"test/eval-capture.test.ts": 5,"test/eval-chronicle.test.ts": 1700,"test/eval-compare.test.ts": 169,+ "test/eval-content-repair-judgment.test.ts": 600,"test/eval-contradictions-auto-supersession.test.ts": 4,"test/eval-contradictions-cache.test.ts": 2820,"test/eval-contradictions-calibration.test.ts": 1,@@ -1158,7 +1161,9 @@"test/fence-repair-attempts.test.ts": 327,"test/fence-repair-config.test.ts": 1464,"test/fence-repair-fixtures.test.ts": 950,+ "test/fence-repair-llm-tail.test.ts": 3000,"test/fence-repair-llm.test.ts": 1515,+ "test/fence-repair-merge.test.ts": 400,"test/fence-repair-normalize.test.ts": 35,"test/fence-repair-raw-rows.test.ts": 8,"test/fence-repair-reasons.test.ts": 1,@@ -2106,6 +2111,7 @@"test/rename-slug-alias.test.ts": 923,"test/repair-captured-facts.test.ts": 2758,"test/repair-command.test.ts": 13483,+ "test/repair-content.test.ts": 4000,"test/repair-conversation-labels.test.ts": 5645,"test/repair-embedding-effects.test.ts": 2716,"test/repair-explicit-only.test.ts": 502,@@ -2119,6 +2125,7 @@"test/repair-jsonb.test.ts": 10,"test/repair-llm-cost.test.ts": 2419,"test/repair-orphan-children-5216.test.ts": 421,+ "test/repair-slug-conflicts.test.ts": 9000,"test/repair-stale-atoms.test.ts": 1888,"test/repair-take-supersession.test.ts": 2019,"test/repair-timeline-comments.test.ts": 608,diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex d09f695e87..e554621e6f 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -66,6 +66,7 @@ import {} from './ai/chat-fallback-planes.ts';import { mergedProviderEnv } from './ai/provider-env.ts';import { FENCE_REPAIR_MEASURED } from './fence-repair/measured.ts';+import { CONTENT_REPAIR_MEASURED } from './content-repair/measured.ts';/** The measured re-ingest page multiplier, as prose (scripts/measure-transcript-split-cost.ts: 4 → 27 pages on a 1 MB session). */export const TRANSCRIPT_REINGEST_MULTIPLIER = 'about 6.75x';@@ -353,8 +354,8 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }// #6377 (GBRA-72). `since` is a placeholder equal to the branch's VERSION so a fresh install's baseline covers it; the integrator sets it// to the merge-slot stamp (master plus one PATCH) by hand, because release:restamp rewrites VERSION, CHANGELOG and TODOS, never this table.{ since: '0.60.130.0', text: 'The maintenance run now repairs the content holds managed sync records, by itself and without consent: two facts or takes fences of one kind in one section are merged into one (exact duplicate rows dropped, colliding numbers renumbered, the validator proving every original row survived), an unclosed fence followed by text on a private page is closed after its last row, and a stray frontmatter `slug:` that names no page (or a page of a different type with no title in common) is removed; each repair is one committed file write carrying the trailer `gbrain-repair: <hold_code> <tier> <confidence>` and a receipt, so `git revert` of that commit undoes it. The `fence_repair` phase runs the fences, the new `content_repair` phase right after it runs the rest of the lane (`gbrain repair content --source <id>` previews both); `gbrain config set fences.repair.enabled false` pauses all of it.' },- { since: '0.60.130.0', text: 'The repair model (`models.fence_repair`, or `models.content_repair` for slug conflicts) now also classifies the cases the deterministic rules mark ambiguous, under the same `fences.repair.max_usd_per_page` ($0.30) and `fences.repair.max_usd_per_day` ($1.00) caps and one shared daily ledger: whether the lines after an unclosed fence on a world-visible page are prose or table rows, and whether two pages a `slug:` line ties together are the same thing. The model chooses among coded answers and never writes text: a world-page close that would expose hidden lines waits for your hash-bound approval (`tail_exposure_approval`), a page merge is recommended, never executed (`merge_recommended` names the canonical page), and an undecided case is `needs_human`. `gbrain config set fences.repair.llm false` turns the model tier off for the whole lane; `--no-llm` keeps one run to the free tiers.' },- { since: '0.60.130.0', text: '`gbrain sync unblock --source <id> --apply` now writes: for every held file the content-repair lane clears (`invalid_fence`, and `frontmatter_slug_conflict` once its kind ships) it runs the lane on exactly those paths as one bounded hash-bound apply under the `fences.repair` caps, prints a receipt per file and schedules the re-screen, and reports each path as `repaired`, `held`, `needs_human` or `skipped` with the reason and its next step; a hold whose stored state waits on a person, your spend decision or the owner host is listed, never retried. Before this release unblock refused every repair-class hold. `--no-llm` keeps the repairs to the free tiers; `--no-repair` restores the refuse-only behaviour. `gbrain sync status` now reports a fence hold the lane marked manual or paid, and a recommended merge, as `needs_human` with the paragraph in `human_reason`.' },+ { since: '0.60.130.0', text: `The repair model (\`models.fence_repair\`, or \`models.content_repair\` for slug conflicts) now also classifies the cases the deterministic rules mark ambiguous, under the same \`fences.repair.max_usd_per_page\` ($0.30) and \`fences.repair.max_usd_per_day\` ($1.00) caps and one shared daily ledger: whether the lines after an unclosed fence on a world-visible page are prose or table rows, and whether two pages a \`slug:\` line ties together are the same thing. The model chooses among coded answers and never writes text: a world-page close that would expose hidden lines waits for your hash-bound approval (\`tail_exposure_approval\`), a page merge is recommended, never executed (\`merge_recommended\` names the canonical page), and an undecided case is \`needs_human\`. ${CONTENT_REPAIR_MEASURED} \`gbrain config set fences.repair.llm false\` turns the model tier off for the whole lane; \`--no-llm\` keeps one run to the free tiers.` },+ { since: '0.60.130.0', text: '`gbrain sync unblock --source <id> --apply` now writes: for every held file the content-repair lane clears (`invalid_fence` and `frontmatter_slug_conflict`) it runs the lane on exactly those paths as one bounded hash-bound apply under the `fences.repair` caps, prints a receipt per file and schedules the re-screen, and reports each path as `repaired`, `held`, `needs_human` or `skipped` with the reason and its next step; a hold whose stored state waits on a person, your spend decision or the owner host is listed, never retried. Before this release unblock refused every repair-class hold. `--no-llm` keeps the repairs to the free tiers; `--no-repair` restores the refuse-only behaviour. `gbrain sync status` now reports a fence hold the lane marked manual or paid, and a recommended merge, as `needs_human` with the paragraph in `human_reason`.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */diff --git a/src/core/content-repair/measured.ts b/src/core/content-repair/measured.tsindex 6fef6ad2cb..fdc1f58c1c 100644--- a/src/core/content-repair/measured.ts+++ b/src/core/content-repair/measured.ts@@ -6,13 +6,18 @@* rule (zero hard failures: no `remove_slug` on a true duplicate, no* `merge_into` on an unrelated pair or with the wrong canonical; at least 80%* `merge_into` with the right canonical on true duplicates), best first,- * ties to the cheaper model. Until that eval has run it equals the fence- * repair's measured list (both frontier models); the content-repair eval- * fills it in its own PR. With `models.content_repair` and- * `models.fence_repair` unset, the judgment uses the first one the brain has- * a provider key for; with none, the model tier stays off- * (`no_measured_model`).+ * ties to the cheaper model. Measured 2026-10-09 on 48 synthetic pairs+ * (25 true duplicates, 10 stray slugs, 8 adversarial, 5 ambiguous), three+ * runs per model, prompt v1: every listed model gave zero hard failures in+ * 144 pair runs, removed every stray slug, deferred every ambiguous pair and+ * never merged an adversarial pair; true-duplicate recognition 92.0%,+ * 85.3% and 80.0%. Verdict mirrored in gbrain-evals+ * (docs/benchmarks/2026-10-09-content-repair-judgment.md). The next eval run+ * updates this list with the prompt version it measured. With+ * `models.content_repair` and `models.fence_repair` unset, the judgment uses+ * the first one the brain has a provider key for; with none, the model tier+ * stays off (`no_measured_model`).*/-import { FENCE_REPAIR_MEASURED_MODELS } from '../fence-repair/measured.ts';+export const CONTENT_REPAIR_MEASURED_MODELS: readonly string[] = ['anthropic:claude-opus-5-5', 'openai:gpt-6.1-sol', 'anthropic:claude-sonnet-5-5'];-export const CONTENT_REPAIR_MEASURED_MODELS: readonly string[] = FENCE_REPAIR_MEASURED_MODELS;+export const CONTENT_REPAIR_MEASURED = 'On 48 synthetic slug-conflict pairs over three runs, each measured default model gave no harmful answer (never deleted the slug of a true duplicate, never merged two different pages) and recognised at least 80% of true duplicates, deferring the rest to a person.';