test(runner): bound the retirement journal reserve and drop code comments

Address review: assert command 564 is accepted, 565 is rejected for retirement
and read commands, and a rejection leaves the journal unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
paperclipbugbotandClaude Opus 5.5 committed 2026-12-04 05:21:07 +00:00
1 parent 3e72d97be6
commit 3c6fe49e80
2 files changed
+21 -7

No files matched your search

@@ -108,9 +108,6 @@ function fillAndRetireCommandJournal(core: DurablePrpControlPlane): void {
}
it("keeps room to retire a session whose work filled the command journal", async () => {
// A long run can journal one semantic tool result per call until the work
// bound is reached. The next run must still be able to stop, drain, suspend
// and close that session, or every successor fails predecessor retirement.
const root = mkdtempSync(resolve(tmpdir(), "runner-full-journal-retirement-"));
const core = new DurablePrpControlPlane({ stateDirectory: root, identity, expectedRunnerVersion, expectedRunnerDigest });
let reopened: DurablePrpControlPlane | undefined;
@@ -128,6 +125,27 @@ it("keeps room to retire a session whose work filled the command journal", async
}
});
it("bounds the retirement reserve and leaves the journal unchanged when it is full", async () => {
const root = mkdtempSync(resolve(tmpdir(), "runner-full-journal-reserve-bound-"));
const core = new DurablePrpControlPlane({ stateDirectory: root, identity, expectedRunnerVersion, expectedRunnerDigest });
try {
fillAndRetireCommandJournal(core);
for (let index = 504; index < 563; index += 1) {
core.queueCommand("runner.suspend", {}, `command_retire_suspend_${index}`);
}
expect(core.store.state.commands).toHaveLength(563);
expect(core.queueCommand("session.close", {}, "command_retire_last").controllerSeq).toBe(564);
expect(core.store.state.commands).toHaveLength(564);
const before = JSON.stringify(core.store.state.commands);
expect(() => core.queueCommand("runner.suspend", {}, "command_retire_overflow")).toThrow("command_journal_full");
expect(() => core.queueCommand("session.snapshot")).toThrow("command_journal_full");
expect(JSON.stringify(core.store.state.commands)).toBe(before);
} finally {
await core.stop();
rmSync(root, { recursive: true, force: true });
}
});
it("checkpoints a retired session whose work filled the command journal", async () => {
const root = mkdtempSync(resolve(tmpdir(), "runner-full-journal-checkpoint-"));
const core = new DurablePrpControlPlane({ stateDirectory: root, identity, expectedRunnerVersion, expectedRunnerDigest });
@@ -67,10 +67,6 @@ const maxFrameBytes = 1024 * 1024;
const maxCommandBytes = Math.floor((maxFrameBytes - 4 * 1024) / 2);
const RUN_ATTACH_ENVELOPE_BYTES = 32 * 1024;
const maxCommands = 500;
// Work commands (tool results, turns, reads) stop at maxCommands. A session
// whose work fills that bound must still be stoppable and retirable by the
// next run, so these commands keep a separate bounded reserve. Each close
// attempt issues at most a stop, a drain and a few suspends.
const retirementCommandTypes = new Set([
"turn.stop", "runner.drain", "runner.suspend", "runner.shutdown", "session.close", "session.destroy", "run.cancel",
]);