Skip to content

Fix L-01: late 401/410 cannot replace a newer session - #3

Merged
abuzaro21 merged 1 commit into
mainfrom
fix/session-recovery-generation
Oct 30, 2026
Merged

abuzaro21 merged 1 commit into
mainfrom
fix/session-recovery-generation

Conversation

@abuzaro21

@abuzaro21 abuzaro21 commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #2. During live qualification, Codex found L-01: an obsolete request's 410 that arrives after a scenario switch starts another session, and the new scenario then shows proposal not found in this session.

Fix

ui/src/api.ts: each session reset increments a generation counter. A 401/410 from a superseded generation retries under the current session instead of resetting again, so concurrent recoveries coalesce into one reset. The engine, API and policies are unchanged.

Test

New Playwright regression that replays Codex's exact sequence: hold a replay 410, switch to Routine payment, deliver the 410 before the proposal reaches the UI. It fails on v1.0.1 with the original error and passes with the fix. Results: 11/11 E2E, 95/95 unit tests, typecheck clean.

Not deployed. Owner approval is required for v1.0.2.

🤖 Generated with Claude Code

Summary by Sourcery

Ensure obsolete session responses cannot disrupt a newer scenario session during concurrent recovery.

Bug Fixes:

  • Prevent late 401/410 responses from superseded sessions from replacing a newer scenario session.
  • Coalesce concurrent session recovery so obsolete responses retry under the current session.

Documentation:

  • Update the documented Playwright test count from 10 to 11.

Tests:

  • Add a Playwright regression covering a late 410 arriving after a scenario switch.

…cannot replace a newer session

Codex live qualification L-01: an obsolete request's 410 arriving after a scenario switch started another
session, and the new scenario's lookups then read a session that did not own its proposal. Each reset now
bumps a generation; a 401/410 from a superseded generation retries under the current session instead of
resetting again (concurrent recoveries coalesce). Adds the exact browser sequence as a regression test.
Engine, API and policies unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR fixes the L-01 race by associating API requests with session generations: a late 401/410 from an obsolete session now retries under the already-current session instead of triggering another reset, allowing concurrent recovery paths to coalesce. A Playwright regression reproduces the exact delayed-410 scenario-switch sequence, and the README reflects the added test.

Sequence diagram for session generation recovery

sequenceDiagram
    actor User
    participant UI
    participant API
    participant Server

    User->>UI: Replay current decision
    UI->>API: api(POST, replay)
    API->>Server: fetch(replay)
    User->>UI: Click Routine payment
    UI->>API: newSession()
    API->>Server: fetch(/api/session)
    Server-->>API: New session
    Server-->>API: 410 response
    API->>API: api(POST, replay, retried)
    API->>Server: fetch(replay) under current session
    Server-->>API: Successful response
    API-->>UI: Routine payment proposal
Loading

File-Level Changes

Change Details Files
Track session generations to prevent stale 401/410 responses from resetting a newer session.
  • Increment the generation whenever a new session reset starts.
  • Capture the request’s generation before awaiting the session and only initiate recovery when it is still current.
  • Retry obsolete-generation failures against the current session, while preserving 410 restart notifications for current-generation failures.
  • Continue serializing session creation and limit each failed request to one retry.
ui/src/api.ts
Add an end-to-end regression covering the late 410/session-switch race.
  • Hold a replay request’s 410 while switching to the Routine payment scenario.
  • Delay the scenario response so an incorrect extra recovery would affect the result before the proposal is displayed.
  • Verify the newer scenario reaches EXECUTE without an alert.
e2e/judge.spec.ts
Update documented end-to-end test coverage.
  • Increase the documented Playwright test count from 10 to 11.
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 08308cc7-16cc-461e-8195-2894d8c40363
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@abuzaro21
abuzaro21 merged commit 8ff28d8 into main Oct 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants