Repository navigation
Conversation
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.
Problem
Fix
POST /v1/sessions/{id}/purge(scopesessions:write, SDKclient.sessions.purge(id)) closes the session first, so new turns, resumes and restores are refused. It then returns a purge receipt:202while pending,200once completed. Retries return the same receipt.session_purged). Replaying it on a restored older database closes the session, deletes its content again and leaves the purge pending, so the controller finishes it again.packages/db/src/modules/sessions/session-purge.ts: receipt, inventory, finish, replay.packages/server/src/sessions/session-purge.ts: the worker, run on the scheduler interval.drainForPurgeincapacity-idle.ts, reusing the PC-220 drain.managed_sessions.purgecolumn (generated migration).units (2):Cannot find module './session-purge') on the temporary branchtest/pc-206-red, now deleted.packages/server/src/sessions/session-purge.test.ts: restore a session onto a second workspace, purge it, retry the purge, check that both workspaces are purged, the archive folder is empty, an old restore grant gets401, history is empty, resume is refused and the completed receipt repeats.packages/db/src/modules/sessions/session-purge.test.ts: replaying the journal record twice on an older database closes the session, removes its events and leaves the purge pending.packages/serversrc/sessions,src/lifecycle,src/persistence/purge*,packages/dbsrc/modules/sessions,src/recovery,src/modules/budgets,src/journalandpackages/sdkall pass, except one test,native producer retains original results ... shared sessions. It times out after 5 s on that slower host, and it times out the same way on the parent branch without this change.examples/e2e/e2b-session-purge.tsat revision9a2c1d3:session.closed.suspended, and its next turn repeated its token on a third VM.bun run checkandbun run typecheckpass locally. This PR's CI runs the full affected suites.Background
conversationIdsexcludes them), so purging a shared workspace leaves other sessions' history intact.Downsides
managed_sessions.purge).Notes
feature/pc-220-idle-reclaim)..changeset/session-purge.md(CLI and SDK, minor).docs/managed-session-work.md(new Purge section and route table),docs/cleanup.md,docs/api.md.recovery-points-flow.test.tstorecovery-fixture.test.tsso both tests share them.storedInputPurgeandworkspaceInputPurgemoved out ofapp.tsintoattachments/purge-inputs.tsto keepcomposeServerunder the function length limit.