Omitted expected heads let commits overwrite concurrent branch history
perfloop-oss/dolt · Uncatalogued correctness
https://perfloop.ai/t/oss/case_5vwf6e4tpg
Verdict
VERIFIED · settled 2026-11-10 · pull request opened as dolthub/dolt#12425
What happened: The check fails before this change and passes with it.
Hypothesis
A commit with an omitted expected head can replace a competing commit without reporting a conflict. The resulting branch no longer contains the competing commit in its ancestry. A bounded native check reproduces this on new and existing branches; real-world frequency and an end-to-end schema copy-tags reproduction remain unmeasured.
CommitUpdate.build prepares an immutable commit from CommitDS, but emits a branch-head precondition only when ExpectedHead is nonzero. database.CommitDatasets validates only the emitted conditions and reuses built commits across optimistic root-swap retries. Thus the retry loop cannot protect a branch whose condition was omitted. BranchHeadUpdate documents that the branch head is always checked and forwards ExpectedHead unchanged. Its schema copy-tags caller at go/cmd/dolt/commands/schcmds/copy-tags.go:295-308 omits that field. The SQL transaction caller at go/libraries/doltcore/sqle/dsess/transactions.go:468-473 supplies it, so the observed existing-branch defect is not a claim that every SQL COMMIT is exposed.
The stored check on prop_b685mqh70s ran at revision 0d1e86b35a814050d1475214e7fdb76388adbe3b: go -C go test ./store/datas -run '^TestPerfloopBranchHeadPublication$' -count=1 -timeout=90s -v. checkProperty run call_SAuPJUQxMngEjjOvW12wjjWI exited 1 from property assertions, not a build or fixture failure. It completed 24 configurations: zero or one initial commit, omitted or matching ExpectedHead, an optional unchanged working-set lock, and no competing write or one competing write after build or immediately before root CAS. Twelve configurations returned nil, changed the competing root, and failed the concurrent-ancestor assertion. All no-conflict controls passed, and the competing-write cases with an existing branch and a nonzero matching ExpectedHead returned ErrMergeNeeded and preserved the root. The smallest returned replay has no initial commit, no working-set lock, and one competing publication after build. Existing-branch failures have the original head, rather than the competing commit, as their common ancestor. These are results only for the enumerated ordinary-commit histories, without crash or I/O faults.
The broader contribution is protection at the common CommitUpdate owner, not adding an expected hash to one caller. The failure requires a supported concurrent branch publication during the build/publication interval; an unchanged working-set lock does not protect against a branch-only update. No incident rate is known. The expected implementation cost is an additional snapshot-head condition per commit, without new public state or an API; compatibility must retain explicit expected-head checks, atomic batch behavior, unrelated-writer retries, and the deliberate force/amend parent rules.
The complete current open-PR listing showed no change to this storage publication owner. https://github.com/dolthub/dolt/pull/12305 was inspected at head 4a707fc330b658f5b09d44f00ce936883948dc34: it aborts SQL transactions when a working set disappears after branch deletion or rename, but does not add this missing branch-head condition. Local history is shallow, and a bounded GitHub path-history request returned HTTP 403, so recent merged history remains an evidence gap. No separate code-review archive was identified in repository guidance; README's Discord link is a community/questions link. Prior repair hyp_gcgvbdknv4 concerns session-value reconstruction and was closed by user:4 after negative improvement measurements; that reason applies to that optimization, not this publication invariant.
The Case should first replay the saved native counterexample and its existing-branch sibling, then establish that every supported CommitUpdate mode retains a snapshot-head condition through publication and retry. A repaired run must reject conflicting heads without replacing the competing root or publishing another batch member, while no-conflict and unrelated-root-writer cases still succeed. Retain force/amend semantics and working-set error distinctions. The stored check and its file placement are a provisional proof harness, not an additional frozen layout requirement.
Change to test: Always guard publication against the branch snapshot used to build the commit, including an absent snapshot, while retaining explicit prepared-head and optional working-set checks. Preserve force/amend parent semantics and reject a conflicting head with ErrMergeNeeded on the first publication attempt or a root-swap retry.
Where it lives
perfloop-oss/dolt · go/libraries/doltcore/doltdb/doltdb.go
Evidence
The check fails before this change and passes with it: `In deterministic ordinary, force, and amend histories, CommitUpdate rejects a competing branch publication after build with ErrMergeNeeded and preserves the competing root and every other batch member, including absent snapshots and omitted ExpectedHead.`
The check fails before this change and passes with it: `In deterministic single-root-conflict histories on absent or existing branches, CommitDatasets rejects a changed CommitUpdate branch snapshot with ErrMergeNeeded without publishing any batch member, while unrelated branch writes allow the complete batch to publish using the originally built commit.`
Timeline
2026-11-10· Case opened2026-11-10· PR opened