Skip to content

fix: parametric functions at direct freeform children leak through providerType.merge - #505

Merged
sini merged 3 commits into
denful:mainfrom
sini:fix/parametric-freeform-content-wrapper-leak
May 10, 2026
Merged

sini merged 3 commits into
denful:mainfrom
sini:fix/parametric-freeform-content-wrapper-leak

Conversation

@sini

@sini sini commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes parametric functions ({ host, user }: { ... }) placed as direct freeform children of namespace aspects (e.g. ns.apps.helix instead of ns.apps.provides.helix) being silently dropped during pipeline resolution
  • The __contentValues wrapper from aspectContentType was promoted to a full aspect by listOf (providerType ...) element-level merge, burying the parametric function as a freeform key unreachable by bind/compile-parametric
  • Normalizes __contentValues wrappers in providerType.merge before dispatch: extracts single parametric functions (non-empty args, no config/options) so existing merge dispatch creates proper __fn/__args wrappers

Test plan

  • test-namespace-parametric-direct-child — nixos class via direct freeform child + angle brackets
  • test-namespace-parametric-hm-via-user-aspect — homeManager class via intermediate aspect at user scope (matches real dotfiles pattern)
  • test-namespace-parametric-provides-child — provides fallback path (was already working, verifies no regression)
  • Full CI suite: 770/770 passing
  • Verified against real config: nixosConfigurations.evo-x2.config.home-manager.users.loom.programs.helix.enable → true

@sini
sini requested a review from vic May 10, 2026 20:54
@sini

sini commented May 10, 2026

Copy link
Copy Markdown
Collaborator Author

Is github broken? My earlier merged PR #501 isn't on main, but the PR is squash merged.

@drupol

drupol commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Is github broken? My earlier merged PR #501 isn't on main, but the PR is squash merged.

It is not yet merged: #503

@sini

sini commented May 10, 2026

Copy link
Copy Markdown
Collaborator Author

Is github broken? My earlier merged PR #501 isn't on main, but the PR is squash merged.

It is not yet merged: #503

oh im being silly thanks :D

sini added 2 commits May 10, 2026 14:10
…ametric freeform children

When a parametric function (e.g. { host, user }: { homeManager = ... })
is placed as a direct freeform child of an aspect (ns.apps.helix instead
of ns.apps.provides.helix), aspectContentType wraps it in a
__contentValues wrapper. When this wrapper is used as an include element,
listOf (providerType ...) calls providerType.merge on each element,
promoting the wrapper to a full aspect with the parametric function
buried as a freeform key — unreachable by the pipeline's bind handler.

The fix normalizes __contentValues wrappers at the start of
providerType.merge: detect wrappers containing a single parametric
function (non-empty args, no config/options) and extract the raw
function so existing merge dispatch creates a proper __fn/__args wrapper.

Tests added:
- test-namespace-parametric-direct-child: nixos class via direct child
- test-namespace-parametric-hm-via-user-aspect: homeManager class via
  intermediate aspect (matches real config pattern)
- test-namespace-parametric-provides-child: provides fallback (existing)
Add __contentValues and __provider to structuralKeysSet so they are
never classified as class content when a content wrapper is promoted
to a full aspect via providerType.merge.  Without this, including a
non-parametric direct freeform child (e.g. an overlay at
ns.overlays.openrazer instead of ns.overlays.provides.openrazer)
emits the nixos content twice — once from the forwarded attr and once
from the __contentValues freeform key.

Add test for the duplication scenario plus tests for parametric direct
children via angle-brackets (nixos, homeManager-via-user-aspect, and
provides-path comparison).
@sini
sini force-pushed the fix/parametric-freeform-content-wrapper-leak branch from 0a0d906 to ea3109a Compare May 10, 2026 21:10
vic
vic previously approved these changes May 10, 2026

@vic vic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Three related fixes for direct freeform children (no provides):

1. providerType.merge: inject name and meta.provider from __provider
   on content wrappers so aspectSubmodule.merge produces meaningful
   identities instead of anonymous include indices.

2. aspectSubmodule: thread providerPrefix through freeform type (same
   as provides submodule) so __provider includes the parent aspect
   name — e.g. ["gloom","overlays","openrazer"] not ["gloom","openrazer"].

3. wrapChild: handle inner content wrappers that listOf passes through
   without calling providerType.merge. Injects identity from __provider
   and extracts parametric functions into includes. Without this, an
   aspect included from two paths (e.g. polybar→razermon→overlay and
   direct razermon→overlay) emits class content twice with different
   anonymous identities, bypassing dedup.
@sini
sini requested a review from vic May 10, 2026 22:34

@vic vic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sini
sini merged commit 852bc41 into denful:main May 10, 2026
40 of 44 checks passed
charlesfire pushed a commit to charlesfire/den that referenced this pull request May 16, 2026
…oviderType.merge (denful#505)

## Summary

- Fixes parametric functions (`{ host, user }: { ... }`) placed as
direct freeform children of namespace aspects (e.g. `ns.apps.helix`
instead of `ns.apps.provides.helix`) being silently dropped during
pipeline resolution
- The `__contentValues` wrapper from `aspectContentType` was promoted to
a full aspect by `listOf (providerType ...)` element-level merge,
burying the parametric function as a freeform key unreachable by
bind/compile-parametric
- Normalizes `__contentValues` wrappers in `providerType.merge` before
dispatch: extracts single parametric functions (non-empty args, no
`config`/`options`) so existing merge dispatch creates proper
`__fn/__args` wrappers

## Test plan

- [x] `test-namespace-parametric-direct-child` — nixos class via direct
freeform child + angle brackets
- [x] `test-namespace-parametric-hm-via-user-aspect` — homeManager class
via intermediate aspect at user scope (matches real dotfiles pattern)
- [x] `test-namespace-parametric-provides-child` — provides fallback
path (was already working, verifies no regression)
- [x] Full CI suite: 770/770 passing
- [x] Verified against real config:
`nixosConfigurations.evo-x2.config.home-manager.users.loom.programs.helix.enable`
→ `true`
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.

3 participants