cli-git native integration #
Purpose and how to respond #
This branch integrates the lanes of the native commit path (package/git-policy/cli/src/native/) and wires
git commit to the full transaction, so the native executable replaces the incumbent TypeScript wrapper.
Branch feat/cli-git-native-integration, worktree .claude/worktrees/cli-git-lane-integration,
created from the transactions head fd26b74a99.
Paths starting with src/, bin/ or e2e/ are relative to package/git-policy/cli/;
every other path is repository-relative.
Respond by merging the branch into main and by vetoing any item under Choices open to veto.
State #
The native executable commits for real.
git commit (anything but a dry run) runs the transaction in src/native/commit_transaction.rs and
commit_conclusion.rs; Unported::CommitTransaction and its refusal are gone.
The incumbent's end-to-end suite passes against the native executable on Git 2.55.0: 36 of 38 scenarios pass and 2 skip
by design (seeds 1 to 9; one run in the last batch failed once on a kill-window leftover, see Results).
The commit differential against the incumbent (from source) finds 10 of 10 cases equal.
The gated head is 0c4d65094e (the commit that follows it only records this document). The container gate
(which includes Clippy with -D warnings over all targets), the fuzz smoke and the mutation campaigns are green or
fully accounted for in Results. Nothing remains open.
Merged lanes #
Merged into this branch, in order:
main(30cdbc2311): the dependent-version wiring and themise.lockrevision 2 upgrade.feat/cli-git-native-landing: slice 7a, merged again at13fe865399(its mutation record).feat/cli-git-native-post-landing: slice 7b, merged again atb1d14c268c(the commit path callspost_landing.rsfor the after-landing order; there is no second ordering).feat/cli-git-native-config(1bc75f16fd):cli-git.config.jsoncand the differential.feat/cli-git-native-e2e: theE2E_WRAPPERselector, merged again at its finished headb307a723d0.feat/cli-git-native-transactions: merged again at its final head52bafbb72a.feat/cli-git-native-landing: merged again at its final head97d461f366. Its choices open to veto were checked against the commit path: the commit path chooses the lock (commit_landing_lock.rs, one attempt at a time, released before replay); the attempt keepsindex.lockafter the target advanced and recovery installs through it; theinstall.indexlink name only matters to recovery, which the transaction directory removal covers.
What was built here #
New modules (each with its *_tests.rs where it has pure logic; the transaction itself is covered by
binary_commit_tests.rs and the end-to-end suite):
commit_transaction.rs: layout capture, published workspace,preparing.json, shadow repository, private index under capture order, interactive selection, unmerged-path check, convergence. It takes no landing lock.commit_conclusion.rs: intended tree, selected worktree records, no-change path, hook dispatcher, native preparation in the shadow, hook changes,prepared.json, the landing loop, post-landing completion.commit_landing_loop.rs,commit_revalidation.rs,commit_landing_lock.rs: the replay-and-reland loop aroundlanding_attempt::land_transaction; the lock is taken for one attempt and released before replay; the starvation reservation is requested after the configured lost races and honored before every attempt.commit_no_change.rs: a correction that restores the base lands as a normalization through the landing attempt.commit_workspace.rs,commit_facts.rs,commit_worktree_records.rs,commit_replay_options.rs,commit_command.rs: the owned workspace, rule facts from the real repository with candidates from the private index, hook and selected-correction records, replay options, and the command (events, post-commit gate, backup).replay_commit.rsgainedmerge_replayandrebuild_replay(the incumbent revalidates the merged tree before it rebuilds the commit);policy_events.rsgained the concurrent-commit events;candidate_prediction.rsandcandidate_store.rsgainedStagedAtBase(candidates against the recorded base, never the movedHEAD);capture_order.rsreaches thecapture-lockedmarker;owner_lock.rsgained a view of an ancestor's lock.- Wiring:
wrapped_command.rsruns the transaction for a real commit; a valid preparation lease lets a hook's nested Git command through and skips recovery (the worktree-copy lease is honored by the forwarding,src/native/worktree_copy_forward.rs).
Decisions with reasons #
- The commit region is parsed by Git's table; a region the table refuses falls through to the policy pass and is
forwarded, so Git reports its own refusal (
an_unknown_option_is_refused_by_git_and_nothing_lands). - Candidates are the index entries of the paths the private index changes against the recorded base, passed as
:(top,literal)pathspecs; an empty scope is answered without asking Git, because an empty pathspec list would make every tracked file a candidate. - The native floor is Git 2.55.0 (settled), so the replay-plumbing probe is not ported and the two
replay-unavailable-*scenarios never run natively; the native e2e runs use--git 2.55.0. - Signals: the preparation
git commitand the replayedpre-commitrun under the signal guard, so aTERMduring a hook ends the commit with 143 and leaves no transaction (a_termination_signal_during_a_hook_ends_the_commit...). - The Markdown autofix finding now reads
monochromatic-lint --fix (markdown/<rule>) rewrites <path>., the words of the incumbent's source; the config differential showed the older wording differed.
Results #
- Config differential:
mise run //package/git-policy/cli:native:config:differential -- --require-all-equalreports 72 rows, 0 failing (the 36 pending rows were the two policies main wires). Under host load the incumbent's logger sometimes printslogger internal error: sink verification failed ... Timed out after 5000mson its standard error, which makes unrelated rows differ for that run; rerun when a row differs only by that line. - Commit differential:
mise run //package/git-policy/cli:native:differential:commit(afternative:build): final newline correction, pre-commit restage, no-change normalization, amend,-a,--include,--pathspec-from-file,--allow-empty, a concurrent replay with the phase marker, and a commit blocked by commit-only are equal in exit code, events, resulting commit, index and worktree. With--native /usr/bin/gitthe same run reports the expected differences, so the comparison can fail. - End-to-end, Git 2.55.0, image tag
integration, whole catalog (38 runs: 10 baseline pass, 26 concurrency pass, 2 skip): seeds 1, 2, 3 (after the shadow-parent fix), 4, 5, 6, 8 and 9 pass completely. Seed 3 first failedhooks-config-concurrentwithcreating .../cli-git/shadow/<id> failed: File exists: two commits raced to create the shared parent; fixed inshadow_create.rs(ensure_private_directory) with a thread-race control. Seed 7 failedsigkill-offsetonce:no-leftoversfound.git/cli-git-captures/capture.lock.<uuid>.stale, the seeded SIGKILL landed between the capture lock's rename and its removal, a window that the incumbent'sreleaseHeldLockhas in the same shape (src/owner-lock/owner-lock.ts) and that nothing sweeps. Reruns of that scenario passed, so it is a timing-dependent window shared with the incumbent design, not a deterministic native defect. Each full run takes about 6 to 33 minutes depending on host load. The scenarios the suite callssigkill-phase-*,reservation-after-lost-racesandbranch-switch-during-commitare real passes. - Container gate (
native:test:container, Git 2.56.0, image tagfollowup, image id7975b36ab8f98ed3eb57ca68ef6a01d22431c840b64c4f1d911606dbefc607ff, Clippy-D warningsover all targets included), run throughgate-slot.tson0c4d65094e: green. Library 1633 passed, 6 ignored; binary 105 passed, 1 ignored; 1 candidate-consumer test passed. The host Clippy task (native:clippy) is clean on the same head. Earlier runs on a host with load average 40 to 75 failedmarkdown::the_real_linter_rewrites_through_add_check_and_fixand, once,coordination::a_live_foreign_owner_is_waited_for_and_namedora_dead_foreign_lock_is_refused_and_left_in_placeon the 5-second command bound; each passes when the host is quieter, and the bound was not changed. - Garbage in
objects/packafter a commit (the flake ofcommit::a_pathspec_file_selects_the_committed_paths, which failed once in a mutation baseline withgarbage: 2): not a defect of the native commit and not a leftover. Git's own detachedgit maintenance run --auto --quiet --detach, which the landing starts as nativegit commitdoes (src/native/maintenance_run.rs), repacks in the background:git repack -d -l -q --cruft --write-midxwritestmp_pack_*andtmp_idx_*files thatgit count-objects -vreports as garbage until the repack renames them. The Git 2.56.0 image starts that repack after the second landing even in a repository of 11 objects (it settles to one pack plusmulti-pack-index, 0 garbage), soassert_nothing_leftraced with it: 45 of 100 runs of the test failed in the container (2 parallel), none of 800 on the host's Git 2.55.0, which starts no repack at that size. Fix, test only:edited_repositoryinsrc/native/binary_commit_tests.rssetsmaintenance.autoDetach false, so the wrapper returns after the maintenance finished; the assertion message now lists the pack directory. Controlcommit::a_landing_returns_after_its_automatic_maintenance_finished(agc.autoPackLimitof 1 and 8 MiB of incompressible files make the repack outlast the wrapper's last steps) failed 20 of 20 runs without the config line and passed 20 of 20 with it (host). After the fix the test passed 150 of 150 runs in the container and the control 20 of 20. - Git 2.55.0 probe (host Git 2.55.0,
native:test:hostandnative:test:binary:host, on an earlier head, before the last test-only commits): the library tests fail only the 2.56.0 comparisons (command_options::git_testsfour tests,command_branch_create::git_teststhree,command_addtable,git_metadata,global_arguments) and the test that needs the built linter (11 failed, 1597 passed at that head); the binary tests fail onlyforwarding::version_is_identical_to_native_git, the threeresolution::tests (all compare thegit versiontext with 2.56.0) and the real-linter test (5 failed, 92 passed at that head). Everycommit::andcoordination::test passes, and the end-to-end suite above runs on Git 2.55.0. - Fuzz smoke (
mise run //package/git-policy/cli.fuzz:smoke) on an earlier head: success, 15 targets exit 0. The generator controlgenerated_arguments_reach_every_frontier_endingneeded two changes: a real commit prints its own text, so its ending carries none, and a commit region that Git's option table refuses is forwarded so Git reports the refusal. No source undersrc/nativechanged after that run (only tests). - Planted controls (unmodified
bin/native-planted-controls.mjs, run as phase 1 of the last scoped campaign on the image built for that campaign): 66 controls, every one noticed by its named test. No non-test source changed after. - Mutation. Campaigns over the files created or changed here were run through
native:mutation:scopedwithNATIVE_MUTATION_BASELINE_SKIP=markdown::the_real_linter_rewrites_through_add_check_and_fix(that test depends on the host load, see above). Earlier per-file campaigns (commit_transaction,commit_conclusion,commit_landing_loop,commit_revalidation,commit_worktree_records,commit_landing_lock,commit_facts,commit_command,commit_no_change,commit_workspace,commit_replay_options,replay_commit,commit_preparation,wrapped_command,refusal_frontier,candidate_prediction,policy_events,owner_lock,capture_order,candidate_store) killed their survivors with controls (binary_commit_tests.rsand the*_tests.rsfiles) or moved logic into small tested functions (stages_worktree,settled_passes,union_paths,replayed_events,lost_races_after,next_attempt_number,ensure_replay_directory,is_detached,retry_while_active,landing_lease_token). The final campaign (commit_preparation.rsandcommit_transaction.rs, 88 mutants, reporttarget/verification/native-mutation-pMcBRc): 57 caught, 28 unviable, 3 missed, 0 timeouts. The 3 missed (pathspec_file_sourcereturningNone, its+replaced by*, and theDisplayofPreparationErrorreplaced by an empty write) were found after the campaign's test image was built; the controlscommit::a_pathspec_file_selects_the_committed_pathsandcommit_preparation::tests::each_preparation_failure_displays_its_own_wordswere added, and each of the 3 mutants was applied by hand to the host source and failed its control, then restored. The two open mutants of the earlier campaign are closed the same way:stages_worktreewith||replaced by&&failsa_capture_lists_worktree_changes_for_all_or_include, andretry_while_activewith its guard replaced bytruefailsthe_guard_wait_retries_only_while_another_holder_is_activeat once (its closures panic past their call cap, so the mutant no longer loops). - Mutation of
src/native/commit_convergence.rs(12 mutants,bin/mutate-native-container-noplanted.mjs, reporttarget/verification/native-mutation-6BnlGO): 7 caught, 5 unviable, 0 missed, 0 timeouts. The one survivor of the earlier campaign,CommitPasses::snapshots_equalreplaced byfalse, is killed bycommit_convergence::tests::stored_states_compare_equal_exactly_when_the_corrected_bytes_match, which stores a correction and its reversal and compares the three stored states; it failed with the mutant applied by hand. - Not mine and left alone:
mise.lockshows a working-tree edit (nightly-2026-10-11tonightly-2026-10-12) thatmise runwrote; it is not committed.
Choices open to veto #
src/native/commit_policy_preparation.rswas deleted (superseded bycommit_conclusion.rs); its no-change constants moved tocommit_no_change.rs, and the transactions branch's controls that only exercised it were removed.- The incumbent's
replayOptionsreads no signing key from an attached-S<key>(its normalization splits the key into a separate token); the native port reproduces that and pins it with a control. A signed commit that lost a race and was given-S<key>is re-signed with the configured key in both wrappers. - Deleted paths are not candidates (the content layer lists present index entries only).
Remaining #
Nothing. Every gate and mutation item of the brief is recorded above.
Rerun commands #
# repository root, native check and Clippy
mise run //package/git-policy/cli:native:check
node "${HOME}/temp/agent/gate-slot.ts" mise run //package/git-policy/cli:native:clippy
# the commit controls on the host
mise run //package/git-policy/cli:native:test:binary:host -- commit::
# the differentials (build first)
mise run //package/git-policy/cli:native:build
mise run //package/git-policy/cli:native:differential:commit
mise run //package/git-policy/cli:native:config:differential -- --require-all-equal
# the end-to-end suite, as its own unit with a memory cap
systemd-run --user --unit=int-e2e --collect --property=MemoryMax=10G \
--property=StandardOutput=file:"$HOME/temp/agent/int-e2e.log" --property=StandardError=file:"$HOME/temp/agent/int-e2e.log" \
--working-directory="$PWD/package/git-policy/cli" --setenv=PATH="$PATH" --setenv=HOME="$HOME" \
--setenv=GIT_POLICY_NATIVE_IMAGE_TAG=integration node "$HOME/temp/agent/gate-slot.ts" \
mise run //package/git-policy/cli:test:e2e:concurrent:native --seed 1 --git 2.55.0
# one mutation scope without the planted-control phase (the container gate must have built the image tag first)
cd package/git-policy/cli && GIT_POLICY_NATIVE_IMAGE_TAG=integration node "${HOME}/temp/agent/gate-slot.ts" \
node bin/mutate-native-container-noplanted.mjs --file src/native/commit_convergence.rs --timeout 900
# the container gate
GIT_POLICY_NATIVE_IMAGE_TAG=integration node "${HOME}/temp/agent/gate-slot.ts" \
mise run //package/git-policy/cli:native:test:container