Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Merge remote-tracking branch 'origin/master' into capy/6712-pr4b

garrytan5781d72022dd
diff --cc .claude-plugin/plugin.json
index a085e9825a,a085e9825a..be7ffabf14
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@@ -1,6 -1,6 +1,6 @@@
{
"name": "gbrain",
-- "version": "0.60.317.0",
++ "version": "0.60.318.0",
"description": "Personal knowledge brain for your coding agent — hybrid search, synthesis, graph traversal, and durable cross-session memory over Postgres/PGLite with pgvector, plus a curated brain-first skill set.",
"author": {
"name": "Garry Tan",
diff --cc .codex-plugin/plugin.json
index 8a66e1251c,8a66e1251c..899059e8ce
--- a/.codex-plugin/plugin.json
+++ b/.codex-plugin/plugin.json
@@@ -1,6 -1,6 +1,6 @@@
{
"name": "gbrain",
-- "version": "0.60.317.0",
++ "version": "0.60.318.0",
"description": "Personal knowledge brain for your coding agent — hybrid search, synthesis, graph traversal, and durable cross-session memory over Postgres/PGLite with pgvector, plus a curated brain-first skill set.",
"author": {
"name": "Garry Tan",
diff --cc BOOTSTRAP_FOR_AGENTS.md
index 9030d5b761,9030d5b761..61f526787b
--- a/BOOTSTRAP_FOR_AGENTS.md
+++ b/BOOTSTRAP_FOR_AGENTS.md
@@@ -1,4 -1,4 +1,4 @@@
--<!-- gbrain-runbook-stamp: 0.60.317.0 -->
++<!-- gbrain-runbook-stamp: 0.60.318.0 -->
<!-- This stamp must equal the VERSION file at every release; CI enforces it
(scripts/check-bootstrap-tag.sh). `gbrain bootstrap status` compares it to
the installed binary and warns on skew. -->
diff --cc CHANGELOG.md
index 57766af607,2f3348c142..e39698ecf7
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -10,30 -10,18 +10,42 @@@ credits are retained; no result has bee
identifiers and attribution are available in the pre-removal Git revision
`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).
- ## [0.60.317.0] - 2026-10-19
++## [0.60.318.0] - 2026-10-19
+
+**A managed `gbrain sync` of an ordinary (non-company) source now compares the files at HEAD with what the brain holds, instead of replaying commits, so a reset, a revert, a rewritten history or a lost run can no longer leave pages behind, and one bad file holds only itself.** Each pass reads the committed tree, the index and the database, admits only the files whose page differs, proves nothing moved underneath it, and records the checkpoint inside the last import's own transaction. An idle sync with nothing new returns in well under a second.
+
+### What changed
+
+| Situation | Before | Now |
+|---|---|---|
+| History rewritten, reset or reverted, or a sync interrupted | replayed `last_commit..HEAD`; pages could be missed or resurrected | every file at HEAD is compared with its page and import record; what differs is admitted |
+| An idle sync with nothing new | about 3 s on a large Postgres brain (57 ms round trips) | about 0.75 s: no level read at all |
+| One odd file (unreadable, a NUL byte, a broken alias list, a page whose identity changed, a write that fails) | stopped the whole source | that file alone is held with its own code and fix; the rest syncs |
+| The checkpoint after an import | its own write request and transactions | carried by the round's last import publication (fewer statements and transactions per run) |
+| First sync after activating a classic brain with 100k pages on Postgres | did not finish | converges in one pass (about 45 s) |
+| A sync that would delete more than half of a source's pages | ran | refused until confirmed, as `repair ghost-pages` already does |
+
+### New for operators
+
+- `gbrain repair file-drift --held --side <side> [--state <state>]` resolves held file-drift pages one decision at a time.
+- `gbrain repair legacy-twins --source <id>` merges page pairs an older gbrain forked from one file (preview first, then `--apply --expect <hash>`).
+- `sync.admission` (`normal`, `imports_only`, `classify_only`) narrows what a managed sync admits; doctor warns while it is restricted.
+- `gbrain sync status --json` reports `convergence` for a managed source.
+
+No schema migration. Company-brain sources keep their existing sync path.
+
+ ## [0.60.317.0] - 2026-10-19
+
+ **Two CI flakes are closed at their source, and a stuck native safety suite now leaves a log instead of a silent timeout.** `test-reads-source-smell` failed with `ENOENT` when `import-file.test.ts` removed its scratch directory from `test/` mid-walk; scratch now lives in the system temp directory and a lint rule keeps it there. The native data-safety suites no longer wait inside `Bun.spawnSync`, where Bun 1.4.0 to 1.4.2 can poison a process (oven-sh/bun#34069).
+
+ ### What changed
+
+ | Situation | Before | Now |
+ |---|---|---|
+ | A unit test needing a scratch directory | `import-file` and `files` made theirs inside `test/`, racing `test-reads-source-smell`'s walk (15 of 82 probe runs failed) | both use `mkdtempSync(join(tmpdir(), ...))` (0 of 79); `check-test-isolation` rule R8 refuses a new scratch path inside the test tree |
+ | `persistence-sync-origin-native` and `export-publication-native` on Bun 1.4.0 | 21 untimed sync `git` calls and four sync child runs, each a window for the spawnSync poisoning that spins every later test to its 180 s deadline | every child process is awaited, with the same assertions |
+ | A native data-safety suite that stalls | ran until the 15-minute job timeout, which kept no log | named, its process table and (macOS) a native stack sampled, and killed at 300 s; the step fails |
+
## [0.60.316.0] - 2026-10-19
**A commit is searchable within about a second whenever any gbrain process is running, and a sync request is never dropped.** Before this, only `gbrain serve` watched for commits: managed sources only, after a 3 s debounce, and a wake could be lost. Classic sources never synced on commit, a lone `gbrain jobs work` took 5 s, and the autopilot daemon waited for its next wall-clock tick (up to 7 minutes). `sync.on_commit` is still off by default.
diff --cc VERSION
index 87da3afbc3,87da3afbc3..e63f0ef4b6
--- a/VERSION
+++ b/VERSION
@@@ -1,1 -1,1 +1,1 @@@
--0.60.317.0
++0.60.318.0
diff --cc openclaw.plugin.json
index bdfd279d1d,bdfd279d1d..4c69b5a668
--- a/openclaw.plugin.json
+++ b/openclaw.plugin.json
@@@ -1,7 -1,7 +1,7 @@@
{
"id": "gbrain-context-engine",
"name": "gbrain",
-- "version": "0.60.317.0",
++ "version": "0.60.318.0",
"description": "Personal knowledge brain with Postgres + pgvector hybrid search",
"family": "bundle-plugin",
"kind": "context-engine",
diff --cc package.json
index acc2a338dc,acc2a338dc..86911a78ad
--- a/package.json
+++ b/package.json
@@@ -241,7 -241,7 +241,7 @@@
"bun": ">=1.4.0"
},
"license": "MIT",
-- "version": "0.60.317.0",
++ "version": "0.60.318.0",
"overrides": {
"@ai-sdk/provider-utils": "4.0.56",
"@hono/node-server": "^2.0.5",
diff --cc plugin-variants/gbrain-coding/.claude-plugin/plugin.json
index b045f1e618,b045f1e618..339b2d652f
--- a/plugin-variants/gbrain-coding/.claude-plugin/plugin.json
+++ b/plugin-variants/gbrain-coding/.claude-plugin/plugin.json
@@@ -1,6 -1,6 +1,6 @@@
{
"name": "gbrain-coding",
-- "version": "0.60.317.0",
++ "version": "0.60.318.0",
"description": "Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant. (persona variant of the gbrain plugin — 21 skills)",
"author": {
"name": "Garry Tan",
diff --cc plugin-variants/gbrain-coding/.codex-plugin/plugin.json
index 4131adc370,4131adc370..6db0db9611
--- a/plugin-variants/gbrain-coding/.codex-plugin/plugin.json
+++ b/plugin-variants/gbrain-coding/.codex-plugin/plugin.json
@@@ -1,6 -1,6 +1,6 @@@
{
"name": "gbrain-coding",
-- "version": "0.60.317.0",
++ "version": "0.60.318.0",
"description": "Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant. (persona variant of the gbrain plugin — 21 skills)",
"author": {
"name": "Garry Tan",
diff --cc plugin-variants/gbrain-coding/README.md
index c6c5ae914a,c6c5ae914a..25fd71e35d
--- a/plugin-variants/gbrain-coding/README.md
+++ b/plugin-variants/gbrain-coding/README.md
@@@ -1,4 -1,4 +1,4 @@@
--<!-- gbrain-plugin-tree-stamp: 0.60.317.0 -->
++<!-- gbrain-plugin-tree-stamp: 0.60.318.0 -->
# gbrain-coding (generated persona variant — do not hand-edit)
Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant.
diff --cc plugin-variants/gbrain-daily/.claude-plugin/plugin.json
index b176ea5377,b176ea5377..b03c51b641
--- a/plugin-variants/gbrain-daily/.claude-plugin/plugin.json
+++ b/plugin-variants/gbrain-daily/.claude-plugin/plugin.json
@@@ -1,6 -1,6 +1,6 @@@
{
"name": "gbrain-daily",
-- "version": "0.60.317.0",
++ "version": "0.60.318.0",
"description": "Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant. (persona variant of the gbrain plugin — 20 skills)",
"author": {
"name": "Garry Tan",
diff --cc plugin-variants/gbrain-daily/.codex-plugin/plugin.json
index 5d167aa489,5d167aa489..3c023f4951
--- a/plugin-variants/gbrain-daily/.codex-plugin/plugin.json
+++ b/plugin-variants/gbrain-daily/.codex-plugin/plugin.json
@@@ -1,6 -1,6 +1,6 @@@
{
"name": "gbrain-daily",
-- "version": "0.60.317.0",
++ "version": "0.60.318.0",
"description": "Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant. (persona variant of the gbrain plugin — 20 skills)",
"author": {
"name": "Garry Tan",
diff --cc plugin-variants/gbrain-daily/README.md
index 738fbbe2a9,738fbbe2a9..b4a478fcbf
--- a/plugin-variants/gbrain-daily/README.md
+++ b/plugin-variants/gbrain-daily/README.md
@@@ -1,4 -1,4 +1,4 @@@
--<!-- gbrain-plugin-tree-stamp: 0.60.317.0 -->
++<!-- gbrain-plugin-tree-stamp: 0.60.318.0 -->
# gbrain-daily (generated persona variant — do not hand-edit)
Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant.
diff --cc plugin/README.md
index 2c24cbade9,2c24cbade9..1d05cd74a8
--- a/plugin/README.md
+++ b/plugin/README.md
@@@ -1,4 -1,4 +1,4 @@@
--<!-- gbrain-plugin-tree-stamp: 0.60.317.0 -->
++<!-- gbrain-plugin-tree-stamp: 0.60.318.0 -->
# gbrain plugin skill tree (generated — do not hand-edit)
This tree is the curated skill set for the gbrain Codex and Claude Code
diff --cc src/core/behavior-change-notice.ts
index 72d5be789e,155b310a47..ac2420a630
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@@ -974,40 -974,6 +974,40 @@@ export const BEHAVIOR_CHANGES: Readonly
{ since: '0.60.316.0', text: 'The autopilot daemon dispatches a freshness sync when a checkout\'s HEAD differs from the commit its source last synced, at the next tick instead of after the 5-minute wall-clock interval (which stays as the backstop), once per HEAD and never in the middle of a rebase or merge; classic and managed sources alike. With `sync.on_commit` on, the daemon also reads every checkout\'s HEAD between ticks (every 3 s, git only; `GBRAIN_AUTOPILOT_HEAD_PROBE_MS`) and queues the sync within seconds.' },
{ since: '0.60.316.0', text: 'On Postgres, `gbrain jobs work` starts a persistence consumer at boot (#7002), so queued persistence effects drain after a `serve` stops even while the worker is idle. It joins the existing election: with `persistence.single_consumer` on it waits beside a live owner and takes over when that owner stops; with the switch off (the default) a worker beside a `serve` runs its own full consumer, as every resident process already does, and doctor `two_consumers_on_host` lists it. A queued sync job now wakes an idle worker at once: LISTEN on a direct session (one extra connection), a 1 s sync-queue read behind a transaction pooler; `GBRAIN_WORKER_SYNC_WAKE=0` turns it off.' },
{ since: '0.60.316.0', text: '`gbrain autopilot --status` grades a running daemon from its own schedule (#7003): the daemon writes `autopilot.heartbeat.json` beside its lock with its next tick, so a healthy daemon on a long adaptive sleep no longer reads `stale` (exit 1); a missing or outdated sidecar falls back to the interval-flag rule. `--status --json` adds `stale_after_source` (`daemon` or `flag`) and `next_tick_at`.' },
+ // #6712 PR 4b (the level-triggered sync pass, design v3.2 §13) and #6885. `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.
- { since: '0.60.317.0', text: 'On a managed brain a plain `gbrain sync` of a non-company source no longer imports only `last_commit..HEAD`: each pass compares every file at HEAD with what the database absorbed (the page and its import record) and admits what differs, so out-of-band changes (a reset or revert, a rewritten history, a lost manifest, an interrupted run) converge on the next plain sync with no flag. When nothing moved since the last converged pass (same HEAD, parser, schema pack and selection, nothing open), the tick is idle and only `last_sync_at` changes; a full comparison still runs at least every 200 passes or 24 hours. A pass uses at most 4 rounds. Company-brain sources keep their cursor.' },
- { since: '0.60.317.0', text: 'In committed mode (the default) a managed sync never imports a dirty working copy, as before: the level-triggered pass keeps the cursor path\'s guarantee and never adopts or writes over such a file either. When the committed file is unchanged since its import, the uncommitted edit is left alone and nothing is held; when the commit moved under an uncommitted edit, the file is held `worktree_dirty` and the page and the edit stay as they are. Commit or restore the file and sync again.' },
- { since: '0.60.317.0', text: 'A page deleted in the database is no longer brought back by a managed sync from a file that is still committed, even after `gbrain delete --purge` or a mirrored purge replay: a purge now leaves a deletion marker (the file versions the brain held) while the file is still in `last_commit` or on disk, and an unchanged file then counts as synced. A file that changed after its page was deleted is held `file_drift` with side `deleted` and state `tombstone_edited` (soft-deleted) or `purged_differs` (purged, naming its slug), and the rest of the source syncs; `gbrain repair file-drift --held --side deleted --state <state>` resolves it. A full pass retires the marker once the file has left both the commit and the disk, so a new file at that path imports as a new page. A page purged before this release has no such marker, and `--full` can still import its file.' },
- { since: '0.60.317.0', text: '`storage.keep_db` is now applied by the managed sync pass itself on the brain host, and the separate keep_db worker that resident owners ran every 10 minutes is retired. A page under a keep_db prefix whose file is clean in the commit gets the database-wins write when its database copy moved (whether or not the file changed too); the write is bound to the committed bytes and the page revision the pass read, so a later edit refuses it. A file with uncommitted changes never gets a database-wins write: it is held like any dirty file. A pass admits at most 200 of these writes; the rest wait as `keep_db_pending`, and the next sync runs a full pass that admits them. While `sync.admission` is not `normal` they wait as `paused_keep_db`. Remote callers never write them.' },
- { since: '0.60.317.0', text: 'A managed sync that would delete more than half of a source\'s file-backed pages (on a source with more than 20) no longer applies those deletes: it writes one withheld record (count, ratio, a hash of the set and up to 20 sample paths), imports everything else, holds no page and still advances `last_commit`. `gbrain sync status` reads `blocked` / `deletes_withheld` with the dry run (`gbrain sync --source <id> --dry-run --json`) as its next step, and `convergence.deletes_withheld` carries the record. If the checkout is wrong or incomplete, restore it and sync; if the deletion is intended, run `GBRAIN_ALLOW_MASS_RECONCILE=1 gbrain sync --source <id>` on the brain host, which applies the deletes and clears the record. Remote callers never apply them.' },
- { since: '0.60.317.0', text: '`gbrain sync status --json` on a managed source now reports the live pass as `convergence` (`dry_run: false`) on a plain status too, read from the pass row: its kind, outcome, stop reason, round, candidates, settled and remaining counts, held Decisions by side, `db_ahead`, `legacy_unverified`, keep_db writes, a withheld mass delete, the open episode, `not_converged_streak` and `classes`, where each class names who acts (`none`, `owner` or `repair`; `gbrain sync status --help` lists them). New field `admission` (`sync.admission`\'s value, `set_at`, `effective`) and new reasons `pass_unfinished`, `not_converged`, `settle_mismatch`, `deletes_withheld`, `selection_scoped` and `admission_paused`; a source is never `synced` while its newest pass is open or ended unconverged. A non-company source has no cursor, so `run_id`, `cursor`, `rate_pages_per_min` and `eta_seconds` read null there. Held `file_drift` files in `gbrain sources status --json` and in sync results carry `side` (`both`, `unknown`, `deleted`) and, for a deleted side, `state`.' },
- { since: '0.60.317.0', text: 'A file that a managed sync settles at the same level in 3 passes in a row but that never reads settled afterwards is now held `settle_mismatch` (it needs a person) instead of being re-imported on every pass, and the rest of the source syncs; within one pass such a file is re-admitted at most once. `gbrain sync status` reports `settle_mismatch` from the second pass. Run `gbrain doctor --json` and `gbrain sources writer status --source <id> --json` (read-only), fix or report what they name, then `gbrain sources retry-held <id>` and sync.' },
- { since: '0.60.317.0', text: 'A managed sync run at a selection other than the source\'s configured one (`--exclude`, `--include-hidden`, `--src-subpath`, a different `--strategy`, or `--working-tree` against `sync.include_working_tree`) now ends `synced` with reason `selection_scoped` when that selection converges, and does not advance `last_commit`, `last_sync_at`, the slug-root pin or `chunker_version`. `gbrain sync status` reads `synced` / `selection_scoped`, and its next step is the plain `gbrain sync`, which syncs the configured selection and advances the commit.' },
- { since: '0.60.317.0', text: '`gbrain repair file-drift` takes `--held [--side both|unknown|deleted [--state tombstone_edited|purged_differs|file_gone]]` to preview and resolve a source\'s held `file_drift` files as one Decision, narrowed by `--only` and `--skip`. In each deleted state the two `--prefer` values do opposite things: `tombstone_edited` keeps the deletion and removes the file (`database`) or restores the page and imports the file (`file`); `purged_differs` removes the file or imports it as a new page; `file_gone` recreates the file or soft-deletes the page. A selection that mixes sides or states refuses `file_drift_mixed_selection` with the narrower commands, and `--side deleted` without `--state` refuses `file_drift_state_required`; nothing is previewed. Holds written before this release carry no side and are listed for a `--slug` preview.' },
- { since: '0.60.317.0', text: '`gbrain sources refresh` no longer refuses `sync_in_progress` because a non-company source\'s managed sync is unfinished: that sync keeps no cursor and reconciles whatever HEAD its next pass reads, so moving the checkout strands nothing, and the refresh\'s own sync of the members converges at the new HEAD. A company brain\'s unfinished cursor, or an older binary\'s cursor the first pass has not retired yet, still refuses with its resume command.' },
- { since: '0.60.317.0', text: 'A `gbrain sync` that follows another drainer now counts the lease holder\'s sync-pass writes as progress, not only its commits and cursor saves, so a pass that spends minutes reading and classifying a large source is not mistaken for a wedged holder. A follower on an older gbrain counts only commits and cursor saves: beside a holder on this release that commits nothing for 5 minutes (a long classify round) it stops `blocked` (exit 1) with `drain_stalled`, cause `no_progress`, so upgrade every host that syncs a source together. Until the next schema migration, the only release to downgrade to is the one immediately before this one; its checkpoint cleanup does not keep the sync-pass rows, so after coming back the first sync runs a full pass with the embedding cost unknown until approved again.' },
- { since: '0.60.317.0', text: 'Doctor reads a non-company managed source\'s sync from its pass row instead of a cursor. When its passes keep stopping (`blocked`, a `not_converged` streak or a `settle_mismatch` streak), `managed_sync_not_moving` warns that managed sync does not converge, `git_held_files` warns even with no file held (the source is listed under `details.passes`) and `managed_sync_blocked` warns, then fails after 60 minutes; each names `gbrain sync status --source <id> --json` as the read-only next step. `terminal_failures` lists what blocks an open pass\'s checkpoint. A source whose newest pass ended `synced` or `up_to_date` at HEAD reads healthy.' },
- { since: '0.60.317.0', text: 'A managed `gbrain sync` of a non-company source now reads the checkout only through allow-listed Git plumbing (`ls-tree`, `ls-files -s`, `diff-tree --no-renames`, `cat-file --batch`, `hash-object --no-filters`) and the files\' own bytes, so the repository\'s clean, process or textconv programs never run during that sync. Before, discovery ran a porcelain `git diff`, which runs them on modified files. Company-brain sources and `--dry-run` keep the earlier discovery.' },
- { since: '0.60.317.0', text: 'A managed sync now reserves each admitted import group\'s estimated embedding cost inside that group\'s admission (one record per group), so a killed sync keeps what it reserved and a replay of the group adds nothing. When a pass\'s reservations, or an open `--full` re-import\'s, reach the approved amount (`sync.cost_gate_min_usd`, $0.50 by default, or what `gbrain sync --yes` approved), the rest of that pass imports without embeddings; the next pass does not inherit that. If the pass record is lost while reservations exist, the cost is unknown and embeddings wait until the owner approves again with `gbrain sync --source <id> --no-pull --yes`.' },
- { since: '0.60.317.0', text: '`gbrain sources set-strategy <id> <strategy>` now also refuses with `sync_run_unfinished` (exit 1, nothing written) while a sync holds the source\'s drain lease or while a re-import the source\'s sync opened (a `--full`, say) is still open. Before, it refused only over an unfinished cursor, which a non-company source no longer has. Wait for the running sync, or finish the re-import with `gbrain sync --source <id> --no-pull`; `gbrain sync status --source <id> --json` shows where it stands. Setting the strategy a source already has is not refused.' },
- { since: '0.60.317.0', text: 'Doctor `managed_sync_not_moving` now also warns when a managed source\'s newest sync pass found nothing to do (`up_to_date`) but took longer than its target: 0.5 s for an idle tick (1 s on a source over 100,000 pages), 2 s for a full round (15 s over 100,000 pages). The warning names the pass\'s `timings_ms` (an idle tick now records `setup` and `kind`), its fix is the read-only `gbrain sync status --source <id> --json --detail`, and it never fails.' },
- { since: '0.60.317.0', text: 'New doctor check `sync_admission_restricted` warns on a managed brain while `sync.admission` is not `normal`, with the value, how long ago it was set and the restore command `gbrain config set sync.admission normal`, which is the user\'s to run (never applied automatically). It reads ok on `normal` and on a brain without managed persistence.' },
- { since: '0.60.317.0', text: 'New brain-wide setting `sync.admission`: `normal` (the default), `imports_only` or `classify_only`, set on the brain host with `gbrain config set sync.admission <value>` (any other value is refused, exit 2, and nothing is written). Under `imports_only` managed sync admits no deletes and no `storage.keep_db` writes; those paths wait (`paused_deletes`, `paused_keep_db`) while imports and the checkpoint go on. Under `classify_only` it reads and classifies, writes no page and stops `resumable` / `admission_paused` (exit 0), with a `next` that asks the user to restore it. The value is read when a pass starts and in every admission, and a delete or keep_db write checks it again just before it publishes (it completes `cancelled` with `admission_paused`, nothing written). `gbrain sync status --json` reports `admission: {value, set_at, effective}`.' },
- { since: '0.60.317.0', text: 'A managed sync now records an import for each page an older gbrain imported whose file still equals the page (such pages have no import record and are counted as `legacy_unverified`). It checks every such page in the source\'s first full round, then up to 500 per pass; a later edit of that file then imports normally instead of being held for a decision. The check is read-only until it writes the record, and a page that differs from its file is left as it is. `convergence.legacy_unverified` counts the pages not yet checked.' },
- { since: '0.60.317.0', text: 'After a parser or schema-pack change, a managed sync re-imports the pages whose file and page are unchanged but whose import record names the older parser (class `reparse`, which sync finishes by itself, with no hold), as the pre-pass prescreen did; the first pass after the change reads the whole source.' },
- { since: '0.60.317.0', text: 'An interrupted `gbrain sync --full` no longer ends with the run that started it: the next plain `gbrain sync` continues the re-import under the selection the `--full` started with, and there is no command to abandon it. A `--full` with a narrower selection (a CLI `--exclude`, say) finishes its own re-import and ends `synced` with status reason `selection_scoped`, without moving `last_commit`; the next plain sync then syncs the configured selection. A plain sync closes any open re-import, and stamps `chunker_version` only when the re-import covered the whole configured selection. To pause paid work, rely on the cost gate; to pause everything, set `sync.admission classify_only`.' },
- { since: '0.60.317.0', text: 'A managed sync pass that runs 4 rounds without the source settling (another writer keeps changing it) stops `not_converged`: outcome `resumable`, exit 0, everything it admitted stands, and `next` reruns the same sync. After 3 such passes in a row, `next` switches to a report: `gbrain sync status --source <id> --json` with `safe_to_loop: false` and `fix.next: report`, and a sync job ends needing an operator, so an agent loop stops instead of retrying. The count resets when a pass converges.' },
- { since: '0.60.317.0', text: 'New explicit repair `gbrain repair legacy-twins --source <id>` (#6885) merges the page pairs syncs before #6857 forked: a legacy page with no recorded file whose slug spells the file\'s name differently from today\'s slug rules, and the twin at today\'s slug that records the file. The read-only preview lists each pair (both pages\' ids, slugs and revisions, the file, whether the contents match) and lists as decisions, never merged, pairs whose contents differ, several legacy pages for one twin, twins whose file is missing or drifted, and twins holding a link, relationship date, timeline entry or raw data row the legacy page holds differently (`twin_evidence_conflicts`). `--apply --expect <hash> --yes` merges exactly the approved pairs: the legacy page takes over the file and keeps its id, links and history, the twin\'s links and their dated transitions, timeline, raw data, user-added tags, aliases and the facts other pages state about it move over through the same twin merge as `gbrain repair origin-twins` (#6948), its slug becomes an alias, and the twin is soft-deleted (its file untouched) and purged after 72 hours. It refuses off the owner host (`not_owner_host`), when the checkout cannot be read (`legacy_twins_storage_unknown`), and when the pairs are more than half of a source\'s file-backed pages (`legacy_twin_mass_merge_refused`, unless `GBRAIN_ALLOW_MASS_RECONCILE=1`). Nothing changes on upgrade; it runs only when named.' },
- { since: '0.60.317.0', text: 'A managed sync of a non-company source that cannot decide which page a file is no longer stops the whole source with `page_identity_changed`: the file alone is held `page_identity_changed` (it needs a person; `meta.reason` names why) and the rest of the source syncs. `several_tombstones`: several deleted pages record the file as their origin; `spelling`: files differing only by letter case or separator (both are held); `identity_differs`: a file whose frontmatter id differs from the page at its slug, which keeps its id, body and slug while its old file\'s deletion waits. A dry run (and a company source) still refuses the source as before, so `gbrain sync --dry-run` reports a refusal where the sync itself holds one file; a remote sync leaves such files for the owner\'s sync to hold.' },
- { since: '0.60.317.0', text: 'A managed sync no longer stops a whole source at a Markdown file whose text holds NUL bytes (U+0000: a UTF-16 "Unicode" save, a binary file named .md, a crash-padded file). Before, every run failed at that file with `storage_error` (SQLSTATE 22P05) and nothing after it synced; now the file alone is held `content_null_bytes`, its message names the file and the first NUL\'s line (and says to save it as UTF-8 when it starts with a UTF-16 byte order mark), and the rest of the source syncs. With `sync.holds=fail` the run stops with `content_null_bytes` instead. Classic (unmanaged) sync is unchanged.' },
- { since: '0.60.317.0', text: 'A managed sync no longer stops a whole source at a committed file whose Git object the checkout lost (an interrupted gc, a partial clone): it imports the working-tree bytes when they hash to the committed blob id, and otherwise holds that file `git_object_missing` (run `git fsck`, restore the object with `git fetch` or from a backup; every sync re-tests it). An imported file that became a directory (`notes/a.md` turned into `notes/a.md/x.md`) no longer stops the source with `page_identity_changed`: its page is deleted and the new file imports.' },
- { since: '0.60.317.0', text: 'When managed sync hits an unexpected error while preparing one file (before anything is admitted), it now holds that file `page_write_failed` with `meta.write_failure.origin` `freeze` and the error in the hold message, and the rest of the source syncs; before, the source stopped on that file on every run. The next syncs re-test the file on their own until it has been held 3 times, so a passing fault clears without help. A deliberate refusal still stops the run, and so does a run in which most files fail that way (5 or more, and at least as many as prepared cleanly), which looks systemic. In a bulk group (Postgres) the failure is reported on the file that failed, not on the group\'s first file.' },
- { since: '0.60.317.0', text: '`gbrain sync status --json` no longer tells an agent to rerun a managed sync forever when every run stops on the same file with the same unclassified `storage_error`: the first such stop is still `connection` with `next` = rerun, but once two runs in a row stop on the same path with the same code and message, `last_error` is `needs_human` (class `page`, `safe_actions` `none`, new field `repeats`), the state is `blocked` / `needs_human`, and `human_reason` names the file. A message that changes between runs stays a rerun.' },
- { since: '0.60.317.0', text: 'A file whose exact bytes an earlier gbrain imported and validated, and which this release refuses (a parser regression), no longer stops the sync by default: it is held `parser_regression` alone (a gbrain bug to report; it needs a person) and the rest of the source syncs. `GBRAIN_SYNC_PARSER_REGRESSION=stop` for the process that syncs restores the old stop (`sync_parser_regression`, the checkpoint does not advance). A refusal this release makes on purpose, such as the YAML alias bound (`frontmatter_alias_limit`), is held as before under either setting.' },
- { since: '0.60.317.0', text: 'Doctor `managed_sync_blocked` (and get_brain_health `sync_blocked`) now count a managed sync pass that stopped with a recorded failure before finishing, in discovery (path `<discovery>`) or on one file, until a later sync of the source succeeds; before, such a source indexed nothing while the check said no run was blocked.' },
- { since: '0.60.317.0', text: 'A managed sync no longer stops a whole source when a file it would skip as already imported (a no-op waiver) has meanwhile become a symlink, a FIFO or an unreadable file in the working tree: that entry is simply not skipped and goes on like any other, where an unreadable file is held `file_unreadable`.' },
- { since: '0.60.317.0', text: 'A managed sync holds a committed file whose name is not valid UTF-8 (a Latin-1 name from an older system or an archive) under the new hold code `path_not_utf8`, naming the rename that fixes it, and the rest of the source syncs; before, the file was held with a raw Git error or stopped the source. Renaming the file to a UTF-8 name clears the hold. With `sync.holds=fail` the run stops with `path_not_utf8`.' },
- { since: '0.60.317.0', text: 'A managed sync of a folder of more than 20 pages moved with `git mv` keeps each page (a move, with its id, links and history): the mass-delete valve no longer counts a delete whose bytes arrive at a new path in the same round. Before, the valve withheld the old paths\' deletes in the first round, so every new path imported as a new page beside its old one (one `shares content_hash ... Indexing both` warning per file) and the old pages were deleted afterwards. A mass delete with nothing arriving is still withheld.' },
++ { since: '0.60.318.0', text: 'On a managed brain a plain `gbrain sync` of a non-company source no longer imports only `last_commit..HEAD`: each pass compares every file at HEAD with what the database absorbed (the page and its import record) and admits what differs, so out-of-band changes (a reset or revert, a rewritten history, a lost manifest, an interrupted run) converge on the next plain sync with no flag. When nothing moved since the last converged pass (same HEAD, parser, schema pack and selection, nothing open), the tick is idle and only `last_sync_at` changes; a full comparison still runs at least every 200 passes or 24 hours. A pass uses at most 4 rounds. Company-brain sources keep their cursor.' },
++ { since: '0.60.318.0', text: 'In committed mode (the default) a managed sync never imports a dirty working copy, as before: the level-triggered pass keeps the cursor path\'s guarantee and never adopts or writes over such a file either. When the committed file is unchanged since its import, the uncommitted edit is left alone and nothing is held; when the commit moved under an uncommitted edit, the file is held `worktree_dirty` and the page and the edit stay as they are. Commit or restore the file and sync again.' },
++ { since: '0.60.318.0', text: 'A page deleted in the database is no longer brought back by a managed sync from a file that is still committed, even after `gbrain delete --purge` or a mirrored purge replay: a purge now leaves a deletion marker (the file versions the brain held) while the file is still in `last_commit` or on disk, and an unchanged file then counts as synced. A file that changed after its page was deleted is held `file_drift` with side `deleted` and state `tombstone_edited` (soft-deleted) or `purged_differs` (purged, naming its slug), and the rest of the source syncs; `gbrain repair file-drift --held --side deleted --state <state>` resolves it. A full pass retires the marker once the file has left both the commit and the disk, so a new file at that path imports as a new page. A page purged before this release has no such marker, and `--full` can still import its file.' },
++ { since: '0.60.318.0', text: '`storage.keep_db` is now applied by the managed sync pass itself on the brain host, and the separate keep_db worker that resident owners ran every 10 minutes is retired. A page under a keep_db prefix whose file is clean in the commit gets the database-wins write when its database copy moved (whether or not the file changed too); the write is bound to the committed bytes and the page revision the pass read, so a later edit refuses it. A file with uncommitted changes never gets a database-wins write: it is held like any dirty file. A pass admits at most 200 of these writes; the rest wait as `keep_db_pending`, and the next sync runs a full pass that admits them. While `sync.admission` is not `normal` they wait as `paused_keep_db`. Remote callers never write them.' },
++ { since: '0.60.318.0', text: 'A managed sync that would delete more than half of a source\'s file-backed pages (on a source with more than 20) no longer applies those deletes: it writes one withheld record (count, ratio, a hash of the set and up to 20 sample paths), imports everything else, holds no page and still advances `last_commit`. `gbrain sync status` reads `blocked` / `deletes_withheld` with the dry run (`gbrain sync --source <id> --dry-run --json`) as its next step, and `convergence.deletes_withheld` carries the record. If the checkout is wrong or incomplete, restore it and sync; if the deletion is intended, run `GBRAIN_ALLOW_MASS_RECONCILE=1 gbrain sync --source <id>` on the brain host, which applies the deletes and clears the record. Remote callers never apply them.' },
++ { since: '0.60.318.0', text: '`gbrain sync status --json` on a managed source now reports the live pass as `convergence` (`dry_run: false`) on a plain status too, read from the pass row: its kind, outcome, stop reason, round, candidates, settled and remaining counts, held Decisions by side, `db_ahead`, `legacy_unverified`, keep_db writes, a withheld mass delete, the open episode, `not_converged_streak` and `classes`, where each class names who acts (`none`, `owner` or `repair`; `gbrain sync status --help` lists them). New field `admission` (`sync.admission`\'s value, `set_at`, `effective`) and new reasons `pass_unfinished`, `not_converged`, `settle_mismatch`, `deletes_withheld`, `selection_scoped` and `admission_paused`; a source is never `synced` while its newest pass is open or ended unconverged. A non-company source has no cursor, so `run_id`, `cursor`, `rate_pages_per_min` and `eta_seconds` read null there. Held `file_drift` files in `gbrain sources status --json` and in sync results carry `side` (`both`, `unknown`, `deleted`) and, for a deleted side, `state`.' },
++ { since: '0.60.318.0', text: 'A file that a managed sync settles at the same level in 3 passes in a row but that never reads settled afterwards is now held `settle_mismatch` (it needs a person) instead of being re-imported on every pass, and the rest of the source syncs; within one pass such a file is re-admitted at most once. `gbrain sync status` reports `settle_mismatch` from the second pass. Run `gbrain doctor --json` and `gbrain sources writer status --source <id> --json` (read-only), fix or report what they name, then `gbrain sources retry-held <id>` and sync.' },
++ { since: '0.60.318.0', text: 'A managed sync run at a selection other than the source\'s configured one (`--exclude`, `--include-hidden`, `--src-subpath`, a different `--strategy`, or `--working-tree` against `sync.include_working_tree`) now ends `synced` with reason `selection_scoped` when that selection converges, and does not advance `last_commit`, `last_sync_at`, the slug-root pin or `chunker_version`. `gbrain sync status` reads `synced` / `selection_scoped`, and its next step is the plain `gbrain sync`, which syncs the configured selection and advances the commit.' },
++ { since: '0.60.318.0', text: '`gbrain repair file-drift` takes `--held [--side both|unknown|deleted [--state tombstone_edited|purged_differs|file_gone]]` to preview and resolve a source\'s held `file_drift` files as one Decision, narrowed by `--only` and `--skip`. In each deleted state the two `--prefer` values do opposite things: `tombstone_edited` keeps the deletion and removes the file (`database`) or restores the page and imports the file (`file`); `purged_differs` removes the file or imports it as a new page; `file_gone` recreates the file or soft-deletes the page. A selection that mixes sides or states refuses `file_drift_mixed_selection` with the narrower commands, and `--side deleted` without `--state` refuses `file_drift_state_required`; nothing is previewed. Holds written before this release carry no side and are listed for a `--slug` preview.' },
++ { since: '0.60.318.0', text: '`gbrain sources refresh` no longer refuses `sync_in_progress` because a non-company source\'s managed sync is unfinished: that sync keeps no cursor and reconciles whatever HEAD its next pass reads, so moving the checkout strands nothing, and the refresh\'s own sync of the members converges at the new HEAD. A company brain\'s unfinished cursor, or an older binary\'s cursor the first pass has not retired yet, still refuses with its resume command.' },
++ { since: '0.60.318.0', text: 'A `gbrain sync` that follows another drainer now counts the lease holder\'s sync-pass writes as progress, not only its commits and cursor saves, so a pass that spends minutes reading and classifying a large source is not mistaken for a wedged holder. A follower on an older gbrain counts only commits and cursor saves: beside a holder on this release that commits nothing for 5 minutes (a long classify round) it stops `blocked` (exit 1) with `drain_stalled`, cause `no_progress`, so upgrade every host that syncs a source together. Until the next schema migration, the only release to downgrade to is the one immediately before this one; its checkpoint cleanup does not keep the sync-pass rows, so after coming back the first sync runs a full pass with the embedding cost unknown until approved again.' },
++ { since: '0.60.318.0', text: 'Doctor reads a non-company managed source\'s sync from its pass row instead of a cursor. When its passes keep stopping (`blocked`, a `not_converged` streak or a `settle_mismatch` streak), `managed_sync_not_moving` warns that managed sync does not converge, `git_held_files` warns even with no file held (the source is listed under `details.passes`) and `managed_sync_blocked` warns, then fails after 60 minutes; each names `gbrain sync status --source <id> --json` as the read-only next step. `terminal_failures` lists what blocks an open pass\'s checkpoint. A source whose newest pass ended `synced` or `up_to_date` at HEAD reads healthy.' },
++ { since: '0.60.318.0', text: 'A managed `gbrain sync` of a non-company source now reads the checkout only through allow-listed Git plumbing (`ls-tree`, `ls-files -s`, `diff-tree --no-renames`, `cat-file --batch`, `hash-object --no-filters`) and the files\' own bytes, so the repository\'s clean, process or textconv programs never run during that sync. Before, discovery ran a porcelain `git diff`, which runs them on modified files. Company-brain sources and `--dry-run` keep the earlier discovery.' },
++ { since: '0.60.318.0', text: 'A managed sync now reserves each admitted import group\'s estimated embedding cost inside that group\'s admission (one record per group), so a killed sync keeps what it reserved and a replay of the group adds nothing. When a pass\'s reservations, or an open `--full` re-import\'s, reach the approved amount (`sync.cost_gate_min_usd`, $0.50 by default, or what `gbrain sync --yes` approved), the rest of that pass imports without embeddings; the next pass does not inherit that. If the pass record is lost while reservations exist, the cost is unknown and embeddings wait until the owner approves again with `gbrain sync --source <id> --no-pull --yes`.' },
++ { since: '0.60.318.0', text: '`gbrain sources set-strategy <id> <strategy>` now also refuses with `sync_run_unfinished` (exit 1, nothing written) while a sync holds the source\'s drain lease or while a re-import the source\'s sync opened (a `--full`, say) is still open. Before, it refused only over an unfinished cursor, which a non-company source no longer has. Wait for the running sync, or finish the re-import with `gbrain sync --source <id> --no-pull`; `gbrain sync status --source <id> --json` shows where it stands. Setting the strategy a source already has is not refused.' },
++ { since: '0.60.318.0', text: 'Doctor `managed_sync_not_moving` now also warns when a managed source\'s newest sync pass found nothing to do (`up_to_date`) but took longer than its target: 0.5 s for an idle tick (1 s on a source over 100,000 pages), 2 s for a full round (15 s over 100,000 pages). The warning names the pass\'s `timings_ms` (an idle tick now records `setup` and `kind`), its fix is the read-only `gbrain sync status --source <id> --json --detail`, and it never fails.' },
++ { since: '0.60.318.0', text: 'New doctor check `sync_admission_restricted` warns on a managed brain while `sync.admission` is not `normal`, with the value, how long ago it was set and the restore command `gbrain config set sync.admission normal`, which is the user\'s to run (never applied automatically). It reads ok on `normal` and on a brain without managed persistence.' },
++ { since: '0.60.318.0', text: 'New brain-wide setting `sync.admission`: `normal` (the default), `imports_only` or `classify_only`, set on the brain host with `gbrain config set sync.admission <value>` (any other value is refused, exit 2, and nothing is written). Under `imports_only` managed sync admits no deletes and no `storage.keep_db` writes; those paths wait (`paused_deletes`, `paused_keep_db`) while imports and the checkpoint go on. Under `classify_only` it reads and classifies, writes no page and stops `resumable` / `admission_paused` (exit 0), with a `next` that asks the user to restore it. The value is read when a pass starts and in every admission, and a delete or keep_db write checks it again just before it publishes (it completes `cancelled` with `admission_paused`, nothing written). `gbrain sync status --json` reports `admission: {value, set_at, effective}`.' },
++ { since: '0.60.318.0', text: 'A managed sync now records an import for each page an older gbrain imported whose file still equals the page (such pages have no import record and are counted as `legacy_unverified`). It checks every such page in the source\'s first full round, then up to 500 per pass; a later edit of that file then imports normally instead of being held for a decision. The check is read-only until it writes the record, and a page that differs from its file is left as it is. `convergence.legacy_unverified` counts the pages not yet checked.' },
++ { since: '0.60.318.0', text: 'After a parser or schema-pack change, a managed sync re-imports the pages whose file and page are unchanged but whose import record names the older parser (class `reparse`, which sync finishes by itself, with no hold), as the pre-pass prescreen did; the first pass after the change reads the whole source.' },
++ { since: '0.60.318.0', text: 'An interrupted `gbrain sync --full` no longer ends with the run that started it: the next plain `gbrain sync` continues the re-import under the selection the `--full` started with, and there is no command to abandon it. A `--full` with a narrower selection (a CLI `--exclude`, say) finishes its own re-import and ends `synced` with status reason `selection_scoped`, without moving `last_commit`; the next plain sync then syncs the configured selection. A plain sync closes any open re-import, and stamps `chunker_version` only when the re-import covered the whole configured selection. To pause paid work, rely on the cost gate; to pause everything, set `sync.admission classify_only`.' },
++ { since: '0.60.318.0', text: 'A managed sync pass that runs 4 rounds without the source settling (another writer keeps changing it) stops `not_converged`: outcome `resumable`, exit 0, everything it admitted stands, and `next` reruns the same sync. After 3 such passes in a row, `next` switches to a report: `gbrain sync status --source <id> --json` with `safe_to_loop: false` and `fix.next: report`, and a sync job ends needing an operator, so an agent loop stops instead of retrying. The count resets when a pass converges.' },
++ { since: '0.60.318.0', text: 'New explicit repair `gbrain repair legacy-twins --source <id>` (#6885) merges the page pairs syncs before #6857 forked: a legacy page with no recorded file whose slug spells the file\'s name differently from today\'s slug rules, and the twin at today\'s slug that records the file. The read-only preview lists each pair (both pages\' ids, slugs and revisions, the file, whether the contents match) and lists as decisions, never merged, pairs whose contents differ, several legacy pages for one twin, twins whose file is missing or drifted, and twins holding a link, relationship date, timeline entry or raw data row the legacy page holds differently (`twin_evidence_conflicts`). `--apply --expect <hash> --yes` merges exactly the approved pairs: the legacy page takes over the file and keeps its id, links and history, the twin\'s links and their dated transitions, timeline, raw data, user-added tags, aliases and the facts other pages state about it move over through the same twin merge as `gbrain repair origin-twins` (#6948), its slug becomes an alias, and the twin is soft-deleted (its file untouched) and purged after 72 hours. It refuses off the owner host (`not_owner_host`), when the checkout cannot be read (`legacy_twins_storage_unknown`), and when the pairs are more than half of a source\'s file-backed pages (`legacy_twin_mass_merge_refused`, unless `GBRAIN_ALLOW_MASS_RECONCILE=1`). Nothing changes on upgrade; it runs only when named.' },
++ { since: '0.60.318.0', text: 'A managed sync of a non-company source that cannot decide which page a file is no longer stops the whole source with `page_identity_changed`: the file alone is held `page_identity_changed` (it needs a person; `meta.reason` names why) and the rest of the source syncs. `several_tombstones`: several deleted pages record the file as their origin; `spelling`: files differing only by letter case or separator (both are held); `identity_differs`: a file whose frontmatter id differs from the page at its slug, which keeps its id, body and slug while its old file\'s deletion waits. A dry run (and a company source) still refuses the source as before, so `gbrain sync --dry-run` reports a refusal where the sync itself holds one file; a remote sync leaves such files for the owner\'s sync to hold.' },
++ { since: '0.60.318.0', text: 'A managed sync no longer stops a whole source at a Markdown file whose text holds NUL bytes (U+0000: a UTF-16 "Unicode" save, a binary file named .md, a crash-padded file). Before, every run failed at that file with `storage_error` (SQLSTATE 22P05) and nothing after it synced; now the file alone is held `content_null_bytes`, its message names the file and the first NUL\'s line (and says to save it as UTF-8 when it starts with a UTF-16 byte order mark), and the rest of the source syncs. With `sync.holds=fail` the run stops with `content_null_bytes` instead. Classic (unmanaged) sync is unchanged.' },
++ { since: '0.60.318.0', text: 'A managed sync no longer stops a whole source at a committed file whose Git object the checkout lost (an interrupted gc, a partial clone): it imports the working-tree bytes when they hash to the committed blob id, and otherwise holds that file `git_object_missing` (run `git fsck`, restore the object with `git fetch` or from a backup; every sync re-tests it). An imported file that became a directory (`notes/a.md` turned into `notes/a.md/x.md`) no longer stops the source with `page_identity_changed`: its page is deleted and the new file imports.' },
++ { since: '0.60.318.0', text: 'When managed sync hits an unexpected error while preparing one file (before anything is admitted), it now holds that file `page_write_failed` with `meta.write_failure.origin` `freeze` and the error in the hold message, and the rest of the source syncs; before, the source stopped on that file on every run. The next syncs re-test the file on their own until it has been held 3 times, so a passing fault clears without help. A deliberate refusal still stops the run, and so does a run in which most files fail that way (5 or more, and at least as many as prepared cleanly), which looks systemic. In a bulk group (Postgres) the failure is reported on the file that failed, not on the group\'s first file.' },
++ { since: '0.60.318.0', text: '`gbrain sync status --json` no longer tells an agent to rerun a managed sync forever when every run stops on the same file with the same unclassified `storage_error`: the first such stop is still `connection` with `next` = rerun, but once two runs in a row stop on the same path with the same code and message, `last_error` is `needs_human` (class `page`, `safe_actions` `none`, new field `repeats`), the state is `blocked` / `needs_human`, and `human_reason` names the file. A message that changes between runs stays a rerun.' },
++ { since: '0.60.318.0', text: 'A file whose exact bytes an earlier gbrain imported and validated, and which this release refuses (a parser regression), no longer stops the sync by default: it is held `parser_regression` alone (a gbrain bug to report; it needs a person) and the rest of the source syncs. `GBRAIN_SYNC_PARSER_REGRESSION=stop` for the process that syncs restores the old stop (`sync_parser_regression`, the checkpoint does not advance). A refusal this release makes on purpose, such as the YAML alias bound (`frontmatter_alias_limit`), is held as before under either setting.' },
++ { since: '0.60.318.0', text: 'Doctor `managed_sync_blocked` (and get_brain_health `sync_blocked`) now count a managed sync pass that stopped with a recorded failure before finishing, in discovery (path `<discovery>`) or on one file, until a later sync of the source succeeds; before, such a source indexed nothing while the check said no run was blocked.' },
++ { since: '0.60.318.0', text: 'A managed sync no longer stops a whole source when a file it would skip as already imported (a no-op waiver) has meanwhile become a symlink, a FIFO or an unreadable file in the working tree: that entry is simply not skipped and goes on like any other, where an unreadable file is held `file_unreadable`.' },
++ { since: '0.60.318.0', text: 'A managed sync holds a committed file whose name is not valid UTF-8 (a Latin-1 name from an older system or an archive) under the new hold code `path_not_utf8`, naming the rename that fixes it, and the rest of the source syncs; before, the file was held with a raw Git error or stopped the source. Renaming the file to a UTF-8 name clears the hold. With `sync.holds=fail` the run stops with `path_not_utf8`.' },
++ { since: '0.60.318.0', text: 'A managed sync of a folder of more than 20 pages moved with `git mv` keeps each page (a move, with its id, links and history): the mass-delete valve no longer counts a delete whose bytes arrive at a new path in the same round. Before, the valve withheld the old paths\' deletes in the first round, so every new path imported as a new page beside its old one (one `shares content_hash ... Indexing both` warning per file) and the old pages were deleted afterwards. A mass delete with nothing arriving is still withheld.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */
diff --cc templates/bootstrap/template-repo/README.md
index 288559540d,288559540d..3187939103
--- a/templates/bootstrap/template-repo/README.md
+++ b/templates/bootstrap/template-repo/README.md
@@@ -1,6 -1,6 +1,6 @@@
# gbrain agent workspace — template
--<!-- gbrain-template-stamp: 0.60.317.0 -->
++<!-- gbrain-template-stamp: 0.60.318.0 -->
This repository is the **"Use this template"** distribution artifact for a
[gbrain](https://github.com/garrytan/gbrain) personal-agent workspace — the same
diff --cc test/persistence-sync-origin-native.test.ts
index 33c14ee1db,9e4aa5f9db..19164e25f3
--- a/test/persistence-sync-origin-native.test.ts
+++ b/test/persistence-sync-origin-native.test.ts
@@@ -1,21 -1,5 +1,20 @@@
-import { afterAll, beforeAll, expect, test } from 'bun:test';
+/**
+ * Native sync-origin identity (separators, case, root spellings) and deletion provenance of managed sync.
+ *
+ * #6712 PR 4b: a non-company source syncs by the live pass, so these tests assert the pass where they used to assert the
+ * cursor. Protects, for the pass: a remote sync keeps its accepted path and payload unchanged across root spellings and,
+ * on a page no sync import recorded, asks for the brain host and writes nothing; deleting a filename no page claims is not
+ * a candidate (no request, the live or tombstoned page unchanged; a tombstone whose file is still present is held
+ * file_drift deleted/tombstone_edited); a committed or working-tree deletion of a page no sync import recorded is held
+ * file_drift deleted/file_gone and the page stays live. A native root spelling keeps the registered owner and resumes the
+ * one pass row; a pass's deletion publication revalidates a recreated file, activation, the configured root and the
+ * origin after preparation, under the request id it was admitted with. An older binary's unfinished cursor (what its
+ * frozen manifest and admitted deletion leave behind) is retired by the pass: a frozen deletion of a present file is never
+ * admitted, an admitted one is cancelled under its original id with its intent unchanged, an origin-less page is never
+ * deleted by slug, and a legacy deletion request with no manifest still fails closed at preparation.
+ */
+import { afterAll, afterEach, beforeAll, expect, test } from 'bun:test';
import { randomUUID } from 'node:crypto';
- import { execFileSync } from 'node:child_process';
import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, unlinkSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join, relative, resolve, sep } from 'node:path';
@@@ -41,9 -24,9 +40,9 @@@ import { computeSyncDelta } from '../sr
import { sha256 } from '../src/core/persistence/digest.ts';
import { disposePersistenceConsumer } from '../src/core/persistence/service.ts';
import { prepareRemoteJob, withSubmissionAuthority } from '../src/core/minions/submission-authority.ts';
+import { readGitSourceHolds } from '../src/core/persistence/sync-holds.ts';
import { isolatedPersistencePostgres } from './helpers/persistence-postgres.ts';
- import { makeGitFixture } from './helpers/git-fixture.ts';
-import { interruptAfterSyncDiscovery } from './helpers/persistence-sync-interruption.ts';
+ import { gitAsync } from './helpers/git-publication.ts';
import { withEnv } from './helpers/with-env.ts';
const home = mkdtempSync(join(tmpdir(), 'gbrain-sync-origin-native-'));
@@@ -82,44 -65,27 +82,44 @@@ async function fixture(engine: BrainEng
return { id, root, head, slug, snapshot, opts: { ...options, sourceId: id, repoPath: root } };
}
+/**
+ * #6712 PR 4b: what an older binary's unfinished cursor left for this source: a cursor row and its frozen manifest naming the
+ * deletion of notes/example.md, and (when `admitted`) that deletion admitted as the cursor's pending request with a legacy
+ * intent (no `working`, no `passId`). A non-company source no longer writes a cursor, so the rows are written as it wrote them.
+ */
async function legacyDeletion(engine: BrainEngine, f: Awaited<ReturnType<typeof fixture>>, admitted: boolean) {
- expect((await interruptAfterSyncDiscovery(engine, f.opts)).status).toBe('partial');
- const [stored] = await engine.executeRaw<{ fingerprint: string; completed_keys: any[] }>(
- "SELECT fingerprint,completed_keys FROM op_checkpoints WHERE op='managed-sync' AND completed_keys->0->>'sourceId'=$1", [f.id]);
- const cursor = stored.completed_keys[0];
+ const context = await resolveManagedSyncContext(engine, f.opts);
+ const authority = await managedSyncAuthority(engine, f.id, context.incarnation, context.root);
+ const binding = { ...context.binding, owner_epoch: String(context.binding.owner_epoch), topology_generation: String(context.binding.topology_generation) };
+ const key = `legacy-${randomUUID()}`, runId = randomUUID();
- const target = execFileSync('git', ['-C', f.root, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
++ const target = (await gitAsync(f.root, 'rev-parse', 'HEAD')).trim();
const entry = { path: 'notes/example.md', sourcePath: f.snapshot.page.source_path!, action: 'delete', working: false,
slug: f.slug, pageId: f.snapshot.page.id, revision: f.snapshot.revision };
+ const cursor: Record<string, any> = { binding, root: context.root, gitRoot: context.gitRoot, sourceId: f.id, incarnation: context.incarnation, from: null, target,
+ slugMode: 'git-root', discoveredAt: new Date().toISOString(), runId, index: 0, total: 1, authority,
+ processingOptions: { noEmbed: true, noExtract: true, noSchemaPack: true }, counts: { added: 0, modified: 0, deleted: 0, chunks: 0 },
+ syncOptions: { full: true, workingTree: false, srcSubpath: null, exclude: [], includeHidden: [], strategy: null } };
const intent: SyncIntent = { kind: 'managed_sync_delete', expected_revision: f.snapshot.revision,
sourcePath: entry.sourcePath, path: entry.path, rawHash: sha256(content), content: null,
- ownerEpoch: String(cursor.binding.owner_epoch), syncAuthority: cursor.authority, cursorKey: stored.fingerprint,
- runId: cursor.runId, index: 0, total: 1, from: cursor.from, target: cursor.target, slugMode: cursor.slugMode };
+ ownerEpoch: binding.owner_epoch, syncAuthority: authority, cursorKey: key,
+ runId, index: 0, total: 1, from: null, target, slugMode: 'git-root' };
const requestId = randomUUID();
- const next = { ...cursor, total: 1, ...(admitted ? { pending: { requestId, slug: f.slug, pageId: f.snapshot.page.id, intent } } : {}) };
- await engine.executeRaw("UPDATE op_checkpoints SET completed_keys=$2::text::jsonb WHERE op='managed-sync-manifest' AND fingerprint=$1", [cursor.runId, JSON.stringify([entry])]);
- await engine.executeRaw("UPDATE op_checkpoints SET completed_keys=$2::text::jsonb WHERE op='managed-sync' AND fingerprint=$1", [stored.fingerprint, JSON.stringify([next])]);
+ if (admitted) cursor.pending = { requestId, slug: f.slug, pageId: f.snapshot.page.id, intent };
+ await engine.executeRaw('INSERT INTO op_checkpoints(op,fingerprint,completed_keys,updated_at) VALUES($1,$2,$3::text::jsonb,now())', ['managed-sync', key, JSON.stringify([cursor])]);
+ await engine.executeRaw('INSERT INTO op_checkpoints(op,fingerprint,completed_keys,updated_at) VALUES($1,$2,$3::text::jsonb,now())', ['managed-sync-manifest', runId, JSON.stringify([entry])]);
if (admitted) await admitWrite(engine, { requestId, operation: 'submit_job', sourceId: f.id,
- sourceIncarnation: cursor.incarnation, slug: f.slug, pageId: f.snapshot.page.id, worktreeId: cursor.binding.worktree_id,
- topologyGeneration: cursor.binding.topology_generation, principal: cursor.authority.writer.principal,
- authority: cursor.authority.writer, callerIntent: intent, intent });
- return { requestId, intent, cursor, entry };
+ sourceIncarnation: context.incarnation, slug: f.slug, pageId: f.snapshot.page.id, worktreeId: binding.worktree_id,
+ topologyGeneration: binding.topology_generation, principal: authority.writer.principal,
+ authority: authority.writer, callerIntent: intent, intent });
+ return { requestId, intent, cursor: cursor as { runId: string; authority: typeof authority }, entry, key };
}
+/** The page the pass keeps: on Windows it re-spells a stored backslash origin with '/' in place, revision unchanged (as the separator identity test asserts). */
+const keptSnapshot = (f: Awaited<ReturnType<typeof fixture>>) => process.platform === 'win32'
+ ? { ...f.snapshot, page: { ...f.snapshot.page, source_path: syncOriginPath(f.snapshot.page.source_path!, 'win32') } } : f.snapshot;
+const legacyRows = (engine: BrainEngine, legacy: Awaited<ReturnType<typeof legacyDeletion>>) => engine.executeRaw<{ op: string }>(
+ "SELECT op FROM op_checkpoints WHERE (op='managed-sync' AND fingerprint=$1) OR (op='managed-sync-manifest' AND fingerprint=$2)", [legacy.key, legacy.cursor.runId]);
+const deleteRequests = (engine: BrainEngine, id: string) => engine.executeRaw<{ request_id: string; state: string; error_code: string | null }>(
+ "SELECT request_id::text AS request_id, state, error_code FROM persistence_requests WHERE source_id=$1 AND intent->>'kind'='managed_sync_delete' ORDER BY sequence", [id]);
test('origin comparison is Windows-specific and never case-folds POSIX identity', () => {
expect(syncOriginPath('notes\\example.md', 'win32')).toBe('notes/example.md');
@@@ -239,15 -200,8 +239,15 @@@ check('native historical separator iden
expect((await engine.executeRaw<{ last_commit: string }>('SELECT last_commit FROM sources WHERE id=$1', [f.id]))[0].last_commit).toBe(f.head);
} else {
await expect(performManagedSync(engine, { ...f.opts, dryRun: true })).rejects.toMatchObject({ code: 'page_identity_changed' });
- await expect(performManagedSync(engine, f.opts)).rejects.toMatchObject({ code: 'page_identity_changed' });
- expect(await engine.executeRaw('SELECT id FROM persistence_requests WHERE source_id=$1', [f.id])).toEqual([]);
+ // GBRA-130 B-3 (was: the pass refused page_identity_changed): both spellings are held, neither is imported or deleted,
+ // and an unrelated file in the same sync imports.
+ writeFileSync(join(f.root, 'notes/other.md'), 'An unrelated synthetic note.\n');
- execFileSync('git', ['-C', f.root, 'add', 'notes/other.md']);
- execFileSync('git', ['-C', f.root, 'commit', '-qm', 'Add an unrelated note']);
++ await gitAsync(f.root, 'add', 'notes/other.md');
++ await gitAsync(f.root, 'commit', '-qm', 'Add an unrelated note');
+ const result = await performManagedSync(engine, f.opts);
+ expect(result.held?.map(hold => [hold.path, hold.code, hold.reason]).sort()).toEqual([['notes/example.md', 'page_identity_changed', 'spelling'], ['notes\\example.md', 'page_identity_changed', 'spelling']]);
+ expect(await engine.executeRaw("SELECT intent->>'path' AS path FROM persistence_requests WHERE source_id=$1 AND intent->>'kind' <> 'managed_sync_checkpoint' ORDER BY path", [f.id])).toEqual([{ path: 'notes/other.md' }]);
+ expect(await engine.getPage('notes/other', { sourceId: f.id })).not.toBeNull();
expect((await engine.readPageSnapshot(f.slug, { sourceId: f.id }))?.revision).toBe(f.snapshot.revision);
}
expect((await engine.readPageSnapshot(f.slug, { sourceId: f.id }))?.revision).toBe(f.snapshot.revision);
@@@ -360,13 -300,12 +360,13 @@@ check('deleting an unowned filename is
const before = await engine.readPageSnapshot(f.slug, { sourceId: f.id, includeDeleted: true });
const history = await engine.getVersions(f.slug, { sourceId: f.id });
unlinkSync(join(f.root, 'notes/example.md'));
- execFileSync('git', ['-C', f.root, 'add', '-A']);
- execFileSync('git', ['-C', f.root, 'commit', '-qm', 'Remove only an unowned duplicate']);
- const target = execFileSync('git', ['-C', f.root, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
+ await gitAsync(f.root, 'add', '-A');
+ await gitAsync(f.root, 'commit', '-qm', 'Remove only an unowned duplicate');
+ const target = (await gitAsync(f.root, 'rev-parse', 'HEAD')).trim();
const opts = { ...f.opts, full: false };
expect(await performManagedSync(engine, { ...opts, dryRun: true })).toMatchObject({ status: 'dry_run' });
- expect(await performManagedSync(engine, opts)).toMatchObject({ status: 'synced', deleted: 0, filesImported: 1, toCommit: target });
+ const result = await performManagedSync(engine, opts);
+ expect(result).toMatchObject({ status: 'synced', deleted: 0, filesImported: 0, toCommit: target, pass: { kind: 'full', outcome: 'synced', candidates: 0 } });
expect(await engine.readPageSnapshot(f.slug, { sourceId: f.id, includeDeleted: true })).toEqual(before);
expect(await engine.getVersions(f.slug, { sourceId: f.id })).toEqual(history);
expect(readFileSync(join(f.root, 'notes/recorded.md'), 'utf8')).toBe(content);
@@@ -458,10 -424,10 +458,10 @@@ check('an explicit working-tree deletio
});
check('native case aliases refuse rather than merge distinct origins', async engine => {
- const f = await fixture(engine, 'Notes/example.md', 'notes/example', { 'Notes/example.md': content });
+ const f = await fixture(engine, 'Notes/example.md', 'notes/example', { 'Notes/example.md': content, 'other.md': 'An unrelated synthetic note.\n' });
- const object = execFileSync('git', ['-C', f.root, 'rev-parse', 'HEAD:Notes/example.md'], { encoding: 'utf8' }).trim();
- execFileSync('git', ['-C', f.root, '-c', 'core.ignorecase=false', 'update-index', '--add', '--cacheinfo', `100644,${object},notes/example.md`]);
- execFileSync('git', ['-C', f.root, 'commit', '-qm', 'Add case-distinct tree entry']);
+ const object = (await gitAsync(f.root, 'rev-parse', 'HEAD:Notes/example.md')).trim();
+ await gitAsync(f.root, '-c', 'core.ignorecase=false', 'update-index', '--add', '--cacheinfo', `100644,${object},notes/example.md`);
+ await gitAsync(f.root, 'commit', '-qm', 'Add case-distinct tree entry');
if (process.platform !== 'win32') {
mkdirSync(join(f.root, 'notes'), { recursive: true });
writeFileSync(join(f.root, 'notes/example.md'), content);
@@@ -479,13 -439,8 +479,13 @@@
expect(readFileSync(join(f.root, 'notes/example.md'), 'utf8')).toBe(content);
});
+// #6712 PR 4b: a legacy deletion request an older binary admitted can still reach preparation; with no manifest entry
+// behind it, it fails closed even when the file is gone, and its accepted intent is not rewritten.
check('unknown old deletion manifests fail closed without rewriting accepted request identity', async engine => {
const f = await fixture(engine);
+ unlinkSync(join(f.root, 'notes/example.md'));
- execFileSync('git', ['-C', f.root, 'add', '-A']);
- execFileSync('git', ['-C', f.root, 'commit', '-qm', 'Remove the synthetic source file']);
++ await gitAsync(f.root, 'add', '-A');
++ await gitAsync(f.root, 'commit', '-qm', 'Remove the synthetic source file');
const legacy = await legacyDeletion(engine, f, true);
await engine.executeRaw("DELETE FROM op_checkpoints WHERE op='managed-sync-manifest' AND fingerprint=$1", [legacy.cursor.runId]);
const row = (await getWriteRequest(engine, legacy.cursor.authority.writer.principal, legacy.requestId))!;
@@@ -495,24 -450,16 +495,24 @@@
await engine.executeRaw("UPDATE persistence_requests SET state='cancelled' WHERE id=$1::uuid", [row.id]);
});
-check('an admitted deletion cannot infer a missing page origin from its slug', async engine => {
+// #6712 PR 4b: the pass reads pages by their recorded origin. A synced page whose origin was cleared, and whose file is
+// gone, is no deletion candidate and no hold: it stays live, and an older binary's admitted deletion of it is cancelled with
+// its intent unchanged.
+check('a pass never infers a missing page origin from its slug: the origin-less page stays live and an admitted legacy deletion of it is cancelled unchanged', async engine => {
const f = await fixture(engine);
+ expect((await performManagedSync(engine, f.opts)).status).toBe('first_sync');
unlinkSync(join(f.root, 'notes/example.md'));
- execFileSync('git', ['-C', f.root, 'add', '-A']);
- execFileSync('git', ['-C', f.root, 'commit', '-qm', 'Remove the synthetic source file']);
+ await gitAsync(f.root, 'add', '-A');
+ await gitAsync(f.root, 'commit', '-qm', 'Remove the synthetic source file');
await engine.executeRaw('UPDATE pages SET source_path=NULL WHERE id=$1', [f.snapshot.page.id]);
+ const before = (await engine.readPageSnapshot(f.slug, { sourceId: f.id }))!;
const legacy = await legacyDeletion(engine, f, true);
- expect(await performManagedSync(engine, f.opts)).toMatchObject({ status: 'blocked_by_failures',
- managedWrite: { write_error: 'page_identity_changed', write_request: { request_id: legacy.requestId } } });
- expect((await engine.getPage(f.slug, { sourceId: f.id }))?.id).toBe(f.snapshot.page.id);
+ const result = await performManagedSync(engine, { ...f.opts, full: false });
+ expect(result).toMatchObject({ status: 'synced', deleted: 0 });
+ expect(result.held ?? []).toEqual([]);
+ expect(await engine.readPageSnapshot(f.slug, { sourceId: f.id })).toEqual(before);
+ expect(before.page.deleted_at ?? null).toBeNull();
+ expect(await deleteRequests(engine, f.id)).toEqual([{ request_id: legacy.requestId, state: 'cancelled', error_code: 'cancelled' }]);
expect((await getWriteRequest(engine, legacy.cursor.authority.writer.principal, legacy.requestId))?.intent).toEqual(legacy.intent);
});