Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(cli): keep consent-read = values (book-mirror, jobs submit, reindex-code --max-cost, reinit-pglite --expect) and jobs work --job-isolation=; supervisor upgrade restart drops = values the old supervisor ignored; row covers both; fix test header placement and stale citations

garrytan472e970823a6
diff --git a/src/cli/flag-equals.ts b/src/cli/flag-equals.ts
index 3194f5a5d6..951bd3293a 100644
--- a/src/cli/flag-equals.ts
+++ b/src/cli/flag-equals.ts
@@ -64,6 +64,8 @@ export const EQUALS_READERS: Readonly<Record<string, readonly string[]>> = {
'beliefs changes': ['--since'],
// beliefs-replay-purges.ts:14 flag() reads --x v and --x=v.
'beliefs replay-purges': ['--archived-at', '--purge-mirror', '--from-url-env'],
+ // core/consent.ts:126 via consentGateOrExit (book-mirror.ts:431, args :440, effects paid); book-mirror reads no --max-* itself.
+ 'book-mirror': ['--max-usd', '--max-cost'],
// capture.ts:96 regex; every other = form is refused by capture's own parser (capture.ts:132).
capture: ['--request-id', '--expected-revision'],
// check-resolvable.ts:120 parseFlags.
@@ -75,7 +77,7 @@ export const EQUALS_READERS: Readonly<Record<string, readonly string[]>> = {
'code-refs': ['--limit', '--lang', '--source'],
// compile-context.ts:74 flagValue (parseCompileFlags :88-115).
'compile-context': ['--target', '--budget', '--include', '--out', '--source'],
- // core/consent.ts:112 parseConsentFlags via enableConsent (decide.ts:348, effects paid); decide reads no --max-* itself.
+ // core/consent.ts:123 parseConsentFlags via enableConsent (decide.ts:348, effects paid); decide reads no --max-* itself.
'decide enable': ['--max-usd', '--max-cost'],
// doctor.ts:417 --scope=brain only (=-only); doctor/budget.ts:68 --tier/--budget-ms; cli/commands/doctor.ts:27 --tier (thin client);
// doctor/registry.ts:332 --only; check-resolvable.ts:120 --skills-dir via doctor.ts:460; core/consent.ts:130 --expect (remediate-consent.ts:133).
@@ -86,7 +88,7 @@ export const EQUALS_READERS: Readonly<Record<string, readonly string[]>> = {
embed: ['--pace', '--pace-max-concurrency', '--max-usd', '--max-cost'],
// eval-conversation-parser.ts:48-53 (main.ts handleCliOnly's eval conversation-parser branch and eval.ts:106 both reach it).
'eval conversation-parser': ['--fixtures', '--min-recall'],
- // eval/decide-eval-flags.ts:124 extractDecideEvalFlags via eval-retrieval-quality.ts:38.
+ // eval/decide-eval-flags.ts:122 extractDecideEvalFlags via eval-retrieval-quality.ts:38.
'eval retrieval-quality': ['--decide', '--decide-provider', '--decide-calibration', '--decide-threshold', '--decide-force-on', '--decide-dataset'],
// eval-takes-quality.ts:82 getFlag; union over run (:148-162) / trend (:200-201) / regress (:212-226); replay reads none.
'eval takes-quality': ['--limit', '--cycles', '--budget-usd', '--slug-prefix', '--models', '--source', '--rubric-version', '--against', '--threshold'],
@@ -108,8 +110,12 @@ export const EQUALS_READERS: Readonly<Record<string, readonly string[]>> = {
import: ['--source', '--source-id'],
// integrity.ts:857 extractFlag via cmdCheck (:306-307); integrity auto is STRICT.
'integrity check': ['--limit', '--type'],
+ // core/consent.ts:126 via jobs/submit.ts:104 requireEmbedBackfillConsent, :128 requireReindexConsent, :294 authorizePaidSubmit (paid); submit's own parseFlag(--max-usd) (:286) reads only the separate `off`.
+ 'jobs submit': ['--max-usd', '--max-cost'],
// jobs/shared.ts:121 parseJobIsolationFlag via jobs/supervisor.ts:165.
'jobs supervisor': ['--job-isolation'],
+ // jobs/shared.ts:121 parseJobIsolationFlag via jobs/work.ts:114.
+ 'jobs work': ['--job-isolation'],
// jobs/watch.ts:11 reads only --refresh-ms=N.
'jobs watch': ['--refresh-ms'],
// lint.ts:929 runLint.
@@ -133,8 +139,10 @@ export const EQUALS_READERS: Readonly<Record<string, readonly string[]>> = {
recall: ['--entity', '--source-id', '--question', '--budget-policy'],
// reindex.ts:155-163 normalizeReindexArgs at entry (cli/commands/reindex.ts:12); --max-cost via core/consent.ts:126 (reindex-consent.ts:77).
reindex: ['--type', '--limit', '--repo', '--workers', '--concurrency', '--max-usd', '--max-cost'],
- // core/consent.ts:126 via reindex-code.ts:503 / reindex-code-delegate.ts:51 (paid); reindex-code reads no --max-usd itself.
- 'reindex-code': ['--max-usd'],
+ // core/consent.ts:126 via reindex-code.ts:503 / reindex-code-delegate.ts:51 (paid); the own --max-cost loop (reindex-code.ts:438) reads only the separate token and :521 takes the consent cap.
+ 'reindex-code': ['--max-usd', '--max-cost'],
+ // core/consent.ts:130 --expect via consentGateOrExit (reinit-pglite.ts:109, plan_hash :119); parseArgs (:213) reads no --expect.
+ 'reinit-pglite': ['--expect'],
// resolvers.ts:172 extractFlag via cmdList (:66-67).
'resolvers list': ['--cost', '--backend'],
// routing-eval.ts:83 parseFlags.
@@ -170,7 +178,7 @@ export const EQUALS_READERS: Readonly<Record<string, readonly string[]>> = {
'skillpack diff': ['--workspace', '--skills-dir'],
// skillpack/scaffold.ts:36 lane select + :73 --workspace=; harness lane skillpack/harness.ts:91-158 parseHarnessArgs (:364).
'skillpack scaffold': ['--workspace', '--harness', '--persona', '--skill', '--dest', '--scope', '--skills'],
- // skillpack/reference.ts:44 harness lane (strict-args.ts:105 makes the non-harness lane STRICT); harness.ts:542.
+ // skillpack/reference.ts:44 harness lane (strict-args.ts:102 makes the non-harness lane STRICT); harness.ts:542.
'skillpack reference': ['--harness', '--persona', '--skill', '--dest', '--scope', '--workspace', '--skills'],
// core/bounded-listing-cli.ts:15 via sources.ts:1213 runStatus (+ :1214 paged regex).
'sources status': ['--limit', '--cursor'],
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index 5b6021052a..df3194455c 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -1308,7 +1308,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;
{ since: '0.60.464.0', text: 'Security: `gbrain serve --access=read-only` (the `=` form) now sets the read-only ceiling. It passed flag validation before but started the serve with full write access, because only `--access read-only` was read. A config that used the `=` form now gets the read-only tool set and refused mutations it asked for; a repeated `--access` never widens a read-only value, and an invalid value in either form refuses. `--surface=<v>` likewise now sets the serve surface (it was ignored, leaving the full surface), and a repeated `--surface` takes the narrowest value.' },
{ since: '0.60.464.0', text: 'A managed sync pass whose process was killed or crashed now reads `resumable` / `pass_interrupted` in `gbrain sync status` (with an `interrupted` block naming the pass and the dead holder) instead of `pass_unfinished`, and a second killed pass reads `blocked` / `pass_abandoned` at once. `gbrain doctor` `managed_sync_blocked` lists both (warn, fail after an hour). A live pass still committing is no longer counted abandoned because its row is old.' },
{ since: '0.60.465.0', text: 'On a managed brain, `gbrain trust release h<id>` of a held fact whose entity page exists now writes the fact into that page\'s `## Facts` fence through the page-write door (a `trust_release` page write) and flips the hold in the same publication, so the released fact lives in the page\'s file and a re-import keeps it. Before, the release inserted a database-only row the file never held; a fence-guard hold that names an existing fence row created a database-only twin of it, and now indexes that row and leaves the file unchanged. The row is stamped `user_confirmed` with origin `trust_release` and the page keeps its trust tier. A hold decided after the release was accepted fails `preview_changed` and writes nothing; a remote request, or a deleted or private entity page, refuses and the fact stays held. A hold with no entity page, and unmanaged brains, release database-only as before.' },
- { since: 'TBD', id: 'cli_flag_equals', text: 'A CLI flag value written with `=` that a command used to ignore now exits 2 (`invalid_params`) and names the two-argument spelling the command reads: `gbrain auth create --scopes=read` minted a full-access token. A switch never takes a value (`--yes=n`, `--dry-run=true`, `--apply=false` and `-y=n` exit 2 instead of being ignored). The `=` spellings a command reads on every path keep working; four that only some paths read now exit 2 with the two-argument fix: the source id given that way to `gbrain extract` for stale extraction, the reason given that way to a fact purge in `gbrain forget`, the checkout path given that way to the database-free `gbrain sources pull`, and the values given that way to the managed `gbrain sources` lifecycle subcommands (add, remove, archive, restore, purge, set-path, reclone). A value written with `=` on a flag that the help of the command declares used to be ignored and now applies, so check scripts that pass these that way: an all-interfaces bind address given to `gbrain serve` bound loopback and now listens on every interface; a public URL given to `gbrain serve` now sets the OAuth issuer and resource, so clients authorized under the old localhost issuer must reconnect, and admin cookies become Secure on https; the serve port, token lifetime and stdio idle timeout, the sync interval, source and repository, the import worker count, the autopilot install repository and supervisor, and the target engine and URL the legacy `gbrain migrate` copier reads take effect the same way; a spend cap given to `gbrain onboard` (off included) now applies, and one given to a resumed `gbrain doctor` remediation overrides the cap its checkpoint recorded; and `gbrain apply-migrations` now honors an accepted reviewed inventory and a forced retry of a wedged migration. A script that passes a value with `=` to a command that does not read that form now stops with the fix instead of running without the value.' },
+ { since: 'TBD', id: 'cli_flag_equals', text: 'A CLI flag value written with `=` that a command used to ignore now exits 2 (`invalid_params`) and names the two-argument spelling the command reads: `gbrain auth create --scopes=read` minted a full-access token. A switch never takes a value (`--yes=n`, `--dry-run=true`, `--apply=false` and `-y=n` exit 2 instead of being ignored). The `=` spellings a command reads on every path keep working, and so do the spending cap and plan hash the consent check of a command reads; a few that only some paths read now exit 2 with the two-argument fix, among them the source id given that way to `gbrain extract` for stale extraction, the reason given that way to a fact purge in `gbrain forget`, the checkout path given that way to the database-free `gbrain sources pull`, and the values given that way to the managed `gbrain sources` lifecycle subcommands (add, remove, archive, restore, purge, set-path, reclone). A value written with `=` on a flag that the help of the command declares used to be ignored and now applies, so check scripts that pass these that way: an all-interfaces bind address given to `gbrain serve` bound loopback and now listens on every interface; a public URL given to `gbrain serve` now sets the OAuth issuer and resource, so clients authorized under the old localhost issuer must reconnect, and admin cookies become Secure on https; the serve port, token lifetime and stdio idle timeout, the sync interval, source and repository, the import worker count, the autopilot install repository and supervisor, and the target engine and URL the legacy `gbrain migrate` copier reads take effect the same way; a spend cap given to `gbrain onboard` (off included) now applies, and one given to a resumed `gbrain doctor` remediation overrides the cap its checkpoint recorded; and `gbrain apply-migrations` now honors an accepted reviewed inventory and a forced retry of a wedged migration. An upgrade restart of a `gbrain jobs supervisor` started with values written that way (which it ignored) starts it again without them. A script that passes a value with `=` to a command that does not read that form now stops with the fix instead of running without the value.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */
diff --git a/src/core/upgrade-restart.ts b/src/core/upgrade-restart.ts
index 2277de240e..5768b712ea 100644
--- a/src/core/upgrade-restart.ts
+++ b/src/core/upgrade-restart.ts
@@ -203,11 +203,14 @@ export interface RestartPlan {
const label = (p: Pick<HostProcess, 'role' | 'pid' | 'version'>) => `${p.role} pid ${p.pid} (${p.version ? `v${p.version}` : 'build not recorded'})`;
-/** The supervisor's stop and start commands from the arguments it runs with, so the restart keeps its queue, concurrency and PID file. */
+/**
+ * The supervisor's stop and start commands from the arguments it runs with, so the restart keeps its queue, concurrency and PID file.
+ * A `--flag=value` token other than --job-isolation was ignored by the supervisor that holds it (an older release) and is refused by this one, so it is dropped: the restart runs what the supervisor applied.
+ */
export function supervisorRestartArgv(args: readonly string[]): { stop: string[]; start: string[]; pid_file: string | null } {
- const rest = args.slice(args.indexOf('supervisor') + 1).filter(arg => arg !== 'start' && arg !== '--detach' && arg !== '--json');
- const at = rest.findIndex(arg => arg === '--pid-file' || arg.startsWith('--pid-file='));
- const pidFile = at === -1 ? null : rest[at]!.includes('=') ? rest[at]!.slice('--pid-file='.length) : rest[at + 1] ?? null;
+ const rest = args.slice(args.indexOf('supervisor') + 1).filter(arg => arg !== 'start' && arg !== '--detach' && arg !== '--json' && !(/^--[^=]+=/.test(arg) && !arg.startsWith('--job-isolation=')));
+ const at = rest.indexOf('--pid-file');
+ const pidFile = at === -1 ? null : rest[at + 1] ?? null;
return {
stop: ['gbrain', 'jobs', 'supervisor', 'stop', ...(pidFile ? ['--pid-file', pidFile] : []), '--json'],
start: ['gbrain', 'jobs', 'supervisor', 'start', '--detach', ...rest, '--json'],
diff --git a/test/cli-flag-equals.test.ts b/test/cli-flag-equals.test.ts
index 2094f9e245..21f3a42959 100644
--- a/test/cli-flag-equals.test.ts
+++ b/test/cli-flag-equals.test.ts
@@ -305,7 +305,7 @@ describe('#7619 split rules', () => {
'src/commands/graph-query.ts': ['graph-query'],
'src/commands/import.ts': ['import'],
'src/commands/integrity.ts': ['integrity check'],
- 'src/commands/jobs/shared.ts': ['jobs supervisor'],
+ 'src/commands/jobs/shared.ts': ['jobs supervisor', 'jobs work'],
'src/commands/jobs/watch.ts': ['jobs watch'],
'src/commands/lint.ts': ['lint'],
'src/commands/migrate-graduation.ts': ['migrate'],
@@ -331,7 +331,7 @@ describe('#7619 split rules', () => {
'src/commands/sync/operator.ts': ['sync status'],
'src/commands/trust-claim.ts': ['trust claim-sources'],
'src/core/bounded-listing-cli.ts': ['orphans', 'sources status', 'sync status'],
- 'src/core/consent.ts': ['decide enable', 'doctor', 'embed', 'features', 'migrate', 'reindex', 'reindex-code'],
+ 'src/core/consent.ts': ['book-mirror', 'decide enable', 'doctor', 'embed', 'features', 'jobs submit', 'migrate', 'reindex', 'reindex-code', 'reinit-pglite'],
'src/core/stable-channel.ts': ['upgrade'],
'src/eval/decide-eval-flags.ts': ['eval retrieval-quality'], // also eval brainbench (exempt) and eval longmemeval (own)
@@ -472,7 +472,7 @@ describe('#7619 refusals that keep consent, scope and targets right', () => {
['extract', ['links', '--source', 'db', '--source-id=source-a'], '--source-id'], ['extract', ['--stale', '--source-id=source-a'], '--source-id'],
['trust', ['explain', 'ref-example', '--source=source-a'], '--source'], ['jobs', ['work', '--concurrency=4'], '--concurrency'],
['forget', ['34', '--reason=stale-example'], '--reason'], ['migrate', ['--to', 'pglite', '--path=/tmp/brain-example'], '--path'],
- ['jobs', ['submit', 'shell', '--params={"a":1}'], '--params'], ['jobs', ['submit', 'sync', '--max-usd=5'], '--max-usd'],
+ ['jobs', ['submit', 'shell', '--params={"a":1}'], '--params'],
] as const) {
const r = await cliOnlyFlagArgs(command, [...args]);
expect('refusal' in r && r.refusal.message).toContain(`takes ${flag} <value> as two arguments`);
@@ -480,7 +480,7 @@ describe('#7619 refusals that keep consent, scope and targets right', () => {
}
});
- // Value: protects=a split value never becomes the first numeric/slug target (forget --purge --reason=3 34 must not hit fact 3); fails_when=a refusal turns into a split or keep; why_new=rows only asserted not-null; seam=none; no_claim=handler behavior after a split (argv-level only)
+ // Value: protects=migrate --to=/--url= reach the graduation and legacy copier readers as two arguments; fails_when=COMMAND_VALUES loses migrate and the = form refuses or is kept; why_new=graduation read the = form on master and the legacy copier never did; seam=none; no_claim=migrate-engine.ts parseArgs is not called (argv-level only)
test('migrate splits the target engine and URL, which every migrate path reads as two arguments', async () => {
expect(await argvFor('migrate', ['--to=postgres', '--url-env', 'TARGET_URL', '--plan'])).toEqual(['--to', 'postgres', '--url-env', 'TARGET_URL', '--plan']);
expect(await argvFor('migrate', ['--to=pglite', '--path', '/tmp/brain-example'])).toEqual(['--to', 'pglite', '--path', '/tmp/brain-example']);
@@ -489,6 +489,7 @@ describe('#7619 refusals that keep consent, scope and targets right', () => {
expect(routesToGraduation(['--to', 'postgres'], { engine: 'pglite' } as GBrainConfig, 'linux')).toBe(true);
});
+ // Value: protects=a split value never becomes the first numeric/slug target (forget --purge --reason=3 34 must not hit fact 3); fails_when=a refusal turns into a split or keep; why_new=rows only asserted not-null; seam=none; no_claim=handler behavior after a split (argv-level only)
test('a flag value never becomes the numeric or slug target of a mutating subcommand', async () => {
for (const [command, args] of [
['forget', ['--purge', '--reason=3', '34', '--dry-run']],
@@ -571,7 +572,6 @@ describe('#7619 refusals that keep consent, scope and targets right', () => {
expect(parseAddTypeArgs(['note', '--primitive=entity', '--no-prefix'])).toMatchObject({ noPrefix: true });
expect(parseMovementArgs(['source-a', '--json=true'])).toMatchObject({ json: true });
expect(() => parseAddTypeArgs(['note', '--primitive=entity', '--no-prefix', '--json=true'])).not.toThrow();
- expect(() => parseMovementArgs(['source-a', '--json=false'])).toThrow('--json is a switch');
});
test('own = parsers behind the gate refuse a value on consent and mutation switches', () => {
diff --git a/test/upgrade-restart.test.ts b/test/upgrade-restart.test.ts
index faa04818af..7c1a29374b 100644
--- a/test/upgrade-restart.test.ts
+++ b/test/upgrade-restart.test.ts
@@ -64,6 +64,14 @@ describe('supervisorRestartArgv', () => {
});
expect(DEFAULT_SUP).toEqual({ stop: ['gbrain', 'jobs', 'supervisor', 'stop', '--json'], start: ['gbrain', 'jobs', 'supervisor', 'start', '--detach', '--json'], pid_file: null });
});
+
+ test('drops the = values an older supervisor ignored, so the restart runs what it applied and this release does not refuse it', () => {
+ expect(supervisorRestartArgv(['jobs', 'supervisor', 'start', '--concurrency=4', '--pid-file=/tmp/sup-example.pid', '--job-isolation=process', '--queue', 'ingest', '--allow-shell-jobs=true'])).toEqual({
+ stop: ['gbrain', 'jobs', 'supervisor', 'stop', '--json'],
+ start: ['gbrain', 'jobs', 'supervisor', 'start', '--detach', '--job-isolation=process', '--queue', 'ingest', '--json'],
+ pid_file: null,
+ });
+ });
});
describe('collectHostProcesses', () => {