Skip to content

reconcile-production: composite action, trixie config/policy templates, fail-closed tests - #68

Merged
bketelsen merged 1 commit into
mainfrom
owners/w-request-r-20261002-8eb482
Oct 2, 2026
Merged

bketelsen merged 1 commit into
mainfrom
owners/w-request-r-20261002-8eb482

Conversation

@bketelsen

Copy link
Copy Markdown

A CI workflow can run a pinned repogen release's reconcile-production for trixie through a reusable composite action that fails closed, with reviewed config and authorization-policy templates; nothing is published.

Reviewed by github-copilot/gpt-6-sol.

Review

approve after 1 round: The prior jq-argument, version-prefix, and CI/CD documentation findings are resolved. The remaining concrete-file finding is resolved by the revised acceptance: this change supplies invalid templates and fail-closed validation, while the digest-pinned config, policy, and shared-pool list belong to the gchlog canary PR. The action is not called by a workflow and nothing is published. A new repogen release and an intake-submit path remain prerequisites, not defects in this change. Host evidence covers only its recorded git and sh checks; the reported Go and lint results were not independently verified here.

Approved plan

reconcile-production CI surface Implementation Plan

For the execution session: Use executing-plans locally or subagent-driven-development when delegation helps. Implementation and task-review dispatch are optional per task. Run this approved plan task by task, then end with onionsoup_propose_changes for this item (repository frostyard/repogen); host verification and the one final independent-family publication review remain required. Steps use checkbox (- [ ]) syntax.

Goal: Add .github/actions/reconcile-production (composite) that installs an exact repogen release and runs repogen reconcile-production for trixie with digest-pinned config/policy and 0600 secret files, plus canonical config/policy templates and tests proving fail-closed behaviour.

Architecture: All input checking lives in one POSIX script, scripts/validate-reconcile-inputs.sh, run first in the action and driven directly by Go tests (same pattern as scripts/validate-publish-target.sh + internal/releaseasset/publish_target_test.go). The action then calls the existing scripts/install-release.sh --github-release, writes secrets into a mktemp -d dir under umask 077 (files 0600), runs the CLI, and removes the dir in an if: always() step. Templates under production/templates/ are canonical JSON with deliberately invalid placeholder values, so the CLI's own Validate() rejects them unfilled.

Tech Stack: Go 1.x tests, POSIX sh, jq (already used in publish-to-r2), GitHub composite actions.

Verification: git diff --check; sh -c 'test -z "$(git ls-files '*.go' | xargs -r gofmt -l)"'; go test -count=1 ./...; node scripts/check-docs.mjs; golangci-lint via ~/.local/share/mise/installs/golangci-lint/2.13.1/golangci-lint-2.13.1-linux-amd64/golangci-lint run (the mise shim fails).

Global Constraints

  • Nothing publishes; no workflow in this repo calls the new action; no secrets, buckets, repository settings or releases are created.
  • Target is exactly trixie; stable (any case/padding) is refused before install.
  • Secrets used only: existing R2 credentials (account id, access key id, secret access key) and existing signing key (REPOGEN_GPG_KEY, armored or base64) plus optional passphrase. Written only to 0600 files, never to argv, $GITHUB_ENV or logs.
  • repogen-version must be an exact vX.Y.Z tag and repogen-commit a 40-hex commit (install-release.sh already enforces; no latest, no @main).
  • publish-to-r2 is untouched and stays closed to deb (ADR-0013).
  • Accepted ADRs are immutable; new behaviour is documented via a new ADR only if it changes an accepted decision (it does not: this is the gated surface ADR-0013 anticipates), so docs go into the existing spec + README.
  • Every new docs/ file needs an index line in docs/README.md (check-docs.mjs).

Assumptions

  • Templates, not concrete files, are committed (Odrade confirmed): a concrete policy pins request/provenance digests, producer commit/tree, the future release binary digest and pool objects, none of which exist yet. Concrete config/policy are written and digest-pinned in the gchlog canary PR after Brian cuts a release. Templates authorize nothing.
  • The concrete config will contain the R2 account id in the gchlog repo (Odrade: acceptable, not a credential; flagged in PR for Brian's veto). The action refuses to run if config account_id/endpoint differ from the r2-account-id input.
  • Intake and coordination buckets do not exist yet; the template names them as placeholders. Creating them is a setting outside this PR.
  • The canary is still blocked by the missing intake-submit path (plan 0001 T0 submit-only endpoint is unbuilt); named as follow-up in the PR, Odrade is raising it with Brian separately. No ad hoc upload path is added.
  • A new repogen release, cut by Brian, is needed before gchlog can pin this action and binary.

Review Focus

  • Policy file whose digest matches but whose target is stable → refused by script before install (test in Task 1).
  • Config account_id differs from the r2-account-id secret → refused (Task 1).
  • Pin given in uppercase hex or with whitespace → refused, not normalised (Task 1).
  • Config/policy path is a symlink → refused (Task 1), matching LoadCanonicalFile.
  • Unfilled template passed as real config → CLI Validate() rejects (Task 2).

Task 1: Input validator script + tests

Files:

  • Create: scripts/validate-reconcile-inputs.sh
  • Create: internal/releaseasset/reconcile_inputs_test.go

Interfaces:

  • Produces: script reading env CONFIG_FILE CONFIG_SHA256 POLICY_FILE POLICY_SHA256 REQUEST_SHA256 PROVENANCE_SHA256 R2_ACCOUNT_ID R2_ACCESS_KEY_ID R2_SECRET_ACCESS_KEY SIGNING_KEY REPOGEN_VERSION REPOGEN_COMMIT; exit 0 or print ::error::<msg> and exit 1. Never echoes secret values.

  • Step 1: write table test TestReconcileInputsFailClosed (use repositoryRoot(t) from contract_test.go, exec.Command("sh", script) with explicit Env). Fixture: temp dir with canonical config {"account_id":"acct0","coordination_bucket":"c","coordination_prefix":"","endpoint":"https://acct0.r2.cloudflarestorage.com","intake_bucket":"i","intake_prefix":"","publication_bucket":"p","publication_prefix":"","region":"auto","request_sha256":"<64 a>","schema":"org.frostyard.repogen.production-config.v1","target":"trixie"} and a policy with "target":"trixie", "request_sha256" equal; pins = sha256 of bytes. Cases (message substring): valid → ok; each of the 12 vars missing/blank → is required; config pin wrong → config digest; policy pin wrong → policy digest; pin uppercase / 63 chars / trailing space → not a lowercase SHA-256; request/provenance pin malformed → same; config target stable, Stable, stable → stable; config target forky → trixie; policy target stable → stable; policy request_sha256 ≠ REQUEST_SHA256 → request; config request_sha256 ≠ REQUEST_SHA256 → request; account_id ≠ R2_ACCOUNT_ID → account; endpoint not https://$R2_ACCOUNT_ID.r2.cloudflarestorage.com → endpoint; config path is symlink → regular file; REPOGEN_VERSION latest or main → exact release tag; REPOGEN_COMMIT not 40 lowercase hex → commit. Also assert output never contains the access-key or secret-key test values.

  • Step 2: go test ./internal/releaseasset -run TestReconcileInputsFailClosed → FAIL (script missing).

  • Step 3: implement script with set -eu, a fail helper as in validate-publish-target.sh, require loop over the vars, case hex check [0-9a-f] ×64 (reject anything else, no trimming), [ -f ] && [ ! -L ] for files, sha256sum compare, jq -er '.target'/.request_sha256/.account_id/.endpoint reads, lowercase-trimmed stable check before the = trixie check, version regex ^v[0-9]+\.[0-9]+\.[0-9]+$ via grep -Eq, commit ^[0-9a-f]{40}$.

  • Step 4: rerun → PASS.

Task 2: Config/policy templates + validator test

Files:

  • Create: production/templates/trixie-config.template.json, production/templates/authorization-policy.template.json (canonical RFC 8785: sorted keys, no whitespace, newline-free, matching the json: tags in internal/production/config.go, all 11 config fields + schema, all 17 policy fields + schema)
  • Create: production/templates/README.md (what each placeholder means, who fills it, that the template authorizes nothing, how to compute pins with sha256sum, that the concrete files live in the producer repo's canary PR)
  • Create: internal/production/template_test.go

Placeholders: strings "REPLACE-<field>" (invalid: fail safeName/validSHA256/validCommit), authoritative_target_absent:false, allowed_pool_objects:[], target:"trixie" fixed literally, publication_bucket:"frostyardrepo" literal (existing bucket per gchlog release.yml), operation:"initialize".

  • Step 1: tests: (a) TestTemplatesAreCanonicalAndUnfilledFailValidation: read each template, intake.DecodeCanonical succeeds into Config/Policy, re-encode equality check that bytes are canonical (use the repo's canonical encoder if exported in internal/intake/canonical.go, else compare DecodeCanonical success which already rejects noncanonical), and Validate() returns error. (b) TestTemplatesFilledValidate: replace each REPLACE-* with a well-formed sample, set absent=true and one pool object, Validate() nil; then set target to stable → error. (c) TestTemplatesCoverEveryField: decoded key set equals struct json tag set (reflect).
  • Step 2: run go test ./internal/production -run Template → FAIL.
  • Step 3: write templates (generate canonical bytes with a throwaway jq -cS and strip trailing newline; confirm no . numbers).
  • Step 4: rerun → PASS.

Task 3: Composite action + contract test

Files:

  • Create: .github/actions/reconcile-production/action.yml
  • Create: internal/releaseasset/reconcile_action_test.go

Inputs (all required: true except gpg-passphrase): repogen-version, repogen-commit, config, config-sha256, policy, policy-sha256, request-sha256, provenance-sha256, r2-account-id, r2-access-key-id, r2-secret-access-key, gpg-private-key, gpg-passphrase. No codename/suite/target input.

Steps: (1) Validate inputs runs $GITHUB_ACTION_PATH/../../../scripts/validate-reconcile-inputs.sh with inputs passed via env: only. (2) Install repogen → install-release.sh --github-release "$REPOGEN_VERSION" "$REPOGEN_COMMIT" "$(uname -m)" "$RUNNER_TEMP/repogen-bin/repogen" (match publish-to-r2's existing invocation lines ~228-240). (3) Reconcile: umask 077; secrets=$(mktemp -d); write r2-credentials.json with jq -n --arg from env; decode key (armored vs base64 as publish-to-r2 lines 375-395) to $secrets/signing-key.asc; passphrase file only if nonempty; chmod 600; record dir in $GITHUB_STATE-free way by fixed path $RUNNER_TEMP/repogen-reconcile-secrets; run the binary with all flags. (4) Remove secrets if: always() → rm -rf "$RUNNER_TEMP/repogen-reconcile-secrets". No set -x, no secret in argv.

  • Step 1: test TestReconcileActionContract parsing action.yml as text/YAML (gopkg.in/yaml.v3 if already in go.mod, else string checks): validate step is first and references the script; install step uses --github-release and no @main/latest; every secret input reaches steps only via env: not inline ${{ inputs.r2-secret-access-key }} in run:; umask 077 precedes secret writes; cleanup step has if: always(); no codename/suite input; command string contains reconcile-production and every mandatory flag from internal/cli/reconcile_production.go. Plus TestNoWorkflowCallsReconcileAction: no file in .github/workflows mentions reconcile-production.
  • Step 2: run → FAIL; Step 3: write action.yml; Step 4: run → PASS. Also run actionlint if available on the file.

Task 4: Docs

Files: Modify docs/specs/production-r2-reconciliation.md (new "CI surface" section: action inputs, validation order, 0600 handling, templates, release prerequisite, intake-submit prerequisite), README.md (short paragraph after the reconcile-production paragraph linking spec and templates; keep "does not authorize a canary"), docs/README.md only if a new docs/ file is added (none planned).

  • Run full verification list; node scripts/check-docs.mjs passes.

PR summary must state

Plan approved by owner:odrade (standing grant approve-plans in lucilla).

Work item: w-request-r-20261002-8eb482

…s, fail-closed tests

A CI workflow can run a pinned repogen release's reconcile-production for trixie through a reusable composite action that fails closed, with reviewed config and authorization-policy templates; nothing is published.

Work-item: w-request-r-20261002-8eb482
Reviewed-by: github-copilot/gpt-6-sol
@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@bketelsen
bketelsen merged commit b90a7bb into main Oct 2, 2026
3 checks passed
@frostyard-machines
frostyard-machines deleted the owners/w-request-r-20261002-8eb482 branch October 30, 2026 04: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