regression: lock durable Session reconnect semantics#953
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b47186ac02
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
dennisonbertram
enabled auto-merge
July 11, 2026 17:41
This was referenced Jul 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Fixes #950. Parent epic: #931.
Durable interactive coding depends on two independent persisted identities: the chat workflow referenced by
chats.activeStreamId, and the Session workspace referenced bysessions.sandboxState.sandboxName. This PR protects the path where a user starts long-running work, disconnects or refreshes, and returns to the same workflow and persistent workspace without duplicate work or a replacement sandbox.The audit found the core durability behavior already correct. One real violation remained: sandbox pause/reconnect/resume failures could echo raw provider messages to logs or API clients, and recovery responses lacked stable typed evidence.
What changed
Characterization and regression coverage
activeStreamId.start()again.session_<sessionId>.alreadyRunningwithout a second reconnect or write.createIfMissingis still limited to the explicit legacy migration path.Small behavior fix
requestIdcorrelation to reconnect and lifecycle responses.sandboxNameandrestoredFromevidence to successful resume responses.sandbox_reconnect_transientsandbox_unavailablesandbox_pause_failedsandbox_resume_state_missingsandbox_resume_unavailablesandbox_resume_failedDocumentation
docs/process/session-durability-proof.mdwith sources of truth, ownership/idempotency rules, safe evidence vocabulary, Level 1 proof, and exact live-provider proof limits.apps/web/SANDBOX-LIFECYCLE.md.docs/agents/lessons-learned.md.TDD audit trail
83e38522 test: characterize durable session reconnect semanticsb47186ac fix: make session recovery evidence safe and typedThis does not manufacture a durability behavior change: stream ownership, workflow starts, sandbox naming, resume policy, and provider connection policy are unchanged.
Out of scope
How it was verified
Focused GREEN suite
Result: 27 passed, 0 failed.
Adjacent durability suite
Result: 200 passed, 0 failed.
Repository gates
bun run --cwd apps/web typecheck— passed.bun --bun run check— passed.git diff --check— passed.bun --bun run ci— all 793 isolated test files passed; all package typechecks passed; migrations are in sync.Browser and live proof
Authenticated Agent Browser reconnect smoke is blocked by configuration in this isolated worktree:
apps/web/.env.localis absent.POSTGRES_URLis absent.BETTER_AUTH_SECRETis absent../init.sh --force-env-pull --verifyattempt stopped with:Vercel project is not linked. Rerun with --link-vercel --vercel-project <name>, or use --offline.The task did not authorize selecting/linking an external Vercel project, so no link was guessed and no authenticated browser claim is made.
Evidence quality and exact proof limits
This PR provides Level 1 deterministic route/workflow/adapter proof. Workflow and Vercel Sandbox calls are doubles. It does not prove:
Level 2 requires configured auth/database state, a disposable repository, a real sandbox name captured before and after resume, workflow/stream evidence across refresh, repository/branch checks inside the resumed sandbox, and redacted browser/server/provider evidence.
Risk and rollback
There is no migration or environment change. Existing clients continue to receive the existing
status,error,success, andalreadyRunningfields; typed metadata is additive. The only copy change replaces raw provider details with safe actionable messages. Rollback is a focused revert of the GREEN commit; existing Session rows, workflow ids, and sandbox names are untouched.The first push hook scanned unrelated files under
.worktrees/create-repo-897and failed on their pre-existing formatting. This branch itself passed full CI, so the documentedSKIP_HOOKS=1bypass was used. No unrelated worktree files were changed.Reviewer guide
docs/process/session-durability-proof.mdfor the contract and proof boundary.apps/web/app/api/chat/[chatId]/stream/route.test.tsfor stream reuse and compare-and-set behavior; production stream routing is intentionally unchanged.apps/web/app/api/sandbox/reconnect/route.tsfor additive correlation/typed warning evidence and redacted structured logs.apps/web/app/api/sandbox/snapshot/route.tsfor persistent-name evidence, typed pause/resume recovery, and provider-message redaction.Please pay particular attention to the fact that transient reconnect failures still preserve runtime state, while hard unavailable errors still clear only the runtime/resume state dictated by existing utility policy.
Open PR overlap audit
apps/web/app/api/chat/route.tsand Session UI, but not the stream route or sandbox lifecycle routes changed here.PLAN.mdand the product planning docs; this PR deliberately leaves those files untouched.