Skip to content

feat(data-ai): type-first data authoring with pinned schemas - #163

Merged
krisnye merged 6 commits into
mainfrom
krisnye/data-ai-type-first-schemas
Jul 31, 2026
Merged

feat(data-ai): type-first data authoring with pinned schemas#163
krisnye merged 6 commits into
mainfrom
krisnye/data-ai-type-first-schemas

Conversation

@krisnye

@krisnye krisnye commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

What

Invert the type↔schema relationship in the @adobe/data-ai architecture rules & skills to type-first:

  • The type is hand-authored in <type>.ts — the readable source of truth. Authors use the richest types available (F32, Vec3, unions, branded aliases) for strong IntelliSense and self-documenting members.

  • The schema is optional and derived from the type, not the reverse. It is written to match the type — often later, by the agent (e.g. when implementing the ECS) — and pinned with a compile-time assertion so the two cannot drift:

    type _Pin = Assert<Equal<Schema.ToType<typeof schema>, MyType>>;

    Schema.ToType appears only in that assertion, never as the exported type.

Why

Makes data types easier to read and write, with better IntelliSense/hover and semantic meaning per property, while still guaranteeing the schema stays exactly in sync. Humans no longer need to hand-write schemas up front.

Changes

  • features/data/index.md, global/namespace.md, data-modelling.md — reworded to type-first + the pinning pattern.
  • skills/build-data/SKILL.md — schema now optional/derived + pinned.
  • (ECS components.md / archetypes.md already bound <Type>.schema and used the pin — unchanged.)
  • Bump @adobe/data-ai 0.9.91 → 0.9.92 (package.json + .claude-plugin/plugin.json).

Docs/rules only — no runtime code changes.

🤖 Generated with Claude Code

krisnye and others added 6 commits July 30, 2026 13:04
Invert the type<->schema relationship. Types are hand-authored as the
readable source of truth (rich types like F32/Vec3 for IntelliSense and
semantic meaning); schemas become optional and are written to match the
type — often later, by the agent, e.g. when implementing the ECS — pinned
to it with `type _Pin = Assert<Equal<Schema.ToType<typeof schema>, T>>` so
they cannot drift. `Schema.ToType` is used only in that assertion, never as
the exported type.

Updates features/data/index.md, global/namespace.md, data-modelling.md, and
the build-data skill. Bumps @adobe/data-ai to 0.9.92.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ed from test file

- The feature's assembled database alias is now `MainService` in the
  folder-eponymous `main-service.ts` (namespace export: `MainService.plugin` /
  `MainService.Store`), matching the namespace pattern; cross-feature form is
  `<Feature>MainService`. Updates main-service/index.md, element.md,
  conformance.md, and the build-app-entry / build-systems skills.
- State-transform cases are now exported from the `<transform>.test.ts` file
  itself (no separate `<transform>.cases.ts`); the conformance runner imports
  them from `<transform>.test.js`. Updates features/data/state.md,
  main-service/conformance.md, features/index.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
One exception to one-declaration-per-file: a namespace folder may have a
single `constants.ts` exporting several plain `const` literals (no functions,
no types), re-exported via public.ts so callers reach them as
`<TypeName>.<constant>`. Function declarations stay one per file.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…atures/ui/ moves

Rules referenced the old flat `.claude/rules/<name>.md` paths from before the
reorg; repoint them at the real locations:
- `.claude/rules/binding-element.md` → `features/ui/binding-element.md`
- `.claude/rules/presentation.md`   → `features/ui/presentation.md`
- `.claude/rules/hooks.md` / `ecs.md` → the rules-root `hooks.md` / `ecs.md`
- drop the dangling `.claude/rules/squirrel/ui-data-access.md` (FFP-only, no
  data-ai equivalent) from observe.md.

Touches observe.md, ecs.md, lit.md, features/ui/binding-element.md, global/react.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Synchronized version bump across all packages for the data-ai standard
changes (type-first schemas, cases-in-test, MainService rename, constants.ts,
rule reference fixes).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…/actions examples

Matches the code-side rename (computed/services/actions parameter renamed to
`service`, MainService-slice terminology); transactions keep `t`.
@krisnye
krisnye merged commit c4a6523 into main Jul 31, 2026
3 checks passed
@krisnye
krisnye deleted the krisnye/data-ai-type-first-schemas branch July 31, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant