Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge origin/master (#6859, v0.60.270.0) into capy/6858-blocked-source
garrytan940691ee968b
diff --cc CHANGELOG.mdindex 9c1821f449,a49b67d8e7..f678115fa2--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -10,30 -10,28 +10,52 @@@ credits are retained; no result has beeidentifiers 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 incremental `gbrain sync` on a large repository whose chunker stamp predates the current chunker | read and token-counted every file before the first write (131 s and 1.4 GB on a 308k-file, 2.7 GB test repo), priced a `chunker_drift` ceiling and could auto-defer cheap embeds | prices only the changed files, as the run embeds them (first write on a blocked 52-page retry went from 58 s to 5 s in the same test); `--full` and classic sources are unchanged |+| 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. 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++A supported low-latency mode (ask 6) is a separate proposal. The repository-scaling preparation cost of ask 5 came from the embed cost estimate above; the remaining per-run work that grows with the repository (git discovery, the identity freeze) measured about 3 s at 308k pages.++ ## [0.60.270.0] - 2026-10-16++ **Security: an image page edited free of private text can no longer slip back into remote image search.** Suppose an image's OCR text carried a private section and someone later edited that section out of the page. GBrain keeps such a page out of remote search, because the picture still shows what the text no longer says. Until now, re-importing the unchanged image while OCR was off or out of budget put it back: the page became searchable again, and remote callers of image search could see its name and title ranked by the private picture. Now that re-import is skipped unless a fresh OCR pass succeeds, and the page stays exactly as it was.++ ### What you'd see++ | Situation | Before | Now |+ |---|---|---|+ | an unchanged image whose private OCR section was edited out of its page, re-imported with OCR off or out of budget (`gbrain embed --stale --images`, `gbrain sync --full`) | re-imported, sealed, and ranked in remote `search_by_image` | `skipped`: "This image had protected OCR, so indexing it requires successful fresh OCR. Enable OCR and reimport the image." Body, chunks and seal state unchanged |+ | the same re-import with OCR on and succeeding | re-imported | re-imported and attested from the fresh OCR, as before |+ | a changed image | re-imported | unchanged behaviour |++ ### What to do++ Upgrade. Nothing is rewritten on upgrade and there is no migration. Affected releases are v0.48.3.0 through v0.60.269.0. Exposure needed all three: an image whose OCR held a protected (`facts`/`takes`) section, a later edit that removed it, and a re-import with OCR disabled or over `embedding_image_ocr_max_images`. If you ran with image OCR off and edited protected text out of image pages, re-import those images with OCR enabled; a page already re-sealed this way can't be told apart from one sealed legitimately.++ ### Itemized changes++ - `importImageFile` (`src/core/import-file.ts`) applies its fresh-OCR requirement to an existing page whose stored row is distrusted (`chunker_version < 0`) when the image hash is unchanged, in addition to a stored body that still carries protected OCR. It never enables OCR or raises the OCR budget on its own.+ - `provenanceDistrusted` (`src/core/search/safe-chunks.ts`) reads the stored `chunker_version` for that check.+ - `test/image-distrusted-reimport.test.ts` (PGLite, and Postgres through `test/e2e/image-distrusted-reimport-postgres.test.ts`) covers OCR disabled and OCR over budget, with a remote `search_by_image` caller, plus the successful-OCR path.+## [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).diff --cc src/core/behavior-change-notice.tsindex b05fa6e40e,7eda5fe2a0..124c1c6582--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@@ -729,11 -729,6 +729,11 @@@ export const BEHAVIOR_CHANGES: Readonly{ 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-5; ask 5 contained per GBRA-108). `since` is a placeholder equal to the branch's VERSION; the integrator sets it to the merge-slot stamp by hand.- { 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.' },- { since: '0.60.269.0', text: 'On a managed brain an incremental `gbrain sync` (without `--no-embed`) no longer reads every file in the repository to price its embeddings when the source\'s chunker stamp is older than the current chunker: a managed incremental sync imports only the changed files and keeps its stamp, so the cost gate now prices the delta it will actually embed. A stale stamp used to add minutes and gigabytes of memory before the first write on a large repository, show a `chunker_drift` ceiling and auto-defer embeds that were cheap. `--full` and classic sources still price the whole tree.' },++ { since: '0.60.270.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.270.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.270.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.270.0', text: 'On a managed brain an incremental `gbrain sync` (without `--no-embed`) no longer reads every file in the repository to price its embeddings when the source\'s chunker stamp is older than the current chunker: a managed incremental sync imports only the changed files and keeps its stamp, so the cost gate now prices the delta it will actually embed. A stale stamp used to add minutes and gigabytes of memory before the first write on a large repository, show a `chunker_drift` ceiling and auto-defer embeds that were cheap. `--full` and classic sources still price the whole tree.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */