Repository navigation
feat(access): loosen a built-in guard for a while or one session (2.148.0) - #201
Merged
Merged
Conversation
…48.0) A lease sets one guard to confirm or allow for 60 s to 8 h, for every session or one, in every project or one, without touching its permanent mode. Rows in ~/.c3/builtin_leases.json count only while the keyring holds the sha256 of the exact row, so forged or edited rows are ignored, and a lease never tightens. The hook and MCP server bind their session id so a per-session lease applies; minting needs the Desk token and the glob. Tests: test_builtin_leases.py; full suite 4595 passed, 7 skipped. Claude-Session: https://claude.ai/code/session_01F6QMHB2mkrDJiQWfC1g9wy
drknowhow
force-pushed
the
feat/hub-builtin-leases
branch
from
September 23, 2026 22:52
c6cfe87 to
d51c710
Compare
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.
Stacked on #200. Loosen a built-in guard for a while, or for one agent session, without touching its permanent mode.
A lease sets one guard to
confirmorallowfor 60 s to 8 h. It covers every session or one, and every project or one. When it ends, the guard is back where it was and there is nothing to undo.services/builtin_leases.pystores leases in~/.c3/builtin_leases.json. They are two-key, like modes: a row counts only while the keyring holds the sha256 of that exact row, so a row that is forged, edited, or copied back after revoke is ignored.access_guard.effective_builtin_modes()applies live leases on top of the standing modes. A lease never tightens. When no lease file exists, the hot path makes one extrais_filecall and no keyring reads.access_guard.bind_session()handles that: the PreToolUse hook binds the payload'ssession_id, and the MCP server binds_grants.session_id()in_svcbefore every tool call. The Hub, CLI and mobile API bind nothing, so only all-session leases apply there.POST /api/hub/access/builtin/leasemints a lease, and minting always needs the Desk token and the glob typed back. A lease that wouldn't loosen anything is a 400.POST …/lease/revokeneeds no token.GET /api/hub/access/builtinnow lists leases.Known limit: the MCP server's host session id is taken at boot, so after
/cleara session lease no longer matches that server's calls. Hook-side enforcement uses the payload id and is unaffected.Tests:
tests/test_builtin_leases.py(14 cases: realm and session scoping, expiry, forged and edited rows, revoke-then-restore, never tightening, TTL bounds, no keyring reads without a file, routes). Full suite: 4595 passed, 7 skipped; ruff clean.https://claude.ai/code/session_01F6QMHB2mkrDJiQWfC1g9wy