Concurrent-commit container suite #
End-to-end workload replay for cli-git concurrent commits.
It is the "Container end-to-end verification" part of
doc/decision/cli-git-concurrent-commits.md
and slice 8 of
doc/concurrent-commits-implementation-plan.md.
Fresh dummy repositories replay realistic concurrent-agent workloads through the packed shadow git,
and an invariant checker judges every run.
How to run #
# package/git-policy/cli: run from the repository root
mise run //package/git-policy/cli:test:e2e:concurrent
mise run //package/git-policy/cli:test:e2e:concurrent --seed 1
mise run //package/git-policy/cli:test:e2e:concurrent --seed 1 --scenario shared-file-overlapping-hunks --git 2.55.0
test:e2e:concurrentdepends ontest:e2e:concurrent:image, which depends onpack:npm. Every run therefore tests the current build.- Every run prints its seed and a replay command first, then one line per scenario and Git version, then a summary. The task exits non-zero when any scenario fails or errors.
--scenariotakes comma-separated scenario names;--gittakes comma-separated versions among2.39.5,2.40.0, and2.55.0.
Regenerate the committed trace with real Git on the host.
It mines this checkout by default;
--repository <path> selects another checkout of the same history,
and --limit and --revision adjust the window.
# package/git-policy/cli: bypasses the wrapper through /usr/bin/git
mise run //package/git-policy/cli:e2e:concurrent:trace
Container #
concurrent-commits.Containerfile builds cli-git-concurrent-e2e:
- Node 24.11.0,
the floor of
engines.nodeinpackage.json; - Git 2.39.5,
Git 2.40.0,
and Git 2.55.0,
built from checksum-pinned kernel.org tarballs,
installed under
/opt/git/<version>; - no Git on the default
PATH, so each scenario picks its Git byPATHorder; - the packed tarball installed with npm at build time under
/opt/cli-git.
Git 2.40.0 is the oldest release with every feature cli-git uses,
because it is the first whose git merge-tree accepts --merge-base:
Documentation/RelNotes/2.40.0.adoc says "merge-tree learns a new --merge-base option",
and --write-tree itself arrived in 2.38.0.
Git 2.39.5,
Debian bookworm's Git,
proves that cli-git degrades without that option
(SPEC.md "Compatibility and degradation"):
a commit that loses a landing race fails fast with concurrent-commit/head-moved instead of replaying.
Git 2.55.0 is the current release;
it builds with its default Rust support enabled.
Config-based hooks (hook.<name>.command) arrived in Git 2.54.0,
so the config-hook scenarios skip on 2.39.5 and 2.40.0.
Each scenario declares how it depends on replay plumbing
(replayPlumbing in scenario-model-fixture.ts):
required, the default, skips it on 2.39.5, where its commits that lose a landing race would fail fast by design;unusedruns it on every Git, because none of its commits can lose a landing race: the baselines,branch-switch-during-commit, the hook-phasesigkill-*scenarios, and thesigkill-phase-*scenarios;absentruns it only on 2.39.5, to prove the degradation: thereplay-unavailable-*scenarios.
The run uses podman run --memory=2g --cpus=2 --rm --network=none.
e2e/ is mounted read-only at /fixture/e2e,
and package/module/caught-value is mounted read-only at /fixture/caught-value
for @monochromatic-dev/module-caught-value/ts,
which the image resolves through a /node_modules symlink.
No host repository is mounted writable,
and no credentials enter the container.
Every scenario creates its own repository and local bare remote under /work/<git-version>/<scenario>/.
Measured image build times on this host:
255 s for a build that compiles both Git versions
(base images already pulled),
and 12 to 19 s for the usual rebuild after pack:npm,
which only replaces the tarball layer.
Workloads #
Commit-shape trace #
commit-shape-trace-generator.ts runs /usr/bin/git log --raw --numstat -M over the newest 4000 non-merge commits
and writes commit-shape-trace.json.
The trace keeps shapes only:
files per commit,
path overlap through stable numeric path IDs,
blob sizes,
added and deleted line counts,
add,
modify,
delete,
and rename kinds,
file modes,
and binary flags.
It holds no file contents,
paths,
object IDs,
messages,
or author data.
Replay picks a seeded window of consecutive commits with 1 to 16 plain-file changes
and synthesizes content for each shape
(text sizes capped at 32 KiB,
binary sizes at 8 KiB).
Paths that must pre-exist are committed by real Git before the window.
Text always ends with exactly one LF,
so the default final-newline normalization never changes captured bytes.
A worker that touches a path another in-flight worker selected waits until that worker's pre-commit hook ran,
so every attempt commits exactly the bytes the harness wrote for it.
A worker that deletes or renames away a path an in-flight worker creates
(or a path created by an in-flight worker before that one)
waits until that worker's wrapper exited instead,
because until that commit lands the path is in neither the deleting commit's preparation base nor its worktree,
and native git commit -- <path> fails with "pathspec did not match" the same way.
The workload then stays a valid sequential-per-path history.
Scenario catalog #
Baselines prove the harness sound and must pass on today's build:
baseline-explicit-commit: modify, add, and delete one path each through sequential explicit-path commits.baseline-index-commit:git addtwo paths, keep an unrelated unstaged edit,commit --no-only.baseline-trace-sequential: 12 trace commits one at a time.baseline-amend: amend a token-free setup commit.baseline-lint-staged: lint-staged's backup stash and hide-unstaged sequence on a partially staged index commit, in a linked worktree.baseline-hooks-hookdirandbaseline-hooks-config:pre-commit,prepare-commit-msg,commit-msg, andpost-commithooks on sequential commits.baseline-ssh-signing: sequential SSH-signed commits.baseline-sigkill-post-commit:SIGKILLinsidepost-commit, after native Git released every lock, thengit statusand a follow-up commit.baseline-checker-positive-control: one commit lands, then real Git amends it with other bytes, stages the replaced blob, and plantsrefs/heads/stale.lock. It passes only when the checker reports exactlyindex-no-revert,landed-bytes,no-leftovers,remote-contains, andworktree-preserved.
Design scenarios exercise the accepted concurrent-commit design:
concurrent-disjoint-paths: 4 to 8 agents commit disjoint files with seeded start jitter.concurrent-trace-replay: 16 trace commits with 4 in flight.shared-file-non-overlapping-hunksandshared-file-overlapping-hunks: the first agent is held inpre-commitafter capturing, the second edits the same file and gets a 1.5 s window to start, then the first is released. Far-apart hunks must both land; overlapping hunks may fail only with exit1and acore-findingevent. Under capture order both captures come from one worktree, so the second capture's bytes land and both commits succeed.shared-file-adjacent-edits: the first agent edits one line and pauses after preparation (phase markerpreparation-done), the second edits the line after it, the line before it, or inserts a line right after it (seeded), so its captured bytes hold both edits, and pauses the same way; then the first is released and lands, and the second is released. Both must land, the second through a replay that keeps its captured bytes (capture order, since both captures come from one worktree,SPEC.md"Capture order"; subsumption reaches the same bytes for a change from elsewhere,SPEC.md"Subsumption").interleaved-index-writers: 4 commits and 4git addruns of new files in a seeded interleaving; every add must succeed and its staged entry must survive.hooks-hookdir-concurrent,hooks-config-concurrent, andssh-signing-concurrent: 4 agents at once with all four hooks or with signing.lint-staged-stash-concurrent: the lint-staged hook while 3 explicit-path agents and 1 partially staged index commit run, in a linked worktree.amend-during-commits: an amend races 3 commits; it may land only on the parent it saw. When it lands, the others replay onto the amended history, which auto-push cannot fast-forward (seepush-rejection-surfaced).reservation-after-lost-races: a victim commit holds in its editor until a first winner lands, then loses one race per winner, pausing at eachrace-lost-<n>while the next winner lands, until itslanding.reserveAfterLostRaces-th lost race (the default of 1, so the first winner alone) takes the landing reservation, where it pauses; a commit started then must not land during a 1.5 s window, and after release the victim lands first. Expectations:victim-lost-races,reserved-within-bound(exactly onelanding-reserved, at mostlanding.reserveAfterLostRaces+ 1 lost races),reservation-blocks-landing, andreserved-lands-first.branch-switch-during-commit:git switch sidewhile a commit is held inpre-commit; the switch and the commit must not both succeed.foreign-index-lock-holder: real Git by absolute path with-c core.lockfilePid=truerunscommit --allwith an editor that holdsindex.lockfor 1.5 s while 3 agents commit; the PID file proves the owner alive, so every agent must wait and succeed. It skips Git older than 2.54.0, which has nocore.lockfilePid.foreign-index-lock-unproven: the same holder withoutcore.lockfilePid, so no evidence proves it alive; each agent either lands after the holder finishes or fails with exit2and onlyindex-lock-unproven-owner, and the holder's own commit succeeds.gc-prune-during-commits:git gc --prune=nowwhile one commit is held inpre-commitand 3 others commit.sigkill-pre-commit,sigkill-prepare-commit-msg,sigkill-commit-msg, andsigkill-post-commit:SIGKILLto one agent's whole process group inside that hook while a bystander commits, thengit statusfor recovery and a follow-up commit.sigkill-offset: the same with the kill at a seeded 20 to 600 ms offset instead of a hook.sigkill-phase-preparation-done,sigkill-phase-landing-locked,sigkill-phase-objects-migrated,sigkill-phase-ref-updated, andsigkill-phase-index-installed: the victim pauses at that landing phase through the test-only phase marker (see "Phase markers"), the bystander starts and gets 500 ms to reach its landing wait, then the victim's process group is killed, followed bygit statusfor recovery and a follow-up commit. Atlanding-lockedthe victim holds the landing lock and the realindex.lock, so the bystander must recover both from a dead owner.victim-reached-phasefails when the victim settled before its marker appeared.replay-unavailable-fails-fast, on 2.39.5 only: a commit held in its editor while another lands must exit1with exactly oneconcurrent-commit/head-movedcore finding and land nothing.replay-unavailable-disjoint-burst, on 2.39.5 only: 4 to 8 agents commit disjoint files; each lands or fails fast exactly that way, and at least one lands.
Hooks and editors are Node programs (hook-program-fixture.ts),
not shell scripts.
Each hook logs its run,
writes a <token>.<event> marker,
and blocks while a <token>.<event>.hold file exists,
which is how scenarios pin interleavings and inject kills.
Phase markers #
Landing phases run no hook,
so the wrapper exposes them through a test-only environment variable
(src/policy-engine/commit-transaction-test-phase.ts,
SPEC.md "Container end-to-end suite"):
# package/git-policy/cli/e2e: environment of one wrapper invocation
CLI_GIT_TEST_ONLY_PHASE_SIGNAL=<phase>:kill # SIGKILL itself at the phase
CLI_GIT_TEST_ONLY_PHASE_SIGNAL=<phase>:kill:<directory> # write <directory>/<phase>.reached first
CLI_GIT_TEST_ONLY_PHASE_SIGNAL=<phase>:pause:<directory> # write the marker, wait for <directory>/<phase>.release
The phases,
in transaction order,
are capture-locked
(capture lock held,
before the capture sequence number is allocated),
preparation-done
(after prepared.json),
landing-locked
(landing lock and real index.lock held,
index-lock-<n>.json written),
objects-migrated
(kept pack written,
before landing-<n>.json),
ref-updated
(after ref-updated.json),
and index-installed
(after the index-installed marker,
before conclusion cleanup and worktree completion),
and race-lost
(after each lost race and any reservation it earned,
before the replay,
outside both locks),
whose files carry the occurrence:
race-lost-<n>.reached and race-lost-<n>.release.
The variable name says it is for tests only,
nothing else sets it,
and a malformed value fails the invocation instead of being ignored.
A nested wrapper invocation from a hook inherits the variable,
so scenarios arm it only on commits whose hooks start no nested commit.
The kill scenarios use pause and kill the whole process group from the harness,
so the harness records the attempt as deliberately killed.
Invariants #
invariant-fixture.ts checks every run:
landed-once: an attempt that exited0appears exactly once in local-branch history; a failed one never appears unless itscommit-landedevent names the commit; a killed one appears at most once.landed-bytes: each selected path holds the bytes captured at invocation, a clean three-way merge of them onto the landed parent from a candidate preparation base, or, for an explicit-path attempt, the landed parent's bytes when an attempt started later captured exactly those bytes for the same path and its commit lies betweenHEADbefore invocation and the parent (capture order kept the later capture's landed bytes,SPEC.md"Capture order").landed-scopeandlanded-branch: a landed commit changes only its selected paths and is reachable from the branchHEADnamed at invocation.worktree-preserved: every path the harness wrote still holds the harness's last bytes.index-no-revertandindex-matches-head: the real index differs fromHEADonly where the harness staged on purpose, and never stages content a landed commit replaced.remote-contains: the remote branch reaches every commit whose wrapper exited0with auto-push applying (not amends, which auto-push cannot fast-forward, not the foreign real-Git commit, and not commits landed on top of an amend of an already-published commit).push-rejection-surfaced: a commit that exited0on top of a landed amend of a commit the remote already had must have surfaced Git'snon-fast-forwardpush rejection and cli-git'sauto-push to origin failednote (owner decision,doc/decision/cli-git-concurrent-commits.md"Amending published history").no-leftovers: norefs/cli-git/ref, lock file or lock directory (the capture lock included), transaction directory undercli-git-transactions/, legacycli-git-transactiondirectory, shadow repository undercli-git/shadow/, landed-capture record undercli-git-captures/landed/, or other capture-store entry remains; the persistentcli-git-transactions/root and the capture store'sworktree-id,sequence, andlanded/directory are allowed (SPEC.md"Capture order").fsck-clean:git fsck --strict --no-danglingexits0with no output.exit-events: wrapper stderr JSONL decodes, sequences start at0, and exit codes agree with the events (SPEC.md"Stream and exit contract").commit-msg-hook,post-commit-once, andsignature-valid: in hooked or signed scenarios, the landed message carries the hook trailer,post-commitran once per successful attempt, andgit verify-commitaccepts the commit.- Scenario expectations such as
all-commits-succeed,command-succeeds,staged-entries-kept,conflict-reported,amend-safe, andswitch-invalidates-commitencode the accepted design's outcome for that scenario.
Seeds and replay #
All workload decisions
(worker counts,
start offsets,
interleavings,
trace windows,
synthesized content,
kill offsets)
come from a generator derived from the run seed and the scenario name plus Git version,
so filtering never shifts another scenario's decisions.
Each result line prints a workload digest over labels,
selections,
and captured bytes.
Two consecutive runs of seed 1 printed identical digests for all 54 non-skipped runs,
and the two seed-1 runs of 2026-09-26 against 09b0eb07b and 9b5f66c40 printed identical digests for concurrent-trace-replay.
Hook barriers make the pinned interleavings identical on replay;
free-running starts and the sigkill-offset kill still depend on process scheduling,
so a replay reproduces the workload exactly but can land a free-running race differently.
Results on the current build #
Seeds 1,
2,
and 3,
2026-09-26,
packed from feat/cli-git-concurrent-commits at b2b20ac74
(after merging the worktree-copy stall fix and automatic maintenance after landing,
waiting for live trust provenance transactions,
failing fast without replay plumbing,
and lowering the landing.reserveAfterLostRaces default to 1),
114 scenario runs per seed:
38 scenarios on each of Git 2.39.5,
2.40.0,
and 2.55.0.
Every seed passed with no failure and no harness error.
Passing #
- Git 2.55.0:
36 passes per seed,
every scenario except the two
replay-unavailable-*ones. - Git 2.40.0:
33 passes per seed.
It skips the config-hook scenarios and
foreign-index-lock-holder, which need Git 2.54.0, and thereplay-unavailable-*scenarios. - Git 2.39.5:
21 passes per seed:
the baselines except
baseline-hooks-config,branch-switch-during-commit, the hook-phasesigkill-*and allsigkill-phase-*scenarios, and bothreplay-unavailable-*scenarios. It skips the 17 scenarios that need replay plumbing or Git 2.54.0.
Before replay degradation existed,
seed 1 on Git 2.39.5 failed 12 of 36 runs:
every commit that lost a landing race exited 2 with transaction-failed
carrying git merge-tree usage text.
No invariant was violated then either:
nothing landed,
and nothing was lost.
With the probe disabled,
both replay-unavailable-* scenarios fail again
(held-fails-fast-with-head-moved and landed-or-failed-fast),
so they detect the regression.
Fixed on the way #
- The replay conflicts
concurrent-trace-replayreported under subsumption alone (a commit's own edit rewrote lines another in-flight commit had just added, for exampletrace/p1538on seed 1 with 2.55.0 andtrace/p627on seed 2 with 2.40.0) are decided by capture order: the later capture's bytes land (SPEC.md"Capture order"). - Seed 2 on 2.55.0 failed
t7withfatal: pathspec 'trace/p5500' did not match any files, becauset7deleted a path another in-flight commit was adding. The harness now waits for the landing of an in-flight commit that creates a path before another commit removes it (see "Commit-shape trace"). - A first seed-3 run failed
concurrent-trace-replayon 2.40.0 withlanded-bytes [t9 d9059a229200 trace/p1015]:t9kept the landed bytes of a path a later capture had landed first, which capture order prescribes and the checker did not accept yet.landed-bytesnow accepts exactly that case (see "Invariants"). The rerun's free-running interleaving did not reach it again. - The same first seed-3 run failed
sigkill-phase-landing-lockedon 2.55.0: the bystander exited2withtransaction-failedESRCH: no such process, read, because reading/proc/<pid>/statof the victim while it exited failed withESRCHand the owner-liveness check treated onlyENOENTas exited. It now treatsESRCHas exited too.
Open problems #
- The shared-file scenarios give the second agent a fixed 1.5 s start window, because the accepted design has no hook-visible point between capture and the hook lock. A heavily loaded host could release the first agent before the second captured.
- The
race-lostmarker sits between a lost race and its replay, but no scenario kills a transaction there yet. - The lint-staged scenarios run in a linked worktree,
because the
linked-worktree-onlycore policy rejects the hook'sgit stashin a main worktree. lint-staged in a main worktree is therefore blocked by cli-git today, independent of concurrency. - The container consumer writes its report with
console: the tagged logger is a workspace package with its own dependencies and is not installed in the container. remote-containsis checked only after the run, not at each wrapper exit.- The trace has few binary changes (12 of 12,984) and renames (42), so windows often contain none; the synthetic scenarios do not add binary or rename cases of their own.