Skip to content

fix(update): let repair settle a publication whose live package already serves the candidate - #165607

Merged
steipete merged 6 commits into
mainfrom
upd/upd-publication-stuck-publishing-settle
Oct 5, 2026
Merged

steipete merged 6 commits into
mainfrom
upd/upd-publication-stuck-publishing-settle

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Adds a guarded settlement path for native package updates remaining blocked at publishing after an operator's external write changes sealed package evidence, even when the installed candidate's packaged contents are healthy. Restoring file contents cannot restore the original filesystem fingerprint, so the old helper refuses both repair and retirement.

Closes #164214. Related: #164422. Thanks @NovaeonStudio for the report and preserved incident evidence.

User Impact

openclaw update repair can close the stranded operation as publication-settled-external-change and admit the next update. It preserves the installed package, launchers, previous package, and sealed helper. Ordinary extra dist files appear in the warning and run ledger. Extra uninventoried package.json scopes under dist/ refuse settlement and keep recovery armed; expected dependency manifests under node_modules/ are ignored. Failed inventoried content, invalid root manifest fields or targets, the wrong candidate version, a changed helper, or a live executor also refuse settlement.

The reporter's npm layout is supported: root package.json, openclaw.mjs, a bin symlink, dist inventories, ordinary top-level README/license files, dependency manifests, and an operator's extra dist backup. Manifest entry targets outside dist must exist and resolve within the package; their content is not verified in this settlement path. Targets within dist remain inventory-verified.

Use a CLI containing this fix. Modified inventoried files must first be restored to their packaged contents; the original sealed helper retains its original checks.

Why This Change Was Made

The activation/custody owner verifies the installed build-info's exact candidate version and both installed inventories through the existing dist-inventory contract. It retains launcher checks, the sealed helper digest, exclusive executor ownership, observation rechecks through archival, and launcher-directory durability before disarming recovery. The inventory reader loads only when settlement runs, preserving the native wrapper's startup dependency boundary.

The P1 correction addresses Node's nearest-manifest semantics: an extra dist/package.json with type: commonjs can break inventoried ESM without changing its bytes. Root package.json is not byte-inventoried today, so settlement requires parsed fields name: openclaw, the exact candidate version, and type: module; every main, exports, and bin target must resolve to a file in the package, with content-inventory membership required for dist targets. Outside-dist targets such as the stock launcher are checked for resolution, not content; the receipt states that distinction. The warning and ledger receipt explicitly say field-verified, not content-verified. The same existing inventory collectors/comparator verify content, and the helper/executor/artifact guarantees remain intact.

Named follow-up: extend the sealed inventory to the top-level launcher and root manifest for NEW operations. This changes the publication contract and belongs in a separate PR; it is not a new prerequisite imposed on existing operation seals here.

Interrupted archival and completed receipts survive lease-database loss or replacement. The ledger owner records an atomic completed receipt keyed by the operation ID, so interrupted reporting can replay without overwriting the original failed update. Warnings report current inventory differences and extra paths; the old whole-tree digest cannot reconstruct historical per-file metadata changes.

No CLI flags, config options, dependencies, SQLite tables, or schema versions change.

Evidence

  • Reporter-layout red/green proof: the npm-layout fixture failed on c4bec41b601781e5884c862dbd657f88e88c4a1b because the previous guard required the root bin launcher to be inventoried. With the correction, the reporter's layout is proven settleable through the public repair boundary: root field-verified manifest, root openclaw.mjs, an npm bin symlink, dist inventories, README/license files, three ordinary/scoped/nested dependency manifests, and the operator's dist/index.js.bak. Recovery is disarmed only after verification, artifacts and the working launcher remain, the warning/ledger name the backup, and the next update can prepare. This is an isolated synthetic npm-layout fixture, not a claim of running on the reporter's machine.
  • Current settlement suite: node scripts/run-vitest.mjs src/cli/update-cli/update-repair-package-activation.test.ts --maxWorkers=1 passed 40/40 three times. Vitest wall 49.25 / 32.06 / 42.29s; wrapper wall 54.45 / 34.97 / 45.54s. The reporter-layout case took 1.085 / 0.981 / 1.017s. Negative cases include extra dist/package.json and dist/nested/package.json, root type/name/version/parse failures, missing or dangling entry targets, failed content inventory, changed helper, and live executor. The suite uses actual package publication/custody and isolated ledger fixtures to prove recovery remains armed on refusal; no deadlines or assertions were weakened. Hosted CI timing for this head is not yet available.
  • Current closure guards: node scripts/run-vitest.mjs test/scripts/eager-import-closure.test.ts test/scripts/pr-wrapper-source-closure.test.ts --maxWorkers=1 passed 20/20, Vitest wall 33.87s, wrapper 36.25s. No new production module or wrapper-inventory entry was needed.
  • Current changed checks: node scripts/check-changed.mjs --base c4bec41b601781e5884c862dbd657f88e88c4a1b --timed passed, exit 0 / 486.11s wall, including formatting, core types, all 27 test type graphs, lint, all three unused-export scans (zero findings), schema and architecture guards. git diff --check passed. All current proof ran locally with isolated OPENCLAW_STATE_DIR; no remote lease or operator Gateway was used.
  • P1 red proof: the extra-manifest cases (dist/package.json, dist/nested/package.json) and the root version/type regressions failed on the previous owner because repair incorrectly resolved. Native Node loaded the synthetic inventoried ESM before the extra manifest (exit 0), then failed parsing it as CommonJS afterward (exit 1).
  • Resolution audit: the canonical package-dist-imports scanner inspected 10,834 files / 70,764 relative edges, finding 0 CommonJS require edges and no extensionless CommonJS edge. Built ESM references use exact paths; the CommonJS extension resolver considers the exact path, .js, .json, and .node (not .mjs). No separate alternate-extension shadow guard was added because this inventory audit identified no applicable extensionless import. This static audit does not claim coverage of arbitrary computed plugin paths.
  • Public repair-boundary reproduction: mutate and restore dist/index.js during publication, retain dist/index.js.bak, and observe repair/retirement refusal with status still publishing. The healthy settlement regression failed before the fix. Before the P1 correction, the corpus had 31/31 settlement regressions passed, including content mismatch, inventoried symlink, live executor, helper/version mismatch, failed directory sync, interrupted archival/reporting, lease loss, retained artifacts, and next-update preparation.
  • Before compression, the repair suite passed 31/31 three times with node scripts/run-vitest.mjs src/cli/update-cli/update-repair-package-activation.test.ts --maxWorkers=1: Vitest wall 96.50 / 59.59 / 101.26s, wrapper 107.73 / 70.02 / 112.91s. The other three touched Gateway/Git-service suites passed 32/32 three times. That prior-head corpus also passed all 121 service integration cases. Hosted CI timing is not yet available.
  • Before the P1 correction, both closure guards (eager-import-closure.test.ts, pr-wrapper-source-closure.test.ts) and staged recovery-runtime checks passed 22/22. The new module and eager contract dependencies are included in scripts/pr-lib/wrapper-components.txt. Full node scripts/check-changed.mjs --base c3b2b7d3fc1a053d2f6907e55e1629c16fc53706 --timed passed every step: core types, all 27 test type graphs, lint, three unused-export scans with zero findings, and architecture guards. One stale max-lines baseline entry was removed; shrink only.
  • Before the P1 correction, all 260 selected importer files ran locally in captured order: 254 passed, 5 skipped, 1 failed; 5,129 tests passed, 73 skipped, 2 failed. Wrapper wall 11,141.94s, including runtime preparation 24m 46.6s (compilation 23m 5.7s). Build preparation is separate from test time.
  • Known failing follow-up: update-repair-agent.e2e.test.ts turn/validating (70.408s) and turn/verifying (70.268s) exhausted the turn budget before tool execution. Each performed 94 live-authority checks, consuming 60.216 / 60.215s in requester/ledger snapshot work; fence checks took under 73ms. The test and measured cost owners are byte-identical to main 6ddf5a6106c18c4cf803a601b3a099e497d943fb. This is source attribution, not a separate baseline execution. Fresh nested authority reads are an explicit contract, so this needs a separate owner-level performance fix; freshness checks, deadlines, and assertions remain intact.
  • Main timing baseline: ran update-finalization-output.process.test.ts once on that clean detached main, then restored the branch: 18 passed, 2 failed. doctor-hang passed 8.013s; doctor-progress failed 9.332s (3342ms phase versus the under-3000ms assertion); borrowed-phase failed 7.623s. The final branch corpus passed all 20 cases, including those three in 5.092 / 5.066 / 4.967s. That passing sample is not a claimed fixture fix. Deterministic child-custody readiness remains the named follow-up.
  • Fixed importer-discovered fixture ownership defects without weaker assertions or longer timeouts: joined scheduler work, used the persisted retry deadline, isolated synthetic installation/HTTP probes, retained the admitted database in shared CLI setup, and adopted main's host-platform namespace fixture correction. The measured Git-service case dropped from 88 snapshot subprocesses / 43.48s to zero, and 56.37s to 7.20s; the explicit cold-state regression remains covered. Existing rollback integration cases passed in 25.812 / 50.211 / 15.264s; they perform real SQLite migration/restore, child lifecycle checks, and local Git operations with mocked builds. The unchanged slow-storage admission case passed in 55.555s, retaining real snapshot reads under its simulated cost clock.
  • Codex P1 review returned HTTP 401 Unauthorized, without a verdict. Further lane review was explicitly waived; the lead will review. All proof used isolated state, and no operator Gateway or state was modified.

Current correction numstat: production +27/-10; tests +30/-9; docs +9/-7 (+66/-26 total). Full PR against the integrated base: production +397/-40; tests/support +485/-59; docs +21/-2; wrapper inventory +3/-0; baseline +0/-1.

@clawsweeper

clawsweeper Bot commented Oct 5, 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 gateway Gateway runtime cli CLI command changes scripts Repository scripts size: L labels Oct 5, 2026
@steipete
steipete marked this pull request as ready for review October 5, 2026 14:04
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 5, 2026, 11:22 AM ET / 15:22 UTC (Revision 2).

ClawSweeper review

What this changes

Adds guarded repair settlement for interrupted package publication, preserves recovery artifacts, records a replayable completion receipt, and updates recovery documentation and test fixtures.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains a useful fix for an unresolved update-recovery dead end. No concrete introduced bug was established, but the earlier published-driver compatibility requirement remains unmet.

Priority: P1
Reviewed head: b46c1e473845c30b6499a4dc191f4974a4adaa38

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation and focused regression evidence are useful, but the published-operation upgrade boundary remains unverified.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a trusted member author, so ordinary external-contributor proof is exempt. The public repair fixture exercises production custody and ledger owners but substitutes an inert helper; independently required compatibility proof for the new persisted intent remains insufficient.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a trusted member author, so ordinary external-contributor proof is exempt. The public repair fixture exercises production custody and ledger owners but substitutes an inert helper; independently required compatibility proof for the new persisted intent remains insufficient.
Evidence reviewed 11 items Pinned introduction and clean checkout: Reviewed the merge-base-to-head introduced changes, not endpoint drift. The checkout remained clean at the pinned original PR head; the supplied test merge is stale and was not used to infer removal of current-main behavior.
Current main still lacks this settlement: Current main sends a same-identity installed candidate through the pending-publication refusal unless another existing settlement condition applies. It lacks the external-publication verification and settlement introduced here.
Verification and final effects: Settlement checks installed inventories, candidate version, manifest fields and targets, launcher evidence, and the sealed helper. Custody retains live ownership and observation checks through journal transitions and archival, including launcher-directory durability before disarming recovery.
Findings None None.
Security None None.

How this fits together

Package activation publishes an installed OpenClaw update and retains evidence for recovery. Repair uses that evidence and exclusive update ownership to decide whether recovery can finish and another update may proceed.

flowchart TD
  A[Interrupted package publication] --> B[Update repair]
  C[Installed package and recovery journal] --> B
  B --> D[Verify contents and exclusive ownership]
  D --> E[Refuse unsafe settlement]
  D --> F[Archive recovery artifacts]
  F --> G[Record completed receipt]
  G --> H[Allow next update]
Loading

Before merge

  • Resolve merge risk (P1) - Existing-operation compatibility remains unverified: settlement writes a durable intent unknown to the published original helper, while current fixtures use an inert helper. Published-driver evidence must establish safe original-helper refusal, preserved artifacts, interruption recovery, and admission of the next writable update.
  • Complete next step (P2) - Provide published 2026.9.7 driver × candidate compatibility evidence for the new settlement receipt before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +357, Tests +426, Docs +19, Other +2. Total +804 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 8 397 40 +357
Tests 7 485 59 +426
Docs 1 21 2 +19
Config 0 0 0 0
Generated 0 0 0 0
Other 2 3 1 +2
Total 18 906 102 +804

Review metrics

Metric Value Why it matters
Persisted recovery contract 1 new settlement intent; 0 table or schema-version changes Existing sealed readers still require compatibility verification despite unchanged SQLite DDL.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/infra/update-run-ledger.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #164214
Summary: This PR specifically implements the external-write publication settlement requested by the open canonical issue.

Members:

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

Merge-risk options

Maintainer options:

  1. Verify published-operation recovery (recommended)
    Provide a published 2026.9.7 driver × candidate result covering settlement, original-helper refusal without writes, retained artifacts, interrupted settlement recovery, and the next writable update.

Technical review

Best possible solution:

Keep settlement in the existing recovery owner and establish published-driver compatibility before landing the new durable receipt contract.

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

Yes, from source: mutate and restore an inventoried file while publication remains publishing, then attempt repair, retirement, and another update. The reporter and focused fixture support this path; this review did not execute it.

Is this the best way to solve the issue?

Yes in direction: guarded settlement through the existing custody owner is narrower than replacing the sealed helper or deleting recovery artifacts. Upgrade safety remains unproven for an operation created by the published driver.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4e011b13e48a.

Labels

Label changes:

  • add P1: This addresses a reported native-update recovery dead end that blocks subsequent updates for affected users.
  • add merge-risk: 🚨 compatibility: The new persisted settlement intent is not understood by published sealed helpers, and current-source fixtures do not verify that upgrade boundary.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a trusted member author, so ordinary external-contributor proof is exempt. The public repair fixture exercises production custody and ledger owners but substitutes an inert helper; independently required compatibility proof for the new persisted intent remains insufficient.

Label justifications:

  • P1: This addresses a reported native-update recovery dead end that blocks subsequent updates for affected users.
  • merge-risk: 🚨 compatibility: The new persisted settlement intent is not understood by published sealed helpers, and current-source fixtures do not verify that upgrade boundary.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a trusted member author, so ordinary external-contributor proof is exempt. The public repair fixture exercises production custody and ledger owners but substitutes an inert helper; independently required compatibility proof for the new persisted intent remains insufficient.

Evidence

What I checked:

  • Pinned introduction and clean checkout: Reviewed the merge-base-to-head introduced changes, not endpoint drift. The checkout remained clean at the pinned original PR head; the supplied test merge is stale and was not used to infer removal of current-main behavior. (b46c1e473845)
  • Current main still lacks this settlement: Current main sends a same-identity installed candidate through the pending-publication refusal unless another existing settlement condition applies. It lacks the external-publication verification and settlement introduced here. (src/infra/package-update-activation.ts:180, 4e011b13e48a)
  • Verification and final effects: Settlement checks installed inventories, candidate version, manifest fields and targets, launcher evidence, and the sealed helper. Custody retains live ownership and observation checks through journal transitions and archival, including launcher-directory durability before disarming recovery. (src/infra/package-update-activation-custody.ts:243, b46c1e473845)
  • Persisted compatibility boundary: The patch adds publication-settled-external-change to persisted intent JSON and writes it before archival. This changes a durable recovery contract even though SQLite tables and numeric schema versions remain unchanged. (src/infra/package-update-activation-schema.ts:92, b46c1e473845)
  • Published original reader: The v2026.9.7 schema has neither superseded nor the new settlement intent. Its sealed entrypoint parses the journal before executing recovery. Safe refusal by that original helper is therefore part of the compatibility scenario to verify, rather than assuming the retained helper understands the new receipt. (src/infra/package-update-activation-schema.ts:70, c074824a27c9)
  • Latest release boundary: The latest supplied release, v2026.9.8, also lacks superseded and the new settlement intent; this is not an already-shipped implementation. (src/infra/package-update-activation-schema.ts:70, fc23bc864e45)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rank-up moves

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

  • Add published-driver compatibility evidence covering settlement, safe original-helper refusal, preserved recovery artifacts, interruption recovery, and the next writable update.

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 (1 earlier review cycle)
  • reviewed 2026-10-05T14:12:18.516Z sha 16ad418 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 5, 2026
@steipete
steipete merged commit fb84dd5 into main Oct 5, 2026
155 checks passed
@steipete
steipete deleted the upd/upd-publication-stuck-publishing-settle branch October 5, 2026 15:27
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
RomneyDa added a commit that referenced this pull request Oct 8, 2026
Backport all required recovery fixes to 2026.10.1: #167302, #167330,
#167358, and #167377. Include their missing settlement prerequisites
#164997, #165238, and #165607.

Close obsolete recovery custody durably before best-effort evidence archival;
keep unfinished rollback and current mutation authority strict. Completed
history cannot block subsequent updates. Qualify authentic interruptions
from pinned 9.8/9.9 updaters plus the unchanged 9.7-to-9.8 negative control.

Adapt donor APIs to the release-owned publication and lease database owners.
No version, dependency, budget, permission, or publication changes.

Proof:619 focused tests passed, including14 release-profile cases;
fresh complete69-file P0-P2 review clean. Complete changed gate passed.
Exact combined release build and stable/all/soak qualification remain pending.

Sources:
3ed1e21 (#167302)
4821885 (#167330)
8879e5e (#167358)
bc860ad (#167377)
9497527 (#164997)
5ae6497 (#165238)
fb84dd5 (#165607)

Co-authored-by: Scott Hanselman <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 26, 2026
…es the candidate (#183479)

A 2026.9.33 to 2026.9.34 update or repair that found a package activation journal at publication-complete, with the live package already serving the recorded candidate and the executor lease intact, refused with "Package publication recovery is pending". settlePendingPackageActivation only settled a prepared operation for an installed candidate, so automatic admission and openclaw update repair both dead-ended.

Extend the existing external-publication settlement to publication-complete: the publication owner verifies the closure and evidence through its retire preflight, the original executor authority is still acquired, and the operation is retired without republishing files. Dry-run admission accepts the same verified state. Publishing and other incomplete phases stay blocked.

Minimal 2026.9.x port of the publication-complete settlement that main carries in 3ed1e21 (#167302), fb84dd5 (#165607), and 0679b18 (#181307); main's separate settlement verifier and custody modules are not ported.
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 gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L 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.

[Bug]: Package publication recovery permanently stuck in publishing after an external write to the live package (macOS, 2026.9.8)

1 participant