Skip to content

fix(gateway): preserve failure details during updates - #148117

Draft
vincentkoc wants to merge 2 commits into
mainfrom
fix/update-gateway-failure-evidence-145388
Draft

vincentkoc wants to merge 2 commits into
mainfrom
fix/update-gateway-failure-evidence-145388

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Related: #145388, #145499.

Draft, not merge-ready: local scoped tests, core types and the full build passed. Full hosted CI, the UI performance gate and published-driver/native-flow qualification remain outstanding.

What Problem This Solves

Gateway-started updates can produce generic or incomplete failure reports when orchestration throws or the updater returns diagnostic facts without progress events. A final-result persistence failure can also leave an accepted handoff without RPC-owned cancellation.

User Impact

Preserves the observed cause, failing phase and returned diagnostic metadata so operators retain the available evidence. If final-result projection throws after a handoff is accepted, the RPC awaits cancellation for that exact owner before rethrowing the original error, including when cancellation or logging fails. Unconfirmed cancellation is not reported as settled custody. The original incidents in the related issues are not reproduced or claimed fixed by this PR.

Why This Change Was Made

  • Keep known installation identity, elapsed time and returned result facts when initialization, preflight, the runner, post-core finalization or managed-handoff startup throws.
  • Set the failing check before fallible staging and validating ledger transitions, so a transition failure is attributed to the phase being entered.
  • Reuse the canonical step projector for returned failure facts, config-write refusals, snapshot capacity and advisory metadata. Restrict the successful null-exit handoff exception to the actual accepted step, not later failures.
  • Keep failure construction, progress and synchronous result projection in one Gateway-local evidence helper; remove the duplicated handler projection and shadowed diagnostic timer.
  • On exceptional final projection, cancel only the RPC-owned accepted handoff, then preserve the original exception. Do not retry ledger writes, invent terminal rows, write a sentinel or transfer ownership on this path. A write may already have committed.

Production LOC: +157/-61 (net +96). Tests/support: +652/-2. Growth gives authoritative diagnostics one Gateway owner and adds the missing exceptional custody cleanup; it does not introduce a second reporting or recovery policy. No new config, schema or protocol is introduced; authority checks, rollback and normal restart policy remain unchanged.

Separate follow-up (G2): #148159 addresses late restart-sentinel persistence and accepted-handoff transfer cause loss. Those paths are not fixed by this parent PR; the child's runtime/type proof remains pending.

Evidence

The following local results bind to tree 5cf38d5bf68e21c2f0e136464929d059d172988d, preserved exactly by the signed commit:

  • Required autoreview and independent source reviews: scoped-clean. These are code reviews, not native updater execution. Autoreview report SHA256: b7008f0f55f34e3daad8c0e72fecc6452f19b9febbdf06db41ba299800c1971b.
  • Targeted formatting, focused lint and git diff --check: passed.
  • Canonical focused tests: 119/119 passed across src/gateway/server-methods/update-failure-evidence.test.ts (22), update.test.ts (55) and update-report-run.test.ts (42). Coverage uses the actual RPC handler, reopened real SQLite, local reports and the actual public-preview handler; updater execution and managed handoff are mocked.
  • Controlled cleanup regression: the same two final-phase/accepted-row cases failed on the exact pre-cleanup handler because cancellation did not start, then passed after byte-exact restoration of the candidate. 2 RED -> 2 GREEN, with no assertion changes. This proves the cancellation-cleanup regression only, not the original diagnostic-loss defect or a packaged update.
  • Canonical run-tsgo core project: passed. Full pnpm build: exit 0 in 7m26s, including declarations, UI and metadata; 52 built-module/Doctor-closure checks and 154 public SDK subpaths passed. Trusted local fallback was used after the remote source-fetch route failed before proof.
  • The full build's report-only UI check measured startup JS gzip 362,051 B versus 361,938 B (+113 B). This is not a passing UI performance gate. Earlier f001 CI reported +66 B; attribution has not been isolated, and no baseline waiver is claimed.
  • Earlier hosted Gateway job passed 111 scoped tests, and all four type jobs passed in that CI run, for f0017931e41fb8380313610736f6cf6c3bb48496 only. Those older hosted results do not qualify this new head, and the aggregate run was not green.

Remaining gaps: full hosted CI on the new head; the UI performance gate; real published-driver-to-candidate/native handoff flow; and failing-before/passing-after execution of the original diagnostic-loss cases. Boundary tests do not establish real IPC cancellation or explain the linked incidents.

Reviewed and signed head: b458db5a27c716c4b7a2e4e1564119de315b4701.

@clawsweeper

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

@vincentkoc

Copy link
Copy Markdown
Member Author

@fuller-stack-dev This draft preserves observed update failure details at the Gateway owner boundary. Code review is clean, but all 14 new regression cases and runtime/type/hosted CI proof are pending. Late sentinel/transfer cause loss remains a separate follow-up; the linked incidents are not claimed fixed. Not merge-ready.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Sep 14, 2026
@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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 5, 2026, 1:30 PM ET / 17:30 UTC (Revision 5).

