When a reference reader resolves secrets for a specific CLI name, it populates a string-to-string map using a specific priority chain. Later steps fill in keys that earlier steps did not provide, but they never overwrite keys already provided by a higher-priority source.
Priority Order (Highest to Lowest):
- Sealed file:
~/.agentcookie/secrets/<cli-name>/secrets.env.sealed. This is the authoritative dataset when sealing is enabled. - Plaintext file:
~/.agentcookie/secrets/<cli-name>/secrets.env. The fallback dataset if no sealed file is present. - Caller-registered fallback file: An optional secondary config file (e.g., a CLI's own
config.toml) provided by the reader. The reader may use heuristics to map these to expected keys. - Process environment: Environment variables matching expected key names. This is the source of last resort to ensure backward compatibility.
Crucial Rule: Bus over Env
The bus (Sealed/Plaintext files) MUST have higher priority than environment variables. This ensures that if a user has a leftover environment variable from an old workflow, the bus remains the authoritative source and is not silently ignored.
# Priority Chain Summary
1. ~/.agentcookie/secrets/<cli-name>/secrets.env.sealed (Sealed)
2. ~/.agentcookie/secrets/<cli-name>/secrets.env (Plaintext)
3. User-provided fallback file (e.g., ~/.config/<cli-name>/config.toml)
4. Process Environment Variables