Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/master' into capy/6803-wave
garrytan48428d5657dc
diff --cc CHANGELOG.mdindex d920438173,98001968c7..5dbd89bb3c--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -10,74 -10,26 +10,94 @@@ credits are retained; no result has beeidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).- ## [0.60.275.0] - 2026-10-17++## [0.60.276.0] - 2026-10-17++**A stuck upgrade queue drains, held embeddings say what they need, and doctor and status answer in bounded time (#6803, #6847).** Four things got better for anyone whose brain grew big or went through the recent upgrades. Image pages that an old upgrade left queued (and missing from search) can now be put back with one keyless command when gbrain already knows they're safe, and the rest are counted and named instead of hidden. Large pages waiting for your embedding approval are reported everywhere with one exact command to approve them, and that command now works on free local embedding models too. `gbrain doctor --json` and `gbrain sync --status` stop running for minutes on a large brain. And the "un-extracted edges" nudge after a sync now agrees with doctor and names the command that actually finishes the job.++### What you'd see++| Situation | Before | Now |+|---|---|---|+| tens of thousands of image pages queued by the 0.51 activation | never left the queue; every resident tick probed all of them; out of search | `gbrain projections drain` seals the ones the importer already attested safe (keyless, no re-embedding); the rest are counted as `reimport`, `protected` or `archived`; the resident probes at most 500 rows per tick |+| doctor `text_projection_readiness` | one `pending` number | counts per class, a drain fix sized to about a minute that asks first, and by-design classes reported as info |+| `gbrain embed --stale` with pages held for approval | silent | `budget_limited`: "N large page(s) have chunks waiting for embedding approval …" plus a per-source approve command |+| `gbrain embed --held --dry-run` on a multi-source brain | exit 1 | lists every source with one approve command each, exit 0 |+| `gbrain embed --held --source <id> --max-usd N` on a free (local) embedding model | reprinted the hold forever | releases it and embeds the page at $0 |+| receipts for a held page | `gbrain reindex --held` (does not exist) | `gbrain embed --held --dry-run --source <id>` |+| `gbrain sync --status --json` | ran a full sync of the source | prints the status envelope with a one-line hint |+| `gbrain doctor --json` on a large brain (non-interactive) | could run past two minutes; slow checks kept running server-side | stops its check run at 90 s by default; each check cancels its own statements at its budget; the cheap incident checks run first |+| "N page(s) have un-extracted edges" after a sync | counted attendance-blocked meetings; named only `extract --stale` | silent when doctor wouldn't warn; names `gbrain extract --stale` and `--catch-up` with time estimates |+| `gbrain extract --stale --source <id>` | ran brain-wide | refuses with `invalid_params`, pointing at `--source-id <id>` |++### What to do after upgrading++Nothing runs on upgrade. Each repair below is preview-first, and you choose when to run it.++- **Queued image pages.** Run `gbrain doctor --only text_projection_readiness --json` to see the counts, then `gbrain projections drain --dry-run --json`. With your go-ahead, run `gbrain projections drain --limit <n>` on the brain host and repeat until `sealable` is 0. It's keyless and makes no provider calls. `reimport` images need their importer: `gbrain embed --stale --images --dry-run`, then the paid run. `protected` and `archived` pages stay out of search by design.+- **Held embeddings.** `gbrain embed --held --dry-run` lists every source. Then `gbrain embed --held --source <id> --max-usd <N>` per source, and `gbrain embed --held --dry-run --source <id> --json` shows held 0. `--max-usd N` is both the run's cap and a saved per-page allowance.+- **Slow status and doctor.** Use `gbrain sync status --source <id> --json`, and `gbrain doctor --tier ops --json` or `--budget-ms 90000`. `gbrain config set doctor.default_budget_ms 0` turns the new default off.+- **Un-extracted edges.** `gbrain extract --stale --dry-run --json` shows the work. On the host, `gbrain extract --stale --catch-up [--source-id <id>]` finishes it in one interruptible run. Done means `actionable: 0`.++### Itemized changes++#### Projection queue (part 2)++- `page-state/projection-class.ts` partitions every queued row into `text`, `sealable`, `reimport`, `protected` and `archived` in one SQL fragment, shared by `projectionBacklog`, the drain preview, the drain, doctor and search readiness.+- `page-state/image-seal.ts` `sealImageProjections` restores the importer's own seal on `sealable` images in groups of up to 500 under the page guard. It writes no chunk and leaves `embedding_image` untouched. Measured: about 1,800 to 2,000 images a second, which sets `IMAGE_SEAL_PAGES_PER_SECOND` and the drain `--limit`.+- `page-state/projection-window.ts` bounds each resident tick and each idle probe to a recency lane plus a 500-row primary-key window with a wrap-around cursor. Segmented rows are probed queue-wide.+- `page-state/projection-status.ts` caches the class counts off the tick path for the resident's `projection_status` reply.+- Embed paths count image pages as blocked instead of queuing `embedding_recovery` rows.+- `embed --stale --images` skips sealable pages and reports `reimport`, `incomplete_sealed`, `ocr_required`, `protected` and `archived`.+- `gbrain projections drain` reports per-class `remaining_by_class` and never says "empty" while image rows remain.+- A read-only `[AGENT]` notice after upgrading names the drain preview.+- `gbrain migrate --to <engine>` (the legacy copier) now carries an image chunk's `embedding_image` vector (#6871). Before, a migrated image page arrived without it and needed a paid re-embed to show up in image search.++#### Held embedding budgets (part 3, #6847)++- `held-embedding.ts` provides `readBudgetLimited` and the shared phrase. `held-embedding-action.ts` provides `heldApproveAction`, which builds the approve command used by `embed --stale`, embed-backfill, doctor and the oversized receipt.+- `partial_embedding` is its own doctor registry entry.+- An explicit `--max-usd` is the hold approval on any provider, and free-recipe models cost $0 in the per-page ledger. The printed paid N is `derivedCapUsd` of the estimate (×1.5, $0.25 floor).+- An approval is refused before release when embeddings can't run (`embedding_unavailable`) or the paid model has no price (`no_pricing`).++#### Bounded doctor and status (part 5)++- `statement-deadline.ts` gives each doctor entry its own deadline engine: Postgres cancels the statement, and PGLite refuses the next one. Frontmatter and fence scans stop at the deadline and report partial results.+- `doctor/default-budget.ts`: `doctor.default_budget_ms` (file plane, default 90000) applies only to plain non-interactive CLI `doctor --json`.+- `capacitySnapshotWithin` waits at most 1.5 s per caller and never caches a timed-out fetch. `capacity-memo.ts` forecasts once per doctor run.+- `sync/operator.ts` `syncOperatorVerb` canonicalizes `sync --status`. `--preview` and `--check` refuse.+- `scripts/bench/doctor-scale.ts` measures doctor, `sync status` and the cheap checks at scale, with a pass criterion.++#### Extraction nudge (part 6)++- `extraction-lag.ts` gives doctor `links_extraction_lag` and the sync nudge one statement and one verdict, with attendance-blocked pages excluded.+- `extract-stale-options.ts` validates `--source` before direct and owner dispatch. Extract's routing flag is `--source-id`.+- `SyncTailReport.underived` drives the per-source line.+- `EXTRACTOR_BUMP_NOTES` pins the link-extractor version, and its test requires a note for every bump.++#### Agent protocol++- `AGENT_TOOL_LIMIT_MS` (120 s): a fix expected to run longer than that is the user's or host admin's (`tell_user_to_run`), never the agent's.++ ## [0.60.275.0] - 2026-10-17++ **`gstack-pregate` now reaches a verdict on small machines: on a machine under 8 cores, the test tier goes to the full Ubicloud gate instead of thousands of local files.** On a 4-core machine, a one-line edit to a hub file such as `src/core/config.ts` selected about 3,900 test files, and pregate hit its 40-minute cap after 308 of them. `.gstack/pregate.json` now declares a `remote_gate`. Pregate records the selected files as one remote obligation in seconds, and `gstack-pregate --remote` clears it by running the full gate on the working tree.++ ### How to use it++ ```bash+ UBI_OWNER=<thread code> gstack-pregate --stage tests --remote --spend-cap <usd> --allow-repo-commands+ ```++ ### Itemized changes++ - `scripts/pregate-remote-gate.sh` (new) runs `bun run ci:ubicloud` and prints `PREGATE_REMOTE: tree=<tree> tests=<n> failed=<n>`.+ - `<tree>` is the working-tree content fingerprint (tracked plus untracked-unignored files), computed before and after the gate.+ - It refuses without `UBI_OWNER`, or when `PREGATE_TREE` names another tree. It prints no receipt when the tree moved during the gate or the gate printed no summary.+ - Provider API keys are removed from the gate's environment.+ - `.gstack/pregate.json` declares `remote_gate`. `CONTRIBUTING.md` documents the flow.+ - Tests: `test/scripts/pregate-remote-gate.test.ts`.+ - No product or schema change.+## [0.60.274.0] - 2026-10-17**A refresh no longer gets stuck when a commit lands on top of its target, and `gbrain repair file-drift` can now resolve a page whose file is gone.** Two fixes ahead of the level-triggered reconcile (#6712).diff --cc src/core/behavior-change-notice.tsindex 37ff2c7757,ae7a84dd0c..fb73116281--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@@ -741,16 -741,6 +741,16 @@@ export const BEHAVIOR_CHANGES: Readonly{ since: '0.60.273.0', text: '`gbrain migrate --to <engine>` through the legacy copier (graduation turned off, or Postgres to PGLite) now refuses a brain that holds page versions, with `writer_coordinator_required`, `reason: page_history` and the number of versions it would discard, instead of copying the pages without them. Nothing changes in either datastore. Graduation from PGLite to Postgres carries versions and is unaffected.' },{ since: '0.60.274.0', text: '`gbrain sources refresh` now completes once every member source has synced to the refresh target or to a commit on top of it. Before, a commit that landed on the target while the refresh synced left it `syncing`, with the worktree fenced, and `--resume` could not finish it either. A refresh left `syncing` by a crashed process still waits for `gbrain sources refresh <source> --resume` when a later sync went past the target.' },{ since: '0.60.274.0', text: '`gbrain repair file-drift --slug|--request` now resolves a live page whose canonical file is gone from the last commit (a held deletion whose page changed, or a write refused `canonical_file_missing`): `--prefer database` recreates the file from the page, and `--prefer file` soft-deletes exactly that page (purged after 72 h; `gbrain restore <slug> --force` undoes it). Both are preview-bound to the page revision and the file\'s absence, and soft deletes honor the mass-delete valve. A file deleted only in the worktree (still committed) is listed `deletion_uncommitted` and routed to committing the deletion or `gbrain repair ghost-pages`. `gbrain sources reconcile --preview` on a missing file names the same routes, and a held deletion\'s next step is the file-drift preview instead of a reconcile preview that refused. An older gbrain refuses a recreate request and writes nothing.' },+ // #6803 wave (projection queue, held embedding budgets, bounded doctor/status reads, extraction nudge). `since` is the branch VERSION until the merge-slot stamp.- { since: '0.60.274.0', text: '`gbrain sync --status` now prints the `gbrain sync status` envelope (with a one-line hint) instead of running a full sync of the source, which nothing used to stop because no sync path read the flag. `gbrain sync --preview` and `--check`, which sync never read either, now refuse with `invalid_params` and a `--dry-run` fix; `--dry-run` is unchanged.' },- { since: '0.60.274.0', text: 'A plain non-interactive CLI `gbrain doctor --json` (stderr not a terminal, no `--budget-ms`, `--tier`, `--fix` or remediation flag) now caps its check run at `doctor.default_budget_ms` (90000 ms; file plane; connect and migrations are not counted) and prints one stderr line saying so; checks past it report health unknown, and the JSON gains `tier`, `complete`, `unknown_sections`, `elapsed_ms` and `budget_ms`. `--budget-ms 0` turns it off for one run and `gbrain config set doctor.default_budget_ms 0` for good. `gbrain config set` now accepts `doctor.entry_budget_ms` and `doctor.orphan_ratio.full_scan_max_pages`.' },- { since: '0.60.274.0', text: 'Doctor entries now stop their database statements at their own budget on every tier (Postgres cancels the statement; PGLite refuses the next one), so a slow check no longer keeps a backend running after the report. The cheap incident checks (`persistence_capacity`, `managed_sync_not_moving`, `managed_sync_blocked`, `text_projection_readiness`, `partial_embedding` and `links_extraction_lag`, now its own entry) run right after the ops sections, the frontmatter and fence scans report partial results at the deadline, `--only <check> --budget-ms N` gives that check the whole N, and a check past its budget names which budget (`details.limit`) and prints that rerun.' },- { since: '0.60.274.0', text: '`gbrain sync status` and write and sync receipts wait at most 1.5 s for the shared capacity snapshot and read capacity as unknown for that call when it is late, without clearing or re-announcing a background pause; a snapshot fetch that timed out is no longer cached for a minute. Doctor now computes the capacity forecast once per run instead of twice.' },- { since: '0.60.274.0', text: '`gbrain projections drain` now seals image pages the importer already attested safe (one image chunk written at or after the safe-chunk fence, unchanged since) in place, keyless, with no chunk write or provider call, so image search ranks them again; every other image page stays queued and out of search until its importer re-imports it (`gbrain embed --stale --images --dry-run`, then the paid run). Its `--json` gains `limited`, `sealed`, `sealed_with_visual`, `sealed_text_only`, `statistics_refreshed` and `remaining_by_class`, and under a resident PGLite owner it prints an exclusive stop, drain and start step instead of only refusing. The resident drains text only and probes at most 500 queued rows per tick.' },- { since: '0.60.274.0', text: 'Doctor `text_projection_readiness` counts the queue by class (`pending`, `sealable`, `reimport`, `protected`, `archived`, `failed`, `as_of`): it warns on pending, sealable, reimport and failed rows, with `gbrain projections drain --limit <n>` (asks first) or the paid importer as the fix, and reports protected-OCR and archived-source images as by design (search reports the `projection_by_design` stage for them instead of `projection_pending`). On a PGLite resident it can move from ok to warn; on Postgres it can move from warn to ok. Embed paths no longer queue `embedding_recovery` rows for image pages, `gbrain embed --stale --images` skips sealable pages and reports `ocr_required`, and a read-only notice after upgrading names `gbrain projections drain --dry-run` when image rows are queued.' },- { since: '0.60.274.0', text: '`gbrain embed --stale` and the embed-backfill job report `budget_limited` (pages held for approval or at their per-page cap, by source) and print one line instead of saying nothing; it is never a failure. Doctor `partial_embedding` is its own entry (`--only oversized_pages` no longer emits it) and its fix is a per-source approve, `gbrain embed --held --source <id> --max-usd <N>` with a concrete N, with every other source in `details.by_source`. `gbrain embed --held --dry-run` lists every source and exits 0 on a multi-source brain; `--held --max-usd` without `--source` there refuses with `invalid_params`. Receipts name `gbrain embed --held --dry-run --source <id>` instead of `gbrain reindex --held`, which does not exist.' },- { since: '0.60.274.0', text: 'An explicit `--max-usd N` on `gbrain embed --slugs` or `--held` now releases a held page on a free embedding provider too (#6847); it used to reprint the hold. Free-recipe models cost $0 in the per-page ledger, printed approve commands carry a concrete N (a paid N includes the 1.5x headroom and $0.25 floor), a free provider\'s approve asks for no paid or egress consent, and an approval when embeddings cannot run or the paid model has no price is refused before the hold is released. `--yes` still never releases a hold.' },- { since: '0.60.274.0', text: '`gbrain extract --stale --source <id>` now refuses with `invalid_params` naming `--source-id <id>` instead of running brain-wide; `--source fs` exits 2 `invalid_params` (it exited 1), and `--source db` refuses as ambiguous when a source is named `db`. Rendered extract fixes pin `--source-id`. The end-of-sync extraction nudge stays silent when doctor `links_extraction_lag` would not warn (attendance-blocked meetings no longer count), names both `gbrain extract --stale` and `gbrain extract --stale --catch-up` with estimates, and becomes a run-it-yourself step above two minutes; `extract --stale` JSON gains `actionable`, `attendance_blocked`, `mention_due` and `complete`; the per-source "still owe extraction" line counts only pages that sync imported; and an owner-delegated plain `extract --stale` keeps the 30-minute budget (`--catch-up` is carried through).' },++ { since: '0.60.275.0', text: '`gbrain sync --status` now prints the `gbrain sync status` envelope (with a one-line hint) instead of running a full sync of the source, which nothing used to stop because no sync path read the flag. `gbrain sync --preview` and `--check`, which sync never read either, now refuse with `invalid_params` and a `--dry-run` fix; `--dry-run` is unchanged.' },++ { since: '0.60.275.0', text: 'A plain non-interactive CLI `gbrain doctor --json` (stderr not a terminal, no `--budget-ms`, `--tier`, `--fix` or remediation flag) now caps its check run at `doctor.default_budget_ms` (90000 ms; file plane; connect and migrations are not counted) and prints one stderr line saying so; checks past it report health unknown, and the JSON gains `tier`, `complete`, `unknown_sections`, `elapsed_ms` and `budget_ms`. `--budget-ms 0` turns it off for one run and `gbrain config set doctor.default_budget_ms 0` for good. `gbrain config set` now accepts `doctor.entry_budget_ms` and `doctor.orphan_ratio.full_scan_max_pages`.' },++ { since: '0.60.275.0', text: 'Doctor entries now stop their database statements at their own budget on every tier (Postgres cancels the statement; PGLite refuses the next one), so a slow check no longer keeps a backend running after the report. The cheap incident checks (`persistence_capacity`, `managed_sync_not_moving`, `managed_sync_blocked`, `text_projection_readiness`, `partial_embedding` and `links_extraction_lag`, now its own entry) run right after the ops sections, the frontmatter and fence scans report partial results at the deadline, `--only <check> --budget-ms N` gives that check the whole N, and a check past its budget names which budget (`details.limit`) and prints that rerun.' },++ { since: '0.60.275.0', text: '`gbrain sync status` and write and sync receipts wait at most 1.5 s for the shared capacity snapshot and read capacity as unknown for that call when it is late, without clearing or re-announcing a background pause; a snapshot fetch that timed out is no longer cached for a minute. Doctor now computes the capacity forecast once per run instead of twice.' },++ { since: '0.60.275.0', text: '`gbrain projections drain` now seals image pages the importer already attested safe (one image chunk written at or after the safe-chunk fence, unchanged since) in place, keyless, with no chunk write or provider call, so image search ranks them again; every other image page stays queued and out of search until its importer re-imports it (`gbrain embed --stale --images --dry-run`, then the paid run). Its `--json` gains `limited`, `sealed`, `sealed_with_visual`, `sealed_text_only`, `statistics_refreshed` and `remaining_by_class`, and under a resident PGLite owner it prints an exclusive stop, drain and start step instead of only refusing. The resident drains text only and probes at most 500 queued rows per tick.' },++ { since: '0.60.275.0', text: 'Doctor `text_projection_readiness` counts the queue by class (`pending`, `sealable`, `reimport`, `protected`, `archived`, `failed`, `as_of`): it warns on pending, sealable, reimport and failed rows, with `gbrain projections drain --limit <n>` (asks first) or the paid importer as the fix, and reports protected-OCR and archived-source images as by design (search reports the `projection_by_design` stage for them instead of `projection_pending`). On a PGLite resident it can move from ok to warn; on Postgres it can move from warn to ok. Embed paths no longer queue `embedding_recovery` rows for image pages, `gbrain embed --stale --images` skips sealable pages and reports `ocr_required`, and a read-only notice after upgrading names `gbrain projections drain --dry-run` when image rows are queued.' },++ { since: '0.60.275.0', text: '`gbrain embed --stale` and the embed-backfill job report `budget_limited` (pages held for approval or at their per-page cap, by source) and print one line instead of saying nothing; it is never a failure. Doctor `partial_embedding` is its own entry (`--only oversized_pages` no longer emits it) and its fix is a per-source approve, `gbrain embed --held --source <id> --max-usd <N>` with a concrete N, with every other source in `details.by_source`. `gbrain embed --held --dry-run` lists every source and exits 0 on a multi-source brain; `--held --max-usd` without `--source` there refuses with `invalid_params`. Receipts name `gbrain embed --held --dry-run --source <id>` instead of `gbrain reindex --held`, which does not exist.' },++ { since: '0.60.275.0', text: 'An explicit `--max-usd N` on `gbrain embed --slugs` or `--held` now releases a held page on a free embedding provider too (#6847); it used to reprint the hold. Free-recipe models cost $0 in the per-page ledger, printed approve commands carry a concrete N (a paid N includes the 1.5x headroom and $0.25 floor), a free provider\'s approve asks for no paid or egress consent, and an approval when embeddings cannot run or the paid model has no price is refused before the hold is released. `--yes` still never releases a hold.' },++ { since: '0.60.275.0', text: '`gbrain extract --stale --source <id>` now refuses with `invalid_params` naming `--source-id <id>` instead of running brain-wide; `--source fs` exits 2 `invalid_params` (it exited 1), and `--source db` refuses as ambiguous when a source is named `db`. Rendered extract fixes pin `--source-id`. The end-of-sync extraction nudge stays silent when doctor `links_extraction_lag` would not warn (attendance-blocked meetings no longer count), names both `gbrain extract --stale` and `gbrain extract --stale --catch-up` with estimates, and becomes a run-it-yourself step above two minutes; `extract --stale` JSON gains `actionable`, `attendance_blocked`, `mention_due` and `complete`; the per-source "still owe extraction" line counts only pages that sync imported; and an owner-delegated plain `extract --stale` keeps the 30-minute budget (`--catch-up` is carried through).' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */