feat(data): Set/Map data model, type-driven conformance ordering, Services injection - #168
Merged
Conversation
…ordering - Add Data.stringify/parse (JSON extended with Map/Set) and route store serialize/deserialize through it - Data / IsData / DeepReadonly / equals now handle ReadonlySet & ReadonlyMap - Conformance compares by type: ReadonlyArray ordered, Set/Map order-independent; remove match.unordered, auto-ignore entity id, support ref correspondence across Set boundaries - Migrate space-rock, hopper, pixie unordered entity bags to ReadonlySet - Formalize service injection: per-feature services/services.ts Services map + Pick<Services,...> in transitions + service-database drift-guard (todo, space-rock) - Update @adobe/data README/AGENTS and data-ai rules/docs; bump to 0.9.97 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
krisnye
force-pushed
the
krisnye/set-map-data-model
branch
from
August 12, 2026 07:37
d7e71d0 to
5b379f8
Compare
Discriminate mode by presence of data/state: state-based (a Functional State Specification is the source of truth, ECS conformance-verified against it) vs ECS-based (ECS is the source of truth, no data/state, no conformance). In ECS-based mode every transaction and action carries its own unit test, since there are no conformance cases. Adds the Two-modes section to features/index.md and gates conformance.md / transactions.md / actions.md / data/state.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
krisnye
force-pushed
the
krisnye/set-map-data-model
branch
from
August 12, 2026 07:39
5b379f8 to
01738a3
Compare
krisnye
commented
Aug 12, 2026
| the semantics: `ReadonlyArray` compares positionally, `ReadonlySet` / `ReadonlyMap` | ||
| order-independently, and a numeric `id` is ignored (the ECS allocates it) — so there | ||
| is no separate "unordered" declaration when writing conformance cases. | ||
|
|
Collaborator
Author
There was a problem hiding this comment.
This logic seems duplicated elsewhere. Let's leave it here and just reference it from the other rules instead of duplicating it.
Collaborator
Author
There was a problem hiding this comment.
Done in 34ae293 — kept the ordering-by-type rule canonical here in data-modelling.md; data/state.md and conformance.md now reference it instead of restating it.
…modelling.md Keep the ordering-by-type explanation canonical in data-modelling.md; state.md and conformance.md now reference it instead of restating it (per PR review). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ap> doesn't strip .set The Set/Map DeepReadonly change turns a resource's Map value into ReadonlyMap; this runtime nonPersistent URL->Entity cache is genuinely mutable, so flag it mutable:true (same as rigid-stack). Missed locally due to a stale tsc -b incremental cache; a clean build reproduces the CI failure. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Description
Makes
Set/Mapfirst-class in the data model, pushes ordered-vs-unordered semantics into the type system, formalizes how services are injected into transitions, and names the two feature-authoring modes.Data.stringify/Data.parseA lower-level JSON serializer extended to round-trip
MapandSetin both directions (plainJSON.stringifyrenders them as{}), surfaced on theDatanamespace. The store'sserialize/deserializenow route through it, so Set/Map values persist.Set/Mapas first-classDataData,IsData,DeepReadonly, andequalsall handleReadonlySet/ReadonlyMap.equalscompares them order-independently (elements/values recurse).mutableClonealready worked viastructuredClone. Verified end-to-end that a stored typed-buffer column of Maps/Sets round-trips.Type-driven conformance ordering
The comparator now derives ordering from the value's type —
ReadonlyArraypositional,ReadonlySet/ReadonlyMaporder-independent — so thematch.unorderedoption is removed. A numericidis auto-ignored unless a case pins it, andMatch.refcorrespondence now holds across aSetboundary (backtracking pairing). Space-rock, hopper, and pixie model their unordered entity bags asReadonlySet.Formalized service injection
Each feature's
services/root exports oneServicesmap; transitions inject withPick<Services, ...>instead of ad-hoc inline types. Eachservice-databasecarries a compile-time drift-guard pinningdb.servicestoServices. Migrated data-lit-todo and data-lit-space-rock-game.Two feature modes: state-based vs. ECS-based
Names the two authoring modes, discriminated by the presence of
data/state/. State-based (the mode for all new features): a Functional State Specification is the source of truth and the ECS is conformance-verified against it. ECS-based (legacy — features predating the state-based approach): the ECS is the source of truth, nodata/state/, no conformance, so every transaction and action carries its own unit test. Documented in the data-ai rules (features/index.mdplus gates inconformance.md/transactions.md/actions.md/data/state.md).Docs
Updated
@adobe/dataREADME/AGENTS and the data-ai rules (data-modelling.md,data/state.md,data/index.md,services/index.md,conformance.md,service.md,features/index.md,transactions.md,actions.md).Testing
lintandtypecheckclean across all 18 packages@adobe/data3011 tests,data-testing12,data-lit-todo102,data-lit-space-rock-game135,data-gpu-hopper90,data-react-pixie42 — all passing (Node 24)🤖 Generated with Claude Code