Repository navigation
fix: resolve identity by definition value and split the provenance field - #678
Merged
Merged
Conversation
den spelled three unrelated things "provider": the type of an `includes` element, the `provides` delivery namespace, and the ancestor chain that forms identity. Both bugs fixed on this branch were a function reading the wrong one, and a reviewer scanning for that has to disambiguate by hand every time. The chain takes gen-aspects' name for it, which is not a new minting: # gen-aspects/lib/identity.nix:4 aspectPath = a: (a.meta.aspect-chain or [ ]) ++ [ (a.name or "<anon>") ]; Identical formula, identical ancestors-only convention. `meta.provider` is `internal = true; visible = false`, so no user-facing surface moves. The internal marker becomes `__aspectChain`, following den's camelCase convention for `__`-prefixed markers rather than the meta field's spelling. `providerType` and `providerPrefix` are deliberately untouched: the first is a different concept, and the second is a false friend that a later step splits into `origin`. den's `providerPrefix` accumulates per level while gen's is fixed per container, so they are not the same thing despite the spelling, and mapping them by name would miswire silently. The published capture field renames too, which breaks den-diagram; that consumer is updated in the same change set. It reads the field through `or [ ]` defaults at four sites, so leaving it stale would not error, it would make every node read as a root in every diagram.
It asserts on `meta.aspect-chain`, which is `internal = true; visible = false` and therefore not a seam. den already separates white-box tests from behaviour tests by directory; this one was in neither. The rename in e6608408 breaking it is the tell: a test at a seam does not notice an internal rename.
meta.aspect-chain defaulted to typeCfg.providerPrefix or [ ], so a root aspect and an inline includes literal both landed on [ ] and nothing downstream could tell them apart. The option is now nullOr (listOf str) with no default; a declared aspect sets its own chain via aspectMeta's mkDefault instead of inheriting one, so the value travels with the aspect through re-inclusion the way meta.loc does not. Audit every reader: identity.aspectPath/baseKey, compile-static's chainIdentity, provide's self-provide meta, and trace's entry/isProvider/ provPath all build ON TOP of the chain (own identity, a child's prefix, or display) rather than testing for root, so they now coalesce null and root alike via a shared identity.ownChain helper instead of the stale `or [ ]` that stopped catching a present-but-null key.
types.nix's parametric-fn branch now writes meta.aspect-chain instead of the dead meta.provider key, activating a previously-inert widening of identity for bare parametric fns under `provides`. Nothing in the suite discriminated the two arms; add a cell that does.
removeAttrs stripped "provider", a key name the aspect-chain rename left behind as a stranded string literal. It never matched the live "aspect-chain" key, so a parametric wrapper carrying its own meta leaked its chain past the filter and won over the freshly computed one.
nameIndexed and constraint/trace consumers key on scopedIncludesChain as rendered strings; a future fill of an absent meta.aspect-chain needs the same parent position as a segment list, not a string to split back apart. chain-push/chain-pop now maintain scopedIncludesChainSegments in lockstep with the existing string chain, fed by the segment list compile-static already builds before rendering it to chainIdentity.
chainWrap took the rendered string and the segment list as two independent parameters, so a third call site (or a change to identity.key) could push a string and a list naming different positions, read by disjoint consumers. chainWrap now takes the segment list alone and renders the string itself via identity.pathKey, and both producers (compile-static, compile-conditional) push identity.aspectPath so the derivation is sound at every call site.
meta.aspect-chain reads null both for an aspect genuinely written inline at an includes site and for one that reaches resolution through some other path never touched by the module system's meta injection: den's own top-level default (a bare submodule option, not an attrsOf element), raw fixtures fed straight to fxFullResolve/capture bypassing the module system, and hand-built closures used as hasAspect/includeIf/exclude guard targets. Filling absent chains from walk position (a later, separate change) can only be sound once null means exactly one thing, so each of these states its own chain explicitly instead.
The acceptance cell for a raw fixture stating its own chain hardcoded the chain into the fixture itself, so deleting defaults.nix's den.default stamp left it green — nothing exercised the actual construction site. Add a cell that reads den.default's chain directly, and give the fixture's own root an explicit chain instead of leaving it another absent-chain node.
An inline `includes = [ { name = ...; ... } ]` literal never gets a
declared chain, so two owners each writing their own inline aspect of
the same name both read as root and collide at the gate. Fill from the
walk's current parent position in compile-static, where this node's
own meta is already forced — but only when the chain is absent, never
overwriting a declared aspect's chain, so a shared reference included
from two sites keeps one identity. Exclude names children.nix has
already walk-stamped (nameIndexed/nameAnon): those already encode their
ancestor position in the name itself, and filling their chain too would
double-encode that position, compounding exponentially at every further
level of nesting.
insecure-predicate-builder.nix and unfree-predicate-builder.nix ship
their parent aspect as a raw attrset (no meta) under
den.default.includes, so the fill in compile-static gave it
den.default's own position instead of staying a root. Their children
carried author-written names that already encoded the parent's path
("insecure-predicate/os"), so filling the parent's now-inherited chain
onto them doubled it.
State every one of these aspects' own chains explicitly, splitting the
"/"-named children into a real chain segment rather than leaving the
path baked into the name string as a single segment.
isWalkStampedName tested a name's shape (".*:[0-9]+(/.*)?") to infer
whether the walk had invented it, which also matches an author-written
name in that shape ("gcc:14") and wrongly excludes it from the
inline-chain fill.
Set __walkStamped on the nameAnon/nameIndexed branches in children.nix,
where the stamped name is actually produced, and have compile-static
test that marker instead of pattern-matching the name. Add __walkStamped
to key-classification.nix's structural keys so it doesn't reach
classification as a class key.
mkParametricBase rebuilt a parametric-resolved aspect from an explicit carry-forward whitelist (name, meta, into, provides) instead of merging onto the original, silently dropping __walkStamped for any walk-stamped child that also compiled as parametric (including a plain static aspect promoted into parametric shape by compile.nix's descendant-arg router). The chain fill then re-fired on re-entry, double-encoding the segment already embedded in the walk-stamped name — live on the stock igloo/tux fixture with no user aspects at all.
…spect claims one identity An inline includes literal with no declared chain reads as root, same as any other unfilled null — so a value written once and included from two owners was indistinguishable from two separately-authored literals, and each inclusion site filled its own chain and split the value into two nodes that double-emitted (types.lines content, so the duplication reached delivered config, not just a diagnostic identity string). providerType.merge (types.nix) now stamps each raw def with its author- written definition position, read before wrapperToAspect rewrites `name`. compile-static's chain fill keys a per-scope registry on that position: the first node to fill at a position claims the walk's current chain, and every later node at the same position reuses the claimed chain instead of filling its own, so both render one identity and gate dedup collapses them to one emission. A node with no definition position (declared aspects, parametric wrappers) behaves exactly as before.
…-bound aspect claims one identity"
…on alone
Stamp meta.__defPos/__defValue at providerType.merge (the one point a
definition is still raw) and register the first chain claimed per
def-position in pipeline state. A second sighting at the same position
reuses that chain only when its raw value is `==` the first's; a factory
or `base // {...}` specialization producing a different value at the same
token position claims its own chain instead of silently colliding with the
first (#670 for that input class, the defect the reverted 38e1f725 mechanism
reintroduced for a different class).
Reverts 38e1f725 (its own commit, restoring shared-raw-include-splits.nix
which the plain revert would have deleted) and replaces it with this sixth,
value-equality-keyed mechanism.
…sition
Two fix-round-1 findings on the value-equality guard (b049398e):
- The claim comparison projected `meta` off both sides before `==`. Any two
raw values differing only in `meta` therefore compared equal, merged, and
dropped one owner's node -- the exact silent-drop class this task exists
to remove, and meta is not comparison-inert (metaType's handleWith/
collisionPolicy are real fields). `__defValue` is captured pre-stamp, so
there was nothing of the guard's own bookkeeping for the projection to
strip. Fixed by comparing the values whole.
- `chainByDefPos.<pos>` held a single claim, registered only once. A
differing sibling from the same factory walked first permanently occupies
the slot, so a genuinely shared value's own two sightings are compared
against the wrong claimant forever and never find each other -- the
mechanism becomes a silent no-op for that walk order. Fixed by keeping a
list of `{ chain; value; }` claims per position and matching against
whichever one equals.
Adds three cells to shared-raw-include-splits.nix covering both findings
(the sibling-then-shared case in both walk orders). Both-baseline and full
suite re-verified unchanged (d61e1f45 4/7, 38e1f725 5/7 on the original set);
just ci 1140/1140, just ci performance 29/29.
…t values The C2 fix (a560f3b4) turned a single claim per definition-position into a list, and findFirst walks the whole list on every arrival -- K(K-1)/2 in the count of distinct raw values sharing one position, not the linear bound recorded before the list existed.
Two policy records sharing a bare name (two mkPolicy "tools" owned by different aspects, or two aspects each declaring their own policies.tools) silently overwrote each other in scopedAspectPolicies, whose registry key was always the bare name with no way to tell them apart. registerPolicy now claims a name within the current scope on first sight and keeps it bare; a second, distinct raw value claiming that same name in the same scope gets displaced to a chain-qualified identity instead of overwriting the first. A shared den.policies.foo referenced twice compares == to its own earlier claim and reuses its identity unchanged, so it still fires once. Bucketing is by (scope, name), not definition position: traced empirically, two aspects' own same-named policies.<name> merge at different option paths (each submodule eval bakes its own aspect name into loc), so a def-position bucket would put them in separate buckets and miss the very collision this exists to catch, even though both land in one scope's scopedAspectPolicies.
…estor scope children.nix's registerPolicy displaced-identity path qualified only by parent chain, which is constant across every claimant sharing one chain — distinguishing claimant #1 from the rest but not #2 from #3 at N>=3. Qualify with the claim's own index within its bucket instead. The same-scope collision check also used e.scope == scope, but policy/schema.nix's emitLateForSibling merges an ancestor scope's registrations with a descendant sibling's by this same ownerIdentity (allAspectPolicies = scopedAspectPolicies.${parentScope} // scopedAspectPolicies.${sib.scopeId}). Widen the filter to self-or-ancestor via the shared foldScopeAncestors walk already used by the constraint registry, so a host-scope and descendant-scope policy sharing a bare name are recognized as distinct claimants there too. Covers both with dedicated regression cells: a three-claimant factory shape for the index qualification, and an ancestor/descendant scope pair (with a second sibling as control) for the late-dispatch merge.
excludeIdentity resolved a policy exclude to its bare registration name, but same-named claimants no longer all share that name -- only whichever claimant registers first keeps it (children.nix registerPolicy); a later claimant gets a chain-qualified identity instead. `excludes = [ betaTools ]` names a specific record, so an exclude authored against it must resolve to whichever identity betaTools itself ends up holding, not to whatever currently occupies the bare name. Raw-value equality against the claim registry is comparable at dispatch time (confirmed empirically), but not at register-constraint time: an aspect's own excludes register before its own includes walk, so the claim registry a raw lookup needs is still empty then. Constraint entries now carry the raw policy reference (rawRef) alongside the bare-name fallback key; resolution happens later, at dispatch, via the shared isPolicyExcluded (constraint.nix) -- the single entry point for both the initial per-scope dispatch (dispatch-policies.nix) and the late-sibling re-dispatch (policy/schema.nix emitLateForSibling), which previously ran its own bare-name-only exclude check and let a rawRef-excluded claimant fire anyway.
…yExcluded An exclude naming a record that never registered must exclude nothing, not fall back to a bare-name match that kills an unrelated policy sharing that name. Also records isPolicyExcluded's per-call cost now that it flattens the scoped registry instead of one lookup.
The prior bound omitted C, the size of the claim bucket resolveClaim scans at each visited ancestor scope — and that bucket is fleet-wide (policyClaimsByName), not per-entity, so the R×D×C term is linear in fleet size once multiple entities declare a same-named excluded policy. Comment only; no behavior change.
E is bounded by how many excludes/handleWith one aspect tree declares — a count, not the include-nesting depth. Comment only.
nix/lib/aspects/types.nix built the `_`-as-provides alias three separate ways: root via mkAliasOptionModule (merges, errors on conflict), nested via a `//` fold (silently overwrites, spelling-priority not order-priority so reordering never recovered the dropped definition), and mergeFunctions' battery branch (only ever read fn.provides, ignored fn._ entirely). Add foldUnderscoreIntoProvides, a single helper that folds a `_` write into `provides` before flatDefs/mergeFunctions see it, so both spellings of one provides key become defs of the same key and merge through the existing per-site machinery instead of one silently dropping the other. Root is unchanged: mkAliasOptionModule already normalizes `_` before mergeWithAspectMeta runs, so calling the helper there would be a no-op. This unifies spelling only (O8, the weak reading), not root's and nested's differing conflict semantics — root still errors on a genuine scalar conflict, nested still last-wins. test-q4-nested-conflict-is-error guards that boundary and is expected to stay red.
test-q4-nested-conflict-is-error asserted nested's genuine scalar conflict IS an error and was designed to stay red — correct during review, but wrong to land: a collected cell that's expected to stay red breaks the "clean just ci means nothing's broken" property every other check here depends on. Replace it with test-q4-root-nested-conflict-diverges: a green cell that pins the same fact (root errors on conflict, nested last-wins) as an assertion instead of a permanent failure. Targets different NixOS options per position (networking.hostName vs time.timeZone) so root's raw conflicting defs can't also poison nested's already-collapsed value in the same host evaluation.
Land a structural probe (providerType.merge called directly, no host eval) for the fix that lets mergeFunctions' battery branch forward a _ write on a __functor-carrying def. Falsified: reverting that one line drops direct/viaUnderscore/viaProvides all to false while the rest of the suite still passes, so nothing else pinned it. Correct foldUnderscoreIntoProvides' docstring: leaving root untouched isn't a no-op (measured false — helper-at-root flips the root conflict test from "ERROR" to "hB"), it's necessary because the helper is a // overwrite and would replace root's priority-preserving, conflict-detecting alias with the same spelling-priority behaviour this fold exists to fix at nested.
Add test-rvb-consumer-battery-underscore alongside the existing direct providerType.merge probe: same three fields, declared via den.aspects.battHolder.provides.batt instead of a hand-minted def, so the pin survives a change in how a declaration reaches merge, not just the merge signature itself. Falsified against the same one-line revert — real red on both cells together. Also fixes a stray triple-space before the colon in the foldUnderscoreIntoProvides docstring (nixfmt does not reformat comment prose, so it survived the prior round's fmt pass unnoticed).
…tion) typeCfg.providerPrefix conflated a container's fixed seed (den.aspects [] den.ful [name], den.batteries ["den" "batteries"]) with the per-level accumulated definition chain. The two coincide at a container root, which made the conflation invisible anywhere anyone would test it. Split into `origin` (list, stated once per container, never accumulated) and `chain` (list | null, threaded definition chain; null keeps its present meaning of "absent, fill from the walk"). Consumers read `typeCfg.chain or typeCfg.origin` — `or` fires on a missing key, not a present null, so the null sentinel used by options.includes is preserved. `origin` deliberately mirrors gen-aspects' own `providerPrefix` field (bound to `origin` there), easing the eventual den-on-gen rewrite; `chain` names the accumulating half gen has no equivalent for. Pure key rename at the three declaration sites and two CI fixture files — zero value changes.
No cell in the corpus asserted a battery or namespace meta.aspect-chain literal, so O4/O5 of the origin/chain split rested on suite totals alone. Add two cells in the shape of this file's existing direct meta.aspect-chain read: a battery root's chain is ["den" "batteries"], a namespace aspect's chain is [<ns>]. Green today, so a regression in either origin seed shows up as a real red instead of a passing total.
…e scope-fork count D1 F1: the walkedScopeIds > 1 throw landed for §4.2 was dead code — push-scope can only fire from inside policy dispatch, which this walk never runs (installPolicies gates on __entityKind, attached only via the resolve-entity effect, never reached here), so the walk can never fan into more than one scope. Worse, the fix as landed introduced a new silent-drop mode: a pipe-arg-deferred child carrying both direct class content and a policy effect (route/instantiate/provide/aspect-policy) or a still-deferred nested include delivered the direct half and dropped the other with no diagnostic, since this walk registers those effects without ever dispatching them. Guard on that residue instead: throw when any of the five scoped-effect state maps (scopedAspectPolicies, scopedRoutes, scopedInstantiates, scopedProvides, scopedDeferredIncludes) hold something for the walk, rather than deliver scopedClassImports alone and lose the rest quietly. Known gap, not closed here: a deferred child whose own includes fans over an entity arg leaves no residue in any of these maps and still loses content silently — that needs bind's entity-arg fan classification, a different position entirely (D1 F1 arm C).
ci.bash's --select marked every expectedError cell as passing without forcing its expr, so a cell asserting an error read green even when the code stopped throwing. Force it through tryEval instead. Only the binary throw/no-throw crosses the nix-eval-jobs worker boundary, so type and message verification still needs nix-unit directly; the header now says so rather than claiming these cells are ignored.
The expectedError cell alongside this one discriminates only under raw nix-unit. Assert the same throw through tryEval so the gate sees it.
…name `isPolicyExcluded` resolved every rawRef exclude entry to its target identity and flattened the whole scoped constraint registry, neither of which depends on the candidate name being tested. Both were inside the four-argument call the two callers made from within a `filterAttrs` lambda, so the entire O(E + R × D × C) term was recomputed for each of P policy names. Curry the function so `name` is the last argument and hoist the partial application out of both lambdas. The rawRef arm now resolves every entry rather than stopping at the first match: which entries got resolved previously depended on the order candidate names arrived in, so an error reachable through resolveClaim surfaced for some dispatch orders and not others.
…forward normalizeRoot's needsWrap branch rebuilt a functor-shaped ROOT aspect from name/meta/includes/__scopeHandlers, dropping excludes, provides, policies, into, classes and every __ marker. Carry every structural key forward except the ones the unwrap itself re-derives, matching mkParametricBase. The branch is reached whenever an aspect carrying a user-written __functor is resolved as a root (the synthetic resolveAspectWith is a non-pattern lambda and reports no functionArgs, so ordinary aspects never enter it). The new cell pins a dropped sibling `excludes`; its non-functor twin is the control that excludes are otherwise live at that root.
builtinStructuralKeys enumerated its twelve __-prefixed entries, so a new pipeline marker was structural only once someone remembered to list it here; until then it was dispatched as class or nested-aspect content. CLAUDE.md already states the convention, and types.nix's providesChildren already applies it as a live predicate. structuralKeysSet becomes isStructuralKey, a predicate — every reader was a membership test, none iterated the set, so no reader loses a list. The eleven non-__ names and den.reservedKeys stay listed and unchanged. isChildKey drops its now-redundant hasPrefix term.
deferHandler's stub and deferConditional's stub read like carry-forward whitelists and are not: the real aspect is queued intact and resolves in full at the drain, while the stub only registers a deferred identity. Verified before writing — the three resolve-complete handlers in the tree (identity.collectPathsHandler, trace.nix's two) read name, meta, __entityKind and __ctxId, none reads includes; resolvedNodes' only consumer (has-aspect.nix's augment) reads name and meta.aspect-chain.
`fx.aspect` re-exported the key predicate with no reader in or out of the module. The dead export predates the rule refactor — `structuralKeysSet` was re-exported here and equally unread — so it was renamed rather than introduced. Leaving it tells the next reader the seam is load-bearing when nothing crosses it.
…l drain bind rules an aspect inert when an entity arg is neither in-ctx nor a descendant. That silence is correct in the main pipeline — the aspect is delivered at another scope — but the post-assembly drain is terminal, so there is no later scope and the content is gone with no trace in any of the five scoped-effect maps the drain guard scans. Record the verdict where it is made (bind) and read it where terminality is known (the drain's residueKinds), rather than inferring a loss from an absent scopedClassImports, which is indistinguishable from an aspect that legitimately delivers nothing. Only the misplaced-entity-arg verdict is recorded: zero-children has no target to deliver to, and the shared-with-descendant verdict is double-cover avoidance, where the descendant does receive the content.
…excludes `providerType`'s check names a list of policy records as a valid element, so `excludes = [ [ policy ] ]` type-checked and then excluded nothing: with no list arm in `excludeIdentity`, `identity.key` reduced the list to "<anon>" and matched no policy. `includes` flattens the same value and delivers, so the two disagreed over a shape their shared type calls valid. This is the silent no-op 3c5b522 closed for bare strings, still open over the shape that commit's own type admits. Its message claimed routing `excludes` through `providerType` made "both error alike"; they did not. Also record why bind's shared-with-descendant verdict is not reported to the terminal drain. Double-cover avoidance is not a vanished delivery, so recording it would throw on correct behaviour, and no cell can catch that mistake: the drain walk starts a fresh pipeline where scopeKind is null, which makes recording all three inert sites observationally identical to recording one.
…ites mkUnderscore's shadow comment held only at the declared-submodule site. The two raw sites — providerType.merge's battery attrset and aspectContentType's nested key — have no submodule and no option defaults to win the providesChildren fold, so a provides child named name/description/meta/includes landed in the aspect's own option position and was read structurally from there. provides.name at a raw site became the aspect's own name and died coercing a set to a string. Reserve those names from the forward only; .provides/._ still reach every child, so _ stays a total alias for provides.
…e claims ci.bash sent nix-eval-jobs' stderr to /dev/null, so a run the evaluator could not finish produced EXIT 1, no summary, zero failures tallied and nothing saying why. Route it to a file, read PIPESTATUS rather than letting set -e abort the summary, and print it. The rest are comments and docs that a commit made false: the residue guard's 'any of the scoped-effect maps' (it is six of fourteen, and the three exclusions are derived, not measured); the two deferral stubs' 'name/meta and nothing else' (also __entityKind and __ctxId); the record-inert handler rule, recorded at the fx.send site where the next author will meet it; meta.provider in the public reference, renamed to meta.aspect-chain and silently absorbed by meta's freeform type if written; and five citations to deleted identifiers and retired suites, one of which claimed coverage from a suite that no longer exists.
…lution An exclude naming a policy record den never found resolved to null, was filtered out, and suppressed nothing with no diagnostic. The check is global, not per-scope: resolveRawRefIdentity returning null for one scope is correct behaviour — a host-scope exclude reaches every descendant scope and the policy it names is typically claimed in only some of them — so warning from isPolicyExcluded would fire on every legitimate multi-scope exclude. It reads the terminal state at fxResolveFull's post-assembly position instead, where both the constraint registry and policyClaimsByName are complete.
sini
marked this pull request as ready for review
September 14, 2026 20:40
`den.hosts.<system>.<name>.includes` was accepted and dropped in silence. resolveEntity built the entity root aspect's collections from exactly two sources — the entity's self-provide and the schema tier — and nothing read them off the instance, while the instance type is built with `strict = false`, so its freeform type absorbed the key instead of raising "option does not exist". The host built with an empty aspect tree, and the only signal was a warning about a different fact, emitted only when no same-named aspect existed either (#663). `includes` is the activation key at the aspect, schema and default tiers, which is what makes the instance spelling the natural guess, so it is honoured rather than rejected. Read in resolveEntity rather than per entity kind, so every kind declaring `isEntity` gains it at once, and read last in the include order: an instance is the most specific site an entity's content can be written at, so its definitions merge over what its kind's schema supplies.
`den.schema.<kind>.excludes` rejected a list-wrapped policy reference while `den.aspects.*.excludes` had just been fixed to honour one (6127cbc), so one user-written shape excluded at the aspect tier and threw at the schema tier. `providerType` names a list of policy records as a valid element and both tiers take the same references, so the divergence had no basis. The `includes` collection already recursed into nested lists and admitted a function; `excludes` did neither, and the two checks were separate copies diverging by inspection. One check parameterised by collection name now serves both, which is what keeps them from drifting again rather than re-stating the recursion twice. A nested bad leaf still errors with the `den:` message: the list arm admits the shape without dropping the check.
Two of the three sit in the aspect reference's own structural-key table, in the file this branch already edited: - `excludes` reads `listOf unspecified`. It is `listOf provider` since the type was routed through `providerType`, which is what makes a bare string an error rather than a silent no-op. - the `meta` row still lists `provider`. The same file's caution block 60 lines down documents the rename to `aspect-chain` and says a stale `meta.provider` is absorbed silently, so the table contradicted the prose beside it. The third is `.claude/skills/den-debugging.md`, the last `__provider` reference in the repo and the skill CLAUDE.md points debugging work at — an agent following it greps for a marker that no longer exists. The file is tracked but its directory is now ignored, so it needs an explicit add. `reference/schema.mdx`'s `listOf raw` for the schema tier is left alone: that collection really is raw-typed, with the element check in its merge.
sini
added a commit
that referenced
this pull request
Sep 15, 2026
…fied aspects (#680) #672 ## Summary Resolution: - Resolves gen-schema through the gen hub instead of pinning gen-schema directly, as gen-schema's root declares `{ prelude, merge, algebra, identity }` with no `...` while den's fallback passed `{ lib }`, which is a hard error at the eleven templates that do not declare the input. - Gains closure coherence from that routing, because pinning gen-schema directly left its transitive closure to den and resolved three revisions of gen-prelude in one lock. Identity: - Declares the home kind's identity keys at the kind, since gen-schema closes the identity-key set the moment the kind is a value and an option contributed through `mkInstanceType`'s `extraModules` arrives after that. - Hides those keys with `visible = false` rather than `internal = true`, as `isPrimitiveOption` reads `internal` and `identity` and not `visible`, so marking them internal would un-declare the very keys `_identity.keys` names. - Records in the source that the `visible` route rests on an implementation fact rather than a stated contract, so a later folding of `visible` into the same presentation exclusion would drop these keys from identity in silence. Module arguments: - Supplies nixpkgs `lib` to schema modules on `den.schema.conf`, which every kind imports, because gen's module system ships no nixpkgs lib and den documents `den.schema.host = { host, lib, ... }:` at five sites. Aspects: - Resolves `den.aspects."<user>@<host>"` for a user declared under a host and for a standalone home keyed `user@host`, as the qualified spelling was accepted by the aspect option and consulted by nothing. - Composes the qualified and bare aspects rather than preferring either, because `modules/aspects/definition.nix` registers a stub aspect per entity so `den.aspects ? <name>` is true for every declared entity, and a stub is structurally indistinguishable from a written aspect. - Keys a home's `name` to its registry key rather than the bare user name, so the field that identifies a home is the one that tells two homes for one user apart, and `userName` carries the user it configures. Diagnostics: - Reaches gen-merge `08fcdd1` through gen `0b6fbd8`, so a `mk*` wrapper in a schema module's `options` position refuses by name rather than failing frames away as a `contents` option of the wrong type. - Names the `structuralKeysSet` removal at the point of use, as closing the structural-key registry by rule dropped that export and a consumer reading it got a bare `attribute 'structuralKeysSet' missing`. It cannot be aliased, because `isStructuralKey` derives the `__`-prefixed half by rule over an infinite domain and no attrset can answer `?` for that. ## Behaviour changes Content that was previously inert becomes live, so a rebuild can emit modules it did not emit before: - `den.aspects."<user>@<host>"` is resolved where it was accepted and ignored. - An entity with both a qualified and a bare aspect applies both. A field changes meaning, which can change an existing configuration: - `home.name` read from a policy or class module is the registry key such as `tux@igloo`, not the bare user name. Read `home.userName` for the user. - `den.batteries.import-tree`'s home variant therefore imports `<root>/<user>@<host>` rather than `<root>/<user>`. It keeps reading `home.name` deliberately, as its host and user variants both key on the entity's own `.name`. No test covers this path. Input that was previously accepted is now refused: - A schema module declaring `options` through `mkMerge` or another `mk*` wrapper refuses by name, where it previously declared options called `_type` and `contents` and failed on a later read. - `_identity.keys` naming a key the kind does not declare refuses, where it previously succeeded and minted over whatever the reflection reached. - `keyClassification.structuralKeysSet` throws by name with its migration, where it previously read as a missing attribute. Replace `structuralKeysSet ? k` with `isStructuralKey k`. ## Validation - `nix develop -c just ci`: 1212/1212, exit 0, zero failures and zero errors, read off stderr with the collected count agreeing with the numerator. - Falsified every new cell against the unfixed tree with the tests held in place, so the red arm measures the fix rather than the cells' absence. - Ran `nix flake check` per template rather than reading `just all check`'s exit code, which aborts at `ci` on a `flake.packages` double declaration that reproduces on `main`. Nine templates pass, and `diagram-demo`, `fleet-demo` and `terranix-demo` fail for reasons that also reproduce on `main`. - Confirmed the identity change by reading `id-hash.nix` rather than only the suite, as explicit `_identity.keys` still drive the hash and membership is validated rather than substituted, so the same-name and cross-system distinctness cells are not passing for the wrong reason. - Measured the `lib` regression across three pins, since it passes before the port, fails on the port and fails after the bump, which places it in the port rather than the bump. - Drove discussion #672's shape through den rather than relaying the upstream report, and the refusal is catchable where its predecessor was an abort that escaped `tryEval`. - Re-derived the hub sha rather than taking it from a report, as an earlier reading was already stale by the time it was written. - Evaluated a real multi-machine configuration against this branch and against `main`, and all seven NixOS machines produce byte-identical derivations while the darwin machine evaluates identically. That sweep is what surfaced the `structuralKeysSet` removal, as the configuration consumes it. - Rebased onto `main` after #678 merged, with the rebased tree diffing empty against the pre-rebase commit, so the replay changed no content. ## Known limitation, not addressed here `lookupAspect`'s missing-aspect warning is dead code in the normal path, because the per-entity stub above makes `den.aspects ? <entity>` always true. Issue #663 cites that warning as the only signal a user gets. Making it fire needs a design decision rather than a predicate change, as an entity legitimately may have no own aspect when it is configured through `den.default` or schema includes.
Collaborator
|
I'm a bit unclear if #678 is meant to be fixed by this, but if it is, I found some behavior that seemed unintuitive. A minimal example: # file-1.nix
{
den.hosts.igloo.includes = [ <some-aspect> ];
}
# file-2.nix
{
den.hosts.igloo.includes = [ <some-other-aspect> ];
}The list of includes doesn't seem to merge, nor does it warn that there are conflicting definitions. Just silent last-entry-wins, I suppose? |
sini
added a commit
that referenced
this pull request
Sep 16, 2026
…dropping one (#681) #678 (comment) ## Summary Merge: - Merges an entity's list-valued keys instead of overwriting them, as `den.hosts`' freeform type merged with `lib.recursiveUpdate`, which treats a list as an opaque leaf, so two files each writing `den.hosts.<system>.<name>.includes` kept one list and dropped the other with no conflict warning. - Concatenates rather than picking a winner, because that is the module system's own rule for a list-valued option (`listOf` merges by `concatLists`) and den's rule at the aspect tier (`aspectContentType`'s `deepMerge`), so the entity registry now agrees with both instead of adding a third behaviour. - Applies to every list-valued key an entity carries, since `includes`, `excludes` and `classes` accumulate everywhere else they appear. - Concatenates in declaration order, as defs reach this merge in reverse declaration order, which is measured rather than assumed and is the same ordering that makes the scalar arm read as first-declaration-wins. Conflicts: - Refuses two definitions of a key that is neither a mergeable attribute set nor a list, as they previously took the first and dropped the other, and a type mismatch such as a list against a string resolved the same silent way. - Refuses when either side is a plain scalar and the values differ, which covers both arms. Requiring both sides to be scalars leaves the mismatch silent, which is what an earlier form of the predicate did. - Excludes functions deliberately, since `==` on two functions is always false and comparing them would reject two identical definitions of a class module or of `instantiate`. - Names a value in the message only where rendering it is safe, because `builtins.toJSON` throws on a derivation or a function and either can be one side of a conflict. Why it went unnoticed: - An attrset key under the same two definitions merged normally, so the collection read as having no effect rather than as a failed merge. A `users.alice` and `users.bob` pair across two files both survive, which is what localised the defect to list leaves rather than to the collection keys or the registry's recursion. - Instance-level collections were read by nothing until recently, so there was no way to observe which list survived. - Both arms are PRE-EXISTING rather than regressions, measured against a tree predating the instance collections being read at all, where the scalar conflict and the type mismatch resolve identically. Making the collections meaningful changed observability, not behaviour, so a list key on an entity has been losing definitions since the gen-schema entity port. ## gen hub Bumps `templates/ci/flake.lock`'s `gen` pin from `0b6fbd8d` to `0004f3c9` over the two `chore:` commits, which moves gen-schema `f8e0e171` to `48cfb992` and leaves gen-merge held at `08fcdd1` on the flake path, so nothing above is affected. - Fixes a separate report, a `den.schema.user` option declared without `default = { }` failing with `gen-merge: the option ... is used but not defined`. The first of the two bumps deliberately did NOT fix it, and said so, because the cause was never the hub rev. - The cause is entry-path divergence. `nix/lib/schema.nix` dispatches on `inputs ? gen`: only `templates/ci` declares that input, so den's own suite takes the FLAKE path while every other consumer takes the `builtins.fetchTarball` fallback. The fallback enters the hub standalone, where no `follows` exist and each member resolves its deps from its own lock, so one hub rev yielded two different closures — gen-merge `08fcdd1` (guarded) on the flake path and `f7e3afb3` (pre-guard) standalone. - gen-schema `48cfb992` carries `2a33f81` in both of its own locks, which is what makes the two paths agree rather than the hub pin moving. - Also drops the `provider` test fixture's `gen-schema` input, which was referenced nowhere and pinned `4bd0f6eb`, a rev predating gen-merge entirely. It put a second gen-schema node in the CI lock, so one lock carried two revisions of one library — the incoherence the hub indirection exists to prevent, in the tree that documents it. ## Behaviour changes - A list-valued key on an entity now accumulates across definitions where one definition previously overwrote the other. A configuration that wrote the same key in two files and relied on one winning will start seeing both. - Two definitions of a non-mergeable key now refuse instead of silently resolving to the first. A configuration that wrote a key twice with different values, or with mismatched types, will start failing where it previously picked one. Definitions that agree are unaffected. - A consumer that declares no `gen` input now resolves gen-merge `2a33f81` where it previously resolved `f7e3afb3`. That is the fix for the report above, and it is the only closure change on the fallback path. ## Validation - `nix develop -c just ci`: 1221/1221, exit 0, zero failures and zero errors, read off stderr with the collected count agreeing with the numerator. - Falsified the three defect cells against the unfixed merge with the tests held in place, so the red arm measures the fix rather than the cells' absence. Both control cells stay green in that arm, which is what makes them controls rather than padding. - Pinned declaration order in its own cell, as concatenating in either direction makes both entries present and so passes the other cells. - Reproduced the report before changing anything, and measured the surviving entry rather than inferring it: the first definition won, not the last. - Measured both arms against a pre-existing tree rather than reasoning about blame, which is what established these as latent defects rather than regressions. - Verified the hub bump against the reporting user's real configuration rather than a reduction, with a live control: `home-manager.users.<u>.programs.helix.ignores` yields its list at exit 0 on this branch, and the same attribute at the previous pin, same instrument, exits 1 with `gen-merge: the option ... is used but not defined`. - `nix flake check` on `minimal`, `default` and `noflake`, none of which declares a `gen` input, so all three exercise the fetched fallback that consumers take rather than the flake path the suite measures.
sini
added a commit
that referenced
this pull request
Sep 19, 2026
Closes #683. ## Summary - Keeps `__providesForwarded` intact when an already-merged aspect is merged a second time, so a `provides` child whose name matches a registered class stays a child instead of being reclassified as the aspect's own class content and emitted into that class. In the reporting configuration a `provides.packages` child reached through an `<angle/bracket>` include arrived as `flake.packages.<system>` carrying fourteen of the child aspect's own fields — `name`, `includes`, `meta`, `provides`, `_`, `__functor`, `homeManager`, `darwin` among them — which a derivation-typed package schema then fails on. - Routes the shadow test through `mkUnderscore`, which already holds both the aspect and the candidate set, rather than leaving a copy at each of the three construction sites. All three derived it from `!(own ? k)`, which cannot tell a name the author wrote at top level from a name an earlier merge forwarded there; the earlier merge published exactly that distinction, so the predicate reads the marker instead of guessing from key presence. - Fixes all three sites, not the reported one. #683 bisects to #678, which is correct for the path it hits (`mergeFunctions`, site B) but not for the defect: `d50f0fc` already carried the identical test at `mergeWithAspectMeta` and `aspectContentType` (lines 132 and 579), so aliasing a merged aspect to a root slot or to a nested freeform key lost the marker before #678. #678 extended the flaw to the include path. - Leaves `packages` registered as a class. The leak is not name-specific — `provides.nixos` reproduces it on stock den with no flake outputs imported — so un-reserving `packages` would address one spelling and leave `nixos`, `darwin`, `homeManager`, `apps`, `checks`, `devShells`, `legacyPackages`, `os`, `user`, `hjem`, `maid` and `wsl` unchanged, while breaking `packages-merge.nix`, the #572 regression asserting `den.aspects.<name>.packages` reaches `flake.packages.<system>`. - Adds two cells: the marker and its classification at the two re-merge sites readable by marker, with the once-merged source as a live control in the same run; and the reporter's shape end to end, since the symptom is the child's own fields arriving as flake output content rather than a marker value. ## Behaviour changes - A provides child sharing a name with a registered class is no longer emitted as that class's content when its aspect is re-merged. A configuration that was receiving the child aspect's fields in a flake output, or its `nixos`/`darwin`/`homeManager` content delivered twice, stops receiving them. That content was never the class content the key named. - A provides child with an ordinary name is no longer reclassified as a nested key on re-merge. Nested keys are not auto-walked, so this was silent. - A name the author genuinely writes at top level alongside a same-named provides child keeps its direct value and stays classified, unchanged. That case is what the shadow test exists for and the predicate still answers it. ## Validation - `nix develop -c just ci`: 1238/1238, exit 0, zero `❌` and zero `☢️`, counted off a capture with stderr merged. The summary numerator agrees with the counted passes, so the `pass + fail` identity is not standing in for a truncated run. - Ran the same suite on the tree with only `types.nix` reverted: 1238 collected, 1236 passing, exit 1, and the two failures are exactly the two new cells. Same population both runs, so nothing else moved in either direction. 1236 is also the count #682 landed at, which is the independent check that the population is right. - Falsified both new cells against the unfixed tree on their actual symptom rather than on a mismatch: `aMarker`/`cMarker` read `[ ]` against `[ "nixos" ]` and `aClassified`/`cClassified` read `[ "nixos" ]` against `[ ]`, while the once-merged control in the same cell stays green — so the cell measures the re-merge rather than a marker that vanished everywhere. - Reproduced #683 as filed before touching anything, against the local checkout rather than the pinned revision: `originalForwarded = [ "packages" ]`, `remergedForwarded = [ ]`, `remergedClasses.classKeys = [ "packages" ]`, and thirteen names in `flake.packages.x86_64-linux`. - Measured the name-independence claim rather than reasoning to it: `provides.nixos` loses the marker and gains `classKeys = [ "nixos" ]` on re-merge with no flake output module imported at all, and a `provides.plainchild` child is reclassified as a nested key in the same run. - Measured the three key positions separately, because they do not share a verdict: a root aspect named `apps` classifies its own content normally (`classKeys = [ "nixos" ]`), a nested key named `apps` is read as class content (`classKeys = [ "apps" ]`) and is correctly reserved, and a `provides` child named `apps` is exempt by marker (`classKeys = [ ]`). Only the third is this bug. - `nix develop -c just fmt`: 577 files processed, 0 changed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#670
Summary
Identity:
providerType.merge, so two owners writing their own inline aspect of one name stay distinct while a sharedlet-bound value included twice keeps one identity.__walkStampedthrough the parametric-resolve round-trip, so a walk-stamped child does not have its position encoded a second time.Policy:
mkPolicy "tools"records in different aspects both fire while a sharedden.policies.fooincluded from two aspects fires once.excludesby raw claim value rather than by bare name, as a displaced claimant was otherwise unaddressable and an exclude suppressed a different policy than the one named.Alias:
_-to-providesfold through one shared helper instead of constructing it separately per site, asmergeFunctions' battery branch was dropping a writtenfn._on the floor rather than folding it.mkAliasOptionModuleout of that helper deliberately and records why, because the helper is a//overwrite and wiring it into root would replace root's conflict detection with spelling-priority.Provenance:
providerPrefixintooriginfor the container seed andchainfor the threaded definition path, because one field carried two facts that coincide at a container root and so conflated without any test showing it.Batteries:
insecureandunfreebatteries keep their identities on a stock configuration.Structural keys:
__-prefixed half of the structural-key registry by rule instead of listing twelve markers by hand, so a new marker is structural the moment it exists rather than when someone remembers to register it.normalizeRoot's functor whitelist with the same structural carry-forwardmkParametricBaseuses, as that branch was dropping a functor-shaped root'sexcludesoutright.aspectKeyType.mergeshare one predicate, because they previously disagreed about an unlisted__key, one treating it as a nested key and the other wrapping it as content.Delivery:
bind's misplaced-entity-arg verdict as pipeline state so the post-assembly drain's residue guard covers it, since that verdict is silent and correct everywhere except a terminal position where no later scope can deliver.Entity instances:
includesandexcludeswritten on an entity instance (den.hosts.<system>.<name>.includes), which were accepted and dropped in silence (den.hosts.<system>.<name>.includesis accepted and silently dropped #663).resolveEntitybuilt the root aspect's collections from the self-provide and the schema tier only, while the instance type is built withstrict = false, so its freeform type absorbed the key instead of raising "option does not exist" — the host built with an empty aspect tree and the only signal was a warning about a different fact. Read inresolveEntityrather than per entity kind, so every kind declaringisEntitygains it at once, and read last in the include order, an instance being the most specific site content can be written at.Excludes:
excludesso a list-wrapped policy reference excludes, becauseproviderTypenames a list of policy records as valid while the reader had no list arm and reduced it to<anon>.den.schema.<kind>.excludesrejected the shape the aspect tier had just been fixed to honour, andproviderTypenames a list of policy records as valid, so the divergence had no basis. Theincludescheck already recursed into nested lists and admitted a function whileexcludesdid neither — two copies diverging by inspection, now one check parameterised by collection name.Provides:
Performance:
Tooling:
ci.bashand reports a dead evaluator separately from a test failure, becausetotalis computed aspass + failover whatever reached the JSON stream, so a run that stopped early read as a cleanN/Nwith the diagnostic discarded.metaType's freeform now absorbs silently and a live test citing a coverage suite that no longer exists.excludesaslistOf unspecifiedand still listedmeta.provider, contradicting the caution block sixty lines below it that documents the rename; and.claude/skills/den-debugging.mdheld the last__providerreference in the repo, in the skill CLAUDE.md points debugging work at.Behaviour changes
Configurations that were silently losing content now deliver it, so a rebuild can emit modules it did not emit before:
mkPolicyrecords sharing a bare name in different aspects both fire, where one previously displaced the other.excludesand other structural siblings, whichnormalizeRootwas dropping outright.includesacross the resolve round-trip.._at all three construction sites rather than two of them landing it in the aspect's own option position.Input that was previously accepted and ignored is now rejected or honoured, which can change an existing configuration:
includesandexcludeson an entity instance are honoured. A configuration that wrote them and silently got nothing will start delivering that content, which is the defectden.hosts.<system>.<name>.includesis accepted and silently dropped #663 reports; a configuration that wrote them redundantly beside a same-named aspect now applies them twice over, deduplicated at the gate.excludes = [ "some-name" ]is a type error. It previously reduced to<anon>, matched nothing, and excluded nothing in silence.excludes = [ [ policy ] ]now excludes. The same value was admitted by the type and then discarded, so a configuration that relied on the no-op will start suppressing the policy it names.nameoutranks its nested position when the two disagree.__-prefixed key is treated as a pipeline internal by rule rather than by appearing on a list of twelve. A__-prefixed key an aspect defines is no longer dispatched as class or nested content.New diagnostics, where the previous behaviour was silence:
den:warning. It does not change what is excluded. A fleet-level exclude warns once per host that does not include the policy, since a resolution is one entity.ci.bashreports a dead evaluator as💥 EVALUATOR FAILEDwith the evaluator's stderr, rather than discarding it and printing a tally over whatever the run reached.Renamed:
meta.provideris nowmeta.aspect-chain, and an absent chain is distinguished from a root one (nullagainst[ ]).metaTypeis freeform, so a stalemeta.provideris absorbed without error rather than rejected.Validation
nix develop -c just ci: 1201/1201 atcb5439b, exit 0, zero failures and zero errors, summary line present and the collected count agreeing with the numerator. (1194/1194 atce38772, before the four cells theden.hosts.<system>.<name>.includesis accepted and silently dropped #663 fix added and the three the schema-tier check added.)nix develop -c just ci performance: 31/31, exit 0, including theresolve.test-chain-100canary and the entity and fleet cells this branch added.ci.bashcomputestotalaspass + fail, which makesN/Nan identity that holds on a truncated run.ci.bashchange by forcing a real parse error: the evaluator's message with file, line and column now reaches stderr, where the identical run previously produced zero bytes and no summary.originagainst gen's own source rather than by name: seeding it makes a nested chain read additively through the subtree, matching gen'sorigin ++ path.excludeslist-element drop and the provides-forward site disagreement.den.hosts.<system>.<name>.includesis accepted and silently dropped #663 before fixing it: both instance-level cells red and both controls green on the unfixed tree, since the failure mode is "produces a plausible value" rather than "throws". Falsified the schema-tier cell the same way — it errors on the unfixed tree and is the only one of the six that flips.nix flake checkper template rather than readingjust all check's exit code, which aborts atcion aflake.packagesdouble declaration that reproduces unchanged onorigin/main. Nine templates pass;diagram-demo,fleet-demoandterranix-demofail for reasons that also reproduce onorigin/main, anddiagram-demo's is the one this branch caused — see below.Known consequence outside this repo
The
meta.provider→meta.aspect-chainrename leftden-diagramreading a field den no longer emits.graph.nixreadentry.providerwith no fallback, sodiagram-demoaborted withattribute 'provider' missing; three further sites read it through anor [ ]fallback and kept rendering with a silently empty chain, flattening the fleet and namespace views' provenance. Nothing in den's gates can catch this — den's CI has no den-diagram dependency by design, andjust all checkcovers neither diagram template.Fixed in denful/den-diagram#2 (merged,
3ba2e47), which reads both spellings from one helper so a single den-diagram works against either side of the rename. The lock bump fordiagram-demoandfleet-demois NOT in this PR. Both templates still failnix flake checkafterwards, for the unrelated pre-existing reasons noted above.