Skip to content

Resident cycles refused on Linux: semantic.db grant trips the bwrap non-subtree .env deny check - #9151

Merged
danieljhkim merged 2 commits into
agent-mainfrom
orbit/ORB-24174-c2ba8b7e
Nov 12, 2026
Merged

danieljhkim merged 2 commits into
agent-mainfrom
orbit/ORB-24174-c2ba8b7e

Conversation

@orbit-agent-01

Copy link
Copy Markdown
Contributor

Task

ORB-24174 — Resident cycles refused on Linux: semantic.db grant trips the bwrap non-subtree .env deny check

Description

Since 0.49.0 every resident_cycle_pipeline run on dk-server-2 fails in ~2s at the cycle step, before any provider call (jrun-20261112-0517-t1, jrun-20261112-0528-t1; last success jrun-20261111-1436-t1 on 0.48):

cli invocation failed (permanent): policy denied: linux-bwrap cannot enforce non-subtree denyModify `~/workspace/constellation/codebases/orbit/**/.env` for a direct invocation; use a managed worktree

Cause

ORB-24077 (#9096) moved the workspace lexical index grant (<ws>/.orbit/state/semantic.db plus -wal/-shm) out of the grants_workspace_modify gate in append_linux_runtime_write_roots (crates/orbit-core/src/adapter/engine_host/actions/sandbox/runtime_grants.rs), so the read-only reviewer profile the resident cycle runs under now carries writable paths inside the workspace root.

In crates/orbit-exec/src/linux_sandbox/argv.rs (~L149-166) a non-subtree deny is refused for a non-managed-worktree invocation when overlaps_writable_root(denied, &writable_roots) (rules.rs:73) is true. The <ws>/**/.env deny from the shipped default policy has static prefix <ws>, which now contains the semantic.db grants, so the check refuses. Before ORB-24077 the reviewer profile had no writable root under <ws> and the check never fired. The reviewer golden (tests/sandbox_profile_goldens/linux/reviewer.txt) was updated but does not exercise the direct-invocation refusal, so CI passed.

Other reviewer-lane jobs (pilot, gate, PR) are unaffected on the box; only the resident cycle runs reviewer as a direct invocation from the registered checkout.

Fix direction

Exact-file grants (the bind-fd sqlite grants: a fixed file whose name cannot match the deny's final glob segment) cannot be used to create or modify a .env file, so they should not count as overlapping writable roots for a non-subtree deny. Either exclude exact-file runtime-store grants from writable_roots in the overlap check, or make the overlap test consider whether a grant could match the deny pattern. Keep the refusal for any directory/subtree grant under the deny prefix. Do not widen the reviewer profile or drop the .env deny.

Resident ORB-24171 is paused until this lands; resume it afterwards.

Acceptance Criteria

  • A Linux sandbox compile of the reviewer fs profile under the shipped default policy, as a direct invocation (managed_worktree false) from the registered checkout, succeeds with the <ws>/.orbit/state/semantic.db* grants present
  • A direct invocation whose profile grants a directory or subtree under the workspace root is still refused for the non-subtree **/.env deny
  • A regression test in the workspace covers both cases above and passes
  • The <ws>/**/.env deny remains in the shipped default policy and the reviewer profile gains no new grants

Execution Summary

Click to expand

Fix: refined overlaps_writable_root in crates/orbit-exec/src/linux_sandbox/rules.rs — an existing regular-file writable root overlaps a non-subtree deny only when the deny glob matches that exact file (fail-closed on regex error); directory/subtree roots keep prefix-overlap refusal. semantic.db/-wal/-shm bind-fd grants therefore no longer trip **/.env, while an exact .env grant still refuses.

Criteria: (1) reviewer-style direct invocation (managed=false) with /.orbit/state/semantic.db* exact grants + shipped **/.env, /.env., **/.env, /.env. denies compiles — covered by new regression test and passed. (2) Directory/subtree grant under ws still refused with non-subtree denyModify — same test, passed; plus existing workspace/ refusal tests pass. (3) Regression test crates/orbit-exec/tests/sandbox/linux_sandbox.rs::direct_invocation_allows_exact_file_grants_but_refuses_directory_grants covers both cases plus exact-.env variant; verified it fails on unfixed code with the reported PolicyDenied message and passes after. (4) crates/orbit-core/assets/policies/default.yaml unchanged (/.env deny remains, reviewer modify:[]) — confirmed via grep and clean diff on that file; no profile widening.

Validation: cargo test -p orbit-exec --test sandbox direct_invocation_allows_exact_file (passed, also fails-before check); cargo test -p orbit-exec --test sandbox full suite 93 passed/3 ignored (bwrap namespace checks deferred by probe on this host, as existing tests report); cargo fmt --all -- --check passed; rustfmt --check on changed files passed; make ci-guards passed; scripts/build-budget.py clippy -p orbit-exec --lib --bins -D warnings passed; clippy --all-targets passed; cargo doc -p orbit-exec with RUSTDOCFLAGS=-D warnings passed. Pipeline final validation (task.final_validation_commands) recorded not_run per instructions — pipeline runs it.

Reconciliation: only crates/orbit-exec/src/linux_sandbox/rules.rs and crates/orbit-exec/tests/sandbox/linux_sandbox.rs changed vs baseline aaf2bfb (clean baseline); context_files widened to include the test file; .orbit/tmp/rules.rs.bak scratch left in gitignored tmp only. Note: resident ORB-24171 resume is pipeline/operator action after landing, not done here.

Validation

  • Not reported

Branch Freshness

  • Base ref: origin/agent-main
  • Head ref: orbit/ORB-24174-c2ba8b7e
  • Behind base: 0
  • Ahead of base: 1

…ra… [ORB-24174]

Resident cycles refused on Linux: semantic.db grant trips the bwrap non-subtree .env deny check

Fixes: 2f9ef8d ("fix: [friction-curation] Index resident task writes instead of warning … [ORB-24077] (#9096)")
Regression-From: ORB-24077
Regression: broke_existing; escape=no_test; severity=high
@orbit-agent-01 orbit-agent-01 added the orbit orbit related label Nov 12, 2026
…r, and I repaired a hard-link alias bypass: overlapping regular-file grants with multiple links now fail closed while single-link semantic.db grants still compile; directory/subtree grants and exact `.env` grants remain refused. The new regression reproduces the alias defect and passes after repair. The policy and reviewer profile files remain unchanged. Final focused tests, formatting, Clippy, rustdoc and ci-guards pass; the broader sandbox target reported 93 passed, 0 failed, 3 ignored but deferred its Bubblewrap runtime paths because this host cannot create unprivileged user namespaces, so capable-Linux evidence remains outstanding. [ORB-24174]

Findings: F1
Paths: crates/orbit-exec/src/linux_sandbox/rules.rs, crates/orbit-exec/tests/sandbox/linux_sandbox.rs
Orbit-Review-Attempt: rvw-068a6b8dd5b2-1
Orbit-Review-Crew: luna@‍xhigh
@danieljhkim
danieljhkim merged commit 11df274 into agent-main Nov 12, 2026
20 checks passed
@danieljhkim
danieljhkim deleted the orbit/ORB-24174-c2ba8b7e branch November 12, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

orbit orbit related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants