Skip to content

fix(update): avoid stale chunks after same-commit Git rebuilds - #157350

Merged
steipete merged 3 commits into
mainfrom
upd/git-post-update-verification-stale-chunk
Sep 24, 2026
Merged

steipete merged 3 commits into
mainfrom
upd/git-post-update-verification-stale-chunk

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Git updates loading removed runtime chunks after rebuilding a checkout whose commit and version remain unchanged.

Fixes #157012. Thanks @MikyWang for the report and both failure traces.

User Impact

Successful Git activation uses fresh-process convergence. Activation captures the built commit and dist digest; shared convergence compares that fact once, including in migrated candidate workers. A mismatch is a recorded verification failure. The existing finalizer retains the prior source/runtime through verification and restores the previous Gateway when its state/config/service safety checks permit rollback. Incompatible state changes or independent source edits retain backups and explain why automatic restoration was refused.

The published 2026.9.5 driver still owns its first hop. Candidate code cannot replace that already-running parent's routing decision or recover backups it discarded. That hop may require the documented manual source update, stopping the Gateway through its actual service manager before rebuilding. Subsequent updates use the repaired driver.

Why This Change Was Made

An already-ahead checkout differs from upstream, so preflight builds it. Rebasing onto the existing ancestor can leave SHA and version unchanged. Activation replaces dist, but the old selector treated matching source metadata as an unchanged runtime. The retained config factory then imported a removed content-hashed writer. The local-commit relationship is the trigger; the three commits' specific contents are unnecessary. The reporter's historical commit identities were not supplied, so the rig reproduces this execution class with synthetic commits.

Scope stays with the existing routing, runtime inventory, and finalizer owners. There is no new recovery path, configuration, CLI option, dependency, or SQLite schema change. This branch was rebased once onto d21bef382a187c6959efc55407c0a446505250e1; #156996 remained unmerged then. Its verified-artifact preflight and managed-stop protections complement this repair.

Production is +228/−144, net +84 lines. Tests/support are +481/−82; docs +6/−0.

Existing owner Net production LOC Hunk justification
Post-core dispatch −9 Select the fresh process for successful Git activation and run it in the activated root.
Git runtime metadata +18 Produce commit/digest using the existing dist content inventory.
Convergence +27 Record one comparison at shared completion, covering fresh children and migrated workers. Preserve prior result facts on failure.
Git runner +26 Retain rollback through existing finalization; share/compact restoration and its source-edit guard. Verify restoration against the prior built commit, which can differ from an already-ahead source HEAD.
Runtime promotion +14 Carry finalizer authority into filesystem effects, expose the retained backup, and join cleanup before reporting its outcome.
Runner contracts +5 Carry the fact and existing transaction callback.
Git CLI orchestration +1 Pass the existing finalizer callback to the Git runner.
Step identity +2 Name verification and retained-backup outcomes.

Evidence

Linux systemd user-service rig: Testbox run 35999950005, lease tbx_01m39pjmrkksh2hwgnd9h23466. Both fixtures had exactly three local commits over unchanged upstream. Each update preserved its source SHA and version while replacing runtime chunks.

Installed-driver flow Unpatched baseline Repaired driver
Runtime build Exit 0, 77.124s Exit 0, 86.082s
openclaw update --yes --channel dev --json Exit 1, 256.113s Exit 0, 246.330s
Outcome post-update-failed ok
Managed Gateway PID 9015 → PID 0, inactive/dead PID 14909 → PID 19170, active/running
Independent health Recovery failed rpcOk: true; serving build matched activation

The baseline passed rebase, candidate build, staging, checkout, activation Doctor, and head verification before failing with:

Cannot find module '.../dist/io.write-BHU9bdth.mjs'
imported from '.../dist/io.factory-BZbRmo8A.mjs'
recovery: serviceRestartSafe=false, reason=runtime-verification-failed

The repaired driver recorded commit 5f5793f574d864a5c8a5d32318a4e60380c36c7d and digest cca97c95201bc0a7c708ff276adab16fddb0162f67dae64fb44b7d654f680e5d. Temporary-path service-definition advisories were separate from the reproduced failure. Both owned services/managers and the lease were stopped and independently verified completed.

This is live proof of the driver at the branch base versus the repair, not a published-2026.9.5-driver cell. It preceded the final relocation of the same comparison to shared convergence; the final focused/dependent proof covers that placement and the migrated worker.

Final code proof on lease tbx_01m39tnwqsdn599fkq7mf4nmkk, run 36007992647:

  • Four focused suites passed 3×, 166 tests per pass. Old-selector, disabled-comparison, and candidate-worker negative controls failed for the intended reasons.
  • Full dependency sweep passed 87 files / 2,557 tests / all 10 configurations in 852.018s: original 86-file argument order plus migrated-worker coverage. No later configuration was skipped.
  • Final check:changed: passed in 2393.713s, including all 25 test-type graphs, lint and every guard; run 36006462431, lease tbx_01m39sxyn33d6g8n23884nad59. Final documentation check: passed in 17.088s; all final code/test hashes remained unchanged.
  • Fresh autoreview --mode branch --base origin/main: scoped-clean, no actionable P0/P1 findings on the committed branch.

Measured pnpm test <file> --maxWorkers=1 costs:

Suite Cases Test time Wall
Convergence authority 26 0.694s 21.338s
Post-core 30 1.480s 26.817s
Git candidate 57 19.317s 38.324s
Post-update recovery 53 10.310s 86.055s

Recovery wall includes cold runtime preparation; the longest focused case was 1.898s. The full sweep's existing monolith took 248.556s of test time and lease suite 151.611s; maximum individual case was 13.689s. The coordinator waived the slow-test gate for this lane (#157018 owns the monolith split); no test was weakened or moved to another tier. Hosted CI duration is not yet available.

Validation repairs retained assertions: fixtures now materialize real build metadata/facts and truthful activation/current-core states. All six lifecycle cases remain, with actual resume production and exactly-one-handoff assertions; one-shot mock queues are reset between cases. The CLI monolith shrinks by one line. A mixed-E2E proof invocation initially skipped needed compiled workers; the final sequence uses native focused recovery preparation and verifies those artifacts before the mixed sweep. No unchanged rollback assertions or production code were altered for that harness error.

@clawsweeper

clawsweeper Bot commented Sep 24, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: L labels Sep 24, 2026
@steipete
steipete marked this pull request as ready for review September 24, 2026 15:08
@steipete
steipete enabled auto-merge (squash) September 24, 2026 15:17
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 5:54 PM ET / 21:54 UTC (Revision 4).

ClawSweeper review

What this changes

The PR makes Git updates verify rebuilt runtime files in a fresh process, retains the previous checkout and runtime for final recovery, and updates updater tests and documentation.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open. Current main still selects the old process for same-commit Git rebuilds, but this PR can discard the previous runtime if its new post-activation identity read fails. The required published-driver upgrade observation is also outstanding.

Priority: P0
Reviewed head: b167f61ba34f67be45f5c711dfd8a94c724a01e0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The repair has useful live and focused evidence, but a concrete recovery-backup defect and an unproven published-driver first hop prevent merge readiness.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The maintainer-author proof gate does not apply. An earlier Linux systemd run exercises the Git update entry point and shows after-fix Gateway recovery, while final shared-convergence placement has focused tests; the repository-required published 2026.9.5 driver × final-candidate cell remains unrecorded. No stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-author proof gate does not apply. An earlier Linux systemd run exercises the Git update entry point and shows after-fix Gateway recovery, while final shared-convergence placement has focused tests; the repository-required published 2026.9.5 driver × final-candidate cell remains unrecorded. No stored-data contract changes.
Evidence reviewed 11 items Current main retains the defect: The fetched main selector starts a fresh post-core process for Git only when the source SHA or version changes; a same-commit rebuild satisfies neither condition.
Introduced fresh-process selection: The PR changes successful Git activation to select fresh-process post-core verification even when SHA and version remain unchanged.
Backup custody begins after a fallible read: After activation and Doctor, the new full-dist identity read runs at line 540. Transaction registration and runtimeRetained assignment follow at lines 560–609.
Findings 1 actionable finding [P1] Retain the prior runtime before reading activation identity
Security None None.

How this fits together

The Git updater builds a candidate runtime, stops the managed Gateway, activates the candidate, and verifies it before retiring recovery backups. Its result then feeds post-update convergence and service recovery.

flowchart LR
  A[Git checkout and local commits] --> B[Build candidate runtime]
  B --> C[Stop managed Gateway]
  C --> D[Activate runtime]
  D --> E[Fresh process verification]
  E --> F{Verified?}
  F -->|Yes| G[Retire backups]
  F -->|No| H[Restore prior Gateway]
Loading

Decision needed

Question Recommendation
After the custody defect is fixed and the tagged-driver run is recorded, may this repair land while installed 2026.9.5 drivers still require manual recovery on their first same-commit update? Accept documented first-hop recovery: Land the repaired driver after exact tagged-driver evidence and the custody repair, with clear manual recovery guidance for existing installations.

Why: Candidate code cannot change an updater already running from the published release; accepting that upgrade limitation is a maintainer choice.

Before merge

  • Retain the prior runtime before reading activation identity (P1) - If the new dist inventory read throws here after Doctor starts, rollbackError refuses source restoration because migration may have begun. runtimeRetained is still false, so finally deletes the previous runtime backup; a stopped managed Gateway can be left without a restoration copy. Register backup custody before this read and cover its failure through the update entry point.
  • Resolve merge risk (P1) - A dist read failure after activation can leave the managed Gateway stopped and delete its only previous runtime backup.
  • Resolve merge risk (P1) - The published 2026.9.5 updater's first hop retains the old selector and may require manual source recovery; the required published-driver × final-candidate managed-service observation is absent.
  • Complete next step (P2) - Repair backup custody before the activation identity read, add an update-entry-point failure regression, and record the published 2026.9.5 driver × final-candidate managed-service outcome before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Retain the prior runtime before reading activation identity — src/infra/update-runner-git.ts:540
Agent review details

Security

None.

PR surface

Source +68, Tests +429, Docs +6. Total +503 across 62 files.

View PR surface stats
Area Files Added Removed Net
Source 38 306 238 +68
Tests 23 588 159 +429
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 62 900 397 +503

Review metrics

Metric Value Why it matters
Production versus test growth production +228/−144, tests/support +481/−82 The PR body attributes net production growth to recovery and verification ownership, with larger test growth around those paths.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #157012
Summary: This PR is the candidate repair for the reported same-commit removed-chunk update failure; the earlier merged stale-build repair addresses a different Git-update condition.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Retain backup before identity capture (recommended)
    Move custody registration ahead of the fallible dist read and prove an injected read failure through the update entry point preserves a recoverable previous runtime.
  2. Hold for tagged-driver evidence
    Keep the PR pending until a published 2026.9.5 driver × final-candidate managed-service run records the first-hop result and recovery path.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Register the Git runtime transaction and mark backup custody before reading the activated artifact identity. Inject a dist inventory read failure after activation Doctor through the update entry point, and assert that the previous runtime backup remains available and the failure is reported. Preserve existing state-safety and authority checks; do not edit CHANGELOG.md.

Technical review

Best possible solution:

Register finalizer custody before fallible activation-identity reads, preserve the prior runtime on every failure path, and document the proven first-hop behavior of the published driver.

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

Yes. The PR's Linux systemd run reproduced the removed-chunk failure after a same-commit rebuild, and fetched main retains the selector that permits that path; this reviewer did not execute the exact fetched-main revision.

Is this the best way to solve the issue?

No, not yet. Fresh-process verification addresses the observed cause at the updater owner, but backup custody must precede the new fallible read and the published-driver upgrade path needs its required observation.

Full review comments:

  • [P1] Retain the prior runtime before reading activation identity — src/infra/update-runner-git.ts:540
    If the new dist inventory read throws here after Doctor starts, rollbackError refuses source restoration because migration may have begun. runtimeRetained is still false, so finally deletes the previous runtime backup; a stopped managed Gateway can be left without a restoration copy. Register backup custody before this read and cover its failure through the update entry point.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1ab1bb09789a.

Labels

Label changes:

No label changes.

Label justifications:

  • P0: The reported update failure leaves a managed Gateway unavailable, and the unresolved custody path can strand it without its previous runtime.
  • merge-risk: 🚨 availability: The introduced post-activation identity read can fail before backup custody is registered, leaving no automatic restoration copy.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The maintainer-author proof gate does not apply. An earlier Linux systemd run exercises the Git update entry point and shows after-fix Gateway recovery, while final shared-convergence placement has focused tests; the repository-required published 2026.9.5 driver × final-candidate cell remains unrecorded. No stored-data contract changes.

Evidence

Acceptance criteria:

  • [P1] pnpm test src/infra/update-runner-git-candidate.test.ts --maxWorkers=1.
  • [P1] pnpm test src/cli/update-cli/update-command-convergence-authority.test.ts --maxWorkers=1.
  • [P1] pnpm test src/cli/update-cli/update-command-post-update-recovery.test.ts --maxWorkers=1.
  • [P1] node scripts/check-changed.mjs --base origin/main.
  • [P1] Published 2026.9.5 installed-driver × final-candidate managed-systemd-service update with recorded outcome and recovery.

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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.

  • Preserve the previous runtime when activation identity capture fails, with an update-entry-point regression.
  • Record the published 2026.9.5 driver × final-candidate managed-service outcome.

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 (3 earlier review cycles)
  • reviewed 2026-09-24T15:18:44.590Z sha d6749c3 :: blocked before merge. :: none
  • reviewed 2026-09-24T18:32:53.852Z sha 0789d208d8b6f241acc73166c9e9648a319a71b3 :: blocked before merge. :: [P1] Retain the old runtime before fallible post-activation reads
  • reviewed 2026-09-24T19:43:03.389Z sha 99e6cf6 :: blocked before merge. :: [P1] Retain the old runtime before reading activation identity

@steipete
steipete disabled auto-merge September 24, 2026 17:17
@steipete
steipete force-pushed the upd/git-post-update-verification-stale-chunk branch from d6749c3 to 0789d20 Compare September 24, 2026 18:24
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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 24, 2026
Route successful Git activation through fresh post-core continuation, compare
the activated build at shared convergence completion, and retain existing
source/runtime rollback through final verification. Reuse the current
state/config/service finalizer and keep verified cleanup hiccups advisory.

Document the published driver's first-hop limitation. Thanks @MikyWang for
reporting the removed-chunk failure and stopped Gateway in #157012.
@steipete
steipete force-pushed the upd/git-post-update-verification-stale-chunk branch from 0789d20 to 99e6cf6 Compare September 24, 2026 19:34
@steipete
steipete enabled auto-merge (squash) September 24, 2026 19:37
@steipete
steipete disabled auto-merge September 24, 2026 20:48
Move the unchanged step result contract to its own leaf and migrate every consumer directly. This removes the type-only cycle introduced by the retained Git transaction hook without changing runtime behavior.
@steipete
steipete enabled auto-merge (squash) September 24, 2026 21:47
@steipete
steipete merged commit 3813c04 into main Sep 24, 2026
197 checks passed
@steipete
steipete deleted the upd/git-post-update-verification-stale-chunk branch September 24, 2026 22:32
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
…law#157350)

* fix(update): recover same-commit Git runtime rebuilds

Route successful Git activation through fresh post-core continuation, compare
the activated build at shared convergence completion, and retain existing
source/runtime rollback through final verification. Reuse the current
state/config/service finalizer and keep verified cleanup hiccups advisory.

Document the published driver's first-hop limitation. Thanks @MikyWang for
reporting the removed-chunk failure and stopped Gateway in openclaw#157012.

* test(update): extract Git runtime restoration cases

* fix(update): isolate the step result type contract

Move the unchanged step result contract to its own leaf and migrate every consumer directly. This removes the type-only cycle introduced by the retained Git transaction hook without changing runtime behavior.
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 merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Git update post-update verification loads removed hashed io.write chunk

1 participant