fix: provider sub-aspect functions receive parametric context#419
Merged
fix: provider sub-aspect functions receive parametric context#419
Conversation
When a parametric aspect includes a provider sub-aspect that is also
a bare function (e.g. den.aspects.foo._.sub = { host, ... }: { ... }),
the sub-aspect's function was never called with the parametric context.
Root cause: providerFnType.merge wraps bare functions as
{ __functor = _: fn; }, placing them in the aspect's __functor rather
than includes. When the parent aspect's function returns
{ includes = [foo._.sub]; }, the sub-aspect appears as a leaf in
deepRecurse's mapIncludes and reaches resolve uncalled.
Fix: applyDeep in parametric.applyIncludes resolves sub-includes of
successful takeFn results one level deep. When take.atLeast calls
a provider function that returns { includes = [sub-aspect]; }, the
nested sub-aspect also receives parametric context before entering
the static pipeline.
Guards prevent double-resolution: results carrying meta (from
withIdentity/withOwn) or __functor (deferred deepRecurse wrappers)
are returned as-is since their includes are already processed.
Fixes vic#413
c66d7c8 to
0851ca1
Compare
vic
approved these changes
Apr 9, 2026
Owner
|
Thanks @kalyanoliveira and @sini |
sini
added a commit
to sini/den
that referenced
this pull request
Apr 10, 2026
PR vic#419 introduced applyDeep to propagate parametric context into bare-result sub-includes. But it called takeFn unconditionally on every sub, including full static aspects whose default functor (withOwn parametric.atLeast) discards owned class configs in a non-static branch. Result: `den.aspects.role._.sub.nixos.x = true` was silently dropped when role was a parametric parent that included its sub-aspect. Gate the inner re-application on canTake.upTo: a static aspect's default functor has empty functionArgs, so upTo is false and the sub is left alone for the static resolve pass. User-provided provider fns (e.g. `{ host, ... }: { nixos = ...; }`) have host in functionArgs, so upTo fires and their config is materialized. This preserves the vic#419 fix while restoring pre-vic#419 behavior for static sub-aspects. Fixes vic#423.
sini
added a commit
to sini/den
that referenced
this pull request
Apr 10, 2026
PR vic#419 introduced applyDeep to propagate parametric context into bare-result sub-includes. But it called takeFn unconditionally on every sub, including full static aspects whose default functor (withOwn parametric.atLeast) discards owned class configs in a non-static branch. Result: `den.aspects.role._.sub.nixos.x = true` was silently dropped when role was a parametric parent that included its sub-aspect. Gate the inner re-application on canTake.upTo: a static aspect's default functor has empty functionArgs, so upTo is false and the sub is left alone for the static resolve pass. User-provided provider fns (e.g. `{ host, ... }: { nixos = ...; }`) have host in functionArgs, so upTo fires and their config is materialized. This preserves the Fixes vic#423.
sini
added a commit
that referenced
this pull request
Apr 10, 2026
) PR #419 introduced applyDeep to propagate parametric context into bare-result sub-includes. But it called takeFn unconditionally on every sub, including full static aspects whose default functor (withOwn parametric.atLeast) discards owned class configs in a non-static branch. Result: `den.aspects.role._.sub.nixos.x = true` was silently dropped when role was a parametric parent that included its sub-aspect. Gate the inner re-application on canTake.upTo: a static aspect's default functor has empty functionArgs, so upTo is false and the sub is left alone for the static resolve pass. User-provided provider fns (e.g. `{ host, ... }: { nixos = ...; }`) have host in functionArgs, so upTo fires and their config is materialized. This preserves the #419 fix while restoring pre-#419 behavior for static sub-aspects. Fixes #423.
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.
Fixes #413
Problem
Provider sub-aspects defined as bare context functions don't receive
{ host }during resolution:When a parent function returns
{ includes = [foo._.sub] }, the sub-aspect is resolved by the adapter system which only passes{ class, aspect-chain }— the{ host }context from the pipeline never reaches nested includes of function results.Fix
applyDeepinparametric.applyIncludes— whentakeFnsucceeds and returns a bare result with sub-includes (nometa, no__functor), also applytakeFnto those sub-includes. This propagates context to provider sub-aspects nested inside function results without double-applying to parametric wrappers ordeepRecurseoutputs.The key discriminator: bare provider results carry only
includes(+namefromcarryAttrs). Results fromwithOwn/withIdentityhavemeta; deferreddeepRecursewrappers have__functor. Neither should be re-resolved.Test coverage
deadbugs/issue-413-provider-bare-function.nix— reproduces the original reportdeadbugs/issue-413-provider-sub-aspect-function.nix— variant withlib.optionalAttrsguardprovides-parametric.nix— provider sub-aspects with parametric context in various configurationscc: @kalyanoliveira for the report