Repository navigation
Description
Implements ADR-066: Convergence Conflicts Are Local-Only Records in a Generic Conflict Journal, Not Per-Node Boolean Flags (nodespace-docs/decisions/066-convergence-conflicts-are-records-not-flags.md), specified in nodespace-docs/components/conflict-journal-and-resolution.md.
Supersedes item 1 of #2374 (the design question, now answered). Items 2-4 of #2374 are unrelated contained bugs and stay there.
Why
_possible_duplicate is a boolean property on person that:
- Can never become
trueon a local-only install.NodeService::mark_possible_duplicateshas zero production callers; the only live writer ismark_collection_name_collision, which handles a different constraint. The person path depends onnodespace-sync. - Cannot name the counterparty. The badge re-derives it at render time with a second, independent
findDuplicateForlookup that can disagree with whatever set the flag. - Cannot be cleared. Per the badge's own header comment, dismissing "only closes this popover; the underlying marker is not cleared", so it reappears indefinitely.
- Leaks into the data model. Being a
SchemaField, it is an empty, uninterpretable column in the person table view.protection: Systemandlocal_onlycontrol who writes and whether it syncs — neither means "hide from views". - Does not generalize. Every future conflicting type would have to declare its own copy of the field. A schema-only extension type gets detection with nowhere to store the result. Collection-name collisions were bolted onto the same boolean because it was the only slot available.
ADR-066 replaces it with a local-only conflict table holding records that carry participants, evidence, and a resolution lifecycle. ADR-065's suggest-don't-block holding is unchanged — a colliding write is still never rejected, and sync apply still never errors, skips or rolls back on a collision. Only the representation of the indicator changes, plus merge is no longer deferred.
Recovered Items already implements the correct shape (a durable record with counterparty data and persistent dismissal) for a neighbouring conflict class, in a per-user JSONL file. It folds into this journal.
S1 — Journal, detection, and deletion of the flag (headless core)
- Add the local-only
conflicttable (id,kind,node_ids,detail,status,detected_at,detected_by,occurrences,last_seen_at,resolved_at,resolution) plus aconflict_participant(conflict_id, node_id)companion table so the per-node lookup is an index hit rather than a JSON scan. No FK tonode— see spec §2.1. -
ConflictKind=UniqueFieldCollision | CollectionNameCollision | SupersededEdit | DuplicateReactiveCreate(last one reserved, no detection yet).ConflictStatus=open | resolved | dismissed. - Deterministic ids:
uuidv5(ns, "{kind}|{sorted_node_ids}|{discriminator}"), discriminator per spec §2.3. Sorting participants makes the id symmetric so arrival order cannot produce two records. -
record_conflictis upsert-by-derived-id: insert, or bumpoccurrences/last_seen_at. Never reopens aresolved/dismissedrecord — this is dismiss-persistence. -
list_conflicts,conflicts_for_node,resolve_conflictonNodeService(spec §3). - Rewrite
NodeService::mark_possible_duplicatesas unique-field detection that journals, and wire it to a real caller in create/update. This is the defect that made the whole mechanism unreachable locally. - Rewrite
SqliteStore::mark_collection_name_collisionto journalCollectionNameCollision— its own kind, ending the conflation with duplicate-person under one boolean. - Scope
find_conflicting_uniquetolifecycle_status = 'active'(get_collection_by_namealready does). Required for §5.3 self-resolution after a merge. - Detection stays post-commit, best-effort, error-swallowing at every site. A journal-write failure must never fail or undo the write it follows.
- Delete
POSSIBLE_DUPLICATE_FIELD, the_possible_duplicateSchemaFieldonperson,is_possible_duplicate,possible-duplicate.ts,possible-duplicate-badge.svelteand their tests. Deletion, not deprecation (CLAUDE.md: zero users, no migrations).
Acceptance: two local person nodes with the same email produce exactly one UniqueFieldCollision record naming both — with no nodespace-sync. Re-detection bumps occurrences rather than adding a row. Dismiss then re-detect leaves it dismissed. A schema-only extension type with a unique field gets records with zero schema changes. grep -r _possible_duplicate packages/ returns nothing.
S2 — Conflicts surface; fold in Recovered Items (desktop)
- Conflicts view: open records grouped by kind, participants as navigable node references, evidence rendered from
detail(never re-derived by a second lookup),occurrenceswhere > 1, resolved/dismissed behind a filter. - Non-destructive actions per spec §5.1: dismiss (persisted), adopt existing, rename (collection-name only), restore (superseded edits).
- Fold Recovered Items in as
SupersededEdit: deletecommands/recovered_items.rs,recovered-items.svelte.ts,recovered-items-badge.svelte; the Pro daemon'srecord_recovered_itemwrites a journal record instead of a JSONL line. Same data, one surface, one dismiss mechanism. - One store on the canonical rune pattern (ADR-049) with
records,hasOpenFor(nodeId), and the actions. - Inline indicator, if kept, is a derived read of the journal, not a stored property, and links into the Conflicts view rather than resolving in a popover.
- Leave
conflict-notifications.svelte.tsalone — transient OCC version-mismatch feedback is an interaction failure, not a durable conflict.
S3 — Merge (highest risk; land last)
merge_nodes(survivor, loser, conflict_id?), one transaction, spec §5.2:
- Property union onto survivor; survivor wins ties and every overwritten loser value is snapshotted into
resolution.superseded. Merge never silently discards user data. - Re-point every
relationshiprow from loser to survivor.has_childproperties.ordertravels with the re-point. A re-point that would violate the(in_node, out_node, relationship_type)unique constraint is dropped and counted, not an error. Self-edges dropped. - Tombstone the loser (
lifecycle_status = 'deleted'). Notdelete_subtree_atomic— it cascades overhas_childdescendants (ADR-041) that step 2 just re-pointed to the survivor. - Close the record as
resolvedwith the merge resolution. - User-initiated only. No auto-merge at any confidence: email is a claim, not an identity key (ADR-065 §5), and a typo would destroy a distinct person's record and re-point their edges.
S4 — Reconciliation sweep
- Close open records whose participants are gone or no longer collide; backstop for the accepted TOCTOU gap in pre-write-check/post-write-mark detection.
Out of scope
DuplicateReactiveCreatedetection — lands with the playbook work (ADR-060).- Rejecting colliding writes. ADR-065 settled it; local-first forbids it and a rejection at sync apply is a stuck cursor.
- Syncing the journal (ADR-066 §2).
- A schema mechanism for hiding fields from table views — orthogonal, and does not resurrect the flag.
Requires verification in nodespace-sync
Not available in this checkout; asserted from nodespace-core doc comments (ADR-066, "Assumptions Requiring Verification"):
-
mark_possible_duplicatein the pulled-write apply path is the soleperson.emailmarker writer — replace with a journal write. - The apply hook can reach
NodeService, and its detection runs post-commit. -
record_recovered_iteminnodespaced-procan write to the local DB rather than JSONL. If it cannot cross that boundary, keep the file as daemon-side transport and fold in on read.
Activity
malibio commentedon Sep 9, 2026
Frontend baseline: 239 test files passed, 4929 tests passed (87.73s).
malibio commentedon Sep 9, 2026
Closing to match board status (Done).