Repository navigation
feat: in-context hasAspect honors projected (delivered) scope state - #602
Merged
Merged
Conversation
An entity-kind binding's .hasAspect, when read from inside a resolved aspect/class-module context, now answers PROJECTED membership for the active scope path (what is actually delivered into this scope) instead of the structural registry tree. The registry query (den.hosts.….users.tux.hasAspect) stays the structural query — one symbol, overloaded by provenance. decomposeSchemaEffect wraps each entity-kind binding's hasAspect to a pure projected lookup over the owning host's already-computed __pathSetByScope, keyed by the active scope id. The scope id is built from entity-kind bindings only so it matches the path-set bucket key regardless of later policy enrichment (e.g. an added 'system' key). Only .hasAspect is replaced; mkScopeId keys off .name, so ctxNames/currentScope are unperturbed.
- foldl' over override kinds -> single lib.genAttrs merge - collapse owner/if-null guard into an idiomatic chained-or for the path set
vic
approved these changes
Jun 10, 2026
sini
enabled auto-merge (squash)
June 10, 2026 04:37
sini
added a commit
to sini/den
that referenced
this pull request
Jun 14, 2026
…tity The projected-hasAspect spec (denful#602) requires every in-context entity-kind binding to answer membership at the ACTIVE (consuming) scope — "is X delivered into THIS scope" — keyed by ONE shared scope id. The id_hash re-key (e8876f3), while correctly making the key stable across standalone-produce vs fleet-consume, over-corrected: it keyed each binding to its OWN id_hash bucket. That made host.hasAspect read the host's own bucket, blinding it to aspects the host delivers DOWN to its users via provides.to-users (those resolve under the consuming user scope, so only the active bucket holds them). Key all in-context bindings to the active scope = the consuming (target) entity's id_hash (the deepest scope in ctx). Keeps e8876f3's fleet stability and per-active-path multi-host discrimination (still reads the owning host's __pathSetByScope) while restoring the spec semantics. Regression reported via github.com/tschan/den-hasaspect-bug. CI 979/979.
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
In-context
.hasAspect— theuser/hostarg inside a parametric aspect body or resolved context — now answers projected membership ("is aspectX delivered into this scope") instead of the entity's standalone structural tree. This fixesuser.hasAspect <x>returningfalsefor aspects delivered viaprovides, even though the config genuinely applies.The registry query (
den.hosts.….users.tux.hasAspect) stays the structural query — one symbol, overloaded by provenance:The projected answer is a byproduct of the owning host's single existing production run — zero extra pipeline runs. It is also per active path: a user appearing under multiple hosts gets per-host answers (
tux@igloovstux@iceberg).Changes
feat(aspects): record per-scopepathSetByScopein the structural walk (thunked, likepathSet)feat(aspects):resolveWithPathssurfacespathSetByScopefrom the samefx.handle;resolvereturn shape unchanged (protectsdeferredModuleconsumers)feat(entities): host/home exposeconfig.__pathSetByScopefrom a shared, memoized__resolveResult— a single run backs bothmainModuleand the path setfeat(aspects):mkProjectedHasAspect— a pure per-scope lookup (no pipeline)feat(aspects): in-context override indecomposeSchemaEffect— wraps entity-kind bindings'.hasAspectwith the projected lookup, keyed by the active scope idCycle-safety rests on two thunk facts: the per-scope set is built in the structural walk (no class-module bodies forced), and
scopedClassImportsis thunked so the trampoline'sdeepSeqnever forces amkIfcondition mid-run. Deciding an aspect'sincludesfrom projected membership is the one cyclic case and is documented inschema.nix(not supported).Test plan
path-set-by-scope(4): bucketing,resolveWithPathsshape, entity exposure, factoryprojected-hasaspect(4): content-position fix, provenance split (registry=false/inContext=true), multi-user (tux/pingu), multi-host (igloo/iceberg)has-aspect(35/35) andissue-540-exclude-guardstay greenDiff: 11 files, +386/-11.