Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

refactor: config get/set sync-key hook moves into sync-config-keys (#6712 PR 2, L3)

garrytan378f9c353c41
diff --git a/scripts/function-size-baseline.tsv b/scripts/function-size-baseline.tsv
index 9eb11b70ae..e504557cb2 100644
--- a/scripts/function-size-baseline.tsv
+++ b/scripts/function-size-baseline.tsv
@@ -8,7 +8,7 @@
path name lines justification
src/commands/bootstrap.ts runHooks 600 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +3 #4618: --seat/--no-seat parse + refusal/note (logic in core/bootstrap/hooks.ts parseSeatFlags)
src/commands/bootstrap.ts runHooks>withLock(#1) 449 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)
-src/commands/config.ts runConfig 781 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +2 #5232: persistence.write_wait_ms dispatch line (logic in setFileWriteWait); wave 10 collector: master and the #4907/#5958 config-set range refusals compose at 775; re-summed at the #6015 merge (767 master baseline + 4 integration lines); re-summed at the wave 10 merge on actual lines; +1 C4: dream.auto_think.* replacement note (logic in questions/auto-think-migration.ts); +5 wave 15 P7.4 #5461: set-time refusal of think.pages_budget_chars / think.excerpt_ceiling_chars (range text from think/pages-budget.ts pagesBudgetConfigError)
+src/commands/config.ts runConfig 782 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +2 #5232: persistence.write_wait_ms dispatch line (logic in setFileWriteWait); wave 10 collector: master and the #4907/#5958 config-set range refusals compose at 775; re-summed at the #6015 merge (767 master baseline + 4 integration lines); re-summed at the wave 10 merge on actual lines; +1 C4: dream.auto_think.* replacement note (logic in questions/auto-think-migration.ts); +5 wave 15 P7.4 #5461: set-time refusal of think.pages_budget_chars / think.excerpt_ceiling_chars (range text from think/pages-budget.ts pagesBudgetConfigError); +1 #6712 PR 2: retired/rollback sync key dispatch line (logic in core/sync-config-keys.ts handleSyncKeyConfig)
src/commands/doctor/bootstrap-checks.ts bootstrapDoctorChecks 476 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)
src/commands/doctor/checks/extraction-sync.ts checkSyncFreshness 333 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)
src/commands/doctor/report-remote.ts doctorReportRemote 416 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index 2bee3f92be..3016beb807 100644
--- a/scripts/module-size-limits.tsv
+++ b/scripts/module-size-limits.tsv
@@ -45,5 +45,5 @@ src/core/search/mode.ts 1669 ratchet +53 W3 confidence-gated reranking: reranker
src/commands/eval-longmemeval.ts 1544 ratchet new row: crossed the 1500 unlisted cap in fw3-search (#5092 benchmark-brain recycling: configureBrain split + recycler wiring + test seams; the recycler itself lives in src/eval/longmemeval/harness.ts); +1 P6: tokenmax synopsis-tier wiring (logic in eval/longmemeval/synopsis-tier.ts); +13 GBRA-81 lane A: --via-operation query|search (flags, per-call expansion pin, the run's expectExpansion, the op branch in runOneQuestion, row field, via_operation_summary and its FAIL line; logic in eval/longmemeval/via-operation.ts); +12 --call-plan FILE / --call-plan-gate CMD: two LME_FLAGS entries (CLI help lines), two ParsedArgs fields, the parseArgs pairing check and the header invariant (planner lives in eval/longmemeval/call-plan.ts; runEvalLongMemEval is one line shorter)
src/commands/doctor/checks/extraction-sync.ts 1523 ratchet +1 undeclared_db_only_pages computes the source Git scope once per source (logic in core/markdown.ts sourceGitScope); new row: crossed the 1500 unlisted cap at the fix wave 9 merge: +7 lane W #5028 (extract_atoms freshness judged by the phase itself) and +3 lane F #5863 (extract_health dates a high halt rate by its last halt), each under the cap alone; +7 #5019: content_hash_duplicates fix pins the pairs' source (GBRAIN_SOURCE) and names a delete that runs; +1 fix wave 10 lane L1 #5556: links_extraction_lag denominator excludes quarantined pages (quarantineFilterFragment import); +11 fix wave 15 P2.8 (#5495): extract_health reads the 7-day halt reasons per kind (halt_reasons, top_halt_reason in details and the top reason in the warn line); the read, the unknown bucket and the ranking live in core/extract/rollup-writer.ts
src/core/search/evidence-delivery.ts 1673 ratchet +5 W5: EvidencePlan.rankCut resolved with the plan (logic in search/page-rank-cut.ts); +20 W5 whole_pages: wholeCost prices a block as delivery would emit it whole (needs the private Block/enrichBlock internals) and the cut is wired before allocate (cutWholePages lives in search/page-rank-cut.ts); new row: crossed the 1500 unlisted cap at the #6367 merge (master 1479, its explicit-budget cap) by the C1 date header threaded through every block path, cap included; pagePlanHits (search/page-plan-hits.ts) and the header loader (evidence-date.ts blockDateHeaders) were peeled first; peel candidate: allocateCapped; +8 at the #6396 merge: page evidence text cut through the fence-chunk trust overlay and the caller minTrust floor (re-summed: our 1504 + master +8); +119 Cat 40 next wave F2: the search.long_page_unit policy (withLongPagePolicy, selectLongPages size preflight with page/byte/deadline limits) and the long-page fetch and fallback in deliverEvidence, kept in the shared seam the plan names (gbrain-evals docs/plans/2026-10-11-cat40-next-wave, F2); +17 F2 rework to the frozen-comparison policy: search.long_page_min_chars (rendered-body characters, default 20,000) read in withLongPagePolicy, a character count in the preflight, the rendered-body confirmation in deliverEvidence, and the long-page row exemption in capDeliveredSnippets (re-summed at the 0.60.225.0 merge: master 1537 + F2 136)
-src/commands/config.ts 1508 ratchet new row: crossed the 1500 unlisted cap in wave 15 P7.4 #5461: set-time validation of think.pages_budget_chars / think.excerpt_ceiling_chars (range + parser live in core/think/pages-budget.ts), mirroring the cycle.consolidate.cluster_threshold hook; +1 wave 16 G5.1 (#6495): set-time refusal hook for search.keyword_statement_timeout_ms (check lives in commands/config/keyword-timeout-value.ts)
+src/commands/config.ts 1509 ratchet new row: crossed the 1500 unlisted cap in wave 15 P7.4 #5461: set-time validation of think.pages_budget_chars / think.excerpt_ceiling_chars (range + parser live in core/think/pages-budget.ts), mirroring the cycle.consolidate.cluster_threshold hook; +1 wave 16 G5.1 (#6495): set-time refusal hook for search.keyword_statement_timeout_ms (check lives in commands/config/keyword-timeout-value.ts); +1 #6712 PR 2: retired/rollback sync key dispatch line (logic in core/sync-config-keys.ts handleSyncKeyConfig)
src/commands/mcp-expose.ts 1512 ratchet hosted_option: Session carries the gbrain.io coaching notice on the first-receipt run and Tailscale/service friction exits (copy, refs and gating live in core/onboard/hosted-option.ts)
diff --git a/src/commands/config.ts b/src/commands/config.ts
index 1d21cca24c..e55cf03491 100644
--- a/src/commands/config.ts
+++ b/src/commands/config.ts
@@ -881,6 +881,7 @@ export async function runConfig(engine: BrainEngine, args: string[]) {
const key = positionals[1];
const value = positionals[2];
if ((action === 'get' || action === 'set') && key) (await import('../core/questions/auto-think-migration.ts')).noteAutoThinkReplacement(key);
+ if ((action === 'get' || action === 'set') && key && await (await import('../core/sync-config-keys.ts')).handleSyncKeyConfig(engine, action, key)) return; // #6712 PR 2
if (action === 'get' && (key === EMBEDDING_DISABLED_KEY || key === 'schema_pack')) {
const effective = key === 'schema_pack' ? await effectiveSchemaPack(engine) : await effectiveEmbeddingDisabled(engine);
@@ -892,15 +893,6 @@ export async function runConfig(engine: BrainEngine, args: string[]) {
console.error(`[config] source: ${effective.note}`);
return;
}
- if (action === 'get' && key) {
- // #6712 PR 2: a retired or rollback sync key prints the value a sync runs with, and where it comes from.
- const effective = (await import('../core/sync-config-keys.ts')).effectiveSyncKey(key, await engine.getConfig(key));
- if (effective) {
- console.log(effective.value);
- console.error(`[config] source: ${effective.origin}`);
- return;
- }
- }
if (action === 'get' && key) {
// #2120: `get` used to read only the DB plane, so a runtime-effective key
// in ~/.gbrain/config.json (or env) reported not-found. Resolve the way
@@ -986,12 +978,6 @@ export async function runConfig(engine: BrainEngine, args: string[]) {
process.exit(1);
}
const value = tail.find(a => !a.startsWith('-')) ?? args[2];
- // #6712 PR 2: a retired sync key is no longer read (warn, write nothing); a rollback key is written with its window.
- const syncNotice = (await import('../core/sync-config-keys.ts')).syncKeySetNotice(key);
- if (syncNotice) {
- for (const line of syncNotice.lines) console.error(line);
- if (!syncNotice.writes) return;
- }
// Bootstrap hook-lane keys are FILE-plane canonical: they are read by
// engine-free processes (the harness hook children and the detached
diff --git a/src/core/sync-config-keys.ts b/src/core/sync-config-keys.ts
index 3f7f722970..211fd5c8cb 100644
--- a/src/core/sync-config-keys.ts
+++ b/src/core/sync-config-keys.ts
@@ -115,3 +115,21 @@ export function syncKeySetNotice(key: string): { writes: boolean; lines: string[
] };
return null;
}
+
+/**
+ * `gbrain config get|set` of a retired or rollback key. `get` prints the value in effect (stdout) and its origin
+ * (stderr); `set` prints the key's notice. True when the command is done: every `get`, and the `set` of a retired key,
+ * which writes nothing. A rollback key's `set` returns false so the write goes ahead; any other key returns false.
+ */
+export async function handleSyncKeyConfig(engine: { getConfig(key: string): Promise<string | null> }, action: 'get' | 'set', key: string): Promise<boolean> {
+ if (!retiredSyncKey(key) && !rollbackSyncKey(key)) return false;
+ if (action === 'set') {
+ const notice = syncKeySetNotice(key)!;
+ for (const line of notice.lines) console.error(line);
+ return !notice.writes;
+ }
+ const effective = effectiveSyncKey(key, await engine.getConfig(key))!;
+ console.log(effective.value);
+ console.error(`[config] source: ${effective.origin}`);
+ return true;
+}
diff --git a/test/sync-config-keys-6712.test.ts b/test/sync-config-keys-6712.test.ts
index 309e592444..e40c314d77 100644
--- a/test/sync-config-keys-6712.test.ts
+++ b/test/sync-config-keys-6712.test.ts
@@ -50,9 +50,9 @@ test('the three kinds are disjoint; tunables and rollback keys are registered, r
for (const key of SYNC_TUNABLE_KEYS) { expect(KNOWN_CONFIG_KEYS).toContain(key); expect(retired).not.toContain(key); expect(SYNC_ROLLBACK_KEYS as string[]).not.toContain(key); }
for (const key of SYNC_ROLLBACK_KEYS) { expect(KNOWN_CONFIG_KEYS).toContain(key); expect(retired).not.toContain(key); }
for (const key of retired) expect(KNOWN_CONFIG_KEYS).not.toContain(key);
- expect(RETIRED_SYNC_KEYS['sync.hold_cap'].replacement.default).toBe(String(GIT_HOLD_CAP));
- expect(RETIRED_SYNC_KEYS['sync.hold_escalate_count'].replacement.default).toBe(String(GIT_HOLD_ESCALATE_COUNT));
- expect(RETIRED_SYNC_KEYS['sync.hold_escalate_pct'].replacement.default).toBe(String(GIT_HOLD_ESCALATE_PCT));
+ expect(String(RETIRED_SYNC_KEYS['sync.hold_cap'].replacement.default)).toBe(String(GIT_HOLD_CAP));
+ expect(String(RETIRED_SYNC_KEYS['sync.hold_escalate_count'].replacement.default)).toBe(String(GIT_HOLD_ESCALATE_COUNT));
+ expect(String(RETIRED_SYNC_KEYS['sync.hold_escalate_pct'].replacement.default)).toBe(String(GIT_HOLD_ESCALATE_PCT));
for (const window of Object.values(CONFIG_ROLLBACK_WINDOWS)) {
expect(window.honored_until).toMatch(/^\d{4}-\d{2}-\d{2}$/);
expect(window.floor).toMatch(/^\d+\.\d+\.\d+\.\d+$/);
@@ -143,7 +143,9 @@ test('doctor sync_config_keys reports a stored retired key as unapplied, and is
expect(clean).toMatchObject([{ name: 'sync_config_keys', status: 'ok' }]);
await engine.setConfig('sync.hold_escalate_count', '10');
await engine.setConfig('sync.waive_batch', 'false');
- const [check] = await syncConfigKeysEntry.run(ctx);
+ const checks = await syncConfigKeysEntry.run(ctx);
+ if (!Array.isArray(checks)) throw new Error('sync_config_keys returned no checks');
+ const [check] = checks;
expect(check).toMatchObject({ name: 'sync_config_keys', status: 'warn', fix: { argv: ['gbrain', 'config', 'get', 'sync.hold_escalate_count'], actor: 'agent' } });
expect(check!.message).toContain('sync.hold_escalate_count=10 (in effect: 50; set GBRAIN_SYNC_HOLD_ESCALATE_COUNT');
expect(check!.message).toContain('sync.waive_batch=false (until at least');