diff --git a/.project/concepts/nextgraph-platform/decision_2026-06-17_eventually-library.md b/.project/concepts/nextgraph-platform/decision_2026-06-17_eventually-library.md index 043942d..8d81217 100644 --- a/.project/concepts/nextgraph-platform/decision_2026-06-17_eventually-library.md +++ b/.project/concepts/nextgraph-platform/decision_2026-06-17_eventually-library.md @@ -58,7 +58,17 @@ Reste à implémenter dans la lib (stubs `TODO`, nécessitent la couche comptes/ ### Intégration du shim mono-wallet (merge 2026-06-30) -Le merge de `main` (shim staging wallet partagé : `storeRegistry`, comptes, isolation, e2e multi-navigateur) a ramené du code écrit contre le SDK brut. **Audit post-merge** : le seul écart à l'invariant « tout passe par `@ng-eventually/client` » était `storeRegistry.ts` qui importait `ng` de `@ng-org/web` ; **corrigé** → il importe `ng` de la lib (le proxy forwarde `doc_create`/`sparql_update`/`sparql_query`). Désormais, les **seuls** imports `@ng-org` runtime de l'app sont le **point d'injection** (`ngSession`) + les exceptions documentées (`auth-setup`, `harness` mock) + les bindings ORM générés (`import type`). L'invariant tient. **Encore in-app** (à migrer dans la lib ensuite) : `storeRegistry`, `AccountContext`, filtre d'**isolation** (`isolation.ts`) — distinct du filtre **ReadCap** de la lib ([[brief_2026-06-15_shared-wallet-shim]]). +Le merge de `main` (shim staging wallet partagé : `storeRegistry`, comptes, isolation, e2e multi-navigateur) a ramené du code écrit contre le SDK brut. + +**Limite découverte (validée en suite complète, 2026-06-30)** : `doc_create` (et les appels SPARQL du shim) **ne peuvent PAS passer par le proxy `ng` de la lib**. Le `ng` de `@ng-org/web` est déjà un **proxy iframe (RPC postMessage)** ; l'envelopper dans le `Proxy` JS de `makeNg` (double proxy) casse le marshaling de `doc_create` → `DataCloneError: function ... could not be cloned`. Tenté (`storeRegistry`+`harness` routés via la lib) → **4 scénarios multistore rouges** ; **annulé**. + +**Frontière d'intégration retenue** : +- **Passent par la lib** (validés) : `useShape` (ORM + filtre ReadCap), `init`/`initNg`, `login`. +- **Restent sur le vrai `ng`** (`@ng-org/web`) : `doc_create` + SPARQL du shim — dans `storeRegistry.ts` (app) et `harness-ng.tsx` (`createSmokeDoc`). C'est cohérent avec « shim **encore in-app** » : quand `storeRegistry` **migrera dans la lib**, il utilisera le `ng` **réel injecté** (`getConfig().ng`) en interne — **pas** le proxy public → plus de double-proxy. + +Imports `@ng-org` runtime de l'app après merge : point d'injection (`ngSession`) + `storeRegistry`/`harness-ng` (doc_create, le temps que le shim rejoigne la lib) + exceptions documentées (`auth-setup`, `harness` mock) + bindings ORM `import type`. + +**Encore in-app** (à migrer dans la lib ensuite) : `storeRegistry`, `AccountContext`, filtre d'**isolation** (`isolation.ts`) — distinct du filtre **ReadCap** de la lib ([[brief_2026-06-15_shared-wallet-shim]]). **TODO lib** : exposer une primitive `doc_create`/SPARQL côté lib qui utilise le `ng` injecté (évite le double-proxy) pour que l'app n'ait plus jamais besoin du `ng` direct. ## Open Questions diff --git a/src/shared/test-harness/harness-ng.tsx b/src/shared/test-harness/harness-ng.tsx index 821d115..88b68cf 100644 --- a/src/shared/test-harness/harness-ng.tsx +++ b/src/shared/test-harness/harness-ng.tsx @@ -11,10 +11,13 @@ import React, { useEffect, useState } from 'react'; import { createRoot } from 'react-dom/client'; import { NextGraphProvider, useNextGraph } from '../context/NextGraphContext'; import { FestipodDataProvider, useFestipodData } from '../context/FestipodDataContext'; -// useShape + ng routed through the lib (SDK-identical surface); caps from /polyfill. -import { useShape, ng } from '@ng-eventually/client'; +// useShape routed through the lib (SDK-identical surface); caps from /polyfill. +import { useShape } from '@ng-eventually/client'; import { getCaps, setCurrentUser, resetCaps } from '@ng-eventually/client/polyfill'; import type { DeepSignalSet } from '@ng-eventually/client'; +// doc_create goes straight to the real SDK: the lib's `ng` proxy over @ng-org's +// iframe-RPC proxy breaks doc_create's postMessage marshaling (see storeRegistry). +import { ng } from '@ng-org/web'; import { FpEventShapeType, FpUserProfileShapeType, diff --git a/src/shared/utils/storeRegistry.ts b/src/shared/utils/storeRegistry.ts index 46539c4..a17862e 100644 --- a/src/shared/utils/storeRegistry.ts +++ b/src/shared/utils/storeRegistry.ts @@ -25,7 +25,13 @@ * against the verified SDK surface but must be validated against a live broker. */ -import { ng } from '@ng-eventually/client'; +// doc_create / SPARQL go straight to the real SDK: the lib's `ng` proxy (a JS +// Proxy over @ng-org's iframe-RPC proxy) breaks doc_create's postMessage +// marshaling (DataCloneError). useShape/login/ReadCap DO route through the lib; +// this low-level path stays direct until storeRegistry moves INTO the lib (where +// it would use the injected real ng, no double-proxy). See +// decision_2026-06-17_eventually-library. +import { ng } from '@ng-org/web'; import { sessionPromise } from './ngSession'; import { normalizeUsername } from '../context/AccountContext';