Skip to content

Add layered configuration resolver#289

Merged
JE-Chen merged 1 commit into
devfrom
feat/layered-config-batch
Jun 21, 2026
Merged

Add layered configuration resolver#289
JE-Chen merged 1 commit into
devfrom
feat/layered-config-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 21, 2026

Copy link
Copy Markdown
Member

What

Adds an ordered, deep-merging config resolver with per-key provenance. merge_patch merges two docs, config_sync is last-write-wins, and AssetStore is flat-per-env — none compose a defaults < file < env < CLI precedence stack or report which layer won each key.

  • LayeredConfig.add_layer(name, mapping, priority=None) — higher priority wins (default: insertion order).
  • resolve() — deep-merges all layers (nested dicts recursively, scalars/lists replaced).
  • get(dotted_key, default) and explain(dotted_key)SourceTrace(value, layer).
  • deep_merge(base, override) — standalone helper.

Layers are caller-supplied mappings (env passed in, never os.environ implicitly), so resolution is deterministic.

Layers

  • Headless core: utils/layered_config/ (pure stdlib copy, zero PySide6).
  • Facade: 3 symbols + __all__.
  • Executor: AC_resolve_config, AC_explain_config.
  • MCP: ac_resolve_config, ac_explain_config (read-only).
  • Script Builder: both under Data.
  • Tests: test/unit_test/headless/test_layered_config_batch.py (9 tests, no Qt).
  • Docs: v81_features_doc.rst (EN + Zh) + toctrees + 3 README What's-new sections.

Verification

  • pytest test/unit_test/headless/test_layered_config_batch.py → 9 passed.
  • ruff check je_auto_control/ clean; pylint 10.00/10; bandit clean; radon CC clean.
  • Package stays Qt-free.

merge_patch merges two docs, config_sync is last-write-wins, and
AssetStore is flat per environment — none compose an ordered defaults <
file < env < CLI precedence stack with a deep merge or report which layer
won each key. Add LayeredConfig (add_layer / resolve / get / explain) and
a standalone deep_merge. Layers are caller-supplied mappings, so the env
layer is passed in rather than read from os.environ. Wired through facade,
executor (AC_resolve_config / AC_explain_config), MCP, and the Script
Builder with a headless test batch and EN/Zh docs.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 43 complexity · 0 duplication

Metric Results
Complexity 43
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit 858d4f7 into dev Jun 21, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/layered-config-batch branch June 21, 2026 14:53
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant