From fef5159683f20d0a715d812c35c89eede8208100 Mon Sep 17 00:00:00 2001 From: Amr Elsayed Date: Mon, 23 Nov 2026 08:53:07 +1100 Subject: [PATCH 1/8] chore(porch): bugfix-1946 init bugfix --- .../status.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml 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..5e6b545ae --- /dev/null +++ b/codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml @@ -0,0 +1,14 @@ +id: bugfix-1946 +title: windows-bugfix-1814-check-time +protocol: bugfix +phase: investigate +plan_phases: [] +current_plan_phase: null +gates: + pr: + status: pending +iteration: 1 +build_complete: false +history: [] +started_at: '2026-11-22T21:53:06.605Z' +updated_at: '2026-11-22T21:53:06.606Z' From 98461f1e69563ce9b72a76021c49f545bd142b1d Mon Sep 17 00:00:00 2001 From: Amr Elsayed Date: Mon, 23 Nov 2026 08:56:33 +1100 Subject: [PATCH 2/8] chore(porch): bugfix-1946 fix phase-transition --- .../bugfix-1946-windows-bugfix-1814-check-time/status.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 5e6b545ae..f1aa29e5b 100644 --- a/codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml +++ b/codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml @@ -1,7 +1,7 @@ id: bugfix-1946 title: windows-bugfix-1814-check-time protocol: bugfix -phase: investigate +phase: fix plan_phases: [] current_plan_phase: null gates: @@ -11,4 +11,4 @@ iteration: 1 build_complete: false history: [] started_at: '2026-11-22T21:53:06.605Z' -updated_at: '2026-11-22T21:53:06.606Z' +updated_at: '2026-11-22T21:56:33.509Z' From 10ad4fd49cf9c1236662451c8d63adabaa0b7027 Mon Sep 17 00:00:00 2001 From: Amr Elsayed Date: Mon, 23 Nov 2026 08:58:56 +1100 Subject: [PATCH 3/8] [Bugfix #1946] Test: check-timeout tests tell a late kill from no kill The three bugfix-1814 timeout tests slept 3s under a 300ms timeout and bounded the check at 2500ms. On Windows the teardown (census, job termination, taskkill) takes ~3s under full-suite load, so the sleep could finish on its own and still report "Timed out". Sleep 30s instead, bound the check at 15s on win32 (2500ms on POSIX), assert the bound in all three tests, and give them a 45s test timeout so a check nobody killed fails on the bound. Test-only: porch's timeout behaviour is unchanged. With the kill disabled, all three fail at ~30s against the 15s bound. --- .../bugfix-1814-check-timeout.test.ts | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) 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 } }); From 69a068991e68db71ef5b052c12918254b0efcc6d Mon Sep 17 00:00:00 2001 From: Amr Elsayed Date: Mon, 23 Nov 2026 08:58:56 +1100 Subject: [PATCH 4/8] [Bugfix #1946] Thread: investigation notes --- codev/state/bugfix-1946_thread.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 codev/state/bugfix-1946_thread.md diff --git a/codev/state/bugfix-1946_thread.md b/codev/state/bugfix-1946_thread.md new file mode 100644 index 000000000..e82b1304b --- /dev/null +++ b/codev/state/bugfix-1946_thread.md @@ -0,0 +1,12 @@ +# 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. From f830a5a090e36c8bdf37880ed968d0463841248c Mon Sep 17 00:00:00 2001 From: Amr Elsayed Date: Mon, 23 Nov 2026 09:02:33 +1100 Subject: [PATCH 5/8] chore(porch): bugfix-1946 pr phase-transition --- .../bugfix-1946-windows-bugfix-1814-check-time/status.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index f1aa29e5b..9da1629a4 100644 --- a/codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml +++ b/codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml @@ -1,7 +1,7 @@ id: bugfix-1946 title: windows-bugfix-1814-check-time protocol: bugfix -phase: fix +phase: pr plan_phases: [] current_plan_phase: null gates: @@ -11,4 +11,4 @@ iteration: 1 build_complete: false history: [] started_at: '2026-11-22T21:53:06.605Z' -updated_at: '2026-11-22T21:56:33.509Z' +updated_at: '2026-11-22T22:02:33.268Z' From 0800439b544e1ee0486727fe7834180ca6038055 Mon Sep 17 00:00:00 2001 From: Amr Elsayed Date: Mon, 23 Nov 2026 09:08:15 +1100 Subject: [PATCH 6/8] [Bugfix #1946] Thread: fix and full-suite results --- codev/state/bugfix-1946_thread.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/codev/state/bugfix-1946_thread.md b/codev/state/bugfix-1946_thread.md index e82b1304b..7a6254f70 100644 --- a/codev/state/bugfix-1946_thread.md +++ b/codev/state/bugfix-1946_thread.md @@ -10,3 +10,12 @@ 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). From a277de26caac917211b785de1f836c3e05cfcf64 Mon Sep 17 00:00:00 2001 From: Amr Elsayed Date: Mon, 23 Nov 2026 09:11:04 +1100 Subject: [PATCH 7/8] chore(porch): bugfix-1946 pr gate-requested --- .../bugfix-1946-windows-bugfix-1814-check-time/status.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 index 9da1629a4..68651f5ae 100644 --- a/codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml +++ b/codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml @@ -7,8 +7,10 @@ current_plan_phase: null gates: pr: status: pending + requested_at: '2026-11-22T22:11:04.150Z' iteration: 1 build_complete: false history: [] started_at: '2026-11-22T21:53:06.605Z' -updated_at: '2026-11-22T22:02:33.268Z' +updated_at: '2026-11-22T22:11:04.151Z' +pr_ready_for_human: true From 7470cd1415bea38b2fb38aae84a74a494e918294 Mon Sep 17 00:00:00 2001 From: Amr Elsayed Date: Mon, 23 Nov 2026 09:19:20 +1100 Subject: [PATCH 8/8] chore(porch): bugfix-1946 pr gate-approved --- .../bugfix-1946-windows-bugfix-1814-check-time/status.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 index 68651f5ae..5506593d8 100644 --- a/codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml +++ b/codev/projects/bugfix-1946-windows-bugfix-1814-check-time/status.yaml @@ -6,11 +6,12 @@ plan_phases: [] current_plan_phase: null gates: pr: - status: pending + 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:11:04.151Z' -pr_ready_for_human: true +updated_at: '2026-11-22T22:19:19.585Z' +pr_ready_for_human: false