Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(tests): budget CLI coverage from parsed options
morluto6b180783ed04
diff --git a/docs/testing.md b/docs/testing.mdindex da96fd889..23194a1af 100644--- a/docs/testing.md+++ b/docs/testing.md@@ -110,9 +110,14 @@ rendered declarations. Keep canonical rejection checks separate from theintentionally reduced compact advertisement, and probe actual client rendererswhen changing schema representations.-The reused CLI boundary workers cap V8 old space at 384 MiB, based on their-profiled allocation and cleanup behavior. This encourages collection between-files; spawned REA processes retain their own heap settings.+The reused CLI boundary workers cap V8 old space at 384 MiB for ordinary runs+and 512 MiB with coverage enabled. Covered ADB fixtures exhaust the ordinary+384 MiB budget; those fixtures also complete with the shared CLI graph preloaded+at 512 MiB. This is a measured capacity control, not a suite-wide speedup claim.+Both profiles keep the+same bounded worker count, and spawned REA processes retain their own heap+settings. Explicitly disabling coverage retains the ordinary profile; coverage+provider options alone do not enable instrumentation.Vitest worker limits do not bound subprocesses launched within a test. Boundthose batches separately so repeated CLI validation cannot oversubscribe thediff --git a/tests/boundary/filesystem/ciTestProjects.test.ts b/tests/boundary/filesystem/ciTestProjects.test.tsindex f0394c5bb..0159a3910 100644--- a/tests/boundary/filesystem/ciTestProjects.test.ts+++ b/tests/boundary/filesystem/ciTestProjects.test.ts@@ -1,6 +1,7 @@import { execFileSync } from "node:child_process";-import { readFile } from "node:fs/promises";+import { readFile, writeFile } from "node:fs/promises";import { join } from "node:path";+import { pathToFileURL } from "node:url";import { describe, expect, it } from "vitest";import {@@ -13,6 +14,9 @@ import {parseDevelopmentTestRequest,} from "../../../scripts/lib/development-tests.mjs";+import { execFileOutput } from "../../../src/process/ExecFileOutput.js";+import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";+const repository = process.cwd();describe("canonical test-project ownership", () => {@@ -72,4 +76,68 @@ describe("canonical test-project ownership", () => {expect(config).toContain("PROJECT_POLICIES");expect(config).not.toContain('"src/{contracts,domain}/**/*.test.ts"');});++ it.each([+ { flags: [], heap: 384, timeout: 30_000, lines: 68 },+ { flags: ["--coverage"], heap: 512, timeout: 60_000, lines: 68 },+ { flags: ["--coverage.enabled"], heap: 512, timeout: 60_000, lines: 68 },+ { flags: ["--coverage=false"], heap: 384, timeout: 30_000, lines: 68 },+ {+ flags: ["--coverage.enabled=false"],+ heap: 384,+ timeout: 30_000,+ lines: 68,+ },+ {+ flags: ["--coverage.provider=v8"],+ heap: 384,+ timeout: 30_000,+ lines: 68,+ },+ {+ flags: ["--coverage.enabled", "--shard", "1/6"],+ heap: 512,+ timeout: 60_000,+ lines: 0,+ },+ {+ flags: ["--coverage.enabled=false", "--shard=1/6"],+ heap: 384,+ timeout: 30_000,+ lines: 0,+ },+ ])(+ "resolves worker resources from actual CLI options: $flags",+ async ({ flags, heap, timeout, lines }) => {+ const root = await createTestTempDirectory("rea-vitest-worker-policy-");+ const script = join(root, "worker-policy.mjs");+ await writeFile(+ script,+ `+ import config from ${JSON.stringify(pathToFileURL(join(repository, "vitest.config.ts")).href)};+ const project = config.test.projects.find(project => project.test.name === 'cli-boundary');+ console.log(JSON.stringify({+ execArgv: project.test.execArgv,+ timeout: config.test.testTimeout,+ lines: config.test.coverage.thresholds.lines,+ }));+ `,+ );+ const result = await execFileOutput(+ process.execPath,+ ["--import", "tsx", script, ...flags],+ {+ cwd: repository,+ timeout: 10_000,+ maxBuffer: 64 * 1024,+ stopSignal: "SIGTERM",+ },+ );+ expect(JSON.parse(result.stdout)).toEqual({+ execArgv: [`--max-old-space-size=${String(heap)}`],+ timeout,+ lines,+ });+ },+ );});diff --git a/vitest.config.ts b/vitest.config.tsindex 2c034beb2..6f733c987 100644--- a/vitest.config.ts+++ b/vitest.config.ts@@ -3,6 +3,7 @@ import { availableParallelism, tmpdir } from "node:os";import { join } from "node:path";import { defineConfig } from "vitest/config";+import { parseCLI } from "vitest/node";import {BUILT_TEST_PROJECTS,SOURCE_TEST_PROJECTS,@@ -23,12 +24,14 @@ if (}const CANONICAL_TEMPORARY_DIRECTORY = realpathSync(tmpdir());-const COVERAGE_ENABLED = process.argv.some((argument) =>- argument.startsWith("--coverage"),-);-const COVERAGE_SHARD = process.argv.some((argument) =>- argument.startsWith("--shard="),+// Use Vitest's option parser so explicit false and spaced shard values retain+// their meaning. Unknown worker/embedding arguments are not Vitest options.+const { options: testOptions } = parseCLI(+ ["vitest", ...process.argv.slice(2)],+ { allowUnknownOptions: true },);+const COVERAGE_ENABLED = testOptions.coverage?.enabled === true;+const COVERAGE_SHARD = testOptions.shard !== undefined;// Keep local and CI concurrency bounded by the runner rather than command locks.const MAX_TEST_WORKERS = Math.min(2, availableParallelism());@@ -63,9 +66,10 @@ const PROJECT_POLICIES = {// CLI tests create fresh command instances or subprocesses and own their// cleanup. Reuse the immutable graph; module mocks belong in process-global.isolate: false,- // Long-lived workers should collect temporary command/schema allocations- // before their two heaps compete with the real CLI child processes.- execArgv: ["--max-old-space-size=384"],+ // Coverage of the shared command/schema graph exhausts the ordinary+ // 384 MiB budget. The preloaded CLI/ADB control completes with 512 MiB;+ // keep both profiles bounded with the same concurrency.+ execArgv: [`--max-old-space-size=${COVERAGE_ENABLED ? "512" : "384"}`],},"process-boundary": {pool: "forks" as const,