Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

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

garrytan86f9fbffaba5
diff --cc docs/architecture/key-files/google-and-loops-continued.md
index ba87323469,9a99cac429..e12f3b86c8
--- a/docs/architecture/key-files/google-and-loops-continued.md
+++ b/docs/architecture/key-files/google-and-loops-continued.md
@@@ -23,7 -23,7 +23,7 @@@
- **`src/core/persistence/sync-authority.ts`** — trusted CLI or original remote generic job authority; rejects stdio bulk privilege promotion and runtime option expansion, intersects original grants with current principal/source policy.
- `src/core/facts/withdrawal-overlay.ts` — pure legacy-fence enumeration and withdrawal rendering shared by coherent snapshots, stale imports and physical forget mirrors. The shared snapshot overlay and import pre-publication validator recognize canonical prefixed/inline markers and distinguish malformed live segments. Discovery refuses matching ambiguous claims before mutation. Fingerprints match independently in each fence, including inactive history, against both the folded (v174) and exact legacy hashes; parser-recognized markers precede preserved evidence context and earlier expiry remains intact. Regression: `test/withdrawal-overlay-concurrency.test.ts` on both engines.
- - **`src/commands/sync-persistence-delegate.ts` + `src/core/persistence/{sync-wire,sync-administration}.ts`** — pre-connect authenticated CLI sync ingress for any resident PGLite owner, including stdio MCP. The CLI JSON renderer shares the direct sync envelope. Strict options preserve source/brain selection and filtering; only current CLI credentials can advance bounded durable cursor slices. Unactivated delegation also forces import-only work and queues the owner embed drain, preserving the inline cost gate; backlogs are per-engine source sets and shutdown waits for actual provider settlement before releasing datastore ownership; the real serve E2E observes a committed receipt before SIGKILL and proves same-ID cursor recovery without breaking locks. The env and default deadlines stay progress-aware across slices (`DelegatedSyncDeadline`): past the deadline the client keeps re-entering while a slice advanced the managed cursor within one progress window, and each slice gets at least one window; `--timeout` and `--hard-deadline` stay strict. Legacy shared-secret sync refuses managed brains. `test/persistence-sync-stdio-owner.test.ts` starts a real stdio owner and exercises CLI import/read/admin, remote-lane denial and revocation without a competing datastore open. #6712 PR 1: the wire still validates an older CLI's `explicitProcessing` list by shape, then ignores it (`WIRE_SKEW_WINDOWS.explicitProcessing` in `src/core/wire-skew.ts`, floor 0.60.254.0, accepted until 2026-11-14); the cursor's opt-outs are inherited (`test/sync-owner-lane-processing-6696.test.ts`).
-- **`src/commands/sync-persistence-delegate.ts` + `src/core/persistence/{sync-wire,sync-administration}.ts`** — pre-connect authenticated CLI sync ingress for any resident PGLite owner, including stdio MCP. The CLI JSON renderer shares the direct sync envelope. Strict options preserve source/brain selection and filtering; only current CLI credentials can advance bounded durable cursor slices. Unactivated delegation also forces import-only work and queues the owner embed drain, preserving the inline cost gate; backlogs are per-engine source sets and shutdown waits for actual provider settlement before releasing datastore ownership; the real serve E2E observes a committed receipt before SIGKILL and proves same-ID cursor recovery without breaking locks. The env and default deadlines stay progress-aware across slices (`DelegatedSyncDeadline`): past the deadline the client keeps re-entering while a slice advanced the managed cursor within one progress window, and each slice gets at least one window; `--timeout` and `--hard-deadline` stay strict. Legacy shared-secret sync refuses managed brains. `test/persistence-sync-stdio-owner.test.ts` starts a real stdio owner and exercises CLI import/read/admin, remote-lane denial and revocation without a competing datastore open. #6696: the wire accepts an `explicitProcessing` list (processing keys only, no duplicates) and the owner keeps a supplied list exactly; a payload without one counts only its true-valued processing keys as typed (`typedSyncProcessing`), so a flagless resume adopts the cursor's stored options (`test/sync-owner-lane-processing-6696.test.ts`).
++- **`src/commands/sync-persistence-delegate.ts` + `src/core/persistence/{sync-wire,sync-administration}.ts`** — pre-connect authenticated CLI sync ingress for any resident PGLite owner, including stdio MCP. The CLI JSON renderer shares the direct sync envelope. Strict options preserve source/brain selection and filtering; only current CLI credentials can advance bounded durable cursor slices. Unactivated delegation also forces import-only work and queues the owner embed drain, preserving the inline cost gate; backlogs are per-engine source sets and shutdown waits for actual provider settlement before releasing datastore ownership; the real serve E2E observes a committed receipt before SIGKILL and proves same-ID cursor recovery without breaking locks. The env and default deadlines stay progress-aware across slices (`DelegatedSyncDeadline`): past the deadline the client keeps re-entering while a slice advanced the managed cursor within one progress window, and each slice gets at least one window; `--timeout` and `--hard-deadline` stay strict. Legacy shared-secret sync refuses managed brains. `test/persistence-sync-stdio-owner.test.ts` starts a real stdio owner and exercises CLI import/read/admin, remote-lane denial and revocation without a competing datastore open. #6712 PR 1: the wire still validates an older CLI's `explicitProcessing` list by shape, then ignores it (`WIRE_SKEW_WINDOWS.explicitProcessing` in `src/core/wire-skew.ts`, floor 0.60.255.0, accepted until 2026-11-14); the cursor's opt-outs are inherited (`test/sync-owner-lane-processing-6696.test.ts`).
- `src/core/facts/backstop.ts` + `src/core/entities/resolve-on-save.ts` — saved facts retain their content and provenance but use a NULL entity target when resolution falls back to slugification. Legacy extraction uses the shared exact source/entity/visibility fingerprint decision before identity-gated cosine candidates, so old facts without vector provenance still deduplicate identical text without relabeling their vectors. The conversation save caller also clears the target on ordinary resolution errors, preserves diagnostic counters, and propagates abort/budget failures. It never treats an invented slug as a verified page. #5836: `src/core/facts/subject-infer-write.ts` `inferMissingSubjects` links facts with no or fallback-only entity via `inferFactSubject` (remote callers: written page only, readable pages, caller fences, managed grant), never on the unmanaged DB-only branch, marks `entity_inferred` (context note; exact-text dedup only in both writers); `test/facts-backstop-entity-inference.test.ts`, `test/managed-facts-entity-inference.test.ts`. #6159: every writer (both backstop buckets, the fence writes and `persistence/facts-maintenance.ts`) dates a fact with `facts/event-time.ts` `factEventTime` (extractor date, then `validFrom`, then `turnAt`, then now) and the extraction prompt's observation date falls back to `turnAt`; the sweep's corpus pass sets `turnAt` from the session file's write time, vetted by `context/corpus-windows.ts` `corpusFactTime` (finite, from 2000, at most 60 s ahead; otherwise logged and dated at extraction) (`test/sweep-corpus-fact-time.test.ts`). #6113: `resolveManagedFactsEmbedding` (`persistence/facts-maintenance.ts`) reads the brain's DB-plane model only; a legacy row without a provider refuses `embedding_configuration` naming `gbrain migrate embeddings --to <gateway provider>:<model> --dry-run` (the read-only preview; applying it needs paid authorization). Test: `test/facts-embedding-bare-model.serial.test.ts`. The notability-filter vocabulary (`NOTABILITY_FILTERS`, `coerceNotabilityFilter`) lives in import-light `src/core/facts/notability-filter.ts` (re-exported here) beside the page-write key resolver. The unmanaged pipeline counts entity groups held on a facts fence that does not parse cleanly as `fence_refused` (nothing written for them). Large pages A7: the page entry (`runPipeline`) plans with the `facts_backstop` watermark (`src/core/extraction-watermark.ts`, cap `MAX_TURN_TEXT_CHARS`): past a matching watermark the extractor reads only the appended text (`PipelineInput.extractText`; `turnText` stays the full body, which the managed preparer compares with the page), an unchanged long page makes no model call, and a head or tail-window read returns `input_truncated` on the inline result; the plan commits after an extraction that neither failed nor aborted. Test: `test/extraction-watermark-facts.test.ts`.
- `src/commands/migrations/v0_32_2.ts` + `src/core/facts/unfenced-facts.ts` — Phase B is the shared core pass `planUnfencedFacts` / `fenceUnfencedFacts`, which the `extract_facts` cycle phase also runs on every cycle (#5299). It fences live unfenced facts (`row_num IS NULL`) only onto an existing source-scoped page, and never ontology observations (`dimension IS NOT NULL`, #6264: they belong to the ontology, keyed by their own provenance) and its recorded canonical file; a managed brain publishes each page as one coordinator `managed_maintenance_adopt_fact_fence` request (database-only pages included; a read-only pre-pass of `planManagedPage` counts the pages that will submit for the up-front lifetime-ID check, so suppressed or unadoptable pages never refuse the step, and the submit loop replans each page right before it submits; `test/fact-fence-adoption-exits.test.ts`), and an unmanaged page is written under the source filesystem lock and page lock (`.tmp` + parse + rename), mirrored into `pages` and stamped in one maintenance transaction, and committed when the checkout is durability-hardened. Missing pages/files are counted as `skipped_no_page` (a recorded canonical file absent on this host is also listed in `missing_files`), never materialized as stubs. #6610: an unmanaged database-only page (no `source_path`/`source_uri`, no file at its slug path) is fenced in its database body through the coordinator (`fenceDatabaseOnlyPage`, no file target) when `resolveFactWriteTarget` makes the write database-only; an unbound source without `persistence.unbound_write=database_only` leaves its rows in `unbound_refused`, which `extract_facts` holds out of reconciliation without gating and doctor `fence_integrity` reports as `unbound_legacy_facts` with the opt-in (`ask_user`). The migration adds a dirty-tree refusal that stays inside the source subdirectory; fence row allocation respects both database-owned row numbers and the parsed fence, preserving idempotent recovery without collisions. Dry runs use the same eligibility checks, and historical drift remains visible rather than silently repaired. #6278: `planFence` uses the fence codec as the oracle (`adoptableClaim`): a legacy row adopts only when `parseFactsFence(renderFactsTable([row]))` hands its claim back active and non-empty with the same kind, visibility, validity and source, differing from the stored text by whitespace and line endings alone (trim, CRLF/CR to LF, NBSP), and the parsed text is written into `facts.fact` with the row number on both the managed and the unmanaged path, so the projection keeps the row's id, vectors and provenance. A row the codec would change further (whitespace-only, `~~x~~`, a literal `<br>`) or a second row whose normalized claim, source and visibility the page already carries stays a legacy row exactly as it is, recorded as an `UnadoptableFactRecord` (source, page, fact id, reason class; never the claim text) and named in `failed_pages` as `FACTS_FENCE_FAILED: <slug> (fence_unrenderable: N row(s), <class>)` in the cycle and the migration output; the page's other rows still adopt. Tests: `test/facts-fence-adoption-roundtrip.test.ts`, `test/extract-facts-unfenced-rows.test.ts`, `test/migrations-v0_32_2-managed.test.ts`.
diff --cc docs/architecture/key-files/managed-sync-bookkeeping.md
index 49cd20e195,75c50c8062..f2e6060e4a
--- a/docs/architecture/key-files/managed-sync-bookkeeping.md
+++ b/docs/architecture/key-files/managed-sync-bookkeeping.md
@@@ -13,9 -13,9 +13,9 @@@ run, and the supersession of a checkpoi
- `src/core/persistence/managed-sync-orphans.ts` + `src/core/repair/managed-sync-orphans.ts` — `gbrain repair managed-sync-orphans --source <id>` (#5459), explicit-only and preview-bound (approved set, `preview_changed` on drift). `classifyManagedSyncOrphans` (read-only; doctor `sync_failures` names the repair when it finds any) takes the source's managed-sync bookkeeping and classes each row `no_cursor` (a failure row with no cursor to resume), `principal_unadoptable` (an unfinished cursor recorded by a principal that is no longer an active local writer, by join on the recorded principal), `superseded` (a pre-options cursor a later run replaced), `incarnation_retired` (#6518: an unfinished cursor or a failure row recorded under a source incarnation the source no longer has, joined on the source id alone, archived sources excluded, a live pending request still retaining it) or `mirror_only` (#6518: a local ledger row with a `managed_cursor_key` and no durable failure row under that key; `mirrorOnlyManagedFailures`, which throws on a failed durable read rather than naming every mirror), and keeps `pending_request_live` and `resumable` rows untouched. `retireManagedSyncOrphan` retires one row atomically: an `incarnation_retired` cursor needs the source still active under another incarnation at apply time and skips the live-writer veto (no retired key is resumable); a `mirror_row` deletes nothing durable and prunes the ledger row only when the durable read, repeated at apply, still finds none. `pruneMirrorOnlyManagedFailures` is the successful-sync path (`clearSettledManagedSyncFailures`). Doctor `sync_failures` classifies whenever the brain is reachable, so the diagnostic is reachable with no current-incarnation failure visible, and reports a failed classification as unknown. `sources set-strategy` points at it when an unfinished run blocks a strategy change. Pinned by `test/repair-managed-sync-orphans.test.ts` and `test/managed-sync-orphans-incarnation-6518.test.ts` (both engines); `test/repair-explicit-only.test.ts` pins its place last in `REPAIR_KINDS`.
- - `src/core/persistence/sync-cursor-key.ts` — #6712 PR 1: one managed cursor per source. `managedCursorKey` is a digest of the source incarnation and, for a company approval only, the company; writer principal, authority and options no longer select a cursor. `legacyManagedCursorKey` reproduces the pre-0.60.254.0 key (read-only). `resolveManagedCursor` is the one boundary that picks a run's key and folds older keys in crash-safely under the drain lease: the canonical unfinished cursor wins, else the newest older-key unfinished cursor is adopted and finished in place under its own key; every other older cursor has its queued requests cancelled and is retired through `retireManagedSyncOrphan` (reason `superseded_by_adoption`, fenced by `assertDrainLease`). A cursor with a running, recovering or publishing request or a recovery row is retained and the pass waits for that request (`writer_pending`) before it drains anything. A company brain's finished old-key cursors are kept. Pinned by `test/persistence-sync-cursor-adoption.test.ts` and `test/persistence-sync-cursor-strategy-6696.test.ts`.
-- `src/core/persistence/managed-retry-actions.ts` — the next action `sync --retry-failed` prints for each managed failure held under another cursor key (#6696, read-only). `resumable` when the row recorded its options or an option set reproduces its cursor key exactly (the run's own options with and without the source's configured strategy and `--full`, or the options another cursor of the source recorded; the key is a digest, so a match is those options): a `replay` when an unfinished run holds the key, a `fresh_discovery` (a new run from HEAD under those options that clears the key's failures when it completes) when none does. `orphaned` when `classifyManagedSyncOrphans` names it (the repair preview). `unresolved` otherwise: a request still in flight (`sync status`), or an option-less cursor nothing selects, which a completed current run supersedes so the orphan repair retires it. One line per distinct command, the command last. Pinned by `test/sync-legacy-retry-actions-6696.test.ts` (both engines), whose printed actions, run as printed, settle every original row.
-
-- `src/core/persistence/sync-cursor-key.ts` — `managedCursorKey` (digest of incarnation, writer principal and authority, company approval and cursor-selecting options) and `selectManagedCursor`, the one boundary that picks a managed run's key (#6696); see the `sync-run.ts` entry.
++- `src/core/persistence/sync-cursor-key.ts` — #6712 PR 1: one managed cursor per source. `managedCursorKey` is a digest of the source incarnation and, for a company approval only, the company; writer principal, authority and options no longer select a cursor. `legacyManagedCursorKey` reproduces the pre-0.60.255.0 key (read-only). `resolveManagedCursor` is the one boundary that picks a run's key and folds older keys in crash-safely under the drain lease: the canonical unfinished cursor wins, else the newest older-key unfinished cursor is adopted and finished in place under its own key; every other older cursor has its queued requests cancelled and is retired through `retireManagedSyncOrphan` (reason `superseded_by_adoption`, fenced by `assertDrainLease`). A cursor with a running, recovering or publishing request or a recovery row is retained and the pass waits for that request (`writer_pending`) before it drains anything. A company brain's finished old-key cursors are kept. Pinned by `test/persistence-sync-cursor-adoption.test.ts` and `test/persistence-sync-cursor-strategy-6696.test.ts`.
+- `src/core/persistence/sync-lease.ts` — #6712 PR 1: the drain lease, one managed drainer per source. `withDrainLease` takes the source's sync lock (`syncLockId`) with a 2-minute TTL renewed every 20 s, so a dead holder's lease lapses inside one cron tick; it is reentrant for the holder (nested passes and the in-process lanes reuse it). The holder record (`managed-sync-lease` checkpoint: kind, id, version, start) plus the lock row give `readDrainHolder` (host, pid, heartbeat, `progress`: commits, last commit, last cursor save). A non-job holder also writes a beacon row in the `gbrain-drain-lease` minion queue (application authority, `max_stalled` 0, renewed with the lease, deleted on release) so an older binary's `liveSyncJob` backs off; downgrades are quiescent (stop serve and crons first). `assertDrainLease` is the fence inside every transaction that admits work, settles or holds an entry, folds a cursor in or swaps the cursor. Following callers (the CLI, a CLI run delegated to a serve) wait for a live holder within their budget (`followStopAt`) and take over when it releases; out of budget, or after losing the lease, they return `leaseHeldResult` (`resumable`, `sync_drain_lease_held`, `next.retry_after_ms` 60 s, `safe_to_loop`); a holder with no progress for `HOLDER_STALL_MS` (5 min) returns `leaseStalledResult` (`blocked`, `drain_stalled`, cause `no_progress`, `stall.lease_holder`). Jobs and the cycle get `SyncLockBusyError` and skip. Pinned by `test/persistence-sync-lease.test.ts`.
- - `src/core/wire-skew.ts` — #6712 PR 1: the one record of wire-skew windows, each a version floor plus a calendar date (`WIRE_SKEW_WINDOWS.explicitProcessing`: floor 0.60.254.0, accepted and ignored until 2026-11-14). The delegation and admin wires read the field name from here, so removing the window is one edit.
++- `src/core/wire-skew.ts` — #6712 PR 1: the one record of wire-skew windows, each a version floor plus a calendar date (`WIRE_SKEW_WINDOWS.explicitProcessing`: floor 0.60.255.0, accepted and ignored until 2026-11-14). The delegation and admin wires read the field name from here, so removing the window is one edit.
- `src/core/persistence/managed-sync-flags.ts` — `managedForbiddenFlag` / `managedSyncFlagRefusal`: the `managed_sync_flag_refused` refusal for `--skip-failed` / `--include-gitignored` on a managed source (#6696), raised at `gbrain sync` parse, in `maybeDelegateManagedSyncToServe` before the socket, and by `resolveManagedSyncContext`.
diff --cc docs/guides/concurrent-writes.md
index f1cb8e2f56,23611d5570..e51948f961
--- a/docs/guides/concurrent-writes.md
+++ b/docs/guides/concurrent-writes.md
@@@ -540,10 -540,10 +540,10 @@@ gbrain sync --source example-source --n
Use `--no-embed` and `--no-extract` here only if they were the original sync
options; retain the original `--no-schema-pack` choice as well. An unfinished
-cursor keeps its processing options: a run that omits these flags (including
-autopilot and `sync` jobs) adopts them, and an explicit conflicting flag refuses
-with `cursor_processing_options_conflict`, naming the stored options and the
-exact resume command. Explicit retry
+cursor keeps its processing opt-outs: every run that resumes it (including
+autopilot and `sync` jobs) inherits them, a flag that asks for more processing
+than the cursor stored is reported as inherited instead of refused, and the
- result names it in `inherited_options` (since 0.60.254.0, #6712). Explicit retry
++result names it in `inherited_options` (since 0.60.255.0, #6712). Explicit retry
retains old terminal receipts, refuses while work is still active and creates
fresh guarded requests. It does not ignore revision conflicts. Inspect the
result and the original withdrawal receipt, then verify that the fact is inactive
diff --cc docs/guides/write-refusals.md
index d10342480c,34788addf2..34924c5f34
--- a/docs/guides/write-refusals.md
+++ b/docs/guides/write-refusals.md
@@@ -64,7 -64,7 +64,7 @@@ of making a duplicate
| <a id="recreated-root"></a>recreated or moved canonical root | `recovery_required` | The checkout at the recorded path is a different directory (new inode and birth time after a restore, a rebuilt container or a Migration Assistant copy) or the recorded path now resolves through a symlink; without this release every verb, self-transfer included, refused with no exit (#5914). | Same path, directory recreated: the self-transfer above with `--confirm-relocated-root` on **both** phases; it waives only the directory identity comparison and needs the reservation beside the root (`.gbrain-owner-<hash>.json`) and the stamp to agree on token, brain, worktree, root and coordination path. Recorded path now a symlink to the moved checkout: `gbrain sources set-path <source> <path>` on the owner host keeps the worktree and moves its records. `gbrain sources writer deactivate --dry-run` lists `physical_root` when its real run would refuse. Runbook: [recreated root](../architecture/topologies.md#recreated-root). Never delete ownership marker files. |
| <a id="embedding_budget_below_worst_case"></a>`embedding_budget_below_worst_case` | `embedding_budget_below_worst_case` | `gbrain migrate embeddings` (or the local `migrate_embeddings` operation) was given a `--max-cost-usd` cap below the migration's worst-case authorization: every planned provider request at its maximum input size, plus any debits a resumed run already holds. The run stopped before any provider request, re-chunk or vector invalidation, so nothing changed. The message and JSON carry `cap_usd`, `worst_case_usd`, `debited_usd` and `required_cap_usd`. | Re-run with the value the `suggestion` names, for example `gbrain migrate embeddings --to <provider:model> --dim <N> --max-cost-usd <required_cap_usd> --yes` (operation: `max_cost_usd`). Preview first with `--dry-run`, which prints the worst-case authorization beside the estimate. Requests settle to reported usage, so actual spend is usually far below the cap. See [embedding migration](embedding-migration.md). |
| frontmatter slug conflict | `frontmatter_slug_conflict` (`invalid_params` on a gbrain older than v0.60.47.0) | A file's frontmatter `slug:` names a different page than its path. On a write nothing is written; during sync the file is held and the rest of the source imports. | Remove the `slug:` line or make it match the path, commit, then sync. See [`frontmatter_slug_conflict`](#frontmatter_slug_conflict). |
- | `cursor_processing_options_conflict` | `invalid_params` | Retired in 0.60.254.0 (#6712): no longer returned. An unfinished sync's processing opt-outs (`--no-embed`, `--no-extract`, `--no-schema-pack`) are inherited by every run that resumes it, and the result names them in `inherited_options`. An older gbrain still returns it when a run's processing flags conflict with the cursor's. | On an older gbrain, run the printed resume command (`gbrain sync --source <source> --no-pull` plus the saved flags) or drop the conflicting flag. After upgrading, rerun the sync: it finishes the cursor with its stored opt-outs. |
-| `cursor_processing_options_conflict` | `invalid_params` | An unfinished sync's processing options (`--no-embed`, `--no-extract`, `--no-schema-pack`) conflict with this run, or the cursor predates saved options and has none. When options are saved, a run that omits those flags, including autopilot and `sync` jobs, adopts them. | When the message prints a resume command (`gbrain sync --source <source> --no-pull` plus the saved flags), run it or drop the conflicting flag. When it reports no saved options, resolve pending requests first, then rediscover with `gbrain sync --source <source> --no-pull --retry-failed` and the processing flags you want. |
++| `cursor_processing_options_conflict` | `invalid_params` | Retired in 0.60.255.0 (#6712): no longer returned. An unfinished sync's processing opt-outs (`--no-embed`, `--no-extract`, `--no-schema-pack`) are inherited by every run that resumes it, and the result names them in `inherited_options`. An older gbrain still returns it when a run's processing flags conflict with the cursor's. | On an older gbrain, run the printed resume command (`gbrain sync --source <source> --no-pull` plus the saved flags) or drop the conflicting flag. After upgrading, rerun the sync: it finishes the cursor with its stored opt-outs. |
| `take_row_collision` | `take_row_collision` | A save adds a takes-table row whose row number already belongs to a different take that exists only in the database. The save stops instead of overwriting that take. | Renumber the new takes row, or add the existing take to the page's takes table, then save with the current `expected_revision` and a **new** request ID (the content changed). |
| `invalid_source_uri` | `invalid_source_uri` | The brain has shared skillpacks, and the page's stored `source_uri` is a `file:` URI that cannot be turned into a local path, so gbrain cannot prove the write stays outside a skillpack. Shared-skill protection stays on. | The source owner inspects the page's stored `source_uri` on the brain host and replaces it with an absolute file URI or clears it; there is no dedicated command yet. Retry with a **new** request ID. |
| `queue_capacity` | `queue_capacity` | Admission would exceed a write-journal limit. Existing requests keep their place; nothing is evicted. For the cumulative limits (lifetime request IDs and receipt bytes), `detail` names the limit, for example `principal_lifetime_ids`; for the outstanding-request caps, `detail` carries the counts (`outstanding=<used> limit=<limit>`), and a managed `gbrain sync` drain waits them out ([`write_capacity`](#drain-write-capacity)). | For a cumulative limit, run the printed `gbrain config set persistence.limits.<limit> <value>` (sized for about one more year at the current rate), then retry with the **same** request ID. For outstanding-request, queued-byte or recovery-byte limits, let outstanding requests finish and check `gbrain sources writer status`. See [bounded admission and retention](concurrent-writes.md#bounded-admission-and-retention). |
diff --cc src/core/behavior-change-notice.ts
index b8d91de69a,a947ca3ca3..849285b4d2
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@@ -627,10 -627,6 +627,10 @@@ export const BEHAVIOR_CHANGES: Readonly
// Large pages A3/T44, A4/T32 (Lane 3a).
{ since: '0.60.242.0', text: 'Replacing a page\'s chunks now writes them in bounded batches (at most 500 rows and 16 MiB of encoded rows per statement) after one prune, all in the same transaction, instead of one statement carrying every chunk. A page with thousands of chunks no longer builds one giant statement, and a failure in any batch still rolls the whole replacement back.' },
{ since: '0.60.242.0', text: 'A chunk vector is now tied to the chunk\'s text and its full embedding input rather than its position. When an edit inserts or removes chunks above it, a projection rebuild moves the unchanged chunk to its new index with its vector instead of dropping it, so only new or changed chunks wait for embedding. An embed that finishes after the page changed now commits the vectors of the chunks that are still the same (same text, source and embedding input) and leaves the rest for the next run, instead of discarding the whole run; the page\'s embedding signature is stamped only when every chunk got its vector. A vector built under an old title or synopsis is still dropped.' },
+ // #6712 PR 1 lane B (prescreen, file_drift, lost-manifest re-discovery); `since` is a placeholder until the merge-slot stamp.
- { since: '0.60.254.0', text: 'A managed sync now skips a file whose import provenance matches it (same bytes on disk, the page still at the revision that import wrote, the same parser) without preparing it: discovery prescreens it and the guarded no-op checks pass it in one transaction. Sync receipts carry a `prescreened` count. A no-change tree walk of 2,000 pages dropped from about 10 s to under 1 s. `--full` bypasses the prescreen.' },
- { since: '0.60.254.0', text: 'A managed sync no longer imports a file over a database version of its page that sync never saw. When the page changed since its file was last imported (or, in a tree walk such as a first sync, `--full` or an unreachable checkpoint, has no usable import record) and the import would change it, the file is held with the new code `file_drift` and the page keeps the database version; `gbrain repair file-drift --prefer database|file` resolves it. Pages under `storage.keep_db` prefixes are not held: the keep_db worker reconciles them from the database. These holds never escalate; with `sync.holds=fail` the run stops with `file_drift` instead. A page that survived a shared-origin delete is held too: the delete\'s warning and the hold both name `gbrain repair file-drift --prefer file` instead of `sync --full`.' },
- { since: '0.60.254.0', text: 'A managed sync whose frozen manifest is missing no longer stops with `storage_error` until an explicit `--retry-failed`: the next sync re-discovers the whole tree at HEAD and finishes, skipping what the lost run already imported. Dry runs and company-brain sources keep the refusal.' },
++ { since: '0.60.255.0', text: 'A managed sync now skips a file whose import provenance matches it (same bytes on disk, the page still at the revision that import wrote, the same parser) without preparing it: discovery prescreens it and the guarded no-op checks pass it in one transaction. Sync receipts carry a `prescreened` count. A no-change tree walk of 2,000 pages dropped from about 10 s to under 1 s. `--full` bypasses the prescreen.' },
++ { since: '0.60.255.0', text: 'A managed sync no longer imports a file over a database version of its page that sync never saw. When the page changed since its file was last imported (or, in a tree walk such as a first sync, `--full` or an unreachable checkpoint, has no usable import record) and the import would change it, the file is held with the new code `file_drift` and the page keeps the database version; `gbrain repair file-drift --prefer database|file` resolves it. Pages under `storage.keep_db` prefixes are not held: the keep_db worker reconciles them from the database. These holds never escalate; with `sync.holds=fail` the run stops with `file_drift` instead. A page that survived a shared-origin delete is held too: the delete\'s warning and the hold both name `gbrain repair file-drift --prefer file` instead of `sync --full`.' },
++ { since: '0.60.255.0', text: 'A managed sync whose frozen manifest is missing no longer stops with `storage_error` until an explicit `--retry-failed`: the next sync re-discovers the whole tree at HEAD and finishes, skipping what the lost run already imported. Dry runs and company-brain sources keep the refusal.' },
// #6712 PR 0 (#6694 + write-only provenance); `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.
{ since: '0.60.248.0', text: 'A managed sync of a source rooted at its Git repository root now checkpoints whichever `slug_root_mode` the source pins (both modes give it the same slugs) and keeps that pin; before, a `source-root` pin failed every checkpoint with `revision_conflict`. A plain `gbrain sync --no-pull --source <id>` now finishes a checkpoint that already failed this way. On a source in a subdirectory, a pin that changes while a sync runs is refused as `slug_root_mode_mismatch` (a person chooses the mode) instead of `revision_conflict`; restoring the pin lets the next plain sync finish. After a downgrade, an older gbrain reports these as `revision_conflict` again.' },
{ since: '0.60.248.0', text: 'Managed-sync import provenance now also records the bytes each publish left on disk (`disk_sha256`, `disk_blob_oid`: the canonical writeback when sync rewrote the file), the page revision it produced and what parsed it (import parser version, Markdown chunker, schema pack), and a sync that skips an unchanged file records the same. Nothing reads these yet; a later release uses them to skip unchanged files. Records written before this release lack them and are replaced on the next import of their page; an older gbrain ignores them.' },
@@@ -652,16 -648,8 +652,18 @@@
// W1 trust prerequisites (#6783 §12 (a) and (b)).
{ since: '0.60.253.0', text: 'A write less trusted than a take or timeline row no longer deletes, replaces or deactivates it. A page publish (`put_page`, sync, a maintenance republish) that drops or rewrites such a row, `takes_remove`, the takes reconcile (`gbrain extract takes`) and the timeline orphan prune now keep the row as it is and file a `forget` proposal (`gbrain trust review`): `gbrain trust confirm tp<id>` applies the change, `gbrain trust drop tp<id>` keeps the row. A refused `takes_remove` returns `forget_requires_owner` with the proposal ref. The page text keeps what the writer published, and the put_page response lists the proposals under `contested`.' },
{ since: '0.60.253.0', text: 'Lowering a row\'s trust tier now lowers what was derived from it: facts, takes, pages and timeline rows reached through their recorded derivation inputs drop to the least trusted of their current inputs (an agent edit that lowers a page, an owner tier change, the `gbrain trust claim-sources` relower repair, a derived republish, a fence field rewrite). Raising a tier never promotes a derivative, and recorded history keeps its tiers. A lowered row\'s `write_origin.input_lowered` names the tier it had; on a managed brain a dependent in another source is marked `needs_rederive` instead.' },
- // #6712 PR 1 lane C (L2 one page, one fate, #6565, #6600): pass once VERSION is stamped 0.60.254.0 (behavior-change-notice.test.ts fresh-install cases).
- { since: '0.60.254.0', text: 'A managed sync now gives each page its own fate (#6712): a page that does not commit is held, retried or stops the run on its own, and the pages admitted after it still publish and are counted from their own receipts. Before, one failed page cancelled the rest of its bulk group and every group admitted ahead of it, and later syncs re-froze them. Two changes of one page in one sync (a delete and an import of one slug, say) are never published in the same group, and the later one is held behind the earlier one (`blocked_on`) when that one is held. `sync.knock_on_refreeze_limit` and `sync.knock_on_run_limit` are retired (`gbrain config set` refuses them) and `knock_on_exhausted` is no longer raised; an older receipt with it reads as superseded. The write owner must run this release.' },
- { since: '0.60.254.0', text: 'A file that changed after its sync request was admitted (`source_changed`) is now retried after the manifest\'s last entry, up to three times, before it is held `worktree_dirty` (before: one retry in place). A dropped connection re-freezes the entry in place; an unrecognized database refusal (an unknown P0001 or a 55000, #6565) stops the run as systemic with the classifier\'s action, and the next plain sync re-freezes the stopped entry, at most three times in a row before `--retry-failed` is needed. A held deletion whose exact page an authorized delete already removed (#6600) settles and clears its hold. `preparation_stalled` holds are retried by every sync until their third attempt, a `concurrent_write` hold is re-screened when its page\'s revision moves, and `--retry-failed` now rediscovers a run whose checkpoint a receipt still blocks.' },
+ // Held-removal accept fix. `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.
+ { since: '0.60.254.0', text: 'Accepting a held take change (`gbrain trust confirm tp<id>`, or accept-all in `gbrain trust review`) that struck a take through or changed its kind or holder now applies exactly that change. On v0.60.253.0 the accept removed the take from the page and the takes index instead (a take graded in its fence was refused and kept). `gbrain repair accepted-takes` lists each take the records prove was removed that way and, with `--apply --expect <hash>`, restores it at the tier of the accepted write; a grade only the database held is not restored. Accepting a held take or timeline change on a page stored in segments now applies it instead of refusing with `page_body_segmented`.' },
++ // #6712 PR 1 lane C (L2 one page, one fate, #6565, #6600): pass once VERSION is stamped 0.60.255.0 (behavior-change-notice.test.ts fresh-install cases).
++ { since: '0.60.255.0', text: 'A managed sync now gives each page its own fate (#6712): a page that does not commit is held, retried or stops the run on its own, and the pages admitted after it still publish and are counted from their own receipts. Before, one failed page cancelled the rest of its bulk group and every group admitted ahead of it, and later syncs re-froze them. Two changes of one page in one sync (a delete and an import of one slug, say) are never published in the same group, and the later one is held behind the earlier one (`blocked_on`) when that one is held. `sync.knock_on_refreeze_limit` and `sync.knock_on_run_limit` are retired (`gbrain config set` refuses them) and `knock_on_exhausted` is no longer raised; an older receipt with it reads as superseded. The write owner must run this release.' },
++ { since: '0.60.255.0', text: 'A file that changed after its sync request was admitted (`source_changed`) is now retried after the manifest\'s last entry, up to three times, before it is held `worktree_dirty` (before: one retry in place). A dropped connection re-freezes the entry in place; an unrecognized database refusal (an unknown P0001 or a 55000, #6565) stops the run as systemic with the classifier\'s action, and the next plain sync re-freezes the stopped entry, at most three times in a row before `--retry-failed` is needed. A held deletion whose exact page an authorized delete already removed (#6600) settles and clears its hold. `preparation_stalled` holds are retried by every sync until their third attempt, a `concurrent_write` hold is re-screened when its page\'s revision moves, and `--retry-failed` now rediscovers a run whose checkpoint a receipt still blocks.' },
+ // #6712 PR 1 lane A (drain lease, one cursor, options inheritance).
- { since: '0.60.254.0', text: 'A managed source now has one drainer at a time (#6712): every managed sync pass (the CLI, `--no-delegate` included, a serve, a `sync` job, the dream cycle) runs under the source\'s drain lease, a 2-minute lease renewed every 20 s, so a crashed holder\'s lease lapses within one cron tick. A second `gbrain sync` follows the holder within its own `--timeout`, printing the holder (kind, pid, host, version) and the pages it commits, and takes over when the holder finishes; out of budget it exits 0 `resumable` with code `sync_drain_lease_held`, `next.retry_after_ms` 60 s and `safe_to_loop`. Ctrl-C stops following and leaves the holder running. A `sync` job or the cycle that finds the lease held skips, as it did on the sync lock.' },
- { since: '0.60.254.0', text: 'A `gbrain sync` that follows another drainer no longer exits 0 forever behind a wedged one: when the lease holder commits no page and saves no cursor for 5 minutes, the run stops `blocked` (exit 1) with `drain_stalled`, cause `no_progress`, `drain.stall.lease_holder` naming the holder, and a fix that reads `gbrain sources writer status --source <id> --json` and names `gbrain sync --source <id> --no-pull --break-lock` for a holder that is gone.' },
- { since: '0.60.254.0', text: 'A managed source keeps one sync cursor (#6712): the cursor key is the source incarnation (plus the company, for a company approval) instead of a digest of the writer, its authority and the options, so a CLI run, a serve, a job and a different writer all resume the same cursor. An unfinished cursor an older gbrain left under another key is finished in place under that key and reported in `cursorAdopted`; other old-key cursors are retired (`superseded_by_adoption`, queued requests cancelled) once nothing under them is running, and a run waits (`writer_pending`) for a request still running under one before it publishes. `cursorFanIn` counts them.' },
- { since: '0.60.254.0', text: 'Resuming an unfinished managed sync never refuses over processing options any more (#6712): the cursor\'s `--no-embed`, `--no-extract` and `--no-schema-pack` opt-outs are inherited by every run that resumes it, a flag that would have asked for more processing is reported in `inherited_options` (and printed), and `cursor_processing_options_conflict` is no longer returned. A writer that resumes another writer\'s cursor admits the rest under its own validated grant; requests already admitted stay under their original principal, are read and cancelled under it, and are never rewritten.' },
- { since: '0.60.254.0', text: 'The delegation wire\'s `explicitProcessing` field is accepted from a sync client below 0.60.254.0 and ignored until 2026-11-14 (`WIRE_SKEW_WINDOWS` in `src/core/wire-skew.ts`), then removed. `gbrain sync --retry-failed` on a managed source now counts every failure of the source, since no failure sits under another cursor key.' },
- { since: '0.60.254.0', text: 'Downgrading below 0.60.254.0 must be quiescent: stop `gbrain serve`, autopilot and sync crons, let the running sync finish, then downgrade. An older binary does not take the drain lease; while a newer non-job holder drains, it writes a `gbrain-drain-lease` row that the live-sync check of 0.60.231.0 and later sees, so such an autopilot backs off instead of dispatching a second sync, but an older CLI started beside a newer drainer is not fenced. An older gbrain resumes an old-key cursor only; a cursor this release created under the new key is invisible to it and is rediscovered from the last synced commit.' },
++ { since: '0.60.255.0', text: 'A managed source now has one drainer at a time (#6712): every managed sync pass (the CLI, `--no-delegate` included, a serve, a `sync` job, the dream cycle) runs under the source\'s drain lease, a 2-minute lease renewed every 20 s, so a crashed holder\'s lease lapses within one cron tick. A second `gbrain sync` follows the holder within its own `--timeout`, printing the holder (kind, pid, host, version) and the pages it commits, and takes over when the holder finishes; out of budget it exits 0 `resumable` with code `sync_drain_lease_held`, `next.retry_after_ms` 60 s and `safe_to_loop`. Ctrl-C stops following and leaves the holder running. A `sync` job or the cycle that finds the lease held skips, as it did on the sync lock.' },
++ { since: '0.60.255.0', text: 'A `gbrain sync` that follows another drainer no longer exits 0 forever behind a wedged one: when the lease holder commits no page and saves no cursor for 5 minutes, the run stops `blocked` (exit 1) with `drain_stalled`, cause `no_progress`, `drain.stall.lease_holder` naming the holder, and a fix that reads `gbrain sources writer status --source <id> --json` and names `gbrain sync --source <id> --no-pull --break-lock` for a holder that is gone.' },
++ { since: '0.60.255.0', text: 'A managed source keeps one sync cursor (#6712): the cursor key is the source incarnation (plus the company, for a company approval) instead of a digest of the writer, its authority and the options, so a CLI run, a serve, a job and a different writer all resume the same cursor. An unfinished cursor an older gbrain left under another key is finished in place under that key and reported in `cursorAdopted`; other old-key cursors are retired (`superseded_by_adoption`, queued requests cancelled) once nothing under them is running, and a run waits (`writer_pending`) for a request still running under one before it publishes. `cursorFanIn` counts them.' },
++ { since: '0.60.255.0', text: 'Resuming an unfinished managed sync never refuses over processing options any more (#6712): the cursor\'s `--no-embed`, `--no-extract` and `--no-schema-pack` opt-outs are inherited by every run that resumes it, a flag that would have asked for more processing is reported in `inherited_options` (and printed), and `cursor_processing_options_conflict` is no longer returned. A writer that resumes another writer\'s cursor admits the rest under its own validated grant; requests already admitted stay under their original principal, are read and cancelled under it, and are never rewritten.' },
++ { since: '0.60.255.0', text: 'The delegation wire\'s `explicitProcessing` field is accepted from a sync client below 0.60.255.0 and ignored until 2026-11-14 (`WIRE_SKEW_WINDOWS` in `src/core/wire-skew.ts`), then removed. `gbrain sync --retry-failed` on a managed source now counts every failure of the source, since no failure sits under another cursor key.' },
++ { since: '0.60.255.0', text: 'Downgrading below 0.60.255.0 must be quiescent: stop `gbrain serve`, autopilot and sync crons, let the running sync finish, then downgrade. An older binary does not take the drain lease; while a newer non-job holder drains, it writes a `gbrain-drain-lease` row that the live-sync check of 0.60.231.0 and later sees, so such an autopilot backs off instead of dispatching a second sync, but an older CLI started beside a newer drainer is not fenced. An older gbrain resumes an old-key cursor only; a cursor this release created under the new key is invisible to it and is rediscovered from the last synced commit.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */
diff --cc src/core/error-registry.ts
index a0639e87b4,88603df695..9b579eab25
--- a/src/core/error-registry.ts
+++ b/src/core/error-registry.ts
@@@ -391,13 -384,12 +391,13 @@@ export const CODES =
preview_changed: { class: 'caller', summary: "The state changed since the approved preview." },
profile_incompatible: { class: 'caller', summary: "The stored profile is incompatible with this operation." },
projection_owner_resident: { class: 'host_only', summary: "A resident owner holds the projection." },
- // #6643: a managed sync stopped re-freezing pages that only waited on another page of the same sync.
- knock_on_exhausted: { class: 'server', summary: "A managed sync kept re-freezing a page that only waited on another page of the same sync, and stopped at its limit because that earlier page still did not commit.",
- why: "A page cancelled or refused only because an earlier page of its sync did not commit published nothing, so the sync re-freezes it under a fresh request by itself; the limit stops a loop when the earlier page keeps failing.",
+ // #6643, retired by #6712 (one page, one fate): no page waits on another page's fate any more, so nothing re-freezes knock-ons.
- knock_on_exhausted: { class: 'server', retired_in: '0.60.254.0',
++ knock_on_exhausted: { class: 'server', retired_in: '0.60.255.0',
+ summary: "Retired: an older gbrain stopped a managed sync that kept re-freezing a page cancelled only because another page of the same sync did not commit. This build never cancels a page for another page's failure, so the stop is superseded.",
+ why: "Since #6712 each page of a sync has its own fate: a page that does not commit is held or stops the run on its own, and the pages after it still publish. A ledger row or receipt with this code was written by an older build.",
docs: 'docs/guides/sync-unblock-runbook.md#decision-table',
- suggestion: 'Read gbrain sync status --source <id> --json: last_error.root_cause names the request that keeps failing. Fix that request, or raise sync.knock_on_refreeze_limit / sync.knock_on_run_limit, then rerun the same sync.',
- fix: { argv: ['gbrain', 'sync', 'status', '--source', '{source_id}', '--json'], consent: [], actor: 'agent', requires_exclusive: false, why: 'Names the root request, its page and error; read-only.' } },
+ suggestion: 'Rerun the same plain gbrain sync --source <id> --no-pull; it resumes the stopped entry under a fresh request. gbrain sync status --source <id> --json shows what remains.',
+ fix: { argv: ['gbrain', 'sync', 'status', '--source', '{source_id}', '--json'], consent: [], actor: 'agent', requires_exclusive: false, why: 'Shows the cursor and the next step; read-only. A plain sync of the source resumes the stopped entry.' } },
keyword_candidates_incomplete: { class: 'unavailable', summary: "Hybrid search's CJK keyword arm hit its deadline or candidate cap on a large corpus, so some keyword matches can be missing.", why: 'The CJK fallback is an unindexed LIKE scan; the arm is bounded so a large brain cannot stall every hybrid search. An incomplete keyword search is not evidence of absence.', docs: 'docs/guides/multi-language-fts.md#cjk-keyword-budget', suggestion: 'Narrow the search with --source-id (MCP source_id), or ask the user to raise search.cjk_keyword_deadline_ms.', fix: { argv: ['gbrain', 'config', 'get', 'search.cjk_keyword_deadline_ms'], consent: [], actor: 'agent', why: 'Shows the deadline in effect (unset means 3000 ms); read-only.', requires_exclusive: false } },
projection_pending: { class: 'retryable', summary: "The current text projection is not ready." },
provenance_required: { class: 'caller', summary: "provenance is required and must be non-empty." },
diff --cc src/core/wire-skew.ts
index 1986602edb,0000000000..ef1795aa02
mode 100644,000000..100644
--- a/src/core/wire-skew.ts
+++ b/src/core/wire-skew.ts
@@@ -1,14 -1,0 +1,14 @@@
+/**
+ * Wire-compatibility windows: fields a gbrain process still accepts from an older peer after it stopped using them.
+ *
+ * Master ships many PATCH releases a day, so a window counted in releases lasts hours. Each window is a calendar
+ * period plus a version floor: a field is accepted (validated, then ignored) until `accept_until`, and only peers below
+ * `floor` still send it. After `accept_until` the field may be deleted from the wire tables that cite its entry here.
+ */
+export interface WireSkewWindow { field: string; floor: string; accept_until: string; why: string }
+
+export const WIRE_SKEW_WINDOWS = {
+ /** #6712 PR 1: the managed cursor's processing options are inherited, so the explicit-flag list no longer decides anything. */
- explicitProcessing: { field: 'explicitProcessing', floor: '0.60.254.0', accept_until: '2026-11-14',
++ explicitProcessing: { field: 'explicitProcessing', floor: '0.60.255.0', accept_until: '2026-11-14',
+ why: 'Sync clients below the floor send the processing flags their user typed (#6317, #6696); a resume now inherits the cursor\'s opt-outs instead.' },
+} as const satisfies Record<string, WireSkewWindow>;
diff --cc test/sync-knock-on-recovery-6643.test.ts
index c6908f0952,869733a7ec..b0e5baa986
--- a/test/sync-knock-on-recovery-6643.test.ts
+++ b/test/sync-knock-on-recovery-6643.test.ts
@@@ -97,9 -95,8 +97,9 @@@ test('the pre-#6643 producer messages a
expect(isSyncKnockOn({ ...base, state: 'cancelled', error_code: 'cancelled', error_message: WINDOW_CANCEL_MESSAGE, intent: page('put_page') } as never)).toBe(false);
// The typed marker survives compaction (no intent, no message).
expect(isSyncKnockOn({ ...base, intent: null, state: 'cancelled', error_code: 'cancelled', error_message: null, error_detail: knockOnDetail('bulk_group', null) } as never)).toBe(true);
- expect(classifySyncFault({ code: 'knock_on_exhausted' })).toMatchObject({ class: 'systemic', needs_human: true });
- expect(CODES.knock_on_exhausted).toBeDefined();
+ // #6712: the retired stop renders superseded: a retryable page fault a plain sync resumes, never a human page.
+ expect(classifySyncFault({ code: 'knock_on_exhausted' })).toEqual({ class: 'page', safe_actions: ['retry'], needs_human: false });
- expect(CODES.knock_on_exhausted).toMatchObject({ retired_in: '0.60.254.0' });
++ expect(CODES.knock_on_exhausted).toMatchObject({ retired_in: '0.60.255.0' });
});
test('the SQL predicate agrees with isSyncKnockOn row by row', async () => {