fix(storage): batch retired Session artifact cleanup - #4984
Draft
99Gaoxiaoqi wants to merge 1 commit into
Draft
Conversation
Resolve Artifact alias guards once per retirement batch and commit successful Session deletions together. Preserve independent unlink and directory-sync failures, cross-Session alias protection, and durable cleanup retry obligations. Fixes apache#4038 Generated-by: Codex
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
Retiring M Sessions previously performed M serialized full-store Artifact path scans. Resolve one locked Artifact snapshot per retirement batch, retain the bounded resolver concurrency, and commit the successful Sessions' metadata deletions in one transaction.
Keep per-Session unlink and directory-sync failures independent: successful siblings can finish, while failed Sessions retain their existing retirement cleanup obligations for retry. A global guard-resolution or metadata-commit failure prevents the batch from reporting success. Cross-Session aliases remain protected, including aliases between two Sessions in the same retiring batch. The single-Session purge API delegates to the batch implementation.
Fixes #4038
Verification
npm run build— passed.npm run typecheck— passed across all workspaces.npm run lintandnpm run format:check— passed.npx knip --workspace apps/desktopandnpx knip --workspace packages/ui— passed.npm --workspace @maka/storage run test:dist— 1,207 passed, 8 skipped, 0 failed.git diff --check— passed.No live Desktop E2E or cross-platform run was performed; this change affects storage and Host cleanup without changing the UI. Validation ran on macOS with Node 26.7.0 and npm 11.19.0.
AI use
Tool(s) and scope: Codex integrated the existing local implementation with current main, documented the batch recovery contract, reviewed the deletion/recovery paths, and performed build, regression, fault-injection, and control-experiment validation. This draft is submitted by Codex on behalf of @99Gaoxiaoqi for human review.
Checklist
Does this PR entail a change in behavior?