Skip to main content

Module config_cmd

Module config_cmd 

Source
Expand description

kranz config — inspect and edit the layered configuration.

Configuration resolves from three layers, later layers winning (see kranz_engine::config): compiled-in defaults ← ~/.kranz/config.json (the GLOBAL layer) ← <repo>/.kranz/config.json (the PROJECT layer).

Four verbs:

  • show — the effective merged config (or one layer with --global/--project).
  • set <path> <value> — set ONE dotted key in a layer file. The dotted path is checked against the config SCHEMA first (a typo’d key would deep-merge, validate green — unknown keys are ignored on deserialize — and be a silent no-op). The edit then happens on the raw JSON tree (never a MissionConfig round-trip), so every other key already IN the file — including keys kranz doesn’t know about — survives untouched. The candidate merge is validated BEFORE anything is written; an invalid value leaves the file byte-identical. A --global write is validated TWICE: standalone (defaults + candidate global — what every OTHER repo sees) and merged with this repo’s project layer; either failure refuses the write, so a project override can never mask a global value that would poison other repos.
  • unset <path> — remove one dotted key from a layer file, pruning parent objects the removal left empty. Removing the last key leaves an empty {} file (the file is never deleted). The dotted path gets the same schema check as set (a typo’d key should say “unknown key”, not “not set”). Unset is NOT validity-gated: removal converges toward the defaults, and gating it could deadlock (an invalid VALUE in one layer would block its own removal). The schema-path gate cannot deadlock: an unknown key never affects validation in the first place.
  • role <role> <model> [effort] — the MID-MISSION path: enqueue a config-change control command on a running mission (the CLI twin of Slack’s /kranz config). File edits only shape FUTURE missions; role reshapes the one that is running, at its next spawn of that role.

Structs§

Layers
The two editable config layer files, resolved once so every verb — and every test — operates on explicit paths instead of re-deriving $HOME.

Enums§

ConfigCommand
Subcommands under kranz config — the configuration surface.

Functions§

cmd_config
Dispatch a kranz config … subcommand. mission is the global –mission flag, consumed only by role.
render_effective
Pretty-print the effective config merged from explicit layer paths over the compiled-in defaults (missing files are skipped, like config::load), with each layer’s provenance so the operator-only key rule applies here exactly as it does at load time.
render_layer_file
Pretty-print one layer file. A missing file renders as {} with exists = false so the caller can add a note without polluting stdout.
render_layer_file_redacted
render_layer_file with secret-shaped values replaced by [REDACTED].
role_change
Resolve the target ACTIVE mission (shared engine resolver — the same policy as Slack: an explicit id must exist and be non-terminal; a bare command needs exactly one active mission) and enqueue ONE config-change control command carrying the same camelCase patch shape Slack produces (kranz_slack::inbound::config_patch). A refused target enqueues NOTHING. Returns the mission id the change was applied to.
set_key
Set dotted to raw (JSON-parsed, string fallback) in the chosen layer file. The dotted path must exist in the config schema (a typo’d key would otherwise merge, validate green, and be a silent no-op). The candidate state is validated BEFORE writing — for --global both standalone and merged with this repo’s project layer; on any failure the file is left byte-identical. Returns the file written.
unset_key
Remove dotted from the chosen layer file, pruning parents the removal left empty. The dotted path gets the same schema check as set — a typo’d key errors as “unknown key”, not “not set”. A schema-valid key that is not set is an error too (and nothing is written). Removing the last key leaves {} — the file is never deleted. Returns the file written.