You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: wiki/architecture/README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@ Canonical rules for code that touches `packages/core`, `packages/viewer`, `packa
23
23
|[spatial-queries](spatial-queries.md)| Placement validation (`canPlaceOnFloor`/`Wall`/`Ceiling`) for tools |
24
24
|[node-schemas](node-schemas.md)| Zod schema pattern for node types, `createNode`, `updateNode`|
25
25
|[vertical-model](vertical-model.md)| Stored level heights, plane-bound wall/ceiling tops, slab placement + thickness, support hosts, clamp rules, and the load migration |
26
+
|[space-detection](space-detection.md)| Commit and replication contract for wall-driven room reconciliation |
26
27
|[events](events.md)| Typed event bus — emitting and listening to node and grid events |
27
28
|[creating-rules](creating-rules.md)| How to add or update a page in this folder |
*Commit and replication contract for wall-driven room reconciliation.*
4
+
5
+
Applies to: `packages/core/src/lib/space-detection.ts`, `packages/core/src/store/**`, and collaboration consumers of `SceneCommit`.
6
+
7
+
Space detection derives room state from wall geometry. Reconciliation updates wall side classifications, creates or updates automatic slabs and ceilings, and updates their level's `children`. Those derived writes are part of the wall edit that triggered them, not a later background operation.
8
+
9
+
## Local commit boundary
10
+
11
+
`initSpaceDetectionSync` must remain a synchronous scene-store subscriber. A local wall mutation and all reconciliation it triggers must finish before zundo emits the mutation's `SceneCommit` snapshot.
12
+
13
+
Reconciliation pauses scene history while applying derived writes. This keeps the triggering edit and its generated state in one undo step, while the outer tracked mutation still captures the final reconciled graph in `SceneCommit.current`. The emitted snapshot must therefore contain:
14
+
15
+
- the triggering wall edit;
16
+
- reconciled `frontSide` and `backSide` values;
17
+
- generated or updated automatic slabs and ceilings; and
18
+
- the corresponding level `children` updates.
19
+
20
+
Do not schedule reconciliation from `subscribeSceneCommits`. Commit listeners run after the snapshot boundary. Because reconciliation writes are history-paused, moving the work there would neither amend the emitted snapshot nor produce a second local commit, leaving collaboration consumers unable to transmit the generated state.
21
+
22
+
## Host patch consumption
23
+
24
+
The originating client is the only client that reconciles a local wall edit and mints IDs for generated room surfaces. Collaboration transports the resulting before/current difference, including the generated nodes and parent updates.
25
+
26
+
Receiving clients apply that transmitted graph as a host patch. Host application is history-paused and may run while the scene is read-only, so space detection must not regenerate the room locally. The receiver consumes the originator's slab and ceiling IDs and records no local undo entry or local commit for the host change.
27
+
28
+
This two-sided contract prevents peers from independently minting different IDs for the same room:
29
+
30
+
1. Local wall edit → synchronous reconciliation → one complete local commit and one undo step.
31
+
2. Host patch → apply the transmitted generated state → no local reconciliation or local history entry.
32
+
33
+
Changes to space-detection scheduling, history pausing, scene commit delivery, or host patch application must preserve both sides of this contract.
0 commit comments