Repository navigation
fix: deferred conditional guards drain at correct scope level (#540) - #541
Merged
Merged
Conversation
sini
force-pushed
the
fix/deferred-guard-scope
branch
from
May 14, 2026 09:30
435734f to
c3dbc63
Compare
sini
force-pushed
the
fix/deferred-guard-scope
branch
5 times, most recently
from
May 14, 2026 14:59
b9b9c3c to
82801aa
Compare
drain-conditionals was firing inside every resolve-children call, including nested aspects. When a conditional was the first include and its dependency was a later sibling, the drain fired inside the conditional's own resolve-children — before the sibling was walked. The guard re-evaluated against an incomplete pathSet and tombstoned. Now drain only fires at entity-level aspects (__entityKind) or root scope aspects (currentScope == rootScopeId), ensuring all siblings have been walked before guards are re-evaluated.
sini
force-pushed
the
fix/deferred-guard-scope
branch
from
May 14, 2026 15:11
82801aa to
8292cb9
Compare
vic
approved these changes
May 14, 2026
compile-conditional now reads scopedConstraintRegistry + scopeParent from pipeline state and builds a scope-specific constraint view via collectScopeConstraints. The guard's hasAspect returns false for aspects that are in the pathSet but excluded in the current scope. This correctly handles policy.exclude + policy.when hasAspect in the same policy: the exclude registers before includes are processed (emitPolicyEffectsThen emits excludes first), so by the time the guard fires, the constraint registry already has the exclude entry. Per-scope isolation: tux's exclude doesn't leak to pingu because collectScopeConstraints only walks the current scope's ancestry.
sini
force-pushed
the
fix/deferred-guard-scope
branch
from
May 14, 2026 17:12
219864f to
a07482c
Compare
sini
enabled auto-merge (squash)
May 14, 2026 17:16
Collaborator
|
Great. Thanks for breakfast 🍞! |
charlesfire
pushed a commit
to charlesfire/den
that referenced
this pull request
May 16, 2026
…#540) (denful#541) ## Summary - Fixes denful#540: `policy.when` with `hasAspect` failed when the conditional was the first include and its dependency was a later sibling - `drain-conditionals` was firing inside every `resolve-children` call, including nested aspects — the guard re-evaluated before siblings were walked - Now drains only at entity-level aspects (`__entityKind`) or root scope aspects (`currentScope == rootScopeId`) ## Root cause The conditional's `resolve-children` drained deferred guards before the parent finished walking all siblings. The pathSet was incomplete, so the guard failed and tombstoned permanently. ## Test plan - [x] `test-conditional-before-dependency` — conditional first, dependency second in aspect includes - [x] `test-conditional-same-level-schema` — same pattern via schema includes - [x] Full CI: 805/805 passing (including all prior denful#525/denful#530 tests) Co-Authored-by: @fmway who provided amazing tests
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
policy.whenwithhasAspectfailed when the conditional was the first include and its dependency was a later siblingdrain-conditionalswas firing inside everyresolve-childrencall, including nested aspects — the guard re-evaluated before siblings were walked__entityKind) or root scope aspects (currentScope == rootScopeId)Root cause
The conditional's
resolve-childrendrained deferred guards before the parent finished walking all siblings. The pathSet was incomplete, so the guard failed and tombstoned permanently.Test plan
test-conditional-before-dependency— conditional first, dependency second in aspect includestest-conditional-same-level-schema— same pattern via schema includesden.lib.policy.whenand<entity>.hasAspect#525/fix: policy.when with hasAspect no longer cycles, policy.for accepts effect descriptors #530 tests)Co-Authored-by: @fmway who provided amazing tests