fix: preserve source entity binding in forward fallback - #627
Merged
Conversation
Add a deadbug suite for the platform-specific `hmPlatforms` pattern from the custom-classes guide and discussion denful#620. The suite covers two fallback cases: - a generated inactive platform source class (`hmDarwin`) while `hmLinux` forwards into `homeManager` - an undeclared, unused source class forwarded into an evaluated `homeManager` target Both cases should be inert instead of tripping the self-parent spawn guard.
Complex forward fallback rewalks from the parent scope so it keeps fleet
visibility. When the source scope is a child entity scope, that rewalk still
needs the source scope's own entity binding.
Previously `resolveSourceFallback` spawned with `bindings = { }`, so a
user-scoped forward with no collected source modules could lose its `user`
binding and collapse into the self-parent spawn guard.
Restore that binding from `scopeEntityKind` and `scopeContexts`, mirroring the
existing drained-spawn reconstruction path.
Contributor
Author
|
Sorry, I forgot to add the |
drupol
reviewed
Jul 2, 2026
sini
approved these changes
Jul 2, 2026
sini
left a comment
Collaborator
There was a problem hiding this comment.
This looks solid enough to me.
Collaborator
|
I'll merge it once CI passes. Thank you for your contribution! :) |
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.
Problem
Refs #620.
The documented platform-specific
hmPlatformsexample can fail when auser-scoped complex forward includes a
fromClasswhose class key never appearsin the user's aspect tree and is not explicitly registered in
den.classes.For example, a user may include
hmPlatformsand define onlyhmLinuxcontent.The generated forward for another class, such as
hmDarwin, then has nocollected source modules when there is no
hmDarwinkey in that user's aspecttree and
hmDarwinis not registered as a class.In that case
getCollectedSourcereturns[], soresolveSourceFallbackrewalks the source aspect from the parent scope to keep fleet visibility. That
fallback used
bindings = { }, dropping the source scope's entity binding. Fora user-scoped forward, losing the
userbinding can make the spawn collapseinto a self-parent edge:
Fix
Restore the source scope's entity binding during complex forward fallback
rewalk.
The binding reconstruction mirrors the existing
mkDraineddrained-spawn path:den/nix/lib/aspects/fx/resolve.nix
Lines 677 to 679 in 70dfa3a
den/nix/lib/aspects/fx/resolve.nix
Lines 702 to 704 in 70dfa3a
The fallback now follows the same pattern: look up the source scope's entity
kind, read that entity from
scopeContexts, and pass it as the spawn binding.This keeps the existing parent-scope spawn behavior for fleet visibility, while
preserving bindings like
userwhen thesourceScopeIdis a child entityscope.
Tests
Added
deadbugs.hm-platform-forwardcovering:hmPlatformsshape: activehmLinuxforwards, inactivehmDarwinstays inert
homeManager, which shouldbe inert rather than crash
Both new regression tests fail on the test-only commit with
spawnNode spawn root equals its parent scopeand pass with this fix.Validated locally:
just ci deadbugs.hm-platform-forward.test-doc-example-forwards-linux-onlyjust ci deadbugs.hm-platform-forward.test-unknown-source-class-to-home-manager-is-inertjust fmtjust ci: 1036/1036 successfulAI assistance
I used AI assistance while preparing this contribution:
ChatGPT 5.5 Thinkinghelped me understand the complex forward fallback path,analyze the dropped source scope entity binding, and notice the existing
mkDrainedbinding reconstruction pattern.Codex GPT-5.5 mediumhelped with contribution workflow, test strategy,fail/pass comparison, test naming/comments, and English wording.
I also used AI to translate and polish English because I am not fluent in
written English. I reviewed the final text, understand the code changes and PR
description, removed repetition, kept the diff minimal and focused, and ran the
final tests locally.
I
Gyeongmin Song, explicitly acknowledge the following: