Skip to content

fix: show why plugin state access fails after an update - #157004

Merged
steipete merged 3 commits into
mainfrom
upd/codex-catalog-plugin-state-open-failed-9-6
Sep 24, 2026
Merged

steipete merged 3 commits into
mainfrom
upd/codex-catalog-plugin-state-open-failed-9-6

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Refs #156930. Thanks @Fuma2013 for the report and the restart/foreground control evidence.

What Problem This Solves

Plugin-state failures appear in structured logs without their nested cause or the process that captured them, hiding why an older background reader rejects an upgraded database.

User Impact

Structured records now include bounded nested causes, native error codes/errno, and the capturing process ID, thread ID, and OpenClaw version. Operators can distinguish a schema-version refusal from a file-open failure. Existing credential redaction remains active; arbitrary error properties and stacks are excluded.

For the reported 9.5 companion / 9.6 Gateway skew, update and relaunch OpenClaw.app; a Gateway-only restart leaves the old app worker in place. The diagnostics change must ship in the next npm release; the separate macOS-only rebuild cannot update the installed CLI/Gateway package.

Why This Change Was Made

The tagged 9.5 app selects its signed private Node/OpenClaw payload, validates that payload against the app's version and build, and runs node worker; updating the external npm CLI does not replace it. The node-host plugin registry registers the same Codex catalog commands and keyed-state store. Its resident catalog reconciles every 30 seconds against the same profile's shared state database. Tagged 9.5 supports schema 17 and rechecks schema support even when reusing a read handle; 9.6 migrates the shared database to schema 18.

This establishes a version-skew mechanism consistent with a failing app-owned background reader, successful 9.6 foreground reads, and persistence across Gateway-only restarts. We have not captured the reporter's exact failing PID or nested cause, so this PR references the issue rather than claiming that attribution is independently proven.

The fix belongs to the plugin-state error and transport owners. One shared bounded cause serializer serves both worker transport and JSON logs; the existing canonical codec preserves typed/aggregate errors and now carries errno. JSON uses errorCode for native causes so OAuth-code redaction does not hide them; in-memory .code is unchanged. owner identifies where the plugin-state error was constructed, including the caller thread for pre-dispatch failures. No schema, migration, retention, or admission-policy changes.

Tagged source evidence

Evidence

  • Published npm 2026.9.5 → 2026.9.6, isolated Linux/Node 24.19 state and free ports: a 5,761-entry resident namespace migrated from schema 17 to 18; the 9.6 Gateway catalog, synchronous/asynchronous SDK reads, and native-rollout reconciliation succeeded. quick_check=ok; no background warning appeared during 65 seconds after readiness or the subsequent native-rollout restart probe.
  • The 9.5 SDK reading that same migrated store produced PLUGIN_STATE_OPEN_FAILED, operation entries, with nested SqliteSchemaVersionError: database schema 18, reader supports 17. This was an isolated reader reproduction, not a live capture of the reporter's macOS process.
  • Logging regressions failed before the fix. They exercise the real JSONL sink after worker capture/restore, native and canonical causes, cyclic aggregates, owner preservation, and bearer-token redaction. Focused run: 20/20 tests; approximately 165 ms test time, 30.02 s wrapper wall including 18.84 s compiler preparation. The existing real-worker error test also checks that worker identity survives restoration.
  • Committed-head importer selection: 14 Vitest shards passed in 608.40 s, with 77 files producing passing-test records. The two Gateway close suites omitted by multi-project selection then passed explicitly in the supported aggregate configuration: 85 tests, 23.76 s. The opt-in external live suite was not enabled. pnpm build exited 0 in 306.72 s; its UI report flagged a Mermaid gzip budget overage (1,555.8 KiB versus 960.0 KiB), not investigated in this lane. Fresh autoreview --mode branch --base origin/main found no actionable P0–P2 findings.
  • Pre-existing test performance is assigned to a separate follow-up: canonical-descendant.integration.test.ts passed 73 cases in 182.587 s of test time; the first server.codex-failure-recovery.test.ts case took 37.121 s. Both timing issues predate this change and are being handled in a separate performance follow-up. No tests were weakened, skipped, or retiered for this change.
  • Final committed-head check:changed passed on Testbox (exit 0, 25m 41.568s), including core types, all 25 core-test typecheck graphs, formatting, lint, schema/ownership guards, and zero runtime import cycles.
  • Production +115/−72 (net +43); tests +85/−1; docs +13/−2. The shared helper replaces the duplicated cause scanner.

Preserve bounded nested causes, native errno, and the process/thread/version that captured plugin-state errors in structured logs. Share cause capture with worker transport and document updating the private Mac app worker after a Gateway schema upgrade.

Refs #156930. Reported by @Fuma2013.
@clawsweeper

clawsweeper Bot commented Sep 24, 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 app: macos App: macos plugin: file-transfer size: M labels Sep 24, 2026
@steipete
steipete marked this pull request as ready for review September 24, 2026 04:21
@steipete
steipete enabled auto-merge (squash) September 24, 2026 04:26
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

The branch adds process and version identity and nested causes to plugin-state errors, carries them across the SQLite worker boundary, and documents recovery from an older macOS app worker reading an upgraded database.

Merge readiness

⛔ Blocked before merge - 11 items remain

Keep open: current main still lacks the requested diagnostics, while this head retains three actionable blockers from the prior review.

Priority: P2
Reviewed head: 4267928da54b9011d124d1801312692b6119367a

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The diagnostic direction and version-skew evidence are useful, but the unchanged security and transport findings make this patch unready to merge.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its published-version experiment supports the schema-skew mechanism and its tests exercise the JSONL sink after worker capture and restore, but no after-fix macOS background-process log is shown. No stored-data contract changes.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its published-version experiment supports the schema-skew mechanism and its tests exercise the JSONL sink after worker capture and restore, but no after-fix macOS background-process log is shown. No stored-data contract changes.
Evidence reviewed 8 items Current main still lacks the change: The current-main error class has no owner field or JSON cause projection; its worker transport retains the older error shape.
Introduced raw JSON projection: The new toJSON method places nested cause messages into any ordinary JSON serialization of this error.
Existing public-message boundary: The existing wrapper deliberately keeps cause messages out of the public error message because they can contain database paths, SQL, or stored values.
Findings 3 actionable findings [P1] Keep raw causes out of ordinary error JSON
[P1] Preserve redaction for unknown nested error codes
[P2] Bound ordinary aggregate graphs before worker transport
Security Needs attention Raw cause in ordinary JSON: The general-purpose error JSON method emits nested cause messages without requiring the file logger's redaction.
Unknown code bypasses code-field protection: Renaming every nested code to errorCode prevents the structured authorization-code rule from recognizing an unknown credential-shaped value.

How this fits together

OpenClaw plugins use a shared SQLite state database. Database errors cross a worker boundary to plugin callers and can then appear in structured operator logs.

flowchart LR
  A[Plugin state request] --> B[SQLite worker]
  B --> C{Read succeeds?}
  C -->|Yes| D[Plugin state result]
  C -->|No| E[Captured error and owner]
  E --> F[Caller error]
  F --> G[Redacted operator log]
Loading

Before merge

  • Keep raw causes out of ordinary error JSON (P1) - The new toJSON() runs for every JSON.stringify(error), including callers outside the redacted file logger. It emits nested cause messages that the existing wrapper deliberately excludes from its public message because they may contain paths, SQL, or stored values. Project those details at the redacted diagnostic sink instead.
  • Preserve redaction for unknown nested error codes (P1) - Copying every nested code to errorCode bypasses the existing authorization-code protection, which classifies the key code. The new log test covers EACCES but not an unknown or credential-shaped code. Retain diagnostic codes through a narrow allowlist and protect all others.
  • Bound ordinary aggregate graphs before worker transport (P2) - The introduced includeOrdinary call selects the canonical codec for any ordinary AggregateError; that codec maps its full errors array before the helper's eight-entry limit can run. A large aggregate therefore expands without a transport bound. Enforce the limit before encoding.
  • Resolve security concern: Raw cause in ordinary JSON - The general-purpose error JSON method emits nested cause messages without requiring the file logger's redaction.
  • Resolve security concern: Unknown code bypasses code-field protection - Renaming every nested code to errorCode prevents the structured authorization-code rule from recognizing an unknown credential-shaped value.
  • Resolve merge risk (P1) - Existing callers that serialize plugin-state errors as JSON would receive nested cause text outside the file logger's redaction boundary.
  • Resolve merge risk (P1) - Unknown nested error codes can enter structured logs under errorCode without the existing protection for code fields.
  • Resolve merge risk (P1) - An ordinary AggregateError with a large errors array can expand without a bound before crossing the worker transport.
  • Complete next step (P2) - Repair raw cause serialization, unknown-code redaction, and aggregate transport bounds before merge.
  • Improve patch quality - Keep nested causes out of ordinary error JSON and verify redaction at the diagnostic sink.
  • Improve patch quality - Allowlist emitted diagnostic codes and bound ordinary aggregate graphs before transport.

Findings

  • [P1] Keep raw causes out of ordinary error JSON — src/plugin-state/plugin-state-store.types.ts:205-214
  • [P1] Preserve redaction for unknown nested error codes — src/plugin-state/plugin-state-error-cause.ts:53-54
  • [P2] Bound ordinary aggregate graphs before worker transport — src/plugin-state/plugin-state-worker-errors.ts:55-56
  • [high] Raw cause in ordinary JSON — src/plugin-state/plugin-state-store.types.ts:213
  • [high] Unknown code bypasses code-field protection — src/plugin-state/plugin-state-error-cause.ts:54
