Skip to content

feat(runner-policy): accept a list of exact secret maps per contract - #970

Merged
kyle-sexton merged 1 commit into
mainfrom
feat/968-multi-map-secrets
Nov 8, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
feat/968-multi-map-secrets

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #968

Summary

A secret change to a reusable workflow's runner-policy contract had a built-in deadlock window: every caller had to send exactly the contract's one secret map, so callers on either side of the component sync failed ci-status until both sides landed. This gives allowedSecrets the same expand/contract shape #950 gave allowedCallerPermissions.

Fix

  • policy.schema.json: a new secretMaps definition, oneOf one exact stringMap or a non-empty, unique list of them. Both runnerInputContract and hostedOnlyContract reference it for allowedSecrets.
  • runner-policy.mjs: feat(runner-policy): accept a list of exact caller permission maps for a migration #950's helpers become shape-neutral (exactMapEntries, exactMapsError) and now serve both permissions and secrets. A caller's secrets: block passes when it equals any one listed map exactly. There is no subset or superset matching. With a single map, the error wording is the same as before. With a list, a mismatch names every listed map. Every listed map is validated the way the single map was: each value must be one whole ${{ secrets.<NAME> }} expression, and a contract with a caller-permission waiver must map same-name or role-named. The visibility-scoped contract scan reads the union of all listed maps, so a denylisted secret that appears only in the new map is still caught.
  • README.md: "Contract revision lockstep" item 3 now describes the expand/contract order for secrets and permissions together. The lines that describe the secret map's shape now cover the list form.
  • No policy.json entry changes.

Verification

  • npm run test:runner-policy: 241 pass, 0 fail. The baseline on main was 232. The nine new tests cover:
    • old, new and mismatched callers against both the single-map and list forms (pass, pass, fail);
    • superset, subset and expression drift;
    • an empty list rejected by the schema;
    • per-map expression and same-name validation;
    • the hosted-only list form;
    • a denylisted secret that appears only in a second listed map.
  • Mutation check: I made the status check use only the last listed map and the visibility scan read only the first map. Four of the new tests failed, and they passed again after I reverted both mutations.
  • The pre-commit hooks passed: biome, markdownlint, editorconfig, typos and gitleaks.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_015XWwmb8QAX8QQkewRWMWYs

A reusable workflow contract's allowedSecrets may now be one exact map or a
non-empty list of exact maps, the same shape allowedCallerPermissions took in
#950. A caller passes while its secrets equal any one listed map exactly, so a
secret change lands expand/contract instead of failing callers on either side
of the sync.

Every listed map is validated as the single map was (whole named-secret
expressions, same-name or role-named mapping under a caller-permission
waiver), and the visibility scan reads every listed map.

Closes #968

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmb8QAX8QQkewRWMWYs
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-08T15:36:03.500286Z
We couldn’t complete this review. Comment @codex review to try again.
4ecc48e PR opened
ℹ️ 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

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

Security review: PR #970 (head 4ecc48e)

No security findings. critical-findings: 0

Scope. I read all 4 changed files in components/runner-policy/: README.md, policy.schema.json, runner-policy.mjs and runner-policy.test.mjs. I also grepped the repository for other readers of allowedSecrets and allowedSecretNames. I did not dispatch verifier subagents, because no candidate finding survived my own read.

What the change does. A contract's allowedSecrets can now be a non-empty list of exact secret maps, as allowedCallerPermissions already could. A caller passes when its secrets: block equals any one listed map exactly. This lets a secret change land expand/contract.

Why it widens nothing.

  • Same exact-match check. exactMapsError (runner-policy.mjs, around L910–925) runs the same exactCanonicalMap per listed map, with the allowed names taken from that map's own keys. A caller must still use exactly the listed names and exact expressions.
    • It has no union or merge of maps, so a caller cannot mix names from different maps.
    • Missing, extra or aliased secrets still fail.
    • secrets: inherit is not a mapping, so it still fails.
  • Validation per listed map. The validatePolicy checks now run for every listed map (the loops around L237–265).
    • A privileged contract with allowedCallerPermissions still requires each secret to map to its own name or the role-prefixed name.
    • The other hosted and runner-input contracts still require one whole ${{ secrets.<NAME> }} expression, so toJSON(secrets) and similar are rejected.
    • Tests cover both cases.
  • Visibility denylist. The scan in visibilityScopedReusableContractFindings (around L1822–1835) flattens every listed map. It checks names and aliased expressions, so a denylisted secret in the new map of a pair is found before callers move to it.
  • Fail-closed schema. The schema accepts a map or a non-empty, unique list of maps. Because allowedSecretNames was removed, I checked for other consumers; the grep found none.
  • Who can add a map. Adding a map takes a reviewed edit to policy.json, which the README says needs another review.
  • Trust-control list. The files touched are not on this repository's listed trust controls, and none of the listed controls changes.
  • Other lenses. There is no instruction-surface deletion or manifest change. The README's lockstep text was rewritten, but only to document the new mechanism.

