feat: layered database structure and AI guidance skills#150
Open
krisnye wants to merge 5 commits into
Open
Conversation
Move samples toward namespaced database layers and expand data-ai skills so agents can follow the same structure. Co-authored-by: Cursor <cursoragent@cursor.com>
…ture # Conflicts: # packages/data-lit-todo/package.json # packages/data-p2p-tictactoe/src/state/negotiation-plugin.ts
…tore Restructure both samples into the four-layer feature model and fix the supporting core types at the source. Core @adobe/data - Remove the separate transaction-context type. `Store` now carries `userId` and its index handles (`IX`); `ToStore<P>` includes indexes + partition keys. Transaction functions operate on `Store` directly — a store *is* the transaction context. Deletes `TransactionContext` / `ToTransactionContext`. - Fix `UIService.FromService` misclassifying a plain async fire-and-forget action (`() => Promise<void>`) as a transaction overload and wrongly requiring an argument; a genuine transaction has a synchronous commit signature (never a Promise), which is the correct discriminator. Samples (tic-tac-toe, todo) - `data/` is the specification: one immutable `State` with pure, unit-tested transforms/derivations. `ecs/` is the materialised view; computeds and transactions are verified against the `data/` precedent by conformance tests. Add `services/` (async ports) and `ui/`. - Facet-named database layers, no feature/app names in the ladder: Core -> Index -> Transaction -> Computed -> Service -> Action. - todo: async name-generator service, todo-analytics service, and an `actions/` layer where the UI dispatches actions that record analytics and call one transaction (async action brackets the slow call for timing). Rules & tooling - Path-mapped `structure/` rules mirroring the feature folders (adds data/state, ecs/actions); README + skill bundle updated. - Require Node >=22 (engines + .nvmrc) so live-reactivity paths are testable. Full-monorepo typecheck clean; test suite green on Node 22. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ests
Builds on the layered feature architecture with lazily-loaded features, a
many-to-many index demo, and a presentation-testing utility — plus fixes to
analytics, computed sharing, and flaky tests.
Multi-feature app (data-lit-todo)
- Restructure the sample into src/features/{main,assign}/. `main` imports each
peer feature's *schema* plugin (Database.Plugin `imports`, not `extends`) so
the shared store knows every schema without type-coupling or bundling the
feature's behavior.
- Feature elements lazily extend the live database on first connect
(DatabaseElement), so a feature's indexes/transactions/UI load only when used.
- New `assign` feature: a User archetype, a unique `usersByName` index and a
multi-value `todosByAssignee` index — the todo<->user many-to-many navigable
both ways; assignee dropdown + Users tab load lazily.
Services / actions
- todo-analytics is now named, strongly-typed methods (event vocabulary and
formatting owned by the service), with a stateless opaque timing token from
randomTodoRequested handed back to randomTodoAdded; named-object args.
Core @adobe/data
- Wrap db.derive computeds in Observe.withCache so N subscribers share one
computation (red/green test).
- Convert flaky wall-clock perf assertions to non-fatal warnings; the suite is
now deterministic and exits 0.
Presentation testing (@adobe/data-lit)
- Add Template — a DOM-free query over a Lit TemplateResult
(text/values/children/has/find) for asserting what a pure render(props)
declares. Pure and tree-shakeable.
- Make todo-row-presentation pure (move the drag hook into the element).
- Unit-test every Lit presentation in the repo (tictactoe, todo, p2p) via
Template; jsdom only where module-load side effects require it.
Rules updated for multi-feature composition, indexes/m2m, and the presentation
testing pattern. Full-monorepo typecheck clean; test suite green on Node 22.
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.
Summary
state/*-pluginfiles to namespaced database layers (data/resources,database/*, transactions, services) so apps compose typed database stacks instead of ad-hoc plugins.data-aiskills (structure, namespace, types, services, resources, and related helpers) so agents are guided toward that same layout and conventions.fromObjectProperties/fromStructProperties), UI-service transaction overload preservation, and split typecheck scripts.Direction
We are pushing toward a consistent, agent-friendly project shape: databases built in layers, folders that map to concepts (types / resources / services / structure), and skills that teach that pattern rather than one-off plugin files.
Test plan
pnpm typecheck(foundation → libraries → samples)data-lit-todo,data-lit-tictactoe, anddata-p2p-tictactoestill rundata-aiskills install/resolve as expectedMade with Cursor