Heuristic:1broseidon Ketch Secret Free Discovery
| Knowledge Sources | |
|---|---|
| Domains | Security, Configuration, Discovery |
| Last Updated | 2026-10-27 00:00 GMT |
Overview
A discovery rule for provider settings: `ketch config` reports which credentials are set using only boolean presence flags and counts (`*_set`, `*_count`, `*_source`), never the credential value itself, so an operator can verify "is my key configured?" without the value ever leaving the config store.
The Insight (Rule of Thumb)
- Action: For each provider setting, `Discovery` emits public fields: a secret `KeyPool` reports `<key>_set` (bool) and `<plural>_count` (int); a `Token` setting reports `<key>_source` (string) and `<key>_set` (bool); a scalar reports the value itself. A secret singular key reports only `<key>_set`. Never emit the secret value.
- Value: `Configured` reports whether explicit credentials make a doctor check required, by checking `GateDoctor` settings only. The plural pool is resolved through `MergeKeys` (singular first, trimmed, de-duplicated, order-preserved) so the count reflects the effective pool.
- Trade-off: An operator cannot see the configured key value from `ketch config` — they must open the file or re-run `config set`. This is deliberate: the config display is the surface most likely to be pasted into a bug report or a terminal screenshot.
- Compatibility: `Token` settings (like `github_token`) report a `source` of `"config"`, `"env"`, `"gh-cli"`, or `"none"` from the resolution chain, so an operator can tell which path supplied the token without seeing it.
Reasoning
The provider registry owns the description of each setting, and `Discovery` (`internal/configbase/settings.go:118-135`) is the single place that decides what a setting exposes to `ketch config` and to JSON output. By gating on `Secret`, `Token`, and `Plural`, the same descriptor that drives validation and env-overlay also drives discovery — there is no second list to keep in sync.
The `*_set` / `*_count` booleans are the contract the MCP server and `ketch doctor` rely on: an agent reading `ketch config` to decide whether a backend is ready sees `brave_api_key_set: true` without ever being trusted with the key. The `GateDoctor` flag is what makes a configured key required in `doctor` — a key set but never selected still gates the exit code, because a broken keyed backend the operator asked for is an installation problem.
The token source string (`config`, `env`, `gh-cli`, `none`) is the one non-boolean a token setting exposes, and it names only provenance, never the value. The `gh-cli` source comes from a 30-second memoised `gh auth token` subprocess so a single CLI invocation sees one consistent answer without paying for a subprocess each call.