start_an_engine_member's test helper theRequests parses the fake engine's request log while a line is half-written #223

Open
opened 2026-11-26 02:51:12 +00:00 by mercurius · 0 comments
Member

Purpose (defect): the engine-member tests never fail on a torn read of the fake engine's request log; they wait for whole lines.

Instance: martha-ai/martha#202, PR 211, run 5102 attempt 1, job "gate coverage", task 17025 on host00-martha-bwrap (2026-11-26). src/start_an_engine_member/start_an_engine_member.node-test.ts:687 "#999 package 5: a turn whose usage the engine reports past the handover limit is followed by the handover prompt ...": SyntaxError "Unterminated string in JSON at position 447", from JSON.parse in theRequests (:204) via untilTheEngineHeardPrompts (:567). The same commit passed the case in pass 1, and the PR doesn't touch this file. Mars ruled it a test race.

Shape: theRequests reads the whole file and JSON.parses every non-empty line, the last one included, while the fake engine may still be writing that line. The polling helpers call it in a loop, so one read in the middle of a write throws instead of waiting.

Done when: theRequests parses only newline-terminated lines (it drops a last line that has no trailing newline yet), or the wait helpers treat a parse failure of the last line as "not yet". A test writes a half line first, and the helper waits rather than throws.

Refs #186.

Purpose (defect): the engine-member tests never fail on a torn read of the fake engine's request log; they wait for whole lines. Instance: martha-ai/martha#202, PR 211, run 5102 attempt 1, job "gate coverage", task 17025 on host00-martha-bwrap (2026-11-26). `src/start_an_engine_member/start_an_engine_member.node-test.ts:687` "#999 package 5: a turn whose usage the engine reports past the handover limit is followed by the handover prompt ...": SyntaxError "Unterminated string in JSON at position 447", from JSON.parse in `theRequests` (:204) via `untilTheEngineHeardPrompts` (:567). The same commit passed the case in pass 1, and the PR doesn't touch this file. Mars ruled it a test race. Shape: `theRequests` reads the whole file and `JSON.parse`s every non-empty line, the last one included, while the fake engine may still be writing that line. The polling helpers call it in a loop, so one read in the middle of a write throws instead of waiting. Done when: `theRequests` parses only newline-terminated lines (it drops a last line that has no trailing newline yet), or the wait helpers treat a parse failure of the last line as "not yet". A test writes a half line first, and the helper waits rather than throws. Refs #186.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
martha-ai/martha#223
No description provided.