Skip to content

refactor(infra): share error cause reader - #130280

Merged
vincentkoc merged 2 commits into
mainfrom
refactor/shared-error-cause-reader
Aug 31, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
refactor/shared-error-cause-reader

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Unhandled-rejection classification and provider retry logic independently implemented the same direct error-cause reader. Keeping those helpers duplicated makes their deliberately narrow object-only contract easier to drift.

Why This Change Was Made

Add one private readErrorCause helper beside the existing error readers and reuse it from both consumers. The helper preserves direct property access, arbitrary cause values, self-references, and throwing getter behavior; recursive and guarded error readers remain separate.

User Impact

No user-visible behavior change. Error-cause inspection now has one canonical implementation for these two runtime paths.

Evidence

  • Focused infra and provider tests: 120 passed.
  • pnpm check:import-cycles: 0 runtime value cycles.
  • check-changed: passed.
  • Autoreview: clean, 0.99 confidence.
  • AWS Crabbox run_ceabb7e07af8 on lease cbx_7378729265c2: fresh public/no-role/no-Tailscale checkout at exact head, frozen install, 120 focused tests passed; lease released.
  • The trusted untrusted-code bootstrap required umask 022 to be prepended because the current AWS image otherwise creates its root-owned Node install unreadable to the crabbox user; no PR code was changed for the workaround.
  • Assertion safety baseline pruned by the repository tool from 13,295 to 13,293 after removing two local assertions.
  • Production delta: +11 / -17, net -6 lines. Tests: +29 lines.

@vincentkoc vincentkoc self-assigned this Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 26, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 26, 2026 18:14
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 1:25 AM ET / 05:25 UTC.

ClawSweeper review

What this changes

The branch centralizes direct reads of an error’s cause property for unhandled-rejection classification and provider-operation retries, adding focused helper-contract tests.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No introduced functional or security defect was found. This MEMBER-authored PR remains open for explicit maintainer handling after exact-head required checks complete.

Priority: P3
Reviewed head: 18072a2030eb0b1efbf70f302c7afb9a33c27902
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A clean, net-negative duplicate consolidation with focused contract coverage and no identified correctness or security issue.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored behavior-neutral internal refactor has no changed user flow requiring contributor real-behavior proof; the PR body’s focused-test and isolated-checkout assertions are supplemental evidence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored behavior-neutral internal refactor has no changed user flow requiring contributor real-behavior proof; the PR body’s focused-test and isolated-checkout assertions are supplemental evidence.
Evidence reviewed 6 items Introduced implementation: The shared reader has the same non-null-object guard and direct property access as each removed local reader; it is now the single owner for both callers.
Caller and sibling behavior: Unhandled-rejection classification reads the direct cause only after its direct code is absent, while provider retry retains its existing self-cycle guards outside the shared reader.
Focused contract coverage: Added tests cover absent, null, arbitrary, self-referential, primitive, function, and throwing-accessor inputs, preserving the intentional direct-access behavior.
Findings None None.
Security None None.

How this fits together

OpenClaw’s shared error utilities feed process-level fault classification and provider retry decisions. These consumers use error metadata to choose either terminal handling or a bounded retry.

flowchart LR
  A[Runtime error] --> B[Shared error utilities]
  B --> C[Direct cause reader]
  C --> D[Unhandled rejection classification]
  C --> E[Provider retry decision]
  D --> F[Process outcome]
  E --> G[Retry or surfaced failure]
Loading

Decision needed

Question Recommendation
After required checks complete, should this behavior-neutral MEMBER-authored refactor be approved for merge? Approve after exact-head checks: Confirm the current head’s required checks and latest review disposition, then approve the duplicate-removal refactor.

Why: The protected maintainer label and MEMBER authorship require explicit maintainer handling even though the reviewed patch has no actionable defect.

Before merge

  • Resolve merge risk (P1) - The supplied exact-head check rollup is incomplete, and two filtered comment bodies (including the newest ClawSweeper comment) could not be refreshed because the GitHub endpoint was unavailable; confirm required checks and any current rank-up disposition before merge.
  • Complete next step (P2) - Explicit maintainer handling is required by the author association and protected label; no repair job is warranted because no actionable defect was found.
Agent review details

Security

None.

PR surface

Source -6, Tests +29, Other 0. Total +23 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 11 17 -6
Tests 1 29 0 +29
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 2 0
Total 5 42 19 +23

Review metrics

Metric Value Why it matters
Production versus tests production +11/-17 (net -6); tests +29; baseline metadata 0 net The patch removes two production copies of the reader and adds focused contract cases without expanding product behavior.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain one narrowly scoped direct cause-reader in the shared error utility and merge only after a maintainer confirms the exact head meets repository gates.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain one narrowly scoped direct cause-reader in the shared error utility and merge only after a maintainer confirms the exact head meets repository gates.

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

Not applicable: this PR consolidates an internal helper rather than reporting a user-facing defect.

Is this the best way to solve the issue?

Yes. The shared error utility is the existing owner of adjacent error readers, and keeping self-cycle and graph-traversal policy in the consumers preserves their distinct responsibilities.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0ee6e0575a90.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P3: This is a small internal duplicate-removal refactor with no intended user-visible behavior change.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored behavior-neutral internal refactor has no changed user flow requiring contributor real-behavior proof; the PR body’s focused-test and isolated-checkout assertions are supplemental evidence.

Evidence

What I checked:

  • Introduced implementation: The shared reader has the same non-null-object guard and direct property access as each removed local reader; it is now the single owner for both callers. (src/infra/errors.ts:28, 18072a2030eb)
  • Caller and sibling behavior: Unhandled-rejection classification reads the direct cause only after its direct code is absent, while provider retry retains its existing self-cycle guards outside the shared reader. (src/provider-runtime/operation-retry.ts:116, 18072a2030eb)
  • Focused contract coverage: Added tests cover absent, null, arbitrary, self-referential, primitive, function, and throwing-accessor inputs, preserving the intentional direct-access behavior. (src/infra/errors.test.ts:41, 18072a2030eb)
  • Current-main comparison: Current main still contains both local readers and has no shared reader in the error utility, so the central refactor is not already implemented or superseded. (src/infra/errors.ts:20, 0ee6e0575a90)
  • PR provenance: The code change is commit 5378e0b; its raw recorded parent is the verified merge base, while the exact head commit only refreshes PR checks. (src/infra/errors.ts:28, 5378e0b61f8a)
  • Scope boundary: The introduced imports are OpenClaw-local error utilities; the patch does not import, execute, test against, or claim compatibility with a Codex runtime, harness, or protocol. (src/provider-runtime/operation-retry.ts:3, 18072a2030eb)

Likely related people:

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

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-26T18:26:07.294Z sha b6c7b1e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T03:58:34.051Z sha 32a0412 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T04:32:29.631Z sha 5378e0b :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc force-pushed the refactor/shared-error-cause-reader branch from 32a0412 to 5378e0b Compare August 31, 2026 04:26
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 31, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

Land-ready verification for exact head 18072a2030eb0b1efbf70f302c7afb9a33c27902:

  • Production: +11/-17 (net -6). Tests: +29. Assertion baseline metadata: +2/-2.
  • scripts/pr review-tests 130280 src/infra/errors.test.ts src/infra/unhandled-rejections.test.ts src/infra/unhandled-rejections.fatal-detection.test.ts src/provider-runtime/operation-retry.test.ts: 120 passed.
  • Fresh pinned gpt-5.6-sol/high autoreview in branch mode: scoped-clean, 0.99 confidence.
  • Exact-head CI: 184 passed, 46 skipped, 0 failed in https://github.com/openclaw/openclaw/actions/runs/33360131896. build-artifacts, the final Node shard, and openclaw/ci-gate all passed.
  • The previous five red checks were one stale-base Control UI CSS budget failure. fix(ui): restore attachment stylesheet build budget #133796 repaired it without raising the 53.5 KiB cap and merged-main UI proof passed.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 130280: passed with gates_mode=hosted_exact_or_recent_parent.
  • scripts/pr merge-verify 130280: passed. Moving main changed a different assertion-baseline row; the production/test patch remains conflict-free and unchanged.
  • Latest ClawSweeper review covers this exact head, reports no findings or security issue, and its remaining exact-check/maintainer-handling items are satisfied.
  • Mandatory Codex source inspection completed at ../codex/codex-rs/cli/src/main.rs:220-245 and ../codex/codex-rs/cli/src/main.rs:2840-2870; those CLI/completion paths are unrelated to this internal error-helper refactor.

No known proof gaps.

@vincentkoc
vincentkoc merged commit ffa8360 into main Aug 31, 2026
234 checks passed
@vincentkoc
vincentkoc deleted the refactor/shared-error-cause-reader branch August 31, 2026 05:38
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 1, 2026
* refactor(infra): share error cause reader

* chore: refresh PR checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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