From f9f798f32070e753ef11abba6b6609419af614f5 Mon Sep 17 00:00:00 2001 From: Dotta Date: Thu, 3 Sep 2026 08:34:08 -0500 Subject: [PATCH] test(runner): allow accepted plan ACPX session resets --- tests/runner-e2e/run-observations.ts | 55 +++++++++++++++++++--------- tests/runner-e2e/runner.spec.ts | 11 ++++++ tests/runner-e2e/support.test.ts | 19 ++++++++++ 3 files changed, 68 insertions(+), 17 deletions(-) diff --git a/tests/runner-e2e/run-observations.ts b/tests/runner-e2e/run-observations.ts index f8883ad6b0..90d4312f19 100644 --- a/tests/runner-e2e/run-observations.ts +++ b/tests/runner-e2e/run-observations.ts @@ -15,6 +15,37 @@ export interface ObservableProviderSessionRun { contextSnapshot?: Record | null; } +export function acceptedPlanSessionResetFailures( + provider: "codex" | "opencode" | "acpx", + previousSessionId: string | null | undefined, + current: ObservableProviderSessionRun, +): string[] | null { + const context = record(current.contextSnapshot); + const acceptedPlanReset = + context.forceFreshSession === true && + context.workspaceRefreshReason === "accepted_plan_confirmation" && + context.source === "issue.interaction.accept" && + context.interactionStatus === "accepted"; + if (!acceptedPlanReset) return null; + + const failures: string[] = []; + if (current.sessionIdBefore) { + failures.push( + `expected accepted Plan run ${current.id} to start without a prior provider session`, + ); + } + if ( + previousSessionId && + current.sessionIdAfter && + current.sessionIdAfter === previousSessionId + ) { + failures.push( + `expected accepted Plan run ${current.id} to rotate the ${provider} provider session`, + ); + } + return failures; +} + function record(value: unknown): Record { return value && typeof value === "object" && !Array.isArray(value) ? (value as Record) @@ -89,23 +120,13 @@ export function providerSessionContinuityFailures( if (index === 0) continue; const previousSessionId = runs[index - 1]?.sessionIdAfter; - const context = record(current.contextSnapshot); - const acceptedPlanReset = - context.forceFreshSession === true && - context.workspaceRefreshReason === "accepted_plan_confirmation" && - context.source === "issue.interaction.accept" && - context.interactionStatus === "accepted"; - if (acceptedPlanReset) { - if (current.sessionIdBefore) { - failures.push( - `expected accepted Plan run ${current.id} to start without a prior provider session`, - ); - } - if (previousSessionId && currentSessionId === previousSessionId) { - failures.push( - `expected accepted Plan run ${current.id} to rotate the ${provider} provider session`, - ); - } + const acceptedPlanResetFailures = acceptedPlanSessionResetFailures( + provider, + previousSessionId, + current, + ); + if (acceptedPlanResetFailures) { + failures.push(...acceptedPlanResetFailures); continue; } diff --git a/tests/runner-e2e/runner.spec.ts b/tests/runner-e2e/runner.spec.ts index 2ac70bd877..a21b45a50e 100644 --- a/tests/runner-e2e/runner.spec.ts +++ b/tests/runner-e2e/runner.spec.ts @@ -10,6 +10,7 @@ import { runnerE2EServerControlPaths } from "./harness-env.js"; import { setupLiveFixtures, type LiveFixtureValues } from "./live-fixtures.js"; import { evaluateMatcher, type MatcherResult } from "./matchers.js"; import { + acceptedPlanSessionResetFailures, isControlPlaneGovernedResponseWait, isNonExecutingReviewFenceRun, numberedPlanStepCount, @@ -1542,6 +1543,16 @@ for (const execution of executions) { ); continue; } + const acceptedPlanResetFailures = + acceptedPlanSessionResetFailures( + "acpx", + previousSessionId, + current, + ); + if (acceptedPlanResetFailures) { + invariantFailures.push(...acceptedPlanResetFailures); + continue; + } if (previousSessionId === currentSessionId) continue; const currentEvents = runEventsByRun.find((captured) => captured.runId === current.id) diff --git a/tests/runner-e2e/support.test.ts b/tests/runner-e2e/support.test.ts index d966aac661..ab7983e517 100644 --- a/tests/runner-e2e/support.test.ts +++ b/tests/runner-e2e/support.test.ts @@ -8,6 +8,7 @@ import { RunnerApi } from "./api.js"; import { FixtureRegistry } from "./fixture-registry.js"; import { classifyFailure, shouldRetryFailure } from "./failure-classifier.js"; import { + acceptedPlanSessionResetFailures, assertIsolatedServerEnvironment, buildPaperclipServerEnvironment, resolvePaperclipRunnerBinaryForHarness, @@ -415,6 +416,24 @@ describe("runner E2E run observations", () => { ).toEqual([ "expected codex to preserve its provider session for run resumed", ]); + expect( + acceptedPlanSessionResetFailures( + "acpx", + initial.sessionIdAfter, + acceptedPlan, + ), + ).toEqual([]); + expect( + acceptedPlanSessionResetFailures("acpx", initial.sessionIdAfter, { + ...acceptedPlan, + sessionIdBefore: initial.sessionIdAfter, + }), + ).toEqual([ + "expected accepted Plan run accepted-plan to start without a prior provider session", + ]); + expect( + acceptedPlanSessionResetFailures("acpx", initial.sessionIdAfter, resumed), + ).toBeNull(); }); });