diff --git a/codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml b/codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml new file mode 100644 index 000000000..5506593d8 --- /dev/null +++ b/codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml @@ -0,0 +1,17 @@ +id: bugfix-1946 +title: windows-bugfix-1814-check-time +protocol: bugfix +phase: pr +plan_phases: [] +current_plan_phase: null +gates: + pr: + status: approved + requested_at: '2026-11-22T22:11:04.150Z' + approved_at: '2026-11-22T22:19:19.584Z' +iteration: 1 +build_complete: false +history: [] +started_at: '2026-11-22T21:53:06.605Z' +updated_at: '2026-11-22T22:19:19.585Z' +pr_ready_for_human: false diff --git a/codev/state/bugfix-1946_thread.md b/codev/state/bugfix-1946_thread.md new file mode 100644 index 000000000..7a6254f70 --- /dev/null +++ b/codev/state/bugfix-1946_thread.md @@ -0,0 +1,21 @@ +# bugfix-1946 thread + +## Investigate +- File passes alone on this host (12 passed, 3 skipped). +- Reproduced under synthetic load (2x cores busy node workers + 8 loops launching cmd.exe), 300ms timeout: + `sleep 3` -> 4454 / 3429 / 3187 ms (fails the 2500ms bound); `sleep 30` -> 2905 / 3199 / 3434 ms. +- So the kill lands late (~3s: census + job terminate + taskkill, each a process launch), it does not fail to land. + No product bug; no escalation. +- Root cause is the test: with a 3s sleep the check can end on its own inside the teardown window and still + report "Timed out" (`killed` is set when the timer fires, checks.ts:115), so 2500ms can't tell late kill from no kill. +- Plan: sleep 30 in the three tests; bound 2500ms on POSIX, 15000ms on win32 (half the sleep, ~4x the worst + observed); assert the bound in all three; per-test timeout 45s so a missing kill fails on the bound, not on a timeout. + +## Fix +- Test-only change in bugfix-1814-check-timeout.test.ts; checks.ts untouched. +- Mutation check: with the timeout's killGroup calls removed, all three tests fail at ~30.1s against the 15s bound. +- Full suite on this host, one run at a time, Tower PID 53132 before and after each: + run 1 via `porch done` (build 51.7s, tests 146.6s, passed first try); runs 2 and 3 `npm test`: + 406 files passed / 9 skipped, 8110 tests passed / 247 skipped, both. +- Side note (not changed, out of scope): runCheck reports "Timed out" whenever the timer fired, even if the + command then exited on its own before the kill landed (`killed` is set at checks.ts:115). diff --git a/packages/codev/src/commands/porch/__tests__/bugfix-1814-check-timeout.test.ts b/packages/codev/src/commands/porch/__tests__/bugfix-1814-check-timeout.test.ts index 4314f5b7b..b6e31fd60 100644 --- a/packages/codev/src/commands/porch/__tests__/bugfix-1814-check-timeout.test.ts +++ b/packages/codev/src/commands/porch/__tests__/bugfix-1814-check-timeout.test.ts @@ -15,6 +15,20 @@ import { logCheckOverrides } from '../index.js'; const env: CheckEnv = { PROJECT_ID: '1814', PROJECT_TITLE: 'check-timeout' }; +/** + * A check that only a kill can end early (#1946). With a 3-second sleep the check could finish on its own + * inside a slow Windows teardown and still report "Timed out", so a late kill and no kill looked the same. + */ +const SLOW_COMMAND = 'sleep 30'; +/** + * How soon a 300ms timeout must end the check. On Windows the teardown is a census, a job termination and a + * taskkill, each its own process launch: about 3s under full-suite load (#1946), so the bound is half the + * sleep. POSIX signals the process group directly and keeps the tight bound. + */ +const KILLED_WITHIN_MS = process.platform === 'win32' ? 15_000 : 2500; +/** Long enough that a check nobody killed fails on KILLED_WITHIN_MS, not on the test timeout. */ +const SLOW_TEST_TIMEOUT_MS = 45_000; + function writeProtocol(root: string, checks: Record, defaults?: unknown): void { const dir = path.join(root, 'codev/protocols/timeouts'); fs.mkdirSync(dir, { recursive: true }); @@ -62,7 +76,7 @@ describe('bugfix #1814: per-check timeout_ms', () => { }); it('a protocol.json timeout_ms reaches the runner and kills the check at that value', async () => { - writeProtocol(root, { tests_py: { command: 'sleep 3', timeout_ms: 300 } }); + writeProtocol(root, { tests_py: { command: SLOW_COMMAND, timeout_ms: 300 } }); const checks = getPhaseChecks(loadProtocol(root, 'timeouts'), 'implement'); expect(checks.tests_py.timeout_ms).toBe(300); @@ -70,8 +84,8 @@ describe('bugfix #1814: per-check timeout_ms', () => { const [result] = await runPhaseChecks(checks, root, env); expect(result.passed).toBe(false); expect(result.error).toContain('Timed out after 0.3s'); - expect(result.duration_ms).toBeLessThan(2500); - }, 15_000); + expect(result.duration_ms).toBeLessThan(KILLED_WITHIN_MS); + }, SLOW_TEST_TIMEOUT_MS); it('a timeout_ms in defaults.checks is parsed too', () => { writeProtocol(root, {}, { checks: { tests_py: { command: 'x', timeout_ms: 900_000 } } }); @@ -80,19 +94,21 @@ describe('bugfix #1814: per-check timeout_ms', () => { }); it('a check without timeout_ms keeps the runner default', async () => { - writeProtocol(root, { build: { command: 'sleep 3' } }); + writeProtocol(root, { build: { command: SLOW_COMMAND } }); const checks = getPhaseChecks(loadProtocol(root, 'timeouts'), 'implement'); expect(checks.build.timeout_ms).toBeUndefined(); const [result] = await runPhaseChecks(checks, root, env, 300); expect(result.error).toContain('Timed out after 0.3s'); - }, 15_000); + expect(result.duration_ms).toBeLessThan(KILLED_WITHIN_MS); + }, SLOW_TEST_TIMEOUT_MS); it('a check timeout_ms takes precedence over the runPhaseChecks default', async () => { - const [result] = await runPhaseChecks({ slow: { command: 'sleep 3', timeout_ms: 300 } }, root, env, 60_000); + const [result] = await runPhaseChecks({ slow: { command: SLOW_COMMAND, timeout_ms: 300 } }, root, env, 60_000); expect(result.error).toContain('Timed out after 0.3s'); - }, 15_000); + expect(result.duration_ms).toBeLessThan(KILLED_WITHIN_MS); + }, SLOW_TEST_TIMEOUT_MS); it.each([0, -1, 1.5, '900000', 2 ** 31])('rejects timeout_ms %j at load', (value) => { writeProtocol(root, { tests_py: { command: 'x', timeout_ms: value } });