Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(config): config get and show mask secrets nested in an object value, camelCase names included (#7346)
garrytan302cd78da677
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex b2e11fd8fb..9978016e99 100644--- a/scripts/module-size-limits.tsv+++ b/scripts/module-size-limits.tsv@@ -45,6 +45,6 @@ src/core/search/mode.ts 1709 ratchet +53 W3 confidence-gated reranking: rerankersrc/commands/eval-longmemeval.ts 1545 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); +1 #7619: parseArgs refuses a value on a switch (--judge=false turned the paid judge on)src/commands/doctor/checks/extraction-sync.ts 1500 ratchet +7 GBRA-130 A-1: links_extraction_lag held bucket and its retry fix (logic in core/extraction-lag.ts heldExtractionReport); +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; +20 wave 18b lane 1: links_extraction_lag names the columns its pre-migration degrade reads (#6599 strict predicate), sync_freshness separates sync outcome from freshness for a source with no successful sync (#4960; verdict text, fixes and the attempt read live in doctor/sync-outcome.ts and core/sync-attempt.ts) and exempts read-only skill-pack catalogs (#6076; core/shared-skills/adopted-packs.ts); -51 #6803 (D1): links_extraction_lag reads its counts and verdict from core/extraction-lag.ts (shared with the sync nudge); +1 #7145: content_hash_duplicates reads one group past its list to report a floor ("at least 50")src/core/search/evidence-delivery.ts 1755 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); +39 Wave B PR 2 lane 2b: planSegmentedBlock joins the windows search/segmented-evidence.ts reads around a segmented page's hits into one run-marked document (needs the private Doc/Piece/buildDoc/locateAnchor internals), planBlock's unit cut split into blockFromDoc for both, sections bounded by their run, selectionCost counts a gap between runs, and the fetch skips the whole-body fence overlay for a segmented page; +4 segmented pages read at once before planning (segmentedReads; the read is search/segmented-evidence.ts, the statements page-body/read-range.ts); +17 GBRA-156: tail trim plan flag, DeliverOptions.query, DeliveryMeta.tail_trim, the trim call and the frozen-hit score/query library fields (logic in search/evidence-tail-trim.ts; interface fields cannot move); +7 GBRA-205: EvidencePlan.titleHeader and DeliveryMeta.title_header (interface fields cannot move) and the titles option on the header loader (logic in search/evidence-date.ts; the query budget key lives in search/evidence-packing.ts); +11 #7600: assemble_evidence quotes conversation rows and capEvidenceToBudget counts the quote fence (logic in search/transcript-quote.ts); +2 GBRA-156 /ship review: the cut-path admission and title room count the quote fence; +2 GBRA-156 /ship review pass 2: capEvidenceToBudget counts the fence only for the paths that fence (quote flag; recall counts the text as returned)-src/commands/config.ts 1524 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 wave 18b lane 5 (#5012 item 6): search.contextual_retrieval prints the existing-pages hint after the write (text lives in commands/config/contextual-mode-hint.ts); +1 #6712 PR 2: retired/rollback sync key dispatch line (logic in core/sync-config-keys.ts handleSyncKeyConfig); +1 #6865: sync.slug_conflicts.auto_remove boolean validation at set time (refusal text in repair/slug-autoheal.ts); +1 #6948: sync.origin_twins.auto_resolve boolean validation at set time (refusal text in repair/origin-twins-heal.ts); +2 #6795: config set chat_model/expansion_model help line and the model-pin import (shadow report and file-pin unset live in commands/config/model-pin-shadow.ts); +1 #6712 PR 4b: sync.admission set-time hook (value logic in commands/config/sync-admission-value.ts); +4 #7130: set-time refusal hook for sync.max_deletes / sync.max_delete_ratio (and .source.<id>) / purge.retention_hours (check lives in core/sync-reconcile.ts deleteSafetyConfigRefusal); +1 GBRA-150: sync.metafile_pages set-time route (body in config/sync-metafile-pages-value.ts); re-summed at the v0.60.330.0 merge (1520 measured); +2 #7242 minions.terminal_hook file-plane key and its set branch (logic in minions/terminal-hook.ts); +1 GBRA-161: generations.* set-time route (refusal in commands/config/generations-values.ts); +1 GBRA-207 #7630: sync.repo_path set-time refusal hook (refusal in core/sync-config-keys.ts syncRepoPathRefusal)+src/commands/config.ts 1532 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 wave 18b lane 5 (#5012 item 6): search.contextual_retrieval prints the existing-pages hint after the write (text lives in commands/config/contextual-mode-hint.ts); +1 #6712 PR 2: retired/rollback sync key dispatch line (logic in core/sync-config-keys.ts handleSyncKeyConfig); +1 #6865: sync.slug_conflicts.auto_remove boolean validation at set time (refusal text in repair/slug-autoheal.ts); +1 #6948: sync.origin_twins.auto_resolve boolean validation at set time (refusal text in repair/origin-twins-heal.ts); +2 #6795: config set chat_model/expansion_model help line and the model-pin import (shadow report and file-pin unset live in commands/config/model-pin-shadow.ts); +1 #6712 PR 4b: sync.admission set-time hook (value logic in commands/config/sync-admission-value.ts); +4 #7130: set-time refusal hook for sync.max_deletes / sync.max_delete_ratio (and .source.<id>) / purge.retention_hours (check lives in core/sync-reconcile.ts deleteSafetyConfigRefusal); +1 GBRA-150: sync.metafile_pages set-time route (body in config/sync-metafile-pages-value.ts); re-summed at the v0.60.330.0 merge (1520 measured); +2 #7242 minions.terminal_hook file-plane key and its set branch (logic in minions/terminal-hook.ts); +1 GBRA-161: generations.* set-time route (refusal in commands/config/generations-values.ts); +1 GBRA-207 #7630: sync.repo_path set-time refusal hook (refusal in core/sync-config-keys.ts syncRepoPathRefusal); +8 #7346: config get/show mask secrets nested in object values (redactNestedConfig beside redactConfigValue, which test/config.test.ts pins to this file)src/commands/mcp-expose.ts 1519 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); +7 GBRA-199: --surface help lines, surfaceChosen option field and the advertise pass-through (registrationAdvertise in core/mcp-registration.ts)src/core/behavior-change-notice.ts 1575 ratchet the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +2 GBRA-205 saved_facts_stems row and its comment (re-summed at the #7901 0.60.492.0 merge: 1541 + 2); +2 GBRA-205 search.query_facts_block default-on row and its approval comment (re-summed at the #7610 0.60.490.0 merge: 1539 + 2); +2 the #7900 content checkpoint host-move row (since TBD until the merge slot), +2 the #7897 private-hold sweep row (since TBD until the merge slot), +2 the #7880 ingest_capture and company-brain private-hold row (since TBD until the merge slot), +5 the frozen-source wave comment and four rows (#7868, #7850, #7869/#7870, #7871), +2 the #7848 visibility_noncanonical hold row (since TBD until the merge slot), +2 the #7846 extract_atoms session-source row (re-summed at the 0.60.481.0 merge: master 1524 + 2), +2 the #7805 synthesize session-source and #7841 visibility_not_applied rows (re-summed at the 0.60.480.0 merge: master 1522 + 2), +2 strict door planned-state row (#7705, re-summed at the 0.60.470.0 merge: master 1514 + 2), +2 Bun floor 1.4.4 row (#7644), the GBRA-95 RLS backfill row (+2), +3 rows for #7596 pass_interrupted, #7599 read-only serve and the --access=read-only ceiling, +1 G5 lane C trust_release row, +1 #7619 cli_flag_equals, +3 GBRA-207 #7630 relative-anchor and stalled-write rows, +2 the #7632 function search_path disclosure row and +2 the #7679 orphaned worktree refresh row (re-summed at the 0.60.471.0 merge: master 1516 + 2), +2 the #7814 retired v0.13.1 grandfather row, +2 the #7618 conversion withhold/progress/push row (master 1520 + 2); the behavior-change table split (#7607) retires this row; +4 GBRA-188 #7489: the wave comment and three rows (brain-first instructions, starter surface default, per-turn rule); +1 GBRA-188 plugin_turn_hook_gbra188 row; +1 GBRA-242 provider_key_rules_7959 row (#7959), +2 the GBRA-199 registration_lists_verbs row (since TBD until the merge slot); +2 GBRA-133 #7652: the #7611 pass_abandoned reader row and the lean read-only serve socket row (re-summed at the 0.60.503.0 merge: master 1555 + 2); +1 GBRA-243: the per-turn hook disclosure row (rows are data and cannot move); +4 GBRA-156 #7598 harness wave comment and rows (remote page cap, sources_not_readable refusal, sources add next step); +4 GBRA-156 #7601 search_quotes_transcript_rows comment and row; +1 GBRA-175 #7475 autopilot_restarts_serve_7475 row (re-summed at the #8012 merge: 1566 + 1); +3 #7997/#8014/#8015 rows (redaction markers, company db_only keep, ignored supabase_only scope); +1 GBRA-250 #8071 rows_behind_checkpoint_8071 row (since TBD until the merge slot); +1 GBRA-250 #8073 derived_write_through_commits_8073 row (since TBD until the merge slot); +2 GBRA-250 #8072 rows (oversize hold left unread, refresh sync budget; since TBD until the merge slot); +1 GBRA-156 #7593: private_pages_granted_sources row (re-summed at the 0.60.527.0 merge: 1574 + 1)diff --git a/src/commands/config.ts b/src/commands/config.tsindex ee213866a0..e427c5e9d7 100644--- a/src/commands/config.ts+++ b/src/commands/config.ts@@ -30,8 +30,8 @@ import {// two surfaces can't drift again. Match on word-segments to avoid// false-positives (e.g. `monkey` doesn't match `key`).export function isSensitiveConfigKey(key: string): boolean {- const lower = key.toLowerCase();- // Word-boundary matches: foo_key, foo.key, key_foo, key, api_key, ...+ const lower = key.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase();+ // Word-boundary matches: foo_key, foo.key, key_foo, key, api_key, secretAccessKey, ...return /(^|[._-])(key|secret|token|password|pwd|passwd|auth)([._-]|$)/.test(lower);}@@ -281,6 +281,14 @@ export function redactConfigValue(key: string, value: string): string {return value;}+/** An object config value with every sensitive field masked at any depth (#7346: storage.secretAccessKey). */+function redactNestedConfig(value: unknown): unknown {+ if (Array.isArray(value)) return value.map(redactNestedConfig);+ if (value === null || typeof value !== 'object') return value;+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k,+ typeof v === 'string' ? redactConfigValue(k, v) : v !== null && v !== undefined && isSensitiveConfigKey(k) ? '***' : redactNestedConfig(v)]));+}+// #3661: the flags `config set` actually honors. Everything else that looks// like a flag is rejected before the write — see the gate in the `set` branch.const CONFIG_SET_KNOWN_FLAGS = ['--force', '--coverage-override', '--yes'];@@ -675,7 +683,7 @@ async function showConfig(engine: BrainEngine): Promise<void> {const display = typeof v === 'string'? redactConfigValue(k, v): v !== null && typeof v === 'object'- ? (isSensitiveConfigKey(k) ? '***' : JSON.stringify(v))+ ? (isSensitiveConfigKey(k) ? '***' : JSON.stringify(redactNestedConfig(v))): v;console.log(` ${k}: ${display}`);}@@ -947,7 +955,7 @@ export async function runConfig(engine: BrainEngine, args: string[]) {if (val !== null && val !== undefined) {// #3943: redact by default like `show`/`set` — `get` output lands in// agent transcripts and shell history; scripts opt out with the flag.- const out = typeof val === 'string' ? val : JSON.stringify(val);+ const out = typeof val === 'string' ? val : JSON.stringify(rawFlag ? val : redactNestedConfig(val));console.log(rawFlag ? out : redactConfigValue(key, out));if (dbAuthoritative) {console.error(`[config] source: ${dbVal !== null && dbVal !== undefined ? 'db plane (authoritative for this key)' : 'file mirror (no DB row)'}${await writebackLanesNote(engine, key)}`);diff --git a/test/config-get-plane.test.ts b/test/config-get-plane.test.tsindex dc1c78a014..ee17b5eb49 100644--- a/test/config-get-plane.test.ts+++ b/test/config-get-plane.test.ts@@ -182,3 +182,50 @@ describe('#5358 — config get resolves publish-gate keys the way the runtime gaexpect(logs).toEqual([String(runtime)]);});});++describe('#7346 — config get and show redact secrets nested in an object value', () => {+ // Value: protects=object-storage credentials never reach scrollback or agent transcripts through config get/show;+ // fails_when=a nested camelCase secret (storage.secretAccessKey) prints in the clear; why_new=the #3943 pins cover+ // only flat snake_case keys; seam=runConfig with a file-plane storage object; no_claim=redaction of --raw output.+ const SECRET = 'minio-test7346-secret-value';+ const KEY_ID = 'minio-test7346-key-id';+ const storage = { backend: 's3', bucket: 'brain-files', endpoint: 'http://127.0.0.1:9000', accessKeyId: KEY_ID, secretAccessKey: SECRET };++ async function runShow(): Promise<string> {+ const logs: string[] = [];+ const logSpy = spyOn(console, 'log').mockImplementation((...a: unknown[]) => { logs.push(a.join(' ')); });+ const errSpy = spyOn(console, 'error').mockImplementation(() => {});+ try {+ await withEnv({ GBRAIN_HOME: home }, () => runConfig(stubEngine({}), ['show']));+ } finally {+ logSpy.mockRestore();+ errSpy.mockRestore();+ }+ return logs.join('\n');+ }++ test('get storage masks the nested credentials and keeps the other fields', async () => {+ writeFileConfig({ engine: 'pglite', storage });+ const { logs, errs, exit } = await runGet({}, 'storage');+ expect(exit).toBeNull();+ const out = logs.join('\n');+ expect(out).not.toContain(SECRET);+ expect(out).not.toContain(KEY_ID);+ expect(errs.join('\n')).not.toContain(SECRET);+ expect(JSON.parse(out)).toEqual({ ...storage, accessKeyId: '***', secretAccessKey: '***' });+ });++ test('get storage.secretAccessKey prints ***; --raw still prints the value', async () => {+ writeFileConfig({ engine: 'pglite', storage });+ expect((await runGet({}, 'storage.secretAccessKey')).logs).toEqual(['***']);+ expect((await runGet({}, 'storage.secretAccessKey', { after: ['--raw'] })).logs).toEqual([SECRET]);+ });++ test('show masks the nested credentials', async () => {+ writeFileConfig({ engine: 'pglite', storage });+ const out = await runShow();+ expect(out).toContain('brain-files');+ expect(out).not.toContain(SECRET);+ expect(out).not.toContain(KEY_ID);+ });+});