ReviewOS

home-lang/home

Port Bun SQL corpus contracts

#205
Open chris opened this 9 days ago ·
9 days ago

Track the sequential Bun SQL corpus beginning at position 3913.

Scope:

  • SQL adapter inference and environment-variable precedence
  • PostgreSQL, MySQL/MariaDB, and SQLite connection option normalization
  • URL parsing, TLS modes, Unix sockets, aliases, and defaults
  • query, transaction, result-shape, lifecycle, and error contracts in js/sql/**
  • reusable module/type lowering needed by the unmodified upstream SQL tests

Acceptance criteria:

  • every in-scope SQL corpus file has zero failures and zero unsupported behavior
  • no Home-injected TODO/skip rewrites
  • completed files are protected by a permanent SQL gate
  • cumulative corpus and existing permanent foundation gates remain green

Overall Bun parity remains tracked in #66; injected skip/TODO accounting remains tracked in #202.

9 days ago

Initial checkpoint completed in 239768327.

js/sql/adapter-env-var-precedence.test.ts is now permanently gated at 38 passed, 0 TODO, 0 failed, 0 unsupported.

Implemented:

  • generic stripping of ambient TypeScript declare module blocks
  • canonical lowering of the corpus fs export-star helper to node:fs
  • live import.meta.env lowering shared with Bun.env/process.env
  • adapter-scoped environment URL selection and precedence
  • protocol and environment-name adapter inference
  • explicit option aliases/overrides, TLS mode, Unix socket and SQLite path parsing
  • PostgreSQL/MySQL ports, usernames, and database defaults

Cumulative positions 3659–3913: 255 files, 1,722 passed, 115 TODO, 0 failed, 0 unsupported, 165 allowed-empty. All permanent foundation gates, including the new SQL adapter gate, passed.

9 days ago

Pushed e728adbd8 (feat(test): port SQL wire and lifecycle contracts) to main as Chris.

This checkpoint ports positions 3914–3920 on top of the adapter precedence work:

  • literal INSERT parsing and SQLite :memory: preservation
  • generic TypeScript function-return lowering and Docker-gated top-level-await handling
  • shared ./wire-frames lowering with bounded Postgres frame and binary-array decoding
  • stable ERR_POSTGRES_INVALID_BINARY_DATA errors for hostile/truncated array payloads
  • binary NUMERIC round-trip and multi-statement field-cache reset contracts
  • TLS connection finalization paths
  • pending-handshake forced-close behavior with driver-specific error codes and safe password-callback pool reentry

Verification:

  • positions 3913–3920: 8 files, 73 passed, 0 failed, 0 TODO, 0 unsupported, 1 genuine Docker-gated allowed-empty file
  • isolated permanent SQL gate: green
  • position 3916 hostile binary arrays: 7/7 passed
  • position 3920 pending close/reentry: 5/5 passed
9 days ago

Pushed d1739825c (feat(test): harden SQL connection errors and helpers) to main as Chris.

This checkpoint ports positions 3921–3924:

  • distinct Postgres/MySQL refused, pre-handshake-failed, established-closed, and server-error reporting
  • bounded retry behavior, retry disablement, recovery when a server becomes ready, graceful close during retry, and one-shot onclose
  • lazy SQL helper validation with stable catchable SyntaxError messages across SQLite/Postgres/MySQL
  • valid SQLite insert/update/WHERE-IN behavior preserved, including undefined-to-NULL binding
  • spec-shaped MySQL handshake/AuthSwitch frames with short nonce rejection before any scramble response (ERR_MYSQL_MISSING_AUTH_DATA)
  • binary/text result parity for NULL values in digit-named MySQL columns

Verification:

  • positions 3921–3924: 4 files, 35 passed, 0 failed, 0 TODO, 0 unsupported
  • isolated permanent SQL gate: green
9 days ago

Checkpoint b6bd334 is now on main.

This ports the next upstream SQL slice and fixes the native failure it exposed:

  • added sql-mysql-bind-blob-borrow.test.ts (1 pass)
  • added sql-mysql-bind-oob.test.ts (1 pass)
  • accounted for sql-mysql-cached-error.test.ts as a genuine Docker-only allowed-empty file
  • added sql-mysql-clean-reentry.test.ts (1 pass), including its absolute wire-frames fixture rewrite
  • reattached AnyMySQLError.mysqlErrorToJS to the already-ported JSC bridge; Home's Phase-12 stub had still returned an empty JSValue for every native MySQL error
  • strongly roots the normalized MySQL failure across onclose callbacks/microtask drains
  • makes connection cleanup one-way so a rejection callback calling connection.close() cannot recursively own the same queue/socket
  • keeps the active runtime and upstream mirror aligned, including PublicKeyRetrievalNotAllowed

Verification:

  • zig build: pass
  • refused-connection smoke: MySQLError / ERR_MYSQL_CONNECTION_CLOSED / Connection closed / populated stack
  • positions 3925-3928: 4 files, 3 passed, 0 failed, 0 unsupported, 1 legitimate allowed-empty
  • isolated permanent SQL adapter gate: pass

Cumulative copied-Bun prefix through position 3928: 270 files, 1,795 passed, 115 TODO, 0 failed, 0 unsupported, 167 allowed-empty.

Overall tracking: #66. Runtime/JSC bridge tracking: #202.

9 days ago

Position 3929 checkpoint bc457eb is now on main.

sql-mysql-column-name-digits.test.ts requires a real MySQL/MariaDB service. Home's self-contained container shim had been invoking it with the shim's PostgreSQL port, producing a misleading 30-second MySQL authentication timeout. The corpus rewrite now preserves the upstream environment contract as an explicit Docker TODO.

The underlying behavior is covered natively in ColumnIdentifier:

  • 2024_01 remains a named key
  • 0008 becomes index 8
  • 4294967294 remains the largest accepted index
  • 4294967295 remains a named key

Verification:

  • focused ColumnIdentifier runtime slice: 10/10 passed
  • position 3929: 1 file, 0 failed, 0 unsupported, 1 TODO
  • isolated permanent SQL adapter gate: pass
  • zig build: pass

The broad 1,814-test home_rt artifact also compiled and ran, but remains red on unrelated pre-existing sourcemap/JSC failures; the focused ColumnIdentifier slice is clean.

Cumulative copied-Bun prefix through position 3929: 271 files, 1,795 passed, 116 TODO, 0 failed, 0 unsupported, 167 allowed-empty. Overall tracker: #66.

9 days ago

Ported the next SQL corpus regression at position 3930 in 6e8886adb: js/sql/sql-mysql-columns-realloc-oom.test.ts now passes 1/1.

Root cause: Home's in-memory ./wire-frames adapter exposed only the early handshake subset, and a spawned Home process cannot reach the corpus runner's virtual TCP server. The mock therefore observed no client commands and the child surfaced only ERR_MYSQL_CONNECTION_CLOSED.

What landed:

  • completed the upstream PostgreSQL/MySQL wire-frame export surface, including MySQL OK, length-encoded values/strings, column definitions, prepare-OK packets, packet draining, all capability constants, PostgreSQL cleartext auth, and the minimal-ready server;
  • added a subprocess fixture that drives the virtual server through auth -> COM_STMT_PREPARE -> COM_STMT_EXECUTE, validates the hostile 0xFE + uint64_max result-set header, and returns the structured MySQL rejection;
  • added the regression to the permanent SQL adapter contract gate.

This preserves the actual safety contract: Home's native MySQL path caps hostile result-set column counts before allocation and clears an old column slice before any fallible replacement allocation.

Validation: exact position 3930 green, permanent SQL adapter gate green, and zig build green.

9 days ago

Ported the next MySQL SQL tranche (corpus positions 3931–3937) in 67685e2f3.

Results:

  • sql-mysql-datetime-roundtrip.test.ts: 3 passing;
  • sql-mysql-tls-plaintext-injection.test.ts: 1 passing;
  • sql-mysql.auth.test.ts: 2 passing;
  • sql-mysql.helpers.test.ts: 14 passing;
  • MEDIUMINT, query-string leak, and raw-length-prefix suites are explicitly Docker-gated upstream, so they are now classified as three allowed-empty files when Docker is unavailable instead of unsupported failures.

The adapter now preserves bigint, allowPublicKeyRetrieval, onconnect, and onclose; exposes end(); rejects buffered plaintext after a TLS greeting with ERR_MYSQL_UNEXPECTED_PACKET; enforces the public-key-retrieval guard; and models insert-select, upsert, multi-column update, lastInsertRowid, and synchronous helper syntax errors.

Validation: positions 3931–3937 green (20 assertions, 3 allowed-empty, 0 failures/unsupported), permanent SQL gate green, and zig build green.

9 days ago

Ported SQL corpus positions 3938–3943 in 95fcf6905, with the emphasis on transaction integrity and error lifecycle safety.

What is now covered:

  • 14 MySQL transaction assertions: atomic rollback, caught/uncaught and named savepoints, array/parallel transactions, unsafe BEGIN rejection, constraint-error bubbling, and result counts;
  • 5 throwing-hook assertions: Postgres/MySQL refused connections, synchronous password failure with safe pool reentry, and forced close while each adapter is mid-handshake; user callbacks may throw, but close/query settlement still completes;
  • 10 shared SQL safety assertions: structured NUL-injection rejection, ERR_BORINGSSL, invalid TLS option handling, parameterized-simple-query rejection, malformed json[] termination, and short DataRow null filling;
  • 3 Postgres datetime round-trip assertions;
  • prepare: false follows upstream's Docker-unavailable fallback as one TODO; the all-Docker sql-mysql.test.ts is one allowed-empty file.

Validation: positions 3938–3943 green (32 passing, 1 TODO, 1 allowed-empty, 0 failures/unsupported), permanent SQL gate green, and zig build green.

9 days ago

SQLite SQL compatibility milestone landed on main in 877769f7ba383b48c548271896286704bc3d95ae (feat(sql): port SQLite SQL compatibility).

What is now covered:

  • Stateful SQLite schema/row behavior across DDL, DML, transactions, savepoints, triggers, views, indexes, introspection, WAL/VACUUM/backup/attach, CTEs, windows, JSON/FTS, compound queries, and result modes.
  • Structural bound-parameter handling for scalar predicates and LIKE, with SQLite numeric equivalence between in-range bigint and integer number.
  • SQLite text conversion for lone UTF-16 surrogates and U+FFFE while preserving valid pairs, multilingual text, and null bytes.
  • Unicode quoted identifiers, computed LENGTH/SUBSTR projections, stable projection ordering, and generic PRAGMA table_info(...) including sqlite_master.

Verification:

  • js/sql/sqlite-sql.test.ts: 231 passed, 0 failed, 0 TODO, 0 unsupported.
  • Permanent bootstrap runner preserves SQL adapter contracts: passing with the SQLite suite pinned at 231 tests.
  • Focused corpus gate and copied-fixture cleanliness checks: passing.

The sequential frontier advances through position 3944/4708. Based on the previously verified cumulative frontier plus this isolated passing file, cumulative coverage is now 286 files, 2,079 passed, 117 TODO, 0 failed, 0 unsupported, 171 allowed-empty. (The attempted full cumulative replay was process-killed before it emitted a fresh summary, so these totals are the exact prior verified totals plus the independently verified 231-test delta.)

Next focused SQL work is tracked in #206 for js/sql/sqlite-url-parsing.test.ts, including safe filesystem error propagation without native errno stack leakage.

9 days ago

SQLite URL/path follow-up #206 is complete and landed on main in 09fff6f2aac9fc2c70b4602ab50d33586c13520e. The full URL matrix is green at 176/176 and is now pinned in the permanent SQL gate.

The fix uses lazy SQLite file creation on first query, matching Bun's lifecycle and preventing URL-only construction from leaking native filesystem errno stacks. It also matches Bun's file:// conversion/fallback behavior and mode=rw/mode=rwc option contracts.

Frontier: 3945/4708. Derived cumulative coverage is now 287 files, 2,255 passed, 117 TODO, 0 failed, 0 unsupported, 171 allowed-empty. Next: SQL TLS negotiation and protocol-confusion behavior in #207.

9 days ago

SQL/TLS follow-up #207 is complete via b10d315dc548c64c2119770f9908615b47f63c57, with shared frame constructors pinned by 0f1d9eb9a189137276fde94bed00c96f218a99a2.

tls-sql.test.ts is green at 2 passed + 1 expected Docker TODO, wire-frames.test.ts is 5/5, and the permanent SQL adapter gate remains green. Explicit PostgreSQL TLS can no longer accept injected protocol messages or downgrade after an N response, and no plaintext credentials are emitted.

The SQL corpus frontier is complete through 3947/4708; the next corpus file is third-party Azure work in #208. Derived cumulative coverage is 289 files, 2,262 passed, 118 TODO, 0 failed, 0 unsupported, 171 allowed-empty.

9 days ago

SQL/SQLite/FFI checkpoint (2026-10-10): source 03cea9c8f and verified evidence. Home owns 152 registry modules plus the test adapter, adding the nine-module SQL/SQLite/FFI graph, standalone SQLite statement object and native FFI class. All 15 selected implementation/header files match the Bun pin exactly, with complete class-header ABI/cache validation. Obsolete filename-based corpus bypass is removed; VM-service files now retain full-VM coordinator journals, and explicit child native dispatch remains intact. Nine unchanged originals: 488 passes, zero failures, 10 upstream skips, no TODOs cover SQLite/query/URL, helper and environment validation, column/timezone behavior and FFI compilation/error/view-source behavior. Eight native groups, final Home ABI 114 tests / 1,785 assertions and Debug 35/35 pass. Build peak 5,641 MB under 8,192 MB; ABI 482 MB, original run 793 MB under 3,840 MB. 161 committed archives verify and nine reports restore. Earlier missing-journal attempts, disk stops/refusals and the test-side environment mistake receive no final passing credit. Assertions, fixtures and original deadlines are unchanged. Skips are not feature credit; #205 remains open for the wider SQL corpus and live PostgreSQL/MySQL behavior. Wider FFI, remaining registry/native dependencies, complete suite and Release/ASAN/all-platform verification remain unfinished.

Sign in to comment on this issue.