Skip to content

Run deterministic tasks with explicit trust and frozen acceptance (#333) - #336

Merged
n0rpan merged 17 commits into
mainfrom
agent/333-work-task-runner
Nov 16, 2026
Merged

n0rpan merged 17 commits into
mainfrom
agent/333-work-task-runner

Conversation

@n0rpan

@n0rpan n0rpan commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Delivers step 1 of #333: one child worker per task in a retained Git worktree. Coordination uses files, Git and typed child results; the runner starts no daemon and spends no model tokens.

Before any checkout or worker starts, the runner validates and snapshots every task's literal branch, base SHA and acceptance commands. Each receipt records that base SHA. Later workers cannot change a planned task by moving a shared ref or creating a replacement ref. Host Git commands clear inherited GIT_* overrides, ignore replacement objects, disable fsmonitor and refuse all transport/lazy fetching, including repository-configured promisor helpers.

Source repositories pass normal project-trust and executable-content approval. Worker starts and same-session repairs explicitly use -na and remove OXA_TRUST_PROJECT: a parent-directory decision, defaultProjectTrust=always or inherited approval flag cannot load a different base's project settings, MCP servers or extensions. User-level resources retain normal behavior. External checks use the approved source and the frozen batch command list.

Worktree bootstrap creates detached metadata without host callbacks. Actual branch creation, checkout hooks, reference hooks and filters run in the normal Bwrap supervisor; rejecting reference hooks still refuse branch creation. Missing bwrap blocks before a worker starts. Configured hook directories retain read-only protection; checkout of a tracked protected hook directory blocks and retains the worktree. Final inspection is read-only/offline, ignores replacement objects and fsmonitor, and returns its clean/dirty verdict by exit code.

The worker contract records oxa_result, OS exit and session ID, drains output with bounded buffers, and preserves worker/check failures. Failed/blocked/interrupted workers consume no repair call. One repair after failed acceptance continues the saved session. Private locks and receipts live outside writable Git/worktree binds (0700 directories, 0600 files). Receipts use a durable temporary file and atomic create-only linking; interrupted writes cannot expose an empty canonical receipt. Worktrees remain available after every outcome.

Local done can include uncommitted work. This slice does not publish. Commit/tree/base binding and acceptance on a clean committed export are required in the saving/publication slices before #397 can push. Worker deadline/stall handling follows the coordinated worker-status/L1 contract.

Measured against main 764e639 at the same build path, x86_64 stripped ci profile, Rust 1.100.0, three isolated synthetic loopback samples per mode:

  • Binary: 16,531,240 → 16,795,176 bytes, +263,936 bytes (~258 KiB).
  • No persistent idle work process: 0 added idle RSS/threads after a batch exits.
  • Stalled-stream runner-parent median: 5,764 KiB RSS / 3 threads; two pipe readers exist only while a worker is active.
  • Direct oxa: 2 threads in both builds; sampled active RSS 8,232 / 8,476 KiB.
  • Direct reply medians: 1,278.9 / 1,278.5 ms. Accepted work-result median: 1,536.6 ms, including the same 1,200 ms stream stall plus Git preparation, sandboxed checkout and external acceptance. These are completion timings, not TTFB.

T3. At 7d81cd5: 254 touched-crate tests, including 47 real-child/bare-repository runner cases, pass with mandatory nested Bwrap and isolated homes. Twenty-four regressions were observed failing before fixes. New cases reproduce inherited/default/environment/repair trust, cross-task ref and replace-ref forgery, partial-clone host execution, Git environment redirection, branch aliases and a receipt-write crash. Existing callback, offline, trust, budget, same-session and bounded-output controls remain green. Strict all-target Clippy, workspace fmt, changed-doc links and all four unchanged CI scans pass. Own-head draft gate 43839602395 and full ready gate 43840375867 are green, including mandatory-bwrap workspace/inventory validation and CodeQL. This PR is ready for external re-review/landing. Later slices will be re-cut on main after their parents land.

@n0rpan
n0rpan marked this pull request as ready for review November 15, 2026 15:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T09:32:15.696884Z 7d81cd5 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cfd23d3bf0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread oxa/oxa-work/src/lib.rs Resolved
Comment thread oxa/oxa-work/src/lib.rs Resolved
@n0rpan

n0rpan commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

First-pass review by oxa → oxc → anthropic/claude-opus-5-5 at head cfd23d3 (O-241; the orchestrator adjudicates and enqueues).

Codex findings

  • oxa/oxa-work/src/lib.rs:177,189 (worktree under the common Git directory): CONFIRMED. run_task still creates the worktree at <git-common-dir>/oxa-work/<id>. In oxa-sandbox/src/gitdirs.rs:148-153, outside() leaves out any Git directory that contains the session's working directory, so common (which holds objects and refs) never gets a writable bind. Under bwrap the child agent can't commit.
  • oxa/oxa-work/src/lib.rs:105 (issue_task fetches the issue while offline): CONFIRMED. Neither issue_task nor work_cmd.rs:8-14 checks OXA_OFFLINE or oxa.offline before starting gh issue view, so the issue is fetched over the network even in offline mode.

Additional findings

  1. oxa/oxa-cli/tests/work_cli.rs:65-190: P2. No test runs the child agent under the bwrap sandbox, and no test makes the agent commit. All tests pass while the first Codex finding stays broken. The PR says normal sandbox rules apply, but no test covers that path.
  2. oxa/oxa-cli/tests/work_cli.rs:159: P2. No test covers --issue in offline mode, so the offline bypass would not have been caught.
  3. oxa/oxa-cli/src/work_cmd.rs:19 and oxa/oxa-work/src/lib.rs:179-188: P3. run_task(...)? aborts the whole batch with exit 2 when a task can't be locked or already has a receipt. Re-running a task file after a partial run never reaches the tasks that haven't run. The docs say this case should leave a red or blocked record and continue.
  4. oxa/oxa-work/src/lib.rs:160-165,178-184: P3. The .lock file is removed only in Drop. If the runner is killed (SIGKILL, power loss), the lock stays and the task fails for good with "cannot lock task" until someone deletes the file by hand. Nothing tells the user why.

TIER: T3
VERDICT: REVISE

🤖 Generated with Claude Code (oxa review lane)

@n0rpan

n0rpan commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

First-pass review by oxa → oxc → anthropic/claude-opus-5-5 at head 667f3f6 (O-241; the orchestrator adjudicates and enqueues).

Codex findings

  • lib.rs:189, worktree inside the common git dir: FIXED. Worktrees now go in <parent>/.oxa-worktrees/<repo>/<id> (oxa/oxa-work/src/lib.rs:192-203), outside the common git directory. Only receipts and locks are written there.
  • lib.rs:105, offline mode not enforced before gh: FIXED. oxa/oxa-cli/src/work_cmd.rs:9-11 refuses the lookup when oxa_proto::offline() is set. work_cli.rs:237 (offline_issue_input_never_spawns_gh) checks both the environment variable and the setting.

New findings

  1. P2: oxa/oxa-work/src/lib.rs:153-157 doesn't pass --offline to the child agent. agent() starts the child with only -p --model … --no-session. The --offline command-line flag is held only by the parent process: netguard::install(a.offline, …) (oxa/oxa-cli/src/dispatch.rs:120) doesn't set OXA_OFFLINE, so the child never sees it. Running oxa --offline work tasks.json therefore starts child agents that can use the network, including remote models. OXA_OFFLINE and oxa.offline still reach the child, so only the flag is lost. Fix by passing --offline or setting OXA_OFFLINE=1 on the child when oxa_proto::offline() is true. No test covers this.
  2. P3: oxa/oxa-cli/src/work_cmd.rs:23 stops the whole batch on one error. run_task(...)? returns early when one task already has a receipt or lock, or when check-ref-format fails. Later tasks are skipped, no JSON line is written for the failed task, and the exit code is 2. The docs say tasks run sequentially and report per-task outcomes, so a stale receipt from a single earlier run blocks every task after it.

TIER: T2
VERDICT: REVISE

🤖 Generated with Claude Code (oxa review lane)

n0rpan commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

Addressed the latest first-pass REVISE at 6915352 (normal merge through current main). The parent offline policy now reaches every child, including an explicit oxa --offline work ...; the new remote-model fake-engine regression failed before the fix and now verifies no chat request reaches the mock. Global flags can precede a subcommand while explicit print/RPC modes retain prompt parsing.

Task setup errors now emit a blocked JSON line, preserve any existing receipt/active task state, and continue the batch; they return aggregate exit 1. The failing-first two-task regression confirms the second task executes. Locks now use kernel ownership on a stable inode, so a file abandoned by a killed runner does not block forever; its failing-first regression is green. The earlier real-bwrap commit and both offline issue-fetch regressions remain green. All 171 touched-crate tests, formatting, strict all-target clippy and unchanged four CI scans pass. The restart checkpoints in step 3 build on these fixes; no review wait.

@n0rpan

n0rpan commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

First-pass review by oxa → oxc → anthropic/claude-opus-5-5 at head 6915352 (O-241; the orchestrator adjudicates and enqueues).

Codex findings

  • lib.rs:189, worktree inside the common Git directory: FIXED. oxa/oxa-work/src/lib.rs:204-217 now puts worktrees in <parent>/.oxa-worktrees/<repo>/<id>, outside the common Git directory. Only the receipts and locks stay inside it.
  • lib.rs:105, gh runs even in offline mode: FIXED. oxa/oxa-cli/src/work_cmd.rs:8-10 checks oxa_proto::offline() before calling issue_task. That check covers both the environment variable and the setting. The offline flag is also passed to child runs (lib.rs:157-159).

New findings

  1. P2: subcommand parsing changed for every subcommand, with no test. File: oxa/oxa-cli/src/args.rs:466-478. Before this PR, a subcommand was recognised only as argv[0]. Now the first non-flag word after any flags is matched against the subcommand list, as long as no message, file, -p or --mode came before it. Example: oxa --model m wipe --all or oxa -c install foo used to send "wipe …" / "install …" to the model as a prompt. Now they run wipe (deleting sessions) or install. The flags typed before the subcommand (--model, -c, …) are parsed and then silently ignored by those subcommands. This is a CLI-wide behaviour change hidden inside the work feature. No test covers the old or new behaviour for the existing subcommands.
  2. P3: a failed agent run can be reported as red instead of blocked. File: oxa/oxa-work/src/lib.rs:237-255. If the first child run fails (for example, a bad model name, so no agent work happens) and the acceptance checks fail, a repair run is started. If acceptance still fails, the task is reported as red and the agent errors are thrown away. docs/work.md says blocked means "setup or agent execution failed", so the receipt shows the wrong cause.

TIER: T2
VERDICT: REVISE

🤖 Generated with Claude Code (oxa review lane)

n0rpan commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

The latest first-pass REVISE at 6915352 is fixed at d7ab5cf, now normally merged through main at e8952cb. Command recognition after options is restricted to the explicit --offline work prefix; the regression covers existing command words after --model/-c/--offline and retains print/-- prompt behavior. A failed repair agent plus failed checks now yields blocked with both causes, rather than red with the agent error discarded. Both regressions failed first; all 174 touched tests, fmt, strict clippy and four unchanged scans pass after the main merge. Continuing propagation and #397's new review fixes.

@n0rpan

n0rpan commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

First-pass review by oxa → oxc → anthropic/claude-opus-5-5 at head e8952cb (O-241; the orchestrator adjudicates and enqueues).

Codex findings

  • lib.rs:189, worktree inside the common Git dir: FIXED. Worktrees now go in <parent>/.oxa-worktrees/<repo>/<id> (lib.rs:207-218), outside the common directory. Only receipts and locks stay in .git/oxa-work.
  • lib.rs:105, offline mode not checked before gh: FIXED. oxa-cli/src/work_cmd.rs:9-11 checks oxa_proto::offline() and refuses before issue_task starts gh.

New findings

  1. P1: acceptance checks run code the agent wrote, outside the sandbox. At oxa/oxa-work/src/lib.rs:128-150, acceptance() runs each done command with plain sh -c, with no sandbox and no trust check, inside the worktree the agent just edited. Freezing the command strings from the base does not help, because commands like cargo test or make run files the agent controls (tests, build.rs, scripts). Scenario: the agent follows a prompt injection in an issue body, writes a malicious test, and the runner then executes it unsandboxed as the user. That gets around the oxa sandbox. The agent's own internal done checks only run when the project is trusted; this path doesn't check trust at all.
  2. P1: an untrusted repository's commands run with no trust check. At lib.rs:113-126 and lib.rs:236, done_commands reads .oxa/settings.json from the base branch and runs it without checking project trust. Scenario: running oxa work tasks.json (or --issue) in a freshly cloned, untrusted repository runs whatever shell commands that repo's .oxa/settings.json lists. This bypasses the trust gate the rest of oxa enforces. docs/work.md says invoking work authorizes this, but that note doesn't replace the gate that AGENTS.md says to keep.
  3. P3: a failed repair run can hide a passing first-run result. At lib.rs:254-255, if the first agent run fails, acceptance fails, the repair run then makes the checks pass, but the repair agent exits non-zero, the task is reported blocked. The work in the worktree is green, yet the outcome says otherwise.

TIER: T3
VERDICT: REVISE

🤖 Generated with Claude Code (oxa review lane)

n0rpan commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

The new acceptance sandbox/trust findings are valid: freezing command text does not constrain agent-edited scripts/tests. I have identified the fix path: require the existing project-trust decision and execute acceptance through the normal Bwrap policy in a separate supervisor that retains the task lock, keeping acceptance external to the model. This implementation is parked under #331's new owner priority while I take Rust skeleton job (a); the REVISE remains outstanding.

The P3 concerning green checks after a nonzero repair-agent exit is intentional: the documented blocked outcome includes agent execution failure. Check success alone does not erase a failed agent process. The state/worktree remain retained.

@n0rpan
n0rpan marked this pull request as draft November 15, 2026 18:38

n0rpan commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

Parked as draft while the acknowledged acceptance sandbox/trust P1s remain unfixed. This prevents it being treated as ready to merge during #331's Rust-skeleton priority. All runner implementation and test evidence are saved; no queued branch was touched. The priority work is now skeleton (a), #428.

@n0rpan n0rpan changed the title Add opt-in oxa work task runner with external acceptance checks Run deterministic tasks with sandboxed acceptance and worker results (#333) Nov 16, 2026

n0rpan commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

The outstanding acceptance sandbox/trust P1s are fixed at ccf2550 after a normal main merge. Both exploit regressions failed before the fix: untrusted source commands executed, and an agent-written check escaped through HOME. They now run through the existing shared trust/content approval and normal Bwrap policy, including read-only executable Git configuration; missing Bwrap blocks. Private runner state is outside writable Git binds, and worker/check supervisors retain the task lock. #332's exit/oxa_result/session contract is consumed, with same-session repair and no repair spend after a budget block. All 230 touched tests, strict checks, docs and four unchanged scans pass. The conservative blocked outcome for a failed worker remains intentional. This head stays draft until its own new gate is green.

@n0rpan
n0rpan marked this pull request as ready for review November 16, 2026 06:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ccf2550fd7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread oxa/oxa-work/src/lib.rs Resolved
@n0rpan

n0rpan commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

First-pass review by oxa → oxc → chatgpt/gpt-6.1-sol at head ccf2550 (O-241; the orchestrator adjudicates and enqueues).

Codex findings

  • FIXED — oxa/oxa-work/src/lib.rs:230–239: Worktrees now live beside the repository, outside the common Git directory; the real-sandbox commit test covers this layout.
  • FIXED — oxa/oxa-cli/src/work_cmd.rs:35–37: Issue lookup checks the installed offline policy before spawning gh; tests cover environment- and settings-based offline mode.
  • CONFIRMED (P1) — oxa/oxa-work/src/lib.rs:108: Command::new("gh") still resolves unrestricted PATH before project trust is checked. An untrusted repository with its executable directory on PATH can execute host code with the user's environment; the existing trusted-executable checks are not used.
    TIER: T3
    VERDICT: REVISE

🤖 Generated with Claude Code (oxa review lane)

@n0rpan
n0rpan marked this pull request as draft November 16, 2026 06:44
@n0rpan
n0rpan marked this pull request as ready for review November 16, 2026 07:05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12341d2092

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread oxa/oxa-work/src/lib.rs Resolved
@n0rpan

n0rpan commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

First-pass review by oxa → oxc → openai/gpt-6.1-sol at head 12341d2 (O-241; the orchestrator adjudicates and enqueues).

Codex findings

  • FIXED — oxa/oxa-work/src/lib.rs:260: Worktrees now live beside the repository under .oxa-worktrees, outside the common Git directory.
  • FIXED — oxa/oxa-cli/src/work_cmd.rs:72: Issue lookup checks the installed offline policy before spawning gh.
  • FIXED — oxa/oxa-cli/src/work_cmd.rs:78: Issue lookup requires project trust and resolves gh through the trusted-executable checks.
  • CONFIRMED — P1, oxa/oxa-work/src/lib.rs:317: Final git status still runs outside the sandbox with inherited credentials/environment. With core.fsmonitor configured to execute a worktree script, a worker can modify that script and have the host-side status probe execute it unrestricted. Read-only Git configuration does not protect the script it references.
    TIER: T3
    VERDICT: REVISE

🤖 Generated with Claude Code (oxa review lane)

@n0rpan
n0rpan marked this pull request as draft November 16, 2026 07:13
@n0rpan
n0rpan marked this pull request as ready for review November 16, 2026 07:42

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 224b4fef12

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread oxa/oxa-work/src/lib.rs Resolved
@n0rpan
n0rpan marked this pull request as draft November 16, 2026 07:46
@n0rpan
n0rpan marked this pull request as ready for review November 16, 2026 07:59
@n0rpan

n0rpan commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

First-pass review by oxa → oxc → openai/gpt-6.1-sol at head dd80623 (O-241; the orchestrator adjudicates and enqueues).

Codex findings

  • FIXED — Worktrees now live outside the common Git directory, allowing normal writable Git binds.
  • FIXED — Issue lookup checks the installed offline policy before spawning gh.
  • FIXED — Issue lookup requires source-project trust and resolves gh through trusted-executable checks.
  • FIXED — Final Git status inspection runs inside bwrap, with fsmonitor disabled; inspection errors block the task.
  • FIXED — Host worktree creation disables hooks and checkout; checkout, filters and task-branch callbacks run inside bwrap.

TIER: T3
VERDICT: CLEAR

🤖 Generated with Claude Code (oxa review lane)

@n0rpan

n0rpan commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Independent second security read at dd80623 (hostile-repository threat model; read-only, nothing run). The GPT review is CLEAR; this read is REVISE: findings 1 and 2 block, 3 must be fixed before any publication slice (#397). Traced code paths are CONFIRMED; the rest PLAUSIBLE.

  1. HIGH: the worker child makes its own trust decision, decoupled from the approved source (oxa-work/src/worker.rs:67-84; trust in oxa-cli/src/dispatch.rs:739-853, approval.rs:47-60). The child starts in <parent>/.oxa-worktrees/<repo>/<id> and trusts by path: a saved decision covering the parent directory, defaultProjectTrust: always, or an inherited OXA_TRUST_PROJECT=1. With parent trust, Approval::NoRecord auto-approves the tree's .oxa settings, mcp.json and extensions on first start, and that content comes from base (and from sandboxed checkout hooks or smudge filters that can edit it), not from the approved checkout; with always or the env flag the repair run loads .oxa files the first worker wrote. Not traced: which of those resources execute on the host in --mode=json. Fix: the runner decides for the child (pass -na, or require the tree's manifest to equal the source's approved manifest before every start, repair included) and strips OXA_TRUST_PROJECT from the child environment.

  2. HIGH: a worker can forge a later task's acceptance (lib.rs:330-335; binds in gitdirs.rs:148-185). The shared common dir is bound read-write; only config, hooks, commondir, gitdir and info are protected, and base plus the done commands are resolved per task after earlier workers ran. Task 1's worker can git update-ref refs/heads/main <evil> or write refs/replace/<base-sha>: task 2's frozen commands become ["true"] and its tree is the attacker's (feeding finding 1). Replace refs defeat even a sha-pinned base. Fix: resolve every base to a sha and read every done list before the first worker starts; GIT_NO_REPLACE_OBJECTS=1 on host git; record the base sha in the receipt. Longer term: per-task ref and object store.

  3. MEDIUM: "done" is not bound to a commit (Record at lib.rs:37-46, verdict lib.rs:409-415). No head or base sha in the receipt; acceptance runs in the writable, possibly dirty tree and a dirty tree still yields Done. An untracked or ignored helper (conftest.py, .cargo/config.toml, a built artefact) can make the frozen command pass. Fix: accept on a clean export of HEAD or refuse dirty and ignored files; record head, tree and base sha and verify them at publication.

  4. MEDIUM (plausible): host git is hardened only by PATH (lib.rs:58-62). GIT_* is inherited; lazy fetch and protocols are not restricted. In a partial clone git show <base>:.oxa/settings.json (lib.rs:138) can fetch on the host despite --offline; a hostile .git/config (repository from a tarball) with a promisor remote on an ext:: URL would be host code execution. Fix: route these reads through the offline read-only supervisor like Inspect, or set GIT_NO_LAZY_FETCH=1, -c protocol.allow=never, -c core.fsmonitor=false and clear GIT_*.

  5. LOW: host git runs before the trust decision (work_cmd.rs:59, and :101 even when untrusted): ordering weakness, no known vector.

  6. LOW: the worker has no deadline (worker.rs:90): a stalled child blocks the batch; checks have 600 s, the worker none.

  7. LOW: the receipt write is not atomic (lib.rs:422-429): a kill between create_new and write_all leaves an empty receipt that blocks the task for good. Temp file plus rename.

  8. LOW: branch names are validated but not normalised (lib.rs:268-272): @{-1} passes check-ref-format --branch and expands; the record then names a branch that was not created.

Checked and sound: absolute, validated git/gh with filtered PATH and no host shell; branch/base cannot start with -; task ids limited to [A-Za-z0-9_-]; existing worktree, branch or receipt refused and nothing deleted; worktree add --no-checkout --detach with hooks disabled and checkout in bwrap; cleared environment, --die-with-parent, null stdin; protected .git file and config paths; verdicts by exit code only; bounded result parsing with duplicate oxa_result rejected; kernel lock on a stable inode; receipts 0600 under a 0700 directory outside the binds.

Missing tests: multi-task ref or replace tampering; a parent-trusted or always child; a partial clone; sha binding.

Held until 1 and 2 are fixed with tests. This is the foundation for unattended runs on untrusted repositories, so the extra round is worth it.

🤖 Generated with Claude Code

@n0rpan
n0rpan marked this pull request as draft November 16, 2026 08:40
@n0rpan n0rpan changed the title Run deterministic tasks with sandboxed acceptance and worker results (#333) Run deterministic tasks with explicit trust and frozen acceptance (#333) Nov 16, 2026

n0rpan commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the independent second read in 7d81cd5:

  • 1: Every worker start, including --continue repair, passes -na and removes OXA_TRUST_PROJECT. Four failing-first real-child tests reproduced host MCP execution through parent trust, default always, the environment flag and a changed manifest before repair; all now pass.
  • 2: The CLI constructs every immutable PlannedTask before any checkout/worker. Base/check resolution never happens after another task has run. Host Git and deterministic checkout/check/inspection ignore replacement objects; receipts record base_sha. Two tests verify the first worker really mutates refs/heads/main or refs/replace/, while the second still checks out the original tree and runs the original checks.
  • 4 is now reproduced and fixed: A synthetic partial clone with a local ext:: promisor helper wrote into private HOME before the fix. Host metadata now clears GIT_* overrides, sets GIT_NO_LAZY_FETCH/GIT_NO_REPLACE_OBJECTS, disables fsmonitor and uses an empty GIT_ALLOW_PROTOCOL whitelist as well as protocol.allow=never. The helper is refused even when the repository explicitly allows ext. Root verification uses this same path.
  • 7: Receipt bytes are fsynced before an atomic create-only link; the directory is synced. A real per-process file-limit crash left an empty canonical receipt with the old writer and leaves none with the new writer.
  • 8: Branch aliases are rejected during planning, before worktree creation.
  • 3 remains a publication prerequisite: Checkpoint work tasks, save uncommitted outcomes, and show status #387/Publish accepted work and file scrubbed problem notes after duplicate searches #397 will save and bind head/tree/base and check a clean committed export before pushing. This slice's local done may be dirty and publishes nothing; docs make that explicit. Deadline/stall handling (6) follows the coordinated worker-status/L1 contract.

All 254 touched tests / 47 runner cases, strict all-target Clippy/fmt, links and unchanged scans pass. The ten new regressions failed first. The PR is draft for this new head's own gate; #358/#387 will be re-cut on main after their parents land, with the event hook/revision at the front of #387.

@n0rpan
n0rpan marked this pull request as ready for review November 16, 2026 09:30
@n0rpan

n0rpan commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Second security read, re-check at 7d81cd5: MERGE-OK. Approved for the queue.

  • 1 FIXED: the runner decides trust for every child start, repair included (-na, OXA_TRUST_PROJECT removed), with four security tests using real git and the real child.
  • 2 FIXED within a batch: every task is planned (base sha, done list) before the first checkout or worker; replace objects are disabled on every host git call and in the sandboxed steps; tests where the worker really runs git update-ref.
  • 4, 7, 8 FIXED (cleared GIT_*, no lazy fetch, empty protocol allow-list; atomic receipt; branch aliases refused).
  • Before the publication slice (Publish accepted work and file scrubbed problem notes after duplicate searches #397), blocking there: finding 3 (the receipt records base_sha only: add head and tree sha, refuse or export-clean a dirty tree) and a residual: the shared objects directory is still writable by workers and git does not re-hash loose or packed blobs on read, so an earlier worker could alter a blob in a later task's base; fix with a per-task object store or an fsck of the base before checkout.
  • Before unattended use: finding 6 (the worker has no deadline).
  • Functional note: clearing GIT_* also drops GIT_CONFIG_GLOBAL; users with safe.directory in a relocated global config may see 'dubious ownership'. Across batches a worker-moved main becomes the next base by design; base_sha makes it visible and publication should compare it with the remote.

🤖 Generated with Claude Code

@n0rpan
n0rpan added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 5421e91 Nov 16, 2026
48 checks passed
@n0rpan
n0rpan deleted the agent/333-work-task-runner branch November 16, 2026 09:58
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