The #1084 refactor wave itself left behind a cluster of *-extraction-contract.test.ts files (born 2026-07-16 – 07-20) that pin source-text layout, not behavior, via readFile + dozens of assert.match/assert.doesNotMatch regexes:
packages/runtime/src/__tests__/tool-runtime-extraction-contract.test.ts (95 regex assertions)
packages/runtime/src/__tests__/ai-sdk-compaction-extraction-contract.test.ts (66)
packages/core/src/__tests__/settings-extraction-contract.test.ts (28)
packages/runtime/src/__tests__/active-full-compact-extraction-contract.test.ts
packages/headless/src/__tests__/oracle-registry-workflow-contract.test.ts
A rename or reformat breaks them; a behavioral regression passes them. session-manager.test.ts:8491 similarly pins runtime-kernel.ts internals by slicing source text (indexOf('private async *runAgentTurn') → includes('new AiSdkFlow')).
Scope
Replace each with (a) typed assertions on the extracted collaborator's public interface and (b) the lane's behavioral tests; delete the regex layer. Keep genuinely defensive source guards — containment-guard-contract.test.ts exists to prevent re-definition of a retired predicate and is fine as-is.
Policy for new extraction PRs (effective immediately): upcoming sub-issue PRs under #1084 and the third-pass governance issue should not add new source-regex extraction contracts. Pin an extraction with typed interface assertions and behavior tests instead.
Direction discussion (maintainer input wanted)
apps/desktop/src/main/__tests__ has a larger pre-existing family (~45 behavioral/wiring tests fed by renderer-shell-source-helpers.ts) asserting renderer wiring by regex over source text. Migrating those is a bigger project with real trade-offs (some assert cross-process wiring that is genuinely awkward to execute). This issue proposes agreeing on a policy — no new source-regex behavior tests; migrate opportunistically when a pinned file is refactored — rather than a big-bang rewrite.
References
#1084 (second-pass governance; the wave that introduced the cluster).
The #1084 refactor wave itself left behind a cluster of
*-extraction-contract.test.tsfiles (born 2026-07-16 – 07-20) that pin source-text layout, not behavior, viareadFile+ dozens ofassert.match/assert.doesNotMatchregexes:packages/runtime/src/__tests__/tool-runtime-extraction-contract.test.ts(95 regex assertions)packages/runtime/src/__tests__/ai-sdk-compaction-extraction-contract.test.ts(66)packages/core/src/__tests__/settings-extraction-contract.test.ts(28)packages/runtime/src/__tests__/active-full-compact-extraction-contract.test.tspackages/headless/src/__tests__/oracle-registry-workflow-contract.test.tsA rename or reformat breaks them; a behavioral regression passes them.
session-manager.test.ts:8491similarly pinsruntime-kernel.tsinternals by slicing source text (indexOf('private async *runAgentTurn')→includes('new AiSdkFlow')).Scope
Replace each with (a) typed assertions on the extracted collaborator's public interface and (b) the lane's behavioral tests; delete the regex layer. Keep genuinely defensive source guards —
containment-guard-contract.test.tsexists to prevent re-definition of a retired predicate and is fine as-is.Policy for new extraction PRs (effective immediately): upcoming sub-issue PRs under #1084 and the third-pass governance issue should not add new source-regex extraction contracts. Pin an extraction with typed interface assertions and behavior tests instead.
Direction discussion (maintainer input wanted)
apps/desktop/src/main/__tests__has a larger pre-existing family (~45 behavioral/wiring tests fed byrenderer-shell-source-helpers.ts) asserting renderer wiring by regex over source text. Migrating those is a bigger project with real trade-offs (some assert cross-process wiring that is genuinely awkward to execute). This issue proposes agreeing on a policy — no new source-regex behavior tests; migrate opportunistically when a pinned file is refactored — rather than a big-bang rewrite.References
#1084 (second-pass governance; the wave that introduced the cluster).