Skip to content

Commit 0087ee8

Browse files
test(e2e): overflow recovery — gate the no-more-main-calls assertion on the fold actually failing
The fail-closed gate deliberately proceeds when the recovery pass's forced historian publishes and the fold materializes in that same pass (aborting would interrupt a now-healthy compacted request). The test asserted zero new main-model calls unconditionally, which only passed when machine load made the in-test historian time out; on a quiet box the historian publishes instantly, the fold lands, and proceeding is the designed behavior. Assert the abort holds the line only while needs_emergency_recovery is still set; the success path is proven by the existing end-state assertions. Co-authored-by: Alfonso <alfonso-magic-context@users.noreply.github.com>
1 parent 3b9f6ec commit 0087ee8

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

packages/e2e-tests/tests/overflow-recovery.test.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,22 @@ describe("context overflow recovery", () => {
243243
// prompt's own resolution.
244244
}
245245
if (recoveryWasPendingBeforeFollowup) {
246-
// The fail-closed transform must interrupt the run before OpenCode
247-
// emits another doomed main-model request. Historian traffic is
248-
// counted separately by the matcher above.
249-
expect(mainCalls).toBe(mainCallsBeforeFollowup);
246+
const recoveryStillPending = (readState().needs_emergency_recovery ?? 0) === 1;
247+
if (recoveryStillPending) {
248+
// The historian did not publish, so the prompt is still the
249+
// doomed shape: the fail-closed transform must interrupt the
250+
// run before OpenCode emits another main-model request.
251+
// Historian traffic is counted separately by the matcher above.
252+
expect(mainCalls).toBe(mainCallsBeforeFollowup);
253+
}
254+
// Otherwise the recovery pass force-fired the historian, blocked
255+
// until it published, and the fold materialized in that same pass
256+
// — the prompt is compacted and no longer doomed, so the
257+
// fail-closed gate deliberately lets the request proceed
258+
// (aborting after a successful in-pass fold would interrupt a
259+
// healthy request). Main-model calls advancing is the success
260+
// path here; the end-state assertions below prove the recovery
261+
// actually completed rather than leaked.
250262
}
251263

252264
// Wait for the recovery cycle to complete. End state evidence:

0 commit comments

Comments
 (0)