Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

spawn seam batch 1 (#4992): hook.ts, brain-repo-durability.ts, hardened-git.ts and claude-cli-language-model.ts launch through core/spawn.ts; the hook's git probes use gitChildEnv()

garrytan797f6af8318a
diff --git a/scripts/check-windows-hide.ts b/scripts/check-windows-hide.ts
index 0c25b1676c..b65c5285b9 100644
--- a/scripts/check-windows-hide.ts
+++ b/scripts/check-windows-hide.ts
@@ -54,7 +54,6 @@ const NOT_YET_MIGRATED: Record<string, string> = {
'src/commands/eval-run-all.ts': 'not yet migrated',
'src/commands/frontmatter-install-hook.ts': 'not yet migrated',
'src/commands/frontmatter.ts': 'not yet migrated',
- 'src/commands/hook.ts': 'wave 13 (GBRA-57) file: migrates with that wave',
'src/commands/import.ts': 'not yet migrated',
'src/commands/init.ts': 'not yet migrated',
'src/commands/integrations.ts': 'not yet migrated',
@@ -73,12 +72,10 @@ const NOT_YET_MIGRATED: Record<string, string> = {
'src/commands/takes.ts': 'not yet migrated',
'src/commands/upgrade.ts': 'not yet migrated',
'src/core/agent-install/setup.ts': 'not yet migrated',
- 'src/core/ai/providers/claude-cli-language-model.ts': 'wave 13 (GBRA-57) file: migrates with that wave',
'src/core/ai/recipes/azure-openai.ts': 'not yet migrated',
'src/core/binary-self-update.ts': 'not yet migrated',
'src/core/bootstrap/status.ts': 'not yet migrated',
'src/core/bootstrap/verify.ts': 'not yet migrated',
- 'src/core/brain-repo-durability.ts': 'wave 13 (GBRA-57) file: migrates with that wave',
'src/core/bun-floor.ts': 'not yet migrated',
'src/core/calibration/gstack-coupling.ts': 'not yet migrated',
'src/core/calibration/undo-wave.ts': 'not yet migrated',
@@ -102,7 +99,6 @@ const NOT_YET_MIGRATED: Record<string, string> = {
'src/core/git-remote.ts': 'not yet migrated',
'src/core/git-visible-files.ts': 'not yet migrated',
'src/core/google/access.ts': 'not yet migrated',
- 'src/core/hardened-git.ts': 'wave 13 (GBRA-57) file: migrates with that wave',
'src/core/harness/install.ts': 'not yet migrated',
'src/core/persistence/engine-graduation.ts': 'not yet migrated',
'src/core/persistence/sync-blobs.ts': 'not yet migrated',
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index 93157d474b..e7a0acf781 100644
--- a/scripts/module-size-limits.tsv
+++ b/scripts/module-size-limits.tsv
@@ -34,7 +34,7 @@ src/commands/sources.ts 2059 ratchet +5 PR #5955 / fix wave 14 P2.7: sources set
src/core/link-extraction.ts 2379 ratchet grown v0.46.26.0 megawave: link-aware timeline split + delimiter-outside-links (#3957 #4062 #3737); +37 wave-k #3908 reimpl: isCrossSourceLinksEnabled config ladder; +10 wave #4277: parseTimelineEntries skips generated backlink receipts; +17 #4855: latin-fold in normalizeBasename + dir-hint step tries both slug grammars; +17: #4855 Latin stroke-letter fold; +5: #4873 ./-relative markdown links kept as live references; +34 wave review: `../y.md` sibling links resolve on the DB path + folded bare-wikilink grammar (#4873 class); +62 #4977: role-prior suppression in machine-list sections (rolePriorSuppressedRanges, EntityRef.index); +3 composed with #4985 (variation-selector strip) in the same wave; +4 #4995: markdown-link anchor strip + lowercase-candidate rationale comments; +6 pre-landing review: #4977 suppression on code-stripped content + truthful watermark/section-list comments; T2: source-qualified inference and atomic origin-scoped derived links; canonical attendance evidence, source-qualified orientation, strict attendee resolution, and relocated filesystem link scanner (command export preserved); +4: pack-owned fallback and ambiguous attendee guards Display-label attendance exclusion, indexed evidence membership, and bounded strict resolver caching; attendance-boundary review.; complete attendance resolution and fence-safe evidence traversal; frontmatter discovery, canonical basename admission and code-aware attendance comment masking; exclude inline HTML comment spans from admitted attendance ranges; +17 write-path wave: same-name rule for entity fuzzy matches + rename-alias fallback in makeResolver; +1 #5567: materialized marker ends bullet detail; +30 #5749: unique global-basename step before fuzzy and live keyword resolution (ResolveOptions, watermark note); #5765: bold **Attendees:** label accepted + LINK_EXTRACTOR_VERSION_TS bump note; +10 eval-wave N9-2/N9-3/N12-7: pack frontmatter mappings inherit FRONTMATTER_LINK_MAP direction, page-type-bound pack attended follows canonical attendance, LINK_EXTRACTOR_VERSION_TS bump note; +1 #5623: normalizeBasename collapses hyphen runs like slugifySegment (extractor watermark note); +11 #5562: parseTimelineEntries accepts dated ### headings (FS-extractor parity); +3 eval-wave N12-6: Participants accepted as attendance evidence + LINK_EXTRACTOR_VERSION_TS bump note; +22 P5 wanted pages: AuthoredRef on body link candidates; -33 lowered: P5 moved machine-section ranges to core/machine-sections.ts and stated relation types to core/line-grammar.ts; +7 P5: ExtractPageLinksOptions interface + wikilinkAuthoredRef helper (keeps extractPageLinks under the function-size limit); +32 P5: per-edge verb attachment (attachedVerb, VERB_RULES) + joined-as works_at + extractor watermark note; P5 x temporal-edges merge: verb attachment reads the verb at the link's own position in the window (excerptAnchor) and the within-page dedup (now dedupeCandidates) drops a mention of a target the page also links with a typed edge; links joined only by commas/conjunctions share the verb before the first (coordinated); board roles (BOARD_RE, BOARD_AFTER_RE) resolve to invested_in for an investor page and advises otherwise, never works_at; +1 fix wave 11 #6191: imports targetTakesVerb (role-verb target guard lives in link-target-roles.ts); v0.60.105.0 merge: #5984 Phase 5 link preparation (+6) re-summed over wave 11 at 2211; +109 Q2 Track C: stable verb-rule ids, traceLinkType/explainLinkType (reasons for every typing decision), per-occurrence typer hoisted out of extractPageLinks (makeTypeFor); unit logic lives in core/link-typing-units.ts; +25 Q2 Track C: typing-unit verb rules and vetoes in attachedVerb/traceLinkType, validity stints in explainLinkType; +4 U3: board-seat rule split out of INVESTED_RE (same verb and precedence) and investor-prior/link offsets passed to unit vetoes; +11 U2: locateLink shared by attachedVerb and the U2 post-pass in traceLinkType; -11 lowered: Q2 verdict reverted U2 (locateLink and the post-pass); +21 fix wave 13 P4.10 #6266: resolveSameDirSlug + exported resolveMarkdownLinkSlug, shared with the link validator
src/core/embedding-migration.ts 1587 ratchet new row: crossed 1500 in v0.46.25.0 fix waves (#4305 #4306 chunk-model truth helpers); retired provider integration removed; safety wave: canonical projection readiness and fact-aware completion; file configuration publication retains lease-row locks; +8 transactional retained-vector rebuildability checks before destructive migration boundaries; archived eligibility: source-locked reconciliation and live/current smoke revalidation; +2 #5680: authorization_generation field and its carry-forward on same-target re-apply (settle idempotency); +10 #5226: plan carries chunks_to_restamp beside chunks_to_embed; +9 #5088: schema transition defers HNSW builds into the marker (deferred_ann_indexes), carry-forward on re-apply, verify blocks on pending/INVALID ANN indexes (build phase in embedding-ann-build.ts); +10 #5088: dim-pinned tables (query_cache, facts, and any later entry of TEXT_EMBEDDING_DIM_PINNED_TABLES) defer their HNSW through the same worklist (DEFERRED_ANN_TABLES, recordDeferredAnnIndexes); +25 wave 8 lane D1 #5885: takes in the dim-pinned column list, plan (takes_to_embed), status (takes_pending) and completion verify; +17 #5334: smoke check samples one representative chunk per distinct page (bounded index-ordered batch walk, longest chunk re-read under the page lock, title-prefixed bounded query); +1 #5334: the smoke-query length limits are shared with the worst-case budget
src/core/github-source.ts 1530 ratchet new row: crossed the 1500 unlisted cap in v0.46.23.0 review fix wave (scope-state gating, client hardening, symlink containment); merged reliability/shared-skills source integration; managed sweep lease wrapper; fix wave 3 lane A: config parser peeled to github-source-config.ts (-47), +account pin wiring and pinned-installation refresh
-src/commands/hook.ts 1931 ratchet cathedral-5 heartbeat extraction offsets part of the BrainBench-seam growth; grown v0.46.26.0 megawave hooks-ipc (#4245); +108 monthly backup check: banner + gated session-start note + detached spawn (backup/status-file readers); +28 ship-review egress hardening: per-harness capture dispatch (capture-spec), memorable gate + receipt + relay block, fail-closed unscanned/newest-guess skips; +79 ambient-writeback WP4: hookStop bank step (gate -> bankWritebackTurn -> IPC flush; gate/bank logic live in core/facts + corpus-segments); +41 adversarial fix wave: wide-tail retry when the 128KB window misses the user turn, by-design heartbeat outcome classes, source-in-name banking; +11 #5413 session-end skips claude-cli self-transcripts; +11 #5701: hook lanes pass allowOversize so a long session reaches the bounded tail read; +1 #5371: the stop-hook dirty probe ignores physical-root ownership metadata (root-metadata.ts, engine-free); 2 core memory: user-prompt context-pressure notice wiring (logic in core/context/pressure.ts; session-start composition in core/context/session-start-output.ts); +3 fix wave 11 W2.1 #6091: PreCompact/SessionEnd capture-time consent record calls (logic in core/context/capture-consent.ts); +5 fix wave 11 W2.9 #6083: the three detached-push call sites skip a managed canonical worktree (push_managed_coordinator) + import; +2 fix wave 11 integration: W1 router help guard import beside the W2 managed-root import; +2 fix wave 13 P4.9 #6399: a header-only Codex rollout ends empty_session, not parser_drift; +3 W14 P4.16 (#5799): banner and SessionStart note read livePushStatuses (predicate in core/workspace-push.ts)
+src/commands/hook.ts 1932 ratchet cathedral-5 heartbeat extraction offsets part of the BrainBench-seam growth; grown v0.46.26.0 megawave hooks-ipc (#4245); +108 monthly backup check: banner + gated session-start note + detached spawn (backup/status-file readers); +28 ship-review egress hardening: per-harness capture dispatch (capture-spec), memorable gate + receipt + relay block, fail-closed unscanned/newest-guess skips; +79 ambient-writeback WP4: hookStop bank step (gate -> bankWritebackTurn -> IPC flush; gate/bank logic live in core/facts + corpus-segments); +41 adversarial fix wave: wide-tail retry when the 128KB window misses the user turn, by-design heartbeat outcome classes, source-in-name banking; +11 #5413 session-end skips claude-cli self-transcripts; +11 #5701: hook lanes pass allowOversize so a long session reaches the bounded tail read; +1 #5371: the stop-hook dirty probe ignores physical-root ownership metadata (root-metadata.ts, engine-free); 2 core memory: user-prompt context-pressure notice wiring (logic in core/context/pressure.ts; session-start composition in core/context/session-start-output.ts); +3 fix wave 11 W2.1 #6091: PreCompact/SessionEnd capture-time consent record calls (logic in core/context/capture-consent.ts); +5 fix wave 11 W2.9 #6083: the three detached-push call sites skip a managed canonical worktree (push_managed_coordinator) + import; +2 fix wave 11 integration: W1 router help guard import beside the W2 managed-root import; +2 fix wave 13 P4.9 #6399: a header-only Codex rollout ends empty_session, not parser_drift; +3 W14 P4.16 (#5799): banner and SessionStart note read livePushStatuses (predicate in core/workspace-push.ts); +1 W15 P5.7 (#4992): gitChildEnv import for the hook git probes (launches moved onto core/spawn.ts)
src/core/chunkers/code.ts 1602 ratchet new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave (decorated-python defs #3821, version-gate + timeout chunker fixes); grown wave-g (#4511): named defs never folded into merged chunks; grown #4669: skip WASM parse for languages without TOP_LEVEL_TYPES; +6 N13-1: CodeChunkMetadata.definesFunction field + merge-guard stamp (predicate lives in def-types.ts); +10 Lua grammar swap: GRAMMAR_REVISIONS + chunkerStamp() (per-language re-chunk gate); +4: CodeChunkOptions.timeoutMs (per-call parse cap; markdown fences parse under a short cap) and the "Parsing failed" → ChunkerTimeoutError mapping in parseWithTimeout
src/core/config.ts 1950 ratchet +1 budgeted delivery PR 1: the search.auto_packing KNOWN_CONFIG_KEYS row (values validated in search/evidence-packing.ts); +1 #6278: persistence.sync_preparation_ms/maintenance_preparation_ms/preparation_ceiling_ms/max_preparation_attempts/preparation_deadlines key row (logic in persistence/preparation-budget.ts, switches.ts); +22 fix wave 11 W6.2/W6.3 (#5989, #6132): search.cjk_keyword_deadline_ms and search.hnsw_iterative_scan type fields, KNOWN_CONFIG_KEYS rows and the mergeSearchScanKnobs helper that keeps loadConfigWithEngine under its function-size baseline (logic in search/cjk-keyword-deadline.ts, search/hnsw-iterative-scan.ts); +8 #5988: sync.holds/hold_cap/hold_escalate_count/hold_escalate_pct/parser_regression key registration (read by persistence/sync-holds.ts); +3 agent operator wave A4: GBrainConfig.consent file-plane slot + 2 consent.preapprove.* key rows (logic in core/consent.ts); +1 System One v1: decide.* key prefix (validated by ai/decide/config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave (spend-controls hint #3703, config-set validation); +3 wave G #3974: sync.include_working_tree key; grown wave-g (#4540 #4494 #4415): extractor caps + intent-pattern config keys; +1 chat-connectors: connectors. config prefix; wave-k: config-table snapshot serving the DB-plane reads (#3980 + #2119 merge); +8: loadConfig hook for ~/.gbrain/.env, loader lives in gbrain-env-file.ts (#3893); +17: litellm/together key-fold slots (#3904 reimpl: two GBrainConfig fields + KNOWN_CONFIG_KEYS rows); +1: link_resolution.cross_source key (#3908); +4 v0.47 gmail-loops: loops.extraction_enabled key; +1: pricing.overrides key (#4633 adoption); +7 #4667 adoption: sync.exclude key registration; +4: eval fix wave keys (quote_verify + 3 rescue knobs); +memorable file-plane key registration (integrations.memorable.enabled + consent-event doc); +33 ambient-writeback: memory.* + brain.audience key registration + GBrainConfig.memory mirror slot (resolvers live in facts/writeback-config.ts); +38 2026-08 wave: retrieval_reflex_volunteer key + env mapping (volunteer-arm kill switch) + E5a registration of the 10 adaptive_return*/autocut*/crag_* search (incl. adversarial batch isEnvDisabled dedup); ambient-writeback (master merge): facts/writeback-config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave; prior growth: sync/intent/chat-connectors/litellm/pricing/loops key folds; +34: #4702 content_sanity.disabled_patterns (type + DB-plane parse/merge + key registration); composition true-up (fix-wave multi-train) | merged v0.48.1.0: master #4788 writeback keys + wave #4702/#4748 keys; master: | merged v0.48.1.0 true-up; ranker wave v0.48.4.0: +4 KNOWN_CONFIG_KEYS rows (+8); +5 #4895: CWD_DOTENV_FILES gains the per-NODE_ENV .local variants Bun auto-loads; +2 #5003: sync.include_hidden key registration; +57 #4605: search.* registry reconciled to the keys mode.ts reads (+20 knob rows, +4 direct-read singletons) + GBrainConfig.search slot + adaptive_return* DB-plane merge; +2 pre-landing review: fts.reindex_in_progress key registration (#4795 marker escape hatch); +4 #4987: auto_timeline key registration (the documented off switch was rejected as unknown); lowered to 1793: GHSA wave v0.50.5.0 moved CWD_DOTENV_FILES + dotenvValuesForKey into core/env-trust.ts (-49, re-exported); re-summed to the merged line count after merging master v0.50.2.0 (#5122) with the v0.50.5.0 security wave; fix wave 3 x fix wave 2 (v0.60.5.0) composition: +1 at the merge; evidence delivery: 5 registered config keys + comment (+7); +2 #5691: embedding_query_prefix key registration; evidence delivery auto v2: search.return_budget_conversation key row (+1); +1 #5836: facts.entity_inference key row; +6 #5824: search.vector_legacy_guard key row + GBrainConfig.search slot + DB-plane merge; +3 wave 8 lane D1 #5885: takes.auto_embed key row; +3 #5232: GBrainConfig.persistence.write_wait_ms file-plane slot + key row (resolver in persistence/write-wait.ts); +2 F4b: planner.* and import.analyze_every_pages keys; +3 cat40 cost wave C1 (garrytan/gbrain-evals#57 follow-ups): mcp.result_rows GBrainConfig slot + key row (resolver in mcp/result-rows.ts); v0.60.46.0 merge: both waves' +3 compose (1824 + 3 = 1827 measured); +4 #5984: sync.bulk, sync.bulk_size, sync.bulk_max_txn_ms known keys; v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (1838 measured); +3 retrieval feedback: the feedback keys in KNOWN_CONFIG_KEYS; 2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); P3 x engine graduation composition: both deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); P3 x foundations-2 composition: deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); +1 GBRA-49: graph.* key prefix (graph.edge_validity, read by link-validity.ts); P3 x P1 (v0.60.57.0) composition: deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); +1 GBRA-49: graph.* key prefix (graph.edge_validity, read by link-validity.ts); +3 P7 search.relational_planner / search.relational_orient_onehop key registration; +2 P7 search.relational_chain_slots key registration; P3 x P7 (v0.60.60.0) composition: deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); +1 GBRA-49: graph.* key prefix (graph.edge_validity, read by link-validity.ts); +3 P7 search.relational_planner / search.relational_orient_onehop key registration; +2 P7 search.relational_chain_slots key registration; +3 agent operator follow-up Item 2: mcp.allow_session_widen (GBrainConfig.mcp slot + known key); P3 x aow-followup composition: deltas re-summed at the merge; 2 Lane D: facts.drain_budget_usd, facts.drain_daily_budget_usd, facts.drain_max_jobs key registration (validated in core/facts/drain.ts); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts); +1 GBRA-49: graph.* key prefix (graph.edge_validity, read by link-validity.ts); +3 P7 search.relational_planner / search.relational_orient_onehop key registration; +2 P7 search.relational_chain_slots key registration; +3 agent operator follow-up Item 2: mcp.allow_session_widen (GBrainConfig.mcp slot + known key); +2 entity mention index: mentions.auto_link, mentions.entity_types, mentions.ignore key rows (resolver in core/mentions/policy.ts); cat40 entity wave merge with v0.60.61.0 (1853 measured); P3 x cat40-entity-wave composition: deltas re-summed at the merge; +6 fix wave lane B3: chat_fallback_on_refusal (GBrainConfig slot, GBRAIN_CHAT_FALLBACK_ON_REFUSAL env fold, known key); +2 W-B4: shared_skills.inventory.* known keys (logic in shared-skills/inventory-limits.ts); +2 fix wave 9 lane B #4921: ai.chat.per_turn_timeout_ms known key; +1 wave 9 lane W #5363: cycle.consolidate.cluster_threshold key row; +1 #5984 lanes: sync.lanes key registration; +2 P8: dream.quote_verify and think.quote_verify known keys; +2 P8: GBrainConfig.mcp.advertised_surface interface slot (resolver in mcp/surface.ts); +2 fix wave 10 lane L1 #4907: cycle.synthesize_concepts.budget_usd registered (validation in cycle/phase-config-values.ts); +2 #5958: dream.propose_takes.call_timeout_ms registered; 3 core memory: memory.core.* and memory.pressure.* known keys; +15 P5: wanted_pages.enabled/remote, line_grammar.enabled/allow_undeclared_types/effective_ranges and put_page.similar_pages key rows (logic in wanted-links.ts, line-grammar.ts, similar-pages.ts); +1 P2 extraction.date_grounding / facts.attribution keys; +1 #6188: fences.normalize registered in KNOWN_CONFIG_KEYS; +2 #6188: fences.repair.max_usd_per_page/per_day key rows; +1 fix wave 12 W2.3 #6231: facts.page_write_notability_filter key row (resolver in facts/notability-filter.ts); +1 #6317: persistence.single_consumer key row (logic in persistence/switches.ts, consumer-election.ts); +2 newer mentions on context_pack cards: mentions.newer_on_cards key row (logic in mentions/newer-mentions.ts); master v0.60.136.0 merge into #5575 memory trust (both sides kept); +1 #5329 (W14 PR3): chronicle.max_events_per_page registered in KNOWN_CONFIG_KEYS (validation in chronicle/config.ts); +2 C1/C2 memory proof wave: search.evidence_date_header + facts.candidate_fusion registry rows; +1 facts.supersession_thresholds registry row (per-model supersession calibration); +1 C4: models.standing_questions key row; +1 search.entity_anchoring key registration (default off; search/entity-anchor.ts); +1 search.query_facts_arm key registration (default off; search/facts-arm.ts); re-summed at the master 6ccf30c3e merge (1871 integration + 1868 master - 1865 base); +1 search.temporal_fact_reserve key registration (default off; search/facts-arm.ts); +1 fix wave 13 PR2: persistence.publication_ceiling_ms (P2.1/P2.3); v0.60.165.0 merge: W14 PR4 +7 and master +2 compose (1947 measured); +1 memory proof wave 2 W1: the recall.question_admission KNOWN_CONFIG_KEYS row (values validated in facts/question-recall.ts); +2 Cat 40 Hard fix wave (#6271) on top: mentions.alias_deny/multiword_aliases/sibling_merge and search.alias_fanout_max/demote_generated KNOWN_CONFIG_KEYS rows (1950 measured)
src/core/bootstrap/harness.ts 2610 ratchet +29 live-PGLite-serve lane: LIVE_SERVE refusal ahead of source resolution + unpinned --token hooks (CI e2e fix); +46 wave review: resolveHookSource dep (serve-parity resolver + federated grant), --source shape validation, loud SOURCE_UNRESOLVED instead of a silent 'default'; +10: #4574 parseCodexBlockBearer http_headers shape + legacy bearer_token fallback; +4 at megawave/wave-k merge; +codex hooks lane: step-7 codex hooks.json + config.toml trust pair, removeHarness arm; +234 ambient-writeback WP3: kind:'instructions' targets (plan/apply/converge-off/remove/status probes, OV-A4 override pre-check) — splice/render mechanics live in instructions-block.ts; +59 adversarial fix wave: registrar-mode block suppression, converge-failure receipt tracking, MCP-confirmed guard before block install; +26 round-3 fixes: codex-lane MCP-confirmed guard + smoke-rollback block strip; master: | merged v0.48.1.0 true-up; +41 #4897 resolveImplicitSource dep + defaultResolveImplicitSource: hooks/token/receipt bind to the serve's implicit default source when --source is omitted; +23 #4586 statusHarness live claude-code mcp verdict (URL mismatch or same-scope non-HTTP registration reads failed, receipt untouched); shared-skills integration on company-ingestion base; +18 #5671: logAmbientPostureNotes helper (registrar note moved out of applyHarness + pre-consent warning when an explicit private facts default meets the HTTP harness; text shared with doctor in facts/writeback-config.ts); +24 #5893: rotation grant carry wiring and its rotationCarry/withheldOperationsNote helpers (carry rules live in token-mint.ts carryLegacyGrant); +6 #5878: --refresh-skills flag and status epoch line (refresh logic lives in harness-skills.ts); +7 #4618 seat: HarnessFlags.seat field, --seat/--no-seat parse via hooks.ts parseSeatFlags, GBRAIN_SEAT in the hook env; -119 #6082: plugin-lane detectors moved to plugin-lanes.ts (re-exported); +18 #6092/#6171: hook ownership identity on write/remove/converge, permission ownership carry, --remove --dry-run and the --status hook census (logic in hooks.ts + harness-hooks.ts)
diff --git a/scripts/serial-files.tsv b/scripts/serial-files.tsv
index 0f61b7bd2e..ec56d0c3a5 100644
--- a/scripts/serial-files.tsv
+++ b/scripts/serial-files.tsv
@@ -389,3 +389,4 @@ test/write-path-zero-llm.serial.test.ts R1 R1: mutates process.env (ANTHROPIC_AP
test/writeback-nudge.serial.test.ts global-state global-state: patches process stdout/stderr/console
test/writeback-review-fixes.serial.test.ts global-state global-state: process-wide test seams __resetCheckpointHarvestForTests; patches process stdout/stderr/console
test/hook-push-banner-superseded.serial.test.ts R1 R1: mutates process.env (GBRAIN_HOME, GBRAIN_BACKUP_CHECK)
+test/spawn-seam-batch1-4992.serial.test.ts R1 R1: mutates process.env (GBRAIN_HOME, GIT_DIR) and spies on node:child_process
diff --git a/src/commands/hook.ts b/src/commands/hook.ts
index f3b9adabaa..943d69c2fc 100644
--- a/src/commands/hook.ts
+++ b/src/commands/hook.ts
@@ -45,7 +45,8 @@ import {
writeFileSync,
} from 'node:fs';
import { isAbsolute, join } from 'node:path';
-import { execFile, spawn } from 'node:child_process';
+import { execFile, spawn } from '../core/spawn.ts';
+import { gitChildEnv } from '../core/git-env.ts';
import { ensureGbrainHome, resolveGbrainHome } from '../core/gbrain-home.ts';
import { loadConfig, type GBrainConfig } from '../core/config.ts';
import {
@@ -723,7 +724,7 @@ function tryExecAsync(bin: string, args: string[], timeoutMs = HOOK_GIT_TIMEOUT_
execFile(
bin,
args,
- { timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024, env: process.env },
+ { timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024, env: gitChildEnv() },
(err, stdout) => resolve(err ? null : stdout.toString().trim()),
);
} catch {
diff --git a/src/core/ai/providers/claude-cli-language-model.ts b/src/core/ai/providers/claude-cli-language-model.ts
index 5772edecc5..bd00b8ecd7 100644
--- a/src/core/ai/providers/claude-cli-language-model.ts
+++ b/src/core/ai/providers/claude-cli-language-model.ts
@@ -34,7 +34,7 @@
* (gateway.toolLoop primarily) use doGenerate.
*/
import { randomUUIDv7 } from 'bun';
-import { spawn, spawnSync } from 'node:child_process';
+import { spawn, spawnSync } from '../../spawn.ts';
import { mkdirSync } from 'node:fs';
import {
claudeCliConfigDir,
diff --git a/src/core/brain-repo-durability.ts b/src/core/brain-repo-durability.ts
index 21ecfd69e8..78a86bf1a8 100644
--- a/src/core/brain-repo-durability.ts
+++ b/src/core/brain-repo-durability.ts
@@ -33,7 +33,7 @@ import {
existsSync, readFileSync, writeFileSync, mkdirSync, chmodSync, rmSync, statSync, renameSync,
} from 'fs';
import { join, dirname, relative, isAbsolute } from 'path';
-import { execFileSync, execSync } from 'child_process';
+import { execFileSync, execSync } from './spawn.ts';
import { execFileBounded } from './bounded-child-exec.ts';
import {
GIT_ENV, GIT_ENV_AUTH, divergenceSafePull, detectDefaultBranch, pushProbe,
diff --git a/src/core/hardened-git.ts b/src/core/hardened-git.ts
index 1fb7848f15..dab6c30837 100644
--- a/src/core/hardened-git.ts
+++ b/src/core/hardened-git.ts
@@ -15,7 +15,7 @@
* (`assertHardenedGitArgs`, wave 12 W4.3), and `hardenedPathDirty` answers
* "is this file changed from HEAD" without `git status`.
*/
-import { spawnSync } from 'node:child_process';
+import { spawnSync } from './spawn.ts';
import { lstatSync } from 'node:fs';
import { join } from 'node:path';
diff --git a/test/spawn-seam-batch1-4992.serial.test.ts b/test/spawn-seam-batch1-4992.serial.test.ts
new file mode 100644
index 0000000000..5ffb4857fb
--- /dev/null
+++ b/test/spawn-seam-batch1-4992.serial.test.ts
@@ -0,0 +1,140 @@
+/**
+ * #4992 batch 1: the two detached `gbrain hook` launches a user feels on
+ * Windows (the Stop-hook workspace push and the session-end backup check) and
+ * the three wave-13 holdovers (`brain-repo-durability.ts`, `hardened-git.ts`,
+ * `claude-cli-language-model.ts`) go through `src/core/spawn.ts`, so every
+ * launch carries `windowsHide: true`, and their git launches build their env
+ * with `gitChildEnv()`. The spy sits on `node:child_process` itself, which the
+ * seam looks up at call time, so a launch that bypassed the seam would reach
+ * the spy without `windowsHide` and fail here.
+ */
+import { afterEach, beforeEach, describe, expect, spyOn, test } from 'bun:test';
+import * as childProcess from 'node:child_process';
+import { EventEmitter } from 'node:events';
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { tmpdir } from 'node:os';
+import { runHook } from '../src/commands/hook.ts';
+import { GIT_LOCAL_ENV_VARS } from '../src/core/git-env.ts';
+import { writeReceipt } from '../src/core/bootstrap/format.ts';
+import type { RepoReceipt } from '../src/core/bootstrap/repo.ts';
+import { hardenedGitSync } from '../src/core/hardened-git.ts';
+
+const ENV_KEYS = ['GBRAIN_HOME', 'DATABASE_URL', 'GBRAIN_DATABASE_URL', 'GBRAIN_SOURCE', 'GBRAIN_HOOKS', 'GBRAIN_STOP_PUSH',
+ 'GBRAIN_STOP_PUSH_DEBOUNCE_MIN', 'CLAUDE_CODE_REMOTE', 'CLAUDE_CODE_REMOTE_SESSION_ID', 'GH_TOKEN', 'GITHUB_TOKEN',
+ 'GBRAIN_BACKUP_CHECK', 'GBRAIN_BACKUP_CHECK_DAYS', 'GBRAIN_FORCE_BACKUP_NAG', 'GIT_DIR', 'GIT_WORK_TREE', 'GIT_CONFIG_NOSYSTEM'] as const;
+
+let tmp: string;
+let saved: Record<string, string | undefined>;
+type SpawnCall = { command: string; args: string[]; options: Record<string, unknown> };
+let spawns: SpawnCall[];
+let execFiles: SpawnCall[];
+let spawnSpy: ReturnType<typeof spyOn>;
+let execFileSpy: ReturnType<typeof spyOn>;
+const realExecFile = childProcess.execFile;
+const { execFileSync } = childProcess;
+
+function fakeChild(): childProcess.ChildProcess {
+ const child = new EventEmitter() as childProcess.ChildProcess;
+ (child as { unref: () => void }).unref = () => {};
+ return child;
+}
+
+beforeEach(() => {
+ tmp = mkdtempSync(join(tmpdir(), 'gb-spawn-seam-'));
+ saved = {};
+ for (const key of ENV_KEYS) { saved[key] = process.env[key]; delete process.env[key]; }
+ process.env.GBRAIN_HOME = tmp;
+ // A system gitconfig with url.insteadOf (a builder machine) would rewrite the origin the push gate checks.
+ process.env.GIT_CONFIG_NOSYSTEM = '1';
+ // A repository-locating variable the hook's git children must not inherit.
+ process.env.GIT_DIR = join(tmp, 'not-a-repo', '.git');
+ spawns = []; execFiles = [];
+ // Detached gbrain re-executions are recorded, never started.
+ spawnSpy = spyOn(childProcess, 'spawn').mockImplementation(((command: string, args: string[], options: Record<string, unknown>) => {
+ spawns.push({ command, args, options });
+ return fakeChild();
+ }) as typeof childProcess.spawn);
+ // The hook's git probes run for real (the test needs their answers) and are recorded on the way through.
+ execFileSpy = spyOn(childProcess, 'execFile').mockImplementation(((command: string, args: string[], options: Record<string, unknown>, callback: unknown) => {
+ execFiles.push({ command, args, options });
+ return (realExecFile as unknown as (...a: unknown[]) => childProcess.ChildProcess)(command, args, options, callback);
+ }) as typeof childProcess.execFile);
+});
+
+afterEach(() => {
+ spawnSpy.mockRestore(); execFileSpy.mockRestore();
+ for (const key of ENV_KEYS) { if (saved[key] === undefined) delete process.env[key]; else process.env[key] = saved[key]; }
+ rmSync(tmp, { recursive: true, force: true });
+});
+
+const home = () => join(tmp, '.gbrain');
+
+/** An initialized bootstrap workspace with unpushed work and a completed repo phase: the shape that spawns the push. */
+function bootstrapWorkspace(name: string): string {
+ const repo = join(tmp, name);
+ mkdirSync(repo, { recursive: true });
+ execFileSync('git', ['init', '-q'], { cwd: repo, env: { ...process.env, GIT_DIR: undefined } });
+ writeFileSync(join(repo, 'untracked-work.txt'), 'unsaved work\n');
+ writeFileSync(join(repo, 'agent.json'), JSON.stringify({ format_version: 1, initialized: true, agent_name: 'test-agent', created_by: 'test', created_at: '2026-01-01T00:00:00.000Z', source_id: 'workspace' }, null, 2) + '\n');
+ const repoUrl = 'https://github.com/alice/boot-repo';
+ execFileSync('git', ['-C', repo, 'remote', 'add', 'origin', repoUrl], { env: { ...process.env, GIT_DIR: undefined } });
+ const toplevel = execFileSync('git', ['-C', repo, 'rev-parse', '--show-toplevel'], { encoding: 'utf8', env: { ...process.env, GIT_DIR: undefined } }).trim();
+ mkdirSync(join(home(), 'bootstrap'), { recursive: true });
+ writeReceipt(home(), {
+ receipt_version: 1, workspace_dir: toplevel, source_id: 'workspace', agent_name: 'test-agent', created_at: '2026-01-01T00:00:00.000Z',
+ created_by: 'test', brain_created_by_bootstrap: false, created_paths: [], registrations: [], repo_url: repoUrl,
+ } as RepoReceipt);
+ return repo;
+}
+
+describe('gbrain hook detached launches (#4992 batch 1)', () => {
+ test('the session-start workspace push is spawned detached with windowsHide: true', async () => {
+ const repo = bootstrapWorkspace('boot-repo');
+ expect(await runHook(['session-start'], { write: () => {}, stdin: '', cwd: repo })).toBe(0);
+ const pushes = spawns.filter(call => call.args.includes('push'));
+ expect(pushes).toHaveLength(1);
+ expect(pushes[0]!.command).toBe(process.execPath);
+ expect(pushes[0]!.args.slice(-4)).toEqual(['sources', 'push', '--path', pushes[0]!.args.at(-1)!]);
+ expect(pushes[0]!.options).toMatchObject({ detached: true, stdio: 'ignore', windowsHide: true });
+ });
+
+ test('the session-end backup check is spawned detached with windowsHide: true and the startup-hook skip', async () => {
+ const repo = bootstrapWorkspace('boot-repo-end');
+ expect(await runHook(['session-end'], { write: () => {}, stdin: JSON.stringify({ session_id: 'sess-seam', cwd: repo }) })).toBe(0);
+ const checks = spawns.filter(call => call.args.includes('backup'));
+ expect(checks).toHaveLength(1);
+ expect(checks[0]!.args.slice(-3)).toEqual(['backup', 'check', '--quiet']);
+ expect(checks[0]!.options).toMatchObject({ detached: true, stdio: 'ignore', windowsHide: true });
+ expect((checks[0]!.options.env as Record<string, string>).GBRAIN_SKIP_STARTUP_HOOKS).toBe('1');
+ for (const call of spawns) expect(call.options.windowsHide).toBe(true);
+ });
+
+ test("the hook's git probes go through the seam with gitChildEnv(): windowsHide set, repository-locating variables dropped", async () => {
+ const repo = bootstrapWorkspace('boot-repo-git');
+ await runHook(['session-start'], { write: () => {}, stdin: '', cwd: repo });
+ const gits = execFiles.filter(call => call.command === 'git');
+ expect(gits.length).toBeGreaterThan(0);
+ for (const call of gits) {
+ expect(call.options.windowsHide).toBe(true);
+ const env = call.options.env as Record<string, string | undefined>;
+ expect(env.GBRAIN_HOME).toBe(tmp);
+ for (const key of GIT_LOCAL_ENV_VARS) expect(env[key]).toBeUndefined();
+ }
+ });
+});
+
+describe('wave-13 holdovers launch through the seam', () => {
+ test('hardenedGitSync spawns git with windowsHide: true', () => {
+ const spy = spyOn(childProcess, 'spawnSync').mockImplementation(((command: string, args: string[], options: Record<string, unknown>) => {
+ spawns.push({ command, args, options });
+ return { status: 0, stdout: Buffer.from(''), stderr: Buffer.from(''), pid: 1, output: [], signal: null };
+ }) as unknown as typeof childProcess.spawnSync);
+ try {
+ expect(hardenedGitSync(tmp, ['rev-parse', '--show-toplevel'], { timeoutMs: 1000, maxBytes: 1024 }).ok).toBe(true);
+ } finally { spy.mockRestore(); }
+ expect(spawns).toHaveLength(1);
+ expect(spawns[0]!.command).toBe('git');
+ expect(spawns[0]!.options).toMatchObject({ windowsHide: true, killSignal: 'SIGKILL' });
+ });
+});