Agent review details

Security

Needs attention: Two introduced cause-serialization paths can expose sensitive diagnostic content outside the intended redaction policy.

PR surface

Source +43, Tests +84, Docs +11. Total +138 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 115 72 +43
Tests 2 85 1 +84
Docs 2 13 2 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 213 75 +138

Review metrics

Metric Value Why it matters
Code growth production +43 net, tests +84 net The shared cause helper replaces an older scanner, but the added error serialization needs the safety repairs above.

Merge-risk options

Maintainer options:

  1. Repair diagnostic projection before merge (recommended)
    Keep raw causes out of ordinary error JSON, preserve protection for unknown codes, and bound aggregate graphs before worker transport.

Technical review

Best possible solution:

Project bounded, allowlisted cause details only at the redacted diagnostic boundary, while retaining worker origin on the in-memory error.

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

Yes for the diagnostic omission: current-main source and the reported published-version reader experiment establish a clear path. The reporter's exact macOS background process was not captured.

Is this the best way to solve the issue?

No. Worker origin is useful, but projecting raw causes from the error's general JSON method and bypassing code-field redaction is broader than the diagnostic need.

Full review comments:

  • [P1] Keep raw causes out of ordinary error JSON — src/plugin-state/plugin-state-store.types.ts:205-214
    The new toJSON() runs for every JSON.stringify(error), including callers outside the redacted file logger. It emits nested cause messages that the existing wrapper deliberately excludes from its public message because they may contain paths, SQL, or stored values. Project those details at the redacted diagnostic sink instead.
    Confidence: 0.97
  • [P1] Preserve redaction for unknown nested error codes — src/plugin-state/plugin-state-error-cause.ts:53-54
    Copying every nested code to errorCode bypasses the existing authorization-code protection, which classifies the key code. The new log test covers EACCES but not an unknown or credential-shaped code. Retain diagnostic codes through a narrow allowlist and protect all others.
    Confidence: 0.93
  • [P2] Bound ordinary aggregate graphs before worker transport — src/plugin-state/plugin-state-worker-errors.ts:55-56
    The introduced includeOrdinary call selects the canonical codec for any ordinary AggregateError; that codec maps its full errors array before the helper's eight-entry limit can run. A large aggregate therefore expands without a transport bound. Enforce the limit before encoding.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This improves diagnosis of a limited plugin-state update failure without evidence of a general runtime outage.
  • merge-risk: 🚨 compatibility: Adding toJSON changes what existing callers receive when they serialize a plugin-state error.
  • merge-risk: 🚨 security-boundary: The introduced JSON and code projections can expose cause text or unknown codes outside the intended redaction boundary.
  • merge-risk: 🚨 availability: The newly included ordinary aggregate graph has no bound before worker transport.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its published-version experiment supports the schema-skew mechanism and its tests exercise the JSONL sink after worker capture and restore, but no after-fix macOS background-process log is shown. No stored-data contract changes.

Evidence

Security concerns:

  • [high] Raw cause in ordinary JSON — src/plugin-state/plugin-state-store.types.ts:213
    The general-purpose error JSON method emits nested cause messages without requiring the file logger's redaction.
    Confidence: 0.97
  • [high] Unknown code bypasses code-field protection — src/plugin-state/plugin-state-error-cause.ts:54
    Renaming every nested code to errorCode prevents the structured authorization-code rule from recognizing an unknown credential-shaped value.
    Confidence: 0.93

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • Ayaan Zaidi: 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 (2 earlier review cycles)
  • reviewed 2026-09-24T04:28:58.352Z sha 0fad961 :: blocked before merge. :: [P1] Keep raw causes out of ordinary error JSON | [P2] Bound ordinary aggregate graphs before worker transport
  • reviewed 2026-09-24T12:47:42.295Z sha 3540938 :: blocked before merge. :: [P1] Keep raw causes out of ordinary error JSON | [P1] Preserve redaction for unknown nested error codes | [P2] Bound ordinary aggregate graphs before worker transport

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 24, 2026
@steipete
steipete merged commit 056f627 into main Sep 24, 2026
204 checks passed
@steipete
steipete deleted the upd/codex-catalog-plugin-state-open-failed-9-6 branch September 24, 2026 19:38
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
…#157004)

Preserve bounded nested causes, native errno, and the process/thread/version that captured plugin-state errors in structured logs. Share cause capture with worker transport and document updating the private Mac app worker after a Gateway schema upgrade.

Refs openclaw#156930. Reported by @Fuma2013.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos docs Improvements or additions to documentation merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant