Skip to content

feat: in-context hasAspect honors projected (delivered) scope state - #602

Merged
sini merged 7 commits into
mainfrom
feat/projected-hasaspect
Jun 10, 2026
Merged

sini merged 7 commits into
mainfrom
feat/projected-hasaspect

Conversation

@sini

@sini sini commented Jun 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

In-context .hasAspect — the user/host arg 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 fixes user.hasAspect <x> returning false for aspects delivered via provides, even though the config genuinely applies.

The registry query (den.hosts.….users.tux.hasAspect) stays the structural query — one symbol, overloaded by provenance:

  • entity from a scope-context arg (parametric body / guard) → projected
  • entity from the registry → structural (unchanged)

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@igloo vs tux@iceberg).

Changes

  • feat(aspects): record per-scope pathSetByScope in the structural walk (thunked, like pathSet)
  • feat(aspects): resolveWithPaths surfaces pathSetByScope from the same fx.handle; resolve return shape unchanged (protects deferredModule consumers)
  • feat(entities): host/home expose config.__pathSetByScope from a shared, memoized __resolveResult — a single run backs both mainModule and the path set
  • feat(aspects): mkProjectedHasAspect — a pure per-scope lookup (no pipeline)
  • feat(aspects): in-context override in decomposeSchemaEffect — wraps entity-kind bindings' .hasAspect with the projected lookup, keyed by the active scope id

Cycle-safety rests on two thunk facts: the per-scope set is built in the structural walk (no class-module bodies forced), and scopedClassImports is thunked so the trampoline's deepSeq never forces a mkIf condition mid-run. Deciding an aspect's includes from projected membership is the one cyclic case and is documented in schema.nix (not supported).

Test plan

  • new internal-api suite path-set-by-scope (4): bucketing, resolveWithPaths shape, entity exposure, factory
  • new deadbug suite projected-hasaspect (4): content-position fix, provenance split (registry=false / inContext=true), multi-user (tux/pingu), multi-host (igloo/iceberg)
  • has-aspect (35/35) and issue-540-exclude-guard stay green
  • full CI: 874/874 successful

Diff: 11 files, +386/-11.

sini added 5 commits June 9, 2026 09:41
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.
@sini
sini requested a review from vic as a code owner June 9, 2026 17:22
@github-actions github-actions Bot added the allow-ci allow all CI integration tests label Jun 9, 2026
sini added 2 commits June 9, 2026 10:43
- foldl' over override kinds -> single lib.genAttrs merge
- collapse owner/if-null guard into an idiomatic chained-or for the path set
@sini
sini enabled auto-merge (squash) June 10, 2026 04:37
@sini
sini merged commit 88161da into main Jun 10, 2026
30 checks passed
@sini
sini deleted the feat/projected-hasaspect branch June 10, 2026 04:43
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-ci allow all CI integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants