Reviewer: Claude Fable 5.1 (claude-fable-5-1) — review @ 17925de
APPROVED. No blockers. Review only: no keys generated, no carlos config touched, nothing merged; scratch worktree removed.
Gates: make test on 17925de is green through vet, fmt, build and go test. test-race stops at the linux-only internal/provisioner on macOS; that target lists the package unconditionally, so it is a Makefile fact, not a branch fact. Hub CI is green.
What I checked
1. Randomness and encoding. Keypairs come from family.Generate: ecdsa.GenerateKey(P256, crypto/rand) plus ecdh.P256().GenerateKey(crypto/rand). MACs are 32 bytes from crypto/rand.Read. Formats: keypairs are base64.Std(family.MarshalKeypair), which is exactly what decodeHomeKeypair parses (strict, re-encode compared, D in range, validRosterKey); publics are base64.RawURL(SignPub), 65 bytes, what operatorPublic parses and what Alta's RawURLEncoding.Strict() + len==65 check on ALTA_DIRECTORY_PROVISIONING_PUBLIC_KEY requires; roster id is rosterKeyID; MACs are standard base64 as operatorMAC parses; HTTP and material go as _BASE64 through exchangeJSON. All match.
2. Key inequality is complete. The generation-time set {Alta, owner-seed, provisioning, roster, resolve, every assertion key} is pairwise distinct by name (distinctTeamKeys). Every boot-time rule is a subset of it: credential loadOperatorHTTP {alta, owner, provisioning, signer, resolve}; directory loadOperatorHTTP {alta, ownerPub, provisioning, assertion…, roster…, resolve}; rosterRuntime.valid (roster ≠assertion); validResolveKeys (resolve ≠signer, assertion, roster); NewCredential and NewCredentialHTTP (signer, browser, provisioning ≠alta/signer); the native command's OtherKeys. distinctTeamMACs requires both MACs to be 32 non-zero bytes and unequal. MAC ≠HOMEDEK and HOMEPEPPER ≠MAC cannot be checked offline; for fresh 32-byte crypto/rand values the collision probability is 2^-256, and the native command refuses at run time rather than at serve. Not a real gap.
3. Secret handling. Every error carries a line number, a rule, or a key name; the only quoted values are origins (public). The loaders return the constant errExchangeConfig. team_keygen.go has no logger (test-enforced). String flags cannot fail to parse and an unknown flag names only the flag. -out opens with O_CREATE|O_EXCL at 0600, chmods, and removes on any failure; O_EXCL also refuses a pre-existing symlink. No nil dereference is reachable from the CLI: the manifest parser refuses an empty manifest, and loadTeamRole requires operator, resolveSigner/resolvePublic before the cross-role checks touch them.
4. -check and the process environment. withTeamEnv clears all eight variables the three loaders read and I confirmed they read nothing else from the environment (role, origins and keys arrive in the Runtime struct). Restore is deferred and runs on the early-return path too. The command spawns no children and exits; setenv does not rewrite the initial environ block, so nothing is observable from outside the process. Safe. The "not concurrent-safe" caveat is right and irrelevant to a CLI.
5. Guard exception. It permits os.Stdout only at argument 2 and os.Stderr only at argument 3 of a four-argument call to RunTeamKeygen whose receiver resolves through the import table to amadan.net/oficina/home/internal/home, and only in cmd/home/main.go. A swap, a duplicate, or any other use in that file is still flagged. The dispatch runs before slog.Default() and rastrillo.Resolve, so nothing logs around it. Narrow enough.
6. Cross-role consistency and Alta pins. Generation validates version/role, origin against the given pair, placeholders unfilled or already equal, key_id = sha256(public_key), a canonical point, 64-hex prefilter, <role>.inspect, operator.NewVerifier, six shared fields equal across roles, and the ALTA_* lines against the pins when present (the private key's public half, sha256(prefilter), installation/registry/device). -check adds: pins equal across roles, subjects equal, owner_seed_public = pub(owner), the credential's provisioning pin = pub(directory provisioning), the resolve pair, MACs distinct, and the Alta section. Roster key ⊆ roster_keys and roster ≠assertion come from the loaders it calls. The round trip against the real alta keygen fixture matches the f78d993 source line for line.
7. Output against #101 §5. Sections are in the apply order 1.1 → 1.2 → 2.1 → 2.2 → Alta, each headed by its one carlos call. HOME_ROSTER_MODE=serve and HOME_ROSTER_KEY sit in the same [directory secrets] section. The [credential env] note says HOME_CONSUMERS_BASE64 gaining alta goes in that same call and is not generated. Each intermediate state boots per the loaders: material is ignored without HTTP, the resolve key alone is valid, roster mode + key alone is valid. Production app names appear only for the production origin pair.
8. Mutants. I ran twelve of my own: drop the duplicate-key refusal; Alta's key effectively out of the set; assertion keys out of the set; MAC equality; resolve-pair agreement; the env restore; two-runs pin agreement; <role>.inspect; 0644 output; subject agreement; "operator would be off"; credential checked against the first assertion key only. Eleven killed. "Alta out of the set" was caught by the self-check through the real loaders even before the named refusal, so the defence in depth earns its place. The one survivor is the last, and it is equivalent for inequality (the directory's own set is the union), but it exposes a coverage gap (N1). The author's five survivors are as described: equivalent.
Notes (non-blocking)
- N1
internal/home/team_keygen_test.go: no test uses a manifest with two assertion keys, so the per-key credential loop atinternal/home/team_keygen.go:471-482is untested. One case before the first key rotation. - N2
internal/home/team_keygen.go:623-626: the[alta env]note namesALTA_HOME_CONSUMER_ID=altaand alta keygen's lines; Alta also requiresALTA_ORIGIN(= thealtaconsumer entry) andHOME_DIRECTORY_ORIGIN. Naming them would make §5's Alta side complete from the file alone. - N3
internal/home/team_keygen.go:631: the header prints the subject (a person ref) beside the key_id. Fine under the one rule, noting only that it sits in the 0600 file. - N4
checkTeamEnvwith an empty assertion map would nil-deref atcred.operator; unreachable from the CLI (parseTeamAssertionKeysrequires 1 to 8). Internal-API nicety only. - N5 Operationally:
-checkvalidates against whatever-assertion-keysit is given, so paste the live directory manifest, as the usage says; and the preview canary needs alta's two origin fields edited first, which the tool rightly refuses to skip.