Skip to content

Commit 5941e05

Browse files
committed
test: tolerate bounded final log mirror
1 parent 97a07f6 commit 5941e05

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

tests/integration/companion.test.mjs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,11 +2090,20 @@ test('background reservation exposes one private invocation, which is single-use
20902090
const privateAuth = { executionCapability: capability, jobId: reserved.json.job.id };
20912091
const first = await companion(context, reserved.json.privateInvocation, {}, privateAuth);
20922092
assert.equal(first.code, 0, first.stderr); assert.equal(first.json.job.status, 'succeeded');
2093+
const terminalResult = first.json.result;
2094+
assert.deepEqual(JSON.parse(terminalResult), { findings: [] });
2095+
const storage = await resolveWorkspaceStorage(context);
2096+
assert.equal(await readFile(join(storage.directory, first.json.job.resultArtifact), 'utf8'), terminalResult);
20932097
const backgroundLog = await readFile(first.json.job.logFile, 'utf8');
2094-
assert.match(backgroundLog, /Assistant message\n[\s\S]*"findings": \[\]/);
2095-
assert.match(backgroundLog, /Final output\n[\s\S]*"findings": \[\]/);
2098+
const assistantBlock = `Assistant message\n${terminalResult}\n`;
2099+
const finalBlock = `Final output\n${terminalResult}\n`;
2100+
assert.equal(backgroundLog.split(assistantBlock).length - 1, 1);
20962101
assert.equal((backgroundLog.match(/Assistant message/g) ?? []).length, 1);
2097-
assert.equal((backgroundLog.match(/Final output/g) ?? []).length, 1);
2102+
// The final block is an observational mirror written after durable success;
2103+
// its bounded append may time out under filesystem load (notably on Windows).
2104+
const finalMirrorCount = backgroundLog.split(finalBlock).length - 1;
2105+
assert.ok([0, 1].includes(finalMirrorCount));
2106+
assert.equal((backgroundLog.match(/Final output/g) ?? []).length, finalMirrorCount);
20982107
assert.doesNotMatch(backgroundLog, /PRIVATE_REASONING|RAW_TOOL_OUTPUT|CAPABILITY_TOKEN/);
20992108
const replay = await companion(context, reserved.json.privateInvocation, {}, privateAuth);
21002109
assert.notEqual(replay.code, 0); assert.equal(replay.json.error.code, 'EXECUTION_CAPABILITY_CONSUMED');

0 commit comments

Comments
 (0)