Skip to content

fix(node:sqlite): publish query diagnostics - #212

Merged
steipete merged 2 commits into
mainfrom
claude/sqlite-query-diagnostics
Oct 26, 2026
Merged

steipete merged 2 commits into
mainfrom
claude/sqlite-query-diagnostics

Conversation

@steipete

@steipete steipete commented Oct 26, 2026 •

Copy link
Copy Markdown

The runtime reports Node 26.12.1 but did not publish sqlite.db.query. Consumers consequently enabled Node-version-gated diagnostics without receiving the event, including OpenClaw's same-query schema-read reentry test.

Publish through the public diagnostics channel from SQLite's native profile callback. Events are synchronous, including nested queries, with a null-prototype { sql, database, duration } payload: expanded SQL (source fallback), the exact database object and SQLite's nanosecond duration estimate. Subscriber transitions enable/disable tracing; prepare and partial iteration emit nothing, and finalization/GC suppresses events. Subscribers retain responsibility for bounding their own recursive instrumentation, matching Node.

Keep active statements guarded through cleanup resets, reject closing busy statements from authorizer callbacks, and preserve database/publisher lifetime and pending query errors during nested reads. Initialize the lazy next-tick function when tracing activates so stack-overflow errors retain the public channel's asynchronous delivery. Add the current constructor aliases and statement close/disposal support used by Node's unchanged feature tests.

Validation:

  • Official Node 26.12.1 source and oracle binaries verified against published SHA-256 checksums. All 12 unchanged Node feature tests pass on Node and the final production build.
  • Eight focused regressions pass, including 16-level synchronous nested queries, unguarded RangeError delivery, failed-query cleanup, authorizer safety and subscription transitions.
  • Surrounding SQLite and diagnostics-channel suites: 949 passed, with seven inherited platform skips and three inherited TODOs.
  • OpenClaw src/infra/sqlite-schema-contract.test.ts at 77d0f72273cb1aaeb21e8e84e6e0742d14de2c03: published S8 24 pass / 1 fail; final patched production build 25 pass / 0 fail / no skips, using isolated HOME/state and OPENCLAW_BUN_PATH.
  • Independent Codex review: P2 scoped-clean after resolving cleanup-reset and authorizer-finalization findings; the follow-up type annotation is also scoped-clean.
  • Exact-head native CI: Linux x64 and macOS arm64 passed on f5e7fda70b22f27dda67ff59493037d0ef043b91; the CI merge commit has exactly the same source tree. Format, source lint and JavaScript lint/typecheck also passed.

Linux production ThinLTO cost, ten alternating S8/patched pairs pinned to one CPU, 200,000 warmups and 5,000,000 measured prepared SELECT 42 AS answer calls per process:

Measurement Result
Published S8 median 59.6492 ns/query
Patched, no subscribers 59.3499 ns/query
Median paired ratio 0.99650, gate <=1.02
Ratio of medians 0.99498
Patched, subscribed (ten runs) 262.4756 ns/query
Subscribed / unsubscribed 4.42251x (+203.1256 ns/query)

Every subscribed run verified 5,000,000 events and correct SQL/database identity; all runs verified query results. No timing retries. The small unsubscribed difference is within normal noise, not claimed as a speedup. Baseline is published S8 at 5534724c02; final patched head is f5e7fda70b22f27dda67ff59493037d0ef043b91.

Reference: Node profile callback, subscriber transitions, and unchanged upstream tests. Upstream Bun searches found no matching diagnostics producer to port.

@steipete
steipete marked this pull request as ready for review October 26, 2026 04:50
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T04:53:02.614844Z f5e7fda Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete merged commit eb34581 into main Oct 26, 2026
6 checks passed
@steipete
steipete deleted the claude/sqlite-query-diagnostics branch October 26, 2026 04:52
steipete added a commit to openclaw/openclaw that referenced this pull request Oct 26, 2026
Capture SQLite query metadata before execution cleanup finalizes the statement. Keep one latest metadata snapshot per statement so history selectivity, bounded metadata reads, and nested anchor assertions remain unchanged.

Verified the original four failures on Node 26.12.1 and Bun with real disposal, then all four passing on both plus the baseline Bun revision. The 16-file session/cache/worker matrix passes on all three runtimes. No production use-after-dispose was found. Codex autoreview is clean.

Related: openclaw/bun#212
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…aw#185103)

Capture SQLite query metadata before execution cleanup finalizes the statement. Keep one latest metadata snapshot per statement so history selectivity, bounded metadata reads, and nested anchor assertions remain unchanged.

Verified the original four failures on Node 26.12.1 and Bun with real disposal, then all four passing on both plus the baseline Bun revision. The 16-file session/cache/worker matrix passes on all three runtimes. No production use-after-dispose was found. Codex autoreview is clean.

Related: openclaw/bun#212
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant