Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

feat(#6803): behavior-change rows for the wave; projection drain texts join the printed-command guard

garrytan24fca44ef6e6
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index dbeafdc521..3b05e467de 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -718,10 +718,10 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }
{ since: '0.60.266.0', text: 'A `source_changed` write receipt\'s fix now follows its recorded reason: two-sided drift previews `gbrain repair file-drift --source <id> --slug <slug> --prefer database` (a group of them `--all-drifted --since <instant>`), a missing canonical file previews `gbrain repair ghost-pages`, an admission race is retried, and a changed binding or unsafe target names `gbrain sources writer status`. `gbrain repair file-drift` takes `--since <ISO-8601 | age>` to narrow `--all-drifted`.' },
{ since: '0.60.266.0', text: 'Doctor `managed_sync_not_moving` now fails (it used to list the source as parked) when a managed source\'s queue holds admitted requests with no consumer and nothing has moved for longer than `persistence.preparation_ceiling_ms`; its fix is the resume sync, which consumes the queue (#6552). A managed sync now prints a line when live pages of the source have no canonical file, naming the read-only `gbrain repair ghost-pages` preview; it never deletes them.' },
// Lane 31 (mirror-recovery fast fail). `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp. A sync behind a withdrawal-mirror or page-write recovery blocked on unexpected_file_bytes stops at once instead of waiting 5 minutes.
- { since: '0.60.267.0', text: 'A sync queued behind a recovery that only the user can resolve now stops after one governor tick with `drain_stalled`, `cause: head_blocked`, instead of waiting out the 5-minute no-progress window. Two recoveries count: a fact-withdrawal mirror whose page file was edited while the mirror was publishing (`blocked_by=effect_recovery(unexpected_file_bytes …)`; the fix asks the user to put the file back to a version gbrain recorded, then rerun the sync), and a page write whose file was edited while it was publishing (`blocked_by=request_recovery(unexpected_file_bytes …)`, whether it blocks the queued head or is the head; the fix runs the `gbrain repair stuck-recovery` preview, or the user undoes the edit). Both name the file, and `gbrain sources writer status` shows the same advice. A recovery that can still finish (its file back on a recorded version) keeps the wait. Known gap: a recovery stuck on `unexpected_staging_bytes` still waits out the window.' },
+ { since: '0.60.271.0', text: 'A sync queued behind a recovery that only the user can resolve now stops after one governor tick with `drain_stalled`, `cause: head_blocked`, instead of waiting out the 5-minute no-progress window. Two recoveries count: a fact-withdrawal mirror whose page file was edited while the mirror was publishing (`blocked_by=effect_recovery(unexpected_file_bytes …)`; the fix asks the user to put the file back to a version gbrain recorded, then rerun the sync), and a page write whose file was edited while it was publishing (`blocked_by=request_recovery(unexpected_file_bytes …)`, whether it blocks the queued head or is the head; the fix runs the `gbrain repair stuck-recovery` preview, or the user undoes the edit). Both name the file, and `gbrain sources writer status` shows the same advice. A recovery that can still finish (its file back on a recorded version) keeps the wait. Known gap: a recovery stuck on `unexpected_staging_bytes` still waits out the window.' },
// W2 belief ledger page-at-time. `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.
- { since: '0.60.267.0', text: 'A page rename (a sync that sees a file move, a frontmatter slug repair, a held-file or import move) now saves the page as it stood before the move as a version, as an edit does, so `get_versions` and `gbrain history` list one more snapshot per rename. The move advances the page\'s revision, and until now no version held the body from before it.' },
- { 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.' },
+ { since: '0.60.271.0', text: 'A page rename (a sync that sees a file move, a frontmatter slug repair, a held-file or import move) now saves the page as it stood before the move as a version, as an edit does, so `get_versions` and `gbrain history` list one more snapshot per rename. The move advances the page\'s revision, and until now no version held the body from before it.' },
+ { since: '0.60.271.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).
@@ -731,11 +731,16 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }
{ 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.' },
// FIFO claim foreground guard (fgp-park-before-claim, #6862).
{ since: '0.60.271.0', text: 'A foreground write no longer loses to an idle drain\'s sync head. While a managed sync drains, a page write that may go ahead of the queued sync groups (none of them names its page) now holds back the next sync group even when the drain\'s lanes are idle and the write\'s own process is still claiming it; before, the drain could start a group in that moment and the write waited for it. The sync side still gets one group after each such write commits, so a stream of writes cannot stall it.' },
- // #6803 lane C (bounded status and doctor reads). `since` is a placeholder equal to the branch VERSION until the merge-slot stamp.
- { since: '0.60.267.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.267.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.267.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 (`links_extraction_lag`, now its own entry, `partial_embedding` and content sanity) 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.267.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.' },
+ // #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.271.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.271.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.271.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`, `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.271.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.271.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.271.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.271.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.271.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.271.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. */
diff --git a/test/held-embedding-printed-commands.serial.test.ts b/test/held-embedding-printed-commands.serial.test.ts
index 3ada0fdf55..95bdb38a48 100644
--- a/test/held-embedding-printed-commands.serial.test.ts
+++ b/test/held-embedding-printed-commands.serial.test.ts
@@ -11,8 +11,11 @@
* Fails when: a surface prints `gbrain reindex --held` (which does not exist),
* an approve without `--source` (refused on a multi-source brain), or a
* placeholder.
- * Extension point: test/helpers/printed-command-guard.ts
- * (`PRINTED_COMMAND_PRODUCERS`); lane A's projection texts register there.
+ * Also guards the projection drain's printed commands (#6803 A9): `PROJECTIONS_HELP`,
+ * `projectionFailureNextAction`, the resident drain steps and Action, doctor's
+ * resident readiness, `formatDrainResult` and the repair and embedding-migration
+ * docs, run on a multimodal brain because they name `embed --stale --images`.
+ * Extension point: test/helpers/printed-command-guard.ts (`PRINTED_COMMAND_PRODUCERS`).
* Serial: it installs the process-wide CLI fix routing (installCliRouting), which
* every renderAction in the process reads.
*/
@@ -22,6 +25,8 @@ import { addSizeState, readPageSizeStates, sizeStateLines, type SyncSizeStates }
import { budgetLimitedReport } from '../src/core/held-embedding.ts';
import { heldPreviewCommand } from '../src/core/held-embedding-action.ts';
import { argvOf, gbrain, makeHeldBrain, seedHeldPage, startFakeEmbeddings, withBrain, type FakeEmbeddings, type HeldBrain } from './helpers/held-embedding-fixture.ts';
+import { PROJECTIONS_HELP, formatDrainResult, projectionFailureNextAction, residentDrainAction, residentDrainSteps } from '../src/commands/projections.ts';
+import { residentProjectionReadiness } from '../src/commands/doctor/checks/projection-readiness.ts';
import { PRINTED_COMMAND_PRODUCERS, docSection, dryForm, extractCommands, registerPrintedCommandProducer, type GuardFixture } from './helpers/printed-command-guard.ts';
const ROUTING = { brain: 'host', source: 'alpha' };
@@ -90,6 +95,58 @@ registerPrintedCommandProducer({
owns: heldCommand,
});
+/** Lane A (#6803 part 2, plan A9): the projection drain's printed commands join the guard. */
+const MULTIMODAL = { GBRAIN_EMBEDDING_MULTIMODAL: 'true' };
+const projectionCommand = (argv: string[]) => argv[0] === 'projections'
+ || (argv[0] === 'embed' && argv.includes('--images')) || (argv[0] === 'doctor' && argv.includes('text_projection_readiness'));
+registerPrintedCommandProducer({
+ name: 'PROJECTIONS_HELP',
+ text: async () => PROJECTIONS_HELP.split('\n').filter(l => !l.startsWith('Usage:')).join('\n'),
+ fill: { '<n>': '10' },
+ owns: projectionCommand,
+ env: MULTIMODAL,
+});
+registerPrintedCommandProducer({
+ name: 'projectionFailureNextAction',
+ text: async () => ['Code projection requires a recorded source path', 'This page kind requires its source importer', 'revision_conflict: moved', 'other']
+ .map(reason => projectionFailureNextAction({ source_id: 'alpha', slug: 'archive/day-b', reason })).join('\n'),
+ owns: projectionCommand,
+ env: MULTIMODAL,
+});
+registerPrintedCommandProducer({
+ name: 'resident drain steps, Action and doctor readiness',
+ text: async () => {
+ const status = { pending: 2, failed: 0, oldest_age_seconds: 60, sealable: 3, sealable_with_visual: 1, reimport: 1, ocr_required: 1, protected: 1, archived: 0 };
+ const action = residentDrainAction({ pid: 4242, subcommand: 'serve' } as never, 'host', status);
+ const readiness = residentProjectionReadiness(4242, status, residentDrainSteps(4242, 'host', 10), action.then);
+ return [residentDrainSteps(4242, 'host', 10), action.user_message ?? '', action.then?.argv?.join(' ') ?? '', action.then?.verify?.argv?.join(' ') ?? '',
+ readiness.message, readiness.fix?.argv?.join(' ') ?? ''].join('\n');
+ },
+ owns: projectionCommand,
+ env: MULTIMODAL,
+});
+registerPrintedCommandProducer({
+ name: 'formatDrainResult (limited drain with image remainders)',
+ text: async () => formatDrainResult({ rebuilt: 2, superseded: 0, failed: [], remaining: 4, limited: true, sealed: 3, sealed_with_visual: 1, sealed_text_only: 2,
+ statistics_refreshed: false, remaining_by_class: { pending: 0, failed: 0, oldest_age_seconds: 60, sealable: 2, sealable_with_visual: 0, reimport: 1, ocr_required: 1, protected: 1, archived: 0 } } as never, 10),
+ owns: projectionCommand,
+ env: MULTIMODAL,
+});
+registerPrintedCommandProducer({
+ name: 'docs/guides/repair.md (projection drain)',
+ text: async () => docSection('docs/guides/repair.md', 'id="projection-drain"', 'id="embedding-key-source"'),
+ fill: { '<n>': '10', '<id>': 'alpha' },
+ owns: projectionCommand,
+ env: MULTIMODAL,
+});
+registerPrintedCommandProducer({
+ name: 'docs/guides/embedding-migration.md (recovery)',
+ text: async () => docSection('docs/guides/embedding-migration.md', '## Recovery', '## '),
+ fill: { '<n>': '10', '<id>': 'alpha' },
+ owns: projectionCommand,
+ env: MULTIMODAL,
+});
+
let fake: FakeEmbeddings;
let brain: HeldBrain;
let fixture: GuardFixture;
@@ -133,7 +190,7 @@ test('every printed command runs in dry form through the real CLI with exit 0',
if (command.includes('<') || command.includes('>')) { failures.push(`${producer.name}: placeholder left in ${command}`); continue; }
if (argv[0] === 'reindex' && argv.includes('--held')) { failures.push(`${producer.name}: ${command} does not exist`); continue; }
if (argv[0] === 'embed' && argv.includes('--max-usd') && !argv.includes('--source')) { failures.push(`${producer.name}: approve without --source: ${command}`); continue; }
- const out = await fixture.run(dryForm(argv));
+ const out = await fixture.run(dryForm(argv), producer.env);
if (out.exitCode !== 0) failures.push(`${producer.name}: gbrain ${dryForm(argv).join(' ')} exited ${out.exitCode}: ${(out.stderr || out.stdout).slice(0, 400)}`);
}
}
diff --git a/test/helpers/printed-command-guard.ts b/test/helpers/printed-command-guard.ts
index 37d98fa623..ea89629a0e 100644
--- a/test/helpers/printed-command-guard.ts
+++ b/test/helpers/printed-command-guard.ts
@@ -38,6 +38,8 @@ export interface PrintedCommandProducer {
fill?: Record<string, string>;
/** Which extracted commands this producer owns (a doc section also names unrelated, mutating commands such as `gbrain upgrade`); default all. */
owns?: (argv: string[]) => boolean;
+ /** Env overlay for this producer's command runs (a surface that names a multimodal-only command runs on a multimodal brain). */
+ env?: Record<string, string | undefined>;
}
export const PRINTED_COMMAND_PRODUCERS: PrintedCommandProducer[] = [];