Skip to content

ci: check that every guarded SOPS value is in COMPOSE_VARS - #1572

Merged
Gerrrt merged 3 commits into
mainfrom
gerrrt/brave-goldberg-3yavt6
Nov 18, 2026
Merged

Gerrrt merged 3 commits into
mainfrom
gerrrt/brave-goldberg-3yavt6

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

What changed

Adds scripts/check_compose_vars.py, a CI check (also in make validate and make check-compose-vars) that fails when a SOPS value guarded by ${VAR:?} in any stacks/*/compose.yaml is missing from COMPOSE_VARS in scripts/render-config.sh. No running service changes.

#1570 has merged and main is merged into this branch, so the check now passes here: COMPOSE_VARS OK — all 51 guarded SOPS values are rendered and seeded.

Why

#1566 guarded WALL_HA_TOKEN in stacks/sensitive/compose.yaml and gave it a stand-in in scripts/seed-validation-env.sh, and #1563 added it to secrets/sensitive.sops.yaml. Nobody added it to COMPOSE_VARS. CI validates with the seed's stand-ins and never runs render, so it passed. make up STACK=sensitive on trinity then failed with "required variable WALL_HA_TOKEN is missing a value". The comment above COMPOSE_VARS already calls these "three copies of one fact"; now something checks them. Refs #1570.

The script asserts:

  1. A guarded name that is a key in some secrets/*.sops.yaml is in COMPOSE_VARS (the feat(wall): heimdall first light, and the house and family calendar on the wall #1566 bug).
  2. A seeded name that is a SOPS key is in COMPOSE_VARS (the same bug, seen from the seed).
  3. A guarded SOPS key has a stand-in in seed-validation-env.sh.
  4. Every COMPOSE_VARS entry is a SOPS key (no typos or dead names).

It reads only top-level key names, which SOPS stores in plaintext, so nothing is decrypted. Guards are read from the parsed YAML, as compose-guards.sh does, so a comment is never taken for a guard (#107). Non-SOPS guards (RENDER_UID, bind addresses) are out of scope.

Blast radius

CI, scripts/validate.sh, the Makefile and docs only. No host, VLAN or service changes.

  • No change to network segmentation or firewall rules
  • No new port published to a VLAN that could not already reach the service
  • No credential added outside secrets/*.sops.yaml

Verification

On main at 43a227d (#1566), it fails and names the variable:

$ python3 scripts/check_compose_vars.py; echo rc=$?
  stacks/sensitive/compose.yaml guards WALL_HA_TOKEN, a key in secrets/sensitive.sops.yaml, but COMPOSE_VARS in scripts/render-config.sh does not list it: render would not write it and `make up` would fail on the unset variable. Add it there.
rc=1

On #1570's head (ebd2cad), with the script copied in, it passes:

COMPOSE_VARS OK — all 51 guarded SOPS values are rendered and seeded (52 listed, 73 SOPS keys, 79 guards)
rc=0

Also run:

  • python3 scripts/check_compose_vars.py --self-test: 11 fixtures pass. scripts/self-tests.sh discovers the suite and reports check_compose_vars.py --self-test (11 fixtures).

  • python3 scripts/check_docs.py: OK.

  • python3 scripts/check_close_keywords.py on this body and the commit message: PASS.

  • ./scripts/lint.sh: ruff passes; the docker- and pipx-backed linters skipped here (no Docker daemon, no pipx). I ran yamllint --strict and actionlint on ci.yml and shellcheck on validate.sh and render-config.sh directly, and all passed. CI's --require-all run is the authority.

  • Full make validate not run: this host had 30 GB free and the suite needs about 38 GB, per CLAUDE.md. Left to CI.

  • make validate passes (not run locally, see above)

  • Deployed to the lab and confirmed working (CI-only change)

  • Docs updated (docs/changelog.md, scripts/README.md)

🤖 Generated with Claude Code

https://claude.ai/code/session_01L2Eweh7G6uK8cbuptGtxTR

#1566 guarded WALL_HA_TOKEN in stacks/sensitive/compose.yaml and seeded
it, #1563 put it in secrets/sensitive.sops.yaml, and nothing added it to
render-config.sh's COMPOSE_VARS. CI validates with the seed's stand-ins
and never runs render, so it passed; `make up STACK=sensitive` on trinity
did not.

scripts/check_compose_vars.py holds the three copies together: a guarded
or seeded SOPS key must be in COMPOSE_VARS, a guarded SOPS key must have
a stand-in, and a COMPOSE_VARS entry must be a SOPS key. It reads only key
names, which SOPS leaves in plaintext. Wired into CI, validate.sh and
`make check-compose-vars`; its fixtures run in self-tests.sh.

It fails on main at #1566 and passes on #1570's head. Refs #1570.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L2Eweh7G6uK8cbuptGtxTR
Copilot AI balanced review requested due to automatic review settings November 18, 2026 18:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The script bypasses require_yaml(), risking CI failures when PyYAML is absent, and its fixture does not detect regressions that scan raw YAML for guards.

2 open issues
What changed in this PR

Adds a validation check to prevent guarded SOPS values from being omitted from rendered Compose environments—the failure behind WALL_HA_TOKEN in #1566, addressed by prerequisite #1570. No running service configuration changes.

Changes:

  • Cross-checks Compose guards, SOPS key names, COMPOSE_VARS, and validation stand-ins without decrypting secrets.
  • Integrates the check into CI, local validation, and a dedicated Make target, with 11 fixtures.
  • Documents the check and the incident that motivated it.
File Description
scripts/​validate.sh Runs the new check during local validation.
scripts/​render-config.sh Adds a comment linking COMPOSE_VARS to the check.
scripts/​README.md Documents the checker and Make target.
scripts/​check_compose_vars.py Implements consistency checks and regression fixtures.
Makefile Adds check-compose-vars.
docs/​changelog.md Records the check and its incident context.
.github/​workflows/​ci.yml Runs the checker in CI.

Review effort: Balanced

Comment thread scripts/check_compose_vars.py Resolved
Comment thread scripts/check_compose_vars.py Resolved
@Gerrrt
Gerrrt enabled auto-merge (squash) November 18, 2026 18:17
…re bite

Load PyYAML through scripts/_deps.require_yaml(), as every sibling check
does, so the pinned bootstrap is used where bare python3 lacks it (#848).

The YAML-comment fixture now comments out a guard on a SOPS key that is
listed but unseeded, so a regression to scanning raw text fails it; with
NOT_A_GUARD, a non-SOPS name, every assertion ignored it either way (#107).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L2Eweh7G6uK8cbuptGtxTR
@Gerrrt
Gerrrt merged commit 01e8cc1 into main Nov 18, 2026
9 checks passed
@Gerrrt
Gerrrt deleted the gerrrt/brave-goldberg-3yavt6 branch November 18, 2026 18:30
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.

3 participants