feat(storage): implement production session snapshots - #4361
Merged
MicroGery merged 1 commit intoSep 1, 2026
Conversation
Generated-by: OpenAI Codex
Astro-Han
approved these changes
Sep 1, 2026
Astro-Han
left a comment
Contributor
There was a problem hiding this comment.
Thanks for this — the composition is tight and the identity binding is the right call.
Verified against head db23cff898:
- Budget reservation matches the codec.
reserveStateBundleBudgetreserves the recursive state entry count plus 3 (state-identity.json,state/,workspace/), which is exactly whatpackSessionBundleends up counting, so the workspace copy is bounded by the real remaining quota rather than discovering the overflow after copying. - The copy window is closed.
O_NOFOLLOWdegrades to 0 on Windows, butcopyWorkspaceFilecompares the pre-openlstatfingerprint (dev/ino/size/mtimeNs/ctimeNs) against the post-openfstat, so a symlink swap changes the inode and fails assource_changed. Directories are fingerprinted on entry and exit. - Exposing
recover()is safe.session-copy-cleanup.ts:197skips records whoseownerLifetimeRefis this process, so a host callingrecover()during an in-flightprepare()cannot delete its own staging. - Root separation is consistent with the existing
assertActivationRootLayoutcontract, not a new constraint on deployments.
Four non-blocking observations, all fine as follow-ups:
production-session-snapshot.ts:337-347— whenbundleFileService.packsucceeds butprepared.release()rejects, the successful artifact is discarded and the error thrown. The Bundle is still on disk atdestination, so retrying the same path fails permanently inassertDestinationMissing. SincePreparedSessionBundleHandledocuments release failures as retryable and the staging lease self-heals on the nextrecover(), returning the artifact and surfacing the cleanup failure separately would lose nothing.packages/runtime/src/quiescent-session-snapshot.ts:92-112— the catch rewrites every non-SessionSnapshotErrorfromoperation()asio_failure/phase: 'admission'. Thesignal.throwIfAborted()calls inresolveWorkspaceConfirmationraise a bareAbortErrorthatnormalizePreparationErrorwould otherwise map tosnapshot_cancelled. Mapping onlySessionQuiescentMutationBusyErrorand rethrowing the rest would keep the coordinator's normalization intact.production-session-snapshot.ts:612-628— names that are legal on POSIX but unrepresentable in USTAR V1 (aux, trailing./space,\ : * ? " < > |) fail the whole snapshot under the sameunsafe_pathcategory as symlinks, with no path or count indetails. Fail-closed looks right given the current exclusion enum, but a distinct category or anobservedcounter would make it locatable.production-session-snapshot.ts:125,260,274,281-289,312— the coordinator runsprepareState→prepareWorkspaceinside one serialized quiescence lane, so the staging-root-keyedMap, thedirname()keying, thefinally { clear() }, and the publicremainingLimitsForDestinationRootoption could collapse into a single closure variable.
Review assistance: Claude (Claude Code) traced the production path and cross-checked the quota accounting, copy-window checks, and cleanup ownership against current main; I reviewed and confirmed those findings myself and own this approval.
abhinav-phi
pushed a commit
to abhinav-phi/maka
that referenced
this pull request
Sep 1, 2026
Generated-by: OpenAI Codex
19 tasks
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.
Summary
Implements PR 2 of #2369: the production path that turns a live, quiescent Session into a private Bundle staging snapshot.
Refs #2369
Security / review focus
The production factory is deliberately single-Session. It rejects overlapping state/config/workspace/staging/cleanup roots and does not expose the raw coordinator, preventing a caller from pairing one Session state with another Session workspace.
The Runtime adapter now requires a Host eligibility check for mutable states outside the Runtime Kernel execution claims. The Host remains responsible for making that authority cover its pending approvals, background work, and external-resume paths.
Verification
AI use
Tool(s) and scope: OpenAI Codex assisted with implementation, adversarial review, regression tests, and local verification. The contributor reviewed the changes and remains responsible for their accuracy, provenance, and licensing.
Checklist
Does this PR entail a change in behavior?