cli-git Rust behavior ledger #
Every responsibility the incumbent TypeScript Git policy wrapper carries,
who consumes it,
whether the Rust rewrite keeps it,
and its proposed owner and proof in the native implementation.
This is the first step of the accepted sequence in
cli-git-rust-implementation.md
("Implementation sequence and verification").
It is an inventory:
it changes no accepted decision and proposes no design beyond owner module names.
Source and conventions #
Source:
a read-only survey on 2026-10-05.
Line numbers are as of commit cd54f8b64.
The incumbent TypeScript under package/git-policy/cli/src (outside src/native)
and package/git-policy/cli/SPEC.md last changed in cf2bf70d2 (2026-09-26).
The native Rust files are cited as of df25471a9,
which landed during the survey and added the configuration and registry modules.
doc/handover/cli-git-rust-implementation.md also changed during the survey,
so it is cited by section name.
Path convention:
SPEC.md,
README.md,
and paths starting with src/,
e2e/,
perf/,
or bin/ are relative to package/git-policy/cli/.
Every other path is repository-relative.
A bare line number or range refers to the file of the nearest preceding citation that carries a line number.
Planning citations:
"implementation plan" is doc/planning/cli-git-rust-implementation.md,
"rewrite scope" is doc/planning/cli-git-rust-rewrite.md,
and the accepted decision is doc/decision/cli-git-rust-rewrite.md.
Each responsibility records these points:
- Behavior: what the incumbent does, with the implementing source.
- Spec:
the
SPEC.mdlines that state it, or that no section states it. - Consumers: who depends on it.
- Status:
retainedorretired. A retired entry cites the planning text that retires it. - Rust owner:
a module under
package/git-policy/cli/src/native/. Atdf25471a9these modules exist:global_arguments.rs,config_loading.rs,config_error.rs,config_file.rs,config_parse.rs,config_policies.rs,config_schema.rs,config_values.rs, andpolicy_registry.rs. Every other name is marked "proposed" and is for the owning delegate to confirm. - Consumer-level test:
what is run and what is observed.
"Standard fixture" means the built native
gitexecutable, first onPATH, in a disposable repository with a local bare remote, inside the bounded Git 2.56.0 container image (implementation plan lines 326 to 338). - Native state:
absent,in progress, orimplemented. "In progress" means theResumption 2026-10-05section ofdoc/handover/cli-git-rust-implementation.mddelegates the area and no module for it exists atdf25471a9. "Implemented" means a library module with unit tests exists. No native executable exists atdf25471a9(src/native/lib.rs:1), so no consumer-level test in this ledger has run.
Measured size #
Measured with tokei 15.0.0 over package/git-policy/cli/src excluding native;
code lines only.
- Source outside tests and built-artifact fixtures: 312 files, 40,559 lines.
- Built-artifact fixtures under
src/trust/fixture: 53 files, 9,379 lines. - Unit tests (
*.unit.test.ts): 110 files, 24,102 lines. - Per source directory,
tests excluded:
policy-engine135 files and 18,582 lines;trust42 files and 5,939 lines;worktree-copy25 files and 3,755 lines; top-level files 33 and 3,587 lines;optional18 files and 2,211 lines;parser20 files and 1,837 lines;index-lock11 files and 1,645 lines;shadow-repository8 files and 1,176 lines;hook-dispatch4 files and 542 lines;rule6 files and 453 lines;owner-lock2 files and 386 lines;api6 files and 317 lines;maintenance2 files and 129 lines. - Inside
policy-engine, by file-name family:commit-transaction-*without recovery 36 files and 4,798 lines;commit-landing-*14 files and 2,301 lines;commit-transaction-recovery-*12 files and 1,848 lines;commit-replay-*10 files and 1,772 lines;manual-push-*8 files and 1,215 lines;commit-capture-order-*8 files and 1,109 lines. - Harnesses:
e2e48 source files and 7,782 lines plus 7 test files and 1,050 lines;perf26 files and 3,498 lines. - Sibling packages:
package/git/executable7 source files and 409 lines;package/git-policy/repository9 and 1,119;package/git-policy/forbidden-strings6 and 633;package/git-policy/markdown-lint5 and 600;package/git-policy/api6 and 305.
Tally #
Each level-3 heading is one responsibility,
counted with rg --multiline --count-matches over the Status and Native state points of this file.
- Responsibilities: 112 in total.
- Status: 92 retained, 20 retired. The retired entries are executable configuration discovery, plugin registration, the 10 trust entries, the 5 authoring entries, older-Git degradation, and the TypeScript unit suites and built-artifact fixtures.
- Native state at
df25471a9: 8 implemented as library code without an executable, 15 in progress, 88 absent, and 1 entry (the unit suites) that is itself verification.
Entry and dispatch #
Executable entry #
- Behavior:
src/index.ts:1carries the Node shebang;src/index.ts:40-41runsrunCliGitonly when Node executes the file as the program entry.package/git-policy/cli/package.json:17-19maps thegitbin name todist/final/node/index.mjs. The installed shimnode_modules/.bin/gitis a package-manager shell script that starts Node on that file. - Spec:
SPEC.md:48-60. - Consumers:
every
gitinvocation whosePATHresolves the shim first. Rootmise.toml:1252-1253putsnode_modules/.binonPATH; rootpackage.json:36depends on the package. Agent tooling reaches it the same way:AGENTS.md:1338(rule CLG) names its guards. - Status: retained. The implementation plan lines 425 to 426 require the installed launcher to resolve directly to the native executable, not to a Node process that starts it.
- Rust owner:
a thin binary entry beside
lib.rs(implementation plan lines 29 to 35). - Consumer-level test:
in the standard fixture,
run
git --versionthroughPATHand inspect the process tree; observe native Git's version text and no Node process. - Native state: in progress.
Startup order #
- Behavior:
runCliGit(src/bin.ts:109-465) runs these steps in order: install the lock PID environment (110); detect the management namespace (139-148); resolve real Git (169,187); resolve worktree identity when classification skips configuration (191-197); recover dead commit transactions unless a preparation lease is inherited (199-204); load configuration (208-210); run the commit transaction (248-257); run the pre-forward engine when no transaction applied (261-272); run the manual-push gate (314-346); forward to real Git when no commit landed (357-369); run the post-commit lifecycle and auto-push (385-423); print post-command output (425-428). - Spec:
SPEC.md:1991-2010,3497-3503. - Consumers: every wrapper invocation.
- Status: retained.
- Rust owner:
wrapper_main.rs(proposed). - Consumer-level test:
in the standard fixture,
plant a dead-owner transaction directory and an invalid configuration,
then run
git add -- a.txt; observe that the transaction directory is recovered before the configuration failure is reported with exit2. - Native state: absent.
Global option parsing #
- Behavior:
parseGlobalOptions(src/parse-global-options.ts:203-210) walks the tokens before the subcommand. It applies each-C <path>to an effective working directory (68-83,133-155), skips one value after-c,-C,--git-dir,--work-tree,--namespace,--super-prefix, and--attr-source(12-20), treats every other dash-led token as a flag (166-174), and marks--version,-v,--help, and-has short-circuit forms (25-30). It returnseffectiveCwd,subcommandIndex, andwillShortCircuit(35-48). - Spec:
SPEC.md:779-797. - Consumers:
25 non-test source files import it
(
rg --files-with-matches "parse-global-options" src --glob '!**/*.unit.test.ts' --glob '!src/native/**', minus the file itself). - Status: retained. The native table differs from the incumbent table; see "Spec and code disagreements" and "Incumbent defects and stale comments".
- Rust owner:
global_arguments.rs(exists). - Consumer-level test:
in the standard fixture,
run each global option form,
including a missing value,
an unknown option,
and a non-UTF-8
-Cpath, through the nativegitand through/usr/bin/git; observe identical exit status and output. - Native state:
implemented as a library function (
src/native/global_arguments.rs:83-157). Evidence: 5 unit tests insrc/native/global_arguments_tests.rs, part of the 9 tests and Clippy pass ofmise run //package/git-policy/cli:native:test:containerrecorded in theResumption 2026-10-05section ofdoc/handover/cli-git-rust-implementation.md. No executable consumes it yet, so the consumer-level test has not run.
Configuration-loading fast path #
- Behavior:
classifyConfigLoading(src/trust/command-classification.ts:267-304) returnsskip-configfor 27 inspection commands (17-45) and forbranchandtagforms without a mutating flag that list or take no positional (49-118,178-251,299-303). Every other command, and an absent subcommand, returnsload-config.resolveRuntimeConfig(src/trust/runtime-config.ts:36-61) consults it before discovery, andsrc/bin.ts:191-197reuses the worktree identity only on the skip path. Short-circuit forms never load configuration (src/bin.ts:208-210). - Spec:
SPEC.md:787-797. - Consumers:
every wrapped inspection command;
the
read-onlyandno-configscenarios ofperf/lifecycle-latency-contracts.ts:219-231. - Status: retained. The implementation plan lines 76 to 77 keep the fast path: operations that need no policy configuration must not initialize the policy engines.
- Rust owner:
config_loading.rs(exists). - Consumer-level test:
in the standard fixture,
write an invalid
cli-git.config.jsonc, then rungit statusandgit add -- a.txt; observe thatstatussucceeds andaddexits2with aconfig-invalidevent. - Native state:
implemented as a library function (
src/native/config_loading.rs:210-229). Evidence: 4 unit tests insrc/native/config_loading_tests.rs, in the same recorded 9-test and Clippy pass. No executable consumes it yet.
Wrapper controls and escape hatches #
- Behavior:
parsePolicyControls(src/policy-engine/controls.ts:132-226) removes wrapper-only tokens before Git's--separator and outside option values:--cli-git-keep-going(12), one--no-enforce-<policy-id>per registered policy (69-71,142-147), and the aliases--no-enforce-worktree,--no-enforce-worktree-branch, and--no-enforce-bulk-add(37-50). It returns the forwardable arguments, the keep-going flag, and the escaped policy IDs.stripEscapeHatch(src/escape-hatch.ts:81-135) removes one flag-position token for the per-command checks.--no-enforce-onlybelongs to the commit-only transform (src/parser/commit.ts:25), and--no-worktree-copyto worktree copy (src/escape-hatch.ts:15). - Spec:
SPEC.md:1246-1252,4005-4008. - Consumers:
agents and humans bypassing one policy for one invocation;
AGENTS.md:1338(rule CLG) restricts when agents may use them. - Status: retained.
- Rust owner:
wrapper_controls.rs(proposed). - Consumer-level test:
in the standard fixture,
run
git add --no-enforce-add-explicit .,git add --no-enforce-bulk-add ., andgit commit -m --no-enforce-only -- a.txt; observe that the first two stage, the wrapper token never reaches Git, and the third commits with the literal message--no-enforce-only. - Native state: absent.
Post-command output #
- Behavior:
printPostCommandOutput(src/post-command-output.ts:38-103) prints one line to stdout after a successful version request (88-94) and one human note aftergit statusunless the output is machine-readable or the caller setadvice.statusHints(72-87,95-102). - Spec:
no
SPEC.mdsection states it. - Consumers:
humans reading
git status; any script that parsesgit --versionoutput sees the added line. - Status: retained. The implementation plan does not name it; see "Open questions".
- Rust owner:
post_command_output.rs(proposed). - Consumer-level test:
in the standard fixture,
run
git status,git status --porcelain, andgit -c advice.statusHints=true status; observe the note only in the first. - Native state: absent.
Real Git and child processes #
Real-Git resolution and self-exclusion #
- Behavior:
resolveRealGit(package/git/executable/src/resolve-real-git.ts:360-414) builds absolute candidates fromPATHand, on Windows,PATHEXT(78-96,155-226), promotes common platform locations thatPATHexposes (package/git/executable/src/platform-paths.ts:10-22,44-98), and returns the first executable candidate that is not a wrapper shim (package/git/executable/src/resolve-real-git.ts:290-338).isGitPolicySelfShim(package/git/executable/src/self-shim.ts:185-246) returnsfalsefor any ELF, PE, or Mach-O header (34-45,212-218), and otherwise searches at most 64 KiB of script text for four markers naming the package or its bundled entry (139-164). Successful results are cached for the process (package/git/executable/src/resolution-cache.ts). - Spec:
SPEC.md:29-38;README.md:21-38. - Consumers:
the wrapper (
src/bin.ts:33,169,187;src/effective-target.ts:6;src/policy-engine/branch-worktree-check.ts;src/policy-engine/direct-check-facts.ts;src/policy-engine/direct-fix.ts;src/rule/commit-index-check.ts;src/rule/commit-sequencer-check.ts;src/maintenance/hk-config-cleanup-command.ts) andpackage/pi-plugin/auto-mode/src/git-worktree-read-allowlist.ts. - Status: retained. The implementation plan lines 84 to 91 port resolution, wrapper-self exclusion, and platform lookup into Rust, and state that the TypeScript resolver used by other consumers needs native-wrapper recognition at cutover. The incumbent classifies every native executable as real Git, so an unchanged TypeScript resolver would select a native wrapper.
- Rust owner:
git_resolution.rs(proposed). - Consumer-level test:
in the standard fixture,
place the native wrapper under two
PATHdirectories ahead of real Git and rungit rev-parse --git-dir; observe one real-Git process and no recursion. Repeat with no real Git onPATH; observe a diagnostic and a nonzero exit. - Native state: in progress.
Alias resolution and built-in command table #
- Behavior:
resolveForwardedCommand(src/forwarded-command.ts:261-397) resolves the command a forwarded invocation runs. Names inGIT_BUILTIN_COMMANDS(src/git-builtin-commands.ts:17, taken from Git 2.55.0) are never treated as aliases. Other names are looked up asalias.<name>andalias.<name>.command(src/forwarded-command.ts:219-259), split with Git'ssplit_cmdlinequoting rules (112-217), and expanded up to 16 times (28). A value starting with!is a shell alias and stays unresolved. - Spec:
SPEC.md:910-918,3472-3473. - Consumers: index-writer coordination and worktree-copy applicability.
- Status: retained.
- Rust owner:
alias_resolution.rs(proposed). - Consumer-level test:
in the standard fixture,
define
alias.wta = worktree addand a chained alias, then rungit wta ../topicfrom a linked worktree; observe that ignored files are copied into the new worktree. - Native state: absent.
Worktree identity resolution #
- Behavior:
resolveGitWorktreeIdentity(src/git-worktree-identity.ts:298-374) replays the caller's global options throughgit rev-parse --path-format=absolute --is-bare-repository --git-dir --git-common-dir --show-cdup(158-228), canonicalizes the paths, and classifies the target asoutside-worktree,bare-repository,main-worktree, orlinked-worktree(25-97,365-373). - Spec:
SPEC.md:903-908. - Consumers:
linked-worktree enforcement (
src/effective-target.ts:62-86), worktree copy (src/worktree-copy/git-observer.ts:93), and startup recovery (src/bin.ts:191-204). - Status: retained.
- Rust owner:
worktree_identity.rs(proposed). - Consumer-level test:
in the standard fixture,
run a guarded command with
--git-dirand--work-treenaming a main worktree from inside a linked one; observe the main-worktree rejection. - Native state: absent.
Child environment and lock PID injection #
- Behavior:
installGitChildEnvironment(src/git-child-environment.ts:191-194) appendscore.lockfilePid=truethroughGIT_CONFIG_COUNT,GIT_CONFIG_KEY_<n>, andGIT_CONFIG_VALUE_<n>(103-157). It preserves existing entries, adds nothing when the last numberedcore.lockfilePidentry already reads as true, and adds nothing whenGIT_CONFIG_COUNTis malformed (74-83,119-122). Private preparation removesGIT_DIR,GIT_WORK_TREE,GIT_COMMON_DIR, andGIT_OBJECT_DIRECTORYfrom the native commit's environment (src/policy-engine/commit-preparation-native.ts:96-101). Leases travel inCLI_GIT_PREPARATION_LEASE,CLI_GIT_LANDING_LEASE, andCLI_GIT_WORKTREE_COPY_LEASE(src/hook-dispatch/hook-dispatch-plan.ts:57;src/index-lock/landing-lease.ts:26;src/worktree-copy/journal-lock.ts:63). - Spec:
SPEC.md:3382-3398,2209-2213,2455-2458,3487-3493. - Consumers:
every forwarded and spawned Git;
foreign
index.lockevidence reads the PID files this setting produces. - Status: retained.
- Rust owner:
git_child_environment.rs(proposed). - Consumer-level test:
in the standard fixture,
run a wrapped
git addheld in a hook withGIT_CONFIG_COUNT=1already set; observe the caller's entry intact, a second entry forcore.lockfilePid, and a PID file besideindex.lock. - Native state: in progress.
Forwarding, standard streams, signals, and exit codes #
- Behavior:
forwardToRealGit(src/forward-real-git.ts:41-91) resolves the command, takes index-writer coordination, and runs real Git throughrunGitWithWorktreeCopy. Real Git is spawned with an argument array, no shell, and inherited standard streams (src/worktree-copy/lifecycle.ts:75-106). The exit mapping is insrc/bin.ts:431-464: a failed real Git exits with its code, or1when it has none (454-456); a policy decision exits1or2(441-442); recovery and unproven-lock errors emit one engine-failure event and exit2(432-440); a worktree-copy failure exits2, or Git's code, or1(443-453); any other error prints its message and exits1(457-460). The wrapper source installs no signal handler:rg "process\.on\(|process\.once\(|\.on\(['\"]SIG" src --glob '!src/native/**' --glob '!**/*.unit.test.ts'returns nothing, with and without--hidden --no-ignore; without the test exclusion it matches two unit-test files only. A Git child ended by a signal therefore yields exit1. - Spec:
SPEC.md:1577-1622,1066-1073. - Consumers: every forwarded command; callers that branch on Git's exit status.
- Status:
retained.
The implementation plan lines 84 to 91 port child environment,
signals,
and exit handling,
and lines 47 to 49 require argument bytes and path representations to be preserved.
The incumbent holds arguments as JavaScript strings (
src/bin.ts:114-115). - Rust owner:
git_forwarding.rs(proposed). - Consumer-level test:
in the standard fixture,
run a forwarded command that exits
3, one killed bySIGTERM, and one with a non-UTF-8 pathspec; observe the wrapper's exit status and that Git received the exact bytes. - Native state: in progress.
Configuration #
Executable configuration discovery #
- Behavior:
discoverConfig(src/trust/config-discovery.ts:142-178) finds the repository root from the effective directory and returnscli-git.config.mjs, or elsecli-git.config.ts, rejecting symbolic links and non-regular files (src/trust/config-discovery.ts:68-90). The root configuration iscli-git.config.ts, which imports plugins from@monochromatic-dev/git-policy-cli/ts(cli-git.config.ts:6-12). - Spec:
SPEC.md:19-27,718-747. - Consumers: this repository's root configuration.
- Status:
retired.
The implementation plan lines 71 to 75 delete executable-config discovery;
lines 440 to 443 replace it with an explicit migration diagnostic for legacy
.tsor.mjsfiles and a hand translation of this repository's configuration. The rewrite scope lines 110 to 115 record the user's selection of JSONC. - Rust owner:
none for discovery of executable files;
config_file.rsowns the migration diagnostic, listed under "Responsibilities the plan adds". - Consumer-level test:
in the standard fixture,
leave only
cli-git.config.tsin the repository root and rungit add -- a.txt; observe the migration diagnostic and that no TypeScript ran. - Native state:
implemented for the diagnostic as a library function:
load_repository_config(src/native/config_file.rs:260-310) returns themigration_requirederror (124-136) when only a legacy file exists. Evidence: 13 unit tests insrc/native/config_file_tests.rs; no gate run fordf25471a9is recorded in a handover document.
Configuration value validation #
- Behavior:
validateConfig(src/trust/config-validation.ts:396-544) rejects unknown top-level keys (401-407), validates concurrency keys, registers built-ins and plugin policies, resolves each policy ID, applies defaults, parses option values through each policy's schema, and resolves declared inputs.runPolicyEnginerejects an unknown configured or selected policy ID withconfig-invalid(src/policy-engine/engine.ts:207-241). A severity isoff,warn, orerror(src/api/policy-types.ts:21). - Spec:
SPEC.md:718-747. - Consumers:
the root configuration's
policiesmap (cli-git.config.ts:27-58). - Status: retained for values: severities, policy IDs, per-policy options, and concurrency keys. The implementation plan lines 55 to 61 require the same errors from a typed JSONC document. The plugin and trust keys are retired; see "Plugin registration" and "Trust consent protocol".
- Rust owner:
config_file.rs,config_parse.rs,config_policies.rs,config_values.rs,config_schema.rs, andconfig_error.rs(exist). - Consumer-level test:
in the standard fixture,
run
git add -- a.txtonce per invalid document: an unknown key, an unknown policy ID, a duplicate key, an invalid severity, and an invalid option value; observe exit2and oneconfig-invalidevent each, before any policy runs. - Native state:
implemented as library modules.
load_repository_config(src/native/config_file.rs:260-310) reads onlycli-git.config.jsoncat a given repository root (41), refuses more than 1 MiB (61), andparse_config(src/native/config_parse.rs:154-198) accepts the top-level keyspolicies,hooks,indexLock, andlanding(39). Typed options exist for two policies:builtin_rulesfor forbidden-strings, andrulesandexcludefor Markdown autofix (src/native/config_schema.rs:75-93). Evidence: 38 unit tests inconfig_file_tests.rs,config_parse_tests.rs, andconfig_values_tests.rs; no gate run fordf25471a9is recorded in a handover document. Nothing emits aconfig-invalidevent yet.
Concurrency configuration #
- Behavior:
validateConcurrencyConfig(src/trust/config-validation-concurrency.ts:167-205) acceptshooks.concurrentCommits(defaultfalse),indexLock.unprovenOwnerTimeoutMs(default1000), andlanding.reserveAfterLostRaces(default1), with the defaults at60-67. Startup recovery and config-free forwarding use the defaults (src/bin.ts:361-366). - Spec:
SPEC.md:749-775. - Consumers:
the hook lock,
the foreign
index.lockwait, and the starvation reservation. - Status: retained. The implementation plan line 57 names "existing concurrency controls" as typed settings.
- Rust owner:
config_parse.rsandconfig_schema.rs(exist). - Consumer-level test:
in the standard fixture,
set each key to a valid value,
zero,
a negative number,
a fraction,
a string,
and an unknown nested key;
observe acceptance or a
config-invalidexit2asSPEC.md:770-774lists. - Native state:
implemented as library code:
apply_concurrency(src/native/config_parse.rs:85-150) and the defaults1000and1(src/native/config_schema.rs:26-29,122-167). Evidence: the unit tests named under "Configuration value validation"; no recorded gate run.
Plugin registration #
- Behavior:
validateConfigregisters each namespace ofpluginsand resolves plugin policy IDs as<namespace>/<policy-name>(src/trust/config-validation.ts:411-420). The root configuration registers the namespacesmarkdown,mono, andsecurity(cli-git.config.ts:22-26). - Spec:
SPEC.md:336-356,725-728. - Consumers: the root configuration.
- Status: retired. The implementation plan lines 63 to 67 state that there are no imports, callbacks, plugin package names, command arrays, or executable-path overrides, and lines 103 to 106 fix the registry to shipped policies. The rewrite scope lines 113 to 115 record the user's rejection of a generic external-policy extension.
- Rust owner:
config_parse.rs(exists), for the rejection. - Consumer-level test:
in the standard fixture,
write a JSONC document with a
pluginskey; observe aconfig-invalidexit2naming the retired key. - Native state:
implemented as library code:
unknown_top_level_key(src/native/config_parse.rs:49-63) returns a specific message forpluginsand fortrust. The native registry keeps this repository's namespaced names as fixed policy names:markdown/autofix,mono/forbidden-root-context,mono/dependent-version-bump, andsecurity/forbidden-strings(src/native/policy_registry.rs:95-160).
Trust subsystem #
Every entry in this section is retired by the implementation plan lines 71 to 75
("Delete executable-config discovery,
bundling,
stored-code evaluation,
consent,
and trust-registry management")
and by the rewrite scope lines 115 and 121 to 124
(the user wants the executable-config trust subsystem removed
and no replacement trust registry or global policy layer).
Retained modules still import helpers from src/trust/:
17 files import src/trust/registry-io.ts
(rg --files-with-matches "trust/registry-io" src --glob '!src/trust/**' --glob '!**/*.unit.test.ts'),
and src/bin.ts:35,
44 and src/policy-engine/commit-transaction.ts:22 import classification and concurrency helpers.
The implementation plan lines 78 to 80 move those helpers by responsibility.
Trust candidate capture #
- Behavior:
captureTrustCandidate(src/trust/candidate.ts:77-163) opens the configuration without following links and resolves filesystem identity, through/proc/<pid>/fd/<fd>on Linux (53). - Spec:
SPEC.md:1752-1762. - Consumers: trust commands and strict loading.
- Status: retired.
- Rust owner: none.
- Consumer-level test: covered by the retired-command test under "Trust management commands".
- Native state: absent.
MJS self-containment validation #
- Behavior:
validateMjs(src/trust/mjs-validator.ts:58-197) parses module syntax without execution and rejects imports other than Node built-ins. - Spec:
SPEC.md:1736-1750. - Consumers: MJS trust.
- Status: retired.
- Rust owner: none.
- Consumer-level test: none; no JavaScript is parsed or executed by the native wrapper.
- Native state: absent.
TypeScript bundling and source capture #
- Behavior:
buildTypeScriptCandidate(src/trust/typescript-builder.ts:95-243) bundles the configuration with Rolldown into one chunk;sourceCapturePlugin(src/trust/typescript-source-capture.ts:204-344) records the tracked source graph. - Spec:
SPEC.md:1917-1966. - Consumers:
TypeScript trust for the root
cli-git.config.ts. - Status: retired.
- Rust owner: none.
- Consumer-level test: none.
- Native state: absent.
Stored-code evaluation #
- Behavior:
loadStrictMjsandloadStrictTypeScript(src/trust/config-loader.ts:180-350) compare live bytes with stored snapshots and import the stored executable snapshot (107-170). - Spec:
SPEC.md:1764-1780. - Consumers: every configuration-loading wrapper command.
- Status: retired.
- Rust owner: none.
- Consumer-level test:
in the standard fixture,
run a configuration-loading command with
stracefollowing children; observe that no Node or other interpreter starts for configuration. - Native state: absent.
Relaxed trust mode #
- Behavior:
loadRelaxedConfig(src/trust/relaxed-loader.ts:272-303) rebuilds or re-snapshots a trusted configuration whenCLI_GIT_NO_PARANOIDnames it (src/trust/trust-service.ts:182;src/trust/relaxed-paths.ts:138-166). - Spec:
SPEC.md:1881-1915. The spec does not name the environment variable. - Consumers: developers who set the variable.
- Status: retired.
- Rust owner: none.
- Consumer-level test:
in the standard fixture,
set
CLI_GIT_NO_PARANOIDand run a wrapped command; observe no change in behavior. - Native state: absent.
Trust consent protocol #
- Behavior:
trustConfig(src/trust/trust-service.ts:66-176) discloses the candidate on stderr and accepts an interactive affirmative response or--yes;trust.childrenadds a second stage for recursive authority. - Spec:
SPEC.md:1782-1807. - Consumers:
git cli-git trust. - Status: retired. The implementation plan lines 68 to 69 add that repository settings can disable policies or change permitted severities without consent, and that no other approval mechanism replaces the prompts.
- Rust owner: none.
- Consumer-level test:
in the standard fixture,
change
cli-git.config.jsoncto disable a policy and run the affected command; observe that the change takes effect with no prompt and no trust failure. - Native state: absent.
Trust registry storage #
- Behavior:
records live under an account-derived root (
src/trust/account-root.ts:35-65) at reversible base64url paths (src/trust/registry-path.ts:41-219), with private modes on POSIX and protected ACLs on Windows (src/trust/registry-io.ts:25-29,130-247), and atomic prepared-record installation (src/trust/registry-record-preparation.ts:168-303). - Spec:
SPEC.md:1624-1734. - Consumers: trust loading and management.
- Status: retired. The implementation plan lines 444 to 445 leave old trust records inert rather than deleting them.
- Rust owner: none.
- Consumer-level test: in the standard fixture, seed a trust registry under a disposable home and run wrapped commands; observe the registry bytes unchanged.
- Native state: absent.
Recursive enrollment, revocation, and provenance journals #
- Behavior:
autoEnrollRecursiveConfig(src/trust/recursive-enrollment.ts:272-316) enrolls descendants of a recursive root;revokeRecursiveTrust(src/trust/recursive-revocation.ts:168-262) removes inherited records; provenance journals are applied and recovered insrc/trust/registry-transaction.ts:135-291under the recursive-operation lock (src/trust/registry-recursive-lock.ts:159-259). - Spec:
SPEC.md:1809-1879,3339-3356. - Consumers: trust loading in every wrapped command.
- Status: retired.
- Rust owner: none.
- Consumer-level test: none beyond the inert-registry test under "Trust registry storage".
- Native state: absent.
Trust management commands #
- Behavior:
runTrustManagement(src/trust/management-runtime.ts:177-294) implementstrust,untrust, andstatus, each writing one JSON object to stdout. - Spec:
SPEC.md:799-885. - Consumers:
humans and agents enrolling a repository;
.github/workflows/cli-git-trust.yml:189-232(jobtrust) runs the trust suites on Linux, macOS, and Windows. - Status: retired. The implementation plan line 444 states that retired trust commands explain that JSONC no longer requires code-execution approval.
- Rust owner:
management_retired.rs(proposed) for the explanation. - Consumer-level test:
in the standard fixture,
run
git cli-git trust,git cli-git trust --yes,git cli-git untrust, andgit cli-git status; observe the explanation and that no registry file is read or written. The exit status and stream are undetermined; see "Open questions". - Native state: in progress (the handover lists a management-command skeleton).
Trust warnings #
- Behavior:
trust warnings are JSON objects on stderr with the codes at
src/trust/types.ts:166-189. - Spec:
SPEC.md:1309-1325. - Consumers: none measured outside the package.
- Status: retired.
- Rust owner: none.
- Consumer-level test: none.
- Native state: absent.
Authoring surfaces #
Every entry in this section is retired by the implementation plan lines 33 to 35 (no permanent TypeScript bridge and no general plugin runtime), lines 63 to 67, and lines 295 to 297 (retired implementations and authoring surfaces are deleted only after their consumers have moved).
Authoring API #
- Behavior:
definePolicy,definePlugin,defineConfig, anddefinePolicyOptionsreturn their argument (src/api/authoring.ts:37-116); the types are insrc/api/config-types.ts,src/api/policy-types.ts,src/api/context-types.ts, andsrc/api/policy-input-types.ts. The canonical copy ispackage/git-policy/api/src. - Spec:
SPEC.md:77-398,628-716. - Consumers:
cli-git.config.ts:6-12;package/git-policy/repository,package/git-policy/forbidden-strings, andpackage/git-policy/markdown-lint, which define policies with it. - Status: retired.
- Rust owner: none.
- Consumer-level test:
after cutover,
rg "git-policy-cli/ts|git-policy-api" . --glob '!doc/**'returns no importer. - Native state: absent.
Package exports and single MJS artifact #
- Behavior:
package/git-policy/cli/package.json:8-16exports the built artifact and./ts;src/authoring.ts:6-99re-exports the authoring API, the optional plugins, and final-newline helpers.package/git-policy/cli/rolldown.node.config.tsbuilds one static bundle. - Spec:
SPEC.md:48-75,4254-4283. - Consumers:
package/config/pnpr/config.yaml:76-80lists the fivegit-policy-*packages for the private registry;.changeset/config.json:21names the wrapper package; the mise tasksbuild,pack:npm, andtest:built:trust(package/git-policy/cli/mise.toml:25-131). - Status: retired. The implementation plan lines 29 to 32 keep the TypeScript executable available until the Rust replacement passes the consumer contracts.
- Rust owner: none; native packaging is implementation sequence step 7.
- Consumer-level test:
install the native package into a disposable project;
observe that
PATHresolves itsgitfirst and that no JavaScript artifact is installed. - Native state: absent.
Optional-policy mirrors #
- Behavior:
file-enforcer.config.ts:2260-2322copies the sources ofpackage/git-policy/repository,package/git-policy/forbidden-strings, andpackage/git-policy/markdown-lintintosrc/optional/, rewriting their API imports, so the single artifact bundles them. - Spec:
SPEC.md:62-75. - Consumers:
the wrapper build;
package/dev-script/file-enforcer/src/generated-policy-contracts.unit.test.ts. - Status: retired. The implementation plan line 435 lists file-enforcer-owned scanner and build integration among the things updated together at cutover.
- Rust owner: none.
- Consumer-level test:
after cutover,
running file-enforcer produces no file under
package/git-policy/cli/src/optional/. - Native state: absent.
Internal test exports #
- Behavior:
src/index.ts:11-37exportsinternalTestExportsand manual-push helpers so built-artifact tests reach internals (src/internal-test-exports.ts:202-236). - Spec:
no
SPEC.mdsection states it. - Consumers:
unit tests under
src/that exercise the built artifact (rg --files-with-matches "internalTestExports|internal-test-exports" packagelists files undersrc/only). - Status: retired with the JavaScript artifact. The behaviors those tests cover keep their own entries in this ledger.
- Rust owner: none.
- Consumer-level test: none.
- Native state: absent.
Supported Node runtime contract #
- Behavior:
package/git-policy/cli/package.json:30-32declares^24.11.0 || ^26.0.0;src/runtime-contract.host-evidence.tsimports the built artifact and runs representative commands at each floor. - Spec:
README.md:6-19. - Consumers:
.github/workflows/cli-git-trust.yml:34-187(jobsruntime-policy,latest-lts-policy, andsupported-runtime); the mise taskverify:supported-runtime(package/git-policy/cli/mise.toml:84-86). - Status: retired with the Node executable. The rewrite scope lines 104 to 106 state that eliminating an external Node installation is not a hard requirement, and the implementation plan lines 425 to 426 remove Node from the launch path.
- Rust owner: none.
- Consumer-level test: none.
- Native state: absent.
Management commands #
Namespace dispatch, grammar, and help #
- Behavior:
the wrapper owns an invocation only when the parsed subcommand is exactly
cli-git(src/bin.ts:147-148).parseManagementArgs(src/management-parser.ts:175-265) accepts--helpor-h,trust [--yes],untrust,status, andcheckorfixwith repeatable--policy <id>,--all, and pathspecs.runManagementCommand(src/management.ts:136-316) prints usage to stderr and exits2on a refusal (149-152), prints help to stdout and exits0(153-156), and requires exactly one scope forcheckandfix:--all, or a non-empty pathspec list after--(171-198). Help returns before real-Git resolution and recovery (src/bin.ts:159-174). - Spec:
SPEC.md:796-833. - Consumers:
humans and agents running
git cli-git;.github/workflows/final-newline.yml:38-39runs a fixture that calls the direct check. - Status:
retained for the namespace,
help,
check, andfix. The implementation plan lines 107 to 112 preservecheckandfix, and line 438 lists the surviving management-command documentation. - Rust owner:
management_arguments.rs(proposed). - Consumer-level test:
in the standard fixture,
run
git cli-git --help,git cli-git check,git cli-git check --all -- a.txt,git cli-git check a.txt, andgit add cli-git; observe help on stdout with exit0, exit2for the three malformed scopes, and ordinary staging of a file namedcli-git. - Native state: in progress (management-command skeleton).
Direct check #
- Behavior:
git cli-git checkloads configuration withforceLoad(src/management.ts:99-118), projects the selected worktree bytes into a private index (src/policy-engine/direct-check-facts.ts:66-111), runs the engine with thedirect-checktrigger and the optional--policyfilter (src/management.ts:291-307), writes events to stdout, and returns the engine's exit code (311-315).--allbecomes the pathspec:/(234-236). - Spec:
SPEC.md:1209-1213. - Consumers:
src/trust/fixture/final-newline-workflow.ts, run by.github/workflows/final-newline.yml:38-39; agents checking policies without committing. - Status: retained.
- Rust owner:
management_check.rs(proposed). - Consumer-level test:
in the standard fixture,
write a worktree file that violates one policy and differs from its staged copy,
then run
git cli-git check --policy final-newline -- a.txt; observe onefindingevent on stdout for the worktree bytes, exit0or1by severity, and unchanged index and worktree bytes. - Native state: absent.
Direct fix #
- Behavior:
runDirectFix(src/policy-engine/direct-fix.ts:238-272) holds the landing lock (181), snapshots the real index, converges patches on private candidate state (src/policy-engine/direct-fix-convergence.ts:103-309, at most 8 changed passes,33), replaces only changed worktree files (src/policy-engine/direct-fix-install.ts:230-339), verifies that every real index blob is unchanged, and emits findings plus onefix-summary. - Spec:
SPEC.md:1215-1227,837. - Consumers:
humans and agents applying fixes;
the
dependent-version-bumppolicy declares thedirect-fixtrigger for this command (src/optional/repository-policy/dependent-version-bump-policy.ts:253-258). - Status: retained.
- Rust owner:
management_fix.rs(proposed). - Consumer-level test:
in the standard fixture,
stage one version of a file,
leave a different fixable version in the worktree,
and run
git cli-git fix -- a.txtwhile a concurrent wrapped commit lands; observe the fixed worktree bytes, a byte-identical real index, onefix-summaryon stdout, and exit0. - Native state: absent.
Policy engine #
Registry, order, and triggers #
- Behavior:
BUILT_IN_POLICIES(src/policy-engine/built-ins.ts:21-27) fixes the built-in order:require-root,linked-worktree-only,branch-worktree-only,add-explicit,final-newline.runPolicyEngine(src/policy-engine/engine.ts:157-420) runs built-ins (279-311), then fixed transforms for thepre-forwardtrigger only (315-326), then plugin policies in registration order (354-375). A policy runs only for the triggers it declares (src/policy-engine/policy-stage.ts:135-137); the trigger set ispre-forward,post-commit,manual-push,direct-check, anddirect-fix(src/api/policy-types.ts:31-36). - Spec:
SPEC.md:1229-1244,3992-3999. - Consumers: every lifecycle.
- Status: retained as a fixed typed registry of shipped policies with stable ordering (implementation plan lines 103 to 106).
- Rust owner:
policy_registry.rs(exists) for the table;policy_engine.rs(proposed) for execution. - Consumer-level test:
in the standard fixture,
make one command violate two policies and pass
--cli-git-keep-going; observe the findings in registry order with increasingsequence. - Native state:
implemented for the table only:
POLICY_REGISTRY(src/native/policy_registry.rs:95-160) lists nine policies in the incumbent order, built-ins first. It records no triggers. Evidence: 4 unit tests insrc/native/policy_registry_tests.rs; no recorded gate run. Execution is absent.
Severities, defaults, and unsafe warnings #
- Behavior:
the effective severity is the configured value or the policy default (
src/policy-engine/policy-stage.ts:145);offskips the policy (146-147). Awarnsetting on a policy that is not warn-safe emits aconfiguration-warningevent, even when the check is clean (151,209-214). Defaults:final-newlineiswarn; the other four built-ins areerror(src/policy-engine/final-newline-policy.ts:88;src/policy-engine/require-root-policy.ts:24;src/policy-engine/linked-worktree-policy.ts:21;src/policy-engine/branch-worktree-policy.ts:21;src/policy-engine/add-explicit-policy.ts:21).branch-worktree-onlyandfinal-newlineare warn-safe. - Spec:
SPEC.md:1352-1366,4000-4004. - Consumers:
the root configuration sets three severities (
cli-git.config.ts:33-57). - Status: retained. The implementation plan lines 68 to 69 let repository settings disable policies or change permitted severities without consent.
- Rust owner:
policy_registry.rsandconfig_policies.rs(exist). - Consumer-level test:
in the standard fixture,
set
add-explicittowarnand rungit add .; observe afindingwith severitywarn, aconfiguration-warningwith codewarn-unsafe, and that Git staged the files. - Native state:
implemented as data:
each
PolicyDescriptorholdsdefault_severityandwarn_safe(src/native/policy_registry.rs:69-160). The five built-ins carry the incumbent defaults. The four optional policies default toOffthere, while the incumbent runs a registered plugin's policy at the policy's own default (src/policy-engine/policy-stage.ts:145); see "Open questions". No event is emitted yet.
Stage execution and stopping #
- Behavior:
runPolicyStage(src/policy-engine/policy-stage.ts:103-257) runs one policy at a time. Without--cli-git-keep-going, the first error finding stops the stage (223-231). A thrown check emitsplugin-threwand stops (162-177); an invalid finding emitspolicy-incompleteand stops (183-184,233-248). A proposed patch ends the stage so convergence can restart (215-222). The direct-check filter and escaped IDs skip policies (138-141). - Spec:
SPEC.md:387-398,1246-1252. - Consumers: every lifecycle.
- Status:
retained.
plugin-threwloses its plugin meaning with a fixed registry; see "Open questions". - Rust owner:
policy_engine.rs(proposed). - Consumer-level test:
in the standard fixture,
run a command that violates the first and third policies,
with and without
--cli-git-keep-going; observe one finding and exit1without the flag, and both findings and exit1with it. - Native state: absent.
Finding validation #
- Behavior:
findingsAreValid(src/policy-engine/policy-stage.ts:60-71) requires a non-emptycodeandmessage.createFindingEventprefixes the code with the policy ID (src/policy-engine/events.ts:410). - Spec:
SPEC.md:562-574. The spec also requires kebab-case codes and an in-range byte location; the engine checks neither (see "Spec and code disagreements"). - Consumers: JSONL consumers.
- Status: retained as structured findings from typed policies (implementation plan lines 103 to 106).
- Rust owner:
policy_findings.rs(proposed). - Consumer-level test:
in the standard fixture,
trigger a finding that carries a location;
observe
byteStartandbyteEndinside the candidate's byte length and a code of the form<policy-id>/<code>. - Native state: absent.
Patch validation and application #
- Behavior:
validatePolicyPatch(src/policy-engine/commit-transaction-patch.ts:122-209) accepts one textual unified diff for exactly the declared path, with oneindexheader naming the candidate's blob revision and mode100644or100755(62-106), and rejects rename, copy, mode, and binary directives (21-32,203-207) and paths with traversal or line breaks (134-143).applyPolicyPatches(src/policy-engine/apply-policy-patches.ts:247-342) applies patches in order throughgit apply --cached --3wayon the private index (src/policy-engine/commit-transaction-git.ts:248-291). The built-in and optional policies build patches withcreateFinalNewlinePatch(src/policy-engine/final-newline-patch.ts:70-129) andcreateFullContentPatch(src/optional/markdown-lint/full-content-patch.ts:114-171). - Spec:
SPEC.md:576-626. - Consumers: commit transactions and direct fix.
- Status: retained. The patch is no longer supplied by untrusted plugin code, but the candidate edit path stays (implementation plan lines 103 to 112).
- Rust owner:
policy_patches.rs(proposed). - Consumer-level test:
in the standard fixture,
commit a file whose fix conflicts with a concurrent edit of the same lines;
observe exit
2withpatch-conflict, no patch bytes in the event, and unchanged ref, index, and worktree bytes. - Native state: absent.
Bounded fix passes #
- Behavior:
convergeCommitPolicies(src/policy-engine/commit-transaction-convergence.ts:110-276) restarts the whole order after each changed candidate state, with at most 8 changed passes (32). Candidate states are serialized to private files and compared byte for byte (src/policy-engine/commit-transaction-candidate-snapshot.ts:82-247). A repeated non-adjacent state isfix-cycle; a changed last pass isfix-pass-limit(src/policy-engine/commit-transaction-results.ts:128-157,233-248). Direct fix uses the same limit (src/policy-engine/direct-fix-convergence.ts:33). - Spec:
SPEC.md:1254-1277. - Consumers: commit transactions, revalidation after replay, and direct fix.
- Status: retained (implementation plan line 106, "bounded fixing passes").
- Rust owner:
policy_convergence.rs(proposed). - Consumer-level test:
in the standard fixture,
commit a file that needs two different policy fixes;
observe one
fix-summarywithpassesequal to the changed passes, the committed bytes fully fixed, and no finding for the corrected problems. - Native state: absent.
JSONL events #
- Behavior:
events are compact JSON objects,
one per line,
with
schemaVersion: 1(src/policy-engine/events.ts:23,588-598). Types:finding(33),engine-failurewith 15 codes (88-103,113),commit-landed(156),core-finding(195),configuration-warning(250),fix-summary(289), and the concurrency eventslanding-race-lost,landing-reserved,commit-replayed, andreplay-headers-dropped(src/policy-engine/events-concurrency.ts:33-178).withFixSummaryappends the summary with sorted unique paths (src/policy-engine/fix-summary.ts:28-100). - Spec:
SPEC.md:1279-1575. - Consumers:
agents and scripts reading wrapper stderr or management stdout;
the end-to-end suite checks exit codes against events
(
e2e/jsonl-event-fixture.ts). - Status:
retained
(implementation plan lines 107 to 112).
The trust-only codes
config-untrusted,config-changed,trust-consent-unavailable, andtrust-failedlose their emitters. - Rust owner:
policy_events.rs(proposed). - Consumer-level test:
in the standard fixture,
drive one event of each retained type and parse stderr line by line;
observe field sets equal to
SPEC.md:1296-1575, no JSONnull, and LF termination. - Native state: absent.
Stream routing and exit codes #
- Behavior:
wrapper policy events go to stderr (
src/bin.ts:219-224,277-280,336-339,412-415,433-438);checkandfixevents go to stdout (src/management.ts:219-224,261-265,311-314). When Git does not run, exit0means clean or warnings only,1means error findings, and2means an engine failure (src/policy-engine/engine.ts:308,347,392,417). A landed commit followed by a blocked post-commit gate exits2(src/bin.ts:416-417). - Spec:
SPEC.md:1577-1622. - Consumers: every caller that branches on the exit status or separates Git output from events.
- Status: retained (implementation plan lines 107 to 112).
- Rust owner:
policy_events.rsandwrapper_main.rs(proposed). - Consumer-level test:
in the standard fixture,
capture stdout and stderr separately for a blocked wrapped command and for
git cli-git check; observe events only on stderr for the first and only on stdout for the second, with the exit codes ofSPEC.md:1588-1622. - Native state: absent.
Candidate facts #
- Behavior:
each lifecycle builds lazy Git facts for the policy context:
git addpredicts the staged delta in a private index (src/policy-engine/add-policy-facts.ts:116-261;src/policy-engine/add-staged-delta.ts:38-216); commit transactions read the private commit index (src/policy-engine/commit-transaction-candidates.ts:316-367) and tracked files (src/policy-engine/commit-transaction-tracked-files.ts:166-294); post-commit reads the landed commit's delta (src/policy-engine/post-commit-facts.ts:130-198); manual push reads newly published content (src/policy-engine/manual-push-candidates.ts:330-426); direct commands read selected worktree bytes (src/policy-engine/direct-check-facts.ts:66-111). Blob bytes load through onegit cat-file --batchprocess (src/policy-engine/blob-batch.ts:205-270). - Spec:
SPEC.md:336-385,597-605. - Consumers: every content policy.
- Status: retained. The implementation plan lines 93 to 99 require immutable candidate versions, lazy batched Git facts, candidate bytes rather than live worktree bytes, and no Git process per file.
- Rust owner:
candidate_facts.rs(proposed). - Consumer-level test:
in the standard fixture,
stage clean bytes,
then write a forbidden string to the worktree copy only,
and commit the staged path with
--no-only; observe a clean commit, and withstracea fixed number of Git processes for 1 and for 100 candidate files. - Native state: absent.
Policy read sets and input fingerprints #
- Behavior:
inside a commit transaction each policy run records what it read:
the candidate list,
the paths whose bytes it loaded,
tracked-file requests,
and the
headOid,landedCommitOid, andpushUpdatesvalues (src/policy-engine/policy-read-set.ts:126-159,400-494). Declared external inputs are fingerprinted: worktree pathspecs, executables, revisions, and environment variables (src/policy-engine/policy-input-fingerprint.ts:367-448;src/policy-engine/policy-input-executable.ts:215-261). After a replay,decideRerun(src/policy-engine/policy-read-tracking.ts:253-310) reuses a recorded run when it proposed no patch, its inputs hold, and its reads replay to the same identities (src/policy-engine/policy-read-validation.ts:254-293). Unrestricted policies always re-run. - Spec:
SPEC.md:400-560. - Consumers: revalidation after replay.
- Status:
retained
(implementation plan lines 215 to 219 list policy read sets;
lines 143 to 146 require a replay that changes a declared input to invalidate the policy result).
The authoring-facing
inputsdeclaration and its schema (src/trust/policy-inputs-schema.ts:163-330) retire with the authoring API; the shipped policies' declarations become fixed data. - Rust owner:
policy_read_set.rsandpolicy_inputs.rs(proposed). - Consumer-level test: in the standard fixture, force a lost landing race with a disjoint winning commit, then with a winning commit that changes the scanner rules file; observe through debug logs or a counting scanner fixture that the context-only policy is reused in the first case and that the scanner re-runs in the second.
- Native state: absent.
Pre-forward lifecycle #
- Behavior:
runPreForwardPolicyEngine(src/policy-engine/pre-forward-engine.ts:34-77) strips wrapper controls, builds add candidate facts when the command isgit add, and runs the engine. A blocking result prevents forwarding (src/bin.ts:273-286); the transformed arguments replace the raw ones (291). - Spec:
SPEC.md:889-899. - Consumers: every wrapped command that loads configuration and is not a commit transaction.
- Status: retained.
- Rust owner:
lifecycle_pre_forward.rs(proposed). - Consumer-level test:
in the standard fixture,
run
git add -- CONTEXT.mdat the repository root; observe aforbidden-root-contextfinding on stderr, exit1, and an unchanged index. - Native state: absent.
Post-commit lifecycle #
- Behavior:
runPostCommitLifecycle(src/policy-engine/post-commit-lifecycle.ts:101-195) uses the landed commit ID passed from the transaction, runspost-commitpolicies against the landed delta, and on a blocking result appendscommit-landedwith outcomepost-commit-blocked(160-171). A setup failure emitscontent-unavailablepluscommit-landed(173-194). Only a clean or warning-only result reaches auto-push (src/bin.ts:416-422). - Spec:
SPEC.md:1075-1092,1558-1575. - Consumers: auto-push, which this gate guards.
- Status: retained.
- Rust owner:
lifecycle_post_commit.rs(proposed). - Consumer-level test:
in the standard fixture,
land a commit whose content passes pre-forward only because of a one-time escape flag;
observe the commit present locally,
the causal finding,
a final
commit-landedevent, exit2, and no push to the bare remote. - Native state: absent.
Manual-push lifecycle #
- Behavior:
runManualPushGate(src/policy-engine/manual-push-gate.ts:45-87) applies togit pushthat is not a dry run and has an enabledmanual-pushpolicy.probeManualPushUpdates(src/policy-engine/manual-push-probe.ts:184-208) runs a private--dry-runpush whose generatedpre-pushhook records Git's update records (src/policy-engine/manual-push-hook.ts:344-405), and validates remote values withgit ls-remote --refs. The published set comes from remote-tracking refs and prior values (src/policy-engine/manual-push-published.ts:105-304); candidates are each newly published commit's delta, or the final tree when nothing is known to be published (src/policy-engine/manual-push-descriptors.ts:204-392;src/policy-engine/manual-push-candidates.ts:330-426), with at most 4 concurrent per-update processes (37). - Spec:
SPEC.md:1169-1207,4020-4041. - Consumers:
forbidden-strings,final-newline, and Markdown autofix declare themanual-pushtrigger;perf/manual-push-latency-benchmark.tsmeasures it. - Status:
retained
(implementation plan lines 107 to 109 name manual-push checks).
The generated
pre-pushhook is a Node program today; its native form is undetermined (see "Open questions"). - Rust owner:
lifecycle_manual_push.rs(proposed). - Consumer-level test:
in the standard fixture,
push a branch whose newest commit adds a forbidden string,
first to a remote that already has its parent and then to an empty remote;
observe a blocked push with exit
1in both cases, a scan of only the newest commit's delta in the first, and a bounded process count for a 1,000-commit history. - Native state: absent.
Built-in policies and fixed transforms #
Git command region parsers #
- Behavior:
parseArgv(src/parser/argv.ts:240-415) is a shared region parser over declared flags and value options.expandAbbreviations(src/abbrev.ts:52-114) lists the unambiguous long-option abbreviations Git accepts. Per-command parsers produce the facts the rules use:parseAddRegion(src/parser/add.ts:258-313),parseCommitRegion(src/parser/commit.ts:212-291) withnormaliseCommitArgs(src/parser/commit-normalise.ts:165-288),parsePushRegion(src/parser/push.ts:64-96),parseStatusPreRegionandparseStatusPostRegion(src/parser/status.ts:83-157),parseStashRegion(src/parser/stash.ts:96-128),parseCleanRegion(src/parser/clean.ts:144-232) withscanCleanOptionOrder(src/parser/clean-option-order.ts:430-438),parseResetRegion(src/parser/reset.ts:127-197), andparseBranchCreationRegion(src/parser/branch-create.ts:108-217). - Spec:
SPEC.md:777-797;doc/handover/cli-git-cac-migration.mdrecords why the package owns its parser. - Consumers: every built-in policy and fixed transform, the commit transaction, and the manual-push gate.
- Status: retained. The implementation plan lines 47 to 49 require Git-specific token classification rather than an unrelated option grammar.
- Rust owner:
command_*.rs, one module per command, owned by the command-parser delegate. - Consumer-level test:
in the standard fixture,
run each documented abbreviation and clustered short form through the native wrapper and through
/usr/bin/gitfor the same repository state; observe that the wrapper's decision matches what Git then does (for examplegit commit --amamends andgit clean --drydeletes nothing). - Native state:
in progress
(queued delegate;
no
command_*.rsfile at40436cd01).
require-root #
- Behavior:
requireRoot(src/rule/require-root.ts:130-191) rejects a command whose effective directory is inside a repository but not at its root. It exemptsinit,clone,version, andhelp(24-29),configwith--global,--system,--list, or-l(34-39,159-170), and a directory outside any repository (175-179). Policy metadata: defaulterror, warn-unsafe, triggerspre-forwardanddirect-check(src/policy-engine/require-root-policy.ts:22-31). - Spec:
SPEC.md:3992-4008. - Consumers: every wrapped command.
- Status: retained (implementation plan lines 116 to 120).
- Rust owner:
rule_require_root.rs(proposed). - Consumer-level test:
in the standard fixture,
run
git statusfrom a subdirectory, from the root, with-C <root>, and outside any repository; observe exit1with arequire-rootfinding only in the first case. - Native state: in progress (queued rule-core delegate).
linked-worktree-only #
- Behavior:
checkLinkedWorktree(src/policy-engine/linked-worktree-check.ts:237-308) rejects everygit stash,git cleanthat is neither a dry run nor interactive, andgit resetwith a destructive mode (138-175), unless the target is a linked worktree or an allowlisted tool cache (298-307). Messages are insrc/policy-engine/linked-worktree-messages.ts:52-109. Policy metadata: defaulterror, warn-unsafe, triggerpre-forward(src/policy-engine/linked-worktree-policy.ts:19-25). - Spec:
SPEC.md:3992-4008. - Consumers:
agents and humans in the main worktree;
e2e/README.md:525-528records that it blocks lint-staged'sgit stashin a main worktree. - Status: retained (implementation plan lines 116 to 120).
- Rust owner:
rule_linked_worktree.rs(proposed). - Consumer-level test:
in the standard fixture,
run
git stash,git clean -fd,git clean -nd, andgit reset --hardin a main worktree and in a linked worktree; observe rejection with exit1only for the three destructive forms in the main worktree. - Native state: in progress (queued rule-core delegate).
Allowed worktree directories #
- Behavior:
classifyEffectiveTarget(src/effective-target.ts:62-86) returnsallowlistedwhen the repository's Git directory lies under a baked-in tool cache. The only entry is uv's cache:UV_CACHE_DIR, orXDG_CACHE_HOME/uv, or<home>/.cache/uv(src/allowed-worktree-dirs.ts:60-102). Membership resolves each root throughrealpathand tests segment-aware containment (144-164,247-281). - Spec:
no
SPEC.mdsection states it. - Consumers:
uv,
whose internal
git reset --hardin its cache would otherwise be rejected (src/allowed-worktree-dirs.ts:43-48). - Status: retained. The implementation plan does not name it; it is part of the linked-worktree policy's accepted behavior.
- Rust owner:
allowed_worktree_directories.rs(proposed). - Consumer-level test:
in the standard fixture,
create a repository under a disposable
UV_CACHE_DIRand one beside it with the same prefix, then rungit reset --hardin each; observe success in the first and rejection in the second. - Native state: absent.
branch-worktree-only #
- Behavior:
checkBranchWorktree(src/policy-engine/branch-worktree-check.ts:101-188) rejects branch creation in the current worktree: explicit forms ofbranch,checkout, andswitch(145-146), and the remote-tracking guess ofgit switch <name>andgit checkout <name>, probed against real Git (src/policy-engine/branch-worktree-remote-guess.ts:158-227). Policy metadata: defaulterror, warn-safe, triggerpre-forward(src/policy-engine/branch-worktree-policy.ts:19-25). - Spec:
SPEC.md:3992-4008. - Consumers:
agents and humans;
the status note names the allowed form
git worktree add -b(src/post-command-output.ts:96-101). - Status: retained (implementation plan lines 116 to 120).
- Rust owner:
rule_branch_worktree.rs(proposed). - Consumer-level test:
in the standard fixture with one remote branch
topicand no local one, rungit switch -c x,git switch topic,git branch --list, andgit worktree add -b y ../y; observe rejection of the first two only. - Native state: in progress (queued rule-core delegate).
add-explicit #
- Behavior:
checkAddExplicit(src/policy-engine/add-explicit-check.ts:77-137) rejectsgit addwith the bulk tokens.,*,-A, or-u(src/parser/add.ts:23-41), naming the matched tokens (src/policy-engine/add-explicit-check.ts:121-133). Policy metadata: defaulterror, warn-unsafe, triggerpre-forward(src/policy-engine/add-explicit-policy.ts:19-25). - Spec:
SPEC.md:3992-4008. - Consumers:
agents and humans;
AGENTS.md:1338(rule CLG). - Status: retained (implementation plan lines 116 to 120).
- Rust owner:
rule_add_explicit.rs(proposed). - Consumer-level test:
in the standard fixture,
run
git add .,git add -A,git add --pathspec-from-file -Awith a pathspec file named-A, andgit add -- a.txt; observe rejection of the first two and staging by the last two. - Native state: in progress (queued rule-core delegate).
final-newline #
- Behavior:
finalNewlinePolicy(src/policy-engine/final-newline-policy.ts:86-119) checks each regular or executable candidate.normalizeFinalNewline(src/policy-engine/final-newline-normalize.ts:108-133) leaves empty, NUL-containing, and non-UTF-8 bytes unchanged, and otherwise requires exactly one terminal LF.isFinalNewlineExcluded(72-93) preserves five path families. Where patches apply, the finding carries a patch (src/policy-engine/final-newline-policy.ts:60-74). Policy metadata: defaultwarn, warn-safe, all five triggers, no external inputs (86-98). - Spec:
SPEC.md:4061-4087. - Consumers:
every commit in this repository;
.github/workflows/final-newline.yml. - Status: retained (implementation plan lines 116 to 120).
- Rust owner:
rule_final_newline.rs(proposed). - Consumer-level test:
in the standard fixture,
commit a text file without a terminal LF,
one with three,
a CRLF file,
a binary file,
an empty file,
and a file under
x/dist/final/node/; observe exact committed bytes: the first three end in one LF with interior bytes untouched, and the others are unchanged. - Native state: in progress (queued rule-core delegate).
atomic-push transform #
- Behavior:
atomicPush(src/rule/atomic-push.ts:48-89) inserts--atomicafterpushunless the caller passed--atomicor--no-atomic. - Spec:
SPEC.md:1242-1244. - Consumers:
every wrapped
git push. - Status: retained (implementation plan lines 121 to 123).
- Rust owner:
rule_atomic_push.rs(proposed). - Consumer-level test:
in the standard fixture with a remote hook that rejects one of two refs,
run
git push origin a bandgit push --no-atomic origin a b; observe that the remote takes neither ref in the first case and one in the second. - Native state: in progress (queued rule-core delegate).
commit-only transform #
- Behavior:
commitOnly(src/rule/commit-only.ts:222-418) inserts-oaftercommit. It rejects-aor--all(all-flag,302-306), a pathless commit outside a merge, cherry-pick, or revert conclusion (pathspec-required,319-343), and a pathless--amendor--allow-emptywhile the index differs fromHEAD(staged-changes-ignored,363-393). It skips insertion for an explicit-o,--only, or--no-only(346-349), for include, interactive, or patch selection (351-357), and for--no-enforce-only(284-299). The checks query real Git (src/rule/commit-index-check.ts:65-110;src/rule/commit-sequencer-check.ts:108-176). Rejections arecore-findingevents (src/policy-engine/fixed-transforms.ts:123-133). - Spec:
SPEC.md:1368-1396,2516-2529. - Consumers:
every wrapped
git commit;AGENTS.md:1338(rule CLG) and rule CPN. - Status: retained (implementation plan lines 121 to 123).
- Rust owner:
rule_commit_only.rs(proposed). - Consumer-level test:
in the standard fixture,
stage
b.txt, then rungit commit -m x -- a.txt,git commit -m x,git commit -a -m x, andgit commit --amend --no-edit; observe that the first commits onlya.txtand leavesb.txtstaged, and that the other three exit1with the threecommit-only/*codes. - Native state: in progress (queued rule-core delegate).
status-hints-off transform #
- Behavior:
statusHintsOff(src/rule/status-hints-off.ts:105-137) inserts-c advice.statusHints=falsebeforestatusunless the caller set that key with a global-c(56-71). - Spec:
SPEC.md:1242-1244. - Consumers:
every wrapped
git status. - Status: retained (implementation plan lines 121 to 123).
- Rust owner:
rule_status_hints.rs(proposed). - Consumer-level test:
in the standard fixture with one unstaged change,
run
git statusandgit -c advice.statusHints=true status; observe Git'suse "git add"hint only in the second. - Native state: in progress (queued rule-core delegate).
Optional policies #
forbidden-strings #
- Behavior:
forbiddenStringsPolicy(src/optional/forbidden-strings/index.ts:112-156, canonical sourcepackage/git-policy/forbidden-strings/src/index.ts) scans candidate bytes.materializeCandidateswrites candidate bytes to temporary files with at most 64 concurrent lanes (src/optional/forbidden-strings/materialize-candidates.ts:21,97-236);scanCandidatesstarts the scanner executable with an argument array (src/optional/forbidden-strings/scan-candidates.ts:273-387);parseScannerOutputturns exit1output into redacted findings (src/optional/forbidden-strings/scanner-output.ts:323-361). Options:executable(defaultforbidden-strings) andbuiltinRules(defaulttrue) (src/optional/forbidden-strings/index.ts:40-49). Declared inputs: the executable,FORBIDDEN_STRINGS_RULES, and the rules file (78-101). Policy metadata: defaulterror, warn-unsafe, triggerspre-forward,post-commit,manual-push, anddirect-check(116-124). - Spec:
SPEC.md:4016-4059. - Consumers:
the root configuration (
cli-git.config.ts:45-57), which pointsexecutableat the Rust scanner underpackage/cli/forbidden-strings/target/release/; rootmise.toml:1321-1327setsFORBIDDEN_STRINGS_RULES;.github/workflows/forbidden-strings.ymlruns the standalone scanner independently. - Status:
retained
(implementation plan lines 124 and 128 to 152).
The scanner is linked in-process through its library interface;
the temporary content files,
the scanner child process,
and stderr parsing are removed (lines 148 to 152).
The
executableoption retires: the rewrite scope lines 126 to 131 forbid arbitrary program selection through JSONC. - Rust owner:
policy_forbidden_strings.rs(proposed), over theScannerinterface inpackage/cli/forbidden-strings/src. - Consumer-level test:
in the standard fixture,
commit a file with a planted built-in-rule match and a clean control,
with a different string in the worktree copy than in the staged copy;
observe exit
1, a redacted finding for the staged bytes only, no matched bytes in any output, and withstraceno scanner child process and no temporary content file. - Native state:
absent in the wrapper.
The scanner's embedding interface is implemented and verified
(
doc/handover/scanner-native-verification.md).
forbidden-root-context #
- Behavior:
forbiddenRootContext(src/optional/repository-policy/index.ts:114-148, canonical sourcepackage/git-policy/repository/src/index.ts) reports a non-deleted candidate at exactlyCONTEXT.md(97-103). Policy metadata: defaulterror, warn-safe, triggerspre-forwardanddirect-check, no external inputs (115-123). - Spec:
SPEC.md:4010-4014. - Consumers:
the root configuration (
cli-git.config.ts:44);AGENTS.mdrule SK3 states the no-context-file convention it enforces. - Status: retained (implementation plan line 125).
- Rust owner:
policy_forbidden_root_context.rs(proposed). - Consumer-level test:
in the standard fixture,
commit a new root
CONTEXT.md, a nesteda/CONTEXT.md, and a deletion of a rootCONTEXT.md; observe rejection of the first only. - Native state: absent.
Dependent-version propagation #
- Behavior:
dependentVersionBump(src/optional/repository-policy/dependent-version-bump-policy.ts:247-271, canonical sourcepackage/git-policy/repository/src) runs for commits that modify a workspace manifest (179-191). It plans patch-level bumps for publishable dependents (src/optional/repository-policy/dependent-bump-workflow.ts:297-391;src/optional/repository-policy/dependent-version-bump.ts:153-353), reading manifests throughtrackedFiles, publishable names frompackage/config/pnpr/config.yaml(src/optional/repository-policy/publishable-names.ts:11,39-82), and source imports (src/optional/repository-policy/source-imports.ts:39-267). Each stale dependent is a finding with a full-content patch for a tracked file that is not a candidate, so the fix adds the path to the commit (src/optional/repository-policy/dependent-version-bump-policy.ts:204-226). Policy metadata: defaulterror, warn-unsafe, triggerspre-forward,direct-check, anddirect-fix(247-258). The root configuration registers the plugin but does not list this policy (cli-git.config.ts:22-58), so it runs at its default severityerror. The native registry gives it the defaultOff(src/native/policy_registry.rs:146-152), so a translated configuration that omits it would stop the policy; see "Open questions". - Spec:
SPEC.md:531-532,607-623,2531-2559;doc/planning/cli-git-policy-added-paths.md. - Consumers:
every commit that bumps a workspace package version.
The standalone task
//package/git-policy/repository:bump:dependents, called by the rootchangeset:versiontask (mise.toml:1193-1197), shares the planning code (package/git-policy/repository/src/bump-dependents-worktree.ts). - Status: retained (implementation plan line 125).
- Rust owner:
policy_dependent_version.rs(proposed). - Consumer-level test:
in the standard fixture with three workspace manifests where
bdepends ona, bumpaand commit onlya's manifest; observe that the landed commit also bumpsb, thatb's worktree and index entries match the commit, and that a dirtybmanifest instead yieldspatch-conflictwith exit2. - Native state: absent.
Markdown autofix #
- Behavior:
markdownLintPolicy(src/optional/markdown-lint/index.ts:93-141, canonical sourcepackage/git-policy/markdown-lint/src) sends each Markdown candidate through the configured command in stdin fix mode (src/optional/markdown-lint/rewrite-candidates.ts:594-632), reportsmarkdown-autofixwith a full-content patch ormarkdown-violation(34-39), and treats exit2or any other status as a failure. Options:command(defaultnode package/cli/markdown-lint/src/cli.ts),rules(defaultlfs-image-url), andexclude(src/optional/markdown-lint/index.ts:46-81). Policy metadata: defaultwarn, warn-safe, all five triggers, unrestricted inputs (97-109). - Spec:
SPEC.md:547-552. - Consumers:
the root configuration (
cli-git.config.ts:33-43), which runs onlylfs-image-urland excludespackage/ssg/. - Status:
retained as current commit-time Markdown normalization
(implementation plan line 126).
Lines 181 to 189 replace the configured command with the coordinated installation's native linter,
called with
--config,--stdin,--stdin-filename, and--fix; repository JSONC cannot choose the executable. Thecommandoption retires (rewrite scope lines 126 to 131). - Rust owner:
policy_markdown.rs(proposed), calling the binary ofpackage/linter/monochromatic-lint. - Consumer-level test:
in the standard fixture with
.lfsconfigand an LFS-tracked image, commit a Markdown file that links the image, including an astral-character and a BOM variant; observe the landed bytes with the rewritten object URL, onefix-summary, and an untouched file under an excluded path. - Native state: absent in the wrapper. The linter rule port is pending: the handover work queue lists native LFS URL normalization as open.
Commit transactions #
Every entry in this section is retained by the implementation plan lines 198 to 237, which port the transaction state machine and durable protocol explicitly and list what to preserve. One entry, "Older-Git degradation", is retired. Native state is absent for every entry: the handover work queue lists transactions, hooks, locks, replay, recovery, worktree copy, and auto-push as not started.
Scope and applicability #
- Behavior:
runCommitTransaction(src/policy-engine/commit-transaction.ts:87-402) handles everygit committhat is not a dry run (109-116); dry runs and short-circuit forms are forwarded (src/bin.ts:248-250). The mode is explicit-path or index (src/policy-engine/commit-transaction-journal-states.ts:50).runCommitTransactionBoundary(src/policy-engine/commit-transaction-boundary.ts:34-65) turns an unexpected error intotransaction-failed, orindex-lock-unproven-owner, with exit2, and rethrows native Git failures so their exit code is preserved. No configuration key or environment variable disables the transaction. - Spec:
SPEC.md:1970-2010. - Consumers: every commit made through the wrapper, by humans and by concurrent agents in one worktree.
- Status: retained.
- Rust owner:
transaction.rs(proposed) with typed states for capture, private preparation, policy convergence, landing, replay, and post-landing completion (implementation plan lines 200 to 206). - Consumer-level test:
in the standard fixture,
run one explicit-path commit,
one
--no-onlycommit, onecommit -a --no-enforce-only, and onegit commit --dry-run; observe one landed commit for each of the first three with native parents and messages, no transaction directory afterward, and plain forwarding for the dry run. - Native state: absent.
Invocation capture #
- Behavior:
captureInvocationLayout(src/policy-engine/commit-transaction-capture.ts:237-379) records the symbolicHEADtarget, the compare-and-swap target ref, the conclusion kind, the repository root, the common Git directory, the real index path, the ref storage format, and the reflog nonce;captureInvocationBase(381-421) reads the preparation base afterward. Conclusion detection and ref helpers are insrc/policy-engine/commit-transaction-capture-refs.ts:86-246. A caller-setGIT_INDEX_FILE,GIT_DIR,GIT_WORK_TREE,--git-dir, and--work-treeare honored. - Spec:
SPEC.md:2012-2062. - Consumers: every later transaction phase and recovery.
- Status: retained.
- Rust owner:
transaction_capture.rs(proposed). - Consumer-level test:
in the standard fixture,
start a commit held in
pre-commit, move the branch with a second commit, and release the first; observe that the first replays onto the second rather than re-reading liveHEAD, and that a detachedHEADcommit lands by compare-and-swap onHEAD. - Native state: absent.
Transaction registry and journal #
- Behavior:
transactions live under
<git-dir>/cli-git-transactions/<uuid>/(src/policy-engine/commit-transaction-registry.ts:45,101). A directory is built under a.pendingname and published by rename afterowner.jsonis complete (60,259-336); removal renames to.retiredfirst (65,338-451). State files are created exclusively and never rewritten (src/policy-engine/commit-transaction-journal-states.ts:378-416):preparing.json,prepared.json,index-lock-<n>.json,landing-<n>.json,ref-updated.json, and theindex-installedmarker (30-45,312-374), at journal schema version 2 (25). Records are parsed strictly (src/policy-engine/commit-transaction-journal-parse.ts:140-330).owner.jsonholds the PID, birth identity, schema version 2, and invocation start time (src/policy-engine/commit-transaction-owner.ts:28,41-65,85-120). - Spec:
SPEC.md:2071-2146. - Consumers: recovery, the starvation reservation, capture-order pruning.
- Status: retained. The implementation plan lines 228 to 233 keep the existing journal and lock formats where practical during the first release, with cross-version fixture verification.
- Rust owner:
transaction_registry.rsandtransaction_journal.rs(proposed). - Consumer-level test:
in the standard fixture,
hold a commit in
pre-commitand list the registry; observe directory mode0700, file mode0600, one published UUID directory withowner.jsonandpreparing.json. Then feed journal files written by the incumbent to the native recovery; observe that each state is read without loss. - Native state: absent.
Private index and selection modes #
- Behavior:
initializeCommitIndex(src/policy-engine/commit-transaction-index.ts:80-176) builds<tx>/commit.index: from the preparation base plus the selected worktree paths for explicit-path commits, or a copy of the real index for index commits.resolvePrivateCommitArgs(src/policy-engine/commit-transaction-selection.ts:149-193) drops pathspecs,--git-dir,--work-tree, and the internal--only; pathspec files, including stdin and NUL forms, are materialized (258-287); interactive and patch selection run native Git once against the private index (195-256) and stay read-only for automatic fixes. Index copies keep the source index timestamps (src/policy-engine/index-file-timestamps.ts:30-86). - Spec:
SPEC.md:2064-2069,2497-2529. - Consumers: preparation and landing.
- Status: retained (implementation plan line 210, "private indexes", and line 221, "real index and worktree isolation").
- Rust owner:
transaction_private_index.rs(proposed). - Consumer-level test:
in the standard fixture,
commit with partial staging and an unstaged tail,
with
--pathspec-from-file=-and--pathspec-file-nul, and with a racily clean same-size edit; observe exact committed, indexed, and worktree bytes, and thatgit statusstill shows the same-size edit. - Native state: absent.
Shadow repository #
- Behavior:
createShadowRepository(src/shadow-repository/shadow-repository.ts:75-191) creates<git-common-dir>/cli-git/shadow/<transaction-id>(src/policy-engine/commit-transaction-capture.ts:477-490): a private object store whoseinfo/alternatesnames the real store, a snapshot of every real ref (src/shadow-repository/shadow-refs.ts:158-397, onepacked-refsfile for the files backend, oneupdate-ref --stdintransaction for reftable), a generatedconfigthat includes the real one and pinscore.worktree,gc.auto, andmaintenance.auto(src/shadow-repository/shadow-config.ts:63-222), and links to every other common-directory entry (src/shadow-repository/shadow-links.ts:53-322). On Windows, shared directories are junctions and shared files are copies (96-125). Conclusion state is copied in (src/shadow-repository/shadow-conclusion-state.ts:55-176). - Spec:
SPEC.md:2148-2406. - Consumers: native preparation, replay, hooks that read branch state.
- Status: retained (implementation plan line 210).
- Rust owner:
shadow_repository.rs(proposed). - Consumer-level test:
in the standard fixture,
hold a commit in
pre-commitand from the hook print the branch name,@{upstream}, anincludeIf "onbranch:"value, andgit rev-parse --git-dir; observe the real branch facts and the shadow path. Rungit gc --prune=nowin the real repository meanwhile; observe the commit lands whole,git worktree listnever shows the shadow, and no shadow remains afterward. Repeat in LFS, submodule, sparse-checkout, reftable, and SHA-256 repositories. - Native state: absent.
Hook dispatch and hook lock #
- Behavior:
writeHookShim(src/hook-dispatch/hook-shim-writer.ts:59-130) writes<tx>/hooks/dispatch.mjs,plan.json, and executable entries forpre-commit,prepare-commit-msg, andcommit-msgwhose first line is#!<process.execPath>(src/hook-dispatch/hook-dispatch-plan.ts:33-49).computeHookDispatchPlan(295-385) records the repository'score.hooksPath, user-disabled events, the caller's config parameters in Git's quoting (131-285), the real Git path, the worktree root, the preparation lease, and the hook lock. The generated program (src/hook-dispatch/hook-dispatch-program.ts:27-238) restores those parameters, exports an absoluteGIT_WORK_TREE, takes the hook lock at<git-common-dir>/cli-git/hook.lockwith its own liveness check (40-173), runsgit hook run --ignore-missing <event>, and propagates the status (175-221).post-commithas no entry and never runs during preparation. A nested wrapper with a valid preparation lease skips recovery and the hook lock (src/hook-dispatch/preparation-lease.ts:40-127). - Spec:
SPEC.md:2408-2478. - Consumers: repository hooks, hookdir and config-based.
- Status: retained (implementation plan lines 211 to 214: hook, editor, signing, and branch identity behavior). The shim is a Node program today; its native form is undetermined (see "Open questions").
- Rust owner:
hook_dispatch.rs(proposed). - Consumer-level test:
in the standard fixture,
install a hookdir
pre-commitand ahook.<name>.commandhook, each appending to a log; commit once and observe each ran once, that a hook in a subdirectory sees the right top level and an absoluteGIT_WORK_TREE, that two concurrent preparations serialize their hooks by default and overlap withhooks.concurrentCommits: true, and that an open message editor does not hold the hook lock. - Native state: absent.
Native preparation #
- Behavior:
runNativePreparation(src/policy-engine/commit-preparation-native.ts:315-374) runs nativegit commitwith inherited standard streams against the shadow repository,GIT_INDEX_FILEnaming the private index,core.hooksPathnaming the shim, and each commit event'shook.<event>.enabled=false. Git owns hooks, the editor, templates, message cleanup, and signing. A failure raisesNativeCommitFailedErrorwith Git's exit code (106-145); the prepared commit is read from the shadowHEAD(409-447). - Spec:
SPEC.md:2193-2237. - Consumers: every commit transaction.
- Status: retained (implementation plan lines 39 to 46 keep native Git responsible for hooks, signing, editors, and sequencer behavior).
- Rust owner:
transaction_preparation.rs(proposed). - Consumer-level test:
in the standard fixture,
commit with an SSH signing key,
with
GIT_EDITORset to a script that edits the message, and with a failingcommit-msghook; observe a verifiable signature, the edited message, and for the failure Git's exit code with ref, index, and worktree bytes unchanged and no shadow repository left. - Native state: absent.
Preparation policy convergence, added paths, and hook-staged changes #
- Behavior:
policies run against the private index and patches converge
(
src/policy-engine/commit-transaction-convergence.ts:110-276). A patch for a tracked file that is not a candidate adds the path whenHEAD, the captured real index, the private index, and the worktree all hold the same blob (src/policy-engine/commit-transaction-added-paths.ts:248-361); otherwise the result ispatch-conflict(111-149). After landing, each added path's worktree copy is replaced only while it still holds the original bytes (401-501). Hook-staged changes are found by diffing the settled tree against the committed tree (src/policy-engine/commit-hook-changes.ts:161-245). A settled tree equal to the base yieldscommit-normalization/no-change(src/policy-engine/commit-transaction-no-change.ts:76-209). - Spec:
SPEC.md:2480-2502,2531-2588. - Consumers:
final-newline, Markdown autofix, and dependent-version propagation; lint-staged-style hooks. - Status: retained.
- Rust owner:
transaction_convergence.rsandtransaction_added_paths.rs(proposed). - Consumer-level test:
in the standard fixture,
commit with a
pre-commithook that reformats and re-stages a selected file and stages one extra path; observe that the landed tree is what the hook staged, that the real index and worktree are reconciled, and that a worktree edit made after the hook ran is kept with a warning. - Native state: absent.
Landing critical section #
- Behavior:
landTransaction(src/policy-engine/commit-landing.ts:198-453) takes the landing lock, or the reserved landing lock (236-249), then the realindex.lock(250), checks the symbolicHEADtarget, reads the target ref, migrates objects, computes the post-index, writeslanding-<n>.json, and advances the target withgit update-ref -m <reflog message> <target> <new> <old>(src/policy-engine/commit-landing-support.ts:192-229). The reflog message iscommit (cli-git <nonce>): <subject>(125-190). It then writesref-updated.json, removes the pack's.keep, installs the post-index through an owner-preserving hard link (src/policy-engine/commit-transaction-install-link.ts:28-64), writesindex-installed, and reproduces conclusion-state cleanup.landWithReplay(src/policy-engine/commit-landing-loop.ts:107-255) loops on lost races. Every landing-lock acquisition first recovers dead landings (src/policy-engine/commit-landing-lock.ts:105-248). Core findingshead-movedandbranch-switchedcome fromsrc/policy-engine/commit-landing-findings.ts:111-149. - Spec:
SPEC.md:2590-2675,3002-3012. - Consumers:
every commit transaction;
reference-transactionhooks see one update of the branch ref. - Status: retained (implementation plan lines 215 to 219: compare-and-swap landing).
- Rust owner:
transaction_landing.rs(proposed). - Consumer-level test:
in the standard fixture,
start 8 commits to disjoint paths together;
observe 8 landed commits,
each exactly once with its captured bytes,
linear native parents,
the nonce entry exactly once in the branch reflog and in the
HEADreflog, and a cleangit fsck. Switch branches between preparation and landing; observeconcurrent-commit/branch-switchedwith exit1and unchanged state. - Native state: absent.
Real index at landing #
- Behavior:
computeLandingPostIndex(src/policy-engine/commit-landing-index.ts:415-528) computes the post-index against the then-current real index. Explicit-path commits reset the committed paths to the landed tree. Index commits reuse the private index only when no replay happened and the real index is byte-identical to the captured one; otherwise each landed path is taken only while its real index entry still equals the captured entry. - Spec:
SPEC.md:2677-2704. - Consumers: concurrent stagers in the same worktree.
- Status: retained (implementation plan line 221).
- Rust owner:
transaction_landing_index.rs(proposed). - Consumer-level test:
in the standard fixture,
hold commit A in
pre-commit, stage pathpwith a second process, and release A; observe thatpis still staged after A lands and that the index never stages a revert of landed content. - Native state: absent.
Object migration and pending-object protection #
- Behavior:
migrateShadowObjects(src/policy-engine/commit-landing-objects.ts:85-165) pipesgit pack-objects --revs --local --stdoutfrom the shadow intogit index-pack --stdin --keep=<message>in the real repository, with the keep messagecli-git <transaction-id>(57-59).removePackKeep(167-235) andremoveTransactionKeeps(237-287) remove.keepfiles after the compare-and-swap, after a failed one, and during recovery. - Spec:
SPEC.md:2706-2749. - Consumers: landing and recovery.
- Status: retained (implementation plan line 220: protection of pending objects).
- Rust owner:
transaction_object_migration.rs(proposed). - Consumer-level test:
in the standard fixture,
pause a landing after migration with the phase marker,
run
git prune --expire=nowandgit repack -a -d, then release; observe that the commit lands whole and that no.keepwith the transaction's message remains. - Native state: absent.
Replay #
- Behavior:
replayOrFail(src/policy-engine/commit-landing-replay-step.ts:313-343) replays a prepared commit after a lost race.mergeReplayTree(src/policy-engine/commit-replay.ts:178-271) runsgit merge-tree --write-tree --name-only -z --merge-base=<base> <current> <prepared>in the shadow.writeReplayedCommit(353-440) rewrites an unsigned commit's raw object, replacing only thetreeandparentlines (src/policy-engine/commit-replay-object.ts:176-271), and rebuilds a signed commit withgit commit-tree -S, dropping custom headers and emittingreplay-headers-dropped(273-352). Signing options come from the invocation (src/policy-engine/commit-replay-options.ts:198-224). A conflict yieldsconcurrent-commit/replay-conflictwith the conflicting paths, the winning commit (src/policy-engine/commit-replay.ts:273-312), and the prepared commit, which is migrated without.keepso it can be cherry-picked. - Spec:
SPEC.md:2751-2844. - Consumers: concurrent agents editing one file.
- Status: retained (implementation plan lines 215 to 219).
- Rust owner:
transaction_replay.rs(proposed). - Consumer-level test:
in the standard fixture,
land two commits started together that edit non-overlapping hunks of one file,
then two that edit the same lines;
observe a clean replay with
landing-race-lostandcommit-replayedevents in the first case, and in the secondconcurrent-commit/replay-conflictwith exit1, unchanged ref, index, and worktree, and a prepared commit thatgit cherry-pickaccepts. Repeat with a non-UTF-8i18n.commitEncodingand with a signed commit carrying a custom header. - Native state: absent.
Subsumption #
- Behavior:
subsumeLandedChanges(src/policy-engine/commit-replay-subsumption.ts:318-442) decides, for each path both sides changed (src/policy-engine/commit-replay-shared-paths.ts:281-332), whether the prepared bytes already contain the landed change. Text paths are tested by strict reverse application (src/policy-engine/commit-replay-reverse-apply.ts:331-360, 3 context lines) and by the one-sided extension rule (src/policy-engine/commit-replay-containment.ts:247-298); a NUL byte in the first 8,000 bytes marks a blob binary (src/policy-engine/commit-replay-subsumption-text.ts:40,50,253-373). Subsumed paths go into a synthetic merge base. - Spec:
SPEC.md:2846-2942. - Consumers: replay.
- Status:
retained
(the implementation plan line 217 names replay;
doc/decision/cli-git-concurrent-commits.mdsection "Serial landing" holds the owner decision). - Rust owner:
replay_subsumption.rs(proposed). - Consumer-level test:
in the standard fixture,
run the cases of
SPEC.md:3716-3727on real repositories; observe each stated outcome, and that the strict reverse check agrees withgit apply --reverse --checkon seeded inputs. - Native state: absent.
Revalidation after replay #
- Behavior:
revalidateReplay(src/policy-engine/commit-revalidation.ts:205-421) reads the merged tree into<tx>/replay-<r>/commit.index, moves the shadowHEADtarget, fingerprints declared inputs, re-runs policies against the paths the replayed tree changes, and re-runspre-commitwhen the tree differs from the last approved one and--no-verifyis absent (src/policy-engine/commit-replay-hook.ts:72-127). A failing re-run exits1without an event. Worktree completions are retargeted to the replayed blobs (src/policy-engine/commit-landing-replay-records.ts:26-90). - Spec:
SPEC.md:2944-3000. - Consumers: replay.
- Status: retained.
- Rust owner:
transaction_revalidation.rs(proposed). - Consumer-level test:
in the standard fixture,
make the winning commit introduce content that a policy must fix in the replayed tree;
observe the fix in the landed commit,
a
fix-summaryaftercommit-replayed, onepre-commitre-run, none under--no-verify, and nothing landed when the re-run fails. - Native state: absent.
Amend, conclusions, and sequencer state #
- Behavior:
amend,
merge,
cherry-pick,
and revert conclusions fail with
concurrent-commit/head-movedwhen the target moved. Conclusion state (MERGE_HEAD,MERGE_MSG,MERGE_MODE,SQUASH_MSG,AUTO_MERGE,CHERRY_PICK_HEAD,REVERT_HEAD,MERGE_RR,sequencer/;src/shadow-repository/shadow-conclusion-names.ts:10-55) is copied into the shadow, with reftable pseudorefs read and written through Git (src/shadow-repository/shadow-conclusion-files.ts:136-246).reproduceConclusionCleanup(src/shadow-repository/shadow-conclusion-cleanup.ts:72-261) removes, in the owning worktree, each entry native Git removed from the shadow, only while it still holds the copied bytes. - Spec:
SPEC.md:3002-3069. - Consumers: merge, cherry-pick, and revert workflows.
- Status: retained.
- Rust owner:
transaction_conclusion.rs(proposed). - Consumer-level test:
in the standard fixture,
conclude a merge,
a cherry-pick,
and a revert through the wrapper and through
/usr/bin/gitin twin repositories, in files and reftable formats; observe byte-identical commits and identical Git-directory state afterward, including mid-sequence. - Native state: absent.
Capture order #
- Behavior:
each capture takes the per-worktree capture lock and a sequence number
(
src/policy-engine/commit-capture-order-store.ts:57-72,302-395), and recordscaptured.jsonwith the stamp and worktree-captured paths (src/policy-engine/commit-capture-order-capture.ts:134-286;src/policy-engine/commit-capture-order-journal.ts:33,245-347). A landing writeslanded/<oid>.json(src/policy-engine/commit-capture-order-records.ts:61-71,248-310,453-476). Replay decides each shared path by comparing sequence numbers (src/policy-engine/commit-capture-order-decision.ts:94-137;src/policy-engine/commit-capture-order-replay.ts:60-154) over the first-parent history (src/policy-engine/commit-capture-order-history.ts:123-172). Records are pruned when no published transaction can need them (src/policy-engine/commit-capture-order-prune.ts:150-217). - Spec:
SPEC.md:3071-3217. - Consumers: replay of commits captured from one worktree.
- Status: retained (implementation plan lines 215 to 219: capture ordering).
- Rust owner:
capture_order.rs(proposed). - Consumer-level test:
in the standard fixture,
capture commit A,
then commit B rewriting the same line,
and land B first;
observe that A keeps B's bytes for that path and lands its other paths.
Reverse the capture order;
observe that the later capture's bytes land.
After the last transaction ends,
observe no file under
cli-git-captures/landed/. - Native state: absent.
Starvation reservation #
- Behavior:
after
landing.reserveAfterLostRaceslost races a transaction writesreservation-requestand waits forreservation.lock(src/policy-engine/commit-landing-reservation.ts:68,187-332). Requests are granted oldest invocation first, ties by transaction ID (145-185). Other transactions wait before landing while a live reservation exists (334-365). A granted reservation emitslanding-reserved. - Spec:
SPEC.md:3265-3307. - Consumers: concurrent commits under contention.
- Status: retained (implementation plan lines 215 to 219: starvation reservations).
- Rust owner:
landing_reservation.rs(proposed). - Consumer-level test:
in the standard fixture with the default of 1,
make one transaction lose a race while others keep landing;
observe
landing-reservedafter itslanding-race-lost, at most 2 lost races for the holder, and release of the reservation when the holder lands, conflicts, or is killed. - Native state: absent.
Post-landing completion #
- Behavior:
after both locks are released,
concludeCommitTransaction(src/policy-engine/commit-transaction-conclusion.ts:168-431) completes added-path worktree copies (393), removes the shadow repository and the transaction directory, runs automatic maintenance (406), and runspost-commitonce (411).runAutoMaintenance(src/policy-engine/commit-landing-auto-maintenance.ts:135-267) mirrors Git's decision frommaintenance.auto,gc.auto, and the detach settings, runsgit maintenance run --auto --quiet, and ignores its status.runPostCommitHook(src/policy-engine/commit-landing-post-commit-hook.ts:98-160) runsgit hook run post-commitin the real worktree under the hook lock, withGIT_INDEX_FILE,GIT_AUTHOR_*, andGIT_EDITOR=:. - Spec:
SPEC.md:3219-3263. - Consumers:
post-commithooks; later Git commands, whose speed depends on the pack count. - Status: retained (implementation plan line 220: post-landing automatic maintenance).
- Rust owner:
transaction_post_landing.rs(proposed). - Consumer-level test:
in the standard fixture,
land 30 commits in sequence with a counting
post-commithook; observe 30 hook runs with the native environment, a bounded pack count, and no background-maintenance text in the JSONL stream. - Native state: absent.
Recovery #
- Behavior:
recoverCommitTransaction(src/policy-engine/commit-transaction-recovery.ts:127-191) runs at startup, before configuration loading.recoverRegisteredTransactions(src/policy-engine/commit-transaction-recovery-scan.ts:194-282) inspects every published directory (src/policy-engine/commit-transaction-recovery-inspect.ts:118-166). A live owner is skipped. A dead owner without a landing record loses its.keepfiles, reservation, shadow repository, and directory. A dead owner with a landing record is recovered under the landing lock (src/policy-engine/commit-transaction-recovery-landing.ts:185-353): an unlanded attempt is discarded, an interrupted index install is completed from the recorded post-index (src/policy-engine/commit-transaction-recovery-files.ts:162-238), and a completed install is recognized (src/policy-engine/commit-transaction-recovery-completion.ts:98-232). Beforeref-updated.jsonexists, a landing counts only when the target reflog holds the nonce entry (src/policy-engine/commit-transaction-recovery-reflog.ts:90-157). Realindex.lockfiles are removed only by recorded device and inode (src/policy-engine/commit-transaction-recovery-evidence.ts:212-270;src/policy-engine/commit-transaction-recovery-validation.ts:328-371). Malformed state fails closed withCommitTransactionRecoveryError(27-49). The legacy single-journal directorycli-git-transactionis still recovered (src/policy-engine/commit-transaction-registry.ts:50;src/policy-engine/commit-transaction-recovery-journaled.ts:60,252-430). - Spec:
SPEC.md:3497-3549,2145-2146. - Consumers:
every wrapper invocation after a crash;
README.mdsection "Commit recovery". - Status: retained (implementation plan lines 225 and 228 to 233: durable recovery after interruption; old transaction state is never silently discarded, and an unreadable state fails with an actionable recovery diagnostic). Whether the native wrapper recovers the legacy single-journal directory is undetermined (see "Open questions").
- Rust owner:
transaction_recovery.rs(proposed). - Consumer-level test:
in the standard fixture,
kill the wrapper with
SIGKILLat each phase marker and each hook point, then rungit status; observe after recovery that the commit either landed whole or not at all, that the real index matches, and that no shadow repository, transaction directory, lock,.keep, or landed-capture record remains. Plant a published directory without a valid owner record; observe exit2, the path named, and its contents preserved. - Native state: absent.
Test phase markers #
- Behavior:
CLI_GIT_TEST_ONLY_PHASE_SIGNAL=<phase>:kill[:<directory>]makes the wrapper kill itself at a phase, and<phase>:pause:<directory>writes a marker and waits for a release file (src/policy-engine/commit-transaction-test-phase.ts:37,109-234). The phases are listed at47-58. A malformed value fails the invocation (83-107). - Spec:
SPEC.md:3954-3972. - Consumers:
the container end-to-end suite (
e2e/scenario-phase-kill-fixture.ts,e2e/scenario-reservation-fixture.ts,e2e/scenario-subsumption-fixture.ts) and the concurrent-commit benchmark (perf/concurrent-commit-latency-pause.ts). - Status: retained. The implementation plan lines 289 to 291 reuse the existing end-to-end scenarios against the Rust executable, and those scenarios reach landing phases only through these markers. Whether a release build carries them is undetermined (see "Open questions").
- Rust owner:
transaction_test_phase.rs(proposed). - Consumer-level test:
the end-to-end
sigkill-phase-*scenarios pass against the native executable. - Native state: absent.
Older-Git degradation #
- Behavior:
the wrapper has no version gate.
replayPlumbingAvailable(src/policy-engine/replay-plumbing.ts:118-146) probesgit merge-tree --write-tree --merge-baseafter a first lost race and falls back toconcurrent-commit/head-moved; automatic maintenance retries without--detachon exit129(src/policy-engine/commit-landing-auto-maintenance.ts:45); a Git withoutcore.lockfilePidyields no PID evidence. - Spec:
SPEC.md:3551-3618. - Consumers:
the end-to-end matrix on Git 2.39.5 and 2.40.0
(
package/git-policy/cli/mise.toml:296-358;e2e/git-version-fixture.ts;e2e/scenario-replay-degradation-fixture.ts). - Status: retired. The implementation plan lines 22 to 25 support the latest stable Git release only and forbid porting older-Git compatibility branches or keeping an old-version test matrix; lines 235 to 237 report missing required Git behavior as an unsupported-environment failure. The rewrite scope lines 105 to 106 state that legacy Git degradation paths are not a parity requirement.
- Rust owner: none for degradation; the unsupported-environment failure is listed under "Responsibilities the plan adds".
- Consumer-level test: run the native wrapper against a Git older than the supported release in a container; observe an unsupported-environment failure and no fallback algorithm.
- Native state: absent.
Locks #
Every entry in this section is retained by the implementation plan lines 222 to 224 (process-birth-aware locks, foreign-lock evidence, and cancellation). Native state is absent for every entry.
Owner locks with process-birth identity #
- Behavior:
acquireOwnerLock(src/owner-lock/owner-lock.ts:499-535) publishes a lock directory by rename after writingowner.jsonexclusively and syncing it (150-165,205-225). The record holds schema version 1, a random token, the owner PID, the owner's birth identity, and for the reservation a transaction ID (src/owner-lock/owner-lock-record.ts:24-63). An owner is alive only while its PID names a process with the recorded birth identity (165-171). A dead owner's lock is retired by renaming it aside before deletion (src/owner-lock/owner-lock.ts:468-497). A waiter polls every 20 ms (69) without a time limit while the owner lives. Birth identity comes from/proc/<pid>/staton Linux, where statesZandXcount as exited, fromps -o lstart=on macOS, and from a PowerShellGet-Processstart time on Windows (src/policy-engine/commit-transaction-process-identity.ts:12-70,132-159). The lock paths are the landing lock, the reservation lock, the hook lock, the capture lock, and one push lock per branch. - Spec:
SPEC.md:3309-3380. - Consumers: landing, reservation, hook dispatch, capture order, auto-push, direct fix, index-writer coordination.
- Status: retained.
- Rust owner:
owner_lock.rsandprocess_identity.rs(proposed). - Consumer-level test: in the standard fixture, kill a lock holder, leave a zombie holder under a PID 1 that does not reap, and plant a lock whose PID was reused by a younger process; observe that the next acquirer retires each lock, and that a live holder makes the acquirer wait until it exits.
- Native state: absent.
Real index lock #
- Behavior:
acquireRealIndexLock(src/policy-engine/commit-landing-index-lock.ts:214-352) creates<index>.lockexclusively, writes Git's lock PID file format, and journals the lock's device and inode inindex-lock-<n>.jsonright after creation. - Spec:
SPEC.md:2597-2602,3378-3380. - Consumers: landing and recovery.
- Status: retained.
- Rust owner:
index_lock.rs(proposed). - Consumer-level test:
in the standard fixture,
pause a landing inside the critical section and run
/usr/bin/git adddirectly; observe that native Git reports the lock held and names the wrapper's PID from the PID file. - Native state: absent.
Foreign index-lock evidence and waiting #
- Behavior:
gatherIndexLockEvidence(src/index-lock/index-lock-evidence.ts:415-561) reads the lock's device, inode, and ctime, the Git PID file (165-315), and open holders by device and inode:/proc/<pid>/fdon Linux (src/index-lock/index-lock-holders-linux.ts:286-359, 16 concurrent readers),lsofon macOS (src/index-lock/index-lock-holders-darwin.ts:335-372), and a Restart Manager query through PowerShell on Windows (src/index-lock/index-lock-holders-win32.ts:31-187).classifyIndexLock(src/index-lock/index-lock-evidence.ts:366-413) returns proven alive, dead, or evidence-free. Process start times use a 20 ms resolution on Linux and 1 s on macOS (src/index-lock/process-start-time.ts:29-54,339-376).waitForIndexLock(src/index-lock/index-lock-wait.ts:270-366) waits without limit for a proven-alive owner, with polls capped at 100 ms or 500 ms (71-77), and otherwise backs off quadratically with jitter (49-64,164-204) up toindexLock.unprovenOwnerTimeoutMs, then raisesIndexLockUnprovenOwnerError(82-129), leaving the lock in place. - Spec:
SPEC.md:3400-3448. - Consumers: landing and forwarded index writers.
- Status: retained.
- Rust owner:
index_lock_evidence.rsandindex_lock_wait.rs(proposed). - Consumer-level test:
in the standard fixture,
hold
index.lockwith a nativegit commitwaiting in its editor, with a PID file naming an exited process, with no PID file, and with a child that holds the lock file open; observe an unbounded wait with one stderr line naming the holder in the first and last cases, andindex-lock-unproven-ownerwith exit2after the configured budget in the others, with the lock left in place. - Native state: absent.
Index-writer coordination and landing lease #
- Behavior:
isIndexWriter(src/index-lock/index-writer-commands.ts:196-235) classifies the resolved command: 15 commands always write the index (33-49), andrestore --staged,resetexcept--soft, andapply --cachedor--indexwrite it by option (68-97).coordinateIndexWriter(src/index-lock/index-writer-coordination.ts:85-173) takes the landing lock for a writer against the real index, pre-waits for a foreignindex.lock, and hands the forwarded Git aCLI_GIT_LANDING_LEASE(src/index-lock/landing-lease.ts:26-110). A nested invocation whose lease names the same held lock proceeds without it. - Spec:
SPEC.md:3450-3495. - Consumers:
every forwarded index writer;
hooks and
rebase --execcommands that call the wrapper again. - Status: retained.
- Rust owner:
index_writer_coordination.rs(proposed). - Consumer-level test:
in the standard fixture,
run
git add -- a.txtwhile a landing is paused inside its critical section; observe thataddwaits and then succeeds. Rungit rebase --exec 'git add -- b.txt'through the wrapper; observe no self-deadlock. - Native state: absent.
Lock order #
- Behavior:
the order is reservation check,
landing lock,
then real
index.lock(src/policy-engine/commit-landing.ts:236-250). No process takes the hook lock or a push lock while holding the landing lock, and none takes another lock while holding the capture lock (src/policy-engine/commit-capture-order-store.ts:328-395). The wrapper never deletes a foreign lock. - Spec:
SPEC.md:3372-3380. - Consumers: every lock user.
- Status: retained.
- Rust owner: the transaction and lock modules together; no separate module.
- Consumer-level test: the end-to-end reservation, index-writer, and hooked scenarios finish without a stuck process under a bounded timeout, on every seed.
- Native state: absent.
Durable formats #
Journal and lock formats #
- Behavior:
the wrapper writes these durable formats:
transaction journal records at schema version 2
(
src/policy-engine/commit-transaction-journal-states.ts:25); transactionowner.jsonat schema version 2 (src/policy-engine/commit-transaction-owner.ts:28); owner-lockowner.jsonat schema version 1 (src/owner-lock/owner-lock-record.ts:29);captured.json,worktree-id,sequence, and landed-capture records at schema version 1 (src/policy-engine/commit-capture-order-store.ts:57-72;src/policy-engine/commit-capture-order-records.ts:71);last-pushedrecords at schema version 1 (src/auto-push-record.ts:33); worktree-copy journals undercli-git-worktree-copy/v1(src/worktree-copy/journal.ts:29-34) with aninstall-log.jsonl(src/worktree-copy/install-log.ts:39); the worktree-copy settlement owner record (src/worktree-copy/journal-lock-owner.ts:46,66-86); candidate snapshots as length-prefixed binary files (src/policy-engine/commit-transaction-candidate-snapshot.ts:22-26,82-151); the hook planplan.json; the reflog messagecommit (cli-git <nonce>): <subject>; and the pack keep messagecli-git <transaction-id>. Private directories are mode0700and files0600, and reads refuse symbolic links. - Spec:
SPEC.md:2083-2146,1000-1014,1097-1120,3088-3159. - Consumers: recovery in every later invocation, including one made by a different wrapper version.
- Status: retained (implementation plan lines 228 to 233).
- Rust owner:
each format belongs to the module that owns its lifecycle;
a
durable_formatstest fixture set proves compatibility. - Consumer-level test: write each record with the incumbent in a disposable repository, stop it at a phase marker, and run the native wrapper; observe correct recovery from every incumbent-written state. Feed each parser truncated, oversized, and wrong-schema records; observe a fail-closed diagnostic and preserved bytes.
- Native state: absent.
Linked-worktree ignored-state copy #
Every entry in this section is retained by the implementation plan lines 239 to 249, which port worktree copy as its own lifecycle module and preserve the main-worktree bypass and the distinction between settlement locks and landing locks. Native state is absent for every entry.
Applicability and main-worktree bypass #
- Behavior:
runGitWithWorktreeCopy(src/worktree-copy/lifecycle.ts:229-425) forwards without synchronization when the invocation is a short-circuit form (278-286), targets a main worktree or no repository (295-303), inherits a validCLI_GIT_WORKTREE_COPY_LEASE(307-324), or carries--no-worktree-copyin flag position (259-277). A command that neither creates nor moves worktrees only recovers pending journals (325-337).git worktree addandgit worktree move, after alias resolution, are applicable sources (src/forwarded-command.ts:399-412). - Spec:
SPEC.md:901-958. - Consumers:
agents that create linked worktrees from a linked worktree;
AGENTS.mdrule IWT usesgit worktree add. - Status: retained.
- Rust owner:
worktree_copy.rs(proposed). - Consumer-level test:
in the standard fixture,
run
git worktree addfrom the main worktree, from a linked worktree, through an alias, and with--no-worktree-copy; observe a copy only for the linked source without the flag, and that the flag never reaches Git. - Native state: absent.
Created-worktree detection #
- Behavior:
observeWorktreeRepository(src/worktree-copy/git-observer.ts:93-147) captures the administrative identity set under the common directory before Git runs, andfindCreatedWorktrees(src/worktree-copy/git-registry.ts:247-306) compares it afterward, so a worktree that Git registered before failing still counts. - Spec:
SPEC.md:924-937. - Consumers: worktree copy.
- Status: retained.
- Rust owner:
worktree_copy_registry.rs(proposed). - Consumer-level test:
in the standard fixture,
run
git worktree addwith apost-checkouthook that fails; observe that the retained worktree still receives the ignored files and that Git's exit status is preserved. - Native state: absent.
Ignored-state selection #
- Behavior:
readIgnoredRoots(src/worktree-copy/ignored-paths.ts:354-410) asks Git for ignored paths under the standard exclusion stack, excludes registered worktrees nested under the source, and reserves the private stage prefix.cli-git-worktree-copy-(src/worktree-copy/snapshot.ts:37). Repository paths are validated before use (src/worktree-copy/ignored-paths.ts:34-108). A bare repository contributes an empty set. - Spec:
SPEC.md:939-962. - Consumers: worktree copy.
- Status: retained (implementation plan line 242: ignored-state selection).
- Rust owner:
worktree_copy_selection.rs(proposed). - Consumer-level test:
in the standard fixture,
ignore files through a nested
.gitignore,info/exclude, andcore.excludesFile, including a symbolic link, a FIFO, and a nested registered worktree; observe that files and links are copied, the nested worktree is skipped, and the FIFO produces a copy failure without being opened. - Native state: absent.
Staging with copy-on-write #
- Behavior:
stageIgnoredSnapshot(src/worktree-copy/snapshot.ts:225-374) copies the selection into a mode-0700sibling directory of the destination, withCOPYFILE_EXCL | COPYFILE_FICLONE(47), which falls back to a full copy. A parent-first manifest is built (src/worktree-copy/entry-manifest.ts:127-267), modes are applied, and the source and stage manifests must match exactly (src/worktree-copy/entry-compare.ts:251-312). - Spec:
SPEC.md:960-978. - Consumers: worktree copy.
- Status: retained (implementation plan line 243: copy-on-write requests).
- Rust owner:
worktree_copy_stage.rs(proposed). - Consumer-level test: in the standard fixture on a reflink-capable filesystem and on one without reflinks, copy a tree with executable files and symbolic links; observe identical bytes, modes, and link targets, and that a source file changed during staging blocks the destination.
- Native state: absent.
Installation, existing-entry checks, and rollback #
- Behavior:
installSnapshot(src/worktree-copy/install.ts:247-316) preflights every existing destination entry and accepts only an exact match (src/worktree-copy/entry-compare.ts:183-249). It creates absent entries exclusively, installing a regular file as a hard link to its staged copy and falling back to an exclusive copy (src/worktree-copy/install-entry.ts:41,233-321), in batches of 512 entries (src/worktree-copy/install.ts:31).rollbackCreated(src/worktree-copy/install-rollback.ts:80-171) removes only transaction-owned paths that still match the stage. - Spec:
SPEC.md:980-998. - Consumers: worktree copy.
- Status: retained (implementation plan line 244: exact existing-entry checks).
- Rust owner:
worktree_copy_install.rs(proposed). - Consumer-level test:
in the standard fixture,
pre-create one identical and one differing file at destination paths;
observe that the identical file is accepted,
the differing one is never overwritten,
the run exits
2, and rollback leaves the Git-created worktree and every unowned path in place. - Native state: absent.
Journals and install log #
- Behavior:
each destination has a journal under
<git-common-dir>/cli-git-worktree-copy/v1(src/worktree-copy/journal.ts:74-120,317-404), written through a private no-follow temporary file, file sync, rename, and directory sync where supported (208-315). Phases arestaged,installing, andcomplete(src/worktree-copy/model.ts:213). Intents and created identities are appended toinstall-log.jsonlinside the stage, one synced line per batch (src/worktree-copy/install-log.ts:283-385;src/worktree-copy/transaction-journal.ts:55-198). Journal values are validated (src/worktree-copy/journal-validation.ts:170-272). - Spec:
SPEC.md:1000-1014. - Consumers: worktree-copy recovery.
- Status: retained (implementation plan line 245: journals).
- Rust owner:
worktree_copy_journal.rs(proposed). - Consumer-level test: in the standard fixture, copy 10,000 ignored files and count journal rewrites and log lines; observe one journal write per phase and a log that grows by batch, not by file.
- Native state: absent.
Settlement lock #
- Behavior:
acquireWorktreeCopyLock(src/worktree-copy/journal-lock.ts:362-457) serializes installation and recovery per common directory. It waits without limit for an owner proven alive, after one stderr line naming the PID and the lock; an unreadable owner record gets a 1000 ms backoff budget (53) and then a failure that leaves the lock in place. Owner records and liveness are insrc/worktree-copy/journal-lock-owner.ts:161-420. The forwarded Git receives the lease token so nested wrapper invocations forward without the lock (src/worktree-copy/journal-lock.ts:323-360). - Spec:
SPEC.md:1015-1029,3334-3338. - Consumers:
worktree copy;
hooks that call the wrapper during
git worktree add. - Status: retained (implementation plan lines 248 to 249).
- Rust owner:
worktree_copy_lock.rs(proposed), or the sharedowner_lock.rs. - Consumer-level test:
in the standard fixture,
start two
git worktree addcommands together from one linked worktree, and run concurrent commits in that worktree meanwhile; observe both copies complete, one waiter line, and no commit waiting on the settlement lock. - Native state: absent.
Crash recovery #
- Behavior:
recoverPendingWorktreeCopies(src/worktree-copy/pending-recovery.ts:66-91) checks for pending journals without the lock and takes it only to recover.recoverWorktreeCopyTransactions(src/worktree-copy/transaction-recovery.ts:173-200) validates journal paths and the private stage (src/worktree-copy/journal-filesystem.ts:178-249;src/worktree-copy/private-path.ts:44-73), discards a transaction whose destination is no longer a linked registration or whose stage is gone, resumes installation otherwise (src/worktree-copy/transaction-install.ts:83-280), and resumes completed cleanup (src/worktree-copy/journal-cleanup.ts:63-109). Malformed or unsafe state fails closed without deleting it. - Spec:
SPEC.md:1031-1064. - Consumers: every later linked-worktree or bare-repository invocation.
- Status: retained (implementation plan lines 246 to 247: containment validation and crash recovery).
- Rust owner:
worktree_copy_recovery.rs(proposed). - Consumer-level test:
in the standard fixture,
kill the wrapper during staging,
during installation,
and during cleanup,
then run
git statusin a linked worktree; observe that each transaction reaches an end with one notice line. Plant a journal whose paths escape the common directory; observe a fail-closed diagnostic and nothing deleted outside the validated stage. - Native state: absent.
Summary line and exit codes #
- Behavior:
after all destinations settle the wrapper writes one summary line to stderr
(
src/worktree-copy/lifecycle.ts:153-173,394-395). A copy-only failure exits2; when Git also failed, Git's status is kept, or1after a signal (src/bin.ts:443-453;src/worktree-copy/errors.ts:30-97). - Spec:
SPEC.md:1066-1073. - Consumers: humans and agents creating worktrees.
- Status: retained.
- Rust owner:
worktree_copy.rs(proposed). - Consumer-level test: covered by the applicability, detection, and installation tests, each asserting the exit status and the stderr line.
- Native state: absent.
Auto-push #
Every entry in this section is retained by the implementation plan line 226 (current auto-push completion and failure reporting). Native state is absent for every entry.
Trigger, skips, and push arguments #
- Behavior:
autoPush(src/auto-push.ts:392-497) runs after every landed commit whose post-commit gate passed (src/bin.ts:416-422). It skips silently without an upstream and without anoriginremote (src/auto-push.ts:413-431), skips with a note on a detachedHEAD(436-448), pushes plainly when an upstream exists, and otherwise runsgit push --set-upstream origin HEAD(35-47,454-456). The push runs real Git directly, so the wrapper's manual-push lifecycle does not run for it. No configuration key disables auto-push. - Spec:
SPEC.md:1094-1167. - Consumers:
every commit in this repository
(
AGENTS.mdrule APG); agents that must not push twice. - Status: retained.
- Rust owner:
auto_push.rs(proposed). - Consumer-level test:
in the standard fixture,
commit on a branch with an upstream,
on a new branch,
on a detached
HEAD, and in a repository without remotes; observe the bare remote's refs and tracking configuration in the first two cases and no coordination file in the last two. - Native state: absent.
Branch keys #
- Behavior:
encodeBranchKey(src/auto-push-branch-key.ts:89-205) writes each byte of the ref name outside lowercase letters, digits,-,_, and.as uppercase%XX;decodeBranchKey(207-220) reverses it. - Spec:
SPEC.md:1111-1120. - Consumers:
push lock and record paths under
<git-common-dir>/cli-git/push/. - Status: retained.
- Rust owner:
auto_push_branch_key.rs(proposed). - Consumer-level test:
in the standard fixture,
commit on branches named
Feature/Aandfeature/a; observe two distinct key files on a case-insensitive filesystem, each decoding to its ref name. - Native state: absent.
Last-pushed records #
- Behavior:
writeLastPushedRecord(src/auto-push-record.ts:202-235) publishes by rename a record of the last attempt: the resolved tip, the outcome, the lock token and PID, the exit code, and a failed attempt's complete output (58-101). An absent or unreadable record reads as no attempt (152-200). - Spec:
SPEC.md:1097-1110. - Consumers: single-flight joins.
- Status: retained.
- Rust owner:
auto_push_record.rs(proposed). - Consumer-level test: in the standard fixture, corrupt the record between two commits; observe that the second commit pushes anyway and rewrites a valid record.
- Native state: absent.
Single flight and joins #
- Behavior:
runSingleFlightPush(src/auto-push-single-flight.ts:296-414) finishes without the lock when the landed commit is an ancestor of the recorded successful tip (226-294), otherwise waits for the per-branch push lock (346), re-reads the record, joins a covering success or a covering failure recorded after its first read, or pushes and records the attempt. A dead pusher's lock is retired through owner liveness. - Spec:
SPEC.md:1122-1167. - Consumers: concurrent landings on one branch.
- Status: retained.
- Rust owner:
auto_push_single_flight.rs(proposed). - Consumer-level test:
in the standard fixture with a slow
pre-pushhook, land 8 commits together; observe fewer pushes than commits, every landed commit on the remote, and after killing one pusher a takeover push by a waiting joiner. - Native state: absent.
Push output and failure reporting #
- Behavior:
filterPushOutput(src/auto-push.ts:105-121) surfaces onlyremote:lines after a clean push and the complete output after a failure. Every affected invocation, owner or joiner, prints the failure and the note at130, and the commit command still exits0. A coordination failure is reported the same way (483-496). - Spec:
SPEC.md:1156-1164,1572-1575,1603. - Consumers: humans and agents reading commit output.
- Status: retained.
- Rust owner:
auto_push.rs(proposed). - Consumer-level test:
in the standard fixture with a remote that rejects the push,
commit from two processes together;
observe the complete rejection text and the local-commit note from both,
exit
0from both, and the commits present locally only. - Native state: absent.
Logging and diagnostics #
Tagged debug logging #
- Behavior:
production code logs through tagged loggers from
@monochromatic-dev/module-logger, rooted at the tagcli-git(src/bin.ts:54). 96 non-test source files calltagged(192 times, and 90 files hold 215debug,info,warn, orerrorcalls (rg --count-matchesoversrc, excluding tests, fixtures, andnative). The console sink prints debug records whenMONOCHROMATIC_VERBOSE=trueor whenprocess.argvcontains--verbose(package/module/logger/src/sink/console.ts:55-77). - Spec:
SPEC.md:1586(debug logs must not corrupt the selected JSONL stream),1478. - Consumers: developers and agents diagnosing a wrapper decision.
- Status: retained. The implementation plan line 260 lists diagnostics in the first native slice.
- Rust owner:
diagnostics.rs(proposed). - Consumer-level test: in the standard fixture, run a blocked command with verbose diagnostics enabled and capture stderr; observe that every line is either one complete JSONL event or one diagnostic line, never an interleaved fragment, and that stdout holds only Git's output.
- Native state: absent.
Human diagnostics #
- Behavior:
expected rejections carry a message that names the input,
the reason,
and each way forward,
for example
src/rule/require-root.ts:182-186,src/rule/commit-only.ts:38-51,108-115, andsrc/policy-engine/add-explicit-check.ts:124-132. Human lines outside JSONL go to stderr throughconsole: management usage (src/management.ts:150,172,190,196), auto-push notes (src/auto-push.ts:85-86,130,488-489), worktree-copy summaries and failures (src/worktree-copy/lifecycle.ts:172;src/bin.ts:444,451), lock waiter lines (src/index-lock/index-lock-evidence.ts:588-604), and uncaught error messages (src/bin.ts:458). Rawconsolecalls appear in 9 non-test source files, two of them host-evidence programs (rg --count-matches 'console\.(log|error|warn|info)\(' src, excluding tests, fixtures, andnative). - Spec:
SPEC.md:1016-1018,1066-1067,3430,1156-1161. - Consumers: humans and agents acting on a rejection.
- Status: retained.
- Rust owner:
diagnostics.rs(proposed), with message text owned by each rule module. - Consumer-level test: in the standard fixture, trigger each rejection and compare the message with the accepted text fixture; observe that each names the affected input and every remedy.
- Native state: absent.
Platform-specific behavior #
The implementation plan lines 300 to 303 keep the existing Linux,
macOS,
and Windows consumer coverage,
and line 338 keeps native macOS and Windows jobs for their filesystem and process contracts.
Trust-only platform code (src/trust/registry-io.ts,
src/trust/account-root.ts,
src/trust/candidate.ts) retires with the trust subsystem.
Linux #
- Behavior:
process-birth identity and exited-state detection read
/proc/<pid>/stat(src/policy-engine/commit-transaction-process-identity.ts:12-70,133-134); process start time uses start ticks and/proc/uptime(src/index-lock/process-start-time.ts:29,355-360); open lock holders are found through/proc/<pid>/fd(src/index-lock/index-lock-evidence.ts:324-328); the hook dispatcher repeats the liveness check (src/hook-dispatch/hook-dispatch-program.ts:69-84); common Git paths are/usr/bin/gitand/usr/local/bin/git(package/git/executable/src/platform-paths.ts:10-13). - Spec:
SPEC.md:3358-3370,3406-3424. - Consumers: the development host, every container harness, and every CI job that runs the wrapper.
- Status: retained.
- Rust owner:
process_identity.rsandindex_lock_evidence.rs(proposed). - Consumer-level test: the standard fixture runs on Linux; the zombie-owner and open-descriptor cases under "Locks" are the platform cases.
- Native state: absent.
macOS #
- Behavior:
birth identity and start time come from
ps -o lstart= -p <pid>(src/policy-engine/commit-transaction-process-identity.ts:135-145;src/index-lock/process-start-time.ts:361-362;src/hook-dispatch/hook-dispatch-program.ts:85-88); open holders come fromlsof(src/index-lock/index-lock-holders-darwin.ts:335-372), spawned only while a foreign lock is present; common Git paths add/opt/homebrew/bin/gitand/opt/local/bin/git(package/git/executable/src/platform-paths.ts:18-22). - Spec:
SPEC.md:3411-3424. - Consumers:
macOS developers;
the
trustjob of.github/workflows/cli-git-trust.yml:189-232is the only macOS CI job, and it runs trust and filesystem-identity tests only. - Status: retained.
- Rust owner:
process_identity.rsandindex_lock_evidence.rs(proposed). - Consumer-level test:
on a macOS host,
run the owner-lock,
foreign
index.lock, and concurrent-commit cases with the nativegit; observe the same outcomes as on Linux. - Native state: absent.
Windows #
- Behavior:
real-Git lookup follows
PATHEXTand compares candidates case-insensitively (package/git/executable/src/resolve-real-git.ts:31,78-123), with Program Files andLOCALAPPDATAinstall roots (package/git/executable/src/platform-paths.ts:27,51-92) and backslash shim markers (package/git/executable/src/self-shim.ts:149-154). Birth identity and start time come from a PowerShellGet-Processcall (src/policy-engine/commit-transaction-process-identity.ts:146-157;src/index-lock/process-start-time.ts:363-364); open holders come from a Restart Manager query run through PowerShell (src/index-lock/index-lock-holders-win32.ts:26-187), never aDELETE-access probe. The shadow repository shares directories as junctions and copies shared files (src/shadow-repository/shadow-links.ts:96-125). Directory sync is skipped (src/worktree-copy/journal.ts:217-219;src/worktree-copy/install-log.ts:255-257). The hook shim's shebang form is pending verification on Windows (SPEC.md:2460-2462). - Spec:
SPEC.md:3417-3423,2460-2462;doc/decision/cli-git-concurrent-commits.md:475-478. - Consumers:
Windows developers;
the
trustjob of.github/workflows/cli-git-trust.yml:189-232is the only Windows CI job. - Status: retained.
- Rust owner:
git_resolution.rs,process_identity.rs,index_lock_evidence.rs,shadow_repository.rs, andhook_dispatch.rs(proposed). - Consumer-level test:
on a Windows host,
run an ordinary commit with a hookdir hook,
two concurrent commits,
a foreign
index.lockheld by Git for Windows, and agit worktree addfrom a linked worktree; observe the outcomes of the Linux cases. - Native state: absent.
Harnesses and verification #
TypeScript unit suites #
- Behavior:
110
*.unit.test.tsfiles undersrc, run by thetest:unittask (package/git-policy/cli/mise.toml:81-82). Many exercise the built artifact through the internal test exports. - Spec:
SPEC.md:3620-3907lists the required disposable fixtures. - Consumers:
local development;
.github/workflows/cli-git-trust.yml:180-184runs two of the files at each supported Node floor, and lines 221 to 228 run three trust files on three operating systems. - Status:
retired with the TypeScript implementation
(implementation plan lines 295 to 297).
The fixture catalog of
SPEC.md:3620-3907stays the list the native tests must cover (lines 304 to 316). - Rust owner: each native module's tests, and the container suite for consumer behavior.
- Consumer-level test: not applicable; this entry is itself verification.
- Native state:
51
#[test]functions exist undersrc/native/atdf25471a9.
Built-artifact fixtures #
- Behavior:
53 files under
src/trust/fixture, consumer programs and their helpers, install the packed tarball in a disposable project and drive the builtgitshim.test:built:trustrunssrc/trust/fixture/built-trust-consumer.tsin a boundedpodmancontainer (package/git-policy/cli/mise.toml:100-131). - Spec:
SPEC.md:4254-4283. - Consumers:
local release verification.
No CI workflow runs the task
(
rg "built:trust|e2e|shadow|worktree-copy|concurrent" .github --hidden --no-ignorematches nothing for them). - Status: retired with the JavaScript artifact (implementation plan lines 295 to 297). Their non-trust cases feed the native container tests.
- Rust owner: the native container suite.
- Consumer-level test: not applicable.
- Native state: absent.
Container end-to-end suite #
- Behavior:
e2e/holds a seeded concurrent-commit suite: a commit-shape trace mined from this repository's history (e2e/commit-shape-trace.json), a scenario catalog (e2e/scenario-catalog-fixture.ts), and invariant checks (e2e/invariant-fixture.ts,e2e/leftover-fixture.ts). The image builds Git 2.39.5, 2.40.0, and 2.55.0 (e2e/concurrent-commits.Containerfile). Tasks:e2e:concurrent:trace,test:e2e:concurrent:image, andtest:e2e:concurrent(package/git-policy/cli/mise.toml:273-358), the last with 2 GiB, 2 CPUs, and no network.e2e/README.md:445-460records 38 scenarios per Git version and three passing seeds. - Spec:
SPEC.md:3909-3988. - Consumers: local verification before a merge. No CI workflow runs it.
- Status: retained. The implementation plan lines 289 to 291 reuse the existing scenarios against the Rust executable, adapting the driver; line 300 replaces the multi-version Git fixture with the exact latest stable release.
- Rust owner:
the adapted driver under
e2e/, outsidesrc/native/. - Consumer-level test:
run every seed-1,
seed-2,
and seed-3 scenario against the native executable on Git 2.56.0;
observe every invariant of
SPEC.md:3973-3988. - Native state: absent.
Performance harnesses #
- Behavior:
perf:lifecycle-latencymeasures paired wrapper and direct-Git samples per scenario and enforces budgets (package/git-policy/cli/mise.toml:137-200;perf/lifecycle-latency-contracts.ts:212-231, with a 2,000 ms ceiling).perf:concurrent-commitsmeasures throughput, lock holds, and lost races (package/git-policy/cli/mise.toml:202-271).perf/manual-push-latency-benchmark.tsmeasures the manual-push gate. Recorded results are the JSON files underperf/. - Spec:
SPEC.md:4089-4252. - Consumers:
.github/workflows/cli-git-performance.yml:70-114runs the lifecycle benchmark when the package version changes and uploads the raw samples. - Status:
retained as an acceptance check
(implementation plan lines 318 to 322).
The trust scenarios
strict-mjs,strict-typescript, andrelaxed-rebuildretire with the trust subsystem. The rewrite scope lines 91 to 96 state that no numeric acceptance budget is settled for the new design. - Rust owner:
the harness under
perf/, outsidesrc/native/. - Consumer-level test: run the lifecycle scenarios against the release native artifact with a positive control per scenario; observe wrapper-added medians and p95 beside the direct-Git baseline, with local processing reported apart from push latency.
- Native state: absent.
CI workflows #
- Behavior:
.github/workflows/cli-git-trust.ymlchecks the Node runtime policy, builds and tests at each Node floor, and runs trust suites on Linux, macOS, and Windows..github/workflows/cli-git-performance.ymlruns the lifecycle benchmark on a version bump..github/workflows/final-newline.yml:38-39runssrc/trust/fixture/final-newline-workflow.ts, an isolated direct check of the final-newline policy..github/workflows/forbidden-strings.ymlruns the released scanner on changed files, independent of the wrapper. - Spec:
SPEC.md:4059,4279-4281. - Consumers:
pull requests and pushes to
main. - Status: retained for the final-newline check, the performance job, and the independent scanner job; the Node-runtime and trust jobs retire with their subjects. The implementation plan line 436 lists CI among the things updated together at cutover.
- Rust owner: none; workflow files.
- Consumer-level test: after cutover, each retained workflow passes on a pull request that uses the native executable.
- Native state: absent.
Maintenance utilities #
hk Git-config cleanup #
- Behavior:
cleanupHkGitConfig(src/maintenance/hk-config-cleanup.ts:56-157) removes only keys beginning withhook.hk-from explicitly chosen Git configuration scopes. The command entry issrc/maintenance/hk-config-cleanup-command.ts; it resolves real Git through@monochromatic-dev/git-executable. - Spec:
no
SPEC.mdsection states it;doc/runbook/remove-retired-hk-git-config.mdis the procedure. - Consumers:
the root task
cleanup:hk-git-config(mise.toml:655-661) and the fixture tasktest:hk-config-cleanup(package/git-policy/cli/mise.toml:133-135). The npm package excludessrc/maintenance(package/git-policy/cli/package.json:24). - Status: retained as a repository task outside the wrapper executable. The implementation plan does not name it; see "Open questions".
- Rust owner: none proposed.
- Consumer-level test: the existing disposable-scope fixture, run against whichever implementation remains.
- Native state: absent.
Consumers #
One list of who reaches the wrapper, by route.
- Installed-bin wiring:
root
package.json:36depends on@monochromatic-dev/git-policy-cli; the package manager writesnode_modules/.bin/git, a shell shim that starts Node ondist/final/node/index.mjs; rootmise.toml:1252-1253putsnode_modules/.binfirst onPATH, and line 1269 adds the package's ownnode_modules/.bin. - Repository configuration:
cli-git.config.ts. - Root mise tasks:
cleanup:hk-git-config(mise.toml:655-661);changeset:version, which calls//package/git-policy/repository:bump:dependents(mise.toml:1193-1197); theFORBIDDEN_STRINGS_RULESenvironment entry (mise.toml:1321-1327). - Package mise tasks:
package/git-policy/cli/mise.toml(run,build,lint*,test:unit,verify:supported-runtime,pack:npm,test:built:trust,test:hk-config-cleanup,perf:*,e2e:*,test:e2e:*, and the native tasks at lines 1 to 19). - file-enforcer:
the optional-policy mirrors (
file-enforcer.config.ts:2260-2322) and the generated scanner rules file (2258). - CI workflows:
cli-git-trust.yml,cli-git-performance.yml,final-newline.yml. - Hooks:
repository Git hooks run under the wrapper's dispatcher during commits.
No tracked file registers a Git hook
(the hk configuration was removed,
doc/handover/cli-git-policies-platform.mdsection "Retirement checkpoint on 2026-07-11";git config --get core.hooksPathis unset in this checkout). This checkout's untracked.git/hooksholds the four Git LFS hooks,post-checkout,post-commit,post-merge, andpre-push, each runninggit lfs <event>throughPATH. Each therefore re-enters the wrapper as a nested invocation of the external commandlfs, which the classifier treats as configuration-loading (src/trust/command-classification.ts:280-281). - Other packages:
package/git/executable(the resolver the wrapper uses and that must recognize it);package/pi-plugin/auto-mode/src/git-worktree-read-allowlist.ts(uses that resolver);package/git-policy/api,package/git-policy/repository,package/git-policy/forbidden-strings, andpackage/git-policy/markdown-lint(policy sources mirrored into the wrapper);package/cli/forbidden-strings(the scanner);package/cli/markdown-lint(the Markdown command);package/config/pnpr/config.yaml:76-80(private-registry publishing list);.changeset/config.json:21. - Agent tooling:
agent shells reach the wrapper through
PATH.AGENTS.mdrules CLG, CPN, APG, APQ, GCE, and GCA describe working with its guards and auto-push.rg --hidden --no-ignore --glob '!**/worktrees/**' "cli-git|git-policy" .claudematches nothing, so no agent hook or skill there names the wrapper.
Responsibilities the plan adds #
These have no incumbent behavior and are not counted in the status tally.
- JSONC configuration loading from repository-root
cli-git.config.jsoncthroughpackage/rust-module/jsonc-edit(implementation plan lines 55 to 61). Native state: implemented as library modules (src/native/config_file.rs,src/native/config_parse.rs). - Legacy configuration migration diagnostic (lines 440 to 443).
Native state:
implemented as library code.
load_repository_configfails when only a legacy file exists (src/native/config_file.rs:273-277) and returns the legacy paths for a notice when both exist (146-153,298-303). - Retired trust-command explanation (line 444). Native state: in progress.
- Unsupported-environment failure for a Git without required behavior (lines 22 to 25 and 235 to 237). Native state: absent.
- In-process scanner linkage with the standalone scanner routed through the same core (lines 128 to 152).
Native state:
the scanner side is implemented (
doc/handover/scanner-native-verification.md); the wrapper side is absent. - First-party linter selection and a one-rule temporary JSONC configuration for the Markdown policy (lines 181 to 189). Native state: absent.
- Native launcher, installed-bin wiring, and native-wrapper recognition in the TypeScript resolver (lines 425 to 434). Native state: absent.
- Container,
mutation,
and fuzz gates,
with a sibling fuzz package (lines 324 to 419).
Native state:
the bounded container runner exists
(
bin/test-native-container.mjs,bin/build-git-test-image.mjs,package/git-policy/cli/mise.toml:1-19); the mutation runner and fuzz package are in progress. - Rollback: the previous executable stays available until native installation and recovery checks pass (line 446).
Spec and code disagreements #
Both sides are recorded; none is resolved here. Items marked "by reading" were derived from the cited source lines and were not observed at the consumer boundary in this survey.
- Built-in order and IDs:
SPEC.md:1237-1241and theBuiltInPolicyIdtype atSPEC.md:233-237list four built-ins;SPEC.md:3995-3999,src/policy-engine/built-ins.ts:21-27, andsrc/api/config-types.ts:59-64list five, withfinal-newlinelast. - Patch target revision:
SPEC.md:582makesrevisionbeingABSENT_GIT_VALUEa condition of a valid patch, andSPEC.md:373calls a candidate with that value mutable. The code gives commit candidates their blob ID asrevision(src/policy-engine/commit-transaction-candidates.ts:185), throws when a patch target's revision is the absent symbol (src/policy-engine/final-newline-policy.ts:62-63), and requires the patch'sindexheader to name that revision (src/policy-engine/commit-transaction-patch.ts:103-105,164). - Post-commit candidates:
SPEC.md:1085sayscandidates()enumerates the landed commit's complete recursive tree. The code supplies only the paths the landed commit changed, throughgit diff-tree --root --no-commit-id -r -z -m(src/policy-engine/post-commit-facts.ts:119-154).doc/handover/cli-git-policies-platform.md, section "Release-readiness checkpoint on 2026-07-11", records the restriction to the landed delta as intended. - Event sequence (by reading):
SPEC.md:1306sayssequencestarts at0for each invocation and increases by one in emission order. Each engine run numbers from0(src/policy-engine/engine.ts:298), and one invocation can write several batches: pre-forward (src/bin.ts:277-280), manual push (336-339;src/policy-engine/manual-push-lifecycle.ts:236), and post-commit (src/bin.ts:412-415;src/policy-engine/post-commit-lifecycle.ts:140-153,177-190). A commit with a pre-forward event and a post-commit event therefore repeatssequence0. - Canonical command facts (by reading):
SPEC.md:784-785sayseffectiveCwdis canonicalized andrepositoryRootis the canonical real-Git top level.parseGlobalOptionsresolves-Clexically withoutrealpath(src/parse-global-options.ts:68-83), and the engine useseffectiveCwdasrepositoryRootwhen no lifecycle supplies one (src/policy-engine/engine.ts:115). - Finding validation:
SPEC.md:564-574requires kebab-case codes and a location inside the candidate's byte length.findingsAreValidchecks only non-emptycodeandmessage(src/policy-engine/policy-stage.ts:60-71), andrg "byteStart|byteEnd" srcoutside tests matches only the type declaration and the event copy (src/api/policy-types.ts:183-193;src/policy-engine/events.ts:417-418). - Policy cancellation:
SPEC.md:383-385says cancellation usescontext.signal. The engine passes the signal of a freshAbortControllerthat nothing aborts (src/policy-engine/engine.ts:119), and the wrapper installs no signal handler. - Management usage text:
SPEC.md:808-811requires exactly one of--allor-- <pathspec>.... The usage text prints both as optional (src/management-parser.ts:22-28); the enforcement matches the spec (src/management.ts:189-192). - Shipped plugin exports:
SPEC.md:71-73namesrepositoryPolicyPluginand, conditionally on issue #354,forbiddenStringsPlugin.src/authoring.ts:28-52exports both unconditionally and alsomarkdownLintPlugin. - Recovery failure code:
SPEC.md:3526-3528says malformed transaction state fails closed and names no code.src/bin.ts:432-438reports it ascontent-unavailable, whileSPEC.md:1457also definestransaction-failed. - Planning text against the spec:
doc/planning/cli-git-concurrent-commits.md:347-353says a private ref underrefs/cli-git/protects pending commits.SPEC.md:2184-2191anddoc/decision/cli-git-concurrent-commits.md:482-483say no such ref exists and the shadow object store protects them. - Windows verification:
doc/decision/cli-git-concurrent-commits.md:475-478says Windows verification of the shadow links runs in CI. The only Windows job runs trust and filesystem-identity tests (.github/workflows/cli-git-trust.yml:189-232). - Incumbent against native global options:
the incumbent skips a value after
--super-prefixand has no entry for--config-envor--shallow-file(src/parse-global-options.ts:12-20), treats every unknown dash-led token as a flag (166-174), and short-circuits only on--version,-v,--help, and-h(25-30). The native table has--config-envand--shallow-file, no--super-prefix(src/native/global_arguments.rs:37-46), reports an unknown option asInvalidOption(149-152), and also treats--html-path,--man-path,--info-path,--list-cmds=, and a bare--exec-pathas queries (95-120). By reading, the incumbent takes the value of a separated--config-env <name>=<var>as the subcommand. - Incumbent against native classification:
the incumbent's mutating
branchlong flags omit--delete-merged,--set-upstream, and--create-reflog, and its short letters omituandt(src/trust/command-classification.ts:49-69); the native table includes them (src/native/config_loading.rs:54-68,179). The incumbent ignores unknown long options when classifyingbranchandtag(src/trust/command-classification.ts:222-238); the native classifier loads configuration for them (src/native/config_loading.rs:167-168).
Incumbent defects and stale comments #
Recorded for the port, not fixed.
- Stale parser-library comments:
43 mentions of "optique" remain in 14 files under
src(rg --count-matches --ignore-case optique src --glob '!src/native/**'), for examplesrc/escape-hatch.ts:55-58,src/rule/atomic-push.ts:28, andsrc/rule/commit-only.ts:181. The package no longer depends on it (package/git-policy/cli/package.json:50-59), andsrc/management-parser.ts:2says the grammar replaced that facade. README.md:1185-1190tells authors to add rules to aRULESarray insrc/index.ts;src/index.ts:1-41has no such array.- The version banner lists eight behaviors by hand and omits
final-newline(src/post-command-output.ts:89-92). src/policy-engine/engine.ts:2and41still call the module a first slice with a built-in-only schema, and the message at235says "Unknown built-in policy ID" for any unknown ID, plugin IDs included.- Recursion over linear input:
walkGlobalOptions(src/parse-global-options.ts:101-181) andfilterFlagEscapeHatch(src/escape-hatch.ts:178-227) recurse once per argument. - Three pinned Git versions describe one grammar:
classification fixtures target Git 2.54.0 (
src/trust/command-classification.ts:4), the built-in command table comes from Git 2.55.0 (src/git-builtin-commands.ts:2), and the native tables target Git 2.56.0 (src/native/global_arguments.rs:1). - Newline-delimited parsing of
git rev-parseoutput:parseIdentityMetadatasplits on LF (src/git-worktree-identity.ts:248-254), so by reading a Git directory path that contains LF is misparsed. - Duplicate constants:
ref-updated.jsonandindex-installedare declared in bothsrc/policy-engine/commit-transaction-journal.ts:19-23andsrc/policy-engine/commit-transaction-journal-states.ts:40-45;journal.jsonin bothsrc/policy-engine/commit-transaction-recovery-journaled.ts:60andsrc/policy-engine/commit-transaction-recovery-landing.ts:81. - Verbose logging is tied to a Git argument:
the logger enables verbose output when
process.argvcontains--verbose(package/module/logger/src/sink/console.ts:69-77), so by readinggit commit --verbosealso turns on wrapper debug lines on stderr. - A Git child ended by a signal exits
1(src/bin.ts:454-456), not a status that names the signal. - The tool-cache allowlist has no platform branch
(
src/allowed-worktree-dirs.ts:60-88): it derives one cache location fromUV_CACHE_DIR,XDG_CACHE_HOME, or<home>/.cache. SPEC.md:2460-2462leaves the hook shim's shebang form on Windows, and for an executable path with spaces, pending verification.doc/handover/cli-git-concurrent-commits.mdkeeps a "Next actions" list (lines 341 to 364) of steps its own "Landed" section (lines 5 to 52) reports as done.- Retained code depends on the trust directory:
17 non-trust files import
src/trust/registry-io.tsfor private-file helpers, andsrc/bin.ts:35,44import classification and concurrency defaults fromsrc/trust/. - No CI workflow runs the transaction,
lock,
worktree-copy,
or end-to-end suites,
and none runs any retained wrapper behavior on macOS or Windows
(
rg "e2e|built:trust|test:unit|shadow|worktree-copy|concurrent" .github --hidden --no-ignorematches only the two-filetest:unitstep of the Linuxsupported-runtimejob and unrelated fuzz workflows).
Open questions #
The planning documents do not determine these. Each names the text that stops short.
- Fixed policy names and optional-policy defaults.
The implementation plan lines 55 to 61 require unknown policy IDs to be errors
but name no IDs or defaults.
The native registry keeps
markdown/,mono/, andsecurity/prefixes and defaults the four optional policies toOff(src/native/policy_registry.rs:95-160). The incumbent runsmono/dependent-version-bumpaterrorwithout listing it. Should the optional policies default to their incumbent severities, and are these the accepted names? - Policy option surface.
The rewrite scope lines 126 to 131 forbid
executableandcommand. Nothing states which other options stay. The native schema keepsbuiltinRules,rules, andexclude(src/native/config_schema.rs:75-93). DoesFORBIDDEN_STRINGS_RULESremain the way to name the rules file? - Configuration root.
The plan says "repository-root" (line 55).
The incumbent uses the nearest ancestor of the effective directory that holds a Git marker
(
src/trust/config-discovery.ts:110-131), which is a linked worktree's own root and ignores--git-dirand--work-tree. Which root does the native wrapper pass toload_repository_config, and what happens in a bare repository? - Legacy configuration during the rollback window.
The plan line 446 keeps the previous executable available,
which needs
cli-git.config.ts, while lines 440 to 443 require a migration diagnostic. The native loader reports a legacy file beside a JSONC file on every load (src/native/config_file.rs:146-153). Is a notice on every configuration-loading command intended while both wrappers are installed? - Retired trust commands.
The plan line 444 says they explain the retirement.
It does not give the exit status,
the stream,
or whether
git cli-git statuskeeps its name for another purpose. - Signals.
The plan lines 84 to 91 port "signals" without stating the contract.
The incumbent has no handler and maps a signaled Git to exit
1. Should the native wrapper forward signals to the child, and which exit status reports a signaled child? - Event sequence numbering. The spec and the code disagree (see "Spec and code disagreements"). The plan lines 315 to 316 make the accepted behavior the oracle. Does the native wrapper number events once per invocation?
- Non-UTF-8 paths in events and journals.
The plan lines 47 to 49 preserve argument bytes and path representations.
JSONL events carry paths as JSON strings (
SPEC.md:1337), andcaptured.jsonstores Latin-1 decoded path bytes (SPEC.md:3138-3139). The encoding of a non-UTF-8 path in an event is not stated. - Engine failure codes that lose their source.
plugin-threw,policy-incomplete,config-untrusted,config-changed,trust-consent-unavailable, andtrust-failed(src/policy-engine/events.ts:88-103) describe plugins and trust. Which code reports a failed built-in policy, such as a scanner error? - Hook dispatcher and generated hooks without Node.
The shim and the manual-push probe hook are generated Node programs
(
src/hook-dispatch/hook-dispatch-program.ts:27;src/policy-engine/manual-push-hook.ts:344-405). The plan lines 425 to 426 remove Node from the launch path. The native form of these hook entries, and its Windows form, is not stated. - Lock and journal interoperability across versions.
The plan lines 228 to 233 keep formats where practical with cross-version fixtures.
Birth-identity strings are built from
psand PowerShell output (src/policy-engine/commit-transaction-process-identity.ts:135-157). Must the native wrapper produce identical strings so each version judges the other's locks correctly? - Legacy single-journal directory.
The incumbent still recovers
cli-git-transaction(SPEC.md:2145-2146). The plan forbids silently discarding old state (lines 230 to 233) but does not say whether this older format is ported or reported. - Unsupported Git detection. The plan lines 22 to 25 support the latest stable release and forbid a network query at run time, and lines 235 to 237 require an unsupported-environment failure. When is the check made, and is it a version comparison or a behavior probe?
- Post-command output.
The plan does not mention the version banner or the status note.
Does the native wrapper keep adding a line to
git --versionoutput? - Tool-cache allowlist. It is compiled in and Linux-shaped. The plan does not say whether it stays compiled in, moves to JSONC, or gains other platforms.
- Test phase markers.
The reused end-to-end scenarios need
CLI_GIT_TEST_ONLY_PHASE_SIGNAL. The plan does not say whether the release executable carries the markers or a separate test build does. - macOS and Windows coverage. The plan lines 300 to 303 keep existing coverage, which today is trust-only on those systems. Which native tests run there?
- TypeScript utilities beside the wrapper.
cleanup:hk-git-configand//package/git-policy/repository:bump:dependentsare TypeScript tasks. The second shares planning code with the dependent-version policy. Do they stay TypeScript, leaving two implementations of the bump plan? - Verbose diagnostics switch.
The incumbent switch is
MONOCHROMATIC_VERBOSEor a--verboseargument. The native switch is not stated. - Performance acceptance.
The rewrite scope lines 91 to 96 say no numeric budget is settled,
while
SPEC.md:4038andperf/lifecycle-latency-contracts.ts:212hold a 2,000 ms ceiling. Which numbers gate the native artifact? - Markdown policy without the linter. The plan lines 181 to 189 select the coordinated installation's linter. The behavior when that binary is missing is not stated.
Related documents #
doc/decision/cli-git-rust-rewrite.md: the accepted decision.doc/planning/cli-git-rust-rewrite.md: scope, settled interview requirements, and the installed-wrapper baseline.doc/planning/cli-git-rust-implementation.md: module responsibilities, sequence, verification gates, and cutover.doc/handover/cli-git-rust-implementation.md: execution state and delegations.doc/decision/cli-git-policies-platform.mdanddoc/handover/cli-git-policies-platform.md: the policy platform and its checkpoints.doc/decision/cli-git-concurrent-commits.md,doc/planning/cli-git-concurrent-commits.md, anddoc/handover/cli-git-concurrent-commits.md: concurrent commits.doc/planning/cli-git-policy-added-paths.md: policies that add paths to a commit.doc/planning/cli-git-noninteractive-trust-ux.md: trust diagnostics, retired with the trust subsystem.doc/handover/cli-git-cac-migration.md: why the package owns its argument parser.package/git-policy/cli/doc/concurrent-commits-implementation-plan.md: the incumbent code map.doc/planning/unified-linter-coverage-ledger.md: the linter ledger this document is modeled on.