Skip to content

spike: @adobe/data adoption evidence (chat-state container port) - #2211

Draft
2witstudios wants to merge 1 commit into
masterfrom
pu/adobe-data-spike
Draft

spike: @adobe/data adoption evidence (chat-state container port)#2211
2witstudios wants to merge 1 commit into
masterfrom
pu/adobe-data-spike

Conversation

@2witstudios

Copy link
Copy Markdown
Owner

⚠️ Evidence artifact — NOT for merge

This branch exists to answer the @adobe/data adoption spike with running code. Nothing here is imported by any production call site; apps/web/src/app/spike/adobe-data/ is a throwaway harness route. Do not merge. Close it once the migration epic is scoped, or cherry-pick src/state/chat/* into that epic's PR A.

Full verdict + migration epic proposal: spike page q9ysdsvdada5c6jp1fq0abpj.

Verdict: ADOPT — after E1, at the E1→E2 boundary

No blocker found. Bindings, SSR, hydration, StrictMode, undo and zustand coexistence all work under Next 15 + React 19, with zero any / as any / @ts-ignore and a clean monorepo typecheck. Not "adopt now" only because E1 PR5/PR6 are in flight on zustand and the rails forbid a mid-wave platform swap.

Versions: @adobe/data@0.9.83, @adobe/data-react@0.9.83.

The decisive proof

apps/web/src/state/chat/__tests__/conversationMessagesFacade.test.ts and pendingStreamsFacade.test.ts are mechanical copies of the two existing store suites with exactly one line changed each — the container construction in beforeEach. Every it() title, every arrangement, every assertion is byte-identical.

49/49 pass. The 133 pure applyX tests are untouched and green, because the transactions call those same functions.

bun vitest run src/state/chat src/stores
→ 55 files, 817 tests, 0 failures

What is in the port

File Role
state/chat/chat-data-plugin.ts components / archetypes / indexes — one entity per conversation, one per live stream
state/chat/chat-state-plugin.ts applyX transitions as transactions, selectors as computed (db.derive), value-returning glue as actions
state/chat/conversationEntry.ts the container swap in one function: read entity → run the untouched pure applyX → write columns
state/chat/facade/* zustand-shaped facades, so existing getState() call sites are unchanged over the new container
app/spike/adobe-data/* RSC → DatabaseProvideruseObservableValues harness

Extra evidence suites: aiActionUndo (5), computedObservables (9), zustandInterop (3), reactBinding (7 — SSR, StrictMode, propagation, unmount, hydration).

Measurements

  • Shared First Load JS: 237 kB → 237 kB. No change to the shared baseline; the library is route-scoped and tree-shaken out of routes that don't import it.
  • @adobe/data client chunk: 52.4 kB raw / 16.9 kB gzip. Ported plugin + facades + harness page: 17.3 kB raw / 5.0 kB gzip.
  • Whole client build: +71.7 kB (+0.20 %) — and that includes the throwaway harness route.
  • bun run typecheck (Turbo, monorepo): clean. eslint on all new files: clean.

Friction the migration epic must carry

  1. computed and actions cannot share one Database.Plugin.create call (0.9.83) — declaring both silently collapses inferred actions to {}. Splitting across an extends boundary fixes it. Undocumented; dictates plugin layout for every adopter.
  2. Database.Plugin.ToStore<P> drops declared indexes — use ToTransactionContext<P> / Database.Read<ToDatabase<P>>.
  3. Transactions may only return void | Entity, so startLoad's "return the generation" contract becomes an action.
  4. Undo/redo requires the plugin to declare its own applyOperations transaction — runtime throw, nothing in the types says so.
  5. Optional fields have no ECS equivalent (null-encoded columns projected back to undefined).
  6. Opaque JS payloads need mutable: true or ToType wraps them in DeepReadonly.

Verification gaps (stated honestly)

  • React render/hydration tests did run in the .pu worktree — the epic's documented dual-React failure did not reproduce here (@adobe/data-react resolves React from apps/web/node_modules, the same copy vitest uses). Re-run on the main checkout before relying on it.
  • /spike/adobe-data was not loaded through a live dev server: it sits behind the auth middleware, and a spike must not modify an auth boundary to make itself reachable. next build compiles it (route listed at 21.8 kB) and SSR/hydration is asserted in tests instead. A signed-in manual load remains the one open gap.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B1feUaxUzUP3Z6oDLTtFDd

Evidence branch for the @adobe/data (ECS + Observe) adoption spike. Not for
merge — no production call site imports any of this.

What is here:
- apps/web/src/state/chat/chat-data-plugin.ts — components/archetypes/indexes:
  one entity per conversation, one per live stream, with real ECS indexes on
  conversationId / streamMessageId / streamPageId.
- chat-state-plugin.ts — the two stores' applyX transitions as `transactions`,
  the selectors as `computed` (db.derive), the value-returning glue as
  `actions`. Only the AI-edit transaction is `undoable`.
- facade/ — zustand-shaped facades so existing getState() call sites are
  unchanged over the new container.
- app/spike/adobe-data/ — RSC → DatabaseProvider → useObservableValues harness.
- __tests__/ — the two existing store suites re-run against the port with zero
  assertion changes (49/49), plus AI-undo, computed, interop and React
  binding/hydration evidence.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 56fd8420-96c2-4e28-9a00-1ddac496ca1d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pu/adobe-data-spike

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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