refactor(sops): encrypted files carry the .sops.yaml suffix #320
No reviewers
Labels
No labels
bug
enhancement
in-progress
needs-info
needs-triage
p0
ready-for-agent
ready-for-human
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/nixos!320
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "afk/319"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #319
The nvim sops rule matched
*/secrets.yamlandupdate-secrets-keysdiscovered its work withfind -name "secrets.yaml". Both encode the same guess — that an encrypted file is one calledsecrets.yaml— and it was wrong in both directions. Ansible's per-server secrets got no editor handling and, worse, no key rotation. And becausesops.luaships in a Neovim config used in every repo, a plaintextsecrets.yamlin an unrelated project could not be saved at all: the hook is aBufWriteCmd, so it replaces the write, and with no creation rule matching there was nothing to write.The filename is now the contract: a file is sops-encrypted iff its name ends in
.sops.yaml.What changed
secrets.yaml→secrets.sops.yamlviagit mv. 19 nixsopsFile/defaultSopsFilereferences and ansible'sbase_loki_secrets_fileretargeted.sops.lua— pattern is*.sops.yaml, with a basename guard skipping the.sops.yamlconfig itself. The guard now runs in all four autocmds; previously onlyBufWriteCmdcalledis_secrets_file(), soBufReadPre/BufReadPost/BufLeaverelied on the pattern alone and would still have fired on the config..sops.yaml— every rule tightened from[^/]+\.yaml$to[^/]+\.sops\.yaml$.update-secrets-keys— convention-based discovery (find -name "*.sops.yaml" ! -name ".sops.yaml",.gitpruned), so ansible secrets enter rotation and future encrypted files need no script edit.Two things beyond the issue's list
scripts/pre-commit:16— itssharedregex containssecrets\.yaml$, the trigger for the all-host dry-build when the root secrets file changes. After the rename it would silently never match again. Retargeted.main, the root rule^[^/]+\.yaml$matched the sops config file.sops.yamlitself.^[^/]+\.sops\.yaml$structurally cannot, since[^/]+needs at least one character before the literal suffix. The exclusion is now a property of the regex rather than luck.I also updated the operational docs the issue didn't enumerate (
AGENTS.md,README.md,.claude/*.md,.roo/rules/rules.md,ansible/README.md,EMAIL_SETUP.md,RESTORATION.md,land-pr/SKILL.md) — each contains a command or path list that the rename makes wrong. Historical records stay stale; instructions must not.Verification
sopsandnixare both absent from the agent sandbox, so the pre-commit dry-build could not run (/nixdoes not exist;test-configurationandansible-checkbail on their missing-toolchain checks before evaluating anything) and./scripts/update-secrets-keyscould not be executed. This needs a dry-build on a machine with Nix before merging. What I could establish instead:HEADcounterparts — verified by comparinggit rev-parse HEAD:<old>against the staged object id, not by reading the diff..sops.yaml's diff is confined topath_regexlines; zero other lines changed.HEADvs. the worktree for all 18 encrypted files. Every one resolves to the same recipient set. Rule count and key groups unchanged..sops.yamlno longer self-matches — confirmed empirically against both the old and new rule sets.sopsFile/defaultSopsFilepaths resolve to files that exist, including the symlink-crossing../utils/modules/victoriametrics/secrets.sops.yamlinfwmetrics.nix. Nosecrets.yamlremains on disk.sops.lua— no Lua interpreter available either, so no real parse. Block-keyword balance is 0 atHEADand 0 in the worktree with depth never going negative, and each of the 4 added guard blocks is self-closing.Not addressed, deliberately
Three encrypted files match no creation rule —
hosts/web-arm/modules/{bitwarden,nextcloud}/secrets.sops.yamlandutils/modules/plausible/secrets.sops.yaml. This predates the PR and is unchanged by it (they matched none before either), but it meansupdate-secrets-keyswill fail on those three. The first two look dead: both modules take their secrets from web-arm'sdefaultSopsFileand nothing references the files. Filed separately as #320, along with the stale retired-host rules the issue scoped out.Two notes:
README.md:19still referenceshosts/cloonar.com/, a host directory that no longer exists — left alone as unrelated. And.claude/skills/README.mdis git-ignored in this worktree, so its edit is local-only and not in this diff.[autoland] verdict: pass
Validated statically. No build gate vouched:
pr checksreturnedstate: none(this repo's only dry-build gate is the local pre-commit hook, and the deploy action does not build), and neithernixnorsopswas available in the landing session. The dry-build and./scripts/update-secrets-keystherefore did not run for this PR. Merged on the maintainer's explicit go-ahead after their own review of the diff.Verified independently:
.sops.yamlno longer self-matches — matched rule[0]^[^/]+\.yaml$on main, matches nothing on head.sopsFile/defaultSopsFilerefs resolve, including the symlink-crossinghosts/fw/modules/fwmetrics.nix:13.sops.luaautocmds guarded (:51, :67, :151, :276).Closes #319, scope matches the issue. Merges cleanly (merge-base is current main).CONCERNS (non-blocking, carried):
./scripts/update-secrets-keyswill exit 1 on three files matching no creation rule (hosts/web-arm/modules/{bitwarden,nextcloud}/secrets.sops.yaml,utils/modules/plausible/secrets.sops.yaml). Confirmed pre-existing on main, not a regression; tracked in #321.