Repository navigation
Replace _possible_duplicate with a generic conflict journal (ADR-068) - #2534
Conversation
Replaces the `_possible_duplicate` boolean property — unreachable on a local-only install, unable to name the counterparty, and impossible to clear — with a local-only `conflict` + `conflict_participant` journal. S1 (headless core): - New v005 migration, `ConflictKind`/`ConflictStatus`/`ConflictRecord`/ `Resolution` model types, deterministic UUIDv5 conflict ids. - `SqliteStore`/`NodeService` conflict-journal methods (record/list/ resolve/conflicts_for_node). - `UniqueFieldCollision` detection wired into `create_node`/`update_node` post-commit (the real caller `mark_possible_duplicates` never had); `CollectionNameCollision` detection rewritten onto the same journal. - Deleted `_possible_duplicate`, `POSSIBLE_DUPLICATE_FIELD`, `mark_possible_duplicates`, `is_possible_duplicate`, and the frontend badge/util, with convergence tests rewritten against the journal. S2 (Conflicts surface + Recovered Items fold-in): - New gRPC RPCs (ListConflicts/ConflictsForNode/ResolveConflict) and Tauri commands. - New `conflicts.svelte.ts` store (ADR-049 pattern), Conflicts view wired into navigation as a singleton tab, inline per-node conflict indicator replacing both the old badges. - Recovered Items fully folded in: daemon JSONL commands, frontend store, and badge deleted; its `SupersededEdit` kind is defined and ready for the daemon-side write path (nodespaced-pro is out of this repo). Deviation from ADR-068's literal text, confirmed with the user: merge's future loser-tombstone will use the existing `lifecycle_status = 'archived'` rather than inventing a new `deleted` value — ADR-042's tombstone turns out to be a cloud-sync concept, not a local lifecycle state, so `archived` is the correct non-destructive local analog. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PK4q7pM7umReyBTt1w6tzN
The highest-risk slice, landed last per the ADR: SqliteStore::merge_nodes_in_tx runs entirely inside one ADR-069 unit-of-work transaction — - Property union onto the survivor, one level into the shared node_type namespace object (properties.<type>.<field>) where the real per-field data lives; survivor wins ties, loser's overwritten values captured for the eventual Resolution::Merge.superseded snapshot. - Every relationship edge touching the loser re-pointed to the survivor via a plain endpoint UPDATE (order and other edge properties travel for free — no delete/reinsert). A re-point that would collide with an existing survivor edge on (in_node, out_node, relationship_type) is dropped, not an error; a self-edge produced by re-pointing both endpoints to the survivor is dropped too. - Loser archived (lifecycle_status = 'archived'), not hard-deleted and not delete_subtree_atomic (which would cascade over has_child descendants the re-point step already moved). Confirms the earlier archived-not- deleted decision at the mechanism that actually needed it. - Optional conflict_id closes the record as resolved with a Resolution::Merge in the same transaction via resolve_conflict_in_tx. NodeService::merge_nodes composes these through with_transaction; gRPC (MergeNodes RPC), Tauri command, and the Conflicts view's per-record "Keep X" merge action wire it end to end. User-initiated only — nothing calls this automatically at any confidence level. Found and fixed a real bug via the new integration tests: the first property-union draft compared only top-level property keys, so it never saw properties.<type>.<field>) is the actual storage shape. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PK4q7pM7umReyBTt1w6tzN
A low-frequency (15-minute) background pass per database, spawned
alongside the embedding processor in build_database_services and stopped
by DatabaseServices::shutdown, that closes open conflict records whose
participants are gone or no longer collide:
- A hard-deleted participant closes the record unconditionally.
- UniqueFieldCollision/CollectionNameCollision records are re-checked
against the participants' CURRENT live values via the same predicates
detection uses (find_conflicting_unique, get_collection_by_name).
- New Resolution::SelfResolved{reason} distinguishes an auto-closed
record from a human's Dismiss — the sweep is the backstop for the
accepted TOCTOU gap in the pre-write-check/post-write-mark pattern,
not a substitute for it.
- list_conflicts(Open) already excludes dismissed/resolved records, so
the sweep never reopens a human's decision.
Found and fixed a real bug via an adversarial test that runs the same
scenario in a loop: the first draft re-checked a UniqueFieldCollision
from an ARBITRARY participant's exclusion perspective (node_ids.first(),
sorted lexically). Whichever id won the sort determined whether the
predicate excluded the participant who moved away or the one who didn't
— excluding the wrong one still finds the OTHER, unrelated, still-correct
participant and reports a false continuing collision. Fixed by checking
each participant's own CURRENT value against a still-live predicate hit,
not an arbitrary stand-in using the stale detected-at-time value.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PK4q7pM7umReyBTt1w6tzN
Pragmatic Code Review — PR #2534Review Type: Initial Review (full diff, SummaryThis is a well-executed, well-tested replacement of the This is a net positive and I'd lean toward approval, but S2's acceptance criteria promise three resolution actions ( Requirements CheckS1 — Journal, detection, deletion of the flag
S2 — Conflicts surface; fold in Recovered Items
S3 — Merge
S4 — Reconciliation sweep
Out of scope, verified not accidentally implemented: No Cannot verify from this repo (correctly out of scope): Documentation-hygiene note (not a functional finding): the issue references ADR-066; every commit message and in-code doc comment references ADR-068. This is presumably a renumbering and not something this review can resolve without access to Deviation Sanity Check (archived vs. literal "deleted" tombstone)Per the pre-approved deviation, I checked whether
This reasoning holds. Not flagging the deviation itself as unexplained, per instructions. Code Review Findings🟡 Important
🟢 Suggestions
Nits
RecommendationAPPROVE with the two Important items (#1 UI action gap, #2 update_node short-circuit) recommended as fast follow-ups rather than blockers — neither is a correctness or security regression, and the S1/S3/S4 core (the highest-risk, most load-bearing part of this change) is thoroughly and convincingly tested, including a genuine adversarial regression test for the sweep bug the author found during development. The architecture is consistent with existing patterns (ADR-069 transaction seam, If the team wants S2 to be considered fully complete against its literal acceptance criteria before merge, item #1 (wire |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Two Important items flagged as recommended fast-follows (not blockers): S2's adopt_existing/rename resolution actions are modeled end-to-end but not wired into the Conflicts view UI, and detect_unique_field_collisions runs unconditionally on every update_node call even when no properties changed. Everything else — S1 detection, S3 merge (highest-risk slice), and S4's reconciliation sweep including its adversarial regression test — is thorough and correct.
…pdates Addresses the two Important findings from PR #2534's pragmatic code review: - Conflicts view: adopt-existing and rename are now reachable, not just modeled server/store-side. Adopt-existing records which participant is "real" (non-destructive). Rename fetches the current node, updates its content, then records the resolution — an ordinary write, not a special backend path. Both are scoped to UniqueFieldCollision/ CollectionNameCollision, the kinds S1 already detects. - update_node skips the post-commit unique-field-collision re-check when an update touches NEITHER content nor properties (a title- or lifecycle_status-only change) — unique field values live under properties, so such an update cannot introduce or need to re-detect a collision. Gating on `touches_content` (not `properties.is_some()` alone, which a first draft tried and which broke a real re-detection path — a content-only rename must still re-run detection to bump occurrences/last_seen_at on an already-open record, caught by the existing `redetecting_the_same_collision_bumps_occurrences_not_a_new_record` test failing). Also fixed two stale doc-comment references to the deleted recovered-items log in pro-sync.svelte.ts (repointed to onProConfirmed's still-live caller, collaboration-view.svelte). Skipped as follow-ups, not blockers (per reviewer's own framing): - Merge-archived nodes are visually indistinguishable from a manual archive (no bookkeeping breadcrumb on the node itself) — low-priority discoverability nit, nothing is lost. - The inline per-node conflict indicator issues one conflicts_for_node IPC call per rendered node — pre-existing pattern from the badges it replaces, not a regression this PR introduces; batching is a separate follow-up. - bun.lock's incidental configVersion diff — unrelated tooling noise. New test: title_only_update_does_not_bump_occurrences locks in the safe short-circuit boundary so a future change can't silently widen it back to the broken properties-only gate. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PK4q7pM7umReyBTt1w6tzN
Address-Review SummaryAddressed (2/2 Important findings):
Skipped as follow-ups (per reviewer's own framing, not blockers):
Verification: Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: Both addressed items are additive/corrective within the existing design (new UI actions using already-reviewed store/backend methods; a narrowed perf gate with a regression test proving the boundary). No new architectural surface, no changed data model, no new risk in S1/S3/S4 (the highest-risk, already-approved core). The PR was already APPROVE before this round. |
Summary
Implements ADR-068 (the issue's cited "ADR-066" is a stale reference — the live decision doc is
nodespace-docs/decisions/068-convergence-conflicts-are-records-not-flags.md), all four delivery slices:conflict+conflict_participantjournal,UniqueFieldCollision/CollectionNameCollisiondetection wired intocreate_node/update_nodepost-commit, and full deletion of_possible_duplicate,POSSIBLE_DUPLICATE_FIELD,mark_possible_duplicates,is_possible_duplicate, and the frontend badge/util.ListConflicts/ConflictsForNode/ResolveConflict) + Tauri wiring, inline per-node conflict indicator, Recovered Items fully folded in (old badge/store/daemon commands deleted).merge_nodes: property union (survivor wins ties, loser's overwritten values snapshotted), edge re-pointing (collision-drop, self-edge-drop, order preserved), loser archived — all in one ADR-069 transaction. User-initiated only.Deviation from the ADR's literal text, confirmed with the user during planning: merge's loser tombstone uses the existing
lifecycle_status = 'archived'rather than a newdeletedvalue. Investigation showed ADR-042's "tombstone" is a cloud/sync-layer concept (is_deleted/deleted_atin Postgres), not a locallifecycle_statusvalue — this codebase only has["active", "archived"], enforced byvalidate_lifecycle_status, with an existing test asserting"deleted"stays rejected. Reusingarchivedavoids inventing a fourth concept; it already fully excludes a node from everyactive-scoped detection query and destroys nothing.Bugs found and fixed via adversarial testing
properties.<node_type>.<field>— the actual storage shape. Fixed to union one level into the shared type namespace.UniqueFieldCollisionfrom an arbitrary participant's exclusion perspective (node_ids.first(), sorted lexically) — whichever id won the sort determined whether the predicate excluded the participant who moved away or the one who didn't, producing a ~50%-of-the-time false "still colliding" result. Fixed to check each participant's own current value.Test plan
bun run rust:test:core— 1284 lib tests + 24 integration test binaries, all passing (includes newmerge_nodes_test.rs,conflict_reconciliation_test.rs, rewrittenperson_duplicate_convergence_test.rs/collection_name_convergence_test.rs/collection_membership_test.rs)cargo test -p nodespace-daemon --lib— 188 passing (includes new conflict-journal gRPC round-trip test)bun run test— 237 frontend test files, 4897 tests passingbun run test:all— full suite (coverage, scripts, skill, Rust workspace) exits cleanbun run quality:fix— svelte-check/tsc/eslint/clippy (-D warnings) all cleangrep -rn _possible_duplicate packages/core/src packages/core/tests— empty (S1's literal acceptance criterion)🤖 Generated with Claude Code