feat(dirty-content-fingerprint): go_build injects fingerprint via ldflags

go_build now reads XCE_DIRTY_FINGERPRINT (empty-safe) and appends
-X main.DirtyFingerprint=... to its existing -ldflags construction,
falling back to plain empty string when unset -- deliberately NOT the
"unknown" fallback GitCommit/BuildTime use, matching dirty_fingerprint's
empty-means-nothing-to-show convention everywhere else in this feature.
Existing GitCommit/BuildTime fallback logic is completely untouched.

Verified independently by review with real scratch Go builds traced via
bash -x: unset -> empty flag value (not fabricated); set -> exact value
carried through; all-unset -> GitCommit/BuildTime still fall back to
"unknown" while DirtyFingerprint stays empty, confirming the two
conventions coexist without interference.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-08-21 06:06:05 +00:00
parent d3d9522f27
commit b949949367
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
2 changed files with 9 additions and 4 deletions

View file

@ -41,9 +41,9 @@
- _Depends: 3.1_
- [ ] 4. Core: Go binary --version/-version fingerprint display
- [ ] 4.1 go_build injects the fingerprint via ldflags
- `src/tools/go_build` reads `XCE_DIRTY_FINGERPRINT` (empty-safe) and appends `-X main.DirtyFingerprint=...` to its existing `-ldflags` construction, falling back to empty when unset
- Observable: invoking `go_build` with the env var unset still produces a working binary whose injected `DirtyFingerprint` var reads empty (not a fabricated value)
- [x] 4.1 go_build injects the fingerprint via ldflags
- `go_build` reads `XCE_DIRTY_FINGERPRINT` (empty-safe) and appends `-X main.DirtyFingerprint=...` to the existing `-ldflags` construction; falls back to plain empty string (deliberately NOT `"unknown"`, unlike `GitCommit`/`BuildTime`), matching `dirty_fingerprint`'s convention everywhere else in this feature; the existing `GitCommit`/`BuildTime` `unknown`-fallback logic is completely untouched
- Observable confirmed live (independently re-verified by review, real scratch Go builds traced via `bash -x`): fingerprint unset -> `-X main.DirtyFingerprint=` empty, binary confirms empty (not fabricated); fingerprint set -> flag carries the exact value; all three vars unset -> `GitCommit`/`BuildTime` still fall back to `unknown`, `DirtyFingerprint` stays empty, the two fallback conventions coexist without interference
- _Requirements: 1.1, 5.1_
- _Boundary: go_build script_