Skip to content

refactor(sqlite): share bounded worker error diagnostics - #138520

Merged
steipete merged 1 commit into
mainfrom
steipete/unruffled-davinci-154ced
Sep 4, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/unruffled-davinci-154ced

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Related: snapshot-worker diagnostic preservation and verifier diagnostic preservation.

Additional instructions

This is a same-repository maintainer-requested PR; maintainers can update the branch.

What Problem This Solves

SQLite snapshot and background-verifier diagnostics currently carry identical bounded suffix policies in two places. This maintainer-requested consolidation prevents those policies from drifting after the two diagnostic-preservation fixes above, without changing operator-visible behavior.

Why This Change Was Made

The snapshot worker now uses the existing formatSqliteErrorCodeSuffix helper and deletes its private formatter and copied extraction loop. It retains coerceErrorMessage(error) for its base text; the verifier keeps its existing name: message / String(error) base text. No helper or API is added.

The suffix still preserves traversal/insertion order, exact deduplication, at most eight cause nodes, code tokens matching /^[A-Z0-9_]{1,64}$/u, and numeric integer errcode values in 0..0x7fffffff. It adds no errstr, stack, cause prose, aggregate-member traversal, SQL, or arbitrary metadata. Both JSON/IPC envelopes, exit behavior, parent reconstruction, raw-error terminal classification, failure precedence, and cleanup remain unchanged.

Production LOC: +4/-27 (net -23). Tests: +0/-0; existing boundary coverage is retained rather than duplicated.

User Impact

None: diagnostic bytes and verdicts remain the same. There are no snapshot/storage/schema/configuration/retention/concurrency/Node/dependency changes. A generic disk I/O error still does not establish disk exhaustion.

Evidence

  • Before and after: 122 tests passed, with one existing Linux-only POSIX-lock probe skipped on macOS. The suites cover native corruption 11, constrained-write 778 through a cause, sync/async ENOENT, bounded projections, verifier IPC 26, raw-error classification, failure precedence, and cleanup.
  • Seven local real-process captures compared byte-for-byte: snapshot sync/async failures, parent reconstruction, native corruption and constrained-write errors, and verifier IPC for invalid/corrupt/missing/healthy synthetic files. Both captured datasets had SHA-256 76fddc1cb652116bbd94fe57c0fab8a587ed95c2f0c615c89d037a3273ed81f9. Synthetic source-file hashes were unchanged and private staging cleanup completed. No operator state or Gateway was accessed.
  • Formatting, production/test typechecks, targeted lint, dead-export scans, import-cycle checks, the complete changed-check wrapper, and the full local pnpm build passed. Codex autoreview returned scoped-clean with no P0 findings.
  • Directly inspected Node v24.20.0 src/node_sqlite.cc:173-225 and 614-638. Installed @types/node does not export SQLiteError; no dependency/type change is needed.

Focused test command:

node scripts/run-vitest.mjs src/infra/sqlite-readonly-location.test.ts src/infra/sqlite-readonly-location.worker.test.ts src/state/openclaw-database-verify.process.test.ts src/state/openclaw-database-verify.test.ts src/infra/sqlite-integrity.test.ts

Changed checks:

node scripts/check-changed.mjs -- src/infra/sqlite-readonly-location.worker.ts
git diff --check

Final maintainer review

Exact-head CI run 33909422678, attempt 1, completed successfully for e87dc59f30bfb77dad91d8f9229839a350fad3f7: 32 successful and 16 intentionally skipped jobs; the required openclaw/ci-gate is successful. The earlier draft-triggered run was skipped.

The ClawSweeper review has no correctness or security finding and recommends merging. Its final maintainer decision is satisfied by the explicit request to land this consolidation. Its requested migration/upgrade compatibility proof is not applicable: the sole changed file formats transient worker stdout; this diff changes no persisted table, schema version, stored representation, migration, or IPC envelope. The before/after boundary captures prove identical serialized diagnostics. No schema modification is being authorized or introduced.

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.
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 4, 2026 19:06
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Sep 4, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 3:36 PM ET / 19:36 UTC.

ClawSweeper review

What this changes

The PR replaces the read-only SQLite snapshot worker’s duplicate bounded error-code formatter with the shared SQLite diagnostic suffix helper.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/infra/sqlite-readonly-location.worker.ts. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open for final maintainer handling: the behavior-neutral consolidation is not on current main, preserves the established bounded diagnostic contract, and has no actionable correctness finding.

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

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, net-negative refactor that exactly consolidates an established policy with retained boundary coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: repository state identifies this as a member-authored maintainer request, so the external-contributor proof gate does not apply; the PR body nevertheless records real synthetic child-process captures for the unchanged worker boundary.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: repository state identifies this as a member-authored maintainer request, so the external-contributor proof gate does not apply; the PR body nevertheless records real synthetic child-process captures for the unchanged worker boundary.
Evidence reviewed 6 items Introduced worker change: The sole introduced hunk preserves the worker’s existing base message and appends the established shared suffix before writing the unchanged error envelope.
Shared-policy equivalence: The helper implements the same eight-node traversal, code-token validation, integer errcode validation, insertion-order deduplication, and parenthesized suffix previously local to the worker.
Caller and envelope boundary: The parent parses the worker’s strict result, converts an unsuccessful result into its existing error wrapper, and the PR does not alter that reconstruction path.
Findings None None.
Security None None.

How this fits together

