Context. surface studio · domain collaboration · route /studio/real-time-collaboration-substrate · auth signed-in + studio entitlement · source apps/oshun/web/src/app/studio/real-time-collaboration-substrate/page.tsx
Last walked. 2026-06-30 crdt-merge real-BFF addendum — Playwright now covers the admin-scoped route render, real CRDT catalog GET, default replica operation merge POST/result, LWW add-biased tie semantics, element table, quick-action targets, catalog loading/error state, malformed JSON client block, live BFF 400 detail, non-admin fail-closed, and anonymous redirect-before-render. Evidence: WALKTHROUGH/results/v1-real-infra-run-2026-06-22.md §246; spec: apps/oshun/web/e2e/studio-real-time-collaboration-substrate.spec.ts. 2026-05-29 automated runtime walk (Playwright headless) — render, /v1 data (2xx), console/page-errors, expected content, screenshot verified; live screen-reader, touch, offline, and telemetry-delivery checks pending a manual AT pass. Evidence: WALKTHROUGH/results/runtime-sweep-2026-05-29.md; content re-verified 2026-06-03 against current source
Purpose#
Operate the real-time collaboration substrate as a live, admin-scoped BFF
console. The workspace (StudioRealTimeCollaborationSubstrateWorkspace) wires a
single CRDT Merge Lane to the real LWW-Element-Set (Last-Writer-Wins
Element-Set) CRDT via /v1/admin/studio/crdt-merge: it folds replica operation
logs into the convergent shared state. Each element is present when its latest
add is not superseded by a later remove, and the converged state is the same
regardless of operation order. This is a real domain computation, not a
simulation.
Entry points#
- Studio root (
/studio) — discoverable as a collaboration workspace - Quick-action links from sibling collaboration workspaces (presence, commenting, review/approval, activity/change feeds, notification center, audit/compliance surfaces)
- Direct URL / bookmark — yes
Layout regions#
page.tsx mounts ShellLayout active="studio", renders
StudioRealTimeCollaborationSubstrateWorkspace, then a single panel
containing 6 sibling quickAction links. There is no Route Map panel on this
page.
- Shell header — from
ShellLayout - Workspace
<h1>— "Studio Real-Time Collaboration Substrate" (WorkspaceHeading), followed by adata-realtime-collaboration-summaryparagraph describing the merge semantics - CRDT Merge Lane (
<h2>data-cr-lane-heading"CRDT Merge Lane") — the catalog/loading/unauthorized/error states, the merge form, and the result - Quick-actions panel —
panelwith 6quickActionlinks to sibling workspaces (no self-link, no Route Map)
States#
- Loading —
data-cr-loading"Loading CRDT merger…" while the GET catalog request is in flight (outcome === null) - Unauthorized —
data-cr-unauthorized"Access restricted." when the catalog GET returns 401/403 (admin scope required); shows the BFF message or "Studio admin scope required to merge CRDT state." - Error —
data-cr-error"Could not load the CRDT merger." on any non-OK catalog response or network failure - Ready (form) — catalog loaded;
data-cr-enumsshows{crdtType} · {opKinds.length} op kinds, and thedata-cr-formmerge form renders - Result — after a successful POST,
data-cr-resultrenders the converged headline + per-element table - Merge validation error —
data-cr-merge-errorfor invalid JSON, network unavailable, or a non-200 POST (shows the POSTdetail) - Anonymous user — redirected to
/welcome?redirect=%2Fstudio%2Freal-time-collaboration-substratebefore the workspace root renders
Interactions#
CRDT Merge Lane form#
- Operations (
textareadata-cr-payload, aria-labeloperations json) — JSON{ operations[{ replicaId, element, op, timestamp }] }; seeded with a default payload - Merge replicas (
buttondata-cr-submit,type="submit") —submitMergeparses the JSON (rejecting invalid JSON withdata-cr-merge-error) and POSTs to/v1/admin/studio/crdt-merge/merge - Client-side malformed JSON block — invalid JSON surfaces "Payload must be valid JSON." and does not send a POST
- Live BFF invalid payload branch — valid JSON with
operations: []reaches the BFF and surfaces detail "operations must be a non-empty array" - LWW tie semantics — a shuffled payload where
tiehas add/remove at timestamp7rendersdata-present="true", proving the add-biased tie-breaker over the real BFF merge route
Result#
- Headline (
data-cr-headline) — renders:converged: <data-cr-converged>plus{presentCount} presentand{removedCount} removed - Elements table (
data-cr-elements) — onedata-cr-element-rowper element withdata-element,data-present, plusdata-cr-add-ts/data-cr-remove-tscells
Quick actions#
- Open Presence and Cursor Systems workspace
- Open Commenting and Annotation System workspace
- Open Review and Approval Workflows workspace
- Back to Activity and Change Feeds workspace
- Back to Notification Center workspace
- Back to Audit and Compliance Surfaces workspace
Data & contracts#
- GET catalog:
/v1/admin/studio/crdt-merge— fetched on mount withbuildBffAuthHeaders()andcache: 'no-store'; returns{ opKinds[], crdtType } - POST verb:
/v1/admin/studio/crdt-merge/mergewith body{ operations[{ replicaId, element, op, timestamp }] }→{ result: { elements[], converged[], summary{ presentCount, removedCount } } }(200) or adetailerror - Realtime: none — request/response only
- Client fetch: direct
fetchwithcache: 'no-store'; no client-side caching - Auth/role check: admin-scoped, fail-closed at the BFF (
admin:*|admin:studio; 401 missing auth, 403 missing scope); reached through the signed-in + studio route gate
Cross-references#
- Parent:
../studio-overview.md - Sibling:
studio-presence-cursor-systems.md,studio-commenting-annotation-system.md,studio-review-approval-workflows.md - Component:
apps/oshun/web/src/components/studio/StudioRealTimeCollaborationSubstrateWorkspace.tsx - BFF route:
apps/oshun/bff/src/routes/admin-studio-crdt-merge.ts - BFF store:
apps/oshun/bff/src/studio/crdt-lww-store.ts
E2E coverage#
apps/oshun/web/e2e/studio-real-time-collaboration-substrate.spec.ts— signed-in admin/studio/real-time-collaboration-substraterender; real CRDT catalog GET with admin bearer; default operation-log merge POST through the live BFF; converged headline andx/y/zelement timestamp/presence rows; shuffled-payload add-biased LWW tie proof; six sibling quick-action links; catalog loading/error; client-side malformed JSON zero-POST; live BFF 400 invalid-payload detail; non-admin 403 fail-closed; anonymous redirect-before-render.apps/oshun/web/e2e/studio-route-render-smoke.spec.ts— broad Studio route render and accessibility smoke coverage includes this route, but does not replace the focused real-BFF CRDT spec above.
Open questions / known gaps#
- Confirm whether a future revision will persist merged CRDT state, or whether the lane stays a stateless merge console
- Document op-kind extensibility (
OP_KINDS) if kinds beyond add/remove are introduced - Live screen-reader and touch-device manual passes remain outside the automated route spec