Skip to content

feat(lead): a grant that lasts until the lead session ends, bound to its process - #109

Merged
androidand merged 1 commit into
devfrom
feat/lead-session-grant
Oct 3, 2026
Merged

androidand merged 1 commit into
devfrom
feat/lead-session-grant

Conversation

@androidand

Copy link
Copy Markdown
Owner

Why

The operator wants the lead grant for the rest of a working session, not a fixed number of minutes. A bare 'no expiry' is unsafe: the OS reuses pids, so a stale grant could silently authorise an unrelated process days later.

What

  • expiresAt: null means until the lead session ends, and is only accepted together with lead.procStart, the start time the OS reports for the lead process.
  • Valid only while that pid is alive and still has that start time. A reused pid has a different start time and is refused, with its own reason. An unreadable start time fails closed with a different reason.
  • opencode lead set now defaults to the session length (--ttl session). Timed grants still work (--ttl 8h, max 24h) and are bound to the process too when it can be read. show, verify and the message frame say until the lead session ends.
  • Start time reader: ps -o lstart= on unix, CIM on Windows (not exercised on Windows here).

Evidence

Verified live first: against real sessions the whole cycle works (generic frame, grant, lead-directive frame, revoke, generic frame again). This change was proved against real processes, including a simulated pid reuse. Typecheck clean. 444 pass, 8 skip, 0 fail across peer, policy, peers and unattended suites; fork:verify clean. Five guards mutation-checked, each red when removed (one of them overlaps with the next line of code, so its test pins the reason message, which is all that check is for).

Limits

Process identity is a same-user, same-machine check, as the rest of the lead grant: it defeats pid reuse and stale grants, not a hostile local user. The Windows start-time path is untested. The CLI refusal when the start time is unreadable has no test (needs a real process listing failure).

🤖 Generated with Claude Code

…its process

A grant with expiresAt: null needs lead.procStart (the OS-reported start time of
the lead process) and is only valid while that pid is alive AND still has that
start time, so a reused pid cannot inherit it. Unreadable start time fails
closed with its own reason. 'opencode lead set' now defaults to the session
length (--ttl 8h etc. still work, max 24h for timed grants); show/verify/frame
say 'until the lead session ends'. Proved against real processes, including a
simulated pid reuse; five guards mutation-checked.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@androidand
androidand merged commit c1124f9 into dev Oct 3, 2026
3 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant