Repository navigation
Description
Pass-three scope decision (critical review). Pass two landed on "rung 2 (a blessed
deepMergeprimitive) is the expected outcome, because per-property provenance is a confirmed must-have." Review pushes back: the must-have is asserted, not validated — there are no customers yet. The umbrella parks #202 for exactly this reason (building for scale that doesn't exist). The same discipline applies here. Decision: commit rung 1 (pattern + guide) now, since the layering capability already exists in plain TypeScript and the example is pure projection over existing primitives. Defer the blesseddeepMergeprimitive + per-key provenance (rung 2) until a real user confirms the need. The rung-2 spec is preserved below as designed, but gated on demand — a new evaluator mechanism does not ship on an unvalidated requirement.
Problem
"One composite, deployed across many environments, with per-environment differences." Today it's hand-rolled from presets (shallow const spreads) + directory partitioning. No first-class answer.
What the grounding showed
The blessed static-data patterns already in chant (@intentius/chant EVL rules + composites) get us most of the way:
- Layering is just const-to-const spread. EVL001's own fix example is
const tags = { ...baseTags, env: "prod" }. Build a config by spreading a base const and overriding — fully static, already supported. - Deep layering is native nested spread.
{ ...base, scaling: { ...base.scaling, ...env.scaling } }. Static dot-access on a const is allowed (only computedconfig[key]is EVL003). So multi-level merge is achievable today. - Composites already instantiate per-env.
const stack = MyStack(prodConfig)is the blessed factory call; props must be static, which a layered const is. - A
deepMerge(a, b)helper is the one thing that does NOT work. Assigned to a const it's a function-call initializer → EVL001/EVL004 reject it. Any merge helper would have to be blessed by the evaluator (folded at synthesis like intrinsics/composites are), which is a real mechanism change.
Conclusion going in: the layering capability exists in plain TypeScript. The remaining frictions are verbosity (deep nested spread is noisy) and boilerplate (one file per environment). These are real but they do not on their own justify a new evaluator mechanism. The one thing that would — per-property provenance — is no longer treated as a confirmed must-have (see the scope decision above), so it no longer forces rung 2.
The mechanism decision (re-scoped)
Rung 1 is committed. Rung 2 is deferred, gated on validated demand. The crux in pass two was that provenance (#204) was a must-have and provenance is cheap only when chant owns the merge. With provenance demoted to "deferred until a user asks," the driver for rung 2 is removed for now. Ship the pattern; revisit the primitive when there is evidence.
Three rungs, lowest that satisfies the committed requirement wins:
- Pattern + guide only. Const layering + native nested spread, documented, with a real "one composite, N environments" example in a lexicon's
examples/. Committed — this is the deliverable. Delivers the layering capability with zero new mechanism. Does not deliver per-key provenance; that is acceptable because provenance is deferred. - One blessed
deepMergestatic primitive — evaluator folds it at synthesis (same class as intrinsics), EVL traces its args to const data, and it records per-key layer origin during the fold (the provenance source design: describe / effective-config introspection command #204 would consume). Strictly: deep object merge, last-wins, no list strategies. Deferred — design preserved below; ship only when a real user confirms provenance/verbosity pain that rung 1 can't absorb. - Env-matrix / directory codegen (declare
[dev,staging]×[us,eu], auto-fan-out directories). Rejected — the tar pit the review warned about. Each stack staying an explicit, readable file is a determinism/auditability feature, not a limitation. Out of scope; only revisit as its own issue if real demand appears.
Out of scope (firm)
- Env-matrix directory auto-generation (rung 3 above).
- Deep-merge list strategies (concat/replace/keyed) — lists replace, full stop.
Note on provenance: per-property provenance is deferred, not committed. If/when rung 2 is built, #203 emits the per-key origin data and #204 renders it. Until then, neither ships.
Tasks
Committed (rung 1)
T1 — Spike + example: prove the pattern on today's primitives. Build a real "one composite, N environments" example: a composite instantiated for ≥3 environments, config layered base→env→region with at least one nested object, and per-env resource names. Build it; record every friction point. Confirm/deny ...base.scaling passes EVL today.
- AC: example builds clean; written friction list; confirms/denies
...base.scalingpasses EVL today.
T2 — Guide + promote the example. "Layered configuration / one composite, many environments" guide page; promote the T1 example into a lexicon's examples/ so CI exercises it.
- AC: guide page merged; example builds in CI.
T3 — Naming/identity. Ensure per-env resource names are stable and collision-free — thread an env/name prop through the composite. Decide: documented pattern vs. a tiny helper.
- AC: example shows distinct, deterministic names per env; approach documented.
T4 — Lint coverage check. Verify EVL004 already forbids non-const layers; add a dedicated diagnostic only if a real gap exists. Do not add a rule speculatively.
- AC: either a written confirmation existing rules cover it, or one new rule with tests.
Deferred (rung 2 — gated on validated demand)
D1 — Decision gate. A real user (or a real internal multi-env project) reports that rung-1 verbosity/boilerplate or the absence of provenance is genuine pain. Without that signal, do not start.
- AC: recorded evidence of demand citing the rung-1 example's frictions.
D2 — Blessed deepMerge primitive. Evaluator-recognized static deepMerge fold; EVL handling so its args must trace to const; per-key origin record emitted for #204; unit tests for fold, rejection of non-const args, and origin accuracy.
- AC: fold + EVL + provenance-origin tests green; origin output matches the shape design: describe / effective-config introspection command #204 consumes.
Open decisions (flag for build phase)
- Does
...base.scaling(static member-access spread) pass EVL today? → T1 answers definitively. - If rung 2 is ever built: core vs per-lexicon? → recommend core (pure data, lexicon-agnostic).
- What presets become: presets remain the single-level shallow case; layered config is the multi-level generalization. If a
deepMergeprimitive ever lands, re-document presets as its one-layer case — but do not break the existing preset API.
Sequencing
Gated by #206 (done — the determinism boundary this leans on). Rung 1 is independent and can land now. #204 v1 (resolved view) does not depend on rung 2 and can proceed against rung-1 config. The deferred rung 2 gates #204's provenance view, which is itself deferred.
Umbrella: #198.
Activity
[-]research: static layered configuration composition (one composite, many environments)[/-][+]design: static layered configuration (one composite, many environments)[/+]feat: layered configuration example + guide, and `chant describe` (#203…
chant-v0.1.17 (#264)