Prose-level notes (not findings).

  • An expand/contract window briefly admits both secret maps. That is the intended behavior, and the README states it.
  • Owner-threat-model hold removals: none.

Settled/prior threads. None were supplied for this run.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

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

No findings. I read the full diff (README, schema, runner-policy.mjs, tests) and the closing issue #968. I did not run the test suite, so the PR's reported test counts and mutation check are author-claimed and unverified by me.

  • Removed allowedSecretNames: contract.allowedSecrets and allowedSecretNames are read only in runner-policy.mjs, per a repo grep. Every reader was moved to the list-shaped allowedSecrets: the contract validation, the status check (runner-policy.mjs:982) and the visibility scan (runner-policy.mjs:1828). Other mentions are prose and still hold.
  • Single-map form: error locations and wording are unchanged, because the location stays ...allowedSecrets with .<name> appended. An existing test pins this.
  • Schema: oneOf between a string map and a non-empty unique array of string maps is unambiguous, and both contract types use it.
  • Validation: the same-name/role-named rule and the whole-expression rule now run on every listed map, with the list index in the error location (such as allowedSecrets[1]).
  • Visibility scan: it takes the union of all listed maps, so a denylisted secret that appears only in the new map is still caught.
  • Closing issue runner-policy: let a contract list several exact secret maps so secret changes land expand/contract #968: the "Done when" items are met: old-map, new-map and mismatched-map callers are tested, and README item 3 describes the expand/contract order.

@kyle-sexton
kyle-sexton merged commit c28cc0a into main Nov 8, 2026
22 checks passed
@kyle-sexton
kyle-sexton deleted the feat/968-multi-map-secrets branch November 8, 2026 15:41
kyle-sexton added a commit that referenced this pull request Nov 8, 2026
Closes #971

## Summary

#950 (multi-map caller permissions) and #970 (multi-map secrets) let a
contract list several exact maps so a change can land expand/contract.
Nothing enforced the contract step. A listed map is fleet-wide, so no
single repository's unused-entry check can tell that the old map has
gone unused. This adds a required switchover date that the analyzer
enforces. That was option 1 of the owner's decision (Q5, 2026-11-08).

## Fix

- `policy.schema.json`: adds `allowedSecretsUntil` to both contract
types and `allowedCallerPermissionsUntil` to runner-input contracts
(`^[0-9]{4}-[0-9]{2}-[0-9]{2}$`).
- `runner-policy.mjs` enforces the four rules for both fields:
  - At load, it fails a list of more than one map that has no date.
- At load, it fails the date field on a single map or a one-entry list.
- At audit, `contract-switchover-expired` fails once today (UTC) is past
the date while more than one map is still listed. The finding names each
contract and field, and says to remove the old map and its date field.
- At audit, `contract-switchover-window` fails a date more than 90 days
after today.
- It also rejects a date that matches the pattern but does not exist,
such as `2026-02-30`.
- Each date rule emits one finding that names every affected contract,
because findings are deduplicated by file, job and rule.
- `auditRepository` takes an injectable `today` (`YYYY-MM-DD`) that
defaults to the current UTC date.
- `README.md`: item 3 of "Contract revision lockstep" now gives the date
fields, their format, the 90-day cap, the failure the day after the
date, and the rule that the follow-up removes the date together with the
old map. The two lines that describe each field's shape point to it.
- `policy.json`: no entry lists more than one map today, so none needed
a date and the file is unchanged.

## Verification

- `npm run test:runner-policy`: 247 pass, 0 fail. The baseline on `main`
was 241.
  - The new tests cover each of the four rules for both fields.
- They check the boundary days: a date equal to today passes and the
next day fails; today plus 90 days passes and plus 91 fails.
- They also cover two expired switchovers named in one finding, and
invalid dates.
- The test helper sets a fixed `today`, and the existing multi-map
fixtures carry a date.
- Mutation check: changing either boundary comparison from `>` to `>=`
made the two boundary tests fail. Both comparisons are restored.
- `node components/runner-policy/runner-policy.mjs --root .` reports
"Runner policy passed." against the real `policy.json`.
- The pre-commit hooks passed: biome, markdownlint, editorconfig, typos
and gitleaks.

## Related

- Refs #950 (multi-map caller permissions)
- Refs #970 (multi-map secrets)
- Refs melodic-software/ci-workflows#1040 (the planned surface check; it
reads the synced contract and must accept the two new date fields)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_015XWwmb8QAX8QQkewRWMWYs

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.

runner-policy: let a contract list several exact secret maps so secret changes land expand/contract

1 participant