ClawSweeper review

What this changes

The PR preserves Gateway update failure details in responses and run history, and awaits cancellation of an accepted update helper when final-result recording throws.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: this member-authored PR retains useful exceptional cancellation work that current main does not cover. No blocking introduced code defect was found, but reconciliation and update qualification remain unresolved.

Priority: P2
Reviewed head: b458db5a27c716c4b7a2e4e1564119de315b4701

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is coherent and has meaningful boundary coverage, with native update qualification still required before landing.
Proof confidence 🌊 off-meta tidepool Not applicable: Member authorship exempts this PR from the external-contributor proof gate. Its actual update.run and reopened SQLite coverage uses mocked updater and cancellation calls; repository-required native cleanup and published-driver qualification remain separate unresolved risks. Existing stored-format contracts are unchanged.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Member authorship exempts this PR from the external-contributor proof gate. Its actual update.run and reopened SQLite coverage uses mocked updater and cancellation calls; repository-required native cleanup and published-driver qualification remain separate unresolved risks. Existing stored-format contracts are unchanged.
Evidence reviewed 9 items Pinned introduction: The merge-base-to-head delta introduces the evidence helper, RPC integration, cancellation guard, and focused tests; endpoint drift was excluded from patch ownership.
Exceptional cleanup: Final projection failure awaits cancellation of the exact RPC-owned handoff, preserves the original exception, and avoids retrying potentially committed ledger writes. The existing cancellation owner checks the active handoff identity and observes helper exit and lease settlement.
Current-main overlap and remaining value: Current main uses createUnexpectedUpdateFailureResult and recordHandoffFailure to preserve diagnostic causes, but its final recordUpdateRunPhase call remains outside an exceptional cancellation guard. Main has also replaced the former inline updater path, requiring deliberate reconciliation rather than restoring the old handler wholesale.
Findings None None.
Security None None.

How this fits together

The Gateway accepts update requests and hands execution to the updater or a managed helper. It records progress and outcomes for operator responses, update history, and failure reports.

flowchart TD
  A[Update request] --> B[Gateway update handler]
  B --> C[Updater or managed helper]
  C --> D[Failure evidence projection]
  D --> E[Update history and reports]
  D --> F{Final recording fails}
  F --> G[Cancel owned helper]
  F --> H[Operator response]
Loading

Before merge

  • Resolve merge risk (P1) - The new final-projection cancellation path has not been qualified with the real helper: helper exit, lease release, and continued Gateway availability remain unverified.
  • Resolve merge risk (P1) - Published-driver-to-candidate upgrade qualification remains outstanding under repository update policy.
  • Resolve merge risk (P1) - The branch conflicts with current main's reorganized update owners; the reconciled candidate must preserve current admission and diagnostics behavior.
  • Complete next step (P2) - Reconcile with current main and complete the native final-projection cleanup and published-driver upgrade qualification before marking the draft ready.
Agent review details

Security

None.

PR surface

Source +96, Tests +650. Total +746 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 157 61 +96
Tests 2 652 2 +650
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 809 63 +746

Review metrics

Metric Value Why it matters
Production versus test growth production net +96 lines; tests/support net +650 lines The body justifies production growth through one Gateway evidence owner and exceptional cleanup, with boundary regressions accounting for most added code.

Merge-risk options

Maintainer options:

  1. Qualify the reconciled cleanup path (recommended)
    Preserve current-main ownership while demonstrating that a final recording failure settles the actual helper and lease without stopping the serving Gateway.

Technical review

Best possible solution:

Integrate exceptional cancellation into current main's update owner, retain its existing diagnostics, and qualify cleanup and upgrades through the real helper and published updater.

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

Yes, source identifies an accepted handoff followed by a throwing final history write, and the supplied cleanup controls establish that boundary regression. Native execution and the original reported incidents were not reproduced in this review.

Is this the best way to solve the issue?

Yes for the exceptional cleanup invariant and reuse of canonical diagnostics; the old handler layout must be reconciled with current main's owners before landing.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded update diagnostics and cleanup improvement, without proof that it resolves the linked update incidents.
  • merge-risk: 🚨 availability: The introduced exceptional path now awaits real helper cancellation, whose process and lease settlement have only mocked coverage for this scenario.
  • 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: Member authorship exempts this PR from the external-contributor proof gate. Its actual update.run and reopened SQLite coverage uses mocked updater and cancellation calls; repository-required native cleanup and published-driver qualification remain separate unresolved risks. Existing stored-format contracts are unchanged.

Evidence

What I checked:

  • Pinned introduction: The merge-base-to-head delta introduces the evidence helper, RPC integration, cancellation guard, and focused tests; endpoint drift was excluded from patch ownership. (src/gateway/server-methods/update.ts:589, b458db5a27c7)
  • Exceptional cleanup: Final projection failure awaits cancellation of the exact RPC-owned handoff, preserves the original exception, and avoids retrying potentially committed ledger writes. The existing cancellation owner checks the active handoff identity and observes helper exit and lease settlement. (src/gateway/server-methods/update.ts:593, b458db5a27c7)
  • Current-main overlap and remaining value: Current main uses createUnexpectedUpdateFailureResult and recordHandoffFailure to preserve diagnostic causes, but its final recordUpdateRunPhase call remains outside an exceptional cancellation guard. Main has also replaced the former inline updater path, requiring deliberate reconciliation rather than restoring the old handler wholesale. (src/gateway/server-methods/update-admission.ts, af6cdb21a6fa)
  • Proof scope and review continuity: The captured PR body reports 119 focused passes and two cleanup red-to-green controls while explicitly stating that updater execution and handoff cancellation are mocked. Full test inspection confirms RPC, reopened SQLite, report-preview, cancellation ordering, original-error retention, and unmanaged-owner controls. The prior description rank-up is addressed; the native qualification gap remains. (src/gateway/server-methods/update-failure-evidence.test.ts:329, b458db5a27c7)
  • Existing storage and redaction contracts: The helper reuses the existing step projector and redacted failure-fact constructor. Failure facts, config refusals, and snapshot capacity already belong to the existing record schema; the introduced patch adds no stored-format, schema, configuration, or protocol contract. (src/gateway/server-methods/update-run-evidence.ts:38, b458db5a27c7)
  • Related child remains distinct: fix(gateway): retain late update handoff failures #148159 remains open and stacked on this branch. Its supplied installed launchd/RPC evidence positively covers sentinel and transfer failures, but does not exercise this parent's final-result projection failure. Neither PR claims the original linked incidents reproduced or resolved. (f355b8403f34)

Likely related people:

  • vincentkoc: 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)
  • fuller-stack-dev: 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.

  • Provide source-bound native evidence that final-result recording failure exits the owned helper, releases its lease, and leaves the Gateway serving.
  • Complete published-driver-to-candidate qualification after reconciling the branch with current main.

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 (4 earlier review cycles)
  • reviewed 2026-09-14T09:29:08.577Z sha f001793 :: blocked before merge. :: none
  • reviewed 2026-09-14T10:37:56.220Z sha f001793 :: blocked before merge. :: none
  • reviewed 2026-09-15T00:23:08.311Z sha b458db5 :: blocked before merge. :: none
  • reviewed 2026-09-26T02:05:24.281Z sha b458db5 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 14, 2026
Preserve the original projection error after joining cancellation for the RPC-owned handoff. Do not retry ledger writes or claim custody settled when cancellation is unconfirmed.

Keep update evidence in its Gateway owner and remove duplicate progress and result projection. Related: #145388, #145499.
@vincentkoc

Copy link
Copy Markdown
Member Author

@fuller-stack-dev Pushed signed b458db5a27c716c4b7a2e4e1564119de315b4701. G1 now awaits cancellation of its accepted handoff when final-result projection fails, without masking the original error or claiming unconfirmed custody is settled.

119 scoped tests, core types and the full build passed; the cleanup control produced 2 intended failures before restoration and 2 passes afterward. Fresh code review is scoped-clean, not native updater proof.

The draft remains not merge-ready: new-head hosted CI, published-driver/native-flow qualification and before/after proof for the original diagnostic-loss defect remain open. The build's report-only UI JS budget is +113 B; attribution is not isolated. Details and exact proof scope are in the updated body. No merge or queue requested.

@clawsweeper clawsweeper Bot added 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. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 15, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 26, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@fuller-stack-dev Current-main closeout audit at ca5ac6f5b69a: retain and adapt this draft; it is not fully superseded.

The decisive residual is prompt, joined cancellation of an RPC-owned accepted handoff when final projection fails. The current RPC awaits final phase recording outside the later cancellation block. The async phase writer can reject, including when required bookkeeping was not recorded, so that rejection skips RPC-owned cancellation. The helper deadline fallback still exists: this is not evidence of an indefinite process leak.

Next integration unit: adapt the cancellation boundary and regression to the current async writers, preserving current admission, campaign and sentinel behavior. Keep the existing regression's meaningful requirements: cancel only the exact owned handoff, join cancellation before rejecting with the original error, do not transfer/write a sentinel/retry on this exceptional path, do not let cancellation or warning failures mask that error, and never cancel a foreign owner in the unmanaged control. Do not restore the historical synchronous projection helper wholesale.

This is a source-only audit, not new runtime qualification. The adapted regression still needs an intended failure on the frozen baseline and a repaired pass through the real RPC boundary, followed by the retained native-flow and current-head landing gates. Historical 119-test and 2-red/2-green results remain evidence for their recorded inputs only. Existing ownership and draft state are preserved; no branch mutation or merge was performed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

2 participants