Repository navigation
C4: Deduplicate the sync-boundary normalizeNodeData (one shared normalizer for both sync paths) - #1267
Conversation
closes #1266) Both sync paths (Tauri domain events and browser SSE) had byte-identical normalizeNodeData implementations that would drift the moment a new type branch was added to one and missed in the other. Extract to a single authoritative function in services/node-normalize.ts; both callers import it. Adds a parity test that guards against future divergence. Note: the three chat message shapes (protocol/view-model/persisted) and nodeToTaskNode are deliberate layering and are left untouched per the issue spec. Co-Authored-By: Claude <[email protected]>
Code Review SummaryThis is a clean, well-scoped extraction. The change is unambiguously net-positive: a byte-identical duplicated function is replaced by a single canonical implementation, both callers are updated, all unused imports are pruned, and a test suite is added. No architectural regressions, no security surface changes, no FindingsCritical IssuesNone. Suggested Improvements
The "Tauri path and browser path produce identical output" test calls The true anti-drift protection is structural: there is now only one definition of NitpicksNit: Nit: Checklist Against Acceptance Criteria
Decision: APPROVE — the improvement note on the parity test's structural framing is advisory. It does not affect correctness or the drift-prevention guarantee (which is already delivered by the single-definition architecture). Safe to merge as-is. |
malibio
left a comment
There was a problem hiding this comment.
Clean extraction with correct structural guarantee. One advisory note on the parity test framing (calling the same function twice is tautological — the drift-prevention is architectural, not test-level), but this does not affect correctness or safety. LGTM.
…tion contract test The dual-invocation pattern (calling normalizeNodeData twice and comparing) was logically guaranteed to pass by construction. The real anti-drift protection is structural — one function definition. Replace with a single test that asserts the complete transformation contract (status, priority, dueDate, id, content), with a comment explaining the architectural guarantee. Co-Authored-By: Claude <[email protected]>
Address-Review SummaryAddressed: 1 recommendation 🟢 Parity test refactored (advisory suggestion)Replaced the tautological dual-invocation pattern (calling No re-review needed — this is a pure test-quality improvement with no logic changes. |
…lizer for both sync paths) (#1267) * C4: Extract duplicated normalizeNodeData into shared node-normalize.ts (closes #1266) Both sync paths (Tauri domain events and browser SSE) had byte-identical normalizeNodeData implementations that would drift the moment a new type branch was added to one and missed in the other. Extract to a single authoritative function in services/node-normalize.ts; both callers import it. Adds a parity test that guards against future divergence. Note: the three chat message shapes (protocol/view-model/persisted) and nodeToTaskNode are deliberate layering and are left untouched per the issue spec. Co-Authored-By: Claude <[email protected]> * Address review: replace tautological parity test with full transformation contract test The dual-invocation pattern (calling normalizeNodeData twice and comparing) was logically guaranteed to pass by construction. The real anti-drift protection is structural — one function definition. Replace with a single test that asserts the complete transformation contract (status, priority, dueDate, id, content), with a comment explaining the architectural guarantee. Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude <[email protected]>
Closes #1266