Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge origin/capy/wave18a (b4bc9aa59, #6883 v0.60.275.0) into capy/6865-slug-autoheal
garrytan4d008f48420a
diff --cc CHANGELOG.mdindex b7e7935694,c9e79e1b76..815dd9e6a3--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -10,80 -10,7 +10,80 @@@ credits are retained; no result has beeidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).- ## [0.60.275.0] - 2026-10-17++## [0.60.276.0] - 2026-10-17++**Notes hidden by a stray `slug:` line come back on the next sync, and gbrain now tells you about committed files it never indexed (#6865).** A note can carry a leftover `slug:` line in its frontmatter that names a page that does not exist, often copied from a template or left behind by an import. Sync held those files, and nothing put them back in search on its own. Now the sync itself removes that one line when the slug it names has no page and no file, imports the note under the name its path gives, commits the edit and keeps the old slug as an alias so existing links still work. A line that names a real page is still left for you to decide.++Some files went missing longer ago, before gbrain kept a record of refused files, so incremental sync never looked at them again. A new maintenance check finds committed files with no page and no hold, schedules them for another look, and `gbrain doctor` reports them. It also lists titled folder `index.md` files, which sync skips on purpose; most of the 572 files in the original report were of that kind, and renaming one to a normal note brings it in.++Hold messages now say what gbrain actually found: "decide which page keeps the slug" only appears when the line names a live page, and a hold gbrain has not judged yet never asks a person.++### What you'd see++| Situation | Before | Now |+|---|---|---|+| a held note's `slug:` line names no page and no file | held until the maintenance run or a manual repair | the next managed sync removes the line, imports the note, commits `gbrain: repair frontmatter slug in <path>`; the result's `slug_lines_removed` counts it |+| the line names an existing page (with a file, or database-only) | "decide which page keeps the slug" | the same, now naming the page and labelling a database-only one |+| a held note edited since sync held it, an unfinished sync, or a sync started by a remote job or agent | n/a | left held for the next pass, with the reason in `slug_lines_removed` |+| a committed file an older gbrain refused before refusals became holds | invisible: no page, no hold, no warning | doctor `unindexed_files` names it; `gbrain sources retry-held <id> --unindexed` and the sync it prints import or hold it |+| a titled `investors/fund-a/index.md` | skipped silently | listed as `metafile_skipped` (info only); rename it to `investors/fund-a.md` to import it |+| a slug-conflict verdict an older gbrain recorded | listed for a person | rechecked once by the next sync or maintenance run |++### Things to watch++- The sync looks at at most 200 held files and spends at most 60 seconds per run; the rest wait for the next sync. A hold the content-repair lane has already judged is left to the lane. Nothing runs at upgrade.+- To see what it would do first: `gbrain repair content --source <id> --no-llm` (read-only). To turn it off: `gbrain config set sync.slug_conflicts.auto_remove false` (or pause the whole content-repair lane with `fences.repair.enabled false`). To undo one edit: `git revert` its commit and sync, which holds the file again; the alias stays, so the restored line then names the file's own page and needs a hand edit.+- Before you upgrade, `gbrain sync unblock --source <id> --apply` or `gbrain repair content --source <id>` removes the same lines by hand.++## To take advantage of v0.60.274.0++`gbrain upgrade` should do this automatically. If it didn't, or if `gbrain doctor` warns about a partial migration:++1. **Run the orchestrator manually:**+ ```bash+ gbrain apply-migrations --yes+ ```+2. **Run a sync** (`gbrain sync --source <id> --no-pull`). It removes the stray lines it can and re-reads older verdicts; there is no schema step.+3. **Verify the outcome:**+ ```bash+ gbrain doctor --only git_held_files,unindexed_files+ gbrain stats+ ```+4. **If any step fails or the numbers look wrong,** please file an issue:+ https://github.com/garrytan/gbrain/issues with:+ - output of `gbrain doctor`+ - contents of `~/.gbrain/upgrade-errors.jsonl` if it exists+ - which step broke++ This feedback loop is how the gbrain maintainers find fragile upgrade paths. Thank you.++### Itemized changes++#### Sync-time removal of stray `slug:` lines++- `src/core/repair/slug-autoheal.ts` `healAfterManagedSync` runs once per managed sync from `commands/sync/perform.ts` `performManagedBranch`, after the drain lease is released. It applies only the content-repair lane's deterministic `absent_page` rule (`healAbsentSlugLine` in `repair/slug-conflicts.ts`), bound to the held bytes (`changed_since_hold`) and skipped for a busy path, through the same coordinated `submitManagedFileRepair` write the maintenance run uses. Inside that write the declared slug is checked again: a page, an alias of another page or a file at its path written since the heal read the source refuses it (`changed_since_preview`). Only holds without a current-lane verdict for their bytes are examined.+- The declared slug is the YAML scalar the import reads (a trailing comment, quoting and escapes resolved), for the sync-time heal and the maintenance lane alike.+- The declared slug is recorded as a `slug_aliases` row inside that write (`recordSlugLineAlias`, `page-state/rename-alias.ts`); the receipt carries `declared_alias`.+- Skip reasons on `SyncResult.slug_lines_removed`: `disabled`, `lane_paused`, `remote_authority`, `sync_unfinished`, `not_writable`. Budget: `SLUG_HEAL_MAX_FILES` 200, `SLUG_HEAL_BUDGET_MS` 60 000.+- `sync.slug_conflicts.auto_remove` (default on) is registered in `KNOWN_CONFIG_KEYS`; `gbrain config set` rejects values other than true/false.++#### Unindexed files++- `src/core/persistence/unindexed-files.ts` streams the last synced commit's tree (`git ls-tree`), filters it through discovery's own eligibility (`loadSyncEligibility`, now exported from `sync-discovery.ts`) and compares in batches against pages, holds and scheduled re-screens. Bounded by time and count with a resume cursor (continued only while the target commit and eligibility are unchanged); blobs are screened in slices of at most 32 MiB with the deadline checked between them; an incomplete scan is never reported clean. Results live in `op_checkpoints` (op `unindexed-files`).+- Files a re-screen cannot import are never scheduled: `slug_taken` (the path slug belongs to another page) and `deleted_page` (the page was deleted while the file stayed committed). Doctor names them read-only with a user fix (rename, delete or restore).+- The maintenance cycle phase `unindexed_files` runs one bounded pass per managed Git source and schedules found files with `requestGitHoldRetry`; doctor `unindexed_files` judges the stored result without scanning; `gbrain sources retry-held <id> --unindexed` runs a pass now (`--dry-run` lists only). The scan never runs on the per-sync path.+- `metafile_skipped` counts titled `isSyncMetafile` names (`index.md`, `README.md`, ...) that sync skips by design; read-only, never scheduled.++#### Truthful hold messages and the lane recheck++- `ContentHoldRepairState` gains `lane_version`, `other_codes` and `named_db_only`. `CONTENT_REPAIR_LANE_VERSION` is 2; a verdict without it is re-judged by the lane (`contentHoldDisposition` in `repair/content-lane.ts`) instead of being escalated.+- `slugConflictEscalation` (`persistence/sync-fault-class.ts`) asks a person only for a current-lane verdict that names a live page; `hold-fix.ts` messages name the page and label a database-only one.++### For contributors++- New tests: `test/slug-autoheal-6865.test.ts` (PGLite) and `test/e2e/slug-autoheal-6865-postgres.test.ts` share `test/helpers/slug-autoheal-scenarios.ts`; `test/slug-conflict-verdict-6865.test.ts`; `test/unindexed-files.test.ts`.+- ## [0.60.273.0] - 2026-10-16+ ## [0.60.275.0] - 2026-10-17**Sync stops handing one page's history to another when Git guesses a rename, and background work on a managed brain stops spending write ids it can never use (fix wave 18a).** When you move a note and edit it in the same commit, Git only guesses that it was a move. Two notes made from the same template and moved together could be paired the wrong way round, and sync then carried one page's facts, links and aliases onto the other. Now sync keeps a page across a guessed move only when the files agree: the same `id`, or the same unique `slug:` line or title. Anything else becomes a new page, and the old one stays restorable, with the exact restore command printed and the purge holding it until someone decides. Contributed by @javieraldape (PR #6732, rewritten).diff --cc src/core/behavior-change-notice.tsindex 7fe5913896,6c007fb90f..09401aa2c8--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@@ -742,18 -742,16 +742,18 @@@ export const BEHAVIOR_CHANGES: Readonly{ since: '0.60.274.0', text: '`gbrain sources refresh` now completes once every member source has synced to the refresh target or to a commit on top of it. Before, a commit that landed on the target while the refresh synced left it `syncing`, with the worktree fenced, and `--resume` could not finish it either. A refresh left `syncing` by a crashed process still waits for `gbrain sources refresh <source> --resume` when a later sync went past the target.' },{ since: '0.60.274.0', text: '`gbrain repair file-drift --slug|--request` now resolves a live page whose canonical file is gone from the last commit (a held deletion whose page changed, or a write refused `canonical_file_missing`): `--prefer database` recreates the file from the page, and `--prefer file` soft-deletes exactly that page (purged after 72 h; `gbrain restore <slug> --force` undoes it). Both are preview-bound to the page revision and the file\'s absence, and soft deletes honor the mass-delete valve. A file deleted only in the worktree (still committed) is listed `deletion_uncommitted` and routed to committing the deletion or `gbrain repair ghost-pages`. `gbrain sources reconcile --preview` on a missing file names the same routes, and a held deletion\'s next step is the file-drift preview instead of a reconcile preview that refused. An older gbrain refuses a recreate request and writes nothing.' },// Wave 18a S1 (#6757 #6782 #6729 #6741 #6749).- { since: '0.60.274.0', text: 'Dream synthesis postprocess finds committed outputs by request id through a new online index (`persistence_requests_request_id`, built concurrently on Postgres, covered by `gbrain repair request-indexes`). A statement timeout on that read now defers the postprocess to a later pass (kept in `dream.synthesize.postprocess_pending`, finished without another synthesis call) instead of failing the pass (the replay runs no child job and verifies the output\'s quotes against the current transcript; a quote not found goes to `unverified_claims`); three deferrals in a row add a line to doctor `persistence_request_indexes`, whose messages now say "request-table indexes".' },- { since: '0.60.274.0', text: '`propose_takes` now treats a reply of `[]` followed by prose as an empty extraction and tombstones the page, instead of retrying the paid call every cycle. Pages that were retried forever get a tombstone on their next run. There is no per-page force flag: the tombstone is keyed by a hash of the page body, so any edit to the body re-extracts the page (docs/guides/cron-schedule.md).' },- { since: '0.60.274.0', text: 'An inexact Git rename (a move that also changed the file, reported as R<100) now keeps its page identity only when the files confirm it: the same frontmatter `id` on both sides that no other file or page carries, or, with no id on either side, a `slug:` line or title (the frontmatter `title:`, else the first `# Heading`, compared with the title the brain stores for the old page) that no other file in the sync and no other live page shares; a respelled path that keeps its slug keeps its page unless the ids conflict (#6729). Any other pair is imported as a delete plus an add: the new file starts a fresh page and the old page keeps its facts, links and aliases on its soft-deleted slug. The sync report prints each pair with `gbrain restore <old-slug> --source-id <id> --force`, `gbrain sync status --json` lists it under `identity_downgrades`, doctor `rename_identity_downgrades` names it, and the purge leaves the old page alone, with no time limit, until the pair gets a disposition (the old page restored, or, once the remedy ships, remedied or closed without merging). A new file whose frontmatter `id` uniquely matches a file deleted in the same sync range, with the same file name, title or bytes, is now its rename even when Git did not pair them; a template id reused by an unrelated new note stays a new page.' },- { since: '0.60.274.0', text: 'A file moved and broken in the same commit (unreadable frontmatter, so Git reports an inexact rename) is no longer held with the old page identity: the old page is soft-deleted and recorded as above and the broken file is held as a new file (#6729). An exact move (R100) that is held still keeps the old page identity and `rename_from`. A managed sync refuses `page_identity_changed` (detail `rename_identity_conflict`) when a file would take over a page, or a held rename would carry one, whose frontmatter `id` differs from its own.' },- { since: '0.60.274.0', text: 'A managed sync no longer adopts the one legacy page that folds to a file\'s slug when both carry an explicit frontmatter id and the ids differ: they are different documents, so the file is held `legacy_slug_conflict` with reason `explicit_id_conflict` (#6729, #6727).' },- { since: '0.60.274.0', text: '`gbrain transcripts ingest --since last` now advances past Codex sub-agent rollouts (session_meta source {subagent: ...}, such as the guardian auto-reviewer). They have no user turn by design, so they are reported as "N sub-agent rollouts (no user turns by design)" (JSON: subagentRollouts), not as drift. An ordinary rollout with assistant turns and no user turn is still drift and still holds the watermark.' },- { since: '0.60.274.0', text: 'On a writer-claimed brain, `gbrain transcripts ingest` no longer submits a write request for a session part whose page would not change: an unchanged re-ingest takes no permanent request id. A part with pending projection work, a pending request, a missing or edited canonical file, or a large (segmented) page is still submitted.' },- { since: '0.60.274.0', text: 'On a writer-claimed brain, background writes are refused before any receipt, so they spend no write-request id, when their source cannot publish: the worktree is in recovery, or the claim\'s owner verification fails on the owner host (a missing canonical or coordination path, or a physical root whose owner marker .gbrain-owner.json or reservation is gone or changed; a device-only change is still re-stamped by the write). The refusal is owner_unavailable with the fix `gbrain sources writer status --source <id> --json`, checked once per source per run. Background writes are every write not made from an interactive surface: the autopilot cycle and its maintenance phases (extraction, synthesis, patterns, consolidation, fence and content repair, lint fixes), Minion jobs (sync, extract and the other job handlers), connector syncs, delegated serve syncs started as background, the keep-DB reconcile, autopilot and job managed syncs, and the transcript stale-part delete. Interactive CLI, MCP and repair writes are unaffected; a paused (draining) owner still accepts and replays.' },- { since: '0.60.274.0', text: 'The managed purge (autopilot purge phase, the purge job and `gbrain pages purge-deleted`) submits nothing for a source whose writer needs recovery (reported `writer_not_active` with its state and reason) and parks a page after five failed purges (doctor `purge_parked_pages`: actor agent on the CLI, host_admin remotely). The cycle purge phase reports warn, not fail, for either. `gbrain pages purge-deleted --retry-parked` retries parked pages once; it obeys `--older-than` (a parked page younger than the cutoff is not retried) and the rename-recovery hold, and its preview, its consent text (which names the parked count) and its run come from one selector.' },- { since: '0.60.274.0', text: '`gbrain repair content` / `repair slug-conflicts` now clears a frontmatter_slug_conflict hold deterministically (remove_slug) when the only other change autoFixFrontmatter would make is a style-only NESTED_QUOTES re-quote of a valid JSON-style tag or alias array. Only the slug: line is removed; the array is left as written and listed as style_only in the preview, the run result and the content_repair receipt. Such holds used to stay still_invalid and needed `repair frontmatter --include-ambiguous`. When the lane still cannot clear a hold because the frontmatter needs other fixes, the still_invalid message now names those fix codes (for example NULL_BYTES).' },+ { since: '0.60.275.0', text: 'Dream synthesis postprocess finds committed outputs by request id through a new online index (`persistence_requests_request_id`, built concurrently on Postgres, covered by `gbrain repair request-indexes`). A statement timeout on that read now defers the postprocess to a later pass (kept in `dream.synthesize.postprocess_pending`, finished without another synthesis call) instead of failing the pass (the replay runs no child job and verifies the output\'s quotes against the current transcript; a quote not found goes to `unverified_claims`); three deferrals in a row add a line to doctor `persistence_request_indexes`, whose messages now say "request-table indexes".' },+ { since: '0.60.275.0', text: '`propose_takes` now treats a reply of `[]` followed by prose as an empty extraction and tombstones the page, instead of retrying the paid call every cycle. Pages that were retried forever get a tombstone on their next run. There is no per-page force flag: the tombstone is keyed by a hash of the page body, so any edit to the body re-extracts the page (docs/guides/cron-schedule.md).' },+ { since: '0.60.275.0', text: 'An inexact Git rename (a move that also changed the file, reported as R<100) now keeps its page identity only when the files confirm it: the same frontmatter `id` on both sides that no other file or page carries, or, with no id on either side, a `slug:` line or title (the frontmatter `title:`, else the first `# Heading`, compared with the title the brain stores for the old page) that no other file in the sync and no other live page shares; a respelled path that keeps its slug keeps its page unless the ids conflict (#6729). Any other pair is imported as a delete plus an add: the new file starts a fresh page and the old page keeps its facts, links and aliases on its soft-deleted slug. The sync report prints each pair with `gbrain restore <old-slug> --source-id <id> --force`, `gbrain sync status --json` lists it under `identity_downgrades`, doctor `rename_identity_downgrades` names it, and the purge leaves the old page alone, with no time limit, until the pair gets a disposition (the old page restored, or, once the remedy ships, remedied or closed without merging). A new file whose frontmatter `id` uniquely matches a file deleted in the same sync range, with the same file name, title or bytes, is now its rename even when Git did not pair them; a template id reused by an unrelated new note stays a new page.' },+ { since: '0.60.275.0', text: 'A file moved and broken in the same commit (unreadable frontmatter, so Git reports an inexact rename) is no longer held with the old page identity: the old page is soft-deleted and recorded as above and the broken file is held as a new file (#6729). An exact move (R100) that is held still keeps the old page identity and `rename_from`. A managed sync refuses `page_identity_changed` (detail `rename_identity_conflict`) when a file would take over a page, or a held rename would carry one, whose frontmatter `id` differs from its own.' },+ { since: '0.60.275.0', text: 'A managed sync no longer adopts the one legacy page that folds to a file\'s slug when both carry an explicit frontmatter id and the ids differ: they are different documents, so the file is held `legacy_slug_conflict` with reason `explicit_id_conflict` (#6729, #6727).' },+ { since: '0.60.275.0', text: '`gbrain transcripts ingest --since last` now advances past Codex sub-agent rollouts (session_meta source {subagent: ...}, such as the guardian auto-reviewer). They have no user turn by design, so they are reported as "N sub-agent rollouts (no user turns by design)" (JSON: subagentRollouts), not as drift. An ordinary rollout with assistant turns and no user turn is still drift and still holds the watermark.' },+ { since: '0.60.275.0', text: 'On a writer-claimed brain, `gbrain transcripts ingest` no longer submits a write request for a session part whose page would not change: an unchanged re-ingest takes no permanent request id. A part with pending projection work, a pending request, a missing or edited canonical file, or a large (segmented) page is still submitted.' },+ { since: '0.60.275.0', text: 'On a writer-claimed brain, background writes are refused before any receipt, so they spend no write-request id, when their source cannot publish: the worktree is in recovery, or the claim\'s owner verification fails on the owner host (a missing canonical or coordination path, or a physical root whose owner marker .gbrain-owner.json or reservation is gone or changed; a device-only change is still re-stamped by the write). The refusal is owner_unavailable with the fix `gbrain sources writer status --source <id> --json`, checked once per source per run. Background writes are every write not made from an interactive surface: the autopilot cycle and its maintenance phases (extraction, synthesis, patterns, consolidation, fence and content repair, lint fixes), Minion jobs (sync, extract and the other job handlers), connector syncs, delegated serve syncs started as background, the keep-DB reconcile, autopilot and job managed syncs, and the transcript stale-part delete. Interactive CLI, MCP and repair writes are unaffected; a paused (draining) owner still accepts and replays.' },+ { since: '0.60.275.0', text: 'The managed purge (autopilot purge phase, the purge job and `gbrain pages purge-deleted`) submits nothing for a source whose writer needs recovery (reported `writer_not_active` with its state and reason) and parks a page after five failed purges (doctor `purge_parked_pages`: actor agent on the CLI, host_admin remotely). The cycle purge phase reports warn, not fail, for either. `gbrain pages purge-deleted --retry-parked` retries parked pages once; it obeys `--older-than` (a parked page younger than the cutoff is not retried) and the rename-recovery hold, and its preview, its consent text (which names the parked count) and its run come from one selector.' },+ { since: '0.60.275.0', text: '`gbrain repair content` / `repair slug-conflicts` now clears a frontmatter_slug_conflict hold deterministically (remove_slug) when the only other change autoFixFrontmatter would make is a style-only NESTED_QUOTES re-quote of a valid JSON-style tag or alias array. Only the slug: line is removed; the array is left as written and listed as style_only in the preview, the run result and the content_repair receipt. Such holds used to stay still_invalid and needed `repair frontmatter --include-ambiguous`. When the lane still cannot clear a hold because the frontmatter needs other fixes, the still_invalid message now names those fix codes (for example NULL_BYTES).' },+ // #6865 (GBRA-122): `since` is a placeholder equal to the branch's VERSION, restamped when the merge slot is called.- { since: '0.60.274.0', text: 'A managed `gbrain sync` now removes a stray frontmatter `slug:` line by itself when the slug it names has no page and no file (#6865, the content-repair lane\'s deterministic `absent_page` rule): right after the sync releases its drain lease, each such held file is rewritten without that one line, imported under the slug its path gives, its `frontmatter_slug_conflict` hold cleared and the edit committed as `gbrain: repair frontmatter slug in <path>` with the `gbrain-repair:` trailer, through the same coordinated repair write the maintenance run already used; the declared slug becomes an alias of the page so links written against it keep resolving. At most 200 files and 60 s per sync; the result\'s `slug_lines_removed` counts them and the rest. A line naming an existing page (with a file or database-only, checked again inside the write), a hold the lane already judged, a file edited since sync held it, a source with an unfinished sync, and a sync submitted by a remote job or agent are left held. Preview what the lane would do with `gbrain repair content --source <id> --no-llm`; opt out with `gbrain config set sync.slug_conflicts.auto_remove false` (or pause the whole lane with `fences.repair.enabled false`); undo one edit with `git revert` of its commit and a sync, which holds the file again (the alias stays, so the restored line then names the file\'s own page and needs a hand edit). Nothing runs at upgrade. Slug-conflict hold status now follows what the lane found: "decide which page keeps the slug" appears only when the line names a live page, a hold with no verdict yet never escalates to a person, and a verdict an older gbrain recorded is rechecked once by the next sync or maintenance run instead of being listed for a person.' },++ { since: '0.60.275.0', text: 'A managed `gbrain sync` now removes a stray frontmatter `slug:` line by itself when the slug it names has no page and no file (#6865, the content-repair lane\'s deterministic `absent_page` rule): right after the sync releases its drain lease, each such held file is rewritten without that one line, imported under the slug its path gives, its `frontmatter_slug_conflict` hold cleared and the edit committed as `gbrain: repair frontmatter slug in <path>` with the `gbrain-repair:` trailer, through the same coordinated repair write the maintenance run already used; the declared slug becomes an alias of the page so links written against it keep resolving. At most 200 files and 60 s per sync; the result\'s `slug_lines_removed` counts them and the rest. A line naming an existing page (with a file or database-only, checked again inside the write), a hold the lane already judged, a file edited since sync held it, a source with an unfinished sync, and a sync submitted by a remote job or agent are left held. Preview what the lane would do with `gbrain repair content --source <id> --no-llm`; opt out with `gbrain config set sync.slug_conflicts.auto_remove false` (or pause the whole lane with `fences.repair.enabled false`); undo one edit with `git revert` of its commit and a sync, which holds the file again (the alias stays, so the restored line then names the file\'s own page and needs a hand edit). Nothing runs at upgrade. Slug-conflict hold status now follows what the lane found: "decide which page keeps the slug" appears only when the line names a live page, a hold with no verdict yet never escalates to a person, and a verdict an older gbrain recorded is rechecked once by the next sync or maintenance run instead of being listed for a person.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */