{"pr":{"number":268,"title":"Gate reviewers' host code execution to internal PRs only","url":"https://github.com/fulcrumaxe/fulcrumaxe/pull/268","state":"MERGED","createdAt":"2026-09-28T02:14:48Z","mergedAt":"2026-09-28T21:58:25Z","closedAt":"2026-09-28T21:58:25Z","mergeMinutes":1184,"additions":1225,"deletions":32,"changedFiles":16,"commits":3,"labels":["acceptance-passed","code-review-passed","security-review-passed"],"gates":["Code review","Security","Acceptance"],"summary":"Code-reviewer, security-reviewer, and acceptance-tester all run PR-head code (pytest, scripts/ci/run-guards.sh, suite scripts) with the operator's full environment and ambient gh login. That was fine while every PR came from us; now that the code plane takes o…","comments":8,"sentBack":true,"scopeDrift":false,"ci":{"state":"SUCCESS","total":12,"passed":11,"failed":0,"skipped":1,"distinct":9,"superseded":3,"supersededFailures":0,"resolved":true,"wallSeconds":308},"touched":[".claude/agents/acceptance-tester.md",".claude/agents/code-reviewer.md",".claude/agents/security-reviewer.md"],"body":"Code-reviewer, security-reviewer, and acceptance-tester all run PR-head code (pytest, scripts/ci/run-guards.sh, suite scripts) with the operator's full environment and ambient gh login. That was fine while every PR came from us; now that the code plane takes outside contributions, an external PR's own diff shouldn't get to execute on this host before a human has looked at it.\nThis adds backend/pr_execution_policy.py, a small resolver that decides host vs static-only from the exit codes of the two intake CLIs that already exist for the merge gate (pr_intake_gate.py security-required-pr and external_intake_gate.py security-required). It returns host only when both confirm the PR is internal — anything else (a different exit code, a timeout, a missing script, any exception) is static-only, and nothing in the environment can override that; the resolver never reads an env var.\nspawn_payload.build_payload calls the resolver for the three reviewer roles when a PR number is present and threads the result through prompt_builder.SpawnPrompt as pr_host_execution. The three spawn templates now render a HOST_EXECUTION: host|static-only line; under static-only, the step that would run PR-head code is replaced with an instruction to review the diff statically and read CI (gh pr checks) instead. The three role cards get the same rule spelled out near the top, since run-guards.sh (code-reviewer step 4b) lives only in the card, not in any rendered template.\nFix round 2: round 1 wrapped the code-reviewer template's execution steps in a HOST_EXEC span, but two steps outside that span (8 and 8b) still anchored to the operator checkout via $(dirname \"$(git rev-parse --git-common-dir)\"). That idiom only finds the operator checkout from a linked git worktree of it. scripts/lib/verify-tree.sh's verify_tree_build — the mechanism a reviewer actually uses to get a PR-head tree — builds a standalone git clone --shared instead, with its own .git. From inside one of those trees the idiom resolves to the PR-head tree itself, so under static-only mode a reviewing agent would still import/execute the PR's own backend/spec_external_docs.py and scripts/check-pr-cli-touched.sh — exactly the code path static-only exists to avoid.\nFixed by rendering the operator root as an absolute path once, at spawn time, reusing pr_execution_policy._repo_root() (already used to locate the two intake-gate CLIs) rather than adding a second resolver. apply_host_execution() now does this substitution unconditionally, independent of mode, since both steps need the real path whether they run under host or static-only.\nStep 7's gate1-invoke line has the identical flaw but is host-only and pre-existing (not introduced by round 1 or this round) — left alone here on purpose; flagging it as a follow-up rather than folding an unrelated fix into this PR.\nVerification\nGate 1: PASS — 128 tests (backend/tests/test_pr_execution_policy.py, test_prompt_builder.py), run with python3 -m pytest against this commit's own tree, built with scripts/lib/code-plane-pr.sh's build step (which also ran the full scripts/ci/run-guards.sh suite against that same tree: 37/37 passed, 11 ledgered not-run) and pushed fast-forward, no force. Includes two new tests (TestOperatorRootSurvivesAVerifyTree) that build a REAL tree with verify_tree_build (scratch AUTONOMOUS_TEAM_STATE_DIR, never the production one) and evaluate the rendered OP_ROOT line from inside it — confirmed these fail against the pre-fix commit (the sentinel API doesn't exist yet there) and pass against this commit.\nGate 2: PASS — CI green on this exact head (50b73112): PR link policy, dashboard, publish denylist, ts-backend, tui, PR mutation evidence, backend (import-smoke), preflight (always-on gates) all pass; open-source export audit skipping (expected, same as round 1).\nRefs D#2644\n🤖 Generated with Claude Code\nhttps://claude.ai/code/session_01WU1ti95kzEKLM567UxUpph","bodyTruncated":false,"files":[{"path":".claude/agents/acceptance-tester.md","additions":35,"deletions":3},{"path":".claude/agents/code-reviewer.md","additions":27,"deletions":4},{"path":".claude/agents/security-reviewer.md","additions":13,"deletions":0},{"path":"agents/acceptance-tester.md","additions":35,"deletions":3},{"path":"agents/code-reviewer.md","additions":27,"deletions":4},{"path":"agents/security-reviewer.md","additions":13,"deletions":0},{"path":"backend/pr_execution_policy.py","additions":275,"deletions":0},{"path":"backend/prompt_builder.py","additions":31,"deletions":2},{"path":"backend/spawn_payload.py","additions":29,"deletions":4},{"path":"backend/spawn_templates/acceptance-tester.tmpl","additions":12,"deletions":2},{"path":"backend/spawn_templates/code-reviewer.tmpl","additions":28,"deletions":6},{"path":"backend/spawn_templates/security-reviewer.tmpl","additions":3,"deletions":0},{"path":"backend/tests/test_pr_execution_policy.py","additions":410,"deletions":0},{"path":"backend/tests/test_prompt_builder.py","additions":211,"deletions":0},{"path":"backend/tests/test_spawn_payload.py","additions":73,"deletions":1},{"path":"engine/manifest.json","additions":3,"deletions":3}],"fileCount":16,"checks":[{"name":"tui","conclusion":"SUCCESS"},{"name":"PR link policy","conclusion":"SUCCESS"},{"name":"PR link policy","conclusion":"SUCCESS"},{"name":"dashboard","conclusion":"SUCCESS"},{"name":"ts-backend","conclusion":"SUCCESS"},{"name":"open-source export audit","conclusion":"SKIPPED"},{"name":"publish denylist","conclusion":"SUCCESS"},{"name":"publish denylist","conclusion":"SUCCESS"},{"name":"backend (import-smoke)","conclusion":"SUCCESS"},{"name":"PR mutation evidence","conclusion":"SUCCESS"},{"name":"PR mutation evidence","conclusion":"SUCCESS"},{"name":"preflight (always-on gates)","conclusion":"SUCCESS"}],"review":[{"kind":"blocked","createdAt":"2026-09-28T02:24:48Z","body":"Security review: needs-fix (reviewed head f2f5806, base 02584cf)\nThe resolver holds up. PR text can't change the mode it picks, and every failure path I tried lands on static-only. The problem is coverage: a static-only prompt still tells the agent to run PR-head code in two places. Everything below comes from renders through python -m backend.prompt_builder render and calls to build_payload / resolve(), run in a fresh clone of each commit on one Linux host. Env set: AUTONOMOUS_TEAM_STATE_DIR=<scratch>. AUTONOMOUS_TEAM_REPO was unset. Nothing was written to the production state dir.\nBlocking: PR-head execution steps outside the conditioned spans (CWE-94, running untrusted code)\n\nbackend/spawn_templates/acceptance-tester.tmpl:44-56. STEP 0 sits outside HOST_EXEC_BEGIN/END, so a static-only render still says \"Run every subsequent step (test suite, lint, build) inside $DEST, e.g. (cd \"$DEST\" && {test command})\". I confirmed this in the rendered prompt. The same prompt also says \"static review only\", so the agent gets both instructions. Fix: move that paragraph and the \"Do NOT run any tests until…\" line inside the span, or reword them so they only talk about building the tree.\n.claude/","truncated":true},{"kind":"blocked","createdAt":"2026-09-28T02:49:44Z","body":"Code review: needs-fix (head f2f5806).\nMechanics of the resolver and the wiring are solid. pr_execution_policy.py is a clean new module: fail-closed on any exit code but 1, injectable run= for tests, bounded timeout, no shell, no env-var back door. prompt_builder.py (+20 lines) and spawn_payload.py (+22 lines) stay registration-sized — the parsing/stripping logic lives entirely in the new module, which is what the Spec's constraint actually asks for. 129/129 new/changed tests pass (test_pr_execution_policy.py, test_prompt_builder.py, test_spawn_payload.py), engine-manifest-guard.py, commands-twin-divergence-guard.sh, and the full run-guards.sh (37/37) all pass clean on a fresh clone of this exact SHA. CI is green. The agents/ mirror and engine/manifest.json match a fresh regen. The leaked @~/.pr_body.md in the first PR body edit is gone from the current body — no scratch path in what's live now.\nOn the deviation flagged for this review: using apply_host_execution() as a post-render pass in prompt_builder.py rather than threading pr_host_execution through spawn_templates.render_body()'s {{var}} substitution is fine. The Implementation Notes are advisory, the acceptance criteria expl","truncated":true},{"kind":"blocked","createdAt":"2026-09-28T03:26:53Z","body":"Security review, round 2: needs-fix (reviewed head 7847e319, compared against f2f5806, code-plane main bf752070)\nRound 1's items 1, 2, 4, 5 and 6 are closed. Item 3 is still open. The new $OP_ROOT anchor for steps 8 and 8b resolves to the PR-head tree in exactly the case the new comment says it protects against.\nAll numbers below come from one Linux host, using a fresh clone of the code plane with the PR head checked out, run under env -u AUTONOMOUS_TEAM_REPO. The only env var I set was AUTONOMOUS_TEAM_STATE_DIR=<scratch>. Nothing was written to the production state dir, and nothing from the verification posted to GitHub.\nBlocking: host code execution under static-only (CWE-94), backend/spawn_templates/code-reviewer.tmpl:200-204 and :224-227\nOP_ROOT=$(dirname \"$(git rev-parse --git-common-dir)\") only finds the operator checkout when cwd is a linked worktree of it. verify_tree_build doesn't build a linked worktree. It runs git clone --shared (scripts/lib/verify-tree.sh:207), which makes a standalone repo with its own .git. Only its object store is borrowed, through objects/info/alternates. I built a real tree with verify_tree_build 7847e319… <scratch>/vtree and ran the exact idiom f","truncated":true},{"kind":"blocked","createdAt":"2026-09-28T03:29:21Z","body":"Code review: pass (re-review, head `7847e319`, delta `f2f5806..7847e31`).\nAll three blocking items from round 1 are fixed.\n\n`backend/spawn_templates/acceptance-tester.tmpl`: STEP 0's exec instructions (\"Run every subsequent step... inside `$DEST`\" and the \"Do NOT run any tests until...\" line) now sit inside `HOST_EXEC_BEGIN`/`HOST_EXEC_END`. A new forbidden-substring test in `test_prompt_builder.py` pins exactly this phrase so it can't silently drift back outside the span.\n`.claude/agents/acceptance-tester.md` (+ `agents/` twin): step 4b now carves the `bootstrap.sh` installer call out as host-only explicitly, while tree-build/assert stays allowed under either mode — the blanket \"reading is not execution\" allowance no longer covers running an installer script out of the tree.\n`backend/spawn_templates/code-reviewer.tmpl` steps 8/8b: both anchor to `$OP_ROOT` (via `git rev-parse --git-common-dir`) instead of cwd-relative paths, so a reviewer whose cwd is the PR-head verify-tree no longer risks importing/running the PR's own edited copy of these scripts. New `TestCodeReviewerAnchoredPaths` covers both the script paths and the `sys.path` import.\n\nNew neutralizer (`pr_execution_policy.n","truncated":true},{"kind":"passed","createdAt":"2026-09-28T03:31:08Z","body":"Acceptance validation passed.\nBuilt a scratch verify-tree at head 7847e319 (fresh clone, own manifest, no drift on assert afterward) and ran everything for real against the operator's own repo-plane config rather than trusting a description of it.\n\npython3 -m pytest backend/tests/test_pr_execution_policy.py backend/tests/test_prompt_builder.py backend/tests/test_spawn_payload.py -q: 143/143 pass. That includes the 9-row resolver truth table in test_pr_execution_policy.py, the external/internal/fail-closed render checks and the new anchored-path / injection-neutralization tests added in this PR's fix-round commit (7847e319, on top of f2f5806).\nRan backend.pr_execution_policy.resolve() directly (not stubbed) against this PR and a second real internal PR, with a real gh login and AUTONOMOUS_TEAM_REPO unset: resolve(268, 'fulcrumaxe/fulcrumaxe', 2644) → ('host', ...), resolve(267, 'fulcrumaxe/fulcrumaxe', None) → ('host', ...) — both match the Spec's real-world verification requirement (an internal PR must resolve to host, never static-only).\npython3 scripts/ci/engine-manifest-guard.py and bash scripts/ci/commands-twin-divergence-guard.sh both exit 0 — the engine/manifest.json and agen","truncated":true},{"kind":"blocked","createdAt":"2026-09-28T20:58:12Z","body":"Fix round 2, addressing the round-2 security review's blocking finding.\n$OP_ROOT at steps 8 and 8b was computed with $(dirname \"$(git rev-parse --git-common-dir)\"), which only finds the operator checkout from a linked git worktree. verify_tree_build (the mechanism reviewers actually use to get a PR-head tree) clones a standalone tree instead — its own .git, borrowed objects via objects/info/alternates — so from inside one, that idiom resolved to the PR-head tree itself. Under static-only that's backwards: it's exactly the code path meant to never touch PR-head content.\nFix: render the operator root as an absolute path once, at spawn time, in apply_host_execution(), reusing pr_execution_policy._repo_root() instead of adding a second resolver. It's applied unconditionally (not mode-gated), since both steps need the real path under host too.\nAdded TestOperatorRootSurvivesAVerifyTree in test_pr_execution_policy.py: builds a real tree with verify_tree_build (scratch AUTONOMOUS_TEAM_STATE_DIR) and evaluates the rendered OP_ROOT line from inside it. Confirmed it fails against the pre-fix commit and passes against this one.\nKnown follow-up, not fixed here: step 7's gate1-invoke line has th","truncated":true},{"kind":"passed","createdAt":"2026-09-28T21:08:39Z","body":"Security review passed at head 50b73112. This was round 3.\nEarlier finding (code injection, CWE-94): fixed. Before this change, steps 8 and 8b in the code-reviewer template found the operator checkout with git rev-parse --git-common-dir. From inside a standalone git clone --shared verify tree, that returns the PR tree itself. A reviewer running there would execute the PR's own scripts/check-pr-cli-touched.sh and import the PR's own backend/spec_external_docs.py.\nI tested both commits the same way:\n\nFor each commit I built two clones: an \"operator\" tree that renders the prompt and a standalone \"PR-head\" verify tree.\nIn every copy of scripts/check-pr-cli-touched.sh and backend/spec_external_docs.py I planted a marker that writes a file when the code runs. The operator copies write an OPERATOR marker and the verify-tree copies write a PRTREE marker.\nI rendered code-reviewer.tmpl in static-only mode with that commit's own SpawnPrompt.render(), pulled out the step 8 and step 8b snippets exactly as rendered, and ran them with bash with the working directory inside the verify tree.\nA stub gh was first on PATH, and the harness checked that before running anything. Only four stubbed calls w","truncated":true},{"kind":"passed","createdAt":"2026-09-28T21:09:27Z","body":"Code review: pass (delta re-review, head 50b73112, delta 7847e319..50b73112).\nVerified 50b7311 is a clean fast-forward of 7847e31 (ahead by exactly one commit, zero divergence).\nThe single commit does what it says: the two OP_ROOT anchors in code-reviewer.tmpl steps 8 and 8b now come from a literal __PR_OPERATOR_ROOT__ sentinel, substituted in pr_execution_policy.apply_host_execution() to an absolute path from the existing _repo_root() — no new resolver added. The substitution is a single .replace() call applied before the host/static-only branch, so it runs unconditionally regardless of mode, matching the stated intent (both modes need the real path). Template diff is confined to those two steps; step 7's gate1-invoke line still uses the old git rev-parse --git-common-dir idiom, left alone as a disclosed follow-up (it's host-only, pre-existing).\nThe updated test_host_render_is_a_pure_substitution_no_structural_change assertion still does a full line-for-line comparison between the raw template and the host-mode render; it just now normalizes two known substitutions (the HOST_EXECUTION line and the operator-root sentinel) instead of one. Any other line mismatch still fails it — not","truncated":true}]},"repo":"fulcrumaxe/fulcrumaxe","selection":{"automatic":true,"score":73,"consideredPrs":40},"alsoNotable":[{"number":252,"title":"close the glued-redirect gap in the dial-registry write guard","url":"https://github.com/fulcrumaxe/fulcrumaxe/pull/252","mergedAt":"2026-09-27T23:58:37Z","rejections":2,"changedFiles":3},{"number":271,"title":"Stop step5 test seams from feeding a real merge","url":"https://github.com/fulcrumaxe/fulcrumaxe/pull/271","mergedAt":"2026-09-28T20:56:50Z","rejections":2,"changedFiles":9},{"number":270,"title":"fail closed when the CI provenance gate can't read a PR's file list","url":"https://github.com/fulcrumaxe/fulcrumaxe/pull/270","mergedAt":"2026-09-28T21:16:34Z","rejections":1,"changedFiles":4},{"number":254,"title":"record when a CI-status test seam is used","url":"https://github.com/fulcrumaxe/fulcrumaxe/pull/254","mergedAt":"2026-09-27T23:50:58Z","rejections":2,"changedFiles":6},{"number":272,"title":"warn once per process when a CI-status test seam is used","url":"https://github.com/fulcrumaxe/fulcrumaxe/pull/272","mergedAt":"2026-09-28T22:42:25Z","rejections":1,"changedFiles":3}]}