Skip to content

feat(pr-pipeline): add the applied-by contract and patch-rules registry - #8477

Merged
kyle-sexton merged 9 commits into
mainfrom
feat/pr-pipeline-applied-by-contract
Oct 19, 2026
Merged

kyle-sexton merged 9 commits into
mainfrom
feat/pr-pipeline-applied-by-contract

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

No related issue: Phase 3 of the lane-funding write-lane plan (owner-approved 2026-10-19)

Hold: a human merges this
Broker pin: melodic-software/azure-iac#57

Summary

This adds the config contract that later phases use to move write lanes' model steps onto ci-workflows run-claude-cli, so each lane spends its role's API credits first. A model activity will hand its change on as a patch to a separate apply step. The new applied-by field names which script activity applies each artifact. The new trust-root registry, .github/actions/resolve-config/patch-rules.json, holds the rules each producer's patch is to be held to. No live activity sets applied-by yet, so lane behavior does not change.

Fix

  • pr-pipeline.schema.json:
    • adds applied-by, a closed key set (patch, feedback-replies, dependency-verdict, work-outcome), allowed on skill leaves only, forcing effect: read and gating: advisory;
    • removes funding;
    • allows checks, self-checks, verify-scripts and web-access (when on) only on a skill whose runner stages edit tools: an effect other than read, or applied-by.patch without prepare: ci-context ($defs/edit-runner). Before, they needed an effect other than read, and checks had no rule.
  • pr-pipeline.yaml: removes the unused funding: map.
  • resolve.mjs rejects with invalid-applied-by a target that:
    • is not a script, or sits outside the lane;
    • is a patch target without prepare: apply-patch;
    • sits in a slot that does not needs the producer.
  • patch-rules.json and its schema hold rows ci-context, review-threads, dependency-review, merge-base, default and issue.
    • Every row must refuse the universal set: .github/**, .claude/**, root .mcp.json, .gitmodules, **/settings*.json, symlinks, gitlinks, new exec bits, and renames into refused paths.
    • A row with base as a commit parent must allow exactly [merge-result].
    • Unknown predicates are rejected.
  • resolve-config.mjs checks the patch rules on every lane run and fails closed. It also rejects an applied-by key the runner does not list in the new applied-by-supported input. pr-run-activity-read.yml passes applied-by-supported: patch.
  • collect-base-activity and the changed-paths filter grant edit tools on effect != read OR applied-by.patch. The effect half goes once the last skill leaves pr-run-activity-write.yml.
  • New broker-vendoring.test.mjs checks the reader's import closure and the files loadConfig needs against the azure-iac broker's vendored lists and binding.mjs TRUST_FILES. It fails naming the missing key, which guards against the kind of broker outage seen on 2026-10-19.
  • Docs: the pr-pipeline README, pr-run-activity.md and the resolve-config README describe the contract and say what is not yet in effect.

A pull request that edits a .github/workflows file runs pr-refine / fix-docs, which is expected to go red here and is not a regression.

