Repository navigation
C3a: Delete frontend outdent ordering math — trust the daemon's authoritative order via relationship events - #1263
Conversation
…ve order via relationship events (#1259) Remove `calculateOutdentInsertOrderPure` / `calculateOutdentInsertOrder` and the three optimistic call sites that passed a hand-computed fractional order to `moveInMemoryRelationship`. Optimistic outdent placement now uses relative-after intent (no order arg); the authoritative float arrives via the `relationship:updated` event and is applied by `applyHasChildUpdated`. Also removes `Math.random() * 0.001` jitter from the `has_child:created` fallback in `hierarchy-sync.ts` — the append path now uses an exact integer increment and logs a warning, consistent with the `relationship:updated` anomaly path. Tests added: - `hierarchy-sync.test.ts`: determinism (no jitter), convergence (optimistic→daemon order) - `outdent-ordering.test.ts`: all `moveInMemoryRelationship` calls from outdentNode are jitter-free (no fractional midpoints as the 4th arg) - `move_node_ordering_test.rs`: Rust integration test locking the `InsertPosition::After` contract — verifies `RelationshipUpdated` emits a finite positive order, and that the emitted order is strictly between its left and right siblings Co-Authored-By: Claude <[email protected]>
Code Review SummaryThis PR delivers C3a cleanly. The core architectural objective — eliminating the frontend's duplicate fractional-order calculation and replacing it with daemon-authoritative order via The diff is focused and cohesive: 47 lines of production code deleted (the two functions plus three call sites), one line replaced in Below are findings ordered by severity. FindingsImprovements
The second test ( To cover the not-yet-persisted branch properly, the child should be set with a viewer source (e.g. This does not block merge — the main behavioral objective is correctly tested — but the two unpersisted outdent paths from the acceptance criteria (
When newOrder = existingChildren.length > 0 ? existingChildren.length + 1.0 : 1.0;This uses the count of children, not the maximum order value. If any child has an order greater than
Nitpicks
Acceptance Criteria Status
Verdict: Approve with the above noted. The mislabeled test is the most meaningful finding but does not introduce a regression — it just leaves two specific code branches (cancel-pending-CREATE and in-flight-CREATE-executing) without targeted test coverage. The PR is a clear net improvement and safe to merge. |
malibio
left a comment
There was a problem hiding this comment.
Review verdict: Approve. Approving — net improvement with no regressions. Key finding: the second test in outdent-ordering.test.ts is mislabeled (uses source.type: 'database' which marks the node as persisted, so it exercises the MOVE path, not the not-yet-persisted CREATE-cancel path as the test description claims). The two unpersisted-branch variants from the acceptance criteria are untested but this does not block merge. Full findings in the review comment above.
- Fix moveInMemoryRelationship fallback: use lastChild.order+1 (value-based) instead of children.length+1 (count-based) to match applyHasChildCreated and avoid order collisions after daemon reconciliation assigns fractional values - Fix mislabeled NOT-YET-PERSISTED test: use viewer source so child is not added to persistedNodeIds, actually exercising the CREATE-cancel/in-flight branches rather than the persisted MOVE path - Defensive Rust test: loop until RelationshipUpdated received instead of assuming first event is the right type - Remove orphaned JS arithmetic assertions (2+3)/2 and (2+2.5)/2 that prove an arithmetic identity, not a system property - Update stale comment: replace "pre-calculating fractional order values" with "pre-issuing all move RPCs" to reflect daemon-owned ordering Co-Authored-By: Claude <[email protected]>
Review Feedback AddressedAll reviewer recommendations addressed in follow-up commit. ✅ Changes Made
|
…ritative order via relationship events (#1263) * C3a: Delete frontend outdent ordering math — trust daemon authoritative order via relationship events (#1259) Remove `calculateOutdentInsertOrderPure` / `calculateOutdentInsertOrder` and the three optimistic call sites that passed a hand-computed fractional order to `moveInMemoryRelationship`. Optimistic outdent placement now uses relative-after intent (no order arg); the authoritative float arrives via the `relationship:updated` event and is applied by `applyHasChildUpdated`. Also removes `Math.random() * 0.001` jitter from the `has_child:created` fallback in `hierarchy-sync.ts` — the append path now uses an exact integer increment and logs a warning, consistent with the `relationship:updated` anomaly path. Tests added: - `hierarchy-sync.test.ts`: determinism (no jitter), convergence (optimistic→daemon order) - `outdent-ordering.test.ts`: all `moveInMemoryRelationship` calls from outdentNode are jitter-free (no fractional midpoints as the 4th arg) - `move_node_ordering_test.rs`: Rust integration test locking the `InsertPosition::After` contract — verifies `RelationshipUpdated` emits a finite positive order, and that the emitted order is strictly between its left and right siblings Co-Authored-By: Claude <[email protected]> * Address review feedback on C3a PR #1263 - Fix moveInMemoryRelationship fallback: use lastChild.order+1 (value-based) instead of children.length+1 (count-based) to match applyHasChildCreated and avoid order collisions after daemon reconciliation assigns fractional values - Fix mislabeled NOT-YET-PERSISTED test: use viewer source so child is not added to persistedNodeIds, actually exercising the CREATE-cancel/in-flight branches rather than the persisted MOVE path - Defensive Rust test: loop until RelationshipUpdated received instead of assuming first event is the right type - Remove orphaned JS arithmetic assertions (2+3)/2 and (2+2.5)/2 that prove an arithmetic identity, not a system property - Update stale comment: replace "pre-calculating fractional order values" with "pre-issuing all move RPCs" to reflect daemon-owned ordering Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude <[email protected]>
Closes #1259