Skip to content

fix: nested aspect key merge and includes scoping - #521

Merged
sini merged 2 commits into
denful:mainfrom
sini:fix/nested-aspect-merge
May 12, 2026
Merged

sini merged 2 commits into
denful:mainfrom
sini:fix/nested-aspect-merge

Conversation

@sini

@sini sini commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Multi-definition merge: When multiple modules define the same nested aspect key, class sub-keys are now properly collected instead of last-win overwrite. emitNestedAspect reconstructs per-sub-key __contentValues so all definitions contribute.
  • Includes scoping: Explicitly including a nested aspect via den.aspects.X.Y no longer auto-walks its nested sub-keys. Sub-aspects at deeper levels must be included explicitly. Direct nesting and organizational grouping continue to auto-walk as before.

Test plan

  • Added regression test for multi-definition nested class key merge
  • Added regression tests for includes scoping (auto-include prevented, explicit include works)
  • All 6 existing nested-aspects tests pass
  • Full CI: 776/776 passing

When multiple files define the same nested aspect key (e.g.
den.aspects.system.base.nixos from two modules), the old code
used unwrapContentValuesRaw which produced { imports = vals; }
for multi-value cases. The aspect pipeline doesn't understand
NixOS module imports, so only the last definition survived.

Fix: mergeContentValuesPerKey reconstructs per-sub-key
__contentValues so the pipeline properly collects all class
module definitions.

Includes regression test for the merge bug and a (currently
failing) test for the nested includes auto-walk bug.
@sini
sini requested a review from theutz May 12, 2026 17:48
@sini sini added the allow-ci allow all CI integration tests label May 12, 2026
@sini
sini enabled auto-merge (squash) May 12, 2026 17:52
@sini
sini requested a review from vic May 12, 2026 17:53
…ncluded

Content wrappers from aspectContentType (accessed via den.aspects.X.Y
in an includes list) carry __contentValues at the top level. Their
nested sub-keys are independent sub-aspects that should only be
included when explicitly referenced, not auto-walked.

Sub-aspects from emitNestedAspect and full aspects from aspectSubmodule
do NOT have __contentValues, so their nested keys continue to auto-walk
as before.

776/776 CI tests pass.
@sini
sini force-pushed the fix/nested-aspect-merge branch from 735937f to 2f6ce11 Compare May 12, 2026 18:05
@sini
sini merged commit b7ac993 into denful:main May 12, 2026
14 of 15 checks passed
sini added a commit to sini/den that referenced this pull request May 12, 2026
aspectContentType shallow-merges forwarded attrs with foldl' //.
This is last-win per key, which silently drops list values from
earlier modules — e.g., multiple modules each adding to includes
would only keep the last module's list.  Before denful#521 this was
masked by auto-walking nested keys; after denful#521 content wrappers
don't auto-walk, so the incomplete includes became the only
resolution path and children were silently dropped.

Generalize the fix to all list-valued keys rather than special-
casing includes/excludes by name: any key whose definitions are
all lists gets concatenated in both aspectContentType.merge (for
forwarded access) and mergeContentValuesPerKey (for auto-walk).
sini added a commit that referenced this pull request May 12, 2026
## Summary

- **Content wrapper includes merge**: When multiple modules each add
children to an aspect's `includes` list (e.g., `polybar.includes =
[coreuse]` in one file, `polybar.includes = [wifi]` in another),
`aspectContentType.merge` shallow-merged forwarded attrs with `foldl'
//`, keeping only the last module's list. Now `includes` and `excludes`
are explicitly concatenated across all content value definitions.
- **mergeContentValuesPerKey includes handling**: The per-key
reconstruction in `emitNestedAspect` wrapped `includes` in a `{
__contentValues, __provider }` content wrapper instead of
list-concatenating, causing `expected a list but found a set` crashes on
the auto-walk path. Now list-concatenates these structural keys.

Fixes a regression exposed by #521 — before that change, auto-walking
masked the incomplete includes list by resolving nested keys regardless.
After #521 correctly suppressed auto-walking for content wrappers, the
incomplete includes became the only resolution path and children from
earlier modules were silently dropped.

## Test plan

- [x] Added regression test: multiple modules each contributing to
`polybar.includes` — all children resolved
- [x] Added regression test: auto-walk path with multi-module includes —
no crash, all children resolved
- [x] Existing `nested-aspect-includes` scoping tests pass (2/2)
- [x] Existing `nested-aspect-merge` test passes (1/1)
- [x] Existing `nested-aspects` suite passes (6/6)
- [x] Full CI: 778/778 passing
charlesfire pushed a commit to charlesfire/den that referenced this pull request May 16, 2026
## Summary

- **Multi-definition merge**: When multiple modules define the same
nested aspect key, class sub-keys are now properly collected instead of
last-win overwrite. `emitNestedAspect` reconstructs per-sub-key
`__contentValues` so all definitions contribute.
- **Includes scoping**: Explicitly including a nested aspect via
`den.aspects.X.Y` no longer auto-walks its nested sub-keys. Sub-aspects
at deeper levels must be included explicitly. Direct nesting and
organizational grouping continue to auto-walk as before.

## Test plan

- [x] Added regression test for multi-definition nested class key merge
- [x] Added regression tests for includes scoping (auto-include
prevented, explicit include works)
- [x] All 6 existing `nested-aspects` tests pass
- [x] Full CI: 776/776 passing
charlesfire pushed a commit to charlesfire/den that referenced this pull request May 16, 2026
## Summary

- **Content wrapper includes merge**: When multiple modules each add
children to an aspect's `includes` list (e.g., `polybar.includes =
[coreuse]` in one file, `polybar.includes = [wifi]` in another),
`aspectContentType.merge` shallow-merged forwarded attrs with `foldl'
//`, keeping only the last module's list. Now `includes` and `excludes`
are explicitly concatenated across all content value definitions.
- **mergeContentValuesPerKey includes handling**: The per-key
reconstruction in `emitNestedAspect` wrapped `includes` in a `{
__contentValues, __provider }` content wrapper instead of
list-concatenating, causing `expected a list but found a set` crashes on
the auto-walk path. Now list-concatenates these structural keys.

Fixes a regression exposed by denful#521 — before that change, auto-walking
masked the incomplete includes list by resolving nested keys regardless.
After denful#521 correctly suppressed auto-walking for content wrappers, the
incomplete includes became the only resolution path and children from
earlier modules were silently dropped.

## Test plan

- [x] Added regression test: multiple modules each contributing to
`polybar.includes` — all children resolved
- [x] Added regression test: auto-walk path with multi-module includes —
no crash, all children resolved
- [x] Existing `nested-aspect-includes` scoping tests pass (2/2)
- [x] Existing `nested-aspect-merge` test passes (1/1)
- [x] Existing `nested-aspects` suite passes (6/6)
- [x] Full CI: 778/778 passing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-ci allow all CI integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants