Skip to content

refactor(plugins): reuse SDK error coercion in seven callback owners - #119451

Merged
steipete merged 1 commit into
mainfrom
codex/loc-0804-cross-plugin-errors-luem8u
Aug 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/loc-0804-cross-plugin-errors-luem8u

Conversation

@steipete

@steipete steipete commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Seven bundled plugins independently implemented identical error-to-Error conversion, creating unnecessary maintenance overhead and allowing error handling to drift across ACPX, Copilot, Discord, LINE, memory, QA, and WhatsApp integrations.

Why This Change Was Made

Reuse the existing public openclaw/plugin-sdk/error-runtime toErrorObject helper in all seven plugins and remove their byte-for-byte equivalent local conversion helpers. This preserves existing Error identity, string conversion, structured causes, and copied error fields without adding dependencies, changing plugin boundaries, modifying configuration, or introducing compatibility paths.

User Impact

No intended user-visible behavior change. Plugin failures continue to preserve their existing error details while production code decreases by 90 lines (+20/-110) across seven production files; no tests were changed.

Evidence

  • Required gpt-5.6-sol/xhigh autoreview completed with no actionable findings.
  • Full unchanged remote pnpm check:changed passed, including plugin-boundary and SDK-contract checks, all production/full-tree/script dead-export scans, plugin and plugin-test typechecks, changed-file lint, repository architecture guards, and zero runtime import cycles.
  • Grouped existing suites covering the canonical helper and all seven plugins reported 245 passed / 5 failed. The five failures are existing WhatsApp credential-persistence test-fixture failures, not failures in the changed error-handling paths.
  • Restoring the WhatsApp production file to exact clean HEAD on the same remote Testbox reproduced the exact same five failures: 35 passed / 5 failed. The candidate file was restored byte-for-byte afterward.
  • Both existing WhatsApp disconnect/error tests directly exercising the changed error conversion passed separately: 2 passed / 0 failed. The remaining 38 unrelated tests were explicitly skipped by the focused name filter; no test was modified, weakened, or represented as passing when it failed.
  • Other grouped suites passed: canonical error coercion 8, ACPX 3, Copilot 39, Discord 7, LINE 32, memory-core 110, and QA channel 11.
  • Remote proof: https://github.com/openclaw/openclaw/actions/runs/30970898298

Named Follow-up

Update the stale WhatsApp credential-persistence test mocks: they assume string fs.open flags while hydrated @openclaw/fs-safe uses numeric flags. The unrelated grouped failures were reproduced identically on clean HEAD; repair belongs to the WhatsApp filesystem-fixture owner and is intentionally not bundled into this production-only error-coercion refactor.

Explicitly bounded seven-plugin callback scope

This change intentionally covers exactly seven SDK-capable, non-auth plugin callback/lifecycle owners: ACPX, Copilot, Discord, LINE, Memory Core, QA Channel, and WhatsApp. Every changed owner already uses public plugin-SDK entrypoints, so replacing its inline coercion copy introduces no new architectural dependency boundary.

Four independently owned production helpers remain explicitly out of scope:

  • The Lobster embedded runner currently imports only Node builtins; introducing its first plugin-SDK runtime import would change its isolated runtime/loader boundary.
  • The OpenAI OAuth runtime is an authentication and credential-security owner explicitly excluded from this refactor.
  • The Codex approval/protocol surface is explicitly excluded by its owner and direct-upstream-inspection gate; it was deliberately neither changed nor judged.
  • The QA Lab suite owns a separately named, exported toQaErrorObject helper used by its source-checkout-only suite runtime. It is a different suite-domain owner/API, not one of the seven inline callback owners.

These are intentional architectural/authorization scope exclusions, not overlooked migration targets. The related review finding is resolved by narrowing both the PR title and its claimed scope rather than expanding into authentication, approval, isolated-runtime, or separately exported QA ownership.

Exact-head bundled-plugin callback runtime proof

The unchanged exact reviewed Discord plugin gateway module was imported through its actual installed public SDK error, runtime-environment, and SSRF entrypoints. Its real waitForDiscordGatewayStop/registerForceStop production callback was invoked with synthetic in-memory gateway events; no real credentials, account, external service, or operator gateway was touched.

