← Back to Pull requests

feat: a Codex seat keeps its own permission envelope and profile across launches #2048

Closed
unknown closed this pull request without merging on Oct 25, 2026 20:46 UTC
View on GitHub
unknown unknown commented on Oct 25, 2026 18:03 UTC
Author

What a person gets

Change an existing Codex member's intended permissions once, without recreating the seat or rebuilding launch flags after every resume. Two values, each with one current record, set through the existing audited rig seat set-permissions:

  • An envelope (--codex-permissions <file>, spec key codex_permissions): sandbox (workspace-write or read-only), approval (never, on-request or untrusted) and, for workspace-write, network_access, writable_roots, exclude_tmpdir_env_var and exclude_slash_tmp. It is emitted as explicit flags with the existing codexEnvelopeArgs on every managed launch and resume.

  • The profile (--codex-profile <name|inherit>): the existing codex_config_profile, now settable on an existing member. A profile doesn't replace a retained conversation's approval; an envelope does.
  • Seats without either launch exactly as before.

    Behaviour

  • One explicit choice per seat. Setting an envelope replaces a recorded permission mode in the same audited write, and --mode (including inherit) replaces an envelope the same way; the result and the event name both. Full access stays the full_bypass mode; the envelope refuses danger-full-access.

  • Precedence. The envelope replaces the posture decision for its fields, including a policy that resolves to full bypass and an ambient OPENRIG_YOLO; status says which it replaces. A named profile still supplies the settings the envelope doesn't state. Team and kernel launch defaults don't apply to a seat with an envelope.

  • OpenRig's additions. Workspace-write keeps OpenRig's generated roots (the queue-state root, the git metadata roots and the seat's own topology folder) on fresh, fork and resume launches, as without an envelope. Read-only gets none. The envelope's own network value is the only network setting.

  • Every path. Fresh launch, fork launch, pod-aware resume, legacy resume (including a seat with its own CODEX_HOME), restore, in-place restart and handover. In a rebuild handover the seat's envelope wins over the observed predecessor policy.

  • A runtime switch. Like a seat's Claude rules, the envelope stays with the seat while it runs another runtime. A switch back to Codex that inherits applies it again, and the Codex successor launches with it. A switch back to Codex with an explicit --permission-mode replaces it, as a mode setter does: the successor launches with that mode, the plan lists the envelope as cleared, and the commit clears it and names it in the seat.runtime_changed event. A switch that doesn't commit leaves the envelope and the seat's choice as they were.

  • The current record governs. The spec writes the record when a seat is created; the setter writes it afterwards. Restore and existing-seat launches read the seat's current profile and envelope, so an older snapshot doesn't bring back a replaced choice. A new generation from rig up <spec> starts from the spec, as other seat settings do. Fork copies the source's current envelope; export round-trips it.

  • The profile check. The setter checks the profile with the existing native preflight in the config home the seat's launches use: the seat's own CODEX_HOME when its env: declares one, else the daemon's explicit CODEX_HOME, which managed Codex launches reassert. An absent file is reported (Codex loads it as an empty layer, so base config applies), not refused. A file whose bytes changed since the last recorded check is reported. A profile the native loader rejects is refused and the previous profile kept, with the existing remedy: recording it would make the seat's next managed launch or resume, possibly an unattended restart, fail at the existing launch preflight until someone repaired it. This refuses nothing that launches today. When neither sets a CODEX_HOME, a pane keeps its own, so the setter reports the profile as unverified rather than checking a different home. Every launch still runs the native preflight.

  • Unreadable records. An unreadable envelope, or one recorded beside a mode by another writer, refuses that seat's launch, fork or export with a repair message rather than launching broader. Status shows the message.
  • Tests

  • Unit (codex-member-permissions.test.ts): validation and normalization, danger-full-access refused, unreadable and both-present

  • records refuse with a repair message, live reads (a cleared profile stays cleared), the setter's atomic mode/envelope replacement with
    both in the audit, legacy flat specs (validate, normalize, export, round-trip; other runtimes refused), and the profile check: a FIFO,
    a directory and an unreadable file give a reason instead of blocking or failing, a loading profile with unreadable bytes stays
    accepted, a check that can't run is reported as not run, and the route answers instead of a 500.
  • Launch arguments: codex-runtime-adapter.test.ts (two seats in one folder get their own flags, the envelope wins over ambient

  • YOLO and a policy posture and keeps a named profile, pod-aware resume) and codex-resume.test.ts (legacy resume adds no network or
    team grants).
  • Paths: restore-orchestrator.test.ts, seat-handover-service.test.ts, agent-image-fork-route.test.ts,

  • cli/test/s03-permissions-cli.test.ts.
  • Mutation check: with the envelope branch removed from fresh launch and legacy resume, the four launch-argument tests fail (the

  • launch falls back to the posture decision) and the rest pass.

    Storage: one migration, 137_node_codex_permissions (nodes.codex_permissions_json). Main has 136, 138 and 139, and the
    migrator applies migrations by name.

    Proof

    All runs are in a Linux container, as root, with --maxWorkers=2. Earlier rounds were reviewed at bf225f3b, on #1914's branch.
    This head is that work rebased onto main after #1914 merged, plus test fixes.

  • Main 80fc3b3f, the daemon files this touches (codex-, native-permission, permission-, restore-orchestrator,

  • seat-handover, seat-lifecycle, seat-runtime-switch, rigspec-, rig-expansion, successor-session, agent-image,
    migrat
    , claude-permission, member-): 2308 pass, 4 skipped.
  • At d9b79c85, the same set: 2344 pass, 5 skipped, 0 fail.

  • - The CLI permission and seat tests pass 152 of 152.
    - test:repo passes 325 of 325.
    - The build passes.
  • At 65ed907d, before the two test fixes, 2 failed. After the rebase, the legacy resume takes the seat's own CODEX_HOME 12th

  • and the envelope 13th, and restore pads its tail with undefined, as main does. Those two tests still passed the old positions and
    expected the old explicit false defaults.
  • At c7c7a277 (adds the runtime-switch test): the build passes, and codex-member-permissions, native-permission and

  • seat-runtime-switch pass 105, with 1 skipped. A later rerun at this head: lint passes, and the same affected daemon set passes
    2345, with 5 skipped.
  • Round 1 (c7c7a277..8a7c63be):

  • - the runtime switch passes the envelope to its Codex successor;
    - the profile check uses the seat's own home;
    - an explicit switch mode replaces the envelope.
  • At d35411c6: build and lint pass, test:repo passes 325 of 325, and the affected daemon set passes 2347 with 2 failing and 5

  • skipped. Both failures were test expectations, fixed in 8a7c63be:
    - the setter test expected the profile check's old two arguments;
    - the replacement test checked for an absent codexPermissions key that the launcher writes as undefined.
  • At 8a7c63be: build and lint pass, and seat-runtime-switch-service, codex-member-permissions, native-permission and

  • seat-lifecycle pass 170, with 2 skipped.
  • The new tests against older code: with ee4215937d's code and d35411c6's tests, the two explicit-replacement tests fail (store

  • and switch), and the inherit and failed-switch cases pass. The third failure there is the setter test's two-argument expectation
    above. With c7c7a277's code and 8a7c63be's tests, exactly five fail and 60 pass:
    - the inherit switch carrying the envelope;
    - the seat-home profile check;
    - the setter passing the seat's node id;
    - both explicit-replacement tests.

    The failed-switch case passes there too, since the old refusal also left the envelope in place.

  • At 98fb3fe8 (clearing an envelope rolls back on any read error except a schema without the column):

  • - build and lint pass;
    - the same four files pass 172, with 2 skipped;
    - with 8a7c63be's code, exactly the two new tests fail: the helper's read-error case, and a switch whose commit hits that error and
    must roll back whole.

    Limits

  • These are launch arguments and records. Native enforcement (effective sandbox, approval on a retained resume, writable roots) is not proven here.

  • The envelope is a native sandbox and approval selection, not a separate OS user or credential isolation. Codex's implicit roots (the working directory and temporary folders) still apply.

  • Start times and other native details are Codex's; admin requirements can still change a value, and Codex reports that.

  • Downgrade: an older OpenRig keeps the stored envelope but doesn't read it, so its launches of the seat use the earlier posture decision, which can be broader. Keep a copy of the intended envelope before using an older managed-launch path.

  • The resume commands printed by rig ps show the profile but not the envelope, as they already omit modes.
  • 🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Added per-seat Codex sandbox and approval settings, including workspace-write options such as network access and writable paths.
    Added support for selecting and checking Codex profiles, with permission changes recorded for review.
    Codex permissions now carry through launches, resumes, restores, forks, and RigSpec export and import.
    Documentation
    * Documented how Codex permissions interact with profiles, defaults, and older OpenRig versions.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: openrig-review Review duration: 163m
    All Vouch review confidence checks passed
    Residual risk 0.32 = Change Risk (0.75) × (1 − Review Confidence (0.58)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 650 lines diff across 8 files
    0.75
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    57%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #2048"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 58.0% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 75.2% (HIGH) · Higher = larger blast radius
    75.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 58.0% · Lower = rushed or shallow review
    58.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 31.6% · Safe to merge
    31.6%