Skip to content

feat(pr-verify): let the capture drive a named action against a clone of the head - #16442

Merged
kyle-sexton merged 2 commits into
mainfrom
feat/pr-verify-capture-drive-target
Nov 15, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
feat/pr-verify-capture-drive-target

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #16385
Closes #16386

Summary

Parts 1 and 2 of #16383. The pr-verify capture can now record a named action of a command-running skill against the pull request's head, with git history available, and the control skill's architecture, corrections and review features name the action to drive.

Before this change the driven Claude Code session ran in an empty folder on the sandbox's tmpfs, with no git history, and the head checkout was mounted read-only, so a skill that reads history (the layout lens's co-change.mjs) exited 2 and a run could not write its memory file.

Fix

  • .github/scripts/pr-verify/sibling-workdir.sh (new): runs inside the sibling sandbox. It waits for a head-ready directory, then git clone --shareds the read-only head checkout into the driven session's working directory ($HOME/w on the sandbox's own tmpfs), copies origin's remote-tracking refs so the default branch resolves, and writes {status, head}. A failed clone empties the directory again.
  • sibling-init.sh: starts that script in the background before the broker starts. The broker and every session it launches already run in $HOME/w, which .claude.json already trusts.
  • pr-verify-capture.yml: installs the script root-owned beside sibling-init.sh. A new step, "Clone the head for the driven session", runs after the head checkout. It makes head-ready, waits up to 150 s and passes only when the sandbox reports ready at the head SHA. It runs under continue-on-error, so a failed or late clone leaves the old empty-directory behavior and the capture still runs. The capture prompt now tells the driver which case holds and to drive the action a feature's ## Drive names, with exactly its arguments.
  • Control skill (.claude/skills/control-claude-code-plugins/): architecture names /architecture:improve layout, corrections names /corrections:codify count-checks, and review names /review:fanout --unattended, which runs under the reproduce_findings value the checkout's docs/conventions/review.yaml sets (label today). The hub's gotcha now says the driven session starts in a clone of the head.

Credential separation is unchanged

  • The bwrap arguments are unchanged: the same mounts (workspace, head and .base read-only; only capture-run and the runtime directory writable), no network, the same env -i allowlist, no new capability and no new user namespace. The existing tests that pin each flag pass unchanged.
  • The clone lives on the sandbox's private tmpfs over $HOME. No step outside the sandbox reads it, and nothing written there is trusted afterwards. The workflow reads only the one-line workdir.json result, as data, compared against the head SHA.
  • No new secret, token or credential reference. The new step and the prompt step hold none, and the existing "no step from the head checkout on holds a secret or the job token" test still passes. The key proxy, the client key, the driver legs' managed settings and the local --restricted launch are untouched.
  • Inside the sandbox, the driven session now loads the head's project files (CLAUDE.md, .claude/settings.json) as its project's, because its working directory is the head. They run in the same sandbox as the plugin code under test, which already runs there, and they reach the API only through the bridge to the key proxy.

Verification

  • node --test --test-concurrency=4 .github/scripts/pr-verify/sibling-workdir.test.mjs: 4/4 pass. The tests cover a ready clone (HEAD equals the head, 3 commits of history, origin/main resolves, writable, the head stays unchanged), a timeout, a head that is not a repository, and a non-empty working directory. Removing the remote-ref fetch makes the ready case fail.
  • node --test --test-concurrency=4 .github/scripts/pr-verify/workflow.test.mjs: 86/86 pass, including three new tests. One pins the install, the background launch and the step order. One runs the clone step against ready, wrong-SHA, failed, timeout and missing results. One runs the prompt step with and without a clone.
  • shellcheck is clean on both sandbox scripts. check-map.sh reports no findings on the control skill. Local actionlint reports only the existing cache-mode key (line 133), which predates this change; CI's pinned actionlint accepts it.
  • Not testable locally: the capture runs only in Actions, inside bwrap on a hosted runner. To check it, look at the first capture run on a pull request that touches plugins/architecture, plugins/corrections or plugins/review. Its "Clone the head for the driven session" step should print ::notice::the driven session starts in a writable clone of the head at <sha>, and the run's sealed transcript should show the named action driven.

Related

🤖 Generated with Claude Code

… of the head

The pr-verify capture's driven Claude Code session ran in an empty folder
with no git history, and the read-only head mount left a skill nowhere to
write. Once the head checkout fills, the sibling sandbox now clones the
head (sharing its object store, with origin's remote-tracking refs) into
the driven session's working directory on its own tmpfs, so a skill there
has the head's files and history and can write beside them. Nothing
outside the sandbox reads that directory. A clone that fails or is late
leaves the directory empty and the capture still runs; the prompt tells
the driver which case holds and to drive the action a feature's Drive
section names.

The control skill's architecture, corrections and review features now
name the action to drive: improve layout, codify count-checks and fanout
--unattended.

The sandbox's mounts, network, environment and credentials are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 15, 2026 21:20
@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-15T21:22:17.026567Z 745767d 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.

@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 30cfebed662673aabd2f769b7c7491f6fc97c275: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Security review (incremental, 745767d → 30cfebe): PR #16442

I found no security issues. I read the whole change in all 4 files on the incremental list. Two of them match trusted paths: .github/workflows/pr-verify-capture.yml and the .claude-lane/** inputs. For those I also read the full head copy of sibling-workdir.sh, the script the changed workflow step drives. This lane already reviewed an earlier head, so this review was blocking only: it reports CRITICAL and IMPORTANT findings, and SUGGESTION findings are dropped.

What I checked

  • The prompt now names a trusted source for ## Drive. The capture prompt used to say "a feature's ## Drive". It now says "a feature's ## Drive in the control skill under $GITHUB_WORKSPACE/.base" (pr-verify-capture.yml#L1253-L1254). The driver now takes the action to drive from the base checkout rather than from text the head could plant. This narrows what untrusted text can decide; it widens nothing.
  • The warning line can no longer inject workflow commands. "Clone the head for the driven session" used to print .status from workdir.json with jq -r ... | strings. A status holding a newline and ::error:: could have injected a workflow command. Now only failed, timeout or ready is printed, and any other value becomes no result (L1236-L1240). The test pins this with an injected-status case.
  • The step now rejects a symlinked or pre-planted handshake file. It refuses a result file that is a symlink, and refuses to start if head-ready already exists, as a directory or a link (L1205-L1208). There is a small window between the -L check and the jq read. It does not matter here: only trusted code has run in the sandbox at this point, this step holds no secret or token, and the result only picks a fixed prompt text.
  • The clone script stays inside the sandbox's tmpfs, with no injection surface. In sibling-workdir.sh:
    • The clone and the fetch now run under timeout (CLONE_SECONDS, default 120; FETCH_SECONDS, default 20) (L60-L61). Both values come from the root-owned launcher's environment.
    • empty() is checked at entry and again right before the clone, so the find -delete cleanup only ever removes what the clone wrote, and only in $HOME/w.
    • report() still builds its JSON with jq --arg, and now exits 1 when it cannot write the result.
    • All arguments are quoted and the source is a local path.
  • The two test files (sibling-workdir.test.mjs, workflow.test.mjs) only add test cases. They use temporary directories and a stub git placed on PATH for one test. No credentials are involved.
  • Trust controls: none touched. The trusted-trigger check, lane-token request, kill switch, token broker and merge holds are unchanged, and the change has no manifest edit. The sandbox's bwrap arguments are also unchanged.
  • Instruction surface: no standing rule is deleted or softened. The one prompt edit narrows where the drive instruction comes from.
  • Spend: the clone is now capped below the existing 150 s wait, so this change adds no lane runtime.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude-review: 1 inline finding(s) on 745767d5318fdaf9531685de2567352fc2ac7fc3; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 30cfebed662673aabd2f769b7c7491f6fc97c275: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Code review: #16442 (incremental, 745767d → 30cfebe)

No blocking findings in this push.

Scope. This review was blocking only, because this lane already reviewed an earlier head. I read every hunk of the 4 files listed in .claude-lane/incremental-files.txt:

  • sibling-workdir.sh
  • sibling-workdir.test.mjs
  • workflow.test.mjs
  • pr-verify-capture.yml

I also read the whole of sibling-workdir.sh at the head. I ran nothing, so the test results in the PR description are the author's claims and I have not checked them.

Earlier advisory finding is fixed. That finding (discussion_r4580300084) said a late clone could change the working directory after the driven session had already started there. This push fixes it:

  • Time limits. The clone is now limited to CLONE_SECONDS (default 120 s) and the fetch to FETCH_SECONDS (default 20 s). Together that is 140 s, under the workflow's 150 s wait, so a slow clone ends as failed and is cleaned up before the workflow stops waiting.
  • Cleanup only removes the clone's own files. <workdir> is checked for emptiness when the script starts and again just before the clone. A directory that already holds files is reported failed and left as it was. The new test checks that a planted file survives.
  • New tests. One cuts off a hung clone with a stub git and checks the directory is emptied. Another checks that a result file the script cannot write makes it exit 1 with a message.

Workflow step. "Clone the head for the driven session" now handles the result file more strictly:

  • It refuses a workdir.json that is a symlink.
  • It prints only a status from the fixed set ready, failed or timeout. Anything else, such as non-JSON or a status containing a newline, prints as no result.
  • It fails with an error if the head-ready path already existed before the head checkout finished.

The tests now compare the exact output line, so an injected ::error:: line would make them fail.

Prompt change. The capture prompt now points the driver to the ## Drive sections in the control skill under $GITHUB_WORKSPACE/.base, the base branch's copy, not the head's. As a result, the ## Drive lines this PR adds only take effect after it merges. That fits reading the control skill from trusted code.

Other checks.

Verifier dropped 0 of 0 candidates.

Security review follow-ups on the head clone for the driven session:

- The clone step prints the sandbox's result status only from a fixed
  vocabulary (ready, failed, timeout, else "no result"), ignores a
  result file behind a symlink, and fails with a named error when the
  head-ready handshake path already existed.
- sibling-workdir.sh bounds the clone (120 s) and the fetch (20 s) below
  the workflow's 150 s wait, so a slow clone ends failed and emptied.
- It refuses a working directory that is not empty, at entry and again
  before the clone, so the failure cleanup removes only what the clone
  wrote.
- A result it cannot write exits 1 with a line in its log.
- The capture prompt names the control skill under .base as the one
  whose Drive section names the action.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton kyle-sexton removed the do-not-merge Hard merge gate: do not merge while applied. label Nov 15, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit a873fc5 Nov 15, 2026
76 checks passed
@kyle-sexton
kyle-sexton deleted the feat/pr-verify-capture-drive-target branch November 15, 2026 21:43
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 6, survived 1, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 86%; mutation score 86%.

File Killed Survived Timeout No coverage Invalid Not run
.github/scripts/pr-verify/sibling-init.sh 1 0 0 0 0 0
.github/scripts/pr-verify/sibling-workdir.sh 5 1 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
.github/scripts/pr-verify/sibling-workdir.sh:55 SBR unclassified none

The run's summary has the full report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

1 participant