Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Merge origin/master (#6857, v0.60.269.0) into capy/6858-blocked-source

garrytan48a03e1916f3
diff --cc CHANGELOG.md
index 07403739fc,04cd49129f..cd5f70ba45
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -10,29 -10,58 +10,81 @@@ credits are retained; no result has bee
identifiers and attribution are available in the pre-removal Git revision
`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).
+## [Unreleased] - 2026-10-16
+
+**A page that stops a managed sync no longer stops its source silently, and gbrain stops rewriting busy files just to refresh an assessment marker.** On a managed Postgres brain one page write was resolved the documented way (`gbrain repair stuck-recovery --keep disk`), and its source then indexed nothing for 21 hours (#6858). The request ended `conflict` / `source_changed` with a message no classifier knew, so the run parked `blocked_by_failures`. Every autopilot freshness sync job returned that parked run and was recorded `completed`, so nothing retried and nothing alerted. The trigger was gbrain itself: managed sync rewrote the canonical file of an oversized page only to refresh its `embed_skip` marker, whose `assessed_at` changes whenever the body does, and that rewrite was the publication an agent's own edit of the hot file collided with.
+
+### What you'd see
+
+| Situation | Before | Now |
+|---|---|---|
+| `repair stuck-recovery --keep disk` abandons a managed sync import | the run parked `blocked_by_failures` until `sync --retry-failed` | the next plain sync retries the page after the rest of its run: it imports the kept file when it is committed, holds it `worktree_dirty` when it is an uncommitted edit, and syncs the rest of the source in the same pass |
+| The `--keep disk` result for any other write | named only `sources reconcile … --preview` | names both follow-ups in order: `sources reconcile … --preview --auto-additive` (still preview-first), then `gbrain sync --source <id> --no-pull`; a sync import names the plain sync |
+| An autopilot (or any) `sync` job whose managed run is blocked, stalled or capped | `completed`, with the parked result | `dead`; the error names the stop and the run's `next` command, and `jobs get` keeps `outcome`, `drain` and `next` in the job's progress |
+| A managed sync run blocked on a page | `sync_failures` warned and failed only after 72 h | new doctor check `managed_sync_blocked`: warns at once and fails after an hour, with `gbrain sync status --source <id> --json` as its fix |
+| get_brain_health with a source blocked over an hour | `ok` | `attention`, with a `sync_blocked` count band (no source names) |
+| A managed sync import of an oversized, quarantined or flagged page | rewrote the canonical file with the gate's marker (a file publication with a recovery record, every time the body changed) | stores the marker in the database only and leaves the file as committed; a file whose marker is missing or stale is not file/database drift |
+
+### What you need to do
+
- Nothing. Markers already written into files stay where they are (nothing rewrites files on upgrade), and a later import of the same file no longer touches them. If your monitoring treats a dead `sync` job as an incident, that is now the intended signal: `gbrain sync status --source <id> --json` names the page and its exit. A plain `gbrain sync` retrying a failure an earlier run recorded comes with #6712 PR 3; until then the `next` command a blocked run prints may still say `--retry-failed`.
++Nothing. Markers already written into files stay where they are (nothing rewrites files on upgrade), and a later import of the same file no longer touches them. If your monitoring treats a dead `sync` job as an incident, that is now the intended signal: `gbrain sync status --source <id> --json` names the page and its exit. Since v0.60.269.0 a plain `gbrain sync` also retries the failure an earlier run recorded, so once the cause is cleared the next freshness job resumes the run by itself.
+
+### Still open on #6858
+
+Preparation cost that scales with the repository instead of the diff (ask 5) and a supported low-latency mode (ask 6) are tracked separately.
+
+ ## [0.60.269.0] - 2026-10-16
+
+ **Cheaper managed publishes, one way to retry, and three managed-sync bugs closed (#6712 PR 3).** A 336 KB page with 1,012 facts, 4,100 timeline rows and 50 code references now publishes in one transaction of 67 statements instead of 318, which takes 4.5 s instead of 19.5 s at 57 ms round trip through a transaction pooler. A plain `gbrain sync` retries the failure the previous run recorded, so `--retry-failed` becomes a deprecated alias, and `gbrain sync --help` lists the ten flags a managed brain needs first. Three managed-sync bugs are fixed: final validation timing out at the end of a long catch-up (#6735), a legacy page forked into a twin (#6727), and doctor calling a fresh cursor idle (#6763).
+
+ ### What you'd see
+
+ | Situation | Before | Now |
+ |---|---|---|
+ | a managed sync publishes a large page (336 KB, 1,012 facts, 4,100 timeline rows, 50 code refs) through PgBouncer at 57 ms RTT | 318 statements, 19.5 s p50 | 67 statements, 4.5 s p50 (676 KB: 35.4 s → 5.5 s) |
+ | a page with code references | two savepointed link writes per reference | one statement per page for all its doc↔impl edges |
+ | `GBRAIN_SYNC_TRACE=1 gbrain sync` | no publish timing | `[sync] publish apply <slug>: <ms>ms` and `[sync] publish effects <slug>: <ms>ms` lines |
+ | a managed sync stopped on a failure, then plain `gbrain sync` | resumed into the same failure until `--retry-failed` | retries the recorded failure; a content refusal whose bytes have not changed is replayed without a new request |
+ | `gbrain sync --retry-failed` on a managed source | the explicit retry | the same as a plain sync, with one `[gbrain notice sync_retry_failed_deprecated]`; accepted for two releases (connector sources still re-approve failed item receipts) |
+ | a checkpoint refused `slug_root_mode_mismatch` while the source keeps the other pin | rediscovered by `--retry-failed`, adopting the new pin | left for a person: `gbrain repair managed-sync-orphans` lists it as `slug_mode_refused` (preview, then apply) |
+ | `gbrain sync --help` | 33 options in one list | "Managed brains" (10 flags) first, then "Classic brains / advanced" |
+ | a 59k-entry catch-up reaches its final checkpoint | `checkpoint_validation_timeout` could throw the run away at the last step | validation reads at most one committed receipt per unfinished receipt; a timeout is re-validated by the next sync instead of rediscovering |
+ | a file whose page an older gbrain imported under a slug the current fold spells differently (punctuation, spaces, accents) | a second page with the same file and content hash | the file imports into the legacy page, keeping its id, links and history; several matching pages hold the file `legacy_slug_conflict` |
+ | a managed sync cursor discovered minutes ago that has not advanced yet | doctor: idle "over an hour" | no warning until an hour after discovery |
+
+ ### Itemized changes
+
+ #### Cheaper publishes (L6)
+
+ - `addCodeReferenceLinks` (`src/core/engine-sql/links.ts`) writes a page's code-reference edges in one statement, keeping source-qualified locked endpoint resolution, context and origin updates, duplicate semantics and missing-endpoint isolation. `import-file.ts` and `page-body/streamed-import.ts` call it once per page.
+ - `declarePublication` folds the publication idle-timeout SET into `declareDurablePersistence`, one round trip less per publication behind a transaction pooler, where pipelining is off.
+ - The `facts.embedding` cast probe is cached on the root engine, so it runs once per process instead of once per publication transaction.
+ - `upsertChunks` reads its three embedding config keys in one statement.
+ - `publication-timing.ts` times member apply and `queuePublicationEffects` (`coordinator.ts`, `group-publish.ts`); it prints only under `GBRAIN_SYNC_TRACE`.
+ - The page's publication transaction runs on the ordinary pool through the pooler; the consumer's scans run on the direct pool (documented in `docs/architecture/key-files/core-persistence-capacity.md`, "Publication cost").
+
+ #### One retry path and managed help (L7)
+
+ - `retryRecordedFailure` (`sync-run.ts`) replaces `retryFailedStart`: a plain sync retries a failure an earlier invocation recorded. Failure rows record `gbrain_version` (additive) so an unchanged refusal is replayed only until the file, the commit or gbrain changes. Company sources follow the same rule for content refusals.
+ - `--retry-failed` prints `sync_retry_failed_deprecated` once per process; `test/error-registry-retired.test.ts` fails on any printed fix or help line that still recommends it.
+ - `slug_mode_refused` joins the `managed-sync-orphans` classes; `checkpoint_moved` (#6834) keeps its repair, since rediscovering a path-sliced run would move `last_commit` backward.
+ - `sync --help` sections come from `MANAGED_HELP_FLAGS`; `--all`, `--hard-deadline`, `--no-bulk` and `--no-lanes` stay accepted on managed sources.
+ - `laneFaultOf` is removed. `drain-step.ts`, `sync-checkpoint-replaced.ts` and the legacy knock-on text stay, because the governor, waivers, prepare, the coordinator and old rows still use them.
+
+ #### Managed-sync fixes (L8)
+
+ - #6735: `INCOMPLETE_SYNC_RECEIPT_SQL`'s committed-sibling clause is a `LEFT JOIN LATERAL ... LIMIT 1`, so its cost follows the unfinished receipts under any join the planner picks; `reviveCheckpoint` revives a `checkpoint_validation_timeout` once per invocation after the stop is recorded (`probeCheckpointBlocker`).
+ - #6727: the identity freeze (`sync-discovery.ts`) adopts the one live page without a recorded file and not database-only whose slug folds to the file's slug, or equals the path without its extension; a bounded lookup that issues nothing on a source with no such pages. `legacy_slug_conflict` is a page hold (fault table row, public category, runbook rows).
+ - #6763: `readManagedSyncBacklog` carries the cursor's `discovered_at`; doctor `managed_sync_backlog` ages a cursor from its last advance or its discovery.
+
+ ### For contributors
+
+ - New budget tests: `test/managed-import-statement-budget.test.ts` and its e2e twin assert the publication transaction's statement count at 0.5x, 1x and 2x of the YC-shaped fixture (bounded 500-row chunks, nothing per row); `test/sync-status-statement-budget.test.ts` pins `sync status` at 1k and 61k receipts. `test/fixtures/goldens/sql-text/chunks.json` was regenerated for the folded config read.
+ - `LatencyProxy` moved to `test/helpers/latency-proxy.ts`.
+ - Convergence harness (#6841): a write the brain accepted (exit 10) that was still unsettled when its writer stopped is settled by its receipt (`get_write_request`) after recovery, so it is never misread as a lost acknowledged write. The nightly's note-0266 failure was this harness gap; no product write was lost.
+ - `sync-run.ts`'s ceiling is 1762, where L7 and L8 compose.
+ - Migration note: `skills/migrations/v0.60.269.0.md`.
+
## [0.60.268.0] - 2026-10-16
**Security: remote entity cards and context packs no longer carry open loops.** Since v0.47.0.0, an `entity` card built for a remote caller (any MCP client, stdio or HTTP) listed the open loops whose counterparty is that entity: the loop summary, its due date and its `loop_id`. Loop rows have no visibility or source grant of their own, so the card showed them even when the loop's commitment fact was private, and since v0.60.167.0 (#5504) also when the loop lives in a source outside the caller's grant, such as a connected Google source. `context_pack` and `delta` build their threads from the same card, so they carried the same loops. Remote cards now skip loop-backed threads; their fact and timeline threads are unchanged.
diff --cc src/core/behavior-change-notice.ts
index 0aa9c61743,7eda5fe2a0..1ad8ff558d
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@@ -724,10 -724,11 +724,15 @@@ export const BEHAVIOR_CHANGES: Readonly
{ since: '0.60.267.0', text: '`purge_fact` now saves each page it rewrites as a version before dropping the purged fence row, and its version redaction then removes the claim from that version as from every other, so `get_versions` and `gbrain history` list one more snapshot per page a fact purge rewrites. The snapshot holds the page as it stood before the purge, without the purged claim.' },
// Remote open-loop hotfix (GBRA-120).
{ since: '0.60.268.0', text: 'Remote callers (every MCP transport) no longer get open-loop-backed threads on `entity` cards, or in `context_pack` and `delta`, which build on those cards: no loop summary, `due` or `loop_id`. Use `open_loops`, which reads loops only in granted sources. The trusted local CLI still sees them on `gbrain entity`, and in `context_pack` / `delta` with `include_private`. Remote `open_loops` grouped results no longer rank counterparties by backlink counts.' },
+ // #6712 PR 3 (L7 retry alias and managed help; L8 #6727 #6735 #6763).
+ { since: '0.60.269.0', text: 'On a managed source a plain `gbrain sync` now retries the failure the previous run recorded, so `--retry-failed` is a deprecated alias (#6712): it stays accepted for two releases, prints the `sync_retry_failed_deprecated` notice and changes nothing (on a google or github connector source it still re-approves failed item receipts). A content refusal, or a pinned import refused for newer uncommitted bytes (`source_changed`), is replayed without a new request until the file changes, is committed, or gbrain is upgraded. Two failures need a person and no sync retries them: a checkpoint refused `slug_root_mode_mismatch` while the source keeps the other pin (`gbrain repair managed-sync-orphans` lists it as `slug_mode_refused`; retiring it keeps the pin) and a checkpoint whose source checkpoint moved (`checkpoint_moved`, #6834). `gbrain sync --help` lists the ten flags a managed brain needs under "Managed brains" first, then "Classic brains / advanced". Downgrading restores the explicit `--retry-failed` retry; older builds ignore the `gbrain_version` a failure row now records.' },
+ { since: '0.60.269.0', text: 'A managed sync no longer forks a second page for a file whose page an older gbrain imported under a slug the current slug fold spells differently (#6727: punctuation, spaces, accents, emoji, full-width characters): a file with no recorded origin and no page at its slug imports into the one live page without a recorded file that folds to it, keeping that page\'s id, links and history. When several such pages match, the file is held `legacy_slug_conflict` (needs a person: keep one, remove the others, then sync); with `sync.holds=fail` the run stops `page_identity_changed`. Pages already forked by older syncs are not merged.' },
+ { since: '0.60.269.0', text: 'A managed sync\'s final checkpoint validation reads at most one committed receipt per unfinished receipt, so a catch-up of tens of thousands of entries no longer times out at its last step (#6735). A checkpoint that still hits `checkpoint_validation_timeout` is re-validated by the next sync of the source (once per run, after the stop is recorded) instead of rediscovering the whole manifest.' },
+ { since: '0.60.269.0', text: 'Doctor no longer warns that a managed sync cursor has been idle "over an hour" right after the cursor was discovered (#6763): idle time counts from the cursor\'s last advance, or from its discovery when it has not advanced yet.' },
+ // #6858 (GBRA-121; Garry: "take care of fixing" #6858 asks 1-4). `since` is a placeholder equal to the branch's VERSION; the integrator sets it to the merge-slot stamp by hand.
- { since: '0.60.268.0', text: 'A durable `sync` job (autopilot freshness included) whose managed run stops on something only a person clears (a run blocked on a page, a stalled drain holder, a write cap) now ends `dead` instead of `completed`: its error names the stop and the run\'s `next` command, and `gbrain jobs get <id> --json` keeps `outcome`, `drain` and `next` in the job\'s progress. New doctor check `managed_sync_blocked` warns as soon as a source\'s run is blocked and fails after an hour (fix: `gbrain sync status --source <id> --json`), and `get_brain_health` gains a `sync_blocked` count band that turns its status to `attention` past the same hour.' },
- { since: '0.60.268.0', text: 'A managed sync import whose stuck publication `gbrain repair stuck-recovery --keep disk` abandoned is retried by the next plain sync after the rest of its run (imported when the kept file is committed, held `worktree_dirty` when it is an uncommitted edit) instead of parking the run `blocked_by_failures`; the `--keep disk` result now names both follow-ups (`sources reconcile … --preview --auto-additive`, then `gbrain sync --source <id> --no-pull`), or the plain sync for a sync import.' },
- { since: '0.60.268.0', text: 'Managed sync no longer rewrites a canonical file only to add or refresh the content gate\'s markers (`embed_skip`, `content_flag`, `quarantine`): they are stored in the database and the file stays as committed, so an oversized page agents keep appending to is no longer republished on every import. A file whose marker is missing or carries another `assessed_at` is not file/database drift. Markers already in files are left alone.' },
++ { since: '0.60.269.0', text: 'A durable `sync` job (autopilot freshness included) whose managed run stops on something only a person clears (a run blocked on a page, a stalled drain holder, a write cap) now ends `dead` instead of `completed`: its error names the stop and the run\'s `next` command, and `gbrain jobs get <id> --json` keeps `outcome`, `drain` and `next` in the job\'s progress. New doctor check `managed_sync_blocked` warns as soon as a source\'s run is blocked and fails after an hour (fix: `gbrain sync status --source <id> --json`), and `get_brain_health` gains a `sync_blocked` count band that turns its status to `attention` past the same hour.' },
++ { since: '0.60.269.0', text: 'A managed sync import whose stuck publication `gbrain repair stuck-recovery --keep disk` abandoned is retried by the next plain sync after the rest of its run (imported when the kept file is committed, held `worktree_dirty` when it is an uncommitted edit) instead of parking the run `blocked_by_failures`; the `--keep disk` result now names both follow-ups (`sources reconcile … --preview --auto-additive`, then `gbrain sync --source <id> --no-pull`), or the plain sync for a sync import.' },
++ { since: '0.60.269.0', text: 'Managed sync no longer rewrites a canonical file only to add or refresh the content gate\'s markers (`embed_skip`, `content_flag`, `quarantine`): they are stored in the database and the file stays as committed, so an oversized page agents keep appending to is no longer republished on every import. A file whose marker is missing or carries another `assessed_at` is not file/database drift. Markers already in files are left alone.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */