← Back to Pull requests

Record what spawned node processes import and read, so a test that runs a script through child_process reruns when that script or its imports change #11

Merged
max-blacksmith merged 11 files (498 lines) on Nov 12, 2026 14:42 UTC
View on GitHub
max-blacksmith max-blacksmith commented on Nov 06, 2026 19:29 UTC
Author

Summary

A test that exercises a script by spawning it (spawnSync(process.execPath, ['scripts/bench.ts']), exec('node dist/cli.js ...')) had no recorded dependency on the script or anything it imports or reads, so the affected selection skipped it after a change to that script. On a large monorepo replay this was the one real miss against the repo's own planner: 22 of 1,781 test files in one project spawn a repo script by path.

Record the child's modules and reads with a preloaded recorder

record-reads.ts (already the first setup file of every test) now also wraps child_process.spawn/exec/execFile/fork and their *Sync forms. Each call gets

options.env.NODE_OPTIONS += ` --import file:///…/record-child.js`
options.env.BLACKSMITH_CHILD_RECORD = '<tmp>/blacksmith-child-…/<pid>-<n>.txt'

record-child.ts runs in the child before its script: it wraps node:fs reads (same wrapReads as the test process, moved to fs-recorder.ts), records every file: resolution through module.registerHooks (ESM and CJS, including through loaders such as tsx), adds process.argv[1] and require.cache, and appends the set to the record file on exit. Grandchildren inherit the environment and append to the same file. When the child exits (sync: after the call returns; async: on 'exit'/'error'), the test process reads the file and adds each path, resolved against the child's cwd, to __vitest_worker__.dependencies, where vitest picks them up like any other dependency of the test file. node_modules paths are dropped as before.

Independent of the child's runtime, the command and every argument that names an existing file are recorded at spawn time, so a shell script or binary still ties the test to the file it was given.

Keep deliberately bare children bare

A child spawned with env: { ...process.env, NODE_OPTIONS: undefined } gets no recorder (only its command line is recorded): that pattern means the test wants to observe a child without node options, and the recorder's exit listener would show up in it.

Other changes

  • The wrapped functions keep the original's non-enumerable own properties (copyProperties), so promisify(exec) still finds promisify.custom.

  • tsconfig.build.json sets rewriteRelativeImportExtensions: record-child.ts imports ./fs-recorder.ts by its real extension because node loads it directly (type-stripped) when the plugin runs from source, and tsc rewrites it to .js in dist/.

  • Fixture: child.test.ts (spawnSync) and child-async.test.ts (promisify(exec)) run src/scripts/child-script.mjs, which imports child-lib.mjs and reads fixtures/child/data.txt; editing any of the three reruns exactly those two tests.

  • README caveat updated: globalSetup, non-node programs and build outputs run in place of their sources still need dependencies.
  • Link to Devin session: https://app.devin.ai/sessions/c7713a84ae564478a4c99c97d618fd0c
    Open in Devin Desktop: https://app.devin.ai/desktop/session/c7713a84ae564478a4c99c97d618fd0c?variant=devin
    Requested by: @max-blacksmith

    <!-- codesmith:footer:staging -->
    ---
    <a href="https://stagingbackend.blacksmith.sh/track/proof-report?proof_session_id=01a1b256-f5d4-7014-ad4b-cf36883f5e96&signature=90904f39e8974a6b429c466215ab8ba7cbbd92f1f845bd05111f6f67bba3187b"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-state-validated-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-state-validated-light.svg"><img alt="View full Proof" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-state-validated-dark-3x.png" width="131" height="28"></picture></a>
    <sup><a href="https://staging.blacksmith.sh/useblacksmith/codesmith/vitest/pr/11?autoLogin=true&ref=codesmith_pr_footer">Open in [code]smith</a> · Need help on this PR? Tag <code>@codesmith-bot</code> with what you need. (Staging)</sup>

    <!-- codesmith:autofix:disabled -->
    <!-- /codesmith:footer:staging -->

    <!-- codesmith:footer -->
    ---
    <a href="https://backend.blacksmith.sh/track/proof-report?proof_session_id=01a1b256-f00a-7379-862c-839e9e0eb322&signature=6f876c5d464eb4ae24c66e9d9ddbc07ec20ce1dfaf709c978ea0baf3e5f9c34e"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-state-validated-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-state-validated-light.svg"><img alt="View full Proof" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-state-validated-dark-3x.png" width="131" height="28"></picture></a>
    <sup><a href="https://app.blacksmith.sh/useblacksmith/codesmith/vitest/pr/11?autoLogin=true&ref=codesmith_pr_footer">Open in [code]smith</a> · Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup>

    <!-- codesmith:autofix:disabled -->
    <!-- /codesmith:footer -->

    Diff: 498 lines (+419 / -79) across 11 files Reviewer: cursor[bot] Review duration: 8352m
    All Vouch review confidence checks passed
    Residual risk 0.13 = Change Risk (0.60) × (1 − Review Confidence (0.78)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.60 · 498 lines diff across 11 files
    0.60
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.58 · 5 substantive comment(s)
    0.58
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    78%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.372
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    12 items
    devin-ai-integration[bot] devin-ai-integration[bot] commented on Nov 06, 2026 19:30 UTC
    Bot

    <!-- devin-pr-monitoring-controls -->
    I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring
  • blacksmith-sh[bot] blacksmith-sh[bot] commented on Nov 06, 2026 19:30 UTC
    Bot

    <!-- codesmith:proof -->

    <picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-3x.png" align="top" width="22" height="22"></picture> Spawned script edits rerun the test <img src="https://backend.blacksmith.sh/api/proof-report-pixel.gif?installation_model_id=2&amp;pr_number=11&amp;published_at=1793994725&amp;repository=useblacksmith%2Fvitest&amp;run_id=01a1b269-1eb2-70b7-94d4-afd11fe2e379&amp;signature=1add1e9b3d4ee9f61ff330288d759b8aae12b23e0291b2271a55e74cee8eabcd" width="1" height="1" alt="">

    Editing the spawned script, its import, or the file it reads reruns all three spawning tests (spawnSync, promisify(exec), promisify(execFile)) and not the unrelated one; before, each edit ran nothing.

    <sub>Merge-base</sub>

    <a href="https://backend.blacksmith.sh/track/proof-report?proof_session_id=01a1b256-f00a-7379-862c-839e9e0eb322&amp;signature=6f876c5d464eb4ae24c66e9d9ddbc07ec20ce1dfaf709c978ea0baf3e5f9c34e#evidence=01a1b256-f00a-7379-862c-839e9e0eb322/case:c1:0"><img src="https://backend.blacksmith.sh/api/attachments/01a1b269-d17e-7222-9de7-9a91a86b929f.e7f2262b1d07839f" alt="Edits run nothing" width="680"></a>

    <sub>This PR <code>c5f909b6</code></sub>

    <a href="https://backend.blacksmith.sh/track/proof-report?proof_session_id=01a1b256-f00a-7379-862c-839e9e0eb322&amp;signature=6f876c5d464eb4ae24c66e9d9ddbc07ec20ce1dfaf709c978ea0baf3e5f9c34e#evidence=01a1b256-f00a-7379-862c-839e9e0eb322/case:c1:1"><img src="https://backend.blacksmith.sh/api/attachments/01a1b269-d296-72c5-b400-f17520e80ecf.67527c57c4bd3e02" alt="Edits rerun 3 of 4" width="680"></a>

    Also checked · 4 match

    <picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> Non-node child: command-line files<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> NODE\_OPTIONS: undefined stays bare<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> tsx-preloaded child fs imports<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> Promisified exec keeps .child

    <sub>Proof on <code>c5f909b6</code> (from <code>9dc961a9</code>) · Did Proof get it right? <a href="https://app.blacksmith.sh/useblacksmith/sessions/01a1b256-e3a8-735c-87a0-a570f37b42b5?autoLogin=true&amp;pane=proof-report%3A01a1b256-f00a-7379-862c-839e9e0eb322&amp;focus=proof&amp;ref=proof_github_rating&amp;rate=up&amp;run=01a1b269-1eb2-70b7-94d4-afd11fe2e379">Yes</a> · <a href="https://app.blacksmith.sh/useblacksmith/sessions/01a1b256-e3a8-735c-87a0-a570f37b42b5?autoLogin=true&amp;pane=proof-report%3A01a1b256-f00a-7379-862c-839e9e0eb322&amp;focus=proof&amp;ref=proof_github_rating&amp;rate=down&amp;run=01a1b269-1eb2-70b7-94d4-afd11fe2e379">No</a></sub>

    View full Proof report

    blacksmith-staging[bot] blacksmith-staging[bot] commented on Nov 06, 2026 19:30 UTC
    Bot

    <!-- codesmith:proof:staging -->

    <picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-3x.png" align="top" width="22" height="22"></picture> Script import edit reruns spawning test <img src="https://stagingbackend.blacksmith.sh/api/proof-report-pixel.gif?installation_model_id=8&amp;pr_number=11&amp;published_at=1793994745&amp;repository=useblacksmith%2Fvitest&amp;run_id=01a1b269-28d8-700e-901c-21745f38f0f8&amp;signature=2f4bb6d5a5f41dcc3182b78e387e1e767192fc38e75af9023d7a77d564aaf7fb" width="1" height="1" alt="">

    After a breaking edit to the module the spawned script imports, the affected run still skipped every test before and reran only the spawning test (which failed) after.

    <sub>Merge-base</sub>

    <a href="https://stagingbackend.blacksmith.sh/track/proof-report?proof_session_id=01a1b256-f5d4-7014-ad4b-cf36883f5e96&amp;signature=90904f39e8974a6b429c466215ab8ba7cbbd92f1f845bd05111f6f67bba3187b#evidence=01a1b256-f5d4-7014-ad4b-cf36883f5e96/case:c1:0"><img src="https://stagingbackend.blacksmith.sh/api/attachments/01a1b269-ba3f-7367-b37a-57db37ab1f32.dff73c8f20c8e533" alt="Import edit skipped" width="659"></a>

    <sub>This PR <code>c5f909b6</code></sub>

    <a href="https://stagingbackend.blacksmith.sh/track/proof-report?proof_session_id=01a1b256-f5d4-7014-ad4b-cf36883f5e96&amp;signature=90904f39e8974a6b429c466215ab8ba7cbbd92f1f845bd05111f6f67bba3187b#evidence=01a1b256-f5d4-7014-ad4b-cf36883f5e96/case:c1:1"><img src="https://stagingbackend.blacksmith.sh/api/attachments/01a1b269-ba63-70d8-9a67-f38240a8e7a2.17621c933f28b9a2" alt="Spawning test reruns" width="659"></a>

    Also checked · 6 match

    <picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> promisify\(exec\) child records its reads<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> Grandchild imports are recorded<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> NODE\_OPTIONS: undefined child stays bare<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> promisify\(execFile\) child is recorded<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> Preloaded child's named fs imports recorded<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> Promisified exec keeps child handle

    <sub>Proof on <code>c5f909b6</code> (from <code>9dc961a9</code>) · not run: Blacksmith Actions cache backend (not needed) · Did Proof get it right? <a href="https://staging.blacksmith.sh/useblacksmith/sessions/01a1b256-e486-717b-951a-63f194333258?autoLogin=true&amp;pane=proof-report%3A01a1b256-f5d4-7014-ad4b-cf36883f5e96&amp;focus=proof&amp;ref=proof_github_rating&amp;rate=up&amp;run=01a1b269-28d8-700e-901c-21745f38f0f8">Yes</a> · <a href="https://staging.blacksmith.sh/useblacksmith/sessions/01a1b256-e486-717b-951a-63f194333258?autoLogin=true&amp;pane=proof-report%3A01a1b256-f5d4-7014-ad4b-cf36883f5e96&amp;focus=proof&amp;ref=proof_github_rating&amp;rate=down&amp;run=01a1b269-28d8-700e-901c-21745f38f0f8">No</a></sub>

    View full Proof report · React 👎 or comment @codesmith dismiss this proof to dismiss

    cursor[bot] cursor[bot] commented on Nov 06, 2026 19:40 UTC
    Reviewer

    <!-- BUGBOT_REVIEW -->
    <!-- BUGBOT_REVIEW_STALE -->
    Stale Bugbot comment from a previous run.

    cursor[bot] cursor[bot] commented on code on Nov 06, 2026 19:40 UTC
    Code Review
    src/record-reads.ts:1
    @@ -27,94 +44,168 @@ interface Context {
     	__vitest_worker__?: WorkerState
     }
     
    -// `vmThreads`/`vmForks` evaluate this file once per test context while the
    -// builtin `fs` object is shared, so the wrappers read the worker state through
    -// a slot the latest evaluation points at the current context's global.
    +// The `vm` pools load this file in one context and run tests in another; the
    +// builtin is shared, so it carries the context that holds the worker state.
     const shared = fs as unknown as Record<symbol, unknown>
     shared[CONTEXT] = globalThis
     
    -function toPath(target: unknown): string | null {
    -	if (typeof target === 'string') return target
    -	if (Buffer.isBuffer(target)) return target.toString()
    -	if (target instanceof URL) {
    -		try {
    -			return fileURLToPath(target)
    -		} catch {
    -			return null
    -		}
    +function dependencies(): Set<string> | undefined {
    +	return (shared[CONTEXT] as Context | undefined)?.__vitest_worker__
    +		?.dependencies
    +}
    +
    +function record(file: string, cwd = process.cwd()): void {
    +	const set = dependencies()
    +	if (!set) return
    +	const absolute = path.resolve(cwd, file)
    +	if (isIgnored(absolute)) return
    +	set.add(absolute)
    +}
    +
    +wrapReads(fs, (file) => record(file))
    +
    +/** Beside this module; `.ts` when the plugin runs from source (its own test fixtures). */
    +const recordChild = fileURLToPath(
    +	new URL(
    +		import.meta.url.endsWith('.ts') ? './record-child.ts' : './record-child.js',
    +		import.meta.url,
    +	),
    +)
    +
    +let recordDir: string | undefined
    +let spawned = 0
    +
    +/** Where one child (and its descendants) appends what it loaded. */
    +function recordFile(): string {
    +	recordDir ??= mkdtemp(path.join(os.tmpdir(), 'blacksmith-child-'))
    +	return path.join(recordDir, `${process.pid}-${spawned++}.txt`)
    +}
    +
    +/** The options object of a `child_process` call, inserted when the call had none. */
    +function optionsOf(args: unknown[]): Record<string, unknown> {
    +	let index = args.findIndex(
    +		(arg, i) =>
    +			i > 0 && typeof arg === 'object' && arg !== null && !Array.isArray(arg),
    +	)
    +	if (index === -1) {
    +		index = Array.isArray(args[1]) ? 2 : 1
    +		args.splice(index, 0, {})
     	}
    -	return null
    +	const options = { ...(args[index] as Record<string, unknown>) }
    +	args[index] = options
    +	return options
     }
     
    -function record(target: unknown): void {
    -	const dependencies = (shared[CONTEXT] as Context | undefined)
    -		?.__vitest_worker__?.dependencies
    -	if (!dependencies) return
    -	const file = toPath(target)
    -	if (file === null) return
    -	const absolute = path.resolve(file)
    -	if (absolute.split(path.sep).includes('node_modules')) return
    -	dependencies.add(absolute)
    +interface Child {
    +	/** The record file the child was given, `null` when nothing is being recorded. */
    +	file: string | null
    +	cwd: string
     }
     
    -/** A recursive copy reads every file below its source. */
    -function recordTree(target: unknown): void {
    -	record(target)
    -	const file = toPath(target)
    +/**
    + * Prepares a `child_process` call: the child gets the recorder preloaded and
    + * a file to report to, and the command plus every argument naming a file is
    + * recorded right away, which is all a non-node child (a shell script, a
    + * binary) can contribute.
    + */
    +function instrument(args: unknown[]): Child {
    +	if (!dependencies()) return { file: null, cwd: process.cwd() }
    +	const options = optionsOf(args)
    +	const cwd =
    +		typeof options.cwd === 'string'
    +			? path.resolve(options.cwd)
    +			: options.cwd instanceof URL
    +				? fileURLToPath(options.cwd)
    +				: process.cwd()
    +	const file = recordFile()
    +	const given = options.env as Record<string, string | undefined> | undefined
    +	const env = { ...(given ?? process.env) }
    +	// `env: { ...process.env, NODE_OPTIONS: undefined }` asks for a child free
    +	// of node options; such a child is left alone and contributes only its
    +	// command line.
    +	const cleared =
    +		given !== undefined &&
    +		Object.prototype.hasOwnProperty.call(given, 'NODE_OPTIONS') &&
    +		given.NODE_OPTIONS === undefined
    +	if (!cleared) {
    +		env[CHILD_RECORD_ENV] = file
    +		env.NODE_OPTIONS = [
    +			env.NODE_OPTIONS,
    +			`--import ${pathToFileURL(recordChild).href}`,
    +		]
    +			.filter(Boolean)
    +			.join(' ')
    +	}
    +	options.env = env
    +	const words = [
    +		...(typeof args[0] === 'string' ? args[0].split(/\s+/) : []),
    +		...(Array.isArray(args[1]) ? args[1] : []),
    +	]
    +	for (const word of words) {
    +		if (typeof word !== 'string' || word === '') continue
    +		const candidate = path.resolve(cwd, word)
    +		try {
    +			if (exists(candidate) && stat(candidate).isFile()) record(candidate)
    +		} catch {}
    +	}
    +	return { file, cwd }
    +}
    +
    +/** Records what the exited child reported, relative to its working directory. */
    +function collect({ file, cwd }: Child): void {
     	if (file === null) return
    -	let entries: string[]
    +	let reported: string
     	try {
    -		entries = fs.readdirSync(file, { recursive: true, encoding: 'utf8' })
    +		reported = read(file, 'utf8')
     	} catch {
     		return
    +	} finally {
    +		try {
    +			unlink(file)
    +		} catch {}
     	}
    -	for (const entry of entries) record(path.join(file, entry))
    +	for (const line of reported.split('\n')) if (line !== '') record(line, cwd)
     }
     
     type Wrappable = Record<string, unknown>
     
    -function wrap(
    -	object: Wrappable,
    -	name: string,
    -	recorder: (target: unknown) => void = record,
    -): void {
    -	const original = object[name]
    +function wrapChildProcess(name: string, sync: boolean): void {
    +	const target = childProcess as unknown as Wrappable
    +	const original = target[name]
     	if (typeof original !== 'function' || BRAND in original) return
    -	const wrapped = function (this: unknown, ...args: unknown[]) {
    -		recorder(args[0])
    -		return (original as (...args: unknown[]) => unknown).apply(this, args)
    -	}
    -	// `realpathSync.native` and friends live on the function.
    -	Object.assign(wrapped, original)
    -	wrap(wrapped as unknown as Wrappable, 'native', recorder)
    +	const call = original as (...args: unknown[]) => unknown
    +	const wrapped = sync
    +		? function (this: unknown, ...args: unknown[]) {
    +				const child = instrument(args)
    +				try {
    +					return call.apply(this, args)
    +				} finally {
    +					collect(child)
    +				}
    +			}
    +		: function (this: unknown, ...args: unknown[]) {
    +				const child = instrument(args)
    +				const process = call.apply(this, args) as
    +					| { once?: (event: string, listener: () => void) => unknown }
    +					| undefined
    +				if (typeof process?.once === 'function') {
    +					const done = () => collect(child)
    +					process.once('exit', done)
    +					process.once('error', done)
    +				}
    +				return process
    +			}
    +	copyProperties(wrapped, original)
     	Object.defineProperty(wrapped, BRAND, { value: true })
    -	object[name] = wrapped
    +	target[name] = wrapped

    Promisify bypasses spawn instrumentation

    Medium Severity

    <!-- DESCRIPTION START -->
    copyProperties copies promisify.custom from the original exec/execFile, and that custom function calls the unwrapped original. promisify(execFile) therefore never injects the recorder, so the child's modules and reads are not added as dependencies.
    <!-- DESCRIPTION END -->

    <!-- BUGBOT_BUG_ID: 677a3078-acb9-4343-bf2f-932ad05a8a1a -->

    <!-- LOCATIONS START
    src/record-reads.ts#L197-L200
    src/record-reads.ts#L171-L197
    LOCATIONS END -->
    <details>
    <summary>Additional Locations (1)</summary>

  • src/record-reads.ts#L171-L197
  • </details>

    <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjIxOWRhMjBhLWFiZDQtNGFkMS05NmJmLWIzYjcxNDcyNmZjYiIsImVuY3J5cHRpb25LZXkiOiItZ2d4U1hNLW9fOWQ2MWpuazFaenZ4MjZzQnkyalZVYVdZdVJKUFJ4cmpjIiwiYnJhbmNoIjoiZGV2aW4vMTc5Mzk5MjUxMy1yZWNvcmQtY2hpbGQtcHJvY2Vzc2VzIiwicmVwb093bmVyIjoidXNlYmxhY2tzbWl0aCIsInJlcG9OYW1lIjoidml0ZXN0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjIxOWRhMjBhLWFiZDQtNGFkMS05NmJmLWIzYjcxNDcyNmZjYiIsImVuY3J5cHRpb25LZXkiOiItZ2d4U1hNLW9fOWQ2MWpuazFaenZ4MjZzQnkyalZVYVdZdVJKUFJ4cmpjIiwiYnJhbmNoIjoiZGV2aW4vMTc5Mzk5MjUxMy1yZWNvcmQtY2hpbGQtcHJvY2Vzc2VzIiwicmVwb093bmVyIjoidXNlYmxhY2tzbWl0aCIsInJlcG9OYW1lIjoidml0ZXN0IiwicHJOdW1iZXIiOjExLCJjb21taXRTaGEiOiJjZjRjMzhmMDZmZGI5ZDEwZjljNmJiM2Q3OGQ3ZDgxZjBiNzg4ZWRjIiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>

    <sup>Reviewed by Cursor Bugbot for commit cf4c38f06fdb9d10f9c6bb3d78d7d81f0b788edc. Configure here.</sup>

    cursor[bot] cursor[bot] commented on code on Nov 06, 2026 19:40 UTC
    Code Review
    src/record-reads.ts:1
    @@ -27,94 +44,168 @@ interface Context {
     	__vitest_worker__?: WorkerState
     }
     
    -// `vmThreads`/`vmForks` evaluate this file once per test context while the
    -// builtin `fs` object is shared, so the wrappers read the worker state through
    -// a slot the latest evaluation points at the current context's global.
    +// The `vm` pools load this file in one context and run tests in another; the
    +// builtin is shared, so it carries the context that holds the worker state.
     const shared = fs as unknown as Record<symbol, unknown>
     shared[CONTEXT] = globalThis
     
    -function toPath(target: unknown): string | null {
    -	if (typeof target === 'string') return target
    -	if (Buffer.isBuffer(target)) return target.toString()
    -	if (target instanceof URL) {
    -		try {
    -			return fileURLToPath(target)
    -		} catch {
    -			return null
    -		}
    +function dependencies(): Set<string> | undefined {
    +	return (shared[CONTEXT] as Context | undefined)?.__vitest_worker__
    +		?.dependencies
    +}
    +
    +function record(file: string, cwd = process.cwd()): void {
    +	const set = dependencies()
    +	if (!set) return
    +	const absolute = path.resolve(cwd, file)
    +	if (isIgnored(absolute)) return
    +	set.add(absolute)
    +}
    +
    +wrapReads(fs, (file) => record(file))
    +
    +/** Beside this module; `.ts` when the plugin runs from source (its own test fixtures). */
    +const recordChild = fileURLToPath(
    +	new URL(
    +		import.meta.url.endsWith('.ts') ? './record-child.ts' : './record-child.js',
    +		import.meta.url,
    +	),
    +)
    +
    +let recordDir: string | undefined
    +let spawned = 0
    +
    +/** Where one child (and its descendants) appends what it loaded. */
    +function recordFile(): string {
    +	recordDir ??= mkdtemp(path.join(os.tmpdir(), 'blacksmith-child-'))
    +	return path.join(recordDir, `${process.pid}-${spawned++}.txt`)
    +}
    +
    +/** The options object of a `child_process` call, inserted when the call had none. */
    +function optionsOf(args: unknown[]): Record<string, unknown> {
    +	let index = args.findIndex(
    +		(arg, i) =>
    +			i > 0 && typeof arg === 'object' && arg !== null && !Array.isArray(arg),
    +	)
    +	if (index === -1) {
    +		index = Array.isArray(args[1]) ? 2 : 1
    +		args.splice(index, 0, {})
     	}
    -	return null
    +	const options = { ...(args[index] as Record<string, unknown>) }
    +	args[index] = options
    +	return options
     }
     
    -function record(target: unknown): void {
    -	const dependencies = (shared[CONTEXT] as Context | undefined)
    -		?.__vitest_worker__?.dependencies
    -	if (!dependencies) return
    -	const file = toPath(target)
    -	if (file === null) return
    -	const absolute = path.resolve(file)
    -	if (absolute.split(path.sep).includes('node_modules')) return
    -	dependencies.add(absolute)
    +interface Child {
    +	/** The record file the child was given, `null` when nothing is being recorded. */
    +	file: string | null
    +	cwd: string
     }
     
    -/** A recursive copy reads every file below its source. */
    -function recordTree(target: unknown): void {
    -	record(target)
    -	const file = toPath(target)
    +/**
    + * Prepares a `child_process` call: the child gets the recorder preloaded and
    + * a file to report to, and the command plus every argument naming a file is
    + * recorded right away, which is all a non-node child (a shell script, a
    + * binary) can contribute.
    + */
    +function instrument(args: unknown[]): Child {
    +	if (!dependencies()) return { file: null, cwd: process.cwd() }
    +	const options = optionsOf(args)
    +	const cwd =
    +		typeof options.cwd === 'string'
    +			? path.resolve(options.cwd)
    +			: options.cwd instanceof URL
    +				? fileURLToPath(options.cwd)
    +				: process.cwd()
    +	const file = recordFile()
    +	const given = options.env as Record<string, string | undefined> | undefined
    +	const env = { ...(given ?? process.env) }
    +	// `env: { ...process.env, NODE_OPTIONS: undefined }` asks for a child free
    +	// of node options; such a child is left alone and contributes only its
    +	// command line.
    +	const cleared =
    +		given !== undefined &&
    +		Object.prototype.hasOwnProperty.call(given, 'NODE_OPTIONS') &&
    +		given.NODE_OPTIONS === undefined
    +	if (!cleared) {
    +		env[CHILD_RECORD_ENV] = file
    +		env.NODE_OPTIONS = [
    +			env.NODE_OPTIONS,
    +			`--import ${pathToFileURL(recordChild).href}`,
    +		]
    +			.filter(Boolean)
    +			.join(' ')

    Child recorder misses ESM fs reads

    Medium Severity

    <!-- DESCRIPTION START -->
    The recorder --import is appended onto existing NODE_OPTIONS, so preloaders such as tsx run first and can bind node:fs ESM exports before wrapping. record-child also never calls syncBuiltinESMExports, so a child's import { readFileSync } from 'node:fs' can skip the wrapper and drop those reads.
    <!-- DESCRIPTION END -->

    <!-- BUGBOT_BUG_ID: b63971ee-1ad1-4782-a2db-ed08818cad16 -->

    <!-- LOCATIONS START
    src/record-reads.ts#L131-L137
    src/record-child.ts#L25-L26
    LOCATIONS END -->
    <details>
    <summary>Additional Locations (1)</summary>

  • src/record-child.ts#L25-L26
  • </details>

    <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmMzMWRhM2UwLWE4ZWEtNGYzOC1iZmYyLWI5OTg0ZDY3ZWZhZCIsImVuY3J5cHRpb25LZXkiOiJOSDRmb1p5Z1lGNHF4SWw4T1Rsbl84Y3JVQXN5eG5JUTZBb01JcllqMndrIiwiYnJhbmNoIjoiZGV2aW4vMTc5Mzk5MjUxMy1yZWNvcmQtY2hpbGQtcHJvY2Vzc2VzIiwicmVwb093bmVyIjoidXNlYmxhY2tzbWl0aCIsInJlcG9OYW1lIjoidml0ZXN0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmMzMWRhM2UwLWE4ZWEtNGYzOC1iZmYyLWI5OTg0ZDY3ZWZhZCIsImVuY3J5cHRpb25LZXkiOiJOSDRmb1p5Z1lGNHF4SWw4T1Rsbl84Y3JVQXN5eG5JUTZBb01JcllqMndrIiwiYnJhbmNoIjoiZGV2aW4vMTc5Mzk5MjUxMy1yZWNvcmQtY2hpbGQtcHJvY2Vzc2VzIiwicmVwb093bmVyIjoidXNlYmxhY2tzbWl0aCIsInJlcG9OYW1lIjoidml0ZXN0IiwicHJOdW1iZXIiOjExLCJjb21taXRTaGEiOiJjZjRjMzhmMDZmZGI5ZDEwZjljNmJiM2Q3OGQ3ZDgxZjBiNzg4ZWRjIiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>

    <sup>Reviewed by Cursor Bugbot for commit cf4c38f06fdb9d10f9c6bb3d78d7d81f0b788edc. Configure here.</sup>

    devin-ai-integration[bot] devin-ai-integration[bot] commented on code on Nov 06, 2026 19:43 UTC
    Code Review
    src/record-reads.ts:1
    @@ -27,94 +44,168 @@ interface Context {
     	__vitest_worker__?: WorkerState
     }
     
    -// `vmThreads`/`vmForks` evaluate this file once per test context while the
    -// builtin `fs` object is shared, so the wrappers read the worker state through
    -// a slot the latest evaluation points at the current context's global.
    +// The `vm` pools load this file in one context and run tests in another; the
    +// builtin is shared, so it carries the context that holds the worker state.
     const shared = fs as unknown as Record<symbol, unknown>
     shared[CONTEXT] = globalThis
     
    -function toPath(target: unknown): string | null {
    -	if (typeof target === 'string') return target
    -	if (Buffer.isBuffer(target)) return target.toString()
    -	if (target instanceof URL) {
    -		try {
    -			return fileURLToPath(target)
    -		} catch {
    -			return null
    -		}
    +function dependencies(): Set<string> | undefined {
    +	return (shared[CONTEXT] as Context | undefined)?.__vitest_worker__
    +		?.dependencies
    +}
    +
    +function record(file: string, cwd = process.cwd()): void {
    +	const set = dependencies()
    +	if (!set) return
    +	const absolute = path.resolve(cwd, file)
    +	if (isIgnored(absolute)) return
    +	set.add(absolute)
    +}
    +
    +wrapReads(fs, (file) => record(file))
    +
    +/** Beside this module; `.ts` when the plugin runs from source (its own test fixtures). */
    +const recordChild = fileURLToPath(
    +	new URL(
    +		import.meta.url.endsWith('.ts') ? './record-child.ts' : './record-child.js',
    +		import.meta.url,
    +	),
    +)
    +
    +let recordDir: string | undefined
    +let spawned = 0
    +
    +/** Where one child (and its descendants) appends what it loaded. */
    +function recordFile(): string {
    +	recordDir ??= mkdtemp(path.join(os.tmpdir(), 'blacksmith-child-'))
    +	return path.join(recordDir, `${process.pid}-${spawned++}.txt`)
    +}
    +
    +/** The options object of a `child_process` call, inserted when the call had none. */
    +function optionsOf(args: unknown[]): Record<string, unknown> {
    +	let index = args.findIndex(
    +		(arg, i) =>
    +			i > 0 && typeof arg === 'object' && arg !== null && !Array.isArray(arg),
    +	)
    +	if (index === -1) {
    +		index = Array.isArray(args[1]) ? 2 : 1
    +		args.splice(index, 0, {})
     	}
    -	return null
    +	const options = { ...(args[index] as Record<string, unknown>) }
    +	args[index] = options
    +	return options
     }
     
    -function record(target: unknown): void {
    -	const dependencies = (shared[CONTEXT] as Context | undefined)
    -		?.__vitest_worker__?.dependencies
    -	if (!dependencies) return
    -	const file = toPath(target)
    -	if (file === null) return
    -	const absolute = path.resolve(file)
    -	if (absolute.split(path.sep).includes('node_modules')) return
    -	dependencies.add(absolute)
    +interface Child {
    +	/** The record file the child was given, `null` when nothing is being recorded. */
    +	file: string | null
    +	cwd: string
     }
     
    -/** A recursive copy reads every file below its source. */
    -function recordTree(target: unknown): void {
    -	record(target)
    -	const file = toPath(target)
    +/**
    + * Prepares a `child_process` call: the child gets the recorder preloaded and
    + * a file to report to, and the command plus every argument naming a file is
    + * recorded right away, which is all a non-node child (a shell script, a
    + * binary) can contribute.
    + */
    +function instrument(args: unknown[]): Child {
    +	if (!dependencies()) return { file: null, cwd: process.cwd() }
    +	const options = optionsOf(args)
    +	const cwd =
    +		typeof options.cwd === 'string'
    +			? path.resolve(options.cwd)
    +			: options.cwd instanceof URL
    +				? fileURLToPath(options.cwd)
    +				: process.cwd()
    +	const file = recordFile()
    +	const given = options.env as Record<string, string | undefined> | undefined
    +	const env = { ...(given ?? process.env) }
    +	// `env: { ...process.env, NODE_OPTIONS: undefined }` asks for a child free
    +	// of node options; such a child is left alone and contributes only its
    +	// command line.
    +	const cleared =
    +		given !== undefined &&
    +		Object.prototype.hasOwnProperty.call(given, 'NODE_OPTIONS') &&
    +		given.NODE_OPTIONS === undefined
    +	if (!cleared) {
    +		env[CHILD_RECORD_ENV] = file
    +		env.NODE_OPTIONS = [
    +			env.NODE_OPTIONS,
    +			`--import ${pathToFileURL(recordChild).href}`,
    +		]
    +			.filter(Boolean)
    +			.join(' ')
    +	}
    +	options.env = env
    +	const words = [
    +		...(typeof args[0] === 'string' ? args[0].split(/\s+/) : []),
    +		...(Array.isArray(args[1]) ? args[1] : []),
    +	]
    +	for (const word of words) {
    +		if (typeof word !== 'string' || word === '') continue
    +		const candidate = path.resolve(cwd, word)
    +		try {
    +			if (exists(candidate) && stat(candidate).isFile()) record(candidate)
    +		} catch {}
    +	}
    +	return { file, cwd }
    +}
    +
    +/** Records what the exited child reported, relative to its working directory. */
    +function collect({ file, cwd }: Child): void {
     	if (file === null) return
    -	let entries: string[]
    +	let reported: string
     	try {
    -		entries = fs.readdirSync(file, { recursive: true, encoding: 'utf8' })
    +		reported = read(file, 'utf8')
     	} catch {
     		return
    +	} finally {
    +		try {
    +			unlink(file)
    +		} catch {}
     	}
    -	for (const entry of entries) record(path.join(file, entry))
    +	for (const line of reported.split('\n')) if (line !== '') record(line, cwd)
     }
     
     type Wrappable = Record<string, unknown>
     
    -function wrap(
    -	object: Wrappable,
    -	name: string,
    -	recorder: (target: unknown) => void = record,
    -): void {
    -	const original = object[name]
    +function wrapChildProcess(name: string, sync: boolean): void {
    +	const target = childProcess as unknown as Wrappable
    +	const original = target[name]
     	if (typeof original !== 'function' || BRAND in original) return
    -	const wrapped = function (this: unknown, ...args: unknown[]) {
    -		recorder(args[0])
    -		return (original as (...args: unknown[]) => unknown).apply(this, args)
    -	}
    -	// `realpathSync.native` and friends live on the function.
    -	Object.assign(wrapped, original)
    -	wrap(wrapped as unknown as Wrappable, 'native', recorder)
    +	const call = original as (...args: unknown[]) => unknown
    +	const wrapped = sync
    +		? function (this: unknown, ...args: unknown[]) {
    +				const child = instrument(args)
    +				try {
    +					return call.apply(this, args)
    +				} finally {
    +					collect(child)
    +				}
    +			}
    +		: function (this: unknown, ...args: unknown[]) {
    +				const child = instrument(args)
    +				const process = call.apply(this, args) as
    +					| { once?: (event: string, listener: () => void) => unknown }
    +					| undefined
    +				if (typeof process?.once === 'function') {
    +					const done = () => collect(child)
    +					process.once('exit', done)
    +					process.once('error', done)
    +				}
    +				return process
    +			}
    +	copyProperties(wrapped, original)
     	Object.defineProperty(wrapped, BRAND, { value: true })
    -	object[name] = wrapped
    +	target[name] = wrapped

    Right for execFile: Node's exec goes through module.exports.execFile (the wrapped one), but execFile[promisify.custom] calls the original directly. 9dc961a gives the wrapped exec/execFile their own promisify.custom that calls the wrapper with a callback (same { stdout, stderr } resolution and error augmentation as Node's). The fixture child-async.test.ts now uses promisify(execFile), and its edits rerun the test.

    devin-ai-integration[bot] devin-ai-integration[bot] commented on code on Nov 06, 2026 19:43 UTC
    Code Review
    src/record-reads.ts:1
    @@ -27,94 +44,168 @@ interface Context {
     	__vitest_worker__?: WorkerState
     }
     
    -// `vmThreads`/`vmForks` evaluate this file once per test context while the
    -// builtin `fs` object is shared, so the wrappers read the worker state through
    -// a slot the latest evaluation points at the current context's global.
    +// The `vm` pools load this file in one context and run tests in another; the
    +// builtin is shared, so it carries the context that holds the worker state.
     const shared = fs as unknown as Record<symbol, unknown>
     shared[CONTEXT] = globalThis
     
    -function toPath(target: unknown): string | null {
    -	if (typeof target === 'string') return target
    -	if (Buffer.isBuffer(target)) return target.toString()
    -	if (target instanceof URL) {
    -		try {
    -			return fileURLToPath(target)
    -		} catch {
    -			return null
    -		}
    +function dependencies(): Set<string> | undefined {
    +	return (shared[CONTEXT] as Context | undefined)?.__vitest_worker__
    +		?.dependencies
    +}
    +
    +function record(file: string, cwd = process.cwd()): void {
    +	const set = dependencies()
    +	if (!set) return
    +	const absolute = path.resolve(cwd, file)
    +	if (isIgnored(absolute)) return
    +	set.add(absolute)
    +}
    +
    +wrapReads(fs, (file) => record(file))
    +
    +/** Beside this module; `.ts` when the plugin runs from source (its own test fixtures). */
    +const recordChild = fileURLToPath(
    +	new URL(
    +		import.meta.url.endsWith('.ts') ? './record-child.ts' : './record-child.js',
    +		import.meta.url,
    +	),
    +)
    +
    +let recordDir: string | undefined
    +let spawned = 0
    +
    +/** Where one child (and its descendants) appends what it loaded. */
    +function recordFile(): string {
    +	recordDir ??= mkdtemp(path.join(os.tmpdir(), 'blacksmith-child-'))
    +	return path.join(recordDir, `${process.pid}-${spawned++}.txt`)
    +}
    +
    +/** The options object of a `child_process` call, inserted when the call had none. */
    +function optionsOf(args: unknown[]): Record<string, unknown> {
    +	let index = args.findIndex(
    +		(arg, i) =>
    +			i > 0 && typeof arg === 'object' && arg !== null && !Array.isArray(arg),
    +	)
    +	if (index === -1) {
    +		index = Array.isArray(args[1]) ? 2 : 1
    +		args.splice(index, 0, {})
     	}
    -	return null
    +	const options = { ...(args[index] as Record<string, unknown>) }
    +	args[index] = options
    +	return options
     }
     
    -function record(target: unknown): void {
    -	const dependencies = (shared[CONTEXT] as Context | undefined)
    -		?.__vitest_worker__?.dependencies
    -	if (!dependencies) return
    -	const file = toPath(target)
    -	if (file === null) return
    -	const absolute = path.resolve(file)
    -	if (absolute.split(path.sep).includes('node_modules')) return
    -	dependencies.add(absolute)
    +interface Child {
    +	/** The record file the child was given, `null` when nothing is being recorded. */
    +	file: string | null
    +	cwd: string
     }
     
    -/** A recursive copy reads every file below its source. */
    -function recordTree(target: unknown): void {
    -	record(target)
    -	const file = toPath(target)
    +/**
    + * Prepares a `child_process` call: the child gets the recorder preloaded and
    + * a file to report to, and the command plus every argument naming a file is
    + * recorded right away, which is all a non-node child (a shell script, a
    + * binary) can contribute.
    + */
    +function instrument(args: unknown[]): Child {
    +	if (!dependencies()) return { file: null, cwd: process.cwd() }
    +	const options = optionsOf(args)
    +	const cwd =
    +		typeof options.cwd === 'string'
    +			? path.resolve(options.cwd)
    +			: options.cwd instanceof URL
    +				? fileURLToPath(options.cwd)
    +				: process.cwd()
    +	const file = recordFile()
    +	const given = options.env as Record<string, string | undefined> | undefined
    +	const env = { ...(given ?? process.env) }
    +	// `env: { ...process.env, NODE_OPTIONS: undefined }` asks for a child free
    +	// of node options; such a child is left alone and contributes only its
    +	// command line.
    +	const cleared =
    +		given !== undefined &&
    +		Object.prototype.hasOwnProperty.call(given, 'NODE_OPTIONS') &&
    +		given.NODE_OPTIONS === undefined
    +	if (!cleared) {
    +		env[CHILD_RECORD_ENV] = file
    +		env.NODE_OPTIONS = [
    +			env.NODE_OPTIONS,
    +			`--import ${pathToFileURL(recordChild).href}`,
    +		]
    +			.filter(Boolean)
    +			.join(' ')

    Agreed: a preloader ahead of ours can have materialized the node:fs ESM namespace already. 9dc961a calls syncBuiltinESMExports() in record-child right after wrapping, the same way record-reads does in the test process, so named imports in the child see the wrappers regardless of NODE_OPTIONS order. The ordering itself is left as is, since appending keeps the user's loaders (tsx) resolving first.

    cursor[bot] cursor[bot] commented on code on Nov 06, 2026 19:48 UTC
    Code Review
    src/record-reads.ts:1
    @@ -27,94 +45,184 @@ interface Context {
     	__vitest_worker__?: WorkerState
     }
     
    -// `vmThreads`/`vmForks` evaluate this file once per test context while the
    -// builtin `fs` object is shared, so the wrappers read the worker state through
    -// a slot the latest evaluation points at the current context's global.
    +// The `vm` pools load this file in one context and run tests in another; the
    +// builtin is shared, so it carries the context that holds the worker state.
     const shared = fs as unknown as Record<symbol, unknown>
     shared[CONTEXT] = globalThis
     
    -function toPath(target: unknown): string | null {
    -	if (typeof target === 'string') return target
    -	if (Buffer.isBuffer(target)) return target.toString()
    -	if (target instanceof URL) {
    -		try {
    -			return fileURLToPath(target)
    -		} catch {
    -			return null
    -		}
    +function dependencies(): Set<string> | undefined {
    +	return (shared[CONTEXT] as Context | undefined)?.__vitest_worker__
    +		?.dependencies
    +}
    +
    +function record(file: string, cwd = process.cwd()): void {
    +	const set = dependencies()
    +	if (!set) return
    +	const absolute = path.resolve(cwd, file)
    +	if (isIgnored(absolute)) return
    +	set.add(absolute)
    +}
    +
    +wrapReads(fs, (file) => record(file))
    +
    +/** Beside this module; `.ts` when the plugin runs from source (its own test fixtures). */
    +const recordChild = fileURLToPath(
    +	new URL(
    +		import.meta.url.endsWith('.ts') ? './record-child.ts' : './record-child.js',
    +		import.meta.url,
    +	),
    +)
    +
    +let recordDir: string | undefined
    +let spawned = 0
    +
    +/** Where one child (and its descendants) appends what it loaded. */
    +function recordFile(): string {
    +	recordDir ??= mkdtemp(path.join(os.tmpdir(), 'blacksmith-child-'))
    +	return path.join(recordDir, `${process.pid}-${spawned++}.txt`)
    +}
    +
    +/** The options object of a `child_process` call, inserted when the call had none. */
    +function optionsOf(args: unknown[]): Record<string, unknown> {
    +	let index = args.findIndex(
    +		(arg, i) =>
    +			i > 0 && typeof arg === 'object' && arg !== null && !Array.isArray(arg),
    +	)
    +	if (index === -1) {
    +		index = Array.isArray(args[1]) ? 2 : 1
    +		args.splice(index, 0, {})
     	}
    -	return null
    +	const options = { ...(args[index] as Record<string, unknown>) }
    +	args[index] = options
    +	return options
     }
     
    -function record(target: unknown): void {
    -	const dependencies = (shared[CONTEXT] as Context | undefined)
    -		?.__vitest_worker__?.dependencies
    -	if (!dependencies) return
    -	const file = toPath(target)
    -	if (file === null) return
    -	const absolute = path.resolve(file)
    -	if (absolute.split(path.sep).includes('node_modules')) return
    -	dependencies.add(absolute)
    +interface Child {
    +	/** The record file the child was given, `null` when nothing is being recorded. */
    +	file: string | null
    +	cwd: string
    +}
    +
    +/**
    + * Prepares a `child_process` call: the child gets the recorder preloaded and
    + * a file to report to, and the command plus every argument naming a file is
    + * recorded right away, which is all a non-node child (a shell script, a
    + * binary) can contribute.
    + */
    +function instrument(args: unknown[]): Child {
    +	if (!dependencies()) return { file: null, cwd: process.cwd() }
    +	const options = optionsOf(args)
    +	const cwd =
    +		typeof options.cwd === 'string'
    +			? path.resolve(options.cwd)
    +			: options.cwd instanceof URL
    +				? fileURLToPath(options.cwd)
    +				: process.cwd()
    +	const file = recordFile()
    +	const given = options.env as Record<string, string | undefined> | undefined
    +	const env = { ...(given ?? process.env) }
    +	// `env: { ...process.env, NODE_OPTIONS: undefined }` asks for a child free
    +	// of node options; such a child is left alone and contributes only its
    +	// command line.
    +	const cleared =
    +		given !== undefined &&
    +		Object.prototype.hasOwnProperty.call(given, 'NODE_OPTIONS') &&
    +		given.NODE_OPTIONS === undefined
    +	if (!cleared) {
    +		env[CHILD_RECORD_ENV] = file
    +		env.NODE_OPTIONS = [
    +			env.NODE_OPTIONS,
    +			`--import ${pathToFileURL(recordChild).href}`,
    +		]
    +			.filter(Boolean)
    +			.join(' ')
    +	}
    +	options.env = env
    +	const words = [
    +		...(typeof args[0] === 'string' ? args[0].split(/\s+/) : []),
    +		...(Array.isArray(args[1]) ? args[1] : []),
    +	]
    +	for (const word of words) {
    +		if (typeof word !== 'string' || word === '') continue
    +		const candidate = path.resolve(cwd, word)
    +		try {
    +			if (exists(candidate) && stat(candidate).isFile()) record(candidate)
    +		} catch {}
    +	}
    +	return { file, cwd }
     }
     
    -/** A recursive copy reads every file below its source. */
    -function recordTree(target: unknown): void {
    -	record(target)
    -	const file = toPath(target)
    +/** Records what the exited child reported, relative to its working directory. */
    +function collect({ file, cwd }: Child): void {
     	if (file === null) return
    -	let entries: string[]
    +	let reported: string
     	try {
    -		entries = fs.readdirSync(file, { recursive: true, encoding: 'utf8' })
    +		reported = read(file, 'utf8')
     	} catch {
     		return
    +	} finally {
    +		try {
    +			unlink(file)
    +		} catch {}
     	}
    -	for (const entry of entries) record(path.join(file, entry))
    +	for (const line of reported.split('\n')) if (line !== '') record(line, cwd)
     }
     
     type Wrappable = Record<string, unknown>
     
    -function wrap(
    -	object: Wrappable,
    -	name: string,
    -	recorder: (target: unknown) => void = record,
    -): void {
    -	const original = object[name]
    +function wrapChildProcess(name: string, sync: boolean): void {
    +	const target = childProcess as unknown as Wrappable
    +	const original = target[name]
     	if (typeof original !== 'function' || BRAND in original) return
    -	const wrapped = function (this: unknown, ...args: unknown[]) {
    -		recorder(args[0])
    -		return (original as (...args: unknown[]) => unknown).apply(this, args)
    +	const call = original as (...args: unknown[]) => unknown
    +	const wrapped = sync
    +		? function (this: unknown, ...args: unknown[]) {
    +				const child = instrument(args)
    +				try {
    +					return call.apply(this, args)
    +				} finally {
    +					collect(child)
    +				}
    +			}
    +		: function (this: unknown, ...args: unknown[]) {
    +				const child = instrument(args)
    +				const process = call.apply(this, args) as
    +					| { once?: (event: string, listener: () => void) => unknown }
    +					| undefined
    +				if (typeof process?.once === 'function') {
    +					const done = () => collect(child)
    +					process.once('exit', done)
    +					process.once('error', done)
    +				}
    +				return process
    +			}
    +	// Node's own promisified `exec`/`execFile` call the unwrapped function;
    +	// `promisify(execFile)` must go through the wrapper to reach the child.
    +	if (promisify.custom in original) {
    +		Object.defineProperty(wrapped, promisify.custom, {
    +			value: (...args: unknown[]) =>
    +				new Promise((resolve, reject) => {
    +					wrapped(
    +						...args,
    +						(error: Error | null, stdout: unknown, stderr: unknown) =>
    +							error
    +								? reject(Object.assign(error, { stdout, stderr }))
    +								: resolve({ stdout, stderr }),
    +					)
    +				}),
    +		})

    Promisify wrapper drops child handle

    Medium Severity

    <!-- DESCRIPTION START -->
    The replacement promisify.custom for exec and execFile never sets child on the returned promise. Node attaches the ChildProcess there, and @types/node types it as PromiseWithChild, so tests that use the handle after promisify(execFile) get undefined and throw.
    <!-- DESCRIPTION END -->

    <!-- BUGBOT_BUG_ID: d728abbf-6ad8-41c8-bb07-26c3c7e5bb99 -->

    <!-- LOCATIONS START
    src/record-reads.ts#L200-L213
    LOCATIONS END -->
    <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjVjNGU5YmYxLTkxN2UtNDdlMS04YmFkLTY4NTMzZmE3NDQ1NCIsImVuY3J5cHRpb25LZXkiOiJ3MDVCdmtYMzZ3ZWppRXNqU2F5R2U4bEtiR1RaQnpXQnJhMjVRcWxGWC1zIiwiYnJhbmNoIjoiZGV2aW4vMTc5Mzk5MjUxMy1yZWNvcmQtY2hpbGQtcHJvY2Vzc2VzIiwicmVwb093bmVyIjoidXNlYmxhY2tzbWl0aCIsInJlcG9OYW1lIjoidml0ZXN0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjVjNGU5YmYxLTkxN2UtNDdlMS04YmFkLTY4NTMzZmE3NDQ1NCIsImVuY3J5cHRpb25LZXkiOiJ3MDVCdmtYMzZ3ZWppRXNqU2F5R2U4bEtiR1RaQnpXQnJhMjVRcWxGWC1zIiwiYnJhbmNoIjoiZGV2aW4vMTc5Mzk5MjUxMy1yZWNvcmQtY2hpbGQtcHJvY2Vzc2VzIiwicmVwb093bmVyIjoidXNlYmxhY2tzbWl0aCIsInJlcG9OYW1lIjoidml0ZXN0IiwicHJOdW1iZXIiOjExLCJjb21taXRTaGEiOiI5ZGM5NjFhOTM1Yjk3MjAzY2YwM2NkNzg5OTNjMjVlNjAwNDVlYjAzIiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>

    <sup>Reviewed by Cursor Bugbot for commit 9dc961a935b97203cf03cd78993c25e60045eb03. Configure here.</sup>

    cursor[bot] cursor[bot] commented on Nov 06, 2026 19:48 UTC
    Reviewer

    <!-- BUGBOT_REVIEW -->
    Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

    <!-- BUGBOT_FIX_ALL -->
    <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTowZmMzMGY1Yy0zMzQ4LTQzZDEtODdiZS1kMWViOWE0NDUwYjQiLCJlbmNyeXB0aW9uS2V5IjoiTDZJTFlZY0k1b0pXZk41V0g0MHdVSGxPQkFRSjlaREhLeXlDeGJPWXQ3USIsImJyYW5jaCI6ImRldmluLzE3OTM5OTI1MTMtcmVjb3JkLWNoaWxkLXByb2Nlc3NlcyIsInJlcG9Pd25lciI6InVzZWJsYWNrc21pdGgiLCJyZXBvTmFtZSI6InZpdGVzdCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>
    <!-- /BUGBOT_FIX_ALL -->

    <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN -->
    <sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.</sup>
    <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END -->

    <sup>Reviewed by Cursor Bugbot for commit 9dc961a935b97203cf03cd78993c25e60045eb03. Configure here.</sup>

    devin-ai-integration[bot] devin-ai-integration[bot] commented on code on Nov 06, 2026 19:49 UTC
    Code Review
    src/record-reads.ts:1
    @@ -27,94 +45,184 @@ interface Context {
     	__vitest_worker__?: WorkerState
     }
     
    -// `vmThreads`/`vmForks` evaluate this file once per test context while the
    -// builtin `fs` object is shared, so the wrappers read the worker state through
    -// a slot the latest evaluation points at the current context's global.
    +// The `vm` pools load this file in one context and run tests in another; the
    +// builtin is shared, so it carries the context that holds the worker state.
     const shared = fs as unknown as Record<symbol, unknown>
     shared[CONTEXT] = globalThis
     
    -function toPath(target: unknown): string | null {
    -	if (typeof target === 'string') return target
    -	if (Buffer.isBuffer(target)) return target.toString()
    -	if (target instanceof URL) {
    -		try {
    -			return fileURLToPath(target)
    -		} catch {
    -			return null
    -		}
    +function dependencies(): Set<string> | undefined {
    +	return (shared[CONTEXT] as Context | undefined)?.__vitest_worker__
    +		?.dependencies
    +}
    +
    +function record(file: string, cwd = process.cwd()): void {
    +	const set = dependencies()
    +	if (!set) return
    +	const absolute = path.resolve(cwd, file)
    +	if (isIgnored(absolute)) return
    +	set.add(absolute)
    +}
    +
    +wrapReads(fs, (file) => record(file))
    +
    +/** Beside this module; `.ts` when the plugin runs from source (its own test fixtures). */
    +const recordChild = fileURLToPath(
    +	new URL(
    +		import.meta.url.endsWith('.ts') ? './record-child.ts' : './record-child.js',
    +		import.meta.url,
    +	),
    +)
    +
    +let recordDir: string | undefined
    +let spawned = 0
    +
    +/** Where one child (and its descendants) appends what it loaded. */
    +function recordFile(): string {
    +	recordDir ??= mkdtemp(path.join(os.tmpdir(), 'blacksmith-child-'))
    +	return path.join(recordDir, `${process.pid}-${spawned++}.txt`)
    +}
    +
    +/** The options object of a `child_process` call, inserted when the call had none. */
    +function optionsOf(args: unknown[]): Record<string, unknown> {
    +	let index = args.findIndex(
    +		(arg, i) =>
    +			i > 0 && typeof arg === 'object' && arg !== null && !Array.isArray(arg),
    +	)
    +	if (index === -1) {
    +		index = Array.isArray(args[1]) ? 2 : 1
    +		args.splice(index, 0, {})
     	}
    -	return null
    +	const options = { ...(args[index] as Record<string, unknown>) }
    +	args[index] = options
    +	return options
     }
     
    -function record(target: unknown): void {
    -	const dependencies = (shared[CONTEXT] as Context | undefined)
    -		?.__vitest_worker__?.dependencies
    -	if (!dependencies) return
    -	const file = toPath(target)
    -	if (file === null) return
    -	const absolute = path.resolve(file)
    -	if (absolute.split(path.sep).includes('node_modules')) return
    -	dependencies.add(absolute)
    +interface Child {
    +	/** The record file the child was given, `null` when nothing is being recorded. */
    +	file: string | null
    +	cwd: string
    +}
    +
    +/**
    + * Prepares a `child_process` call: the child gets the recorder preloaded and
    + * a file to report to, and the command plus every argument naming a file is
    + * recorded right away, which is all a non-node child (a shell script, a
    + * binary) can contribute.
    + */
    +function instrument(args: unknown[]): Child {
    +	if (!dependencies()) return { file: null, cwd: process.cwd() }
    +	const options = optionsOf(args)
    +	const cwd =
    +		typeof options.cwd === 'string'
    +			? path.resolve(options.cwd)
    +			: options.cwd instanceof URL
    +				? fileURLToPath(options.cwd)
    +				: process.cwd()
    +	const file = recordFile()
    +	const given = options.env as Record<string, string | undefined> | undefined
    +	const env = { ...(given ?? process.env) }
    +	// `env: { ...process.env, NODE_OPTIONS: undefined }` asks for a child free
    +	// of node options; such a child is left alone and contributes only its
    +	// command line.
    +	const cleared =
    +		given !== undefined &&
    +		Object.prototype.hasOwnProperty.call(given, 'NODE_OPTIONS') &&
    +		given.NODE_OPTIONS === undefined
    +	if (!cleared) {
    +		env[CHILD_RECORD_ENV] = file
    +		env.NODE_OPTIONS = [
    +			env.NODE_OPTIONS,
    +			`--import ${pathToFileURL(recordChild).href}`,
    +		]
    +			.filter(Boolean)
    +			.join(' ')
    +	}
    +	options.env = env
    +	const words = [
    +		...(typeof args[0] === 'string' ? args[0].split(/\s+/) : []),
    +		...(Array.isArray(args[1]) ? args[1] : []),
    +	]
    +	for (const word of words) {
    +		if (typeof word !== 'string' || word === '') continue
    +		const candidate = path.resolve(cwd, word)
    +		try {
    +			if (exists(candidate) && stat(candidate).isFile()) record(candidate)
    +		} catch {}
    +	}
    +	return { file, cwd }
     }
     
    -/** A recursive copy reads every file below its source. */
    -function recordTree(target: unknown): void {
    -	record(target)
    -	const file = toPath(target)
    +/** Records what the exited child reported, relative to its working directory. */
    +function collect({ file, cwd }: Child): void {
     	if (file === null) return
    -	let entries: string[]
    +	let reported: string
     	try {
    -		entries = fs.readdirSync(file, { recursive: true, encoding: 'utf8' })
    +		reported = read(file, 'utf8')
     	} catch {
     		return
    +	} finally {
    +		try {
    +			unlink(file)
    +		} catch {}
     	}
    -	for (const entry of entries) record(path.join(file, entry))
    +	for (const line of reported.split('\n')) if (line !== '') record(line, cwd)
     }
     
     type Wrappable = Record<string, unknown>
     
    -function wrap(
    -	object: Wrappable,
    -	name: string,
    -	recorder: (target: unknown) => void = record,
    -): void {
    -	const original = object[name]
    +function wrapChildProcess(name: string, sync: boolean): void {
    +	const target = childProcess as unknown as Wrappable
    +	const original = target[name]
     	if (typeof original !== 'function' || BRAND in original) return
    -	const wrapped = function (this: unknown, ...args: unknown[]) {
    -		recorder(args[0])
    -		return (original as (...args: unknown[]) => unknown).apply(this, args)
    +	const call = original as (...args: unknown[]) => unknown
    +	const wrapped = sync
    +		? function (this: unknown, ...args: unknown[]) {
    +				const child = instrument(args)
    +				try {
    +					return call.apply(this, args)
    +				} finally {
    +					collect(child)
    +				}
    +			}
    +		: function (this: unknown, ...args: unknown[]) {
    +				const child = instrument(args)
    +				const process = call.apply(this, args) as
    +					| { once?: (event: string, listener: () => void) => unknown }
    +					| undefined
    +				if (typeof process?.once === 'function') {
    +					const done = () => collect(child)
    +					process.once('exit', done)
    +					process.once('error', done)
    +				}
    +				return process
    +			}
    +	// Node's own promisified `exec`/`execFile` call the unwrapped function;
    +	// `promisify(execFile)` must go through the wrapper to reach the child.
    +	if (promisify.custom in original) {
    +		Object.defineProperty(wrapped, promisify.custom, {
    +			value: (...args: unknown[]) =>
    +				new Promise((resolve, reject) => {
    +					wrapped(
    +						...args,
    +						(error: Error | null, stdout: unknown, stderr: unknown) =>
    +							error
    +								? reject(Object.assign(error, { stdout, stderr }))
    +								: resolve({ stdout, stderr }),
    +					)
    +				}),
    +		})

    Good catch. c5f909b sets child on the returned promise the way Node does, and the fixture now asserts pending.child.pid before awaiting.

    Reviewers
    Assignees
    max-blacksmith max-blacksmith
    Labels
    risk: low confidence: 78.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 59.8% (MEDIUM) · Higher = larger blast radius
    59.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 78.3% · Lower = rushed or shallow review
    78.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 13% · Safe to merge
    13%