Skip to content

fix: excludes work on nested keys without _ prefix - #542

Merged
sini merged 1 commit into
mainfrom
fix/nested-key-exclude-identity
May 15, 2026
Merged

sini merged 1 commit into
mainfrom
fix/nested-key-exclude-identity

Conversation

@sini

@sini sini commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Nested keys defined without _ prefix (e.g., my-aspect.sub-aspect1) produce content wrappers { __contentValues, __provider } with no name field
  • When passed to excludes, identity.key produced "<anon>" instead of the actual key name, so the constraint never matched the aspect during the tree walk
  • Fix: normalize content wrappers in registerConstraints by extracting name from __provider — the same normalization wrapChild does in normalize.nix

Root cause

The aspect type system produces different shapes for nested keys vs _-prefixed sub-aspects:

  • den.aspects.foo.bar → { __contentValues, __provider } (content wrapper, no name)
  • den.aspects.foo._.bar → { name = "bar"; meta.provider = [...]; ... } (full aspect)

The constraint system computed identity on the raw wrapper before normalization injected the name.

Test plan

  • test-nested-key-exclude — excludes both _-prefixed and non-prefixed sub-aspects
  • Full CI: 809/809

@github-actions github-actions Bot added the allow-ci allow all CI integration tests label May 14, 2026
@sini
sini force-pushed the fix/nested-key-exclude-identity branch from e402b8a to 8d28051 Compare May 14, 2026 18:21
@sini
sini requested a review from vic as a code owner May 14, 2026 18:21
@theutz

theutz commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Is this something that got surfaced by my dalliance with excludes?

@sini

sini commented May 14, 2026

Copy link
Copy Markdown
Collaborator Author

Is this something that got surfaced by my dalliance with excludes?

It was raised in #500

@fmway

fmway commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Interesting, so basically den has 2 aspect, sub-aspect and full aspect. While sub-aspect is maybe an unknown class, but they will be act as an aspect when they're inside includes. And full aspect is truly an aspect, that can be define in a root, or inside provides.

Am i right?

@sini

sini commented May 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

Interesting, so basically den has 2 aspect, sub-aspect and full aspect. While sub-aspect is maybe an unknown class, but they will be act as an aspect when they're inside includes. And full aspect is truly an aspect, that can be define in a root, or inside provides.

Am i right?

Sort of, yes. The types will be changing in a couple weeks, but that's the current type system. Ideally the typesystem would just let us say aspect types have keys of (aspect | class/quirk | fn-to-aspect) but for a multitude of reasons (backwards compat + identity + we can only detect functions, not if it's a class or fn-to-aspect) we're doing a bit of gymnastics.

We'll be replacing this with denful/flake-aspects 2.0 after we've got everything hammered out and hopefully be able to simplify it then

@sini

sini commented May 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

Interesting, so basically den has 2 aspect, sub-aspect and full aspect. While sub-aspect is maybe an unknown class, but they will be act as an aspect when they're inside includes. And full aspect is truly an aspect, that can be define in a root, or inside provides.

Am i right?

@fmway since you seem genuinely interested, and since I don't think you're in our matrix chat, I just published this doc that's helpful for understanding pipeline resolution flow: https://gist.github.com/sini/e326de73fca4704d663336eae86e546c

This is subject to change in our next version, but this is what we just shipped.

@fmway

fmway commented May 14, 2026 •

Copy link
Copy Markdown
Collaborator

@fmway since you seem genuinely interested, and since I don't think you're in our matrix chat, I just published this doc that's helpful for understanding pipeline resolution flow: https://gist.github.com/sini/e326de73fca4704d663336eae86e546c

This is subject to change in our next version, but this is what we just shipped.

Okay, thanks. I'll land on the matrix later. Sorry, i just asked in the wrong place.

@sini

sini commented May 14, 2026

Copy link
Copy Markdown
Collaborator Author

@fmway since you seem genuinely interested, and since I don't think you're in our matrix chat, I just published this doc that's helpful for understanding pipeline resolution flow: https://gist.github.com/sini/e326de73fca4704d663336eae86e546c
This is subject to change in our next version, but this is what we just shipped.

Okay, thanks. I'll land on the matrix later. Sorry, i just asked in the wrong place.

You're fine, just happy you're engaging. It's the open-source process. :)

Content wrappers ({ __contentValues, __provider }) from nested keys
defined without the _ prefix had no name field, causing identity.key
to produce "<anon>" instead of the actual nested key name. The
constraint system registered the exclude under the wrong identity.

Normalize content wrappers in registerConstraints by extracting the
name from __provider, matching what wrapChild does in normalize.nix.
@sini
sini force-pushed the fix/nested-key-exclude-identity branch from 8d28051 to d131bfb Compare May 15, 2026 06:53
@sini
sini enabled auto-merge (squash) May 15, 2026 06:53
@sini
sini merged commit 2c7f942 into main May 15, 2026
15 checks passed
@sini
sini deleted the fix/nested-key-exclude-identity branch May 15, 2026 07:00
charlesfire pushed a commit to charlesfire/den that referenced this pull request May 16, 2026
## Summary

- Nested keys defined without `_` prefix (e.g., `my-aspect.sub-aspect1`)
produce content wrappers `{ __contentValues, __provider }` with no
`name` field
- When passed to `excludes`, `identity.key` produced `"<anon>"` instead
of the actual key name, so the constraint never matched the aspect
during the tree walk
- Fix: normalize content wrappers in `registerConstraints` by extracting
`name` from `__provider` — the same normalization `wrapChild` does in
`normalize.nix`

## Root cause

The aspect type system produces different shapes for nested keys vs
`_`-prefixed sub-aspects:
- `den.aspects.foo.bar` → `{ __contentValues, __provider }` (content
wrapper, no `name`)
- `den.aspects.foo._.bar` → `{ name = "bar"; meta.provider = [...]; ...
}` (full aspect)

The constraint system computed identity on the raw wrapper before
normalization injected the name.

## Test plan

- [x] `test-nested-key-exclude` — excludes both `_`-prefixed and
non-prefixed sub-aspects
- [x] Full CI: 809/809
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.

3 participants