# Machine Git count contract v1

This contract is mandatory for every WG Paid / MGTS STEP that reports Machine Git facts.

1. A full commit tree count must use `git ls-tree -r --full-tree --name-only` with explicit `--git-dir` and `--work-tree`.
2. The full tree count must be independently equal to the number of non-directory entries produced by `git archive`.
3. Future STEP facts must use explicit fields:
   - `git_tree_file_count`
   - `published_archive_file_count`
   - `changed_file_count`
   - `changed_files`
4. The ambiguous field `tracked_file_count` is forbidden.
5. STEP code must pass `/opt/router-ops/bin/router-step-machine-git-guard --step-code <step-code.sh>` before changes and again before PASS.
6. STEP facts must pass the same guard with `--facts-json`; when a Machine Git publication exists, also provide its published `facts.json`.
7. Any tree/archive mismatch or unsafe `ls-tree` use produces STOP, never PASS.
8. Historical reports are immutable. Corrections are published as later timestamped STEP artifacts.
