Repository navigation
reconcile-production: composite action, trixie config/policy templates, fail-closed tests - #68
Merged
Merged
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Goal: Add
.github/actions/reconcile-production(composite) that installs an exact repogen release and runsrepogen reconcile-productionfor 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 asscripts/validate-publish-target.sh+internal/releaseasset/publish_target_test.go). The action then calls the existingscripts/install-release.sh --github-release, writes secrets into amktemp -ddir underumask 077(files 0600), runs the CLI, and removes the dir in anif: always()step. Templates underproduction/templates/are canonical JSON with deliberately invalid placeholder values, so the CLI's ownValidate()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
trixie;stable(any case/padding) is refused before install.REPOGEN_GPG_KEY, armored or base64) plus optional passphrase. Written only to 0600 files, never to argv,$GITHUB_ENVor logs.vX.Y.Ztag and repogen-commit a 40-hex commit (install-release.sh already enforces; nolatest, no@main).Assumptions
account_id/endpointdiffer from ther2-account-idinput.Review Focus
targetisstable→ refused by script before install (test in Task 1).account_iddiffers from ther2-account-idsecret → refused (Task 1).Validate()rejects (Task 2).Task 1: Input validator script + tests
Files:
scripts/validate-reconcile-inputs.shinternal/releaseasset/reconcile_inputs_test.goInterfaces:
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(userepositoryRoot(t)from contract_test.go,exec.Command("sh", script)with explicitEnv). 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 targetstable,Stable,stable→stable; config targetforky→trixie; policy targetstable→stable; policy request_sha256 ≠ REQUEST_SHA256 →request; config request_sha256 ≠ REQUEST_SHA256 →request; account_id ≠ R2_ACCOUNT_ID →account; endpoint nothttps://$R2_ACCOUNT_ID.r2.cloudflarestorage.com→endpoint; config path is symlink →regular file; REPOGEN_VERSIONlatestormain→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, afailhelper as in validate-publish-target.sh,requireloop over the vars,casehex check[0-9a-f]×64 (reject anything else, no trimming),[ -f ] && [ ! -L ]for files,sha256sumcompare,jq -er '.target'/.request_sha256/.account_id/.endpointreads, lowercase-trimmed stable check before the= trixiecheck, version regex^v[0-9]+\.[0-9]+\.[0-9]+$viagrep -Eq, commit^[0-9a-f]{40}$.Step 4: rerun → PASS.
Task 2: Config/policy templates + validator test
Files:
production/templates/trixie-config.template.json,production/templates/authorization-policy.template.json(canonical RFC 8785: sorted keys, no whitespace, newline-free, matching thejson:tags in internal/production/config.go, all 11 config fields + schema, all 17 policy fields + schema)production/templates/README.md(what each placeholder means, who fills it, that the template authorizes nothing, how to compute pins withsha256sum, that the concrete files live in the producer repo's canary PR)internal/production/template_test.goPlaceholders: 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".TestTemplatesAreCanonicalAndUnfilledFailValidation: read each template,intake.DecodeCanonicalsucceeds intoConfig/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), andValidate()returns error. (b)TestTemplatesFilledValidate: replace eachREPLACE-*with a well-formed sample, set absent=true and one pool object,Validate()nil; then set target tostable→ error. (c)TestTemplatesCoverEveryField: decoded key set equals struct json tag set (reflect).go test ./internal/production -run Template→ FAIL.jq -cSand strip trailing newline; confirm no.numbers).Task 3: Composite action + contract test
Files:
.github/actions/reconcile-production/action.ymlinternal/releaseasset/reconcile_action_test.goInputs (all
required: trueexceptgpg-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. Nocodename/suite/targetinput.Steps: (1)
Validate inputsruns$GITHUB_ACTION_PATH/../../../scripts/validate-reconcile-inputs.shwith inputs passed viaenv: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); writer2-credentials.jsonwithjq -n --argfrom 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 secretsif: always()→rm -rf "$RUNNER_TEMP/repogen-reconcile-secrets". Noset -x, no secret in argv.TestReconcileActionContractparsing 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-releaseand no@main/latest; every secret input reaches steps only viaenv:not inline${{ inputs.r2-secret-access-key }}inrun:;umask 077precedes secret writes; cleanup step hasif: always(); nocodename/suiteinput; command string containsreconcile-productionand every mandatory flag from internal/cli/reconcile_production.go. PlusTestNoWorkflowCallsReconcileAction: no file in.github/workflowsmentionsreconcile-production.actionlintif 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.mdonly if a new docs/ file is added (none planned).node scripts/check-docs.mjspasses.PR summary must state
Plan approved by owner:odrade (standing grant approve-plans in lucilla).
Work item: w-request-r-20261002-8eb482