Repository navigation
fix(core): a policy in a den.default include registers once - #765
Merged
Merged
Conversation
A `{ host, user }` include in den.default is also fanned out at the host
scope for each user (#753), so a policy record it builds was registered
by every copy. The claim told copies apart by whole-value `==`, and a
record built inside the include is a new value in each copy, so each one
got its own identity and delivered again: twice for one user, three times
each for two.
A policy record now carries the include site it was written at: the
parametric include as written, its include positions below, and the
bound entities its `fn` doesn't take as arguments. A claim with an equal
site is a copy of a registration already made, so it isn't registered
again. Two different records under one name stay two registrations.
Reported in GitHub #764.
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
Reported, bisected and traced by @istvnurbn in #764:
(den.batteries.user-shell "fish")inden.default.includesdefinesusers.users.<name>.shelltwice since v0.20.0, so no host evaluates. Their bisect to 22b2097 (#753) and their claim trace are what pointed at the cause. Thank you!#764 fixes the battery. The same failure also hits any policy record that a
{ host, user }include inden.defaultbuilds inline, so this PR fixes it in core:Cause. Since #753, a
{ host, user }include that the descendant also gets (den.default) is fanned out at the host scope too, once per user. R6 drops that copy's class content for an accepted user, but its policies still register at the host scope, and the user's own copy registers again. The policy-name claim (claim.nix) tells registrations apart by whole-value==. A record built inside the include is a new value in every copy, so each copy is displaced to its own identity and delivers again: twice for one user, three times each for two. Alet-bound record compares equal and collapses, which is whydefine-userandprimary-userworked, and why #764'sletfixes the battery.Fix. A policy record now carries the include site it was written at (
children.nixpolicySiteKey):fndoesn't take as arguments, so a record that captured the outeruserkeeps one registration per user.Every copy of one include is walked from the same value, and
==compares a function inside a container by pointer, so copies' sites are equal. The site isn't the wrapped__fn: a functor's is rebuilt on every walk (normalize.nixwrapFunctorChild).A claim with an equal site is a copy of a registration already made, so it isn't registered again. Two different records under one name keep different sites and stay two registrations (O4). A record with no site, and a value-equal match (O5), behave as before.
Behaviour against main
Each row holds in transition and acknowledged mode.
den.default{ host, user }include[0 1][3 3][1 1][1 1][2 2][1 1][1 1][2 2][1 1]fnreads the outeruser, two users[0 1][2 2][1 1]policy.includeof host content, two users[0 1][2 2][1 1]den.batteries.user-shellv0.19.0's
[0 1]is an older bug: a user's registration overwrote its sibling's. This PR fixes that too.Validation
templates/ci/modules/deadbugs/den-default-inline-policy.nix, 10 cells, each in transition and acknowledged mode. 20/20 here, 4/20 on main.ci.bash, 4 workers): 2200/2200.NIX_SHOW_STATS) on the 9 template configurations that evaluate: at most +0.08% function calls and +0.03% thunks.#764's battery passes unmodified, so its change isn't needed once this lands.