feat(dirty-content-fingerprint): add --version-only composition with dirty_fingerprint
Adds xce_compose_version_ex() as a sibling of the existing, completely untouched xce_compose_version(): when dirty_fingerprint is non-empty, it strips a trailing -dirty from the commit field (anchored tail-slice strcmp, not a substring search) and appends -<dirty_fingerprint> instead; when empty/NULL, it delegates directly to the original function, so output is structurally guaranteed byte-identical -- including the Requirement 5.2 fallback case (dirty tree, fingerprint computation failed) where commit_id's own pre-existing -dirty suffix already signals "modified" with no new sentinel needed. No main.c call sites touched -- consuming daemons (tasks 3.2/3.3) still call the original xce_compose_version() and will switch to the new function themselves. Verified independently by review, full lib suite on both debug and ASAN profiles: 301 tests, 0 failures, 0 ignored; suffix-anchoring, buffer safety, and the empty-fingerprint delegation path all confirmed correct by hand-tracing the implementation, not just trusting the test results. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
fc5cba15e1
commit
7ebcba6d49
4 changed files with 178 additions and 5 deletions
|
|
@ -19,11 +19,10 @@
|
|||
- _Boundary: Nix packaging_
|
||||
|
||||
- [ ] 3. Core: C daemon --version fingerprint display
|
||||
- [ ] 3.1 Extend the shared version-composition mechanism with an optional fingerprint field, without touching commit_id
|
||||
- `commit_id`'s own computation and its existing `-dirty` suffix are **not modified** -- this task only changes how the `--version` composition function *displays* it
|
||||
- `xce_compose_version()` (or a sibling function reusing its internals) gains an optional `dirty_fingerprint` parameter, consumed only by the `--version` call path: when non-empty, the composition strips a trailing `-dirty` from `commit_id` (if present) and appends `-<dirty_fingerprint>` instead, producing `<commit_id>-<hash>`; when empty, the composition uses `commit_id` completely as-is (already correctly showing the bare hash on a clean tree, or `<hash>-dirty` on a dirty tree where the fingerprint computation failed -- Requirement 5.2, satisfied for free)
|
||||
- The existing signature/call sites used by startup-log composition are left completely unaffected -- no new parameter reaches them, and `commit_id` is passed to them exactly as before
|
||||
- Observable: new unit tests in `test_utils.c` confirm all three cases (empty field + clean `commit_id` -> `<commit_id>` alone; empty field + `-dirty`-suffixed `commit_id` -> `<commit_id>-dirty` unchanged; non-empty field -> `-dirty` stripped and replaced with `-<hash>`) and confirm the startup-log-facing composition path's existing tests still pass completely unmodified
|
||||
- [x] 3.1 Extend the shared version-composition mechanism with an optional fingerprint field, without touching commit_id
|
||||
- New sibling function `xce_compose_version_ex()` added alongside the completely untouched `xce_compose_version()` (zero diff lines in its body or its 3 pre-existing tests); anchors the `-dirty` strip via a true tail-slice `strcmp` (not `strstr`), so it cannot false-match a `-dirty` substring elsewhere; correctly appends `-<fingerprint>` with exactly one dash even when the commit field has no `-dirty` to strip; delegates via a genuine `return xce_compose_version(...)` call (not a re-implementation) when the fingerprint is empty/NULL, structurally guaranteeing byte-identical output, proven by a dedicated equivalence regression test
|
||||
- No `main.c` call sites were touched by this task (grep-confirmed all still call the original, untouched `xce_compose_version()`) -- that's tasks 3.2/3.3's job
|
||||
- Observable confirmed live (independently re-verified by review, full lib suite on both debug and ASAN profiles): 301 tests, 0 failures, 0 ignored on both profiles; all 3 required cases present with byte-exact assertions, plus 2 meaningful additional regression/defensive tests; buffer handling confirmed snprintf-bounded with no overflow risk
|
||||
- _Requirements: 1.1, 1.2, 1.3, 1.4, 2.1, 3.1, 3.2, 5.2_
|
||||
- _Boundary: utils.h, utils.c_
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue