Repository navigation
fix(state): retain native codes in database verification errors - #138095
Conversation
Preserve native diagnostic codes for operators investigating background SQLite verification failures. Keep the original message, verification verdict, and storage behavior unchanged. Fixes #138067.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 5:31 AM ET / 09:31 UTC. ClawSweeper reviewWhat this changesThe PR adds bounded Node Merge readiness⛔ Blocked before merge - 5 items remain Keep open. This is a focused candidate fix for the paired open bug and no introduced correctness defect was found; merge remains a maintainer checkpoint because this review environment could not independently retrieve the upstream Node/SQLite contract sources. Priority: P2 Review scores
Verification
How this fits togetherThe background database verifier prepares database files read-only, checks integrity, and sends per-database results to the Gateway. This change enriches failure diagnostics after classification, while the existing owner still decides whether a failure is inconclusive or quarantine-worthy. flowchart LR
A[Database file] --> B[Read-only preparation]
B --> C[Background verifier]
C --> D[Integrity classification]
D --> E[Bounded diagnostic formatter]
E --> F[Gateway verification result]
Decision needed
Why: The introduced logic depends on native Before merge
Agent review detailsSecurityNone. PR surfaceSource +27, Tests +209, Docs +2. Total +238 across 4 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the focused formatter at the verifier result boundary, preserve its existing classification and cleanup flow, and record a maintainer-confirmed Node/SQLite contract check before merge. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: current main and stable v2026.8.2 both format verifier failures as name plus message only, while the added synthetic IPC test identifies the exact missing fields. The review did not execute it because the target checkout must remain read-only. Is this the best way to solve the issue? Yes, subject to upstream contract confirmation: formatting after the existing classification preserves terminal behavior, while the shared formatter would emit cause prose and requires a redaction policy that this worker does not own. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e0c230789b33. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Maintainer verification for exact head The dependency-inspection item in ClawSweeper's review is resolved by direct source inspection, not waived. I personally read Node v24.20.0's error constructors, its backup error handlers, and the equivalent v22.22.3 code, plus the installed SQLite types and SQLite result-code documentation. Node stores the string code and integer errcode separately from message text. The formatter preserves those bounded fields without reclassifying the error or interpreting generic IOERR as disk exhaustion. The public v2026.9.1 tag was also rechecked and resolves to Validation: env -u LIVE -u OPENCLAW_LIVE_TEST -u OPENCLAW_LIVE_GATEWAY -u OPENCLAW_LIVE_USE_REAL_HOME node scripts/run-vitest.mjs src/state/openclaw-database-verify.test.ts src/state/openclaw-database-verify.process.test.ts src/infra/sqlite-integrity.test.ts52 tests passed, with failing-before/passing-after regression proof. The built worker also passed a real synthetic IPC probe: native pnpm build qaRuntimeRuntime build and normal postbuild validation passed. The full local declaration build was rejected by its unchanged dependency-input stability fence; that limitation remains documented in the PR body. The clean CI artifact build passed for this exact head. node scripts/check-changed.mjs -- docs/reference/database-schemas.md src/infra/sqlite-error-diagnostics.ts src/state/openclaw-database-verify.process.test.ts src/state/openclaw-database-verify.worker.tsThe complete changed gate passed on an unchanged retry after the documented local process-cleanup failure. Fresh independent Codex review was scoped-clean with no findings, and normal commit hooks preserved the reviewed candidate. CI run 33855067053, attempt 1 and the required |
|
Merged via squash.
|
Reuse the existing SQLite error-code suffix helper in the snapshot worker while preserving its base message and every worker envelope, exit, classification, and cleanup contract. Remove the duplicated bounded extraction policy without adding API or test seams. Related: snapshot diagnostics #137999 and verifier diagnostics #138095. Production +4/-27; tests unchanged. Focused boundary suites, byte-equivalent synthetic process captures, changed checks, full build, and Codex autoreview passed.
…claw#138095) Preserve native diagnostic codes for operators investigating background SQLite verification failures. Keep the original message, verification verdict, and storage behavior unchanged. Fixes openclaw#138067.
…8520) Reuse the existing SQLite error-code suffix helper in the snapshot worker while preserving its base message and every worker envelope, exit, classification, and cleanup contract. Remove the duplicated bounded extraction policy without adding API or test seams. Related: snapshot diagnostics openclaw#137999 and verifier diagnostics openclaw#138095. Production +4/-27; tests unchanged. Focused boundary suites, byte-equivalent synthetic process captures, changed checks, full build, and Codex autoreview passed.
Closes #138067
Additional instructions
This is a same-repository maintainer branch; maintainers can update it.
What Problem This Solves
Resolves a problem where operators investigating background database-verification failures receive only the error name and message, even though Node supplied a string
codeand a numeric SQLiteerrcode. The loss happens before the worker sends its result to the Gateway, so the original native distinction is unavailable in the verification diagnostic.Why This Change Was Made
Preserve the verifier's exact existing message prefix and append a small, I/O-free bounded code projection at the error-to-string boundary. The projection visits at most eight cause nodes, deduplicates admitted codes, limits string codes to 64 uppercase ASCII/digit/underscore characters, and admits only nonnegative signed-32-bit integer SQLite result codes. It does not serialize cause prose, stacks, SQL, aggregate members, or arbitrary metadata.
The verifier still classifies the original error before formatting. Both verification/preparation errors and close failures use the same formatter; an earlier verification failure continues to take precedence over a later close failure. Snapshot workers and all storage, schema, configuration, retention, concurrency, cleanup, serial execution, and IPC lifecycle behavior remain unchanged. No Node or dependency patch is involved.
The generic error formatter was rejected because it expands cause/structured prose, does not preserve SQLite
errcodeon Errors, and brings a logging-configuration dependency into this worker boundary. A dedicated pure projection keeps those concerns separate and can be reused without importing an executable worker.User Impact
Background database-verification diagnostics retain native codes needed for troubleshooting. They do not change corruption or quarantine decisions, and they do not interpret generic
disk I/O error/errcode=10as disk exhaustion. The database integrity guide documents that distinction.Production LOC: +28/-1 (net +27). Tests: +210/-1 (net +209). Documentation: +2/-0. The production growth is the bounded diagnostic capability; no new execution or persistence path is added.
Evidence
Before and after: real synthetic SQLite failure
A disposable non-SQLite file produces the native error
code=ERR_SQLITE_ERROR,errcode=26. Before the repair, the verifier returns:{"ok":false,"error":"Error: file is not a database","terminal":false}After the repair, including across the real compiled child-process IPC boundary:
{"ok":false,"error":"Error: file is not a database (code=ERR_SQLITE_ERROR, errcode=26)","terminal":false}The original source bytes remain unchanged. All data was synthetic, with isolated temporary home/state/cache roots; no operator state or Gateway was accessed. Native before/after proof ran on Node 24.20.0, with an additional candidate probe on Node 26.8.1.
Regression and contract proof
Tests were added before production changes: 16 expected missing-code failures and 27 passes on the original formatter. The repaired candidate passes 52 tests across the verifier and integrity suites. Coverage includes real compiled-child IPC, raw and wrapped I/O failures, extended codes, bounded/deep/cyclic causes, rejected metadata, unchanged original messages, close-error diagnostics, original-failure precedence, terminal classification, cleanup, existing WAL behavior, and quarantine behavior.
The complete changed gate passed. Its first run hit
EPROCESSGROUP_CLEANUP_FAILEDduring core-test typecheck teardown, without TypeScript diagnostics. The process group was confirmed absent and the lock released; the unchanged retry passed without weakening any guard. Separate focused type-aware lint and the canonical verifier-test typecheck shard also passed.Direct dependency inspection: Node v24.20.0 error construction, its backup error path, Node v22.22.3's equivalent error construction, and the installed Node SQLite types. SQLite's result-code contract distinguishes generic I/O errors from disk-full errors.
The existing formatter is present in stable
v2026.9.1; introduction provenance is not established. This PR repairs the diagnostic boundary rather than attributing the bug to a particular earlier change.Build and independent review
pnpm build qaRuntimepassed: runtime/worker compilation, plugin assets, import guards, runtime postbuild validation, and build stamps completed. A separate native probe of the builtdist/state/openclaw-database-verify.worker.jspassed on Node 24.20.0, preservingcode=ERR_SQLITE_ERROR,errcode=26, andterminal=false; the child closed, source bytes were unchanged, and operator state was untouched.The full
pnpm builddid not pass. After six successful declaration compiler groups, the compiler input-stability fence detected changed ctime on a shared ancestor@types/events/index.d.tsdependency. There was no TypeScript diagnostic or task-source change. Dependencies and guards were left unchanged; the runtime profile was then selected because this patch changes no SDK/declaration API. The required exact-head CI artifact build subsequently passed, as recorded below.Fresh pre-commit Codex autoreview completed successfully with
scoped-cleanand no findings; the lead accepted the unchanged candidate. Normal commit hooks passed and the committed four-file contents match that reviewed candidate.ClawSweeper review follow-up
The exact-head review found no patch defect and accepted the native behavior proof. Its sole before-merge item was direct dependency-contract inspection, which its review environment could not complete. That item is addressed by direct maintainer inspection:
ERR_SQLITE_ERRORseparately from the message and createserrcodefrom a C++int; the database overload readssqlite3_extended_errcode. The backup error handlers use those constructors. Node v22.22.3 has the equivalent construction. These sources were personally read, alongside the installed SQLite backup types and the retained native probes.The refreshed review's Rank-up move and maintainer decision requested native-contract confirmation or explicit acceptance of the recorded inspection. That request is fulfilled by the direct inspection above and the lead's land-ready confirmation. The additional production surface remains limited to the bounded verifier diagnostic projection. No code change or contract waiver was needed; native review artifacts validated for this exact head.
Exact-head CI completion
CI run 33855067053, attempt 1 completed successfully at
f12b17ab47bc6ffbc794cce4bf477858e119f8ea, including the required artifact build and final Windows test job.The repository watcher exited 0 with
GREENand zero pending checks. Temporary GitHub rate-limit and pagination-snapshot errors recovered within its normal bounded retries. No CI job reruns, source changes, or gate bypasses were needed. Native review setup, main-baseline inspection, PR-head inspection, artifact validation, and hosted preparation completed without rebasing.Landing
Merged through the native workflow as a1e8a18bb197. A pre-intent observation race stopped the first merge; the next request was rejected by GitHub with HTTP 405 because the base branch changed. After explicit operator approval, one native recovery attempt succeeded. The approved source head and landed verifier/helper/test contents match; no merge guard was weakened.
The native workflow posted merge completion, and the paired issue closed with landed proof. The task checkout is clean at the landed main commit; other checkouts and the separate snapshot-worker work were untouched.