The read-only SQLite worker prepares database snapshots in a child process and returns a compact JSON result to the parent snapshot flow. Its error formatter determines which bounded native error codes operators can see when preparation fails.

flowchart LR
  A[Snapshot request] --> B[Read-only SQLite worker]
  B --> C[SQLite preparation]
  C --> D{Success or error}
  D -->|success| E[Snapshot location]
  D -->|error| F[Bounded error suffix]
  F --> G[JSON error result]
  G --> H[Parent snapshot flow]
Loading

Decision needed

Question Recommendation
Should this protected, member-authored behavior-neutral refactor be merged after the final maintainer decision? Merge the consolidation: Adopt the shared helper so snapshot and verification workers no longer maintain duplicate bounded suffix policies.

Why: Repository policy keeps member-authored and maintainer-labeled items out of automated cleanup, even where the patch review is clean.

Before merge

  • Complete next step (P2) - A maintainer must make the final merge decision for this protected, member-authored PR.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -23. Total -23 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 4 27 -23
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 1 4 27 -23

Review metrics

Metric Value Why it matters
Production versus test LOC production -23, tests 0 The patch removes duplicate production policy without adding a new runtime, configuration, persistence, or API surface.

Stored data model

Persistent data-model change detected: serialized state: src/infra/sqlite-readonly-location.worker.ts, unknown-data-model-change: src/infra/sqlite-readonly-location.worker.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Merge the consolidation as the single shared bounded diagnostic-policy path while retaining the worker’s distinct base-message contract.

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

Not applicable: this is a behavior-preserving refactor, and the existing source tests plus documented synthetic subprocess captures cover the retained worker output contract.

Is this the best way to solve the issue?

Yes. Reusing the existing helper removes the duplicate policy while preserving the worker-specific base message and its strict JSON result boundary.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a low-risk internal cleanup that reduces maintenance drift without changing intended operator behavior.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: repository state identifies this as a member-authored maintainer request, so the external-contributor proof gate does not apply; the PR body nevertheless records real synthetic child-process captures for the unchanged worker boundary.

Label justifications:

  • P3: This is a low-risk internal cleanup that reduces maintenance drift without changing intended operator behavior.
  • 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: Not applicable: repository state identifies this as a member-authored maintainer request, so the external-contributor proof gate does not apply; the PR body nevertheless records real synthetic child-process captures for the unchanged worker boundary.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a1e8a18 adds src/infra/sqlite-error-diagnostics.ts:4 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a1e8a18bb197; files: src/infra/sqlite-error-diagnostics.ts)
  • 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.

@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready review for e87dc59f30bfb77dad91d8f9229839a350fad3f7.

The maintainer explicitly requested this consolidation and has now requested landing. The latest ClawSweeper review has no actionable correctness/security finding and recommends merge. Its migration-proof flag is not applicable: this one-file diff consolidates transient diagnostic formatting, not persisted SQLite tables or schema. No store/configuration/protocol/retention/concurrency/dependency behavior changes. The PR body now records this disposition.

Local proof passed before and after: 122 tests, with the existing Linux-only POSIX-lock probe skipped on macOS. Seven synthetic real-process captures were byte-identical across snapshot JSON, sync/async parent reconstruction, and verifier IPC; source hashes were unchanged and private staging cleanup completed. Existing coverage includes native corruption11, constrained-write778 through a cause, ENOENT, verifier native codes/classification, failure precedence and cleanup. No operator Gateway/state was accessed.

Exact local commands:

node scripts/run-vitest.mjs src/infra/sqlite-readonly-location.test.ts src/infra/sqlite-readonly-location.worker.test.ts src/state/openclaw-database-verify.process.test.ts src/state/openclaw-database-verify.test.ts src/infra/sqlite-integrity.test.ts
node scripts/check-changed.mjs -- src/infra/sqlite-readonly-location.worker.ts
pnpm build
git diff --check

All passed. Codex autoreview is scoped-clean with no P0 findings; the reviewed worker bytes still match this head. Exact-head CI run 33909422678, attempt 1, is successful (32 successful jobs, 16 intentionally skipped); the required openclaw/ci-gate is successful. No Testbox lease was needed: native preparation will verify the hosted exact-head result.

Production +4/-27 (net -23); tests +0/-0. Proceeding through the repository-native prepare/merge gates.

@steipete
steipete merged commit 43a7f62 into main Sep 4, 2026
168 of 176 checks passed
@steipete
steipete deleted the steipete/unruffled-davinci-154ced branch September 4, 2026 21:14
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…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.
steipete added a commit to openclaw/clawsweeper that referenced this pull request Sep 5, 2026
Require a persistence owner or same-hunk durable boundary before treating JSON conversion as stored state. Distinguish SQLite diagnostic helpers from real schema, store, codec, and compatibility owners without changing approval or migration-proof gates.

Reproduce the exact full and normalized patch from openclaw/openclaw#138520 and preserve twenty real-persistence controls in the offline detector-to-render proof.
steipete added a commit to openclaw/clawsweeper that referenced this pull request Sep 5, 2026
Require a persistence owner or same-hunk durable boundary before treating JSON conversion as stored state. Distinguish SQLite diagnostic helpers from real schema, store, codec, and compatibility owners without changing approval or migration-proof gates.

Reproduce the exact full and normalized patch from openclaw/openclaw#138520 and preserve twenty real-persistence controls in the offline detector-to-render proof.
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: XS 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