Repository navigation
fix: a policy's exclude covers its includer's subtree, wherever it sits in includes - #729
Merged
Merged
Conversation
…ts in includes A policy listed in an aspect's includes fired only at the scope's dispatch. By then the aspect's static includes had already passed the gate, and the exclude it registered carried the policy's own include chain, so it reached only what the policy itself included. policy.exclude therefore removed nothing the includer pulled in, directly or through a role. registerConstraints now also evaluates the policies in the aspect's includes against the scope's context and registers their exclude effects beside the aspect's own excludes: before any include is gated, with the includer's subtree as reach. A policy whose arguments the scope does not supply yet is left to its dispatch.
theutz
approved these changes
Oct 15, 2026
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.
Summary
This is the second excludes gap:
den.lib.policy.exclude <aspect>, returned by a policy that sits in an aspect'sincludes, was ignored. It was traced from a nix-config host: a microVM guest whosetailscaleaspect, pulled in through a role, still declared its age secret.The aspect-level form,
den.aspects.igloo.excludes = [ den.aspects.feat ], already worked through the role.#728 is the other gap: a schema-included parametric aspect losing its identity. That's a different cause in a different file. The two PRs are independent and don't conflict.
Root cause
Two problems, both in how a policy's exclude was registered.
includesis only registered during the include walk (register-aspect-policy). It fires at the scope'sdispatch-policies, after the aspect's static includes have already passedgate→check-constraint. The trace showscheck featwith no entry, thenregister-constraint owner=policy identity=feat.ownerChain, andfilterByScopeapplies a subtree exclude only under that chain. It would cover only what the policy itself includes. (issue-540-exclude-guardpasses only because its include and exclude come from one policy.)Fix
registerConstraints(nix/lib/aspects/fx/aspect/children.nix) already registers an aspect's ownexcludesbefore its includes are walked. It now does the same for the policies in that aspect'sincludes:scopeContextsplus the aspect's scope handlers, andself, as dispatch binds it.excludeeffects as subtree constraints alongside the aspect's own.The result is the same timing and the same reach as
excludes = [ … ].A policy whose required arguments the scope doesn't supply yet is skipped here and left to its dispatch, which behaves as before. The later dispatch re-registers the same exclude, which is harmless.
Tests
New file
templates/ci/modules/deadbugs/policy-exclude-reaches-includer-subtree.nix:excludesthrough a role;features/exclude-nested-role.nix(branchtest/policy-exclude-reach, 658f9a8)templates/cisuite (local)Cost
Each policy listed in an aspect's
includesis now evaluated once more, at constraint registration, in addition to its dispatch. Only itsexcludeeffects are used. I didn't measure the cost.