fix: same-named hosts or homes on two systems collapse silently in one walked scope
Two hosts with the same name on different systems collapse silently when one walked scope resolves both, and the same goes for two homes. Only one declaration's content lands, and which one depends on list or policy order.
Reproduction
den.hosts.x86_64-linux.shelf = { };
den.hosts.aarch64-linux.shelf = { };
# one environment whose host policy doesn't filter by system
den.policies.env-to-hosts = { environment, ... }:
map (host: resolve.to "host" { inherit host; })
(lib.concatMap builtins.attrValues (builtins.attrValues den.hosts));
Both hosts' outputs are built with the first-listed declaration's content and host record. The other system's host reads system = "x86_64-linux" from host, although its hostPlatform is right. Nothing warns. den.lib.__hasLandedAspect on the second host reports that it isn't instantiated.
Two same-named homes on two systems already have distinct identities, yet they still collapse into one scope in this shape.
Cause
A walked scope's label is built from the entity's name under its parent, so both declarations map to env=prod,host=shelf. The walk's context dedup then drops the second resolve as a repeat, and it never becomes its own scope. A host-scope policy that re-resolves the other system's declaration is accepted as a re-entry of the first, because re-entry compares only the name-based identity.
Walks that resolve each system's hosts separately, such as per-system environments or the default flake walk, aren't affected.
Proposed fix
Refuse the collision by name instead of building the wrong host:
- Record each host's and home's declaration key (its
den.hosts.<system>.<name>path) internally when the registry builds it. Don't derive it fromsystem, which a host can override. - At the walk's dedup and at the re-entry check, a record whose declaration key differs from the one the scope was created with throws an error naming both declarations and the scope.
- The same declaration reached twice, one record delivered in two classes, and records without a declaration key, like hand-built
{ name = …; }records, behave as today.
This changes behaviour for configs that currently build, wrongly, with both declarations in one scope. They need to walk each system's hosts separately, or use distinct names. Public names, ids and output paths don't change.