fix(client): per-entity write round-trip + dedicated inbox anchor
Real-broker validation of the per-document model surfaced round-trip breaks the fake-ng unit tests missed: - The inbox anchor was the shim graph itself, making loadShim ~60s; give the inbox its own document so anchor resolution is fast and isolated. - store-registry adjustments so per-entity documents created via the SDK are indexed and readable back through the scope fan-out. docs/simulation.md updated. 89 tests pass; tsc rc=0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -315,15 +315,31 @@ export async function resolveScopeGraph(scope: Scope): Promise<Nuri> {
|
||||
return scopeStoreNuri(scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* The reserved account that OWNS the shared registration-inbox document. Like the
|
||||
* discovery index's special account, it lives in the reserved namespace (no user
|
||||
* can produce this key) and only HOSTS a document — its `public` scope document is
|
||||
* the inbox anchor. Disappears at migration (native per-document inboxes).
|
||||
*/
|
||||
const INBOX_ANCHOR_ACCOUNT = reservedAccount("inbox");
|
||||
|
||||
/**
|
||||
* The inbox anchor NURI for the current session (where emulated inbox deposits
|
||||
* physically land). SDK-shaped: the consumer never resolves the private store
|
||||
* itself. In the polyfill this is the shared wallet's private store (a real
|
||||
* repo NURI — required because the broker rejects a `urn:` anchor); at
|
||||
* migration it becomes the host's native inbox and this resolution moves here.
|
||||
* physically land). SDK-shaped: the consumer never resolves a store itself.
|
||||
*
|
||||
* This is a DEDICATED inbox DOCUMENT (a reserved account's public scope document —
|
||||
* a real repo NURI from `docCreate`, stable across clients via the shim), NOT the
|
||||
* shared wallet's private-store root. Reason (perf + hygiene): the shim (the
|
||||
* account→document trust root) lives in the private-store graph and is scanned on
|
||||
* every `loadShim`; routing every inbox deposit into that SAME graph bloats it
|
||||
* without bound (thousands of deposit triples across sessions), turning `loadShim`
|
||||
* into a multi-second full-graph scan. A separate inbox document keeps the shim
|
||||
* graph small and the deposits isolated. At migration this becomes the host's
|
||||
* native per-document inbox and the resolution moves here.
|
||||
*/
|
||||
export async function resolveInboxAnchor(): Promise<Nuri> {
|
||||
return scopeStoreNuri("private");
|
||||
const record = await ensureAccount(INBOX_ANCHOR_ACCOUNT);
|
||||
return record.docPublic;
|
||||
}
|
||||
|
||||
// --- per-entity documents + per-scope index -------------------------------
|
||||
|
||||
Reference in New Issue
Block a user