Repository navigation
feat(standards-sync): add inert reusable config-sync workflow (Track B) - #50
Conversation
First-party engine for standards Track B (config & file distribution): reads a distribution manifest, copies each included file to its per-layout destination in each target repo, and opens a PR per target (never pushes to a default branch). Upstream is authoritative; synced files are read-only-by-convention downstream. INERT until activated: dry-run defaults true (the plan job logs the full per-target plan from the manifest alone -- no target checkout, no token), and the writing sync job is gated behind a GitHub App token that does not exist yet (provisioned via github-iac, per-account, as a separate gated step). SHA-pinned actions (checkout, create-github-app-token, create-pull-request) per D5; persist-credentials:false; inputs passed via env, not inlined into run. Validate against this repo's actionlint + zizmor lanes before merge. See melodic-software/standards docs/dedup-program/config-distribution-plan.md. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GbDWhcUtduCejgi7mcbMfy
|
Claude finished @kyle-sexton's task in 3m 43s —— View job PR Review:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e85e902d2
ℹ️ 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".
…ard) - secrets app-id/app-private-key -> required: false, with a "Require App credentials" guard at the start of the sync job. Lets a caller invoke the inert dry-run (the default) without wiring secrets before the App exists; real runs still fail fast if credentials are missing. - sanitize manifest src/dest before copy: reject absolute paths and any `..` component so a (first-party) manifest entry can never escape the standards or target trees. Defense-in-depth. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GbDWhcUtduCejgi7mcbMfy
|
Claude finished @kyle-sexton's task in 1m 34s —— View job
Follow-up Review:
|
|
Thanks — addressed in
|
…title Polish from the PR #50 re-review (all were informational): - add `permissions: contents: read` to the plan job (explicit least-privilege, symmetric with the sync job). - add a workflow `concurrency` group (queue, no cancel) so two runs never race on the same per-target sync branch. - include the standards-ref in the PR title (the commit message already had it). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GbDWhcUtduCejgi7mcbMfy
|
Claude finished @kyle-sexton's task in 1m 52s —— View job
Follow-up Review:
|
|
Both prior findings confirmed resolved. Addressed the informational items too in
Left as-is by design: the |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 188213fa5e
ℹ️ 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".
|
Claude finished @kyle-sexton's task in 1m 45s —— View job
Follow-up Review: merge-to-main sync + Codex finding assessmentThe latest commit ( Codex Finding: Plan/sync manifest divergence on movable
|
standards/main change between jobs |
Effect |
|---|---|
| New target added | Matrix silently omits it — no sync this run. |
| Target removed | Sync leg runs against a target no longer in the manifest; yq returns empty tools, nothing is copied, but a pointless PR may open. |
| File renamed/moved | cp .standards-src/<old-src> fails with a non-zero exit. |
| Layout destination changed | Files land in the destination from the new manifest, but the plan log records the old destination — audit trail is wrong. |
The last case (wrong audit trail) is particularly harmful because the plan step's primary value is as a dry-run/audit record.
Fix: Capture the commit SHA the plan job actually checked out and propagate it as a job output for the sync legs to pin against.
plan:
outputs:
matrix: ${{ steps.build.outputs.matrix }}
standards-sha: ${{ steps.build.outputs.standards-sha }} # ← add
steps:
- name: Check out standards
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: melodic-software/standards
ref: ${{ inputs.standards-ref }}
persist-credentials: false
- name: Build target matrix from manifest
id: build
env:
MANIFEST: ${{ inputs.manifest }}
run: |
set -euo pipefail
matrix="$(yq -o=json -I=0 '...' "$MANIFEST")"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
echo "standards-sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" # ← addThen in the sync job, replace ref: ${{ inputs.standards-ref }} with:
- name: Check out standards (sources)
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: melodic-software/standards
ref: ${{ needs.plan.outputs.standards-sha }} # ← pinned SHA
path: .standards-src
persist-credentials: falseThis guarantees both jobs operate on the same commit, makes the audit log accurate, and is safe because the plan job already validated the manifest is well-formed before emitting the matrix.
Remaining Informational Items (unchanged)
peter-evans/create-pull-request SHA/comment — L178: 5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 — worth a manual cross-check that the SHA matches the v8.1.1 tag before first activation (the create-github-app-token SHA was verified in a prior round; this one has not been).
zizmor — still advisory-only per CI config; ${{ inputs.standards-ref }} expansions at L183–184 are in with: blocks, not run: steps, so no shell injection vector. No blocker.
Static branch name — chore/standards-sync at L182 is safe given the workflow-level concurrency group. If the SHA-pinning fix above is applied, the branch name could optionally include the SHA suffix for traceability (not required).
Summary
The merge commit introduces no new workflow content. The Codex TOCTOU finding is valid: when standards-ref = main (the default), the plan and sync jobs can observe different manifest snapshots if standards/main advances between them. The fix is low-cost (one git rev-parse HEAD output, one ref: change) and worth applying before activation — primarily because it preserves the accuracy of the plan step as an audit record. Everything else from prior rounds remains resolved.
…(Codex P2) With a movable standards-ref (e.g. main), the plan job built the matrix from one checkout while each sync leg re-checked-out the ref again; if main advanced between, the matrix/layout could be applied to a different tree. The plan job now resolves and outputs the exact SHA, and the sync job checks out + records that SHA, so the logged plan and the PR contents always match. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GbDWhcUtduCejgi7mcbMfy
…tware/ci-workflows into track-b-standards-sync
|
Claude finished @kyle-sexton's task in 1m 29s —— View job
Follow-up Review:
|
|
Both Codex (P2) threads on this PR are addressed in code:
All checks green. The repo's thread-resolution rule blocks merge until these are marked resolved; I'm not permitted to self-resolve reviewer threads. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd0f8540b8
ℹ️ 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".
## Summary Track B activation groundwork for the config-distribution engine (follows #50): - **`targets` input** — comma-separated exact-match allowlist of manifest repos (empty = all). This is the pilot / staged-rollout control: the first real sync runs against a single target without touching the manifest. Exact membership via yq set subtraction — no substring matching (`github-iac` alone matches nothing and fails the run). Spaces are stripped so `a, b` and `a,b` filter alike; a filter matching no target is a hard error (typo protection). - **Plan log iterates the built matrix** instead of the raw manifest, so the logged plan is exactly the target set the sync job will run, filter included. - **App token narrowed** — `permission-contents: write` + `permission-pull-requests: write` on the mint step, so the token carries only what the sync needs even if the installation ever has wider grants. Resolves the zizmor `github-app` finding (local zizmor v1.26.1 now clean on this file). - Header status note updated: the App secrets now exist on `standards`, and the SHA-pinned caller lands next. ## Verification Filter expression exercised locally with yq v4.53.3 against the live `standards` manifest: empty filter → all 4 targets; exact repo → 1; substring → 0 (errors); spaced pair → 2. actionlint + zizmor clean locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01GbDWhcUtduCejgi7mcbMfy <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes cross-repo sync scope and GitHub App token permissions; mistakes in the targets filter are guarded by hard errors, but a misconfigured allowlist could still limit or block intended rollouts. > > **Overview** > Adds a **`targets`** `workflow_call` input so callers can run a **staged rollout** against a comma-separated, exact-match allowlist of manifest repos (empty = all). The plan job normalizes the filter, builds the matrix with yq set subtraction (no substring matches), and **fails the run** on junk filters or unknown repo names so typos cannot silently skip one repo while others sync. > > The **distribution plan log** now walks the **built matrix** instead of every manifest target, so dry-run output matches what the sync job will execute when filtered. > > On real syncs, **`actions/create-github-app-token`** now sets **`permission-contents: write`** and **`permission-pull-requests: write`** so minted tokens only carry branch/PR permissions even if the App installation is broader. Header comments are updated to reflect activation gating via caller + secrets rather than a draft “not active” note. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ad6a93e. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Summary
The first-party sync engine for standards Track B (config & file distribution) — see the companion PR melodic-software/standards#53 for the program docs, manifest, and decisions. Reads a distribution manifest from
standards, copies each included file to its per-layout destination in each target repo, and opens a PR per target (never pushes to a default branch). Upstream is authoritative; synced files are read-only-by-convention downstream.Inert by design — safe to merge before activation
dry-rundefaults true: theplanjob logs the full per-target plan from the manifest alone (no target checkout, no token), so it is useful and harmless before auth exists.syncjob is gated (if: !inputs.dry-run) behind a GitHub App token that is not provisioned yet (a separate gated step viagithub-iac, per-account).Security posture
checkout,create-github-app-token,create-pull-request);persist-credentials: false; the App token is scoped per-owner (owner+repositories); inputs passed viaenv, never inlined intorun.actionlintis clean locally; zizmor I could not run locally.Not in this PR (gated)
standards(added at activation, pinned to this workflow's@SHA).github-iac.🤖 Generated with Claude Code
https://claude.ai/code/session_01GbDWhcUtduCejgi7mcbMfy