@voltro/testing 0.40.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/dist/dialect.js +251 -149
  3. package/package.json +8 -8
package/CHANGELOG.md CHANGED
@@ -39,6 +39,177 @@ _Changes staged for the next release accumulate here (rolled up from
39
39
 
40
40
  ---
41
41
 
42
+ ## [0.42.0] — 2026-08-17
43
+
44
+ ### ⚠ BREAKING
45
+
46
+ - **@voltro/cli, @voltro/data-transfer** — **Two security defects on the data-transfer surface, both found by using the feature rather than by reading it.**
47
+
48
+ **A `{ profile }` in an admin-export request could name a PATH.** `loadProfile` resolved the client's string with `resolve(cwd, x)` — which returns an absolute path unchanged and lets `../` traverse — and the resolved file is `await import()`ed, which RUNS it. So a holder of the data-transfer secret could make the api process execute any file on the pod: an escalation from "can export prod data" to "can run code", and chainable on an instance whose object storage is a filesystem the same caller can write to.
49
+
50
+ `POST /_voltro/admin/export` now accepts a NAME only — `[A-Za-z0-9_-]{1,64}`, resolved under `data-profiles/` and checked to be contained there. **Migration: if you passed a path over `--target api`, move the file to `data-profiles/<name>.ts` and pass `<name>`.** `voltro data export --profile` on a DIRECT target still accepts a path: it runs on the operator's own machine, where a path is not an escalation. No user-authored code changes, so `codemod: none`.
51
+
52
+ **An unrecognised masking action copied the value through.** `applyAction` ended in `return input.value`, so a profile with a typo in the action shape (`{ action: 'fake', kind: 'email' }` instead of `{ fake: 'email' }`) exported every row of a `.sensitive()` column verbatim — with a 200 and an audit line counting the column as masked. Measured against a live instance: a masked export of two users came back carrying both real addresses.
53
+
54
+ The applier now throws, and `planMasking` refuses the policy BEFORE a row is read: `MaskingError` gained `invalidActions`, reported separately from `unclassified` because the fixes differ — one needs a classification, the other needs the policy corrected.
55
+
56
+ ### Added
57
+
58
+ - **@voltro/runtime** — A write the database refuses on an integrity rule now raises a typed `ConstraintViolation` instead of an opaque `SqlError`. It carries `{ kind, table, operation, constraint?, column? }`, where `kind` is one of `foreignKey` · `foreignKeyInUse` · `unique` · `notNull` · `check`. Declare it in a procedure's `error:` to pattern-match it; undeclared it still reaches the client as an `InternalError` carrying its own sentence rather than `Failed to execute statement`.
59
+
60
+ It carries NAMES and never the driver's message, which on most engines contains row data — postgres attaches the complete failing row to a not-null and a check violation, mysql and mssql echo the duplicate value. Classification is measured against live postgres 17, MySQL 8.4, MariaDB 11, SQL Server 2022 and sqlite.
61
+
62
+ Raised from one guard covering every write op (insert · insertMany · upsert · insertIgnore · update · updateMany · delete · deleteMany · hardDelete · patchJson); the tenant-FK case still resolves to `TenantScopeViolation` first.
63
+
64
+ ### Fixed
65
+
66
+ - **@voltro/cli, @voltro/data-transfer** — `voltro data import|export` — four defects on the `--target api` path, all found by a consumer seeding a fresh cluster from a bundle.
67
+
68
+ **A flag this command does not read is now an ERROR.** `--dry-run` and `--tables` were accepted on the import path and dropped in silence: a preview against a production-shaped cluster ran the import instead (2905 rows, then a 500), and a run narrowed to a one-row table wrote all 10 593. Both are one defect — an argument parser that ignores what it does not understand — so every `voltro data` subcommand now declares the flags it reads per target and refuses the rest, naming the flag and what to use instead.
69
+
70
+ **`--dry-run` and `--tables` now work on the import, on BOTH targets.** A dry run reaches every verdict a real run reaches (schema fit, cross-dialect portability, mode legality, the table selection) and stops before the first write; the api path carries them as `x-import-dry-run` / `x-import-tables` and echoes `{ dryRun: true, wrote: false }`. A `--tables` name the bundle does not carry is refused, listing what it does. `--dry-run` on an api EXPORT is refused rather than ignored — previewing a read protects nothing.
71
+
72
+ **The schema-drift pre-flight compares the INTERSECTION, not whole schemas.** A bundle's fingerprint covers its source schema regardless of export scope, and two environments never have identical whole schemas, so the check refused every cross-environment seed with a diff whose every line said the difference changes nothing — making `--force` the routine way to import and removing the protection it guards. It now reports only what would break the load: a carried table or column the target lacks, a type mismatch, or a column the target REQUIRES that the bundle carries no value for.
73
+
74
+ **A failed row says why.** `reason` was `Failed to execute statement` for every one of 2905 rows. It now names the constraint and the rule (`foreign key tasks_laneId_fkey: the referenced row does not exist [23503]`), or the driver's own message with its code, or — where there is no driver under the failure — the error from the layer that refused.
75
+
76
+ Also: `voltro data inspect` accepts a directory bundle instead of dying inside the archive reader with a JSON parse error (`--target api` always unpacks into a directory, even when the path ends in `.vbundle`).
77
+
78
+ **Three more, found by running the whole thing against live MariaDB and MySQL** rather than against sqlite:
79
+
80
+ - A re-run of a COMPLETED import wrote nothing and reported the bundle's full row count — the resume ledger lives in the bundle directory, so truncating a target and re-importing printed `import complete … 10593 rows` over an empty database. Resume is right; being quiet about it was not. It now warns, names the skipped tables, and says which ledger file to delete. - The deferred-FK recovery pass OVERWROTE the diagnosis. When a held row cannot be written, the resolver retries it with every `reference` column nulled to break a cycle — and that attempt's failure replaced the original reason, so a row whose real problem was one column reported a not-null violation on a column the framework itself had nulled. The recovery attempt no longer records a reason. - MySQL/MariaDB errno **1364** (a statement that OMITS a column which is NOT NULL with no default) is classified as a not-null violation. postgres reports 23502 for that situation and mssql 515, so the mysql family was the only one where "you did not supply a required column" came back unclassified.
81
+ - **@voltro/database** — CHECK constraints were invisible to introspection on **MySQL** — and with them every `.oneOf()` column and every `json_valid` marker.
82
+
83
+ `information_schema.check_constraints` differs between the two engines of the family: MariaDB carries `TABLE_NAME`, MySQL does not have that column at all. The introspector selected it, the query errored, and an `Effect.orElseSucceed` turned that into an empty list. A swallowed error and an empty result read identically, which is why this needed a two-engine test to surface. The query JOINs `information_schema.table_constraints` for the name now, which both engines answer.
84
+
85
+ `parseEnumCheck` also learned MySQL's rendering. The same clause is stored differently:
86
+
87
+ mariadb 11 `status` in ('draft','live','done') mysql 8.4 (`status` in (_latin1'draft',_latin1'live',_latin1'done'))
88
+
89
+ MySQL puts a charset introducer before each literal, which the pattern — written against MariaDB's form — did not read. Both are pinned in `enumCheckParity.test.ts`.
90
+
91
+ Neither fix completes the round trip on MySQL: `.oneOf()` still comes back unclassified there. That is asserted as a known gap in `oneOfCheck.mariadb.integration.test.ts` (which fails the moment it starts working) and written up in `plans/open/framework/mysql-oneof-roundtrip.md`.
92
+ - **@voltro/database** — `voltro db apply` works on MySQL. It could not create a table with an index, and could not drop a column, on that engine at all.
93
+
94
+ `IF [NOT] EXISTS` outside `CREATE`/`DROP TABLE` is a MariaDB extension — MySQL rejects it with ER_PARSE_ERROR (measured on 8.4 for `CREATE INDEX IF NOT EXISTS`, `ALTER TABLE … DROP COLUMN IF EXISTS`, and `ADD COLUMN IF NOT EXISTS`). The applier emitted the first two, because `@effect/sql-mysql2` reports the dialect `mysql` for both engines and the shared branch had only ever run against MariaDB. A `reference()` column gets an index by default, so in practice most tables were affected.
95
+
96
+ The applier now asks the SERVER which engine it is (`SELECT VERSION()`; MariaDB stamps itself into the string) and emits the plain form on MySQL. The idempotency `IF [NOT] EXISTS` provided moves into the statement runner, which tolerates exactly the errnos meaning "already in the requested state" — 1061 for a duplicate index name, 1091 for dropping something absent. The engine is read from the connection rather than from `DB_DIALECT` or `variant`, because the DDL has to be legal for the server that receives it and those are what an operator typed.
97
+
98
+ Verified against live MySQL 8.4 and MariaDB 11: a schema evolution — create, add column, add index, drop column — applied through `applyPlan` on both, converging at every step, plus a replayed plan (what a resume does) that must not error on the statements it repeats.
99
+
100
+ **sqlite had the same defect, found by the new cross-dialect scenario on its first run.** `ALTER TABLE … DROP COLUMN IF EXISTS` is accepted by postgres, mssql and MariaDB and rejected by sqlite — and the generic emitter, shaped for postgres, is what sqlite used. So `voltro db apply` could not drop a column on sqlite either. The conditional form is now emitted only where it is legal, and the "already dropped" case is tolerated per dialect (`idempotentDdl.ts`).
101
+
102
+ `runDialectParity` gained a schema-evolution scenario — create, add column, add index, drop column, applied for real with a convergence check after each step — so the migration APPLIER is now covered on all five dialects. It previously had one scenario covering one op kind, while twenty-two covered the store; that split is why four emitter defects survived.
103
+
104
+ **And a fifth, found by making one MariaDB-only suite two-sided.** `text().unique()` on an unbounded text column created a table on MariaDB and failed the CREATE outright on MySQL: `BLOB/TEXT column 'x' used in key specification without a key length`. The bring-up emitter (`migrate.ts`) wrote an inline `UNIQUE`; the declarative applier had always written a separate PREFIXED unique index. The two emitters disagreeing on one statement is the failure shape this package's own notes describe, and only one engine said so.
105
+
106
+ `migrate.ts` emits the prefixed index now, through the same `indexStmt` that already owns the per-dialect `IF NOT EXISTS` rule, and names it `<table>_<column>_key` to match the applier's — so the two paths produce the same object.
107
+
108
+ **Note the behaviour change on MariaDB.** It accepted the inline form by backing it with a HASH long-unique index, whose hidden `DB_ROW_HASH_n` column breaks the binlog CDC reader (documented in `packages/database/CLAUDE.md`). Uniqueness on such a column is now enforced on the first 191 characters rather than the whole value — which is what `voltro db apply` already did, and what MySQL can express at all. Bound the column with `text().maxLength(n)` if you need full-value uniqueness.
109
+ - **@voltro/sql-mysql** — `insertIgnore` on MySQL was a different feature from `insertIgnore` on MariaDB — and the difference could turn a conflict into an error.
110
+
111
+ The whole diagnostic apparatus — the refusal to report a REJECTED write as a conflict, and the message naming the constraint that actually fired — sat behind a `variant === 'mariadb'` branch. MySQL took an `else` that used no `INSERT IGNORE` at all: look for a row matching the conflict columns, insert if there is none. That cannot hold the one property the method exists for. A caller that looks before anyone else writes sees nothing, so the write it then makes is the one that raises the duplicate-key error `insertIgnore` promises never to raise — reproduced deterministically against both engines with an uncommitted holder (the lookup cannot see the holder's row; the insert cannot proceed until it commits).
112
+
113
+ Underneath sat the reason a straight port would still have produced nothing: **MySQL answers a PREPARED `SHOW WARNINGS` with 1295 ER_UNSUPPORTED_PS**, and the warning read is deliberately failure-tolerant (a diagnostic must never replace the caller's real problem), so it returned an empty list — indistinguishable from a statement that raised nothing. MariaDB accepts both protocols. The read goes through the text protocol now, the same spelling the binlog path already used for `SHOW MASTER STATUS`.
114
+
115
+ Both engines now run one `INSERT IGNORE` and reach one decision function. What differs is only the probe for "did it land": MariaDB has `INSERT IGNORE … RETURNING *`; MySQL has no RETURNING, so the row's own key answers instead. `SELECT ROW_COUNT()` — the obvious alternative — cannot be used: measured on both engines, it reports 1/0 correctly but CLEARS the warning list on MySQL, and run the other way round returns `-1` because `SHOW WARNINGS` is then the last statement. The count and the diagnosis cannot both be had; the diagnosis is the one worth having.
116
+
117
+ Found by converting the suite that covers this to run on both engines, which is also where every MySQL assertion in it had been reporting the driver's generic `Failed to execute statement`.
118
+ - **@voltro/database** — A `reference()` column now creates a real foreign key on **MySQL**. It did not before: MySQL/InnoDB parses a column-inline `REFERENCES` clause and discards it — no constraint, no warning, the `CREATE TABLE` succeeds — while MariaDB honours the identical clause. Both engines reach the same emitter (the driver reports the dialect `mysql` for either), and every mysql-family integration suite in the repo runs against MariaDB, so referential integrity that postgres, MariaDB, mssql and sqlite all enforced was silently absent on MySQL.
119
+
120
+ Both emitters now write a table-level `CONSTRAINT <table>_<column>_fkey FOREIGN KEY …` inside the `CREATE TABLE`, which both engines honour and which `CREATE TABLE IF NOT EXISTS` keeps idempotent. Existing MariaDB schemas are unaffected — the introspected snapshot carries no constraint name, so nothing re-plans.
121
+
122
+ Verified against live MySQL 8.4: the constraint is in the catalog, the server refuses an orphan row, introspection reads it back, and the re-plan is empty.
123
+ - **@voltro/sql-turso, @voltro/testing** — A migration on turso applied correctly and then reported itself as failed: `voltro db apply` ran an `add-column`, re-planned to prove convergence, saw the column still missing, proposed the same operation again, and the second execution died with `duplicate column name`. No fingerprint was recorded, so every subsequent boot re-proposed the same work — and the error named the migration applier, which had done nothing wrong.
124
+
125
+ The client caches one prepared statement per connection per SQL text, and a prepared statement carries the schema it was prepared against. So a cached `PRAGMA table_info(t)` keeps answering with the old columns after a DDL — it is never re-prepared, so sqlite's schema-cookie re-preparation never runs. The invalidation for this existed, on the unprepared path (`sql.unsafe`) only, and the migration path sends its DDL through the PREPARED one. The statement that changed the schema and the cache that had to be dropped were on the same connection, one function apart, with nothing connecting them.
126
+
127
+ Any schema-changing statement now drops that connection's cached statements, whichever path it arrived on.
128
+
129
+ Three hypotheses were measured and disproven before this one — an applier retry (each operation is issued once), an MVCC snapshot (two raw libsql clients both see the DDL), and a pool-wide cache problem (four connections held open together, the PRAGMA prepared on each, a DDL on one: the other three answer correctly, because SQLite bumps the schema cookie and the driver re-prepares on the connections that did not make the change).
130
+
131
+ The two `runDialectParity` scenarios that drive the migration applier were skipped for turso on the strength of that misreading. They run now, and the per-fixture opt-out that carried the skip is deleted: it was holding a defect open while reading like a documented limitation.
132
+
133
+ **`apiSurface: compatible`, and the reason is a date rather than an argument.** Removing `DialectFixture.skipApplierScenarios` moves a line in `@voltro/testing`'s golden, so the changelog's narrowing detector flags it — and it is right to, because that detector's baseline is `origin/main`. But the field never reached a RELEASE: it was added after `v0.41.0` and deleted before this one, both inside the same unreleased range. `git show v0.41.0:packages/testing/etc/testing-dialect.api.md` does not contain it. No published version ever offered it, so no consumer can have set it, and there is nothing to migrate.
134
+
135
+ Worth writing down because the first reading of this was wrong in the safe direction: it was filed `BREAKING` with a codemod on the strength of "an optional field disappeared from a published package's surface", which is the right instinct and the wrong conclusion here. **"Removed relative to main" is not "removed relative to what users have"** — a symbol that lives and dies between two tags trips the detector while breaking nobody, and the difference is only visible by asking the last TAG rather than the last commit.
136
+
137
+ ---
138
+
139
+ ## [0.41.0] — 2026-08-17
140
+
141
+ ### ⚠ BREAKING
142
+
143
+ - **@voltro/web, @voltro/cli** — `middleware.ts` exports `defineMiddleware(...)` (from `@voltro/web/middleware`) instead of a bare function, and each export carries its own `match`. Several middlewares per file are allowed; **at most one may match a given route**.
144
+
145
+ Migration: the codemod wraps the existing default export. That is behaviour-preserving — no `match` means every server-rendered route, which is what an unwrapped middleware did — and its note explains how to replace a hand-written path gate with a `match`.
146
+
147
+ **Why it was worth a break.** A hand-written `if (!req.pathname.startsWith('/app')) return` is invisible: nothing can tell you a middleware runs nowhere, or that two of them claim one route. `match` puts it where both the boot and `voltro doctor` can read it.
148
+
149
+ **The matcher speaks ROUTES, not URL patterns** — `under` / `routes` / `except`, validated against the app's own route patterns. A path matching no route refuses the boot instead of silently never firing. This is the deliberate difference from the `'/((?!api|_next/static|…).*)'` shape: our hook runs after route matching, so an app has never needed to know its own asset layout, and non-page requests are reachable only by asking (`assets: true`) — where, note, there is no render, so only `setCookies` takes effect.
150
+
151
+ An overlap refuses the boot and names both middlewares plus the route. Declaration order is not a semantic, "most specific wins" silently drops the broader hook, and merging needs a per-field rule nobody remembers — so two hooks writing one `authorization` header is a refusal, not a resolution.
152
+
153
+ **The web bundle budget moved UP, and the split is worth stating** because only one half is a cost the framework imposes:
154
+
155
+ | measured | before | after | | --- | --- | --- | | first load | 184 955 B | 185 309 B (**+354**) | | lazy route chunks | 3 502 B | 4 415 B (+913) |
156
+
157
+ The **+354 B of first load is the real price** — one `serverContext` chunk, 0.2 KB gz, which every app now carries whether or not it declares a middleware. That is the number to argue with, and it leaves 6.7 KB of headroom under the ceiling.
158
+
159
+ The +913 B is NOT a per-route regression: the fixture gained four routes (`exact`, `exact/[id]`, `mw`, `mw/skip`) to exercise the feature end to end, at 0.1–0.2 KB gz each, which accounts for the growth without remainder. Re-pinned with `--update` rather than by hand, so the `slackFloor` keeps ratcheting — a ceiling nobody lowers again silently permits re-inflating to the old number.
160
+
161
+ ### Fixed
162
+
163
+ - **@voltro/data-transfer, @voltro/cli** — `voltro data export` could not export a table whose primary key is not named `id`, and one of its two failure modes reported success.
164
+
165
+ The keyset column was `columns.find(c => c.type === 'id')?.name ?? 'id'`, and `type: 'id'` is tagged only on a column that is BOTH the single-column primary key AND literally named `id` — identically in all four dialect introspectors. So any introspected table with another PK name was ordered by a column that does not exist. It now comes from the real primary key (the synthesised `<table>_pkey` index), with the declared `id()` column still winning where there is one.
166
+
167
+ **A composite or absent primary key is now REFUSED**, not silently ordered by the first column: keyset pagination on a non-unique order splits equal values across page boundaries, so rows are dropped or duplicated into a bundle that reports success. Bounded exports are recoverable; a quietly short backup is discovered at the restore.
168
+
169
+ **A requested table missing from the schema is refused too.** `scope: { kind: 'tables' }` used to drop unknown names, so a run that explicitly named a table wrote `"tables": []` and printed `export complete` with exit 0. `kind: 'all'` over an empty database is still a legal empty export — the asymmetry is deliberate: a named table is an expectation.
170
+
171
+ **Failure reasons survive.** `String(e?.message ?? e)` produced `"write table failed: "` with nothing after the colon — `??` falls back on null/undefined, and an Effect `TaggedError` carries an empty-string `message`. Every catch site in the exporter now reports tag, message or cause.
172
+
173
+ **New: `voltro data export --exclude a,b`** — everything except these, resolved against the live table list. It is the escape hatch the refusals above require; without it a single unkeyable table would block a whole-database export. An unknown name is refused for the same reason. Direct target only (the expansion needs the live table list), and it expands to an explicit `tables` scope, so the manifest records what was actually exported.
174
+
175
+ Reported with a reduced repro, a four-way variation over PK TYPES that ruled type out, and two disproved hypotheses. The affected tables include `@effect/cluster`'s own (`cluster_locks`, `cluster_migrations`), so no app running workflows could take a whole-database export.
176
+ - **@voltro/database, @voltro/runtime, @voltro/cli** — `.encrypted()` had three writers and two encodings. The store wrote `encrypt(JSON.stringify(v))`; `encryptField` — the documented raw-SQL escape hatch — and `voltro db encrypt-column` wrote `encrypt(v)`. All three produce the same `enc:v1:` envelope and nothing distinguished them, so a value written by one and read by another either threw with the wrong diagnosis or came back subtly wrong (`decryptField` handed back the JSON encoding verbatim, quotes and all, raising nothing).
177
+
178
+ There is one encoding for every WRITE now, and every READ resolves BOTH forms — so **no data has to be rewritten and nothing is blocked**. That second half is the point: the old form is already on staging and production disks, and a fix that needs the rows rewritten before the app works is an outage with a migration attached.
179
+
180
+ Reading two forms is deterministic, not a heuristic. After decrypting, a parse failure is the raw form; a parse to a STRING is the JSON form; a parse to a non-string depends on the column's declared type (a text column cannot hold a number, so `12345` is a raw string that parsed by accident). The one case nothing can separate — a raw secret whose literal text is `"abc"`, quotes included — is stated in the code rather than hidden.
181
+
182
+ **`voltro db encrypt-column` verified itself against the wrong decoder.** It wrote the raw form and checked it with `cipher.decrypt` — a decoder nothing reads these columns with — so it reported success over columns the app could not read. It round-trips through `decodeFieldValue` now, the same function the store calls. A self-check against a decoder the runtime does not use is not a weaker check; it is a second opinion from the same mistake.
183
+
184
+ The command also NORMALISES rows in the old encoding as it goes (reported separately from the ones it encrypts), so an operator does not write a script per column. It skips anything ambiguous and anything it cannot decrypt.
185
+
186
+ **The width pre-flight measured the wrong thing after the encoding changed.** It sized the ciphertext from the PLAINTEXT's byte length while the cipher is handed the JSON encoding — two characters more at minimum, and more for every escape. Measured on a real MariaDB: a 63-byte value in a `varchar(135)` passed the check and the UPDATE answered `ER_DATA_TOO_LONG`, which is the failure that check exists to prevent, mid-column with the rest already converted. It measures the encoded length now, and the refusal says "encodes to" rather than "is" so an operator measuring their own column finds the number it names.
187
+
188
+ **Two dialect defects, both found by running the command against real servers.** SQL Server reports `-1` for `NVARCHAR(MAX)` — its spelling of unbounded — and the pre-flight read it as a one-character column, so it refused the widest column the dialect has and printed `declared as -1` at the operator. And SQLITE has no `information_schema` at all: the shared catalog query died there with `Failed to prepare statement` and no statement attached, on a dialect the command claims to support. It uses `pragma_table_info` now, reporting no length because sqlite enforces none.
189
+
190
+ Measured end to end on postgres, mysql, mariadb, mssql and sqlite: a table holding plaintext, the old encoding and the current encoding side by side converts, every row decodes back to its original value, a re-run writes nothing, and a wrong key refuses with exit 1.
191
+
192
+ **Backups and restores were never affected and now say so.** `voltro data export` reads through the raw dialect store, so ciphertext travels verbatim in either encoding — pinned by a test, because a future change that wrapped that store would put plaintext credentials in a bundle.
193
+ - **@voltro/protocol, @voltro/cli** — Three findings from one consumer round, all of the same shape: something the framework knows and does not say.
194
+
195
+ **A decode failure on a GUARDED procedure now says the guard did not run.** The payload decodes before the handler, so a guard on a procedure with a malformed payload never gets the chance to refuse. A consumer auditing a guard called one with an incomplete payload, got a decode error instead of a `ScopeError`, and concluded the guard was not applied — the wrong conclusion in the dangerous direction. The title now carries `(guarded — the guard did NOT run: the payload failed to decode first, so this says nothing about access)`. It discloses nothing new: that a procedure is guarded is already visible to anyone who sends a VALID payload. An `openAccess:` declaration is not an enforced guard and gets no such sentence — `hasEnforcedGuard` is the one predicate, read by both the label and the wire error union, because two copies of that rule would disagree invisibly.
196
+
197
+ **`middleware.ts`'s `httpOnly` default is documented at the field, and warned about.** It defaults to `HttpOnly`, which is wrong for a session cookie a browser SDK reads back: Supabase's `createBrowserClient` reads `document.cookie`, so a forgotten `httpOnly: false` gives the browser a session it cannot see — the SSR render is perfect and the user is signed out at the first client-side call. The consumer only avoided shipping it because their probes already set the flag. `voltro dev` warns once per cookie when a session-shaped name is written with no `httpOnly` decision; an explicit decision either way silences it, because warning on a decision is how a diagnostic becomes noise.
198
+
199
+ **`voltro dev` restarts when `middleware.ts` changes.** It is loaded once per boot, that is documented, and a consumer read it and still lost an afternoon: they sabotaged the middleware, saw no change, and concluded it was not wired — in an environment where everything else hot-reloads. It now restarts through the same respawn a hard-restart field in `app.config.ts` uses, extracted so there is one copy of the `execArgv` inheritance and the signal forwarding.
200
+ - **@voltro/cli** — `middleware.ts` now produces ONE view of the request that every downstream reader takes. Previously only `buildLoaderQuery` saw the hook's result, while the loader context (`ctx.headers`), the SSR request snapshot (`useServerRequest()`) and the locale resolver kept reading the raw request — four readers, two answers, within eighty lines of one function.
201
+
202
+ The consequence was worse than an inconsistency: a hook that renews purely via `setCookies` — no `headers` at all, which is the normal shape for a cookie-session IdP and the reason the response half exists — moved nothing for the render that ran it. The rpc call still sent the old `Cookie` header, because a renewed cookie only reached the browser.
203
+
204
+ `setCookies` is applied to the cookie jar before the render, the `Cookie` header is rebuilt from that jar (an explicit `cookie` in the hook's own `headers` still wins), and `maxAge <= 0` deletes, so a hook that signs someone out renders them signed out. Both SSR boot paths shadow the raw headers out of scope after the hook runs, so a new reader added below is correct without knowing any of this.
205
+ - **@voltro/cli** — `voltro start` dropped `middleware.ts`'s `Set-Cookie` on **streamed** responses — which is the arm a plain `renderMode: 'ssr'` page takes, so it was the common case. The hook renewed the session server-side, the render used the fresh value, and the browser kept the consumed one. Against an IdP that rotates refresh tokens and detects reuse, that is worse than not renewing at all.
206
+
207
+ The cause is worth stating because it read as handled: a streamed response hands the socket to `stream(res)` and the caller never looks at the returned `headers`, so the `withCookies(...)` wrapper on that arm was dead code — sitting under a comment promising the cookies were written on every arm. The cookies now travel with the headers `streamSsrResponse` itself writes, and the dead wrapper is gone.
208
+
209
+ Found by booting real `voltro dev` and `voltro start` servers against a fixture and reading the response. Every unit test was green throughout, and the render's own HTML was correct — only the wire was wrong.
210
+
211
+ ---
212
+
42
213
  ## [0.40.0] — 2026-08-16
43
214
 
44
215
  ### ⚠ BREAKING
package/dist/dialect.js CHANGED
@@ -1,55 +1,55 @@
1
- import { _voltroMigrationPlansTable as e, boolean as t, bulkInsertLimitsFor as n, eq as r, id as i, integer as a, table as o, text as s, timestamp as c } from "@voltro/database";
2
- import { Effect as l } from "effect";
3
- import { _voltroUndoLogTable as u, applyInverses as d, synthesizeInverse as f } from "@voltro/runtime";
4
- import { afterEach as p, beforeEach as m, describe as h, expect as g, it as _ } from "vitest";
5
- import { SqlClient as v } from "@effect/sql";
6
- import { applyPlan as y, applySchema as b, introspectSchema as x, planMigrations as S } from "@voltro/database/sql";
1
+ import { _voltroMigrationPlansTable as e, boolean as t, bulkInsertLimitsFor as n, dropped as r, eq as i, id as a, integer as o, table as s, text as c, timestamp as l } from "@voltro/database";
2
+ import { Effect as u } from "effect";
3
+ import { _voltroUndoLogTable as d, applyInverses as f, synthesizeInverse as p } from "@voltro/runtime";
4
+ import { afterEach as m, beforeEach as h, describe as g, expect as _, it as v } from "vitest";
5
+ import { SqlClient as y } from "@effect/sql";
6
+ import { applyPlan as b, applySchema as x, introspectSchema as S, planMigrations as C } from "@voltro/database/sql";
7
7
  //#region src/dialectParity.ts
8
- var C = (e) => ({
8
+ var w = (e) => ({
9
9
  table: e,
10
10
  predicate: void 0,
11
11
  order: [],
12
12
  take: void 0,
13
13
  skip: void 0,
14
14
  projection: void 0
15
- }), w = o("voltro_parity_a", {
16
- id: i(),
17
- title: s(),
18
- count: a()
19
- }), T = o("voltro_parity_b", {
20
- id: i(),
21
- title: s()
22
- }), E = o("voltro_parity_c", {
23
- id: i(),
24
- title: s(),
25
- count: a(),
15
+ }), T = s("voltro_parity_a", {
16
+ id: a(),
17
+ title: c(),
18
+ count: o()
19
+ }), E = s("voltro_parity_b", {
20
+ id: a(),
21
+ title: c()
22
+ }), D = s("voltro_parity_c", {
23
+ id: a(),
24
+ title: c(),
25
+ count: o(),
26
26
  flag: t().default(!1)
27
- }), D = o("voltro_parity_d", {
28
- id: i(),
29
- title: s(),
30
- at: c().nullable(),
31
- n: a().nullable()
32
- }), O = o("voltro_parity_bulk", {
33
- id: i(),
34
- title: s(),
35
- count: a(),
27
+ }), O = s("voltro_parity_d", {
28
+ id: a(),
29
+ title: c(),
30
+ at: l().nullable(),
31
+ n: o().nullable()
32
+ }), k = s("voltro_parity_bulk", {
33
+ id: a(),
34
+ title: c(),
35
+ count: o(),
36
36
  flag: t().default(!1)
37
- }), k = (e) => {
37
+ }), A = (e) => {
38
38
  let t = n(e);
39
39
  if (t === void 0) return 0;
40
- let r = Object.keys(O.fields).length;
40
+ let r = Object.keys(k.fields).length;
41
41
  return Math.max(1, Math.min(Math.floor(t.maxBindParameters / r), t.maxRowsPerStatement ?? Infinity));
42
- }, A = (t) => {
43
- h(`dialect parity: ${t.name ?? t.dialect.id}`, () => {
42
+ }, j = (t) => {
43
+ g(`dialect parity: ${t.name ?? t.dialect.id}`, () => {
44
44
  let n = null;
45
- m(async () => {
45
+ h(async () => {
46
46
  await t.setup(), n = await t.make(), await n.migrate([
47
- w,
48
47
  T,
49
48
  E,
50
49
  D,
51
50
  O,
52
- u
51
+ k,
52
+ d
53
53
  ]);
54
54
  for (let e of [
55
55
  "voltro_parity_a",
@@ -58,35 +58,35 @@ var C = (e) => ({
58
58
  "voltro_parity_d",
59
59
  "_voltro_undo_log"
60
60
  ]) {
61
- let t = await n.store.query(C(e));
61
+ let t = await n.store.query(w(e));
62
62
  for (let r of t) await n.store.delete(e, r.id);
63
63
  }
64
- }), p(async () => {
64
+ }), m(async () => {
65
65
  await n?.dispose(), await t.teardown(), n = null;
66
- }), _("rename-table: the rows move, and the plan converges", async () => {
67
- let r = "voltro_rename_src", a = "_voltro_rename_dst", c = n.run, u = async () => {
68
- await c(l.gen(function* () {
69
- let e = yield* v.SqlClient;
70
- for (let t of [a, r]) yield* l.orElseSucceed(e.unsafe(`DROP TABLE IF EXISTS ${t}`), () => []);
66
+ }), v("rename-table: the rows move, and the plan converges", async () => {
67
+ let r = "voltro_rename_src", i = "_voltro_rename_dst", o = n.run, l = async () => {
68
+ await o(u.gen(function* () {
69
+ let e = yield* y.SqlClient;
70
+ for (let t of [i, r]) yield* u.orElseSucceed(e.unsafe(`DROP TABLE IF EXISTS ${t}`), () => []);
71
71
  })).catch(() => {});
72
- }, d = () => c(l.gen(function* () {
73
- let e = yield* v.SqlClient, t = yield* x(e);
72
+ }, d = () => o(u.gen(function* () {
73
+ let e = yield* y.SqlClient, t = yield* S(e);
74
74
  return {
75
75
  ...t,
76
- tables: t.tables.filter((e) => e.name === r || e.name === a)
76
+ tables: t.tables.filter((e) => e.name === r || e.name === i)
77
77
  };
78
- })), f = async () => S({
78
+ })), f = async () => C({
79
79
  declared: [m],
80
80
  live: await d(),
81
81
  dialect: t.dialect.id
82
82
  });
83
- await u();
84
- let p = o(r, {
85
- id: i({ prefix: "rn" }),
86
- title: s()
87
- }), m = o(a, {
88
- id: i({ prefix: "rn" }),
89
- title: s()
83
+ await l();
84
+ let p = s(r, {
85
+ id: a({ prefix: "rn" }),
86
+ title: c()
87
+ }), m = s(i, {
88
+ id: a({ prefix: "rn" }),
89
+ title: c()
90
90
  }).renamedFrom(r);
91
91
  await n.migrate([p, e]), await n.store.insert(r, {
92
92
  id: "rn_1",
@@ -96,82 +96,184 @@ var C = (e) => ({
96
96
  title: "two"
97
97
  });
98
98
  let h = await f();
99
- g(h.operations.some((e) => e.op.kind === "rename-table"), "the marker must fold").toBe(!0), g(h.operations.filter((e) => e.blocked !== void 0), "nothing may be blocked").toEqual([]), await c(l.gen(function* () {
100
- let e = yield* v.SqlClient;
101
- return yield* y(e, h, {
99
+ _(h.operations.some((e) => e.op.kind === "rename-table"), "the marker must fold").toBe(!0), _(h.operations.filter((e) => e.blocked !== void 0), "nothing may be blocked").toEqual([]), await o(u.gen(function* () {
100
+ let e = yield* y.SqlClient;
101
+ return yield* b(e, h, {
102
102
  declared: [m],
103
103
  appliedBy: "dialect-parity",
104
104
  environment: "dev",
105
105
  source: "auto-diff",
106
- replan: () => l.promise(f)
106
+ replan: () => u.promise(f)
107
107
  });
108
108
  }));
109
- let _ = await n.store.query(C(a));
110
- g(_.map((e) => e.id).sort(), "every row survived the rename").toEqual(["rn_1", "rn_2"]), g((await f()).operations, `${t.dialect.id}: the plan must converge`).toEqual([]), await u();
109
+ let g = await n.store.query(w(i));
110
+ _(g.map((e) => e.id).sort(), "every row survived the rename").toEqual(["rn_1", "rn_2"]), _((await f()).operations, `${t.dialect.id}: the plan must converge`).toEqual([]), await l();
111
+ }), v("schema evolution: create → add column → add index → drop column, converging at each step", async () => {
112
+ let i = "voltro_parity_evolve", l = n.run, d = async () => {
113
+ await l(u.gen(function* () {
114
+ let e = yield* y.SqlClient;
115
+ yield* u.orElseSucceed(e.unsafe(`DROP TABLE IF EXISTS ${i}`), () => []);
116
+ })).catch(() => {});
117
+ }, f = () => l(u.gen(function* () {
118
+ let e = yield* y.SqlClient, t = yield* S(e);
119
+ return {
120
+ ...t,
121
+ tables: t.tables.filter((e) => e.name === i)
122
+ };
123
+ })), p = async (e) => C({
124
+ declared: e,
125
+ live: await f(),
126
+ dialect: t.dialect.id
127
+ }), m = async () => (await f()).tables[0]?.columns.map((e) => e.name) ?? [], h = async (e, n) => {
128
+ let r = await p(e);
129
+ n && _(r.operations.length, `${t.dialect.id}: nothing to apply — the step asserts nothing`).toBeGreaterThan(0), _(r.operations.filter((e) => e.blocked !== void 0), `${t.dialect.id}: nothing may be blocked`).toEqual([]), r.operations.length !== 0 && (await l(u.gen(function* () {
130
+ let n = yield* y.SqlClient;
131
+ return yield* b(n, r, {
132
+ declared: e,
133
+ appliedBy: "dialect-parity",
134
+ environment: "dev",
135
+ source: "auto-diff",
136
+ replan: (n) => u.map(S(n), (n) => C({
137
+ declared: e,
138
+ live: {
139
+ ...n,
140
+ tables: n.tables.filter((e) => e.name === i)
141
+ },
142
+ dialect: t.dialect.id
143
+ }))
144
+ });
145
+ })), _((await p(e)).operations, `${t.dialect.id}: the plan must converge`).toEqual([]));
146
+ };
147
+ await d(), await n.migrate([e]), await h([s(i, {
148
+ id: a({ prefix: "ev" }),
149
+ name: c()
150
+ })], !0), _(await m(), `${t.dialect.id}: v1 columns`).toEqual(["id", "name"]), await n.store.insert(i, {
151
+ id: "ev_1",
152
+ name: "one"
153
+ }), await n.store.insert(i, {
154
+ id: "ev_2",
155
+ name: "two"
156
+ }), await h([s(i, {
157
+ id: a({ prefix: "ev" }),
158
+ name: c(),
159
+ qty: o().nullable()
160
+ })], !0), _(await m()).toContain("qty"), await h([s(i, {
161
+ id: a({ prefix: "ev" }),
162
+ name: c(),
163
+ qty: o().nullable()
164
+ }).index(["qty"])], !0), await h([s(i, {
165
+ id: a({ prefix: "ev" }),
166
+ name: c(),
167
+ qty: r()
168
+ })], !0), _(await m(), `${t.dialect.id}: v4 columns`).toEqual(["id", "name"]);
169
+ let g = await n.store.query(w(i));
170
+ _(g.map((e) => e.id).sort(), `${t.dialect.id}: rows survived the evolution`).toEqual(["ev_1", "ev_2"]), await d();
171
+ }), v("re-applying a create-table plan is a no-op, indexes included", async () => {
172
+ let r = "voltro_parity_reapply", i = n.run, l = async () => {
173
+ await i(u.gen(function* () {
174
+ let e = yield* y.SqlClient;
175
+ yield* u.orElseSucceed(e.unsafe(`DROP TABLE IF EXISTS ${r}`), () => []);
176
+ })).catch(() => {});
177
+ }, d = () => i(u.gen(function* () {
178
+ let e = yield* y.SqlClient, t = yield* S(e);
179
+ return {
180
+ ...t,
181
+ tables: t.tables.filter((e) => e.name === r)
182
+ };
183
+ })), f = s(r, {
184
+ id: a({ prefix: "ra" }),
185
+ name: c(),
186
+ qty: o().nullable()
187
+ }).index(["qty"]), p = async () => C({
188
+ declared: [f],
189
+ live: await d(),
190
+ dialect: t.dialect.id
191
+ });
192
+ await l(), await n.migrate([e]);
193
+ let m = await p();
194
+ _(m.operations.some((e) => e.op.kind === "create-table"), `${t.dialect.id}: expected a create-table to re-apply`).toBe(!0);
195
+ for (let e = 0; e < 2; e++) await i(u.gen(function* () {
196
+ let e = yield* y.SqlClient;
197
+ return yield* b(e, m, {
198
+ declared: [f],
199
+ appliedBy: "dialect-parity",
200
+ environment: "dev",
201
+ source: "auto-diff",
202
+ replan: (e) => u.map(S(e), (e) => C({
203
+ declared: [f],
204
+ live: {
205
+ ...e,
206
+ tables: e.tables.filter((e) => e.name === r)
207
+ },
208
+ dialect: t.dialect.id
209
+ }))
210
+ });
211
+ }));
212
+ _((await p()).operations, `${t.dialect.id}: the re-applied plan must converge`).toEqual([]), await l();
111
213
  });
112
- let a = "voltro_parity_bulk", c = () => n.run(l.gen(function* () {
113
- let e = yield* v.SqlClient;
114
- yield* l.orElseSucceed(e.unsafe(`DELETE FROM ${a}`), () => []);
115
- })), h = (e, t) => Array.from({ length: e }, (e, n) => ({
214
+ let l = "voltro_parity_bulk", g = () => n.run(u.gen(function* () {
215
+ let e = yield* y.SqlClient;
216
+ yield* u.orElseSucceed(e.unsafe(`DELETE FROM ${l}`), () => []);
217
+ })), x = (e, t) => Array.from({ length: e }, (e, n) => ({
116
218
  id: `${t}_${String(n).padStart(6, "0")}`,
117
219
  title: `row ${n}`,
118
220
  count: n,
119
221
  flag: !1
120
222
  }));
121
- _("insertMany past this dialect's one-statement ceiling lands EVERY row", async () => {
122
- let e = k(t.dialect.id);
123
- g(e, `no bulk-insert limits are declared for '${t.dialect.id}' — a dialect with no entry chunks at nothing, so this scenario would pass having tested nothing`).toBeGreaterThan(0);
223
+ v("insertMany past this dialect's one-statement ceiling lands EVERY row", async () => {
224
+ let e = A(t.dialect.id);
225
+ _(e, `no bulk-insert limits are declared for '${t.dialect.id}' — a dialect with no entry chunks at nothing, so this scenario would pass having tested nothing`).toBeGreaterThan(0);
124
226
  let r = e + 5;
125
- await c();
126
- let i = await n.store.insertMany(a, h(r, "bulk"));
127
- g(i.length, `insertMany returned ${i.length} of ${r} post-images`).toBe(r), g(i[0]?.id).toBe("bulk_000000"), g(i[r - 1]?.id).toBe(`bulk_${String(r - 1).padStart(6, "0")}`);
128
- let o = await n.store.query(C(a));
129
- g(o.length, "the database holds fewer rows than insertMany reported").toBe(r), await c();
130
- }, 12e4), _("a chunked insertMany is still ALL-OR-NOTHING", async () => {
131
- let e = k(t.dialect.id) + 5;
132
- await c();
133
- let r = h(e, "atomic");
227
+ await g();
228
+ let i = await n.store.insertMany(l, x(r, "bulk"));
229
+ _(i.length, `insertMany returned ${i.length} of ${r} post-images`).toBe(r), _(i[0]?.id).toBe("bulk_000000"), _(i[r - 1]?.id).toBe(`bulk_${String(r - 1).padStart(6, "0")}`);
230
+ let a = await n.store.query(w(l));
231
+ _(a.length, "the database holds fewer rows than insertMany reported").toBe(r), await g();
232
+ }, 12e4), v("a chunked insertMany is still ALL-OR-NOTHING", async () => {
233
+ let e = A(t.dialect.id) + 5;
234
+ await g();
235
+ let r = x(e, "atomic");
134
236
  r[e - 1] = {
135
237
  ...r[e - 1],
136
238
  id: r[0].id
137
- }, await g(n.store.insertMany(a, r), "a duplicate primary key must still reject the whole call").rejects.toThrow();
138
- let i = await n.store.query(C(a));
139
- g(i.length, `${t.dialect.id}: ${i.length} rows survived a FAILED insertMany — chunking introduced partial success. The chunks must run inside one transaction when the caller holds none.`).toBe(0), await c();
140
- }, 12e4), _("DDL is idempotent — re-applying the schema is a no-op", async () => {
141
- await n.migrate([w, T]);
142
- }), _("insert + query round-trips a row", async () => {
239
+ }, await _(n.store.insertMany(l, r), "a duplicate primary key must still reject the whole call").rejects.toThrow();
240
+ let i = await n.store.query(w(l));
241
+ _(i.length, `${t.dialect.id}: ${i.length} rows survived a FAILED insertMany — chunking introduced partial success. The chunks must run inside one transaction when the caller holds none.`).toBe(0), await g();
242
+ }, 12e4), v("DDL is idempotent — re-applying the schema is a no-op", async () => {
243
+ await n.migrate([T, E]);
244
+ }), v("insert + query round-trips a row", async () => {
143
245
  let e = await n.store.insert("voltro_parity_a", {
144
246
  id: "a1",
145
247
  title: "one",
146
248
  count: 1
147
249
  });
148
- g(e).toMatchObject({
250
+ _(e).toMatchObject({
149
251
  id: "a1",
150
252
  title: "one",
151
253
  count: 1
152
254
  });
153
- let t = await n.store.query(C("voltro_parity_a"));
154
- g(t.length).toBe(1), g(t[0]?.id).toBe("a1");
155
- }), _("update returns the post-image", async () => {
255
+ let t = await n.store.query(w("voltro_parity_a"));
256
+ _(t.length).toBe(1), _(t[0]?.id).toBe("a1");
257
+ }), v("update returns the post-image", async () => {
156
258
  await n.store.insert("voltro_parity_a", {
157
259
  id: "a2",
158
260
  title: "pre",
159
261
  count: 1
160
262
  });
161
263
  let e = await n.store.update("voltro_parity_a", "a2", { title: "post" });
162
- g(e).toMatchObject({
264
+ _(e).toMatchObject({
163
265
  id: "a2",
164
266
  title: "post"
165
267
  });
166
- }), _("delete removes the row + reports true", async () => {
268
+ }), v("delete removes the row + reports true", async () => {
167
269
  await n.store.insert("voltro_parity_a", {
168
270
  id: "a3",
169
271
  title: "x",
170
272
  count: 1
171
- }), g(await n.store.delete("voltro_parity_a", "a3")).toBe(!0);
172
- let e = await n.store.query(C("voltro_parity_a"));
173
- g(e.length).toBe(0);
174
- }), _("undo: the _voltro_undo_log TEXT changes column round-trips a JSON ChangeSet", async () => {
273
+ }), _(await n.store.delete("voltro_parity_a", "a3")).toBe(!0);
274
+ let e = await n.store.query(w("voltro_parity_a"));
275
+ _(e.length).toBe(0);
276
+ }), v("undo: the _voltro_undo_log TEXT changes column round-trips a JSON ChangeSet", async () => {
175
277
  let e = [{
176
278
  table: "voltro_parity_c",
177
279
  op: "update",
@@ -201,9 +303,9 @@ var C = (e) => ({
201
303
  undone: !1,
202
304
  createdAt: /* @__PURE__ */ new Date()
203
305
  });
204
- let t = await n.store.query(C("_voltro_undo_log"));
205
- g(t.length).toBe(1), g(JSON.parse(t[0].changes)).toEqual(e);
206
- }), _("undo: reverts an INSERT (inverse delete) on this dialect", async () => {
306
+ let t = await n.store.query(w("_voltro_undo_log"));
307
+ _(t.length).toBe(1), _(JSON.parse(t[0].changes)).toEqual(e);
308
+ }), v("undo: reverts an INSERT (inverse delete) on this dialect", async () => {
207
309
  let e = {
208
310
  invocationId: "inv1",
209
311
  subject: null,
@@ -218,10 +320,10 @@ var C = (e) => ({
218
320
  })
219
321
  }]
220
322
  };
221
- await d(n.store, f(e));
222
- let t = await n.store.query(C("voltro_parity_c"));
223
- g(t.find((e) => e.id === "c2")).toBeUndefined();
224
- }), _("undo: reverts an UPDATE including the BOOLEAN, restoring the captured value FAITHFULLY", async () => {
323
+ await f(n.store, p(e));
324
+ let t = await n.store.query(w("voltro_parity_c"));
325
+ _(t.find((e) => e.id === "c2")).toBeUndefined();
326
+ }), v("undo: reverts an UPDATE including the BOOLEAN, restoring the captured value FAITHFULLY", async () => {
225
327
  await n.store.insert("voltro_parity_c", {
226
328
  id: "c3",
227
329
  title: "t",
@@ -229,14 +331,14 @@ var C = (e) => ({
229
331
  flag: !0
230
332
  });
231
333
  let e = (await n.store.query({
232
- ...C("voltro_parity_c"),
233
- predicate: r("id", "c3")
334
+ ...w("voltro_parity_c"),
335
+ predicate: i("id", "c3")
234
336
  }))[0], t = await n.store.update("voltro_parity_c", "c3", {
235
337
  count: 2,
236
338
  flag: !1
237
339
  });
238
- g(t.flag).not.toEqual(e.flag);
239
- let i = {
340
+ _(t.flag).not.toEqual(e.flag);
341
+ let r = {
240
342
  invocationId: "inv2",
241
343
  subject: null,
242
344
  changes: [{
@@ -247,13 +349,13 @@ var C = (e) => ({
247
349
  next: t
248
350
  }]
249
351
  };
250
- await d(n.store, f(i));
352
+ await f(n.store, p(r));
251
353
  let a = (await n.store.query({
252
- ...C("voltro_parity_c"),
253
- predicate: r("id", "c3")
354
+ ...w("voltro_parity_c"),
355
+ predicate: i("id", "c3")
254
356
  }))[0];
255
- g(a.flag).toEqual(e.flag), g(a.count).toEqual(e.count);
256
- }), _("undo: reverts a DELETE (inverse re-insert) on this dialect", async () => {
357
+ _(a.flag).toEqual(e.flag), _(a.count).toEqual(e.count);
358
+ }), v("undo: reverts a DELETE (inverse re-insert) on this dialect", async () => {
257
359
  let e = await n.store.insert("voltro_parity_c", {
258
360
  id: "c4",
259
361
  title: "gone",
@@ -271,24 +373,24 @@ var C = (e) => ({
271
373
  prev: e
272
374
  }]
273
375
  };
274
- await d(n.store, f(t));
275
- let i = (await n.store.query({
276
- ...C("voltro_parity_c"),
277
- predicate: r("id", "c4")
376
+ await f(n.store, p(t));
377
+ let r = (await n.store.query({
378
+ ...w("voltro_parity_c"),
379
+ predicate: i("id", "c4")
278
380
  }))[0];
279
- g(i.id).toBe("c4"), g(i.title).toBe("gone"), g(i.flag).toEqual(e.flag);
280
- }), _("onChange fires insert + update + delete events", async () => {
381
+ _(r.id).toBe("c4"), _(r.title).toBe("gone"), _(r.flag).toEqual(e.flag);
382
+ }), v("onChange fires insert + update + delete events", async () => {
281
383
  let e = [], t = n.store.onChange((t) => e.push(t.op));
282
384
  await n.store.insert("voltro_parity_a", {
283
385
  id: "a4",
284
386
  title: "a",
285
387
  count: 1
286
- }), await n.store.update("voltro_parity_a", "a4", { title: "b" }), await n.store.delete("voltro_parity_a", "a4"), t(), g(e).toEqual([
388
+ }), await n.store.update("voltro_parity_a", "a4", { title: "b" }), await n.store.delete("voltro_parity_a", "a4"), t(), _(e).toEqual([
287
389
  "insert",
288
390
  "update",
289
391
  "delete"
290
392
  ]);
291
- }), _("binding more than 10 change listeners emits no MaxListeners warning", async () => {
393
+ }), v("binding more than 10 change listeners emits no MaxListeners warning", async () => {
292
394
  let e = [], t = (t) => {
293
395
  e.push(t.name);
294
396
  };
@@ -296,19 +398,19 @@ var C = (e) => ({
296
398
  let r = Array.from({ length: 32 }, () => n.store.onChange(() => {}));
297
399
  await new Promise((e) => setImmediate(e));
298
400
  for (let e of r) e();
299
- process.off("warning", t), g(e.filter((e) => e === "MaxListenersExceededWarning"), "the change bus still warns at 11 listeners — `raiseChangeListenerCeiling` is not wired into this dialect’s store").toEqual([]);
300
- }), _("transactional rolls back on throw + drops queued events", async () => {
401
+ process.off("warning", t), _(e.filter((e) => e === "MaxListenersExceededWarning"), "the change bus still warns at 11 listeners — `raiseChangeListenerCeiling` is not wired into this dialect’s store").toEqual([]);
402
+ }), v("transactional rolls back on throw + drops queued events", async () => {
301
403
  let e = [], t = n.store.onChange((t) => e.push(t.op));
302
- await g(n.store.transactional(async (e) => {
404
+ await _(n.store.transactional(async (e) => {
303
405
  throw await e.insert("voltro_parity_a", {
304
406
  id: "rollback",
305
407
  title: "r",
306
408
  count: 0
307
409
  }), Error("intentional rollback");
308
- })).rejects.toThrow("intentional rollback"), t(), g(e).toEqual([]);
309
- let r = await n.store.query(C("voltro_parity_a"));
310
- g(r.length).toBe(0);
311
- }), _("transactional commit drains queued events in order", async () => {
410
+ })).rejects.toThrow("intentional rollback"), t(), _(e).toEqual([]);
411
+ let r = await n.store.query(w("voltro_parity_a"));
412
+ _(r.length).toBe(0);
413
+ }), v("transactional commit drains queued events in order", async () => {
312
414
  let e = [], t = n.store.onChange((t) => e.push(t.op));
313
415
  await n.store.transactional(async (e) => {
314
416
  await e.insert("voltro_parity_a", {
@@ -320,8 +422,8 @@ var C = (e) => ({
320
422
  title: "b",
321
423
  count: 2
322
424
  });
323
- }), t(), g(e).toEqual(["insert", "insert"]);
324
- }), _("upsert inserts a new row, then updates on conflict — no duplicate", async () => {
425
+ }), t(), _(e).toEqual(["insert", "insert"]);
426
+ }), v("upsert inserts a new row, then updates on conflict — no duplicate", async () => {
325
427
  await n.store.upsert("voltro_parity_a", {
326
428
  id: "u1",
327
429
  title: "first",
@@ -334,20 +436,20 @@ var C = (e) => ({
334
436
  conflictColumns: ["id"],
335
437
  update: ["title", "count"]
336
438
  });
337
- let e = await n.store.query(C("voltro_parity_a"));
338
- g(e.length).toBe(1), g(e[0]).toMatchObject({
439
+ let e = await n.store.query(w("voltro_parity_a"));
440
+ _(e.length).toBe(1), _(e[0]).toMatchObject({
339
441
  id: "u1",
340
442
  title: "second",
341
443
  count: 2
342
444
  });
343
- }), _("insert + update bind an explicit NULL into a datetime2/int column", async () => {
445
+ }), v("insert + update bind an explicit NULL into a datetime2/int column", async () => {
344
446
  let e = await n.store.insert("voltro_parity_d", {
345
447
  id: "nd1",
346
448
  title: "nulls",
347
449
  at: null,
348
450
  n: null
349
451
  });
350
- g(e).toMatchObject({
452
+ _(e).toMatchObject({
351
453
  id: "nd1",
352
454
  title: "nulls",
353
455
  at: null,
@@ -362,12 +464,12 @@ var C = (e) => ({
362
464
  at: null,
363
465
  n: null
364
466
  });
365
- g(t).toMatchObject({
467
+ _(t).toMatchObject({
366
468
  id: "nd2",
367
469
  at: null,
368
470
  n: null
369
471
  });
370
- }), _("updateMany updates only the rows matching the predicate + returns the count", async () => {
472
+ }), v("updateMany updates only the rows matching the predicate + returns the count", async () => {
371
473
  await n.store.insert("voltro_parity_a", {
372
474
  id: "m1",
373
475
  title: "x",
@@ -386,17 +488,17 @@ var C = (e) => ({
386
488
  op: "eq",
387
489
  value: 5
388
490
  } });
389
- g(e).toBe(2);
491
+ _(e).toBe(2);
390
492
  let t = await n.store.query({
391
- ...C("voltro_parity_a"),
493
+ ...w("voltro_parity_a"),
392
494
  predicate: {
393
495
  column: "title",
394
496
  op: "eq",
395
497
  value: "hit"
396
498
  }
397
499
  });
398
- g(t.length).toBe(2);
399
- }), _("updateMany with an AND predicate is an atomic compare-and-set (the wakeup-claim pattern)", async () => {
500
+ _(t.length).toBe(2);
501
+ }), v("updateMany with an AND predicate is an atomic compare-and-set (the wakeup-claim pattern)", async () => {
400
502
  await n.store.insert("voltro_parity_a", {
401
503
  id: "cas",
402
504
  title: "pending",
@@ -411,10 +513,10 @@ var C = (e) => ({
411
513
  op: "eq",
412
514
  value: e
413
515
  }] }), t = await n.store.updateMany("voltro_parity_a", { title: "claimed" }, { where: e("pending") });
414
- g(t).toBe(1);
516
+ _(t).toBe(1);
415
517
  let r = await n.store.updateMany("voltro_parity_a", { title: "claimed-again" }, { where: e("pending") });
416
- g(r).toBe(0);
417
- }), _("deleteMany removes only the rows matching the predicate + returns the count", async () => {
518
+ _(r).toBe(0);
519
+ }), v("deleteMany removes only the rows matching the predicate + returns the count", async () => {
418
520
  await n.store.insert("voltro_parity_a", {
419
521
  id: "d1",
420
522
  title: "x",
@@ -433,10 +535,10 @@ var C = (e) => ({
433
535
  op: "eq",
434
536
  value: 5
435
537
  } });
436
- g(e).toBe(2);
437
- let t = await n.store.query(C("voltro_parity_a"));
438
- g(t.map((e) => e.id)).toEqual(["d3"]);
439
- }), _("deleteMany emits one delete ChangeEvent per removed row (old-image)", async () => {
538
+ _(e).toBe(2);
539
+ let t = await n.store.query(w("voltro_parity_a"));
540
+ _(t.map((e) => e.id)).toEqual(["d3"]);
541
+ }), v("deleteMany emits one delete ChangeEvent per removed row (old-image)", async () => {
440
542
  await n.store.insert("voltro_parity_a", {
441
543
  id: "e1",
442
544
  title: "gone",
@@ -458,10 +560,10 @@ var C = (e) => ({
458
560
  op: "eq",
459
561
  value: "gone"
460
562
  } });
461
- t(), g(r).toBe(2);
563
+ t(), _(r).toBe(2);
462
564
  let i = e.filter((e) => e.op === "delete");
463
- g(i).toHaveLength(2), g(i.map((e) => e.id).sort()).toEqual(["e1", "e2"]);
464
- }), _("deleteMany with no match returns 0 and removes nothing", async () => {
565
+ _(i).toHaveLength(2), _(i.map((e) => e.id).sort()).toEqual(["e1", "e2"]);
566
+ }), v("deleteMany with no match returns 0 and removes nothing", async () => {
465
567
  await n.store.insert("voltro_parity_a", {
466
568
  id: "k1",
467
569
  title: "keep",
@@ -472,14 +574,14 @@ var C = (e) => ({
472
574
  op: "eq",
473
575
  value: "absent"
474
576
  } });
475
- g(e).toBe(0);
476
- let t = await n.store.query(C("voltro_parity_a"));
477
- g(t.length).toBe(1);
478
- }), _("retryFilter recognises the dialect's own transient codes", () => {
577
+ _(e).toBe(0);
578
+ let t = await n.store.query(w("voltro_parity_a"));
579
+ _(t.length).toBe(1);
580
+ }), v("retryFilter recognises the dialect's own transient codes", () => {
479
581
  let e = t.dialect.retryFilter(/* @__PURE__ */ Error("garbage"));
480
- g(["retry", "noRetry"]).toContain(e);
582
+ _(["retry", "noRetry"]).toContain(e);
481
583
  });
482
584
  });
483
585
  };
484
586
  //#endregion
485
- export { b as applySchema, A as runDialectParity };
587
+ export { x as applySchema, j as runDialectParity };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/testing",
3
- "version": "0.40.0",
3
+ "version": "0.42.0",
4
4
  "description": "Test utilities for Voltro apps — deterministic clock, subject and row factories, a handler-level invoke and a request-level app harness, queued LLM responses, scoped subject/tenant runners, and a cross-dialect parity harness.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -43,15 +43,15 @@
43
43
  "node": ">=24.0.0"
44
44
  },
45
45
  "dependencies": {
46
- "@voltro/database": "0.40.0",
47
- "@voltro/env": "0.40.0",
48
- "@voltro/logger": "0.40.0",
49
- "@voltro/protocol": "0.40.0",
50
- "@voltro/runtime": "0.40.0",
51
- "@voltro/workflow": "0.40.0"
46
+ "@voltro/database": "0.42.0",
47
+ "@voltro/env": "0.42.0",
48
+ "@voltro/logger": "0.42.0",
49
+ "@voltro/protocol": "0.42.0",
50
+ "@voltro/runtime": "0.42.0",
51
+ "@voltro/workflow": "0.42.0"
52
52
  },
53
53
  "peerDependencies": {
54
- "@voltro/client": "0.40.0",
54
+ "@voltro/client": "0.42.0",
55
55
  "effect": "^3.22.0",
56
56
  "react": "^19.0.0",
57
57
  "@effect/sql": "^0.52.0"