Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: defer the boot build line rather than logging a permanent 'unknown' (#4694)

[._.]/ Adam Eivy300d3474690e
diff --git a/server/lib/buildIdentity.js b/server/lib/buildIdentity.js
index 6c284781dd..1c47f6eda3 100644
--- a/server/lib/buildIdentity.js
+++ b/server/lib/buildIdentity.js
@@ -43,8 +43,15 @@ const GIT_TIMEOUT_MS = 5000;
// git's own "there is no value here" spellings in the porcelain-v2 header:
// `(initial)` for a repo with no commits yet, `(detached)` for a detached HEAD.
-// Both must read as absent — a branch literally named "detached" is not what
-// git means here, and `(initial)` is not a commit.
+// Both read as absent.
+//
+// git permits a branch literally named `(detached)` and prints it in this header
+// byte-for-byte identically to a real detached HEAD, so the format itself cannot
+// separate the two and neither can any parser over it. Reading it as detached is
+// the right call anyway: the cost is one mislabeled branch in a display string,
+// and `commit` — the field the drift comparison actually uses — is unaffected.
+// (The mirror case does not exist on the client: git REFUSES to create a branch
+// named `HEAD`, so `rev-parse --abbrev-ref` printing `HEAD` is always detached.)
const NO_COMMIT = '(initial)';
const NO_BRANCH = '(detached)';
diff --git a/server/services/bootstrap.js b/server/services/bootstrap.js
index 9ae3b724d8..1a00222aa9 100644
--- a/server/services/bootstrap.js
+++ b/server/services/bootstrap.js
@@ -26,7 +26,7 @@ import { join } from 'path';
import { resolveInstallRoot } from '../lib/dataRoot.js';
import { PORTS } from '../lib/ports.js';
import { getSelfHost } from '../lib/peerSelfHost.js';
-import { getCachedBuildIdentity, formatBuildIdentity } from '../lib/buildIdentity.js';
+import { getBuildIdentity, getCachedBuildIdentity, formatBuildIdentity } from '../lib/buildIdentity.js';
import { setupProcessErrorHandlers, asyncHandler, ServerError, errorEvents } from '../lib/errorHandler.js';
import { ERROR_CATEGORIES } from '../lib/aiToolkit/errorDetection.js';
import { createAIToolkit } from '../lib/aiToolkit/index.js';
@@ -632,8 +632,21 @@ const announceListening = ({ io, httpServer, localHttpServer, httpsEnabled, port
// lands at a DETERMINISTIC position in the banner instead of racing it.
// Read synchronously from the cache primed at boot: this function's caller
// does not await it, so an await here would let the lines below print around
- // the yield and scramble the banner.
- console.log(` 🧬 build ${formatBuildIdentity(getCachedBuildIdentity())}`);
+ // the yield and scramble the banner. In the normal case boot (migrations, DB)
+ // far outlasts one git call, so the value is ready and lands in place.
+ //
+ // If it is NOT ready — a git wedged on a locked index or a slow network mount
+ // — defer rather than printing `unknown`, which would be a permanent lie: the
+ // probe resolves moments later and every other consumer reports it correctly.
+ // Losing banner adjacency beats logging a wrong answer that never updates.
+ const identity = getCachedBuildIdentity();
+ if (identity) {
+ console.log(` 🧬 build ${formatBuildIdentity(identity)}`);
+ } else {
+ getBuildIdentity()
+ .then((late) => console.log(` 🧬 build ${formatBuildIdentity(late)} (probed late)`))
+ .catch((err) => console.error(`❌ Build identity probe failed: ${err.message}`));
+ }
if (!httpsEnabled) {
console.log(` 🌐 http://localhost:${port}`);
console.log(`⚠️ HTTP only — getUserMedia (mic) won't work over Tailscale IP. Run "npm run setup:cert" to enable HTTPS.`);