test: codify space-detection commit visibility - #613
Conversation
Aymericr
left a comment
There was a problem hiding this comment.
This is what #586 was asking for, and the diagnosis is right — the comment at initSpaceDetectionSync names the actual mechanism (zundo snapshots after subscribers return), and the test is the guard that would have gone red on #554 instead of us catching the missing slab and ceiling by measurement. The wiki page covering both directions, including the origin: 'host' / readOnly half, is more than I expected.
Three things before I merge:
- Rebase.
space-detection.tshas grown about 750 lines since you branched and the anchor moved, andspace-detection.test.tsnow importsrunWithSceneCommitNodeIdsfrom../store/history-control, so your new import from that module conflicts. Mechanical, but please confirm the test still passes after. - Say why the real store. Every other test in that file uses the minimal store stand-ins. Driving the real
useScenesingleton is the right call here — a stub can't exercise the zundo boundary you're asserting — but it looks like an oversight without a line saying so. Please also restoreuseScenestate in thefinally, not justclearSceneHistory(), so the singleton mutation can't leak into a later test. - Retitle to
test:— there's no behavior change in the diff, andfix:will read wrong in the changelog.
One note so it doesn't surprise you: my follow-up on #586 widened the ask to an equivalence harness (scoped reconciliation must produce the same spaces and surfaces as a full detectSpacesFromWalls). That's for the TopologyIndex work when it returns, not a condition on this. Your commit-visibility assertion stands on its own and I want it in main now.
Adds the regression guard that would have gone red on pascalorg#554: asserts the derived slab/ceiling writes land inside the originating local SceneCommit rather than after it, plus a comment at initSpaceDetectionSync naming the zundo snapshot boundary that makes the synchronous store subscription the required home for reconciliation. The test drives the real useScene singleton rather than the minimal store stand-ins the rest of the file uses, because a stub cannot exercise that boundary. It captures and restores the singleton's state in the finally block so the mutation cannot leak into a later test. No behavior change, hence test: rather than fix:.
cfb544a to
1d573d3
Compare
|
All three done. Rebased. Onto current main (81 commits). Two conflicts, both from the growth you flagged: Said why the real store. The test now carries a line stating that the real Retitled to Noted on the equivalence harness being scoped to the |
|
Verified the rebase — parent is One thing left, and it's yours: the red quality check is formatting only. The import you hand-merged at I retitled the PR to Fix the line and I'll merge. |
|
Fixed in b00703c — Quality is green now, which means the suite actually ran on this head for the first time: 62 pass, 0 fail, 241 expect() calls. That's the 62/62 you were waiting on. Thanks for the retitle catch on the squash title, and for verifying the rebase line by line. |
What does this PR do? / ## How to test / ## Screenshots / screen recording / ## Checklist (bun dev, bun check, docs, main-branch boxes)
Preserve
initSpaceDetectionSyncas a synchronous scene-store subscriber and add a focused rationale at that integration point explaining that reconciliation must finish within the triggering local transaction before its commit snapshot is emitted. Add an architecture page that defines the two-sided replication contract: local reconciliation output is included in the originating commit, while host patches consume those nodes under read-only mode rather than re-running reconciliation. Link that page from the architecture index so future changes to space detection, history pausing, or commit delivery encounter the invariant during design review.Fixes #586
Note
Low Risk
Tests and documentation only plus an explanatory comment; no changes to reconciliation scheduling or history pausing logic.
Overview
Locks in how wall-driven room reconciliation must interact with scene history and
SceneCommitsnapshots, without changing runtime behavior ininitSpaceDetectionSync.Adds an integration test on the real
useScenestore: placing the closing wall must yield one local commit whose snapshot includes auto slab/ceiling, reconciled wallfrontSide/backSide, and updated levelchildren, and one undo that removes the wall and generated surfaces together. Documents inspace-detection.tsthat reconciliation must stay in the synchronous scene-store subscriber (notsubscribeSceneCommits), because zundo emits the local commit after subscribers return and history-paused derived writes must land inside that boundary.Introduces
wiki/architecture/space-detection.md(linked from the architecture index) describing the two-sided contract: local edits reconcile synchronously into the originating commit; peers apply host patches without re-running detection or minting new IDs.Reviewed by Cursor Bugbot for commit b00703c. Bugbot is set up for automated code reviews on this repo. Configure here.