Repository navigation
feat(config): unified polylogue.toml with explicit layer precedence (#829) - #1143
Conversation
Establishes the five-layer precedence chain described in #829 with provenance tracking surfaced through `polylogue config --show-layers`. Layers (low → high): 1. built-in defaults 2. site TOML — /etc/polylogue/polylogue.toml (env: POLYLOGUE_SITE_CONFIG) 3. user TOML — $XDG_CONFIG_HOME/polylogue/polylogue.toml or ./polylogue.toml (env: POLYLOGUE_CONFIG) 4. POLYLOGUE_* env vars 5. CLI overrides (per-invocation) `PolylogueConfig` now exposes `layers` and `layer_of(key)` so callers (and the CLI) can report which physical layer supplied each value. `describe_config_layers()` complements that by reporting the resolved file paths and existence for the site and user layers. The CLI `polylogue config` command gains `--show-layers` and emits the layer descriptor + per-key provenance in either TOML or JSON. Inherited snapshot drift from the master `init` command (#1116) is refreshed in the same change so the syrupy gate is green again. Ref #829 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Line 357 in 43db757
Do not drop POLYLOGUE_CONFIG/POLYLOGUE_SITE_CONFIG paths when the file is missing, because polylogue config --show-layers is supposed to explain where each layer points and whether it exists. With the current is_file() gate, an explicit but mistyped path is reported as path: null, which hides the operator error and makes the new diagnostics far less useful.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if before_env.get(key, _MISSING) != value: | ||
| layers[key] = "env" |
There was a problem hiding this comment.
Record provenance by key presence, not value delta
Update the layer map even when a higher-precedence layer sets the same value, otherwise --show-layers reports misleading provenance. For example, setting POLYLOGUE_API_PORT=8766 currently leaves api_port marked as default because the value did not change, even though the env layer explicitly supplied it; the same issue applies to TOML layers that restate default values.
Useful? React with 👍 / 👎.
Summary
Establishes the five-layer config precedence chain described in #829
(defaults → site → user → env → CLI) and surfaces layer provenance
through
polylogue config --show-layers.Problem
polylogue/config.pyalready had aPolylogueConfigloader that read asingle TOML and
POLYLOGUE_*env vars, but it did not match thecontract in #829 in three ways:
/etc/polylogue/polylogue.tomlso packaging can ship defaults thatare themselves overridable per user.
way to ask "which layer did this come from?" — the very question
feat(config): unified config system — polylogue.toml, four-layer precedence, shared daemon/CLI config #829 calls out for
polylogue config --show-layers.configCLI command did not expose layer information at all.Solution
polylogue/config.py:DEFAULT_SITE_CONFIG_PATH = /etc/polylogue/polylogue.tomland_site_config_path()with aPOLYLOGUE_SITE_CONFIGoverride (emptystring disables, e.g. for tests and ephemeral environments).
_default_config_values()and an_apply_toml_layer()helper that records which keys each layeractually changed.
load_polylogue_config(site_config_path=..., config_path=..., cli_overrides=...)now walks defaults → site TOML → user TOML → env → CLI in order and
builds a
layersmap alongside the resolved values.PolylogueConfiggainslayers(dict) andlayer_of(key)accessors;malformed TOML is swallowed silently so a broken site config cannot
brick the CLI.
describe_config_layers()returns a JSON-friendly view of theresolved site and user config paths plus existence flags, used by
polylogue config --show-layers.polylogue/cli/commands/config.py:--show-layersto the existingpolylogue configcommand.{value, layer}map in eitherTOML or JSON (both via
console.print(..., markup=False)so JSON andTOML headers survive Rich markup parsing).
tests/unit/core/test_config.py:TestPolylogueConfigLayerPrecedencecovers every transition(default → site → user → env → CLI), the missing-file fallthrough,
and the malformed-TOML graceful fallback.
TestDescribeConfigLayerscovers the structured report includingthe
POLYLOGUE_SITE_CONFIG=""disable case.The inherited
init-command snapshot drift on master (#1116 landedwithout refreshing
tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr)is included so
pytest tests/unit/cli/test_terminal_snapshots.pyisgreen again on this branch.
Verification
Ref #829