beads/internal/storage/versioncontrolops
matt wilkie db4b11d8f1
feat: auto-resolve issues-table modify/modify conflicts by LWW (updated_at) (#4699)
* feat: auto-resolve issues-table modify/modify conflicts by LWW (updated_at)

Add an issues case to TryAutoResolveMergeConflicts that auto-resolves
modify/modify conflicts on the issues table using row-wise last-write-wins
by updated_at. This eliminates the biggest remaining manual wall in
multi-clone sync: the issues-table conflicts that follow routine cross-clone
pulls (GH#4698).

Safety predicate (issuesConflictsAreLWWSafe):
- Only modify/modify (base_id valid, both our_id and their_id valid)
- Reject add/add (no base row), delete/modify (one side NULL)
- Reject equal updated_at (ambiguous)

Resolution (resolveIssuesLWWConflicts):
- For rows where ours wins: DELETE the conflict row from
  dolt_conflicts_issues (working set already holds our values)
- For remaining rows (theirs wins): DOLT_CONFLICTS_RESOLVE('--theirs')
- Stage with DOLT_ADD('issues')

Updated TestPullFromReportsOperatorConflicts to pin updated_at to equal
values on both sides, making the conflict ambiguous so the safety check
rejects it — the test exercises the operator-conflict reporting path which
requires a conflict the auto-resolver declines.

Added four new tests covering theirs-wins, ours-wins, ambiguous, and
add/add scenarios.

Agent-Signature: amp-gpt-5.4-2026-03-05-high on behalf of maphew

* feat: narrow issues LWW auto-resolve to losing-side-predates-merge-base

Tighten the issuesConflictsAreLWWSafe predicate so a modify/modify
issues-table conflict is only auto-resolved by last-write-wins when the
losing side's updated_at predates the merge base (equals the base row's
updated_at). If the losing side also moved its updated_at past the base
value, both sides made real edits since the last sync and row-level LWW
would silently drop the losing side's field-level changes — that
concurrent-edit case is now left for the operator (GH#4698 Risk
mitigation).

This preserves the common case the basic LWW fix targets: one side's
conflict is a migration artifact (the row was rewritten by a schema
change but updated_at did not move) and the other side made the only
real edit. bd is primarily single-user-multi-machine, so concurrent
same-issue edits since a shared merge base are rare.

Implementation: issuesConflictsAreLWWSafe now also selects
base_updated_at from dolt_conflicts_issues and, after the existing
modify/modify and unequal-timestamp checks, verifies the losing side's
(older) updated_at does not exceed the base value. The resolution
function (resolveIssuesLWWConflicts) is unchanged — it already does
row-wise LWW; only the safety gate is stricter.

Tests:
- Updated setupIssueMergeConflict to seed a controlled base updated_at
  (the helper now explicitly sets updated_at on the seed row instead of
  relying on CURRENT_TIMESTAMP, which made the base value timing-
  dependent).
- Existing theirs-wins/ours-wins tests set the losing side's updated_at
  equal to the base so they exercise the auto-resolve path.
- New TestTryAutoResolveMergeConflicts_IssuesConcurrentEditLeftAlone:
  both sides' updated_at > base → left for the operator.

Agent-Signature: amp-gpt-5.4-2026-03-05-high on behalf of maphew
2026-07-10 16:04:15 -07:00
..
backup.go fix: suppress auto-backup address conflict warning (#2927) 2026-04-02 20:28:47 -07:00
backup_test.go fix: suppress auto-backup address conflict warning (#2927) 2026-04-02 20:28:47 -07:00
branches.go /{cmd,internal}: wip sync and data EmbeddedDoltStore methods 2026-03-24 12:01:16 -07:00
clone.go fix: pass remote auth user during clone (#4484) 2026-07-05 11:28:24 -07:00
clone_test.go fix: pass remote auth user during clone (#4484) 2026-07-05 11:28:24 -07:00
commit.go /{.github,cmd,internal}: pr feedback, ci fix 2026-03-25 12:58:46 -07:00
compact.go fix(compact): pass --allow-empty to DOLT_CHERRY_PICK (#4454) 2026-07-05 10:53:10 -07:00
db.go /{cmd,internal}: wip sync and data EmbeddedDoltStore methods 2026-03-24 12:01:16 -07:00
fastforward.go feat(gate): non-destructive fast-forward adopt detection (adopt-ff, #4551 follow-up 2) (#4586) 2026-07-07 05:58:28 -07:00
fastforward_test.go feat(gate): non-destructive fast-forward adopt detection (adopt-ff, #4551 follow-up 2) (#4586) 2026-07-07 05:58:28 -07:00
flatten.go /{cmd,internal}: pr feedback 2026-03-25 15:09:54 -07:00
gc.go /{cmd,internal}: fix commands 2026-03-25 13:48:13 -07:00
mergesettle.go feat: auto-resolve issues-table modify/modify conflicts by LWW (updated_at) (#4699) 2026-07-10 16:04:15 -07:00
remotes.go fix(fetch): drop session-killing DOLT_GC from failed-fetch path (bd-6dnrw.10) 2026-06-11 00:59:49 -04:00
version_control.go /{cmd,internal}: pr feedback 2026-03-25 15:09:54 -07:00