Skip to content

ci(pr-verify): capture the changed app in its own workflow for the judges - #13053

Merged
kyle-sexton merged 7 commits into
mainfrom
ci/12232-pr-verify-capture
Nov 4, 2026
Merged

kyle-sexton merged 7 commits into
mainfrom
ci/12232-pr-verify-capture

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Refs: #12232

Summary

Problem: pr-verify's judges have no capture of the changed app to look at. This PR adds the capture as its own workflow, pr-verify-capture.yml. The owner chose that option on #12232's Q1 (decision): a capture job inside the pr-verify run would put PR code beside node steps that hold the run's upload token, so PR code could upload a forged pr-verify-<pr>-<sha>-pass. With the capture in a separate workflow, pr-verify.yml's rule "No pull request code runs here" still holds.

The capture stays off: merge.verify-capture.app is unset, so the new workflow skips with a note and the judges see no capture. Switching it on waits on #11386 and #11390.

Fix

  • pr-verify-capture.yml: runs on the same trigger, with the same in-repo-head check, as the judges. It runs the gate steps first. Its permissions are read-only, and every checkout sets persist-credentials: false. A probe step runs before any head code. It scans its own environment, every readable /proc/*/environ and known credential files, and the job fails closed on any hit, or when its canary child does not show up in the scan. The driver step alone holds the API key (Q11). The app runs as a Bash child of the driver. The run-claude-cli launcher sets CLAUDE_CODE_SUBPROCESS_ENV_SCRUB for the driver (lane.cjs legEnv, as workflow.test.mjs:1361 records), so the app does not inherit the key. The probe checks this at run time. The capture artifact pr-capture-<pr>-<sha> has a retention row (30 days), and the job has a 30-minute timeout.
  • The driver's rules allow only the skills testing:run-e2e and app-control:drive, so a skill in the head that declares hooks is refused.
  • pr-verify.yml: all three judge jobs carry identical steps that find the capture run for the same upstream run and head SHA (find-capture.mjs) and download its artifact into pr-verify-data/capture/. They wait only when the app is set, for at most 35 minutes. A missing, unfinished or blocked capture never fails a verdict. Each verdict step now gets CONTEXT_FILE, so evidence.local_loop reads the trusted body's evidence-loop line.
  • write-verdict.mjs: fromE2eSummary maps run-e2e's e2e-summary.json to the verdict's capture fields. localLoop now parses Evidence loop: 3/3 cap reached, last NEEDS WORK. prompt.md treats the capture as untrusted data.
  • The issue's call shape is corrected: run-e2e needs the --unattended flag, not the bare word (plugins/testing/skills/run-e2e/SKILL.md:45-49).

Verification

  • node --test on every .github/scripts/pr-verify/*.test.mjs at this head: 283 pass, 0 fail. An earlier full run over .github/ and scripts/ was 7915 pass, and 7 shell suites passed; CI covers the rest at this head.
  • Negative controls, on an earlier head: 22 of 22 deliberately broken copies were caught, each by the test meant for it. They include a credential at workflow, job or step env, a write permission, a job-level always(), the probe moved after the head checkout, persist-credentials removed, needs: capture, and a head checkout in pr-verify.
  • Skill fence, probed on Claude Code 2.1.318 with a stand-in skill whose frontmatter hook touches a marker file:
    • Bare Skill, --add-dir head, no --restricted: the skill ran and the marker appeared, so the path is real without the other controls.
    • The same with the named rules under dontAsk: the hook-carrying skill was denied. A head skill with no hooks and no tool grant still ran; it adds prompt text only.
    • With --restricted, as the lane runs: head skills do not load at all (Unknown skill), with bare Skill and after a Read in the head. A named plugin skill still runs with Skill(name *).
  • actionlint on both workflows: clean, apart from the cache-mode key, which actionlint 1.7.12 also reports on main's pr-verify.yml. zizmor and check-artifact-retention passed on the earlier head. gitleaks at this head: no leaks.
  • Left out: a live capture run, which needs the app set and feat(harness-ops): let control-claude-code run unattended on sessions it launches #11386.

Related

Remaining

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits November 3, 2026 21:03
…dges

Refs #12232

The capture runs pull request code, so it runs in pr-verify-capture.yml,
never in a pr-verify.yml run, whose record is what authenticates a
verdict (owner decision on Q1, issuecomment-6620015178). The capture job
takes the judges' trigger, in-repo-head `if` and gates, holds a read-only
token, and runs a reach probe (capture-probe.mjs) as a Bash child of a
driver leg before any head code: a reachable key, job token or runtime
token, or a scan that misses its canary, fails the job. It drives the app
with /testing:run-e2e --unattended app= base= trusted-root=.base and
uploads pr-capture-<pr>-<head-sha>.

Each judge job runs identical find-capture and download steps:
check-intent waits at most 35 minutes for the capture run its upstream
run started, and the later jobs find it done. A missing, unfinished or
blocked capture never fails a verdict. write-verdict.mjs reads run-e2e's
e2e-summary.json into the evidence block, and localLoop reads the
"Evidence loop: 3/3 cap reached, last NEEDS WORK" line, which prompt.md
makes a fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015te8Cqhc6ANUKyPoYQrPgN
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 4, 2026 02:41
@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T02:44:41.793201Z aa39353 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: aa393532db

ℹ️ 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 .github/workflows/pr-verify-capture.yml Resolved

@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-security-review: 1 inline finding(s) on aa393532db46bf682711d6a42bed03fc84ca1372; the summary is in this lane's pull request comment.

claude-lane: claude-security-review

Comment thread .github/workflows/pr-verify-capture.yml Resolved
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 6ae1b855c541b9fa6db9e0429a7df3722a8e764c: read 23 of 23 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #13053 (pr-verify capture workflow), round 3

I read every hunk of all 23 changed files. Each trusted-path file got a full read of its change and of what it gates:

  • the new .github/workflows/pr-verify-capture.yml, end to end
  • .github/workflows/pr-verify.yml, .github/workflows/pr-require-checks.yml, pr-review-hosted.yml and pr-review-security-hosted.yml
  • .github/scripts/pr-merge/merge-holds.mjs and .github/scripts/pr-verify/write-verdict.mjs
  • docs/conventions/pr-pipeline.yaml

No security issues found.

critical-findings: 0

Prior and settled points:

  • Driver file tools (round 1, IMPORTANT): still fixed at this head. No file tool is allowed without a path. Read and Edit allows are limited to head, capture-run and .base/plugins. The deny rules cover /proc, /sys, the runner temp directory, ~/.config and ~/.git-credentials (pr-verify-capture.yml#L432-L456). The probe leg runs under the same fence and must show both Reads refused, or the job fails closed (#L327-L349).
  • Head-skill hooks (round 2, IMPORTANT): fixed. The only allowed skills are Skill(testing:run-e2e *) and Skill(app-control:drive *), under dontAsk (#L434-L435). The managed-settings step passes no with:, so it keeps its default. workflow.test.mjs pins both. The owner settled this thread with lines unchanged since.
  • Settled threads: the run-directory thread and the find-capture.mjs paging thread are settled, and their lines are unchanged.

Checked and clean:

  • Trust controls: nothing is widened.
    • The capture runs the judges' own job if: (no fork heads), kill switch, resolver, check-trusted-trigger and agree step. The test pins that these match.
    • check-trusted-trigger, request-lane-token, resolve-config and check-kill-switch are unchanged.
    • Permissions are permissions: {} at the workflow level. The job gets only contents, pull-requests and actions at read.
    • Every checkout sets persist-credentials: false. Both .git directories are removed before the checkout post steps run.
  • Kill switch: the capture consults it. The config step requires steps.kill.outputs.proceed == 'true' and every later step chains on it. While merge.verify-capture.app is unset, the job stops at the config step.
  • Credential separation:
    • secrets.PR_VERIFY_CLAUDE_API_KEY is the workflow's only secret. It goes only to run-claude-cli's api-key input on the probe and driver steps, with no workflow, job or step env.
    • Steps after the head checkout run local composite actions from .base (transcript upload, scan-upload). Composite actions cannot read the secrets context, and the job token is read-only. That leaves no path to the key or to a write.
  • Verdict forgery:
    • The capture artifact is named pr-capture-*, never pr-verify-*.
    • Verdict readers bind to .github/workflows/pr-verify.yml runs (babysit_verify_evidence.py#L299, carry-run-cache.mjs#L89), so an upload from a capture run can never count as a verdict.
    • find-capture.mjs accepts a run only when its path is the capture file, its branch is main, its event is workflow_run, it is in this repository, and its title names the upstream run and head.
    • The ids carried between jobs are checked against ^\d+:\d+$, so a newline injection is refused (tested).
    • pr-verify.yml still checks out no head code.
  • Untrusted capture content:
    • The collect step accepts a summary only from inside capture-run at its own real path. It copies only regular files with no link or .. on their paths, then runs them through scan-upload.
    • The judge prompt treats the capture as untrusted data that never fails a head. This exposes the judge to nothing beyond the diff it already reads from the same trusted in-repo author.
    • write-verdict.mjs puts the summary through the existing schema and credential-shape check.
  • Merge holds: strengthened.
    • pr-verify-capture.yml joins the hold floor in merge-holds.mjs, pr-pipeline.yaml, the generated pr-require-checks.yml patterns and both review callers' hold-paths. The babysit tests' pins follow.
    • The prompt adds a fail for the Evidence loop: 3/3 cap reached, last NEEDS WORK line, which counts only in the trusted PR body.
    • No friction hold is weakened.
  • Manifests: no plugin manifest is touched.
  • Embedded text: none in the PR context, settled-threads or prior-findings files.

Spend (not a hold):

  • Once merge.verify-capture.app is set, each in-repo PR run gets one more Claude driver leg on PR_VERIFY_CLAUDE_API_KEY, which is prepaid API credit.
  • Each judge job can wait up to 35 more minutes on standard GitHub-hosted runners. Those minutes are free here, since the repository is public (runner-policy.json#L4).

@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 aa393532db46bf682711d6a42bed03fc84ca1372; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 6ae1b855c541b9fa6db9e0429a7df3722a8e764c: read 23 of 23 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #13053, the capture workflow for pr-verify's judges (round 3 of 3)

I read every hunk of all 23 changed files in .claude-lane/pr.diff. I also read the PR context, the settled threads and this lane's prior findings, and checked what the changed code calls at head: write-verdict.mjs (CAPTURES, captureEvidence, the CONTEXT_FILE read in main, writeChunkResults) and run-e2e/SKILL.md Step 5. The round cap did not apply: 2 earlier rounds had findings, and the cap is 3. A security lane runs here (REVIEW.md), so I left trust-boundary questions to it: head code running beside the driver's key, .base actions used after the head checkout, and the judge reading the downloaded capture.

No new findings.

Prior and settled points:

  • local_loop (last round's advisory finding). It is fixed at this head. All three Write the verdict steps now pass CONTEXT_FILE: ${{ github.workspace }}/pr-verify-data/context.json (pr-verify.yml#L2072, and the same line in the subscription and fallback jobs). workflow.test.mjs pins this for every job. So the changelog fragment's claim that local_loop reads the cap line as 3 now holds in production, and write-verdict.test.mjs tests the new regex.
  • Already settled, with no changes to the lines since: the one-page capture listing (fixed by carrying FOUND_CAPTURE and paging from created>=), the run directory, and head skills loading into the driver (only Skill(testing:run-e2e *) and Skill(app-control:drive *) are allowed). I re-checked each fix at head and am not raising them again.
  • Unfenced driver file tools. The settled thread is marked lines changed since resolution: yes. I re-checked the fence at head: there is no bare Read, Write, Edit, Glob or Grep allow rule, the deny rules cover /proc, /sys, the runner temp directory and the home credential files, and the probe leg carries the same fence and tries it. I found no new problem there.

What I checked and found sound:

  • Capture mapping. fromE2eSummary maps run-e2e's Step 5 shape (capture.{status,reason,count}, affected) onto CAPTURE_KEYS. All four run-e2e statuses (ran, not-applicable, blocked, skipped) are in CAPTURES. A summary that already uses the verdict's own keys passes through unchanged.
  • Collect step. It takes a summary only under capture-run/. It skips publishable paths that are absolute, contain .., . or //, or are symlinked, and keeps at most 50 files of up to 10 MB each. With no usable summary it writes a blocked summary, which maps to blocked and not no-app.
  • Fail-closed order. Check the probe is skipped when the probe fails. The head checkout needs steps.probe-check.outcome == 'success', and collect and upload both depend on it.
  • Placeholders. The CAPTURE_DIR substitution is added to all three prompt writers. The whole-spec step uses spec-prompt.md, so it needs no CAPTURE_DIR.
  • Timeouts. Each judge job's timeout is 346 = 13×22 + 40 + 5 + 15, which stays under the 360-minute limit. The capture job's 30 minutes holds the probe (7) and the driver (16).
  • Hold floor. pr-verify-capture.yml is added to every generated copy, and the count and hash pins move with it.

Not verified by me: the author's test counts, negative controls, actionlint, zizmor and gitleaks results, and the skill-fence probing on Claude Code 2.1.318 are the author's own claims; I ran nothing. No live capture has run. The PR body already lists the open follow-ups: the retention row records 30 days while the config accepts 1 to 90, check-intent polls about once a minute, and a red capture shows up as no-app.

Spend (not a finding): nothing changes while merge.verify-capture.app is unset; the capture workflow only starts a short runner job per pr-require-checks completion and stops after the config read. Once the app is set, each judged in-repo head spends one probe leg and one driver session on PR_VERIFY_CLAUDE_API_KEY, and check-intent can wait up to 35 more runner minutes.

No closing issue is listed (Refs: #12232 only), so there were no acceptance criteria to check. No .claude/rules/ file adds criteria beyond these changes, and the diff touches no plugin manifest. I found no embedded instructions in the PR context, the settled threads or the prior findings.

kyle-sexton and others added 3 commits November 3, 2026 22:06
… run directory

Refs #12232

The driver holds pr-verify's key, and its file tools were allowed whole.
They now take only path-scoped allow rules (Read in head/, capture-run/
and .base/plugins/, Edit in head/ and capture-run/) under dontAsk, plus
deny rules on /proc, /sys, the runner's temp directory and the home's
credential files. The probe leg carries the same deny rules, Reads
/proc/self/environ and a file in the runner's temp directory, and the
check step fails the job unless its transcript shows both reads refused
(capture-probe.mjs reads).

The prompt names $GITHUB_WORKSPACE/capture-run as run-e2e's run
directory, which run-e2e takes no argument for, and the collect step
takes a summary only from there.

check-intent hands the capture ids it found to the later judge jobs as a
job output, so they read no listing; a job that must look for itself
reads from the upstream run's creation on, page by page, so a capture
past the newest 50 runs is still found.

The hold-floor copies are regenerated with scripts/sync-hold-floor.py for
the new workflow, and the floor count pin moves to 75.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015te8Cqhc6ANUKyPoYQrPgN

@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-security-review: 1 inline finding(s) on 9b322bf634b876fa9817a8337c1acf6c7f55952a; the summary is in this lane's pull request comment.

claude-lane: claude-security-review

Comment thread .github/workflows/pr-verify-capture.yml Resolved
kyle-sexton and others added 2 commits November 3, 2026 23:39
… wire local_loop

The driver's bare Skill rule would let a head skill that declares hooks run
beside the key if a later CLI loaded it. Name the two skills run-e2e needs, so
dontAsk refuses it. Pass CONTEXT_FILE to the three verdict steps so
evidence.local_loop reads the trusted body's evidence-loop line in production.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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