Repository navigation
Refactor UpdateSource type system for clarity and correctness - #413
Merged
Merged
Conversation
…393) **Problem:** The UpdateSource type conflated two orthogonal concepts: 1. Data origin (where did the update come from?) 2. Persistence state (should this be persisted to database?) This led to: - Confusing dual meaning of 'database' type - Misuse of 'external' type as workaround for persistence control - Navigation service bug using 'external' instead of 'database' - No explicit API for persistence control **Solution: Explicit Persistence API (Option C)** **Phase 1: Add Explicit Persistence Control** - Added `persist` option to UpdateOptions: false | true | 'debounced' | 'immediate' - Added `markAsPersistedOnly` option to explicitly track backend-loaded nodes - Maintains backward compatibility with legacy source.type checks **Phase 2: Migrate SharedNodeStore** - Created `determinePersistenceBehavior()` helper method - Migrated all 3 locations checking `source.type === 'database'` - updateNode(), setNode(), deleteNode() now use explicit API **Phase 3: Clarify UpdateSource Semantics** - Added comprehensive JSDoc explaining data provenance vs persistence - Documented that UpdateOptions.persist controls persistence, not source.type **Phase 4: Remove 'external' Type** - Replaced 'external' workaround in shared-node-store.ts reconciliation - Replaced 'external' workaround in reactive-node-service.svelte.ts combineNodes - Updated all test files to use 'database' or 'mcp-server' appropriately - Removed 'external' from UpdateSource union type **Phase 5: Add Tests and Documentation** - Added 3 comprehensive tests for new explicit persistence API - Tests verify persist: false, markAsPersistedOnly, and legacy behavior - All existing 1486 tests still pass, now 1490 total (+4 new tests) **Files Changed:** - types/update-protocol.ts: New persistence options, removed 'external' type - services/shared-node-store.ts: Explicit persistence helper + usage - services/reactive-node-service.svelte.ts: Fixed 'external' workaround - tests/*: Updated all test files, added comprehensive test coverage **Test Results:** - Frontend: ✅ 1490 passed | 48 skipped (1538 total) - All quality checks pass **Migration Path:** - Backward compatible: Legacy `source.type === 'database'` still works - New code should use explicit `options.persist` instead - Clear migration path for future MCP integration (Phase 3) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Implemented 2 of 3 review recommendations from PR #413: 1. ✅ API Naming Clarity (🟢 Suggestion): - Enhanced JSDoc for persist option to explicitly clarify persist: true vs undefined - Added explanation of difference between auto-determined modes - Included new example showing persist: true usage for structural changes 2. ✅ Test Coverage Gap (🟢 Suggestion): - Added explicit test for persist: true behavior with structural changes - Test verifies immediate persistence triggering (not debounced) - Documents expected behavior with clear comments - Increased test count from 1490 to 1491 (all passing) 3. ⏭️ Migration Documentation (🟢 Suggestion - SKIPPED): - Rationale: Inline JSDoc already provides comprehensive migration examples - Commit message documents rationale extensively - Separate migration guide would duplicate existing documentation - Decision: Skip for now, revisit if multiple related migrations accumulate All quality checks pass, no lint/format issues. Test Results: ✅ 1491 passed | 48 skipped (1539 total) Addresses reviewer recommendations from pragmatic-code-review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Collaborator
Author
Review Feedback AddressedSuccessfully implemented 2 of 3 review recommendations: ✅ Implemented Changes1. API Naming Clarity (🟢 Suggestion)
2. Test Coverage Gap (🟢 Suggestion)
⏭️ Skipped Recommendation3. Migration Documentation (🟢 Suggestion - SKIPPED)
Test Results✅ 1491 passed | 48 skipped (1539 total) Commit
Ready for final review. All non-blocking suggestions addressed with thoughtful engineering judgment applied to the skipped recommendation. |
malibio
added a commit
that referenced
this pull request
Feb 4, 2026
* Refactor UpdateSource type system for clarity and correctness (Issue #393) **Problem:** The UpdateSource type conflated two orthogonal concepts: 1. Data origin (where did the update come from?) 2. Persistence state (should this be persisted to database?) This led to: - Confusing dual meaning of 'database' type - Misuse of 'external' type as workaround for persistence control - Navigation service bug using 'external' instead of 'database' - No explicit API for persistence control **Solution: Explicit Persistence API (Option C)** **Phase 1: Add Explicit Persistence Control** - Added `persist` option to UpdateOptions: false | true | 'debounced' | 'immediate' - Added `markAsPersistedOnly` option to explicitly track backend-loaded nodes - Maintains backward compatibility with legacy source.type checks **Phase 2: Migrate SharedNodeStore** - Created `determinePersistenceBehavior()` helper method - Migrated all 3 locations checking `source.type === 'database'` - updateNode(), setNode(), deleteNode() now use explicit API **Phase 3: Clarify UpdateSource Semantics** - Added comprehensive JSDoc explaining data provenance vs persistence - Documented that UpdateOptions.persist controls persistence, not source.type **Phase 4: Remove 'external' Type** - Replaced 'external' workaround in shared-node-store.ts reconciliation - Replaced 'external' workaround in reactive-node-service.svelte.ts combineNodes - Updated all test files to use 'database' or 'mcp-server' appropriately - Removed 'external' from UpdateSource union type **Phase 5: Add Tests and Documentation** - Added 3 comprehensive tests for new explicit persistence API - Tests verify persist: false, markAsPersistedOnly, and legacy behavior - All existing 1486 tests still pass, now 1490 total (+4 new tests) **Files Changed:** - types/update-protocol.ts: New persistence options, removed 'external' type - services/shared-node-store.ts: Explicit persistence helper + usage - services/reactive-node-service.svelte.ts: Fixed 'external' workaround - tests/*: Updated all test files, added comprehensive test coverage **Test Results:** - Frontend: ✅ 1490 passed | 48 skipped (1538 total) - All quality checks pass **Migration Path:** - Backward compatible: Legacy `source.type === 'database'` still works - New code should use explicit `options.persist` instead - Clear migration path for future MCP integration (Phase 3) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address review: Improve persist option documentation and test coverage Implemented 2 of 3 review recommendations from PR #413: 1. ✅ API Naming Clarity (🟢 Suggestion): - Enhanced JSDoc for persist option to explicitly clarify persist: true vs undefined - Added explanation of difference between auto-determined modes - Included new example showing persist: true usage for structural changes 2. ✅ Test Coverage Gap (🟢 Suggestion): - Added explicit test for persist: true behavior with structural changes - Test verifies immediate persistence triggering (not debounced) - Documents expected behavior with clear comments - Increased test count from 1490 to 1491 (all passing) 3. ⏭️ Migration Documentation (🟢 Suggestion - SKIPPED): - Rationale: Inline JSDoc already provides comprehensive migration examples - Commit message documents rationale extensively - Separate migration guide would duplicate existing documentation - Decision: Skip for now, revisit if multiple related migrations accumulate All quality checks pass, no lint/format issues. Test Results: ✅ 1491 passed | 48 skipped (1539 total) Addresses reviewer recommendations from pragmatic-code-review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 5, 2026
* Refactor UpdateSource type system for clarity and correctness (Issue #393) **Problem:** The UpdateSource type conflated two orthogonal concepts: 1. Data origin (where did the update come from?) 2. Persistence state (should this be persisted to database?) This led to: - Confusing dual meaning of 'database' type - Misuse of 'external' type as workaround for persistence control - Navigation service bug using 'external' instead of 'database' - No explicit API for persistence control **Solution: Explicit Persistence API (Option C)** **Phase 1: Add Explicit Persistence Control** - Added `persist` option to UpdateOptions: false | true | 'debounced' | 'immediate' - Added `markAsPersistedOnly` option to explicitly track backend-loaded nodes - Maintains backward compatibility with legacy source.type checks **Phase 2: Migrate SharedNodeStore** - Created `determinePersistenceBehavior()` helper method - Migrated all 3 locations checking `source.type === 'database'` - updateNode(), setNode(), deleteNode() now use explicit API **Phase 3: Clarify UpdateSource Semantics** - Added comprehensive JSDoc explaining data provenance vs persistence - Documented that UpdateOptions.persist controls persistence, not source.type **Phase 4: Remove 'external' Type** - Replaced 'external' workaround in shared-node-store.ts reconciliation - Replaced 'external' workaround in reactive-node-service.svelte.ts combineNodes - Updated all test files to use 'database' or 'mcp-server' appropriately - Removed 'external' from UpdateSource union type **Phase 5: Add Tests and Documentation** - Added 3 comprehensive tests for new explicit persistence API - Tests verify persist: false, markAsPersistedOnly, and legacy behavior - All existing 1486 tests still pass, now 1490 total (+4 new tests) **Files Changed:** - types/update-protocol.ts: New persistence options, removed 'external' type - services/shared-node-store.ts: Explicit persistence helper + usage - services/reactive-node-service.svelte.ts: Fixed 'external' workaround - tests/*: Updated all test files, added comprehensive test coverage **Test Results:** - Frontend: ✅ 1490 passed | 48 skipped (1538 total) - All quality checks pass **Migration Path:** - Backward compatible: Legacy `source.type === 'database'` still works - New code should use explicit `options.persist` instead - Clear migration path for future MCP integration (Phase 3) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address review: Improve persist option documentation and test coverage Implemented 2 of 3 review recommendations from PR #413: 1. ✅ API Naming Clarity (🟢 Suggestion): - Enhanced JSDoc for persist option to explicitly clarify persist: true vs undefined - Added explanation of difference between auto-determined modes - Included new example showing persist: true usage for structural changes 2. ✅ Test Coverage Gap (🟢 Suggestion): - Added explicit test for persist: true behavior with structural changes - Test verifies immediate persistence triggering (not debounced) - Documents expected behavior with clear comments - Increased test count from 1490 to 1491 (all passing) 3. ⏭️ Migration Documentation (🟢 Suggestion - SKIPPED): - Rationale: Inline JSDoc already provides comprehensive migration examples - Commit message documents rationale extensively - Separate migration guide would duplicate existing documentation - Decision: Skip for now, revisit if multiple related migrations accumulate All quality checks pass, no lint/format issues. Test Results: ✅ 1491 passed | 48 skipped (1539 total) Addresses reviewer recommendations from pragmatic-code-review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 26, 2026
* Refactor UpdateSource type system for clarity and correctness (Issue #393) **Problem:** The UpdateSource type conflated two orthogonal concepts: 1. Data origin (where did the update come from?) 2. Persistence state (should this be persisted to database?) This led to: - Confusing dual meaning of 'database' type - Misuse of 'external' type as workaround for persistence control - Navigation service bug using 'external' instead of 'database' - No explicit API for persistence control **Solution: Explicit Persistence API (Option C)** **Phase 1: Add Explicit Persistence Control** - Added `persist` option to UpdateOptions: false | true | 'debounced' | 'immediate' - Added `markAsPersistedOnly` option to explicitly track backend-loaded nodes - Maintains backward compatibility with legacy source.type checks **Phase 2: Migrate SharedNodeStore** - Created `determinePersistenceBehavior()` helper method - Migrated all 3 locations checking `source.type === 'database'` - updateNode(), setNode(), deleteNode() now use explicit API **Phase 3: Clarify UpdateSource Semantics** - Added comprehensive JSDoc explaining data provenance vs persistence - Documented that UpdateOptions.persist controls persistence, not source.type **Phase 4: Remove 'external' Type** - Replaced 'external' workaround in shared-node-store.ts reconciliation - Replaced 'external' workaround in reactive-node-service.svelte.ts combineNodes - Updated all test files to use 'database' or 'mcp-server' appropriately - Removed 'external' from UpdateSource union type **Phase 5: Add Tests and Documentation** - Added 3 comprehensive tests for new explicit persistence API - Tests verify persist: false, markAsPersistedOnly, and legacy behavior - All existing 1486 tests still pass, now 1490 total (+4 new tests) **Files Changed:** - types/update-protocol.ts: New persistence options, removed 'external' type - services/shared-node-store.ts: Explicit persistence helper + usage - services/reactive-node-service.svelte.ts: Fixed 'external' workaround - tests/*: Updated all test files, added comprehensive test coverage **Test Results:** - Frontend: ✅ 1490 passed | 48 skipped (1538 total) - All quality checks pass **Migration Path:** - Backward compatible: Legacy `source.type === 'database'` still works - New code should use explicit `options.persist` instead - Clear migration path for future MCP integration (Phase 3) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address review: Improve persist option documentation and test coverage Implemented 2 of 3 review recommendations from PR #413: 1. ✅ API Naming Clarity (🟢 Suggestion): - Enhanced JSDoc for persist option to explicitly clarify persist: true vs undefined - Added explanation of difference between auto-determined modes - Included new example showing persist: true usage for structural changes 2. ✅ Test Coverage Gap (🟢 Suggestion): - Added explicit test for persist: true behavior with structural changes - Test verifies immediate persistence triggering (not debounced) - Documents expected behavior with clear comments - Increased test count from 1490 to 1491 (all passing) 3. ⏭️ Migration Documentation (🟢 Suggestion - SKIPPED): - Rationale: Inline JSDoc already provides comprehensive migration examples - Commit message documents rationale extensively - Separate migration guide would duplicate existing documentation - Decision: Skip for now, revisit if multiple related migrations accumulate All quality checks pass, no lint/format issues. Test Results: ✅ 1491 passed | 48 skipped (1539 total) Addresses reviewer recommendations from pragmatic-code-review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
mstomar125
added a commit
that referenced
this pull request
Aug 11, 2026
…(nodespace-sync#413 core half) (#2029) * Surface access-gated cascade-delete refusal as a distinct typed error + modal The SubtreeAccessGate seam (ADR-041) already refused a cascade delete whose subtree contains nodes the caller can't read, but mapped it to a generic HierarchyViolation → INVALID_ARGUMENT, indistinguishable from ordinary validation — so the frontend couldn't tell a refusal apart. Make it a first-class, user-visible outcome: - New NodeServiceError::SubtreeAccessDenied { inaccessible_count } (not the shared bare-string HierarchyViolation); the gate's Denied branch returns it. - New OpsError::SubtreeAccessDenied → maps to gRPC Status::failed_precondition with the count in x-subtree-inaccessible-count metadata (mirroring how a version conflict carries x-version-conflict), so the status is distinct from validation and from OCC. - Frontend: status_to_command_error → a SUBTREE_ACCESS_DENIED command code carrying { inaccessibleCount }; an isSubtreeAccessDenied guard; a global refusal modal ("N item(s) not visible — nothing was deleted"). - The delete is optimistic (the node is removed locally before the backend call), so on a refusal the store restores exactly what the optimistic removal stripped (node, version, persisted-set membership, subscriber notify) and shows the modal. Descendants are only removed via post-commit events, which never fire on a refusal, so restoring the target node is sufficient. Community/no-Pro path is unchanged (AlwaysAllowGate never denies). This is the core half of sync#413; the daemon-side gate that actually calls the cloud subtree_inaccessible_count, and live validation, follow separately. Part of #413. Co-Authored-By: Claude Opus 4.8 <[email protected]> * Address review: restore the view layer on refusal; scope the refusal code Two real defects from review: - The optimistic restore lived only at the store layer, but the reactive view service owns `_rootNodeIds` (the top-level view's source of truth) and strips the node from it synchronously — so a refused top-level delete restored the store yet the node stayed gone from the UI. The store's deleteNode now takes an `onRefused` callback it invokes (after restoring its own state) so the view service restores `_rootNodeIds`/`_uiState` too. The store delete is fire-and-forget, so this callback is how the refusal (which lands async) reaches the view layer. Covered by store-level onRefused tests (fires on a refusal, not on success or a non-refusal error). - status_to_command_error branded EVERY FailedPrecondition as SUBTREE_ACCESS_DENIED, but the daemon returns FailedPrecondition from unrelated paths (node-create / schema failures). Now the code is assigned only when the x-subtree-inaccessible-count metadata is actually present; otherwise it falls through to GRPC_ERROR. Also (minor): renamed the version-conflict precedence test to say what it verifies (conflict reported when the gate allows) and added a genuine both-true test asserting the access refusal PRECEDES the version conflict — the gate runs before the OCC check, so we never leak version state on an access denial. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #393