Repository navigation
fix(core): remove retained session files only while they are the checked ones - #473
Merged
Merged
Conversation
Prune validated each retained file, then removed it by name. A file replaced in between was removed, and prune still reported the id. Each file is now removed only while its device and inode match the checked ones, as in the coordination path. The rmdir by name stays a documented limit.
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.
Closes #463
session pruneremoved each retained file by name after checking it, so a writer that replacedxvfb.logorstopped.jsonin between lost the replacement, and prune still reported the id. Retained files now go throughunlinkStaleFile, as the coordination path already did: each file is removed only while its device and inode match the checked ones, and a file that a concurrent prune already removed counts as done.stopped.jsonstill goes last. A replaced file fails the prune run and stays, with its directory, and the next prune still finds the teardown time.Two windows remain, both documented in the code. The identity check and the unlink are two syscalls, and POSIX has no unlink by inode, so a replacement made between them is still removed. This is the same window the coordination path has; #472 tracks closing it in the shared helper. The directory removal also goes by name. If a concurrent prune removed the directory and a stalled first permit caller made an empty one with the same id, this prune removes that one too. The caller then fails closed on its next step, so no data is lost and no input is delivered.
Traceability
xvfb.logandstopped.json; a probe that replaces a file just before the by-name unlinkmain's source and pass here. The probe onmainloses the replacement and reports the id~/.pickforge/investigations/463/before.log,after-1.logtoafter-3.log,probe-main.jsonrmdirIfEmpty: the caller fails closed, and no data is lostpackages/core/src/session-retention.ts~/.pickforge/investigations/463/after-1.logtoafter-3.log,core.log~/.pickforge/investigations/463/probe-fixed.jsonfull-suite.shat f57c269; faf8635 adds a code comment only, and the retention tests, lint and typecheck were rerun on it~/.pickforge/investigations/463/full/,after-doc.log,lint-doc.log,typecheck-doc.logpickcheck check --base origin/main --fail-on new,worsened,unmatched; gitleaks on the branch commits~/.pickforge/investigations/463/pickcheck.json,gitleaks.logNo device pass: the change is in prune's file removal, with no screen or CLI output change. The tests drive
pruneSessionLogs, whichsession prunecalls.Review
Council of Sol and Fable. The Kimi seat did not run: its provider hit a usage limit during this batch.
retainSessionLogsremoves staging files by name after anlstat; both are in #472. A replaced file fails the wholesession prunerun; kept, because the command reports the error and can run again.