Skip to content

fix: running Gateway can report a checkout commit it never loaded - #132854

Merged
obviyus merged 2 commits into
openclaw:mainfrom
PollyBot13:fix/runtime-loaded-build-identity-20260829
Aug 30, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
PollyBot13:fix/runtime-loaded-build-identity-20260829

Conversation

@PollyBot13

@PollyBot13 PollyBot13 commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A built OpenClaw process could report the current source-checkout commit instead of the commit that produced its loaded code. If the checkout moved while the Gateway kept running, status output and SQLite refusal diagnostics changed identity. Update restart validation could also reject the correct running build.

Root cause

The three runtime diagnostics called the mutable Git resolver when they rendered or finalized. OpenClaw already records loaded build provenance, but no process-lifetime commit owner consumed its three real forms:

  • matching local build stamps for incremental source builds;
  • build-info.json for packaged or source-archive builds;
  • Git only for true source execution without build metadata.

Fix

src/version.ts now snapshots the loaded commit once beside the existing loaded build ID. Status, SQLite diagnostics, and restart finalization use that owner. Incomplete or conflicting loaded metadata returns an unknown commit instead of guessing from a mutable checkout. Workspace and trajectory provenance keep the live Git resolver.

The repair preserves the current SqliteSchemaVersionError contract and updates the database troubleshooting guide.

Evidence

Current-main red at 49a8b1cb2138b5545465d10f866962157bb49529:

  1. Built and started the real Gateway.
  2. Moved the source checkout to 357078cf7087534443dac92eb86e8aa32abb7b08 without rebuilding or restarting.
  3. Status and SQLite diagnostics incorrectly reported 357078c.
  4. Restart finalization changed ok to restart-revision-mismatch.

Exact-head green at 256d643ae63b17bc31ad967acefbdd28a8060fb8:

  1. Built and started the real Gateway from the repaired head.
  2. Moved the source checkout to c9476275b86cd7b037ac9a33d762d0c6032b5d2f without rebuilding or restarting.
  3. CLI version, status, and SQLite diagnostics kept reporting loaded head 256d643.
  4. The live Gateway status RPC stayed healthy.
  5. Restart finalization stayed ok with no mismatch reason.

The changed checkout commit is the anti-cache probe: it differs from the loaded build while every diagnostic remains bound to the build metadata.

Sanitized terminal evidence

current-main red
builtCommit=49a8b1cb2138b5545465d10f866962157bb49529
checkoutCommitAfterStart=357078cf7087534443dac92eb86e8aa32abb7b08
statusTitle="OpenClaw 2026.8.1 (357078c)"
sqliteDescriptionCommit=357078c
restartStatus=error
restartReason=restart-revision-mismatch

exact-head green
builtCommit=256d643ae63b17bc31ad967acefbdd28a8060fb8
checkoutCommitAfterStart=c9476275b86cd7b037ac9a33d762d0c6032b5d2f
cliVersion="OpenClaw 2026.8.1 (256d643)"
gatewayStatusRpc=ok
gatewayRuntimeVersion=2026.8.1
statusTitle="OpenClaw 2026.8.1 (256d643)"
sqliteDescriptionCommit=256d643
restartStatus=ok
restartReason=null

Validation

  • 362 focused tests passed across the runtime owner, three consumers, and two sibling suites.
  • The new owner regression failed on current main because no process-bound commit owner existed.
  • Exact-main and exact-head production builds passed.
  • Focused Oxlint, Oxfmt, docs checks, import-cycle checks, and changed-scope repository ratchets passed.
  • Production: +69/-30, net +39. The added lines encode the closed loaded-artifact modes; three consumer-side Git lookups were removed. The contributor candidate was net +70 production lines.
  • Tests: +167/-5, net +162.
  • No configuration, protocol, or database schema changed.

AI-assisted: yes (Codex).

@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 4:30 AM ET / 08:30 UTC.

ClawSweeper review

What this changes

The PR snapshots the commit that produced the loaded Gateway artifact and uses it in status output, schema diagnostics, and update-restart validation instead of reading a checkout that may have moved.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/infra/sqlite-user-version.ts. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open for normal maintainer review: the inspected introduced code centralizes the correct process-bound build identity and routes all three stated runtime consumers through it, with no concrete patch defect found. A current-main source comparison could not complete because this partial checkout could not retrieve the fetched-main tree.

Priority: P2
Reviewed head: 256d643ae63b17bc31ad967acefbdd28a8060fb8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The implementation is a focused owner-boundary repair with credible real-Gateway before/after evidence; current-main source retrieval remains a reviewer-side comparison gap.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed owner is the process-bound artifact commit captured in src/version.ts; the PR's sanitized exact-head terminal trace exercises a real Gateway built from that head, moves the checkout without restart, and observes the repaired status, SQLite diagnostic, and restart-finalization outcomes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed owner is the process-bound artifact commit captured in src/version.ts; the PR's sanitized exact-head terminal trace exercises a real Gateway built from that head, moves the checkout without restart, and observes the repaired status, SQLite diagnostic, and restart-finalization outcomes.
Evidence reviewed 7 items Canonical runtime identity owner: The introduced resolver accepts matching local build stamps, falls back to packaged build information when stamps are absent, and otherwise retains the existing Git resolver only for true source execution; version.ts captures that result once per process.
All stated consumers use the owner: Status reads the process-bound commit, the schema diagnostic names it, and Gateway startup refreshes the restart sentinel through the updated finalizer.
Artifact-metadata contract: Local build and postbuild scripts each write their commit head into dist metadata, matching the two stamps the introduced resolver requires to agree.
Findings None None.
Security None None.

How this fits together

Gateway status, schema-refusal messages, and restart validation all identify the running build for operators. Build stamps and packaged build information feed a process-bound identity so a later checkout update cannot change those running-service outputs.

flowchart LR
A[Built Gateway artifact] --> B[Build stamps or build info]
B --> C[Process-bound build identity]
C --> D[Gateway status]
C --> E[Schema diagnostic]
C --> F[Restart validation]
G[Current checkout revision] --> H[Workspace provenance]
Loading

Before merge

  • Resolve merge risk (P1) - The partial checkout could not retrieve current-main source at 43d2590, so an intervening competing implementation could not be independently ruled out here.
  • Resolve merge risk (P1) - Production code is +69/-30 (net +39); the added closed metadata modes are justified by the new canonical ownership boundary, but they should remain the only artifact-identity resolution path.
Agent review details

Security

None.

PR surface

Source +39, Tests +162, Docs 0, Other 0. Total +201 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 5 69 30 +39
Tests 7 167 5 +162
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 14 238 37 +201

Review metrics

Metric Value Why it matters
Production versus test delta production +69/-30 (net +39); tests +167/-5 (net +162) The production increase consolidates three diagnostic consumers behind a single artifact-provenance owner; the test growth covers the metadata modes and each consumer.

Stored data model

Persistent data-model change detected: serialized state: src/infra/git-commit.ts, unknown-data-model-change: src/infra/git-commit.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one process-bound loaded-artifact identity resolver beside the existing build ID, use it for running-service diagnostics and restart checks, and retain live Git lookup only for explicitly workspace-scoped provenance.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one process-bound loaded-artifact identity resolver beside the existing build ID, use it for running-service diagnostics and restart checks, and retain live Git lookup only for explicitly workspace-scoped provenance.

Do we have a high-confidence way to reproduce the issue?

Yes. The supplied real-Gateway trace gives a concrete build, start, checkout-move, status, schema-diagnostic, and restart-finalization sequence; source inspection independently identifies the former live-Git reads. I did not re-execute contributor code in this read-only review.

Is this the best way to solve the issue?

Yes. A single process-lifetime artifact identity owner is the narrowest maintainable repair: it replaces exactly the three running-service reads while trajectory metadata retains the deliberately live workspace resolver.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 43d259069c83.

Labels

Label justifications:

  • P2: This fixes bounded but misleading Gateway diagnostic and update-validation behavior without a demonstrated message, session, security, or availability outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed owner is the process-bound artifact commit captured in src/version.ts; the PR's sanitized exact-head terminal trace exercises a real Gateway built from that head, moves the checkout without restart, and observes the repaired status, SQLite diagnostic, and restart-finalization outcomes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed owner is the process-bound artifact commit captured in src/version.ts; the PR's sanitized exact-head terminal trace exercises a real Gateway built from that head, moves the checkout without restart, and observes the repaired status, SQLite diagnostic, and restart-finalization outcomes.

Evidence

What I checked:

  • Canonical runtime identity owner: The introduced resolver accepts matching local build stamps, falls back to packaged build information when stamps are absent, and otherwise retains the existing Git resolver only for true source execution; version.ts captures that result once per process. (src/infra/git-commit.ts:222, dbd794c10aaf)
  • All stated consumers use the owner: Status reads the process-bound commit, the schema diagnostic names it, and Gateway startup refreshes the restart sentinel through the updated finalizer. (src/status/status-message.ts:1003, 256d643ae63b)
  • Artifact-metadata contract: Local build and postbuild scripts each write their commit head into dist metadata, matching the two stamps the introduced resolver requires to agree. (scripts/lib/local-build-metadata.mts:44, 256d643ae63b)
  • Focused regression coverage: Tests cover matching and conflicting stamps, build-info fallback, source-only Git fallback, process-lifetime capture, and each redirected consumer's displayed or restart result. (src/infra/git-commit.test.ts:136, dbd794c10aaf)
  • Real behavior proof: The PR body records a sanitized exact-head Gateway run that moved the checkout without rebuilding or restarting; status, SQLite diagnostics, and restart finalization remained bound to the loaded head while the status RPC stayed healthy. (256d643ae63b)
  • Prior diagnostic context: The existing schema diagnostic originated in the earlier repair that deliberately named the refusing install and documented the linked-checkout ambiguity; this PR refines that same operator-facing boundary. (src/infra/sqlite-user-version.ts, 40fb1ca27e4e)

Likely related people:

  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (6 earlier review cycles)
  • reviewed 2026-08-29T21:29:09.591Z sha 58c5242c97f4130ba2ae1693380af9dc93798a36 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-29T23:41:48.560Z sha f4504151e88e80ab9d439e46dcc5f9903582d951 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T23:49:04.204Z sha 06bca06af95fc3a401284bb9f533f0ceee575d29 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T07:23:37.669Z sha 9331922811c170cd4395e9db585953dbc16554ab :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T07:50:31.238Z sha 1b4b2c67ef21fe094c7c76628e1952fb72c643f2 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T08:17:30.992Z sha 256d643 :: needs maintainer review before merge. :: none

@PollyBot13
PollyBot13 force-pushed the fix/runtime-loaded-build-identity-20260829 branch from 58c5242 to f450415 Compare August 29, 2026 23:34
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 29, 2026
@obviyus
obviyus force-pushed the fix/runtime-loaded-build-identity-20260829 branch from 06bca06 to 9331922 Compare August 30, 2026 07:16
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 30, 2026
@obviyus
obviyus force-pushed the fix/runtime-loaded-build-identity-20260829 branch from 9331922 to 1b4b2c6 Compare August 30, 2026 07:43
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 30, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 30, 2026
@obviyus
obviyus force-pushed the fix/runtime-loaded-build-identity-20260829 branch from 1b4b2c6 to dbd794c Compare August 30, 2026 08:01
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Aug 30, 2026
@obviyus
obviyus merged commit f2cc4f1 into openclaw:main Aug 30, 2026
269 checks passed
@obviyus

obviyus commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks @PollyBot13!

Proof: A built Gateway stayed running while its source checkout moved to another commit. CLI and Gateway status remained healthy, status and SQLite diagnostics kept the loaded commit, and restart validation stayed successful.

  • Bug: Runtime diagnostics could switch to the checkout's new Git commit even though the Gateway still ran an older build.
  • Fix: One process-lifetime owner now resolves matching local build stamps, packaged build info, or true source Git and serves all three Gateway diagnostics.

Example

Before After
Status reported the moved checkout; restart validation failed with a revision mismatch. Status reports the loaded build; restart validation remains successful.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
Bind Gateway diagnostics to one process-lifetime loaded-build commit.

Status output, SQLite schema-refusal errors, and restart validation now keep reporting the artifact that the Gateway loaded after its source checkout moves. Conflicting build metadata fails closed instead of guessing from live Git state.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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