fix(secrets): read the age identity once per process so <(...) keys survive --all #94

Merged
dan-claude-bot merged 2 commits from fix/age-key-read-once into main 2026-07-18 20:23:41 +00:00

2 commits

Author SHA1 Message Date
dan-claude-bot
a504ac2b54 test(secrets): make the read-once comment path-neutral so #90's /dev/fd rename cannot stale it
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-18 19:22:16 +00:00
claude-hdb
8c396736c8 fix(secrets): read the age identity once per process so <(...) keys survive --all (#36)
A process substitution (`CAST_AGE_KEY_FILE_<ENV>=<(pm read ...)`) is a
read-once pipe, but `diff --all` / `apply --all` call decryptSecrets once
per project. The first project drained the pipe; every later project
re-read the key file, handed age an empty identity, and failed — the
fleet loop then misreported the project as unreachable (diff) or aborted
the fleet (apply). Latent today because only one registered project has
a prod store; real the moment a second one gains one.

Cache the key bytes by key path, module-level, so the identity is read
exactly once per process. Exposure is unchanged: the key already
transits this process's memory on every call.

The regression test uses a FIFO, which really drains — unlike the
existing /proc/self/fd test, whose regular file re-opens at offset 0 on
every read. A second writer serves emptiness after the first decrypt so
a regression fails loudly (age: no secret keys found) instead of
blocking the suite on a writerless FIFO open.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 18:27:53 +00:00