Skip to content

Per-session mount role grants (read/write/exec)#436

Open
zechengz wants to merge 4 commits into
mainfrom
feat/session-mount-grants
Open

Per-session mount role grants (read/write/exec)#436
zechengz wants to merge 4 commits into
mainfrom
feat/session-mount-grants

Conversation

@zechengz

@zechengz zechengz commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

Sessions can be restricted to per-mount roles. The mount's configured mode is the ceiling; a session grant can only narrow it on the READ < WRITE < EXEC lattice.

  • SDK: ws.create_session("agent", mounts={"/data": "read", "/scratch": "write"}); a plain list keeps the previous allowlist behavior (mount's own mode). TS: ws.createSession(id, { mounts }).
  • CLI: mirage session create WS -m /data:read -m /scratch:write (bare -m /data inherits).
  • Server: POST /sessions {"mounts": {...}}, dict or list; invalid role returns 422.
  • Enforcement rides the existing read-only checks via effective_mount_mode, so a session-denied write produces the same stderr as a read-only mount. The python builtin exec gate is per-session now. Grants survive fork, background jobs, and snapshots.

Behavior changes

  • A user-defined / mount is now governed by grants instead of bypassing the allowlist (the documented escape hatch). The implicit scratch root stays auto-granted so pathless commands keep working in restricted sessions.
  • Python capability errors now carry the GNU-style command prefix (cat: session 'x' not allowed ...), matching TS.
  • mirage/runtime is renamed to mirage/context (TS core/src/context).

Testing

  • New 1:1 unit tests for the context module plus workspace grant suites in both languages; existing capability/jobs/fork regression tests updated.
  • New integ/grants.py / integ/grants.ts with byte-identical output against truth_grants.txt, wired into both integ legs.
  • Python full suite green (known jina flake excluded); TS core 3561, server 148, cli 51 green; pre-commit green.

zechengz added 4 commits July 3, 2026 02:53
Sessions can now be granted per-mount roles: create_session(id, mounts={'/data': 'read', '/scratch': 'write'}). The mount mode stays the ceiling; a grant only narrows it. List form keeps the old allowlist behavior. Exposed on the SDK, server, and CLI (-m /data:read) in both languages, with integ truth coverage. A user-defined root mount is now governed by grants instead of bypassing them, and the python capability error gained the GNU-style command prefix to match TS. The mirage runtime package is renamed to mirage/context (core/src/context).
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.

1 participant