Skip to content

fix(pr-pipeline): refuse untrusted provenance at arm time, in the merge queue and in lane eligibility - #10040

Merged
kyle-sexton merged 9 commits into
mainfrom
fix/arm-untrusted-provenance
Oct 25, 2026
Merged

kyle-sexton merged 9 commits into
mainfrom
fix/arm-untrusted-provenance

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: owner decision Q-ARM (poteto session, 2026-10-25)

Summary

The untrusted-provenance hold was enforced only by the local babysit lane. A lanes App pull request whose linked issue gained work-class: untrusted-provenance (or any label naming untrusted work) after admission could still be armed for native auto-merge and pass the merge queue. This applies the same trust hold at three more points: at arm time in enable-auto-merge, in the pr-merge gate's lane_eligibility, and in ci-status's merge_group step. All three read the linked issue by the gate's own link rule and refuse on a label naming untrusted work in any spelling, a label removed by a non-human or through an App, or an unreadable link, label list or timeline.

Scope choices the owner approved: the merge-queue step checks only pull requests an automation opened (a person's own pull request is not read), and it matches labels with jq ascii_downcase, so Untrusted, UNTRUSTED and the canonical label all hold.

Fix

  • plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py:1697: new trust_refusal, the one home of the hold (labels read whole, _untrusted, _untrusted_removed_by_non_human). eligibility (:1995) now calls it instead of inlining the checks.
  • babysit_merge_policy.py:2643: lane_eligibility applies trust_refusal to the linked issue, judging a human with the lane's agent_identity, self_logins and permission.
  • plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py:246: the issue read fetches labels; Reader.link_refusal (:1353) applies trust_refusal after the link rule, so evidence --lane-link refuses an untrusted issue and enable-auto-merge arms nothing.
  • .github/scripts/pr-merge/enable-auto-merge.mjs:32: header comment names the trust hold as part of the link it requires.
  • .github/workflows/pr-require-checks.yml:4323: step Fail a queued pull request carrying a hold label reads, for an automation-opened pull request, its linked issue (closing issues, else the one plain Refs: issue by the base's refsIssue), its labels and its timeline, and fails on an untrusted label, one removed by anyone other than a person on the base's trusted-actor list or through an App, or any unreadable read (three attempts each).
  • docs/conventions/pr-pipeline/README.md:697, :1110, :1203: Merge authority and Native auto-merge describe the hold at all three points and how a person lifts it.
  • Changelog fragments under .changes/pr-pipeline/ and .changes/source-control/.

Verification

Run on the branch after merging origin/main (no conflicts):

  • bash scripts/ci-hold-merge-group.test.sh: PASS=42 FAIL=0 (runs the workflow step body against stubbed reads: untrusted label in variant spellings, non-human and App removals, trusted-actor removal, Refs link, unreadable link, labels, timeline and trusted-actor list).
  • python3 -m unittest discover -s plugins/source-control/skills/babysit-prs/scripts/tests -p 'test_*.py': 2932 tests, OK.
  • node --test .github/scripts/pr-merge/*.test.mjs: 362 pass, 0 fail.
  • shellcheck scripts/ci-hold-merge-group.test.sh and actionlint .github/workflows/pr-require-checks.yml: clean.
  • bash scripts/check-affected.sh --tests: 13 checks passed; of 39 selected shell suites, 37 passed and the 2 needing PyYAML (scripts/ci-test-node-stop-commands.test.sh, scripts/run-hygiene-gate.test.sh) passed when re-run with a local PyYAML venv on PATH (2 and 10 checks). Of the 78 delegated non-shell suites: the babysit Python suites are in the discover run above, scripts/test_check_contract_clause_coverage.py ran 24 tests OK, and the other 24 Node files ran 1308 tests, 0 fail (the 3 resolve-config files after npm ci in that directory).
  • scripts/check-stale-base-overlap.sh --check origin/main: HEAD is up to date with origin/main.

Related

  • Pull request states and the hold convention: docs/conventions/loop-lane/README.md.
  • Trust hold reference: docs/conventions/pr-pipeline/README.md, sections Merge authority and Native auto-merge.

🤖 Generated with Claude Code

kyle-sexton and others added 5 commits October 25, 2026 10:22
enable-auto-merge arms lane pull requests through
babysit_verify_evidence.py `evidence --lane-link`, which never ran
eligibility. So a label naming untrusted work, added to the linked
issue after admission while the lane built, did not stop the arm.

The link read now also applies the trust hold. The hold is one function,
babysit_merge_policy.trust_refusal, which eligibility now calls too:
labels read whole, none matching _untrusted, and none removed by a
non-human (_untrusted_removed_by_non_human). The labels come with the
link's existing GraphQL query and the timeline costs one REST read. A
refusal comes back as `ineligible`, which enable-auto-merge already
treats as a refusal a person clears (comment plus human-gated label),
so the JS needs no new code. An unreadable read refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LY6PpXaikB8J2tRLeypMmn
lane_eligibility, the pr-merge gate's own path for lane pull requests,
read no label at all, so an untrusted-provenance label on the linked
issue never held a lane merge outside native auto-merge. It now calls
trust_refusal on the linked issue, judging a human as eligibility does.
That is one more REST timeline read per lane pull request with a linked
issue.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
report-outcome writes a Hold: line only when the issue carries the
exact untrusted-provenance label at PR open, and enable-auto-merge
checks at arm time. So a label added after arming, or while the pull
request waited in the queue, still merged.

The merge-group step "Fail a queued pull request carrying a hold label"
now reads, for a pull request an automation opened, its linked issue:
the closing issues here, or with none, the one plain Refs: issue by the
base's merge-holds.mjs refsIssue. It fails on a label containing
"untrusted" in any case (_untrusted), or one ever removed by anyone not
a person on the base's trusted-actor list, or through an App
(_untrusted_removed_by_non_human, stricter than admit.mjs
untrustedHold, which lets the lanes App's removal lift it and reads
only the newest event). An unreadable link, label list, timeline or
trusted-actor list fails closed. That is one GraphQL read per queued
pull request, plus a timeline read per linked issue, and a labels read
for a Refs issue, when an automation opened it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 25, 2026 16:14
@chatgpt-codex-connector

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 🔄 Running since 2026-10-25T16:14:07.775258Z 90010ab 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 Oct 25, 2026
@kyle-sexton

Copy link
Copy Markdown
Member Author

Held with the do-not-merge label until Automation Lanes' security review of 90010ab returns. poteto removes the label when the review is in and dispositioned.

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed dbe26b42ecf01656c182500017284f89a8d1b747: 0 finding(s), 0 as inline comments.

Incremental security review of the four files that changed since 275130a, read against the PR context. I found no security issues.

The change does two things.

  • Fail closed on a bot with no id: The trust-hold step in ci-status now fails closed when the pull request author is a Bot and databaseId is not a number. Before, a null id made the lanes comparison false, so a bot that could have been the lanes App was treated as another automation. For a bot that read as a different automation, a no-link pull request passed the hold. In .github/workflows/pr-require-checks.yml, the jq ... error(...) branch plus || { ...; exit 1; } turns that case into a job failure.
  • One lanes App id for both steps: The lanes App id moves into one job-level LANES_APP_ID: 337595936. Both the trust-hold step and the lanes-hold step read it from there.

What I checked:

  • No widening:
    • An empty or missing LANES_APP_ID makes jq --argjson id "" error, which fails the step closed.
    • The lanes-hold step also validates the id with ^[1-9][0-9]*$ and exits 1 otherwise.
    • A null or ghost author is not a Bot, so it gets false, the same result as before.
    • The id is still hardcoded, and its value is unchanged.
  • Drift check: scripts/ci-lanes-pr-hold.test.sh now compares the job-level LANES_APP_ID with merge.agent-identity's id in .github/standards/trusted-actors/trusted-actors.json. The job-level value cannot drift from the trusted-actor list without that suite failing.
  • Tests: scripts/ci-hold-merge-group.test.sh and scripts/ci-lanes-pr-hold.test.sh cover the new null-id case and the missing-id case. They only change test inputs.
  • Changelog fragment: The .changes fragment just documents the new fail-closed case.
  • Trusted paths: The changed files match none of the trusted-path globs.

manifest: no manifest files changed.
critical-findings: 0

Spend: no change that draws on prepaid credit or subscription usage, and nothing that can start a real charge.

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed dbe26b42ecf01656c182500017284f89a8d1b747: 0 finding(s), 0 as inline comments.

Incremental review of the changes since 275130a. I found nothing to flag.

What changed

  • .github/workflows/pr-require-checks.yml: ci-status gets one job-level LANES_APP_ID: 337595936. The trust-hold step and the lanes-hold step now both read it. They no longer hard-code the id (337595936 in one, lanes_app_id=337595936 in the other).
  • The trust-hold step's jq now fails closed with ::error::the bot author id of #… could not be read when the author is a Bot with a non-numeric databaseId. Before, it compared .databaseId == 337595936 and so counted that bot as "not the lanes App".
  • The lanes-hold step rejects a missing or non-numeric LANES_APP_ID before it makes any call.
  • scripts/ci-hold-merge-group.test.sh and scripts/ci-lanes-pr-hold.test.sh: both tests read the id from the workflow instead of a literal. ci-lanes-pr-hold.test.sh still checks it equals merge.agent-identity's trusted-actor id. New cases cover a bot author with a null id and an empty LANES_APP_ID.
  • The changelog fragment now lists "a bot author with no numeric id" among the fail-closed cases. It matches the new behaviour.

Checks I made by reading the code

  • The job-level LANES_APP_ID does not change the Clear a cost-only review hold step, which sets its own step-level LANES_APP_ID from vars.AUTOMATION_LANES_APP_SENDER_ID at pr-require-checks.yml:3737. Step-level env overrides job-level env.
  • In the trust-hold step, a null author (a deleted account) gives __typename null, which is not "Bot", so the result is false and the step does not fail. A human author is unaffected. Only a Bot with a missing or non-numeric id fails closed, as the fragment says.
  • If jq errors, the || { … exit 1 } handler runs, so the failure does not slip past bash -e.
  • The test sed patterns match only the single six-space-indented job-level line. A duplicate definition would give a multi-line value, fail the numeric regex, and fail the test.
  • LANES_APP_ID (337595936) matches the melodic-automation-lanes[bot] entry in .github/standards/trusted-actors/trusted-actors.json:6.

I read these tests but did not run them. The PR description's pass counts are the author's claims, and I did not confirm them. I did not re-review files unchanged since 275130a. No manifest items apply, and the closing-issue section is empty because the PR cites an owner decision rather than an issue. No hold applies, because the change spends no billed resource.

kyle-sexton and others added 4 commits October 25, 2026 12:24
comment-hygiene's tracker-reference pattern flagged "issue 18's labels
read" in the stub's description.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and jq errors

The merge-queue trust hold step now fails a lanes App pull request
(matched by its bot databaseId, as the lanes App step matches it) that
does not link exactly one issue in this repository, so dropping the
link after arming no longer skips the check. Another automation's pull
request that links none still passes.

Both jq matches capture their exit code: 0 holds, 1 passes, anything
else fails closed instead of reading as no match.

babysit_merge_policy._untrusted matches "untrusted" ASCII-only, as the
step's jq ascii_downcase does; a shared fixture holds both to the same
table. The README says how a removal-by-non-human hold ends: a new
issue and a new pull request, since the timeline keeps the removal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The queue trust step matched the lanes App by author.databaseId; a Bot
author whose databaseId read null counted as another automation and
skipped the dropped-link check. It now fails closed.

The lanes App id is one job-level LANES_APP_ID in ci-status that both
the trust-hold and lanes-hold steps read, and both step suites take it
from the workflow. The lanes-hold step fails closed when it is unset.

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 Oct 25, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 25, 2026

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.

The pr-verify verifier failed head dbe26b42ecf01656c182500017284f89a8d1b747. What it wrote, as data:

Summary: PR #10040 links no issue, so the spec is the PR's own title and body. It asks for the untrusted-provenance trust hold to be enforced in three more places: at arm time (`evidence --lane-link` / `enable-auto-merge`), in `lane_eligibility`, and in the merge-queue step of `ci-status`. The diff adds all three, they fail closed, and the tests are thorough. One unrequested change blocks: `_untrusted` used to match with Unicode `casefold()` and now uses an ASCII-only regex. That narrows the existing babysit `eligibility` hold, which was the only untrusted-work hold before this PR, so labels such as `untruſted` or `untrusted` stopped holding. This loosens a hold on outside work that the owner keeps, and it contradicts the body's own "any spelling". The body says the owner approved `ascii_downcase` only for the merge-queue step.
- context.json: a trusted comment says the PR is held with `do-not-merge` until a security review of 90010ab3 is dispositioned. That is context, not a spec requirement, but the hold still applies.
- .github/workflows/pr-require-checks.yml:4376: the queue step judges who removed a label by the base's `trusted-actors.json` human ids. The Python readers use `is_human`, which is permission-based. So a write-access person who is not on the list lifts the hold in Python but not in the queue. This is stricter and documented, so it does not block, but a human should know the two disagree.
- .github/workflows/pr-require-checks.yml:3143: `LANES_APP_ID` moved from a hard-coded step variable to a job-level env value, still checked against `merge.agent-identity`'s trusted-actor id by `scripts/ci-lanes-pr-hold.test.sh`. The step now fails closed when the value is not numeric. No takeover risk found.

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.

The pr-verify verifier failed head dbe26b42ecf01656c182500017284f89a8d1b747. What it wrote about this file, as data:

- plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py:1398: `_untrusted` changed from `"untrusted" in str(label).casefold()` to the ASCII-only `UNTRUSTED` regex. Labels the old check held (`untruſted`, `untrusted`, `UNTRUſTED`) now pass `eligibility`, `lane_eligibility` and `link_refusal`. The spec asks for no such loosening; it says to refuse 'in any spelling'. Restore the casefold match, or keep ASCII matching and also match casefold. A Python check stricter than the queue's jq check is defence in depth, not a defect.

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.

The pr-verify verifier failed head dbe26b42ecf01656c182500017284f89a8d1b747. What it wrote about this file, as data:

- plugins/source-control/skills/babysit-prs/scripts/tests/fixtures/untrusted-labels.json:14: the `passes` list pins `untrusted`, `untruſted` and `UNTRUſTED` as passing, and `test_the_label_match_agrees_with_the_queue_step` (test_babysit_merge_policy.py) asserts this for Python. After restoring casefold, have the Python test expect these to hold, for example by moving them to a separate `python-holds` list that `ci-hold-merge-group.test.sh` treats as passes or skips.

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.

The pr-verify verifier failed head dbe26b42ecf01656c182500017284f89a8d1b747. What it wrote about this file, as data:

- plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_merge_policy.py:3636: the test case `[MECHANICAL, "work-class: untrusted-provenance"]` is removed from the 'class label is ignored' test. This is correct now that `lane_eligibility` refuses that label, and new tests cover the refusal.

Merged via the queue into main with commit f55e829 Oct 25, 2026
83 of 85 checks passed
@kyle-sexton
kyle-sexton deleted the fix/arm-untrusted-provenance branch October 25, 2026 18:06
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