Skip to content

fix(core): reserve pruned session ids with takeover identity records - #212

Merged
ElbertePlinio merged 3 commits into
mainfrom
fix/170-retire-takeover-identity
Sep 27, 2026
Merged

ElbertePlinio merged 3 commits into
mainfrom
fix/170-retire-takeover-identity

Conversation

@ElbertePlinio

@ElbertePlinio ElbertePlinio commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Closes #170

This picks continued id reservation over retirement.

Explicit session prune still removes the retained session directory and keeps the sibling .<id>.takeover-identity record. With the directory gone, every takeover call for that id fails closed. A delayed input call for the destroyed session can't rebuild its permit storage or pass an empty lease check. createSession now also skips any id that still has a record, so a pruned id is never handed to a new session whose takeover could never succeed.

Retiring the record at prune was tried in the first commit and dropped after review. It let a delayed withAgentPermit caller recreate coordination for the dead id and see no lease. That call could then deliver input to a display that a new session had reused while a human held control.

Active and error sessions, held permits, legacy roots and uncertain records behave as before, because prune does not touch the record at all. The cost is one small dotfile per pruned session that ever took agent input, in an id space of 2^32 per session type.

Verification: new cases in packages/core/test/session-retention.test.ts check three things. After prune the record survives unchanged, withAgentPermit and readHumanLease for the pruned id reject without running the action or recreating the directory, and createSession skips a reserved id (this fails without the session.ts change). All tests run under temp PICKFORGE_HOME dirs and never touch real home data. The full bun run test:coverage (2134 tests), lint, typecheck and build pass, and PickCheck reports only the preexisting parseHumanLease finding.

Explicit log pruning now removes a session's takeover identity record only when it binds exactly the torn-down directory being removed, and only after that directory is gone. Unreadable, mismatched or linked records keep the directory, and createSession skips ids that still have a record.

Closes #170
Retiring the record at prune let a delayed input call for a destroyed session rebuild its coordination storage and pass the lease check while a reused display was under human control. Prune now keeps the record, so late callers keep failing closed, and createSession skips any id that still has one.
@ElbertePlinio ElbertePlinio changed the title fix(core): retire takeover identity records at explicit prune fix(core): reserve pruned session ids with takeover identity records Sep 27, 2026
@ElbertePlinio
ElbertePlinio merged commit fd2abf6 into main Sep 27, 2026
10 checks passed
@ElbertePlinio
ElbertePlinio deleted the fix/170-retire-takeover-identity branch September 27, 2026 01:23
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.

desktop: retire retained takeover identity records safely

1 participant