Verification

  • node --test over .github/actions/resolve-config/*.test.mjs and .github/actions/collect-base-activity/*.test.mjs: 540/540 pass on 8e78e7c (530 before the review fix in cda5fd3).
  • scripts/check-affected.sh --tests: no failures on 8e78e7c.
  • Broker compatibility (run on 8e78e7c): the currently pinned reader (359c1fa) loads this tree's config and trust files, including the changed pr-pipeline.schema.json, without error, and gives the same grant results as this tree's reader for all 13 live lane slots (0 differences). The pin PR changes only resolve-config.pin.
  • Two fresh-context verifier passes. The first failed two criteria: docs ahead of code, and merge rows accepting any. Both were fixed, and the final pass found only wording, which was corrected.
  • Revert after the broker deploy: revert azure-iac#57 and deploy it first, then revert this change.

Related

  • melodic-software/azure-iac#57 (broker pin; owner deploys after this merges)
  • Lane-funding plan phases 4-8 consume this contract

🤖 Generated with Claude Code

kyle-sexton and others added 5 commits October 19, 2026 12:38
A read skill leaf's applied-by names what it hands on (patch,
feedback-replies, dependency-verdict, work-outcome) and the script
activity that applies each. The schema limits it to skills with effect
read and gating advisory; the config reader rejects invalid-applied-by
targets (not a script, a patch target without prepare: apply-patch,
outside the producer's lane, or a slot that does not need the producer).
resolve-config emits the map and takes applied-by-supported, which the
read runner passes as patch. A read skill with applied-by.patch gets the
write tool set without commit tools, and changed-paths leaves out
instruction surfaces for it. No live activity sets applied-by yet.

patch-rules.json registers, per producer prepare mode plus default and
issue, what apply-patch admits; checkPatchRules validates it against its
schema, the universal refused set, two-parent commits and rows for every
mode in use. broker-vendoring.test.mjs checks resolve.mjs's closure and
the trust-root JSON against the broker's vendored lists, with the two
registry files pending the azure-iac pin pull request.

The funding map and the read-effect bans on web-access, self-checks and
verify-scripts are removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
resolve-config now reads patch-rules.json and its schema beside itself
and runs checkPatchRules before every lane resolve, failing closed when
either is missing or invalid, and fails an applying leaf whose
applied-by sets a key applied-by-supported does not name. The check
stays out of loadConfig and resolveGrant, so the lanes token broker,
which passes only the trust-root files its binding lists, needs no new
file on either the old or the new pin.

broker-vendoring.test.mjs now copies the broker's TRUST_FILES and the
exports it calls, and checks that every file loadConfig needs is one the
broker reads from main's tip and serves its tests, that the patch rules
are not among them, and that the broker's calls resolve this tree's
config. collect-base-activity gains tests for a read skill that hands
on a patch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gistry does today

A patch-rules row whose commit has the base as a parent must allow
exactly [merge-result]; [any, merge-result] is now rejected, with a
fixture. The docs and the prepare description now call patch-rules.json
the registry the apply-patch script is to read, since no apply step reads
it yet, and the resolve-config README says the registry is checked after
the config loads. The read runner's applied-by-supported comment names
its output-mode condition.

broker-vendoring.test.mjs probes loadConfig's needed files from the full
lane file set, so a key missing from the copied TRUST_FILES is named in
the failure, with a self-test. callers.test.mjs's commit helper turns off
commit signing so host signing config cannot fail it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ejection order

The convention README and pr-run-activity.md now say the read runner
collects a patch only when the caller passes output-mode: patch, that no
activity sets applied-by today, and that fix-ci reaches apply-ci-fix
through output-mode: patch. The resolve-config README places the patch
rules check after loadConfig's rejections and before rejections 12 and
15.

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

chatgpt-codex-connector Bot commented Oct 19, 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-10-19T17:51:56.422540Z 538033b 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.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Security review: PR #8477 at 31550d0

Findings: 0. I found no exploitable security issue in this diff, so I posted no inline comments.

I read the config resolver and patch-rules validation, the tool-grant change in collect-base-activity, the schema constraints on applied-by, the read workflow change, and the docs. I did not read the test files or fixtures. I also did not read the patch-application and collection scripts. This diff doesn't touch them, and the PR's own docs say no activity sets applied-by yet.

Trust boundaries checked:

  • Patch-rules registry. checkPatchRules validates patch-rules.json against its schema. It rejects any row that omits the nine universal refusals. It also requires a two-parent (merge) commit to allow exactly merge-result.
  • Config and rule files. resolve-config reads the config from the base checkout. It reads the rule files from the action's own directory, so the PR head can't alter them.
  • Applied-by validation. checkAppliedBy requires each target to be a script activity, to set prepare: apply-patch, and to be in the same lane and need the producer. It uses Object.hasOwn, so there is no prototype-key lookup.
  • Schema limits on the new patch path. applied-by is limited to effect: read with gating: advisory. ci-context can't use the checks, self-checks and verify-scripts grants on this path. The schema enforces web-access only for a skill that sets reads-untrusted.
  • Tool grants. An activity that hands on a patch gets Edit, Write and Agent, but not commit_files or delete_files. The read job holds no write token, and a later job with its own rule check applies the change.
  • Changed-paths filtering. An activity that hands on a patch now has instruction surfaces and CODEOWNERS paths left out of its scope. That is a tightening.
  • New workflow input. APPLIED_BY_SUPPORTED goes through an env: block and a regex split, not a shell-interpolated run: string. The runner rejects any applied-by key it doesn't support before the head checkout.
  • Instruction-surface deletion. The diff removes the funding: map from docs/conventions/pr-pipeline.yaml. This is configuration that names which role's secrets pay for each lane, not a guardrail. I could not tell from the diff whether anything else still reads funding, so that is a correctness question for the code-review lane. I also did not consult the instruction exception register.
  • Actions hardening. I did not re-report workflow-trigger, permission or pin concerns, which belong to zizmor.

Note: patch-rules.json sets allow: ["any"] for several rows, and this diff doesn't show what that value permits. I didn't judge it, because the code that applies the patch is outside this diff.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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

No findings. I read the full diff (.claude-lane/pr.diff, 32 files) and the PR context, and I ran no tests myself.

The PR adds the applied-by field, the patch-rules.json registry with its schema, and the applied-by-supported input. It also adds the invalid-applied-by and patch-rules rejections in resolve.mjs, the edit-tool grant in collect-base-activity, and broker-vendoring.test.mjs. It removes the funding map.

What I checked and found consistent:

  • Wiring: selected.applies and chosen exist where checkAppliedBySupported reads them (resolve.mjs:822, resolve-config.mjs:331). changedPathTargets has one non-test caller, resolve.mjs:755, and it already passes the renamed edits parameter.
  • Removed funding map: Nothing in the code or workflows under docs/conventions, .github/actions or scripts reads it. The only remaining mentions are the README and pr-run-activity.md prose.
  • collect-base-activity: prepare: ci-context keeps its own tool set, and the jq -e ... // empty test is false when applied-by is absent, so existing read skills are unchanged.
  • Inert today: live-config.test.mjs asserts that no live activity sets applied-by, so lane behavior does not change.

Verification in the PR body (540/540 tests, the broker compatibility run, the two verifier passes) is author-claimed, and I did not rerun it.

Not a finding: the PR body notes pr-refine / fix-docs is expected to go red because .github/workflows changes.

kyle-sexton and others added 3 commits October 19, 2026 13:58
…ges no edit tools

checks, self-checks, verify-scripts and web-access turned on now need an
effect other than read, or applied-by.patch without prepare: ci-context.
collect-base-activity stages them only for those skills, so elsewhere they
were silently ignored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lane-Activity: pr-unblock/resolve-conflicts
@kyle-sexton
kyle-sexton enabled auto-merge October 19, 2026 18:15
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 19, 2026
Merged via the queue into main with commit 94f6031 Oct 19, 2026
25 checks passed
@kyle-sexton
kyle-sexton deleted the feat/pr-pipeline-applied-by-contract branch October 19, 2026 18:23
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