Skip to content

Frontend dead-code cleanup: vestigial conflict/validation members + dead OptimisticOperationManager (C1b re-audit residue) - #1278

Merged
malibio merged 2 commits into
mainfrom
worktree-issue-1277-frontend-deadcode-cleanup
May 30, 2026
Merged

malibio merged 2 commits into
mainfrom
worktree-issue-1277-frontend-deadcode-cleanup

Conversation

@malibio

@malibio malibio commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Closes #1277

…ecated stubs (closes #1277)

Delete `validateNodeReferences` (deprecated stub), `ensureAncestorChainPersisted` (no-op),
the pre-C5 client-side conflict subsystem (`detectConflict`, `handleConflict`,
`setConflictResolver`/`getConflictResolver`, `conflictResolver` field, `createDefaultResolver`),
and `OptimisticOperationManager` (only imported by its own test; inline rollback already works).

Remove `Conflict`/`ConflictResolver`/`ConflictResolution` types and `skipConflictDetection` option
from `UpdateOptions` — the daemon is authoritative for OCC verdicts (ADR-026 C5 amendment);
`conflictNotifications` and the live OCC path in `updateNode`/`updateTaskNode` are untouched.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio

malibio commented May 30, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

This is a well-executed dead-code removal. The PR deletes ~1,400 lines and adds ~23, a healthy ratio for a cleanup task. All primary acceptance criteria from issue #1277 are met: the client-side conflict subsystem, OptimisticOperationManager, validateNodeReferences, and ensureAncestorChainPersisted are fully removed; the live daemon-OCC path (conflictNotifications, updateNode/updateTaskNode) is demonstrably untouched; svelte-check exits clean (0 errors, 0 warnings across 1,645 files); and all 3,833 frontend tests pass.

The stated risk in the issue — that detectConflict/conflictResolver was reachable via the live updateNode path — was correctly resolved: no production caller passes previousVersion to updateNode (only tests did). Removing the branch is safe.


Findings

Improvement — conflictCount in StoreMetrics is now permanently zero

StoreMetrics.conflictCount (update-protocol.ts:83) is initialized to 0 in three places in shared-node-store.svelte.ts (lines 485, 2641, 3190) but is never incremented. The only writer was handleConflict, which this PR deletes. The field is not read by any caller in the codebase.

This is not a correctness bug — the value is always 0, which is accurate post-cleanup — but the field is now semantically inert dead state. Per the project rule "delete dead code / no dead state," it should be removed from the StoreMetrics interface and from the three metric initializer objects in the store.

This is a one-liner follow-up, not a blocker, but it is a direct project-rule violation that this PR partially created.

Affected files:

  • packages/desktop-app/src/lib/types/update-protocol.ts (remove conflictCount: number from StoreMetrics)
  • packages/desktop-app/src/lib/services/shared-node-store.svelte.ts (remove conflictCount: 0 from the three metric initializer objects)

Nit — Two stale comment items from the issue are not addressed

The issue lists two stale comment items under "Stale comments (doc nits, low priority)":

  • reactive-node-service.svelte.ts:4-8 "Phase 1.2 / Backward compatible" header
  • reactive-node-service.svelte.ts:~1632 ReactiveNodeService alias-export comment

The Phase 1.2 header was addressed (the REFACTORED FOR MULTI-VIEWER SUPPORT (Phase 1.2): line and Backward compatible - existing API preserved bullet are gone). The alias-export stale comment (// For backward compatibility with existing imports) was also removed. Both are done. The issue marks these as low-priority and the PR commit message does not claim them — no action needed, noting this explicitly since the issue listed them as open items.


Nit — previousVersion field comment is slightly stale

NodeUpdate.previousVersion (update-protocol.ts:62) retains the comment // Previous version for conflict detection. Now that the client-side conflict subsystem is gone, the field's purpose is solely to support rollback (in rollbackUpdate). The comment is technically inaccurate.

// Before
previousVersion?: number; // Previous version for conflict detection

// After
previousVersion?: number; // Snapshot of version before update, used for rollback

Trivial and non-blocking.


Notes on Acceptance Criteria

Criterion Status
All five vestigial members + tests deleted; no @deprecated tags remain in the store Done
optimistic-operation-manager.svelte.ts + its test deleted Done
Confirmed no production caller passes previousVersion to updateNode Verified
conflictNotifications and daemon-OCC conflict path untouched Verified
Doc path + OOM claim fixed in frontend-state-and-persistence.md Deferred to separate doc/ PR in nodespace-docs (correct per issue scope)
No lint suppression; bun run test and bun run check green Verified: 3,833 tests pass, svelte-check 0 errors

Verdict: Approve with one recommended follow-up. The conflictCount dead-field is a CLAUDE.md rule violation worth cleaning up in a single-line follow-up (can be done before merge or as an immediate follow-on). The core cleanup is correct, complete, and safe to merge.

conflictCount in StoreMetrics was always zero after handleConflict was
deleted in the prior commit. Remove the field from the type and its three
initializer sites. Fix the previousVersion comment to describe its actual
purpose (rollback) rather than the deleted conflict-detection use.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio
malibio merged commit a4f2689 into main May 30, 2026
@malibio
malibio deleted the worktree-issue-1277-frontend-deadcode-cleanup branch May 30, 2026 16:25
malibio pushed a commit that referenced this pull request May 30, 2026
The vi.mock addition during rebase conflict resolution caused the
OCC integration tests to fail — vi.fn().mockResolvedValue(undefined)
on updateNode in the factory intercepted the vi.spyOn rejection setup,
breaking the test's ability to simulate VERSION_CONFLICT responses.

Main's version of this file already had moveChildrenToParent in its
mock (added by #1278's dead-code cleanup). Restoring that version
fixes 3 failing OCC integration tests.

Co-Authored-By: Claude <[email protected]>
malibio added a commit that referenced this pull request May 30, 2026
… (all-or-nothing) (#1276)

* C3c: Atomic child-transfer-on-split — single MoveChildrenToParent RPC (closes #1275)

Replaces the N per-child MoveNode RPCs with a single all-or-nothing
MoveChildrenToParent RPC that re-parents an ordered set of children in
one database transaction. OCC failures now roll back the entire batch
rather than leaving partial state.

Changes span all five layers:
- proto: new MoveChildrenToParent RPC + ChildMove/request/response messages
- core: SqliteStore::move_children_to_parent (single txn, delete+insert per edge)
  + NodeService::move_children_to_parent (up-front OCC pre-validation on all
  children, delegates atomic edge swap, bumps versions, emits RelationshipUpdated)
- daemon: gRPC handler using existing service_error_to_status pipeline
- tauri: move_children_to_parent command registered in lib.rs
- frontend: BackendAdapter interface + TauriAdapter + HttpAdapter + MockAdapter;
  createNode child-transfer branch issues exactly one moveChildrenToParent call
  instead of N moveNode calls; on failure the #656 child-transfer-failure
  notification is preserved verbatim

Tests: 4 new Rust unit tests (success, all-or-nothing, non-container guard,
order preservation); 1 new daemon OCC mapping test; frontend test updated to
spy on moveChildrenToParent and assert single-RPC + rollback + #656 notification.
All 3867 frontend + 881 Rust tests pass.

Co-Authored-By: Claude <[email protected]>

* Address review: fix order chaining, add in-transaction OCC + cycle guard, tighten test

Three review findings addressed:

1. Fractional order chaining bug (sqlite_store.rs): was computing orders with
   arbitrary prev=i*1000.0 instead of the previously assigned order. Now
   accumulates iteratively with orders.last().copied() as prev, producing
   correct sequential fractional values (e.g. [1.0, 2.0, 3.0]).

2. TOCTOU + missing cycle check (node_service/mod.rs):
   - Store method now accepts (child_id, expected_version) pairs and validates
     version inside the transaction using a version-gated DELETE + SELECT
     changes() — any mid-flight concurrent bump is caught inside the txn.
   - Added is_descendant() cycle guard in the service pre-validation loop,
     matching move_node's guards exactly as specified by the issue.

3. Frontend "exactly once" assertion (reactive-node-service.test.ts):
   Changed toBeGreaterThan(callsBefore) → toBe(callsBefore + 1) to enforce
   the acceptance criterion that exactly one RPC is issued, not merely ≥1.

Skipped: HttpAdapter dev-proxy route (no server-side handlers exist for any
route — consistent with project pattern); ADR-026/031 amendment (separate
nodespace-docs doc/ branch, cross-linked via PR description).

Co-Authored-By: Claude <[email protected]>

* Address review: root-node guard, actionable error ID, store-layer atomicity tests

Three re-review findings addressed:

1. Root-node false positive (node_service/mod.rs): added is_root_node() guard in
   the pre-validation loop so root nodes get HierarchyViolation instead of a
   spurious VersionConflict from the in-transaction changes()=0 path. Root nodes
   have no has_child edge so the version-gated DELETE would always return 0 rows.

2. Actionable conflict node ID (node_service/mod.rs): the VERSION_CONFLICT error
   re-mapping now parses the node ID out of the store's error string
   ("VERSION_CONFLICT: node '<id>' ...") using strip_prefix + split, so the
   resulting NodeServiceError::VersionConflict carries the actual offending node
   ID instead of "batch-child".

3. Store-layer atomicity tests (sqlite_store.rs): two new #[tokio::test] tests:
   - test_move_children_to_parent_store_rejects_stale_version: calls the store
     directly (bypassing service pre-validation) with a stale version token;
     asserts VERSION_CONFLICT error + child1 still under original parent (rollback).
   - test_move_children_to_parent_store_success_and_order: asserts correct strictly-
     increasing orders and all children move to new_parent on success.

All 3867 frontend + 17 browser + 883 Rust tests pass (883 = +2 new store tests).

Co-Authored-By: Claude <[email protected]>

* Fix: remove spurious vi.mock from conflict-notification test

The vi.mock addition during rebase conflict resolution caused the
OCC integration tests to fail — vi.fn().mockResolvedValue(undefined)
on updateNode in the factory intercepted the vi.spyOn rejection setup,
breaking the test's ability to simulate VERSION_CONFLICT responses.

Main's version of this file already had moveChildrenToParent in its
mock (added by #1278's dead-code cleanup). Restoring that version
fixes 3 failing OCC integration tests.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Jun 22, 2026
…ead OptimisticOperationManager (C1b re-audit residue) (#1278)

* Dead-code cleanup: remove client-side conflict subsystem + OOM + deprecated stubs (closes #1277)

Delete `validateNodeReferences` (deprecated stub), `ensureAncestorChainPersisted` (no-op),
the pre-C5 client-side conflict subsystem (`detectConflict`, `handleConflict`,
`setConflictResolver`/`getConflictResolver`, `conflictResolver` field, `createDefaultResolver`),
and `OptimisticOperationManager` (only imported by its own test; inline rollback already works).

Remove `Conflict`/`ConflictResolver`/`ConflictResolution` types and `skipConflictDetection` option
from `UpdateOptions` — the daemon is authoritative for OCC verdicts (ADR-026 C5 amendment);
`conflictNotifications` and the live OCC path in `updateNode`/`updateTaskNode` are untouched.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Remove dead conflictCount metric and fix previousVersion comment

conflictCount in StoreMetrics was always zero after handleConflict was
deleted in the prior commit. Remove the field from the type and its three
initializer sites. Fix the previousVersion comment to describe its actual
purpose (rollback) rather than the deleted conflict-detection use.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
malibio added a commit that referenced this pull request Jun 22, 2026
… (all-or-nothing) (#1276)

* C3c: Atomic child-transfer-on-split — single MoveChildrenToParent RPC (closes #1275)

Replaces the N per-child MoveNode RPCs with a single all-or-nothing
MoveChildrenToParent RPC that re-parents an ordered set of children in
one database transaction. OCC failures now roll back the entire batch
rather than leaving partial state.

Changes span all five layers:
- proto: new MoveChildrenToParent RPC + ChildMove/request/response messages
- core: SqliteStore::move_children_to_parent (single txn, delete+insert per edge)
  + NodeService::move_children_to_parent (up-front OCC pre-validation on all
  children, delegates atomic edge swap, bumps versions, emits RelationshipUpdated)
- daemon: gRPC handler using existing service_error_to_status pipeline
- tauri: move_children_to_parent command registered in lib.rs
- frontend: BackendAdapter interface + TauriAdapter + HttpAdapter + MockAdapter;
  createNode child-transfer branch issues exactly one moveChildrenToParent call
  instead of N moveNode calls; on failure the #656 child-transfer-failure
  notification is preserved verbatim

Tests: 4 new Rust unit tests (success, all-or-nothing, non-container guard,
order preservation); 1 new daemon OCC mapping test; frontend test updated to
spy on moveChildrenToParent and assert single-RPC + rollback + #656 notification.
All 3867 frontend + 881 Rust tests pass.

Co-Authored-By: Claude <[email protected]>

* Address review: fix order chaining, add in-transaction OCC + cycle guard, tighten test

Three review findings addressed:

1. Fractional order chaining bug (sqlite_store.rs): was computing orders with
   arbitrary prev=i*1000.0 instead of the previously assigned order. Now
   accumulates iteratively with orders.last().copied() as prev, producing
   correct sequential fractional values (e.g. [1.0, 2.0, 3.0]).

2. TOCTOU + missing cycle check (node_service/mod.rs):
   - Store method now accepts (child_id, expected_version) pairs and validates
     version inside the transaction using a version-gated DELETE + SELECT
     changes() — any mid-flight concurrent bump is caught inside the txn.
   - Added is_descendant() cycle guard in the service pre-validation loop,
     matching move_node's guards exactly as specified by the issue.

3. Frontend "exactly once" assertion (reactive-node-service.test.ts):
   Changed toBeGreaterThan(callsBefore) → toBe(callsBefore + 1) to enforce
   the acceptance criterion that exactly one RPC is issued, not merely ≥1.

Skipped: HttpAdapter dev-proxy route (no server-side handlers exist for any
route — consistent with project pattern); ADR-026/031 amendment (separate
nodespace-docs doc/ branch, cross-linked via PR description).

Co-Authored-By: Claude <[email protected]>

* Address review: root-node guard, actionable error ID, store-layer atomicity tests

Three re-review findings addressed:

1. Root-node false positive (node_service/mod.rs): added is_root_node() guard in
   the pre-validation loop so root nodes get HierarchyViolation instead of a
   spurious VersionConflict from the in-transaction changes()=0 path. Root nodes
   have no has_child edge so the version-gated DELETE would always return 0 rows.

2. Actionable conflict node ID (node_service/mod.rs): the VERSION_CONFLICT error
   re-mapping now parses the node ID out of the store's error string
   ("VERSION_CONFLICT: node '<id>' ...") using strip_prefix + split, so the
   resulting NodeServiceError::VersionConflict carries the actual offending node
   ID instead of "batch-child".

3. Store-layer atomicity tests (sqlite_store.rs): two new #[tokio::test] tests:
   - test_move_children_to_parent_store_rejects_stale_version: calls the store
     directly (bypassing service pre-validation) with a stale version token;
     asserts VERSION_CONFLICT error + child1 still under original parent (rollback).
   - test_move_children_to_parent_store_success_and_order: asserts correct strictly-
     increasing orders and all children move to new_parent on success.

All 3867 frontend + 17 browser + 883 Rust tests pass (883 = +2 new store tests).

Co-Authored-By: Claude <[email protected]>

* Fix: remove spurious vi.mock from conflict-notification test

The vi.mock addition during rebase conflict resolution caused the
OCC integration tests to fail — vi.fn().mockResolvedValue(undefined)
on updateNode in the factory intercepted the vi.spyOn rejection setup,
breaking the test's ability to simulate VERSION_CONFLICT responses.

Main's version of this file already had moveChildrenToParent in its
mock (added by #1278's dead-code cleanup). Restoring that version
fixes 3 failing OCC integration tests.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Frontend dead-code cleanup: vestigial conflict/validation members + dead OptimisticOperationManager (C1b re-audit residue)

1 participant