{
  "head":"bcdf40f49d3e52346851274da087a5af03ae7a22",
  "productionPlugin":"extensions/discord/src/monitor.gateway.ts",
  "entrypoint":"waitForDiscordGatewayStop/registerForceStop",
  "publicPluginSdk":["openclaw/plugin-sdk/error-runtime","openclaw/plugin-sdk/runtime-env","openclaw/plugin-sdk/ssrf-runtime"],
  "observations":[
    {"label":"error","message":"gateway stopped","sameIdentity":true,"causeIdentity":false,"code":"E_ORIGINAL","status":null,"disconnects":1,"detaches":1},
    {"label":"string","message":"connection closed","sameIdentity":false,"causeIdentity":false,"code":null,"status":null,"disconnects":1,"detaches":1},
    {"label":"structured","message":"Non-Error rejection","sameIdentity":false,"causeIdentity":true,"code":"E_DISCORD_GATEWAY","status":503,"disconnects":1,"detaches":1}
  ]
}

The actual canonical public SDK path preserves existing Error identity, string messages, structured cause/error metadata, and exactly-once disconnect/detach cleanup. Hosted exact-head CI and ci-gate passed after one unrelated retry of a known managed Git subprocess cleanup race. Named follow-up: investigate the independent live-updater managed fast-forward process-group teardown race without weakening process cleanup guarantees.

ClawSweeper rank-up disposition: the remaining-helper finding is explicitly addressed by the narrow seven-owner title/scope and documented owner-boundary exclusions; the requested real bundled-plugin runtime transcript is supplied above. The reviewed Git head is unchanged, so root policy requires no additional bot re-review.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: line Channel integration: line channel: whatsapp-web Channel integration: whatsapp-web extensions: memory-core Extension: memory-core extensions: acpx channel: qa-channel Channel integration: qa-channel extensions: copilot size: S maintainer Maintainer-authored PR labels Aug 5, 2026
@steipete
steipete marked this pull request as ready for review August 5, 2026 03:14
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 4, 2026, 11:21 PM ET / August 5, 2026, 03:21 UTC.

ClawSweeper review

What this changes

The PR replaces seven bundled plugins’ duplicate thrown-value-to-Error helpers with the public openclaw/plugin-sdk/error-runtime helper.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 4 items remain

Keep open: the seven substitutions preserve behavior exactly, but the refactor leaves at least two identical non-Codex production helpers, so it does not yet establish one canonical coercion path. The external-PR proof is also test/CI-only rather than after-fix runtime evidence.

Priority: P3
Reviewed head: bcdf40f49d3e52346851274da087a5af03ae7a22

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The substitutions are semantically sound, but the cleanup is incomplete and the available proof is limited to tests and CI.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body provides remote test and CI results, but no after-fix runtime evidence from a real plugin setup; any posted evidence should redact private endpoints, credentials, and identifiers. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body provides remote test and CI results, but no after-fix runtime evidence from a real plugin setup; any posted evidence should redact private endpoints, credentials, and identifiers. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Canonical contract: The shared helper preserves Error identity, creates an Error for strings, and retains non-Error causes plus enumerable fields—the same semantics as every removed helper.
Public plugin boundary: The helper is re-exported by the focused public error-runtime SDK entry point, which is declared in package exports and the SDK entrypoint list.
Existing contract coverage: Tests cover Error identity, string conversion, structured fields, and cause preservation.
Findings 1 actionable finding [P2] Migrate the remaining identical coercion helpers
Security None None.

How this fits together

Bundled channel and provider plugins normalize arbitrary callback and lifecycle failures before passing them into transport shutdown, webhooks, agent streaming, and memory-provider cleanup. The Plugin SDK exposes this shared conversion without plugins importing core internals.

flowchart LR
A[Callback or lifecycle failure] --> B[Bundled plugin]
B --> C[Plugin SDK error helper]
C --> D[Normalized Error]
D --> E[Channel or runtime outcome]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body provides remote test and CI results, but no after-fix runtime evidence from a real plugin setup; any posted evidence should redact private endpoints, credentials, and identifiers. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Migrate the remaining identical coercion helpers (P2) - This import establishes the canonical SDK path, but at least two non-Codex production modules still contain the exact same local helper: extensions/lobster/src/lobster-runner.ts:347 and extensions/openai/openai-chatgpt-oauth-flow.runtime.ts:359. Migrate them in this refactor or explicitly narrow its scope; otherwise the duplication and drift source remain.
  • Resolve merge risk (P1) - No after-fix runtime evidence from an installed plugin setup was available; the reported Testbox suites and CI are supplemental proof only.
  • Complete next step (P2) - The protected maintainer label keeps this PR in human review; ClawSweeper should not open an automated repair lane for it.

Findings

  • [P2] Migrate the remaining identical coercion helpers — extensions/acpx/src/runtime-turn.ts:5
Agent review details

Security

None.

PR surface

Source -90. Total -90 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 7 20 110 -90
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 20 110 -90

Review metrics

Metric Value Why it matters
Production versus test LOC production -90, tests 0 The submitted seven-file cleanup is net-negative production code, but its canonicalization goal remains incomplete.

Stored data model

Persistent data-model change detected: serialized state: extensions/whatsapp/src/session.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Migrate the remaining identical production helpers to the existing SDK helper, then attach a redacted after-fix plugin runtime transcript or obtain a maintainer proof override.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Migrate the remaining identical production helpers to the existing SDK helper, then attach a redacted after-fix plugin runtime transcript or obtain a maintainer proof override.

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

Not applicable: this is a behavior-preserving internal refactor, and direct source comparison establishes the relevant semantics.

Is this the best way to solve the issue?

No: the seven replacements are exact, but the best owner-boundary fix also removes the remaining identical non-Codex production copies through the same public SDK helper.

Full review comments:

  • [P2] Migrate the remaining identical coercion helpers — extensions/acpx/src/runtime-turn.ts:5
    This import establishes the canonical SDK path, but at least two non-Codex production modules still contain the exact same local helper: extensions/lobster/src/lobster-runner.ts:347 and extensions/openai/openai-chatgpt-oauth-flow.runtime.ts:359. Migrate them in this refactor or explicitly narrow its scope; otherwise the duplication and drift source remain.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a low-risk internal cleanup with no intended user-visible behavior change.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides remote test and CI results, but no after-fix runtime evidence from a real plugin setup; any posted evidence should redact private endpoints, credentials, and identifiers. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P3: This is a low-risk internal cleanup with no intended user-visible behavior change.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides remote test and CI results, but no after-fix runtime evidence from a real plugin setup; any posted evidence should redact private endpoints, credentials, and identifiers. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Current blame attributes the canonical coercion implementation and the affected duplicate helpers to the same shared-area commit. (role: recent shared-error contributor; confidence: medium; commits: 6293b54250fc; files: packages/normalization-core/src/error-coercion.ts, src/plugin-sdk/error-runtime.ts)
  • steipete: Prior merged history includes the canonical error-coercion refactor and this PR continues that cleanup direction. (role: prior canonicalization contributor; confidence: medium; commits: 49cc59b1e88e; files: packages/normalization-core/src/error-coercion.ts, extensions/acpx/src/runtime-turn.ts)

Rank-up moves

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

  • Migrate the remaining identical production helpers or narrow the stated scope.
  • Add a redacted after-fix runtime transcript from a bundled plugin setup, then update the PR body for a fresh review.

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.

@steipete steipete changed the title refactor(plugins): reuse canonical error coercion refactor(plugins): reuse SDK error coercion in seven callback owners Aug 5, 2026
@steipete
steipete merged commit 60a8ec8 into main Aug 5, 2026
257 of 269 checks passed
@steipete
steipete deleted the codex/loc-0804-cross-plugin-errors-luem8u branch August 5, 2026 04:05
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

channel: discord Channel integration: discord channel: line Channel integration: line channel: qa-channel Channel integration: qa-channel channel: whatsapp-web Channel integration: whatsapp-web extensions: acpx extensions: copilot extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant