Skip to content

fix(update): retain finalization failure reasons in reports - #147286

Merged
steipete merged 2 commits into
mainfrom
steipete/upd-finalize-step-failure-reason
Sep 13, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/upd-finalize-step-failure-reason

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Related: #147160, #146514

What Problem This Solves

Failed update finalization could record reason: null, leaving status and the generated issue with an unknown cause, install kind, and rollback outcome even though Doctor's error was available.

Reported by @Navras98 (#147160).

User Impact

Finalization failures retain the failing check's code (or phase name), and the reviewed report shows the first recognized diagnostic line instead of an unknown exit. Standalone package finalization records that package rollback is unnecessary because it does not replace the core package. This makes no claim that Doctor left config/state unchanged or that Gateway health was verified.

Why This Change Was Made

The finalization lifecycle now records the reason atomically with its failed step; terminal failure preserves it when the parent supplies no explicit reason. The CLI finishes the admitted run before triage and uses that same run ID for reporting. Common report preparation consumes only matching ledger facts and preserves explicit result reasons, measured package-manager modes, and verified recovery outcomes.

Install classification uses the existing package/Git detector once. Durable reports use that install kind when no measured npm/pnpm/bun mode is available. An explicit skipped step records the package rollback non-outcome only for standalone package finalization. Inherited runs and post-core children, including the published 2026.9.3 marker without a run ID, leave rollback with their parent.

Removed paths: duplicate install-kind probes, the unrelated standalone report identity, and the hardcoded CLI reason that masked the ledger. Production delta: +80 lines; the added code carries facts through the existing ledger/report owners. No schema, retention, dependency, config, or activation changes. The maintenance refusal itself remains owned by #146514.

Evidence

  • Regression tests were run unchanged against the original production code by saving and reversing only the production diff, then reapplying it (no stash). The CLI/ledger run failed 13 tests: null reasons across every finalization phase and an interactive preview with unknown mode and unexpected-error. The report-only regression separately failed because Reason code: doctor-failed was absent.

  • Candidate focused proof: all 194 tests passed across finalization, command/interactive reporting, fresh Doctor handling, diagnostic redaction, and the durable ledger.

  • Coverage includes thrown Doctor refusals, returned plugin failures, every finalize:* phase, parent reason precedence, matching run identity, private diagnostic suffix removal, and post-core children with/without a run ID.

  • pnpm check:changed: passed (including core and test typechecks, targeted lint, schema and import-cycle guards).

  • Independent Codex autoreview at P2: scoped-clean after fixing a pre-ledger stderr redaction finding; the emitted-record regression covers the correction.

  • Original CI: run 34775810071 reported an unrelated failure in checks-node-compact-small-32: test/scripts/test-projects.test.ts:1044 expects five QA Profile Evidence targets, but routing also returns test/scripts/qa-profile-run-status.test.ts. The CI run is completed with failure; the other observed checks passed, with no cancellations. No unrelated source change was added to this PR. The CI checkout is merge 6533953c02859c524e42f98415ac6e949efd2639, with parents main 0afc02335308892d7efa3ccf7d981e912c6dd238 and this head 9be5afeee9e1f106dd708cc97e25760a92a2009f. GitHub's parent-to-merge comparison contains only this PR's 11 files; the failing routing owner and test are unchanged.

  • Refresh CI: run 34778204511 completed successfully for af563f73427fc9e8a5fb303f38deaf210bae5da9. The exact-head watcher returned GREEN; no failed or cancelled jobs required a retry. The empty refresh is tree-identical to the reviewed head. Its observed checkout is 272ef4ef64b19c9a499ec2e440902421661c9819, with main c08d8406c28baddbc2ff2b7a80a284c839b24e3f as its first parent; that parent contains the routing correction.

Limitations: synthetic isolated-state proof, not a live npm update or Gateway restart. The published-driver contract was checked at the 2026.9.3 tag and exercised through its handoff markers; no full published-package installation matrix was run. Existing historical runs cannot recover facts that were never recorded, and existing diagnostic size limits still apply.

ClawSweeper review

Latest reviewed head: af563f73427fc9e8a5fb303f38deaf210bae5da9 (19:44 UTC), tree-identical to the approved code at 9be5afeee9e1f106dd708cc97e25760a92a2009f. No code or security findings were identified, so no code fixups were needed. The maintainer accepted the existing regression, handoff-marker, and report-boundary evidence for this reporting-only repair; the requested full published-updater × candidate execution remains a documented proof gap. This change does not alter package replacement, Doctor admission, parent recovery, or Gateway activation. The generic data-model compatibility reminder does not require a migration here: this patch adds no schema, storage format, retention, or recovery changes. No re-review was requested by this lane because the code is unchanged; ClawSweeper refreshed its review automatically.

Record finalization reason and install facts before triage, preserve explicit parent outcomes, and report the recognized Doctor cause with an explicit standalone package rollback non-outcome. Refs #147160, #146514. Reported by @Navras98 (#147160).
@clawsweeper

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

@steipete
steipete marked this pull request as ready for review September 13, 2026 18:49
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: M maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 13, 2026, 3:44 PM ET / 19:44 UTC (Revision 3).

ClawSweeper review

What this changes

Preserves finalization failure reasons, installation type, and redacted diagnostics in update history and failure reports, while distinguishing standalone package finalization from parent-owned rollback.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful reporting fix absent from current main and the latest release. No blocking code or security findings remain; the documented maintainer disposition addresses the previous review’s proof request.

Priority: P2
Reviewed head: af563f73427fc9e8a5fb303f38deaf210bae5da9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, coherent repair with meaningful regression coverage and an explicitly accepted execution limitation.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored exemption applies. Inspected coverage exercises finalization, the durable ledger, and report preparation with injected Doctor failures and handoff markers; it is synthetic boundary evidence, not a live package update. The PR records acceptance of that limitation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored exemption applies. Inspected coverage exercises finalization, the durable ledger, and report preparation with injected Doctor failures and handoff markers; it is synthetic boundary evidence, not a live package update. The PR records acceptance of that limitation.
Evidence reviewed 9 items Verified review scope and continuity: The checkout is the pinned original head. Comparing the previously reviewed head with HEAD produces no file changes, confirming the CI-refresh commit leaves the reviewed implementation unchanged.
Current main still loses the recorded reason: Current main’s terminal record helper assigns result.reason ?? null, and its finalization/reporting paths lack this branch’s reason propagation and matching-run enrichment.
Latest release retains the same defect: The v2026.9.4 source also clears an omitted terminal reason to null. The release API independently identifies v2026.9.4, published September 11, as latest.
Findings None None.
Security None None.

How this fits together

OpenClaw’s update finalizer runs Doctor and plugin maintenance, recording outcomes in the update ledger. Status views and user-reviewed failure reports consume those records to explain failures and recovery outcomes.

flowchart TD
  A[Update finalization] --> B[Doctor and plugin maintenance]
  B --> C[Record failure reason and diagnostics]
  A --> D[Standalone or parent-owned run]
  D --> C
  C --> E[Existing update ledger]
  E --> F[Matching-run report preparation]
  F --> G[Redacted report preview]
Loading

Before merge

  • Resolve merge risk (P1) - A full published-updater × candidate execution remains unperformed; the PR explicitly documents maintainer acceptance of the narrower reporting and handoff evidence.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +80, Tests +192, Docs +7. Total +279 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 7 138 58 +80
Tests 3 207 15 +192
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 352 73 +279

Review metrics

Metric Value Why it matters
Production and regression coverage Production +80 net lines; tests +192 net lines Production growth is justified by carrying diagnostic facts through existing ledger/report owners, with regressions covering identity, ordering, and parent outcome preservation.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/logging/diagnostic-support-redaction.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep failure facts in the existing ledger and derive reports from the matching run without implying package rollback or Gateway health that was never observed.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep failure facts in the existing ledger and derive reports from the matching run without implying package rollback or Gateway health that was never observed.

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

Yes, from source: a finalization failure without an explicit terminal reason loses its cause on current main, and the report path lacks matching-run reason enrichment. Reporter evidence and the submitted regressions corroborate it; no runtime reproduction was executed here.

Is this the best way to solve the issue?

Yes. The patch repairs the existing producer-to-ledger-to-report path, preserves explicit outcomes, and keeps diagnostics bounded without introducing another storage or recovery owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9d5615cee1c7.

Labels

Label justifications:

  • P2: This bounded diagnostic repair makes failed updates actionable without changing update recovery or activation behavior.
  • 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 maintainer-authored exemption applies. Inspected coverage exercises finalization, the durable ledger, and report preparation with injected Doctor failures and handoff markers; it is synthetic boundary evidence, not a live package update. The PR records acceptance of that limitation.

Evidence

What I checked:

  • Verified review scope and continuity: The checkout is the pinned original head. Comparing the previously reviewed head with HEAD produces no file changes, confirming the CI-refresh commit leaves the reviewed implementation unchanged. (af563f73427f)
  • Current main still loses the recorded reason: Current main’s terminal record helper assigns result.reason ?? null, and its finalization/reporting paths lack this branch’s reason propagation and matching-run enrichment. (src/infra/update-run-record.ts:58, 9d5615cee1c7)
  • Latest release retains the same defect: The v2026.9.4 source also clears an omitted terminal reason to null. The release API independently identifies v2026.9.4, published September 11, as latest. (src/infra/update-run-record.ts:58, 3a9d69db306c)
  • Recording and reporting retain existing owners: Finalization records a failed step and reason through the existing transactional ledger, finishes standalone failures before triage, and passes the admitted run identity. Report preparation rejects mismatched ledger identities and preserves explicit result reasons and measured recovery outcomes. (src/infra/update-failure-report-prepare.ts:315, af563f73427f)
  • Existing storage contract: The unchanged schema already permits nullable reason, optional package/Git target kind, bounded diagnostic details, and skipped steps. The patch adds no schema version, migration, retention rule, or recovery authority. (src/infra/update-run-schema.ts:79, af563f73427f)
  • Focused regression coverage: Inspected tests cover real ledger persistence before triage, interactive report content, all seven finalization phases, explicit parent reason precedence, mismatched report identities, private suffix removal, and post-core markers with and without inherited run IDs. The PR reports 194 passing focused tests and pre-fix failures; this read-only review did not execute them. (src/cli/update-cli/update-command-lifecycle.test.ts:249, af563f73427f)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (2 earlier review cycles)
  • reviewed 2026-09-13T18:57:57.654Z sha 9be5afe :: blocked before merge. :: none
  • reviewed 2026-09-13T19:24:28.623Z sha 9be5afe :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 13, 2026
@steipete
steipete merged commit d10ef37 into main Sep 13, 2026
188 checks passed
@steipete
steipete deleted the steipete/upd-finalize-step-failure-reason branch September 13, 2026 20:17
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…#147286)

* fix(update): retain finalization failure reasons in reports

Record finalization reason and install facts before triage, preserve explicit parent outcomes, and report the recognized Doctor cause with an explicit standalone package rollback non-outcome. Refs openclaw#147160, openclaw#146514. Reported by @Navras98 (openclaw#147160).

* chore: refresh finalization report CI
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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.

1 participant