Skip to content

fix(update): report the built runtime instead of the unbuilt source version - #143538

Merged
RomneyDa merged 3 commits into
mainfrom
fix/stale-build-visibility
Sep 10, 2026
Merged

RomneyDa merged 3 commits into
mainfrom
fix/stale-build-visibility

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

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 --version resolved the version from the source package.json while the commit came from the build:

resolveVersionFromModuleUrl = readVersionFromPackageJson(...) || readVersionFromBuildInfo(...)

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, and 2026.9.2 had never been compiled. openclaw status reported git main @ <HEAD> with no indication that dist/ was six days behind it.

This is not a cosmetic mismatch. The repo already detects the exact condition — collectGitRuntimeErrors compares build-info.commit, .buildstamp.head and .runtime-postbuildstamp.head against the expected SHA, and verifyGitUpdateRecovery returns runtime-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.json records 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 reachable build-info.json and still fall back to package.json, and published packages ship dist/build-info.json alongside a matching package.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.mjs answers bare --version/-V/-v and exits before the runtime entry loads, so it never reaches the resolver above. Its resolveLauncherVersion() read package.json first while resolveLauncherCommit() already preferred dist/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. GitUpdateStatus already carried root and sha, so detecting staleness needed only a built-commit read (readBuiltRuntimeCommit, added next to the existing readBuiltGatewayBuildId) and a comparison.

The status check deliberately compares the built commit to HEAD rather than reusing collectGitRuntimeErrors wholesale. That helper also fails on a missing dist/entry.js and 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

VERSION is 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:86 returns metadata?.app_version === VERSION to 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 at 2026.8.1, sitting in a checkout whose package.json read 2026.9.2, reported 2026.9.2 — so against a database already stamped 2026.9.2 by 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:68 compares the gateway version against the CLI's VERSION; a stale CLI now correctly reports the mismatch instead of hiding it.
  • src/infra/sqlite-user-version.ts:39 builds the diagnostic identity OpenClaw ${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 --version now reports the version actually executing. openclaw status gains a stale build (running <commit>, run pnpm build) marker on the update row when dist/ 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

node scripts/run-vitest.mjs src/version.test.ts                  Tests  17 passed (17)
node scripts/run-vitest.mjs src/commands/status.update.test.ts   Tests  17 passed (17)
node scripts/run-vitest.mjs src/commands/status.update-channel.test.ts \
  src/commands/status.update-ledger.test.ts src/infra/update-check.test.ts
                                                                 Tests  30 passed (30)
pnpm tsgo                                                        exit 0

New tests:

  • reports the built version when dist lags the source package version — pins the real-world shape (source 2026.9.2, build 2026.8.1) and asserts the built version wins while readVersionFromPackageJsonForModuleUrl still sees the source value.
  • reports a stale build when dist was built from a different commit
  • stays quiet when the built commit matches HEAD — guards against the false-positive mode described above.
  • test/openclaw-launcher-version.e2e.test.ts gains reports 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.ts covers readBuiltRuntimeCommit, pinning the null results (no dist/, provenance without a commit) that keep source-only checkouts from being reported stale.

node scripts/check-changed.mjs passes every lane except plugin boundaries, which fails identically on a clean checkout of main with zero changes (2026-09-08 sdk-untrusted-context-identifier-aliases, 6927 code refs) and is reported separately.

Follow-up not taken here

openclaw doctor still does not run the stale-runtime check at all; this PR only reaches status and --version. Wiring collectGitRuntimeErrors into 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

…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
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@RomneyDa
RomneyDa marked this pull request as ready for review September 10, 2026 00:04
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S maintainer Maintainer-authored PR labels Sep 10, 2026
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
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 10, 2026, 12:40 AM ET / 04:40 UTC (Revision 3).

ClawSweeper review

What this changes

The 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
Reviewed head: 853d0c0258d2de21333de416d98307e2fba99d01

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with useful regression coverage and no identified code defect, pending targeted plugin upgrade validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate; inspected evidence covers launcher and resolver fixtures, while plugin rebuild recovery remains a separate upgrade-validation gap.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate; inspected evidence covers launcher and resolver fixtures, while plugin rebuild recovery remains a separate upgrade-validation gap.
Evidence reviewed 9 items Current main still needs the fix: The fetched main revision still resolves package metadata before build metadata; its status formatter has no builtSha warning.
Latest release retains source-first precedence: The supplied latest-release revision, v2026.9.3, also resolves package.json before build-info.json.
Earlier launcher finding resolved: The change since the earlier reviewed head reverses the launcher's metadata precedence. The added launcher regression exercises differing source and build versions; the author reports its intended pre-fix failure and subsequent passing result.
Findings None None.
Security None None.

How this fits together

OpenClaw 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]
Loading

Before merge

  • Resolve merge risk (P1) - On a Git installation with newer source metadata than its built runtime, external plugins previously admitted using the source version can now be skipped. The submitted validation does not demonstrate plugin admission before and after rebuilding or unchanged behavior for a matched fresh installation.
  • Complete next step (P2) - Validate plugin admission for matched source/build metadata and a stale build, then show successful loading after rebuilding; document any intentional plugin rejection.
Agent review details

Security

None.

PR surface

Source +21, Tests +129, Other +3. Total +153 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 23 2 +21
Tests 4 130 1 +129
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 8 5 +3
Total 9 161 8 +153

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Validate plugin admission through rebuild recovery (recommended)
    Demonstrate unchanged admission with matched metadata, rejection when the actual build is below a plugin's declared floor, and successful loading after rebuilding.
  2. Explicitly accept the admission change
    An area owner can accept that previously admitted external plugins may stop loading on stale builds and record the operator recovery guidance.

Technical review

Best 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.

Labels

Label justifications:

  • P2: This repairs misleading runtime diagnostics for Git installations with stale builds.
  • merge-risk: 🚨 compatibility: Changing the effective host version can cause existing external plugins to be skipped until the runtime is rebuilt.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate; inspected evidence covers launcher and resolver fixtures, while plugin rebuild recovery remains a separate upgrade-validation gap.

Evidence

What I checked:

  • Current main still needs the fix: The fetched main revision still resolves package metadata before build metadata; its status formatter has no builtSha warning. (src/version.ts:93, 3ffdc1bfccd4)
  • Latest release retains source-first precedence: The supplied latest-release revision, v2026.9.3, also resolves package.json before build-info.json. (src/version.ts:93, 1391f7cd2d40)
  • Earlier launcher finding resolved: The change since the earlier reviewed head reverses the launcher's metadata precedence. The added launcher regression exercises differing source and build versions; the author reports its intended pre-fix failure and subsequent passing result. (openclaw.mjs:619, 853d0c0258d2)
  • Existing plugin compatibility contract: The compatibility resolver uses runtime VERSION unless explicitly overridden. Manifest loading skips non-bundled plugins whose minimum host version exceeds it, and discovery also checks plugin API ranges. Thus correcting VERSION can change which previously admitted plugins load. (src/plugins/manifest-registry.ts:1035, 853d0c0258d2)
  • Documented admission behavior: The plugin manifest documentation explicitly defines older-host rejection for non-bundled plugins and treats bundled source plugins as co-versioned. Accurate runtime identity supports this existing contract rather than introducing a new plugin API. Public docs: docs/plugins/manifest/package-json.md. (docs/plugins/manifest/package-json.md:59, 853d0c0258d2)
  • State checks remain independently guarded: The startup fast path checks supported schema version, integrity, schema shape, and pending repairs before comparing app_version with VERSION. This patch changes identity input but introduces no schema or migration definition. (src/state/openclaw-state-db-fast-path.ts:61, 853d0c0258d2)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Validate matched-install plugin admission, stale-build rejection, and successful loading after rebuilding.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-10T01:56:57.006Z sha ae6d009 :: needs changes before merge. :: [P2] Apply built-version precedence to the launcher fast path
  • reviewed 2026-09-10T04:18:00.037Z sha 853d0c0 :: blocked before merge. :: none

`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
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 10, 2026
@RomneyDa

Copy link
Copy Markdown
Member Author

Addressed in 853d0c0258.

[P2] launcher fast path — confirmed, and this was a real miss on my part, not a false positive. openclaw.mjs answers bare --version/-V/-v and exits before the runtime entry loads, so changing src/version.ts alone left the packaged CLI still reporting the source version. resolveLauncherVersion() now prefers dist/build-info.json, matching resolveLauncherCommit(), which already did.

This also explains the original symptom precisely: the commit half already came from dist while the version half came from package.json, which is how the reporting install printed OpenClaw 2026.9.2 (1623683) — a source version paired with a build stamped 2026.8.1. The two halves disagreed by construction.

test/openclaw-launcher-version.e2e.test.ts gains reports the built version when the source package version moved ahead with deliberately differing package and build versions. Verified it fails on pre-fix code for the intended reason:

AssertionError: expected 'OpenClaw 1.2.3-test (1234567)' to be 'OpenClaw 2026.8.1 (1234567)'
Tests  1 failed | 14 skipped (15)

With the fix: Test Files 1 passed (1), Tests 15 passed (15). pnpm tsgo exits 0.

Separately, the PR body now records that this resolver is not display-only: VERSION feeds openclaw-state-db-fast-path.ts:86, where a stale build previously matched schema_meta.app_version and skipped startup repairs it had never run.

@steipete

Copy link
Copy Markdown
Contributor

The remaining review gap is plugin compatibility proof: VERSION also drives external-plugin admission, so preferring built metadata can change which plugins load on a stale checkout. Please link a hosted CI run and identify the tests demonstrating (1) admission with matched source/build metadata, (2) rejection when the actual stale build is below the plugin's declared host/API floor, and (3) successful admission after rebuilding to a compatible version. The current launcher/resolver/status tests do not demonstrate that admission-and-recovery sequence.

@RomneyDa
RomneyDa merged commit df9cb08 into main Sep 10, 2026
317 of 319 checks passed
@RomneyDa
RomneyDa deleted the fix/stale-build-visibility branch September 10, 2026 23:06
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants