secret declare: take the host recipient term from the target secrets.nix #275
No reviewers
Labels
No labels
blocked
bug
decision
duplicate
enhancement
help wanted
invalid
landed?
question
ready-to-merge
stale
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/tools!275
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/declare-host-recipient"
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?
allod secret declareno longer writes[ hostKey ]as the start of the new recipient line. It reads the existingpublicKeyslines in the targetsecrets.nixand opens the new line with the term they all open with, so a secrets repo that binds the hypervisor's keys under another name gets a line that evaluates there. If those lines do not agree on one term, or a line opens with something that is not a name or a bracketed list,declarerefuses before writing anything and lists what each line starts with. On the template and on any repo whose lines open with[ hostKey ]the output is byte for byte what it was. What proves it: the existing declare tests still produce the same files, a fork fixture withhostKeysand nohostKeygetshostKeys ++ vmKeys "dev-a"andhostKeys;, and three disagreeing fixtures are refused with every file untouched. If it is wrong, revert the one commit;declarewrites only text an agent reviews in a PR, and the repo's own checks still gate the ciphertext atcreatetime.What changed
declareHostRecipientTermreads the leading term of each matched line: a nix name, a dotted name, or one bracketed list, standing alone or followed by++. One shared term is used; anything else is a refusal naming the file, the count of lines, and what each one starts with.declareSecretsRecipientstakes that term instead of a literal.docs/allod-secret.mdsay where the term comes from and what is refused.Noticed, not changed
The public template's
secrets.nixnow derives every entry (allod/secrets#40 and the forge-key and host-key maps), so it has no top-level"secrets/<name>.age".publicKeysline at all.declarealready refuses it withno existing publicKeys line to insert after, before and after this change. That is a separate defect in howdeclarefinds its insertion point and in what the template offers it; this PR does not touch it.Risk
R1. One command's generated text, in a function with no side effects, gated by the same in-memory validation and same-bytes-on-disk checks as before. No secrets read, no git behaviour changed. Rollback is a revert.
Validation
gofmt -l cmd/allodclean;go vet ./...andgo vet -tags site,secret ./...clean.go test ./...,go test -tags secret ./cmd/allod/, andgo test -tags site,secret ./...pass, run fromnix develop.hostKeyswith nohostKeyyields the fork's term for a VM target and for the host alone, and the written file never gains the template's name; three refusal fixtures (two terms, VM keys first, a nested list) each name the file and what was found and leave all three files untouched; a table test over the term grammar.declareagainst a real fork'ssecrets.nixfollowed bynix flake check. The fixture reproduces the shape the issue describes, a list bound under another name with nohostKey.Closes allod/tools#271
Owner request: too many comments. Cutting every comment this diff adds to a contract, a trap, or a pointer, one to three lines each, and deleting the rest.
Closed unmerged by the owner's decision. This fixes the symptom at the tool while keeping the cause: declare hand-writes a recipient line into a fork's secrets.nix. The proper fix derives those recipients from the rotation registry inside the secrets repo, after which declare writes no secrets.nix line at all and this code has nothing to parse. The replacement issue is filed on allod/secrets and linked from allod/tools#271.
Pull request closed