Skip to content

fix(retention): remove orphan lease staging files - #314

Merged
ElbertePlinio merged 2 commits into
mainfrom
fix/313-lease-staging-retention
Oct 8, 2026
Merged

ElbertePlinio merged 2 commits into
mainfrom
fix/313-lease-staging-retention

Conversation

@ElbertePlinio

@ElbertePlinio ElbertePlinio commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

retainSessionLogs now removes lease staging files left by a process that died between writing .human-lease-<uuid> and linking it, including the ..human-lease-<uuid>.tmp-<pid>-<n> temp from writeFileAtomic and the .human.lease.json.tmp-<pid>-<n> temp a killed lease renewal leaves. Before this, pruneDirectory saw the staging file as unknown data and skipped the retained session forever. Only those three exact names, with a full UUID shape, are removed, and never directories. Symlinks are unlinked without following them. Any other unknown entry still blocks pruning.

Closes #313

Requirement Verified by Scenario Result Evidence
Remove lease staging files on retention Automated test (session-retention.test.ts) Staging file and writeFileAtomic temp present at teardown Both removed; session prunes CI
Keep refusing other unknown files Same test Directory with a staging-like name, .human-lease-notes, and ..human-lease-<uuid> without a temp suffix Kept; prune refuses until they are gone CI
Test: retained session with orphan staging file is pruned Same test Retain, destroy record, prune Pruned CI

The stopped.json temp case is filed as #315.

Checks: lint, typecheck, build, GSK_RENDERER=cairo bun run test:coverage (3,022 passed, 6 skipped), PickCheck clean. Reviews: Astra and Fable at xhigh, one repair round, all findings resolved.

QA pass skipped: the change is internal retention cleanup with nothing new to drive. The test uses the real filesystem paths and the real retention and prune functions.

@ElbertePlinio
ElbertePlinio merged commit 3d61ccc into main Oct 8, 2026
10 checks passed
@ElbertePlinio
ElbertePlinio deleted the fix/313-lease-staging-retention branch October 8, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core: a crash during lease publish blocks log pruning for that session

1 participant