From fd62e26bcef16442b84ba9fbcadc38c215cd8469 Mon Sep 17 00:00:00 2001 From: Rongsong Shen Date: Fri, 21 Aug 2026 05:42:11 +0000 Subject: [PATCH] feat(dirty-content-fingerprint): controller/scheduler show fingerprint in --version controller/main.c and scheduler/src/main.c now compose argp_program_version via a genuinely separate buffer/call to xce_compose_version_ex() (reading STR(VERSION_DIRTY_FINGERPRINT), matching the existing commit_id/build_time macro pattern). The startup-log composition call site -- same function, same arguments, same buffer -- is left completely unchanged in both files. controller/testsuite/test.c (xce_test, confirmed to have no startup log) gets a direct in-place swap. All three files carry explicit comments marking the --version/startup-log divergence as deliberate. Verified independently by review with real builds and live daemon starts: --version shows - for all three binaries, matching compile_commands.json; live startup logs for both daemons show the unchanged old -dirty format with the fingerprint never present. Co-Authored-By: Claude Sonnet 5 --- .../specs/dirty-content-fingerprint/tasks.md | 6 +++--- src/controller/main.c | 18 +++++++++++++++++- src/controller/testsuite/test.c | 14 +++++++++++--- src/scheduler/src/main.c | 19 ++++++++++++++++++- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/.kiro/specs/dirty-content-fingerprint/tasks.md b/.kiro/specs/dirty-content-fingerprint/tasks.md index ad3cc0f1..9c21b3e6 100644 --- a/.kiro/specs/dirty-content-fingerprint/tasks.md +++ b/.kiro/specs/dirty-content-fingerprint/tasks.md @@ -26,9 +26,9 @@ - _Requirements: 1.1, 1.2, 1.3, 1.4, 2.1, 3.1, 3.2, 5.2_ - _Boundary: utils.h, utils.c_ -- [ ] 3.2 (P) Controller and scheduler: fingerprint in --version, startup log unaffected - - `argp_program_version`'s composition call (controller/main.c, scheduler/main.c, controller/testsuite/test.c) passes the new `dirty_fingerprint` value; the startup INFO log line's own composition call is left unchanged, with a code comment marking the divergence as deliberate - - Observable confirmed live: on a dirty tree, `xce_controller --version`/`xce_test --version`/`xce_scheduler --version` show the fingerprint suffix; the startup log line for both daemons is byte-identical to the original `build-time-versioning` feature's already-shipped format (with or without the tree being dirty) +- [x] 3.2 (P) Controller and scheduler: fingerprint in --version, startup log unaffected + - `argp_program_version` for controller/scheduler now composed via a genuinely separate buffer/call to `xce_compose_version_ex()` (reading `STR(VERSION_DIRTY_FINGERPRINT)`, matching the existing commit_id/build_time macro pattern); the startup-log call site's `xce_compose_version()` call, arguments, and buffer are byte-for-byte unchanged (independently verified by review via diff + grep); `controller/testsuite/test.c` (no startup log, confirmed via grep) got a direct in-place swap; all three files carry explicit code comments marking the divergence as deliberate + - Observable confirmed live (independently re-verified by review, real builds + live daemon starts): `xce_controller --version`/`xce_test --version`/`xce_scheduler --version` all show `-`, cross-checked against `compile_commands.json`; live controller and scheduler startup logs show the old `-dirty` format unchanged, fingerprint never present, build_time matching `--version` exactly - _Requirements: 1.1, 1.2, 1.3, 1.4, 2.1, 3.1, 3.2, 4.1_ - _Boundary: controller/main.c, scheduler/main.c, controller/testsuite/test.c_ - _Depends: 3.1_ diff --git a/src/controller/main.c b/src/controller/main.c index b654cffd..82e4aec9 100644 --- a/src/controller/main.c +++ b/src/controller/main.c @@ -322,6 +322,13 @@ int main(int argc, char* argv[]) * it outlives this point in main() (contract documented on * xce_compose_version() in utils.c). */ static char version_buf[128]; + /* dirty-content-fingerprint task 3.2: SEPARATE buffer/composition, used + * ONLY for argp_program_version (--version/-V). version_buf above is + * left completely untouched -- its own xce_compose_version() call and + * the startup INFO log line reading it (below) are unaffected by this + * feature, per Requirement 3.2. This divergence (the two call sites now + * showing different strings) is deliberate, not an oversight. */ + static char version_display_buf[128]; /* Capture the NULL-terminated argv for self-restart BEFORE argp_parse so a * later demotion/rejoin convergence can execv() the same image (Req 1.3). */ @@ -331,7 +338,16 @@ int main(int argc, char* argv[]) * pointer when --version/-V is processed. */ xce_compose_version(version_buf, sizeof(version_buf), "xce v0.0.1-", STR(VERSION_COMMIT_ID), STR(VERSION_BUILD_TIME)); - argp_program_version = version_buf; + /* dirty-content-fingerprint task 3.2: --version-only composition -- + * appends the dirty_fingerprint suffix (if any) on top of the same + * commit/build_time inputs. Do NOT fold this into version_buf above; the + * startup INFO log must keep showing the original, fingerprint-less + * format (Req 3.2). */ + xce_compose_version_ex(version_display_buf, sizeof(version_display_buf), + "xce v0.0.1-", STR(VERSION_COMMIT_ID), + STR(VERSION_BUILD_TIME), + STR(VERSION_DIRTY_FINGERPRINT)); + argp_program_version = version_display_buf; memset(&arguments, 0x0, sizeof(arguments)); arguments.conf_keep_n = 2; diff --git a/src/controller/testsuite/test.c b/src/controller/testsuite/test.c index 4c55edfa..ee4f6d5a 100644 --- a/src/controller/testsuite/test.c +++ b/src/controller/testsuite/test.c @@ -4394,10 +4394,18 @@ int main(int argc, char* argv[]) memset(&arguments, 0x0, sizeof(arguments)); - /* Must run before argp_parse(): argp reads argp_program_version by + /* dirty-content-fingerprint task 3.2: xce_test is not a daemon -- it has + * no startup log line at all (see anatomy/build-time-versioning notes), + * so there is no second call site to keep divergent here (unlike + * controller/main.c and scheduler/src/main.c, which each keep a + * separate, untouched xce_compose_version() buffer for their startup + * INFO log per Req 3.2). version_buf can safely be composed directly + * via xce_compose_version_ex() to pick up the dirty_fingerprint suffix. + * Must run before argp_parse(): argp reads argp_program_version by * pointer when --version/-V is processed. */ - xce_compose_version(version_buf, sizeof(version_buf), "xce v0.0.1-", - STR(VERSION_COMMIT_ID), STR(VERSION_BUILD_TIME)); + xce_compose_version_ex(version_buf, sizeof(version_buf), "xce v0.0.1-", + STR(VERSION_COMMIT_ID), STR(VERSION_BUILD_TIME), + STR(VERSION_DIRTY_FINGERPRINT)); argp_program_version = version_buf; argp_parse(&argp, argc, argv, 0, 0, &arguments); diff --git a/src/scheduler/src/main.c b/src/scheduler/src/main.c index be2499ad..af677404 100644 --- a/src/scheduler/src/main.c +++ b/src/scheduler/src/main.c @@ -235,6 +235,14 @@ int main(int argc, char* argv[]) * it outlives this point in main() (contract documented on * xce_compose_version() in utils.c). */ static char version_buf[128]; + /* dirty-content-fingerprint task 3.2: SEPARATE buffer/composition, used + * ONLY for argp_program_version (--version/-V). version_buf above is + * left completely untouched -- its own xce_compose_version() call and + * the two mutually-exclusive startup INFO log lines reading it (below) + * are unaffected by this feature, per Requirement 3.2. This divergence + * (the two call sites now showing different strings) is deliberate, not + * an oversight. */ + static char version_display_buf[128]; memset(&arguments, 0x0, sizeof(arguments)); @@ -242,7 +250,16 @@ int main(int argc, char* argv[]) * pointer when --version/-V is processed. */ xce_compose_version(version_buf, sizeof(version_buf), "xce v0.0.0.1-", STR(VERSION_COMMIT_ID), STR(VERSION_BUILD_TIME)); - argp_program_version = version_buf; + /* dirty-content-fingerprint task 3.2: --version-only composition -- + * appends the dirty_fingerprint suffix (if any) on top of the same + * commit/build_time inputs. Do NOT fold this into version_buf above; the + * startup INFO log lines must keep showing the original, fingerprint- + * less format (Req 3.2). */ + xce_compose_version_ex(version_display_buf, sizeof(version_display_buf), + "xce v0.0.0.1-", STR(VERSION_COMMIT_ID), + STR(VERSION_BUILD_TIME), + STR(VERSION_DIRTY_FINGERPRINT)); + argp_program_version = version_display_buf; argp_parse(&argp, argc, argv, 0, 0, &arguments);