Repository navigation
fix(core): prune session markers one day after teardown - #418
Merged
Merged
Conversation
Explicit session prune now removes the .<id>.input-closed and .<id>.takeover-identity markers of a gone session once both are older than SESSION_MARKER_HORIZON_MS (24 hours). Until then they keep the id reserved and late callers keep failing closed. Markers stay while a record, a session lock or a data directory exists in any sessions root, so pending, interrupted and retained teardowns keep them. Before prune removes a retained directory, it copies the teardown time from stopped.json onto older markers, so the horizon starts at the last record. The identity goes first: a crash between the two removals leaves the closure marker, which still refuses input and reserves the id. Closes #317
The release line waits for the 0.7.1 notes to be reset, so it moves to the PR description.
6 tasks done
2 tasks done
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.
Every desktop or browser teardown left a
.<id>.input-closedmarker, and.<id>.takeover-identitywas never removed, so the sessions directory grew for the life of the install.session prunenow removes both markers one day after the session's teardown. A command reads the record once and re-checks it at every permit; the longest one is a 300 s desktop wait or input after up to 90 s for the session lock, so a day covers live callers with a wide margin. Teardown retains logs withstoppedAtjust before it removes the record. When prune removes that directory, it first moves the markers' modification time forward tostoppedAt, so the horizon counts from teardown, not from the first takeover. Markers stay while a record, a session lock or a data directory exists in any sessions root, while either one is younger than the horizon, and when either is not a regular file. The identity goes first, so a crash between the two leaves the closure marker, which still refuses every caller. Nothing else in the directory is removed.Two fixes came from review. Two concurrent prunes no longer fail when one already removed a marker. A permit or lease caller that read the record before teardown and resumes after the markers are gone no longer recreates the session directory and identity: storage creation re-reads the record first.
Rollback: revert the merge. No data format changes. Markers removed before the revert belonged to sessions with no record, lock or directory for over a day; after the revert, new teardowns keep their markers forever again.
No device pass beyond the CLI: prune has no screen. The CLI journeys below ran against real desktop sessions in an isolated
PICKFORGE_HOME.Closes #317
SESSION_MARKER_HORIZON_MSinsession-retention.tssession-retention.test.ts;~/.pickforge/investigations/317/qa-output-final.txtJ3desktop clickon the pruned iddocs/releases/UNRELEASED.mdstill holds the tagged 0.7.1 notesRelease note for the next version: "
session pruneremoves the input closure and takeover identity markers of a destroyed session one day after its teardown. Until then they keep the id reserved, so late input for that session still fails. (#317)"Follow-ups: #413 binds late callers to a session generation, so a reused id can never accept stale input. #414 prunes a session directory that a crash or a stalled first caller leaves without
stopped.json.Checks:
bun run typecheck,bun run lint,bun run test:coveragewith the CI environment variables (3384 passed) before the rebase on main,packages/core/test(1259 passed) after it, PickCheck (no new or worsened functions). One unrelated load flake inevidence-exportis #412. A CI timing flake insecurity-takeover-observationson 138f77f is #423.Council review, 3 rounds:
Round 1 findings and outcomes: the concurrent prune error was fixed. Three findings about a stalled caller, the check-then-unlink race and markers from older versions were closed by their seats in round 2, because each needs a new session to draw the same random 32-bit id. The lock sentinel finding was closed because the data directory and the carried teardown time protect that window. Sol's round 2 finding about a stale caller rebuilding storage was fixed.
Still disputed after round 3: Sol holds that a first caller can still stall between the record re-read and the directory create, and rebuild storage. Fable accepts it: the stall must last more than a day between two adjacent awaits, no input is delivered, and only an empty directory and identity remain. Rolling back shared storage after publish would be riskier than that leftover. Settled as accepted; the cleanup is tracked in #414.