test(dirty-content-fingerprint): add dev-loop distinguishability regression

Adds src/tools/test-dirty-fingerprint-distinguishability.sh, driving a real
xce-build.sh scheduler cycle through the 4 required --version fingerprint
states (clean/dirty-A/dirty-B-differs/reverted-A-matches). Uses a genuine
isolated git worktree (git worktree add --detach at a unique mktemp -u
path) to sidestep this actively-shared repo's ambient concurrent-editing
noise -- all file edits confined strictly inside the isolated worktree,
cleaned up via a trap registered before creation so it safely no-ops if
creation never happened.

Verified independently by review across two full live runs, including a
deliberately sabotaged copy forcing edit-B to reproduce edit-A's content:
the sabotaged run correctly failed with a clear message and exit 1,
proving genuine discriminating power. git worktree list and the real
repo's working tree confirmed byte-identical to baseline before and after
every run.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-08-21 09:56:12 +00:00
parent fd53525651
commit a7d64c8225
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
2 changed files with 485 additions and 3 deletions

View file

@ -94,9 +94,10 @@
- _Depends: 5.1_
- [ ] 6. Integration: cross-toolchain consistency and regression verification
- [ ] 6.1 Dev-loop distinguishability and clean-tree regression test
- New standalone script (following the `build-time-versioning` feature's `src/tools/test-*.sh` convention) drives a real `xce-build.sh scheduler` build cycle: build on a clean tree and confirm `--version` shows the commit id alone (no `-dirty` suffix, no fingerprint suffix); edit a tracked file, rebuild, confirm a fingerprint suffix appears and `-dirty` does not; edit again with different content, rebuild, confirm the fingerprint differs from the previous one; revert to the first edit's exact content, rebuild, confirm the fingerprint matches the first capture exactly
- Observable: the script exits non-zero and reports clearly if any of the four expected states (clean/no-suffix-at-all, dirty-A, dirty-B different from A, reverted-to-A matching A) does not hold, or if a literal `-dirty` substring ever reappears anywhere in `--version` output
- [x] 6.1 Dev-loop distinguishability and clean-tree regression test
- New script `src/tools/test-dirty-fingerprint-distinguishability.sh` uses a genuine isolated `git worktree add --detach` (unique `mktemp -u` path, `trap cleanup EXIT` registered before creation, safe no-op if creation never happened, `rm -rf`+`prune` fallback) to sidestep this actively-shared repo's ambient concurrent-editing noise -- all file edits confined strictly inside the isolated worktree, the real repo's own working tree never touched
- Drives a real `xce-build.sh scheduler` cycle through the 4 required states via genuine builds; fails loudly with a clear message on any mismatch
- Observable confirmed live (independently re-verified by review across two full live runs, including a deliberately sabotaged copy forcing edit-B to reproduce edit-A's content): clean/no-suffix, dirty-A, dirty-B-differs-from-A, reverted-to-A-matches-A all held with real fingerprints; sabotaged run correctly failed with a clear message and exit 1, proving genuine (not just synthetic) discriminating power; `git worktree list` and the real repo's working tree confirmed byte-identical to baseline before and after every run, both by implementer and reviewer
- _Requirements: 1.1, 1.2, 1.3, 1.4, 2.1_
- _Depends: 2.1, 3.2_