feat(dirty-content-fingerprint): worker shows fingerprint in --version

Worker's hand-rolled OPT_VERSION case now composes via a genuinely
separate version_display_buf/xce_compose_version_ex() call, mirroring
task 3.2's already-approved controller/scheduler pattern exactly. Both
startup-log XCECD_LOG call sites (--peers and no-peers) are left
completely untouched, same xce_compose_version() call, same version_buf.

Verified independently by review with a real build and live daemon runs
in both branches: --version shows <commit>-<fingerprint> matching
compile_commands.json, -dirty correctly stripped not doubled; both
startup log branches show the old fingerprint-less format unchanged.

All three C daemons (controller, scheduler, worker) are now complete.

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

View file

@ -323,6 +323,16 @@ int main(int argc, char* argv[])
* read this SAME buffer, never recomputing it independently, so the
* two can never disagree (Requirement 2.2). */
static char version_buf[128];
/* dirty-content-fingerprint task 3.3: SEPARATE buffer/composition, used
* ONLY for the --version case below. version_buf above is left
* completely untouched -- its own xce_compose_version() call and the
* two mutually-exclusive startup INFO log lines reading it (further
* down) are unaffected by this feature, per Requirement 3.2. This
* divergence (the two call sites now showing different strings) is
* deliberate, not an oversight -- mirrors controller/main.c's and
* scheduler/src/main.c's identical version_display_buf pattern
* (dirty-content-fingerprint task 3.2). */
static char version_display_buf[128];
xce_cluster_config_t cluster_cfg = {0};
int use_ha = 0; /* 1 when --peers given */
@ -378,6 +388,15 @@ int main(int argc, char* argv[])
* ready by the time the startup INFO log lines run later in main(). */
xce_compose_version(version_buf, sizeof(version_buf), "xce v0.0.1-",
STR(VERSION_COMMIT_ID), STR(VERSION_BUILD_TIME));
/* dirty-content-fingerprint task 3.3: --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.1-", STR(VERSION_COMMIT_ID),
STR(VERSION_BUILD_TIME),
STR(VERSION_DIRTY_FINGERPRINT));
while ((opt = getopt_long(argc, argv, "n:l:vh", long_opts, NULL))
!= -1) {
@ -402,8 +421,11 @@ int main(int argc, char* argv[])
case OPT_VERSION:
/* Prints and exits before any other startup work (peer
* parsing, check_user(), daemon init, etc.) -- same contract
* as controller/scheduler's --version. */
printf("%s\n", version_buf);
* as controller/scheduler's --version. dirty-content-fingerprint
* task 3.3: prints version_display_buf (fingerprint-aware), not
* version_buf -- the startup INFO log lines further down keep
* reading the original version_buf, untouched. */
printf("%s\n", version_display_buf);
return 0;
case 'h':
default: