Skip to content

fix(takeover): require a running session for permits and publish complete leases - #305

Closed
ElbertePlinio wants to merge 5 commits into
mainfrom
fix/213-295-298-takeover-coordination
Closed

ElbertePlinio wants to merge 5 commits into
mainfrom
fix/213-295-298-takeover-coordination

Conversation

@ElbertePlinio

Copy link
Copy Markdown
Member

Three takeover bugs. This PR changes when an agent permit is granted, so it waits for an owner's merge decision.

#213: an agent permit now requires a running session record. acquireAgentPermit checks the registry before it creates any coordination, and again after the permit file is verified. withAgentPermit checks once more, after its lease check and before the action. A delayed input call across teardown is refused before its action runs. Legacy and retained session directories stay readable. Desktop startup with the inherit home policy starts VNC and Xvfb while the session is still starting, so that path now skips the permit for a starting record.

#298: the human lease is now written to a temporary file and linked into place. A peer that loses the claim never sees a partly written lease. The staging file is removed on every path.

#295: a new AgentPermitUnavailableError marks any permit gate failure that happens before the action starts. The MCP input tools and the CLI pointer evidence now report it, and HumanControlActiveError, as not-attempted. Failures in the action or in permit release stay attempted.

Closes #213
Closes #295
Closes #298

Requirement Verified by Scenario Result Evidence
#213 refuse coordination for an id without a live record Automated test Permit for a destroyed retained session, with and without prune Refused before creation, typed error packages/core/test/takeover.test.ts, session-retention.test.ts
#213 keep retained directories readable Automated test Takeover status and readers on retained sessions Pass Same tests
#213 delayed input across teardown never runs its action Automated test, stress Stalled action resumes after teardown Action never runs; 30 of 30 stress runs under busy loops ~/Artifacts/pickforge-batch3-2026-10-08/A-sol/validation
#213 live sessions still take input Device pass Default and --inherit-home desktop sessions: create, click, destroy Clicks completed; inherit startup worked ~/Artifacts/pickforge-batch3-2026-10-08/qa-A
#298 peers never read a partial lease Automated test, stress Concurrent claimers; every loser gets HumanLeaseHeldError Pass, 30 of 30 under load A-sol/validation
#295 CLI pointer evidence Device pass, automated test Human lease held: desktop click, desktop drag; after release Refused: not-attempted in evidence; after release: completed qa-A/actions-*.jsonl
#295 non-takeover permit failures Automated test Permit storage failure before the action; release failure after not-attempted before, attempted after, in MCP and CLI desktop-input-captures.test.ts, desktop-pointer-evidence.test.ts
Repo checks lint, typecheck, build, PickCheck, coverage Head 0f00f93 on a quiet host All pass; 2996 tests, thresholds hold ~/Artifacts/pickforge-batch3-2026-10-08/213-295-298-takeover-coordination-cov.log

Require running session records before agent input. Keep late callers from recreating coordination after teardown.

Publish complete human lease files through exclusive links. Record pre-action permit failures as not-attempted in CLI and MCP evidence.

Fixes #213
Fixes #295
Fixes #298
@ElbertePlinio

Copy link
Copy Markdown
Member Author

The #298 and #295 fixes moved to #312. The #213 teardown gate will get a new PR with a kernel-released lock. This PR stays open as reference until that PR exists, then I will close it.

@ElbertePlinio

Copy link
Copy Markdown
Member Author

Superseded by #312 (#298, #295) and #316 (#213, with a kernel-released gate lock).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant