Skip to content

feat(cli): add voltage context to inspect effective scope - #11

Merged
thebrandonlucas merged 1 commit into
masterfrom
feat/cli-context
Oct 8, 2026
Merged

thebrandonlucas merged 1 commit into
masterfrom
feat/cli-context

Conversation

@thebrandonlucas

@thebrandonlucas thebrandonlucas commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add voltage context, which shows what a command would act on without running one: the effective profile, account, organization, environments, wallet, webhook, API URL, configuration directory and config.toml path, each with where it came from (flag, profile, environment, default, or unset).
  • Report the selected credential's kind and location (keychain, file, or environment) without reading its secret, plus a typed credential_problem when commands would reject the selection: empty_api_key, no_credential, multiple_credentials, unknown_credential, or bound_elsewhere (a saved API key used outside its organization or environment). Context and every command share auth::select, so inspection reports exactly the rejection a command would make.
  • List ignored_variables: VOLTAGE_* scope, credential, or config-directory variables that are set but supply nothing because a flag or the selected profile takes precedence. A leftover export, or a profile silently overriding your environment, is the surprise this command exists to explain.
  • Precedence stays in Settings::scope, which now also reports sources (Settings::sourced_scope), so context cannot drift from what commands actually use.
  • Inspection makes no network request, reads no saved secret, and does not create the configuration directory.

Bottom of stack #18 (#11 → #17 → #14 → #15); based on master.

Example

export VOLTAGE_ORGANIZATION_ID=1111…   # leftover from yesterday
export VOLTAGE_WALLET_ID=3333…
voltage context --org 2222… --json
{
  "organization_id": {"value": "2222…", "source": "flag"},
  "wallet_id": {"value": "3333…", "source": "environment"},
  "environment_ids": {"value": [], "source": "unset"},
  "account": {"value": null, "source": "unset"},
  "credential": null,
  "api_url": {"value": "https://voltageapi.com/v1", "source": "default"},
  "config_file": {"path": "…/config.toml", "exists": false},
  "ignored_variables": ["VOLTAGE_ORGANIZATION_ID"]
}

(data only; trimmed.) Human output on a terminal is still the generic envelope rendering; a dedicated name value (source) view is deferred to the human-output PR.

Review exceptions

  • Public items: none added to the library API. Source, ScopeSources, sourced_directory, Settings::sourced_scope and Settings::config_file are pub(crate) even though config is a public module. auth::select, Selected, Rejected, and config::CredentialProblem are pub(crate); ambient_api_key stays private. The ignored-variable rules live in config beside the precedence they describe.
  • No unsafe, lint exceptions, project traits, getters, or dependencies.

Verification

  • cargo fmt --check
  • cargo clippy --locked --all-targets -- -D warnings
  • cargo machete --with-metadata
  • cargo test --locked: integration tests cover profile-over-ambient precedence, flag-over-variable precedence, ignored_variables, a blank VOLTAGE_API_KEY, secret absence from output, no HTTP requests, and no configuration directory created
  • python3 scripts/check-coverage.py

@thebrandonlucas
thebrandonlucas force-pushed the feat/cli-context branch 2 times, most recently from 028dc66 to 6a1c988 Compare October 7, 2026 12:56
@thebrandonlucas
thebrandonlucas changed the base branch from master to feat/cli-interaction-progress October 7, 2026 13:03
@thebrandonlucas thebrandonlucas changed the title CLI context feat(cli): add voltage context to inspect effective scope Oct 7, 2026
@thebrandonlucas
thebrandonlucas force-pushed the feat/cli-context branch 2 times, most recently from e0da34b to 3e8017c Compare October 7, 2026 17:11
@thebrandonlucas
thebrandonlucas marked this pull request as ready for review October 7, 2026 17:18
tee8z
tee8z previously approved these changes Oct 7, 2026
Base automatically changed from feat/cli-interaction-progress to master October 7, 2026 20:51
@thebrandonlucas
thebrandonlucas dismissed tee8z’s stale review October 7, 2026 20:51

The base branch was changed.

@thebrandonlucas
thebrandonlucas added this pull request to stack #16 October 7, 2026 20:57
@thebrandonlucas
thebrandonlucas requested a review from tee8z October 7, 2026 21:10
Comment thread src/config.rs Resolved
voltage context reports the effective profile, account, credential kind
and location, organization, environments, wallet, webhook, API URL, and
configuration directory, each with its source (flag, profile,
environment, default, or unset). Precedence stays in Settings::scope,
which now also reports sources. Inspection reads no saved secret, makes
no network request, and does not create the configuration directory.

It also lists ignored_variables: VOLTAGE_* scope, credential, or
config-directory variables that are set but supply nothing because a
flag or the selected profile takes precedence. Credential selection is
shared with auth, so credential_problem reports the same typed rejection
commands make: a blank VOLTAGE_API_KEY, no or multiple saved
credentials, an unknown name, or an API key bound to a different
organization or environment. The provenance types stay crate-private
although config is a public module.
@thebrandonlucas
thebrandonlucas merged commit 918cfaf into master Oct 8, 2026
6 checks passed
@thebrandonlucas
thebrandonlucas deleted the feat/cli-context branch October 8, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants