Repository navigation
fix(update): report the built runtime instead of the unbuilt source version - #143538
Conversation
…ersion A git checkout that pulls without rebuilding keeps executing the previous dist, and every surface an operator would check hid that. `openclaw --version` read the source package.json while the commit came from the build, so a machine running a 2026.8.1 build reported "2026.9.2 (1623683)" — a version that was never compiled. `openclaw status` reported HEAD with no hint that dist lagged. Prefer build-info.json for the version (source runs have none and still fall back to package.json), and report the built commit in the update row when it differs from HEAD. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014rTGeD4bUUEvA6vupgJt4d
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Pins the null results that keep source-only checkouts from being reported as running a stale build. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014rTGeD4bUUEvA6vupgJt4d
|
Codex review: blocked before merge. Reviewed September 10, 2026, 12:40 AM ET / 04:40 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR makes CLI version reporting prefer built runtime metadata and adds a status warning when a Git checkout’s build differs from its source commit. Merge readiness⛔ Blocked before merge - 2 items remain The fix remains necessary on current main, and the earlier launcher finding is resolved. No blocking code defect was found; the previously identified plugin upgrade validation remains outstanding. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw reads package and build metadata to identify the running CLI and evaluate plugin compatibility. Its update status also compares the checkout with upstream and reports build staleness to operators. flowchart TD
A[Package metadata] --> C[Runtime version resolution]
B[Built artifact metadata] --> C
C --> D[CLI version output]
C --> E[Plugin compatibility checks]
B --> F[Build and checkout comparison]
G[Git checkout commit] --> F
F --> H[Update status warning]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +21, Tests +129, Other +3. Total +153 across 9 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep runtime identity tied to build provenance, with upgrade proof showing accurate plugin rejection on stale builds and successful loading after rebuilding. Do we have a high-confidence way to reproduce the issue? Yes, from source: differing package and build versions make current main report the source version while the launcher commit comes from the build; no runtime reproduction was executed in this review. Is this the best way to solve the issue? Yes, preferring existing build provenance is a focused repair, and the launcher now follows the same rule; plugin upgrade coverage is still needed because VERSION also drives admission. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3ffdc1bfccd4. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
`openclaw.mjs` answers bare --version/-V/-v and exits before the runtime entry loads, so the resolver change alone left the packaged CLI reporting the source version. Its commit half already preferred dist provenance, which is how a stale build printed a source version paired with a built commit. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014rTGeD4bUUEvA6vupgJt4d
|
Addressed in [P2] launcher fast path — confirmed, and this was a real miss on my part, not a false positive. This also explains the original symptom precisely: the commit half already came from dist while the version half came from
With the fix: Separately, the PR body now records that this resolver is not display-only: |
|
The remaining review gap is plugin compatibility proof: |
…ersion (openclaw#143538) * fix(update): report the built runtime instead of the unbuilt source version A git checkout that pulls without rebuilding keeps executing the previous dist, and every surface an operator would check hid that. `openclaw --version` read the source package.json while the commit came from the build, so a machine running a 2026.8.1 build reported "2026.9.2 (6a473ab)" — a version that was never compiled. `openclaw status` reported HEAD with no hint that dist lagged. Prefer build-info.json for the version (source runs have none and still fall back to package.json), and report the built commit in the update row when it differs from HEAD. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014rTGeD4bUUEvA6vupgJt4d * test(update): cover built-commit provenance reads Pins the null results that keep source-only checkouts from being reported as running a stale build. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014rTGeD4bUUEvA6vupgJt4d * fix(update): apply built-version precedence to the launcher fast path `openclaw.mjs` answers bare --version/-V/-v and exits before the runtime entry loads, so the resolver change alone left the packaged CLI reporting the source version. Its commit half already preferred dist provenance, which is how a stale build printed a source version paired with a built commit. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014rTGeD4bUUEvA6vupgJt4d --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
What Problem This Solves
A git-mode install that pulls but never rebuilds keeps executing the previous
dist/. Every surface an operator would check to notice that reported the opposite.openclaw --versionresolved the version from the sourcepackage.jsonwhile the commit came from the build:Observed on a live install: the machine printed
OpenClaw 2026.9.2 (1623683)while actually running a build stamped{"version":"2026.8.1","commit":"1623683f…"}. The version half came from source, the commit half from the build, and2026.9.2had never been compiled.openclaw statusreportedgit main @ <HEAD>with no indication thatdist/was six days behind it.This is not a cosmetic mismatch. The repo already detects the exact condition —
collectGitRuntimeErrorscomparesbuild-info.commit,.buildstamp.headand.runtime-postbuildstamp.headagainst the expected SHA, andverifyGitUpdateRecoveryreturnsruntime-verification-failed— but only inside the update path. When an update aborts at its dirty-tree precondition it writes that verdict to a support file and stops; nothing tells the operator, and the version string then actively contradicts it. On the install that prompted this, that combination hid a stale runtime for six days until a plugin failed to load against a module its build predated.Why This Change Was Made
Two minimal changes, both reusing what already exists:
Version precedence.
build-info.jsonrecords the version the running artifact was actually built from, so it now wins. Both readers were already present and exported; only the||order changed. Source runs (tsx,pnpm dev) have no reachablebuild-info.jsonand still fall back topackage.json, and published packages shipdist/build-info.jsonalongside a matchingpackage.json, so neither case changes. No test pinned the old precedence — the existing one covers "falls back to build-info when package metadata is unavailable", which still holds.Launcher precedence. The package executable
openclaw.mjsanswers bare--version/-V/-vand exits before the runtime entry loads, so it never reaches the resolver above. ItsresolveLauncherVersion()readpackage.jsonfirst whileresolveLauncherCommit()already preferreddist/build-info.json— which is exactly how a stale build printed a source version paired with a built commit (OpenClaw 2026.9.2 (1623683)). Both halves now agree.Status visibility.
GitUpdateStatusalready carriedrootandsha, so detecting staleness needed only a built-commit read (readBuiltRuntimeCommit, added next to the existingreadBuiltGatewayBuildId) and a comparison.The status check deliberately compares the built commit to HEAD rather than reusing
collectGitRuntimeErrorswholesale. That helper also fails on a missingdist/entry.jsand on Control UI asset health, which would flag every developer running from source as "stale". Comparing commits reports only the real condition, and stays silent when no build exists.The version string is not only cosmetic
VERSIONis derived from this resolver and is stamped into persisted state and compared at two decision points, so the wrong value had consequences beyond display:src/state/openclaw-state-db-fast-path.ts:86returnsmetadata?.app_version === VERSIONto decide whether startup repairs can be skipped ("app_version commits only after this release's repairs; same-build writes are canonical"). Under the old precedence a dist built at2026.8.1, sitting in a checkout whosepackage.jsonread2026.9.2, reported2026.9.2— so against a database already stamped2026.9.2by a genuine build, the stale runtime matched and skipped startup repairs it had never run. Reporting the built version makes that comparison fail, which falls through to the full repair path; a false negative here only does more work.src/commands/doctor-gateway-health.ts:68compares the gateway version against the CLI'sVERSION; a stale CLI now correctly reports the mismatch instead of hiding it.src/infra/sqlite-user-version.ts:39builds the diagnostic identityOpenClaw ${VERSION} (${commit}). That is the exact string [Bug]: Schema-version error blames a downgrade that never happened; version string cannot identify the stale build #115008 reported as unable to identify the stale build; it is now truthful.Nothing gates a migration on the version string — the schema decisions key off
user_version— so no migration behavior changes.User Impact
openclaw --versionnow reports the version actually executing.openclaw statusgains astale build (running <commit>, run pnpm build)marker on the update row whendist/was built from a different commit than HEAD. Nothing changes for npm installs, source runs, or checkouts whose build is current. No config surface, no new files.Evidence
New tests:
reports the built version when dist lags the source package version— pins the real-world shape (source2026.9.2, build2026.8.1) and asserts the built version wins whilereadVersionFromPackageJsonForModuleUrlstill sees the source value.reports a stale build when dist was built from a different commitstays quiet when the built commit matches HEAD— guards against the false-positive mode described above.test/openclaw-launcher-version.e2e.test.tsgainsreports the built version when the source package version moved ahead, with deliberately differing package and build versions. Verified failing on pre-fix code:expected 'OpenClaw 1.2.3-test (1234567)' to be 'OpenClaw 2026.8.1 (1234567)'.src/infra/update-git-runtime.test.tscoversreadBuiltRuntimeCommit, pinning the null results (nodist/, provenance without a commit) that keep source-only checkouts from being reported stale.node scripts/check-changed.mjspasses every lane exceptplugin boundaries, which fails identically on a clean checkout ofmainwith zero changes (2026-09-08 sdk-untrusted-context-identifier-aliases, 6927 code refs) and is reported separately.Follow-up not taken here
openclaw doctorstill does not run the stale-runtime check at all; this PR only reachesstatusand--version. WiringcollectGitRuntimeErrorsinto a doctor check (with the source-run false positives handled) is the natural next step and is left for a separate change.🤖 Generated with Claude Code
https://claude.ai/code/session_014rTGeD4bUUEvA6vupgJt4d