@voltro/database 0.19.0 → 0.20.1

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.
package/CHANGELOG.md CHANGED
@@ -39,6 +39,230 @@ _Changes staged for the next release accumulate here (rolled up from
39
39
 
40
40
  ---
41
41
 
42
+ ## [0.20.1] — 2026-07-30
43
+
44
+ ### Changed
45
+
46
+ - **@voltro/database, @voltro/runtime, @voltro/plugin-versioning, @voltro/plugin-presence, @voltro/voltro** — Five framework-table indexes were holding GENERIC names in a namespace that is shared with your tables. Index names are unique per SCHEMA on every supported dialect, so `_voltro_row_history.index('byTrace')` reserved `byTrace` for the whole database — and `byTrace` is the first thing anyone reaches for when indexing a `traceId`. A consumer added `traceId` to their own audit table, indexed it the obvious way, and collided with ours; the framework's own error message even suggested renaming the framework's index as the fix.
47
+
48
+ Renamed: `_voltro_row_history` `byTrace` → `byRowHistoryTrace`, `bySubject` → `byRowHistorySubject`; `_voltro_api_keys` `byTenant` → `byApiKeyTenant`; `_voltro_presence` `byChannel` → `byPresenceChannel`; `_voltro_connections` `bySubject` → `byConnectionSubject`. These are `_voltro_*` tables, so the rename rides the declarative differ on `voltro db apply` / boot — no codemod. Adopters see a one-time index rebuild.
49
+
50
+ A test now enforces the rule that most framework tables already followed: a framework index name must MENTION its own table. Mechanical, so it cannot rot the way a curated list of "generic" names would, and it does not demand the full `_voltro_<table>_<name>` form — which would force renaming ~20 already-safe indexes for no benefit. It also asserts no two framework tables claim the same index name, since installing two such plugins together would fail at migrate time for a reason neither plugin's author could see.
51
+
52
+ ### Fixed
53
+
54
+ - **@voltro/sql-mysql, @voltro/voltro** — A MariaDB table with a UNIQUE constraint on an UNBOUNDED text column can never be decoded from the binlog. The reader now says so ONCE — with the real cause and a remedy that works — and excludes the table, instead of looping on it forever.
55
+
56
+ **The mechanism.** MariaDB backs an unbounded UNIQUE with a **HASH long-unique index**, which adds a hidden `DB_ROW_HASH_n` column to the InnoDB row. That column IS in the binlog row image and is NOT in `information_schema.COLUMNS`, so the reader compares N+1 against N and throws on every write to that table:
57
+
58
+ ```text
59
+ Table app.sessions schema changed between binlog event and metadata fetch:
60
+ the event has 9 columns, fetched metadata has 8
61
+ ```
62
+
63
+ Nothing is broken; the table is shaped that way, permanently. The previous recovery (skip to the current binlog end) recovered nothing, because the end is exactly where the next failing write appears — a loop a consumer measured at roughly every 9 seconds, re-signalling resync to the whole fleet each pass.
64
+
65
+ **The cause we shipped in the previous entry was WRONG, and this retracts it.** It blamed a `DROP COLUMN` that ran as `ALGORITHM=INSTANT` leaving a phantom column, and told people to run `ALTER TABLE … FORCE`. The same consumer measured that: 9 InnoDB columns before the rebuild, 9 after, hidden column still present — the rebuild recreates the index and therefore recreates the hidden column. The repair line sent readers in a circle. They also disproved the version theory, being on the same MariaDB 11.8 we had tested on and failed to reproduce a phantom column with.
66
+
67
+ **Now:** affected tables are found at CDC start by a privilege-free probe — the direct evidence in `INNODB_SYS_COLUMNS` needs `PROCESS`, which an app DB user does not have, so the constraint SHAPE is inferred from `information_schema.STATISTICS` + `COLUMNS` instead — reported once as an error naming `text().maxLength(n)` as the remedy and `ALTER TABLE FORCE` as explicitly not one, and EXCLUDED from the reader.
68
+
69
+ Excluding is what makes it converge, and that is measured rather than assumed: an excluded table with a hidden hash column produces no reader error at all, while the same table included throws on the first write. Cross-instance change events for such a table are lost until it is bounded; own-node reactivity is unaffected (writes still emit inline).
70
+
71
+ Framework `_voltro_*` tables cannot hit this — they are filtered out of the reader's include list before it reaches the replication client, and exclusion demonstrably shields the metadata fetch.
72
+
73
+ **Caveat worth reading if you are already affected:** on a table that ALREADY exists, adding `.maxLength(n)` currently changes nothing — the schema differ does not diff text length, so it plans 0 operations and reports "up to date". That is a separate defect, reported in the same round and not yet fixed; until it is, the remedy only applies to newly created tables.
74
+ - **@voltro/cli, @voltro/voltro** — `voltro codegen` no longer writes a silently plugin-less `rpcGroup.generated.ts`, and it now reports what it merged.
75
+
76
+ `loadApiConfig` swallows every failure into `null`, and `config?.plugins ?? []` turned that into "this app has no plugins". So an `app.config.ts` that threw while importing produced a generated file with **no plugin error union and no plugin routes** — followed by `voltro codegen: wrote rpcGroup.generated.ts`. The file typechecks, so nothing downstream catches it; the only symptom is a client branching on an error tag that never arrives.
77
+
78
+ A consumer with ~140 declarative `guards:` measured that file 2781 lines shorter after a version bump, with the `ScopeError` import and the whole `__voltroPluginErrors` union gone. For the record, since they were careful to separate measurement from conclusion: the generator did NOT drop the feature — the plugin-codegen path is byte-identical between 0.19.0 and 0.20.0, and the published `@voltro/cli@0.20.0` does contain the identifier they grepped for. Their `grep` came back empty because the bundled chunk contained a literal NUL byte, which makes a file binary to most search tools (fixed separately, and it had been hiding files from our own audits too). What was real is the artefact diff, and this is the path that produces it without a word.
79
+
80
+ Now: a config that EXISTS but fails to load is a refusal with a non-zero exit and the underlying cause, not a quiet downgrade. An app with no `app.config.ts` at all still generates — absence is legitimate, failure is not. And every run prints `(plugins N, error schemas N, plugin routes N)`, because a count that drops from 7 to 0 has to be visible in the success line or the next occurrence is found the same way: by diffing artefacts during a debugging session.
81
+
82
+ `loadApiConfigDiagnosed` is the new seam (`{ config, present, error }`); `loadApiConfig` is unchanged for every existing caller.
83
+ - **@voltro/cli, @voltro/voltro** — `ssr cold-compile` log lines now carry the compile's duration, and `voltro start` emits them at all.
84
+
85
+ The lines had a `start` and an `end` and no timing, which looks readable and is not: cold compiles run concurrently up to `VOLTRO_DEV_SSR_COMPILE_CONCURRENCY`, so the pairs INTERLEAVE. Subtracting adjacent timestamps names the wrong module, and above a limit of two they cannot be paired by eye at all — which is what a user reading a pod log actually hit, with three `start` lines before their `end`s:
86
+
87
+ ```
88
+ …:59.704 ssr cold-compile start id=…/layout.tsx
89
+ …:59.704 ssr cold-compile start id=…/(main)/layout.tsx
90
+ …:03.447 ssr cold-compile end 3743ms id=…/layout.tsx
91
+ ```
92
+
93
+ The gate had the number for free and threw it away. It is measured INSIDE the concurrency permit, so it is the module's own compile cost rather than the time it spent queued behind the limit — those are different numbers and only one of them is a property of the module. A slow first paint is usually one slow module, and this is the line that names it.
94
+
95
+ A failed compile now says `FAILED` instead of `end`. Without that, a 3.7-second line for a module that threw read exactly like a slow but successful compile.
96
+
97
+ `voltro start`'s middleware fallback constructed the same gate with NO callbacks, so an on-demand compile there produced no line whatsoever; it is wired now.
98
+ - **@voltro/cli, @voltro/voltro** — `voltro db plans`, `db drift` and `db restore-snapshot` worked on postgres only. On mysql/mariadb (and mssql and sqlite) all three died with:
99
+
100
+ ```text
101
+ fatal unhandled cli error (FiberFailure) SqlError: Failed to execute statement
102
+ ```
103
+
104
+ The cause is three `${sql('col')}::text AS ${sql('col')}` casts — POSTGRES syntax, in read paths whose helper is still called `buildPgLayer`. `db apply`, which WRITES the same ledger table, has no cast and worked, which is exactly the split a consumer reported: the commands that read were broken, the one that writes was fine.
105
+
106
+ The casts existed to stop a driver handing back a `jsonb` object or a `Date`. Normalising in JS gets the same result and cannot be dialect-specific, since drivers differ in whether a json column arrives parsed and whether a timestamp arrives as a `Date`.
107
+
108
+ Worth naming what it cost: `db drift` is the command whose whole job is "alert if live diverged from declared", and the consumer who found this had live divergence at the time. The specific detector and the general one were blind together.
109
+
110
+ **And the error now names the failing statement.** Their verdict was the actionable part of the report:
111
+
112
+ > *"the error names no statement … the statement text (or even the operation name) > would turn this from a dead end into a bug report. We would have sent you the > failing SQL if the error had contained it."*
113
+
114
+ Right twice over — they could not diagnose it, and neither could we from the report; it took reading our own source. `@effect/sql`'s `SqlError` carries the driver error in `cause`, and every supported driver puts the useful part there (mysql2: `code`, `errno`, `sqlState`, `sqlMessage`, usually `sql`; pg: `code`, `detail`, `hint`, `position`). The CLI's fatal reporter printed only the wrapper. It now walks the cause chain and prints the driver message, the codes and the statement — collapsed to one line, and saying `<not attached by the driver>` when there genuinely is none, because that is information too.
115
+
116
+ Shape-based rather than `instanceof SqlError`, deliberately: the CLI catches errors that have crossed the serve/start bundle boundary, where two copies of `@effect/sql` make `instanceof` silently false — the failure mode this repo has already paid for elsewhere.
117
+ - **@voltro/cli, @voltro/voltro** — `voltro doctor`'s `plaintext-secret` rule no longer flags metadata ABOUT a credential. An audit row denormalising the public facts of an api key — `apiKeyId`, `apiKeyKeyId`, `apiKeyType`, `apiKeyOwnerId`, `apiKeyName` — had three columns already excluded by the `*Id` suffix, while `apiKeyType` and `apiKeyName` fired. Telling a team to encrypt the LABEL of a credential is how a rule earns being ignored.
118
+
119
+ The exclusion now covers final words that cannot BE the credential — `Name`, `Type`, `Kind`, `Label`, `Prefix`, `Suffix`, `Status`, `State`, `Scope(s)`, `Version`, `Count`, `Provider`, `Format`, `Note`/`Description`/`Comment`, plus the existing `Id` and the hash family. Deliberately NOT on the list: `Value`, `Secret`, `Token`, `Key`, `Password` — the words that name the thing itself. A false negative from an over-wide list is silent, so that is the failure mode the list is built against, and a test pins the words that must still fire.
120
+ - **@voltro/database, @voltro/cli, @voltro/voltro** — `voltro doctor` no longer contradicts itself about the `.serverOnly()` wire audit. The same command on the same tree reported:
121
+
122
+ ```
123
+ human: serverOnly: NOT CHECKED | json: {'checked': True, 'leaks': 0}
124
+ ```
125
+
126
+ Two causes, both fixed. `registerRelations` refused a re-registration of the IDENTICAL relation object, so a process that executes a module twice looked like two conflicting declarations — it now mirrors `registerTable`'s `existing === table` tolerance (a DIFFERENT block claiming the same name still throws). And doctor loaded the app three times per run; it now loads once, so every report sees the same outcome instead of the first one succeeding and the next failing.
127
+
128
+ The consequence was worse than the noise: the throw aborted the wire audit, so the check that a token cannot reach a client had not run since the reporting app adopted the marker — and a CI gate written exactly as we documented (`fail on serverOnly.checked === false`) reported green on an app where the audit provably had not run. That is the "reads as coverage without being coverage" failure the `serverOnly` field was added to remove, reappearing in the field added to prevent it.
129
+ - **@voltro/sql-mysql, @voltro/voltro** — `insertIgnore` on MariaDB no longer reports a cause it cannot know, and no longer turns a REJECTED write into a silent "conflict". `INSERT IGNORE` downgrades EVERY error to a warning — foreign key, NOT NULL, CHECK, truncation — so the post-check's premise ("the insert was skipped ⇒ a unique constraint fired") does not hold on this dialect. It asserted a second unique index that did not exist; the real cause was an FK (an auto-stamped `createdBy` with no matching `actors` row), and a consumer spent the diagnosis looking for a phantom index.
130
+
131
+ The message now reads the real error from `SHOW WARNINGS` on the same connection — BEFORE the existing-row lookup, since that lookup is itself a statement and resets the warning list. A non-duplicate warning is reported as a rejection and throws, because returning there is data loss presented as a normal outcome: the row is not written and the caller is told it already was. A genuine duplicate on an unnamed constraint now names the constraint that fired. Outside a transaction the warning cannot be attributed to our own statement (each statement acquires from the pool independently), so the message says the constraint is unknown rather than guessing — framework mutations are auto-transactional, so the common path has the cause.
132
+ - **@voltro/logger, @voltro/cli, @voltro/database, @voltro/voltro** — `voltro doctor --json` and `voltro capabilities --json` now emit exactly one JSON document on stdout. A `log.warn` from module discovery landed there ahead of it, so:
133
+
134
+ ```console
135
+ $ voltro doctor --json 2>/dev/null | python3 -c 'import json,sys; json.load(sys.stdin)'
136
+ JSONDecodeError: Extra data: line 2 column 1
137
+ ```
138
+
139
+ Note the `2>/dev/null` in that repro — stderr was already redirected, so there was no shell-side workaround. And it only happened when a warning fired, so a consumer's CI parsed the document correctly until one file out of 368 tripped one. That is the same failure the `serverOnly.checked` field was added to remove — an automat unable to separate the normal case from the special case — one layer out, in the surface added to fix it.
140
+
141
+ A command that owns stdout for machine output now calls `claimStdoutForJson()` before doing any work that could log, and every record goes to stderr from then on. The stream decision itself moved into ONE place (`@voltro/logger`'s `stream.ts`, exported as `routeDiagnosticsToStderr`): the Effect surface and the direct surface each carried their own copy of `level === 'error' ? stderr : stdout`, and two copies of one rule is how the rule failed to change.
142
+
143
+ **Also fixed, same report:** the warning that started it was itself wrong. A `*.relations.ts` whose `relations(...)` map is EMPTY was reported as *"no relations(...) export found"* — pointing the reader at a missing export that is right there. `isRelationsSpec` rejects an empty map (correctly — there is nothing to register), but the caller could not tell that apart from a module with no export at all. It now says the map is empty and names the export.
144
+ - **@voltro/cli, @voltro/voltro** — The SSR bundle build now externalises a bare specifier it cannot resolve instead of aborting, so an uninstalled OPTIONAL peer no longer makes `voltro build` impossible.
145
+
146
+ The SSR step runs with `ssr: { noExternal: true }` — inlining everything is what lets a production web image ship without a framework dependency tree — and that left no escape for a package that cannot be resolved at all. The commonest such package is an optional native peer reached through a library's Node entry:
147
+
148
+ ```
149
+ Rolldown failed to resolve import "canvas"
150
+ from ".../konva/lib/index-node.js"
151
+ ```
152
+
153
+ `konva`'s `main` is its Node build, which requires the optional native `canvas`; its `browser` field points at one that does not. An app that never renders to a canvas server-side has nothing to install.
154
+
155
+ A consumer measured that there was no way out from their side either, and each measurement is worth keeping: the import was ALREADY dynamic (rolldown must still resolve it to form the chunk), `renderMode: 'spa'` does not help (`.framework/app.tsx` imports every page statically for the router, so the module is in the SSR graph whatever the render mode), and an `ssr.external` passthrough in `app.config.ts` is not read. So `voltro build` — and with it the production image — was unavailable for that app.
156
+
157
+ The api serve bundle and the web start bundle already did exactly this; that plugin is esbuild's and this step is vite/rolldown, so it is the same probe behind a different interface. Framework packages (`@voltro/*`, `@effect/*`, `effect`) are never externalised, so the "needs nothing from node_modules" property still holds.
158
+
159
+ Every externalised specifier is NAMED in the `SSR bundle ready` line. Externalising is right for an uninstalled optional peer and wrong for a genuine missing dependency — it trades a loud build failure for a quiet runtime one — and only the reader can tell which, so it is reported rather than swallowed.
160
+ - **@voltro/sql-mysql, @voltro/sql-sqlite, @voltro/sql-mssql, @voltro/sql-postgres, @voltro/database, @voltro/voltro** — A typed error thrown inside a mutation now reaches the client TYPED, on every dialect. It arrived as an untagged `Die` defect on mysql/mariadb, sqlite and mssql: `transactional()` settled its program with `runPromise`, which rejects with Effect's `FiberFailure` wrapper, and the wrapper copies `message` and a decorated `name` but nothing else — no `_tag`, no payload, no prototype. So the rpc encoder could not match the failure against the mutation descriptor's `error:` union:
161
+
162
+ ```
163
+ └─ ["error"] └─ ["_tag"] └─ is missing
164
+ Expected never, actual (FiberFailure) NotFoundError: …
165
+ ```
166
+
167
+ Framework mutations are auto-transactional, so this was EVERY typed mutation error in an app. Nothing failed — `defineMutation({ error: … })` compiled, the client's type still said `NotFoundError`, and the `error._tag === 'NotFoundError'` branch was simply never taken at runtime. Actions, which are not auto-transactional, marshalled correctly the whole time, which is what made the transaction the discriminator. A hand-rolled error class lost its fields and its `instanceof` too; only `message` survived, which is why a workaround built on `error.message` looked like it worked and hid this.
168
+
169
+ Postgres already had the unwrap, with a comment describing this exact consequence, and the three sibling dialects kept the broken call — so the fix is now one shared `settleTransactionExit` in `@voltro/database` that all four import, plus a parity test that fails if any store's `transactional()` reaches `runtime.runPromise` again. Reported by a consumer on MariaDB who verified it against 0.19.0 too, so it is not a 0.20.0 regression.
170
+
171
+ ### Internal (no consumer-facing effect)
172
+
173
+ - **@voltro/runtime, @voltro/database, @voltro/protocol, @voltro/cli, @voltro/plugin-billing, @voltro/plugin-mail, @voltro/plugin-sso-saml, @voltro/plugin-storage** — Fourteen source files carried a LITERAL NUL byte — the house idiom for a composite map key, written as the raw character instead of an escape. That makes the file BINARY to every text tool: `grep` skips it entirely and reports nothing, which is indistinguishable from a clean file. It was found because a new guard test scanning for framework index names came back clean on `runtime/src/connectionVault.ts` — 1020 lines that every previous grep-based audit in this repo had also silently skipped, including the one looking for exactly the index name that file declares.
174
+
175
+ Replaced with the JavaScript escape for U+0000. Identical runtime value, files are text again. No behaviour change.
176
+
177
+ ---
178
+
179
+ ## [0.20.0] — 2026-07-29
180
+
181
+ ### ⚠ BREAKING
182
+
183
+ - **@voltro/plugin-versioning, @voltro/database, @voltro/voltro, @voltro/sql-postgres, @voltro/sql-mysql, @voltro/sql-sqlite, @voltro/sql-mssql** — `versioningPlugin({ timing: 'in-transaction' })` produced a WRONG trail, not merely a slow one. Reported and reproduced against MariaDB 11 by a team that wired both plugins and measured before migrating a single call site.
184
+
185
+ **It recorded every change twice.** The two timings are alternatives, but the post-commit change tap stayed wired when the in-transaction recorder was registered, so both ran. One `bookmarks.create` → two history rows.
186
+
187
+ **And the trail was mis-ordered, which is worse.** Each path numbered independently: one insert plus one update produced versions `0, 0, 1, 2` across four rows. `selectAsOf`, `sortHistory` and `diffVersionRows` all read `version`, so `rowAsOf` returned the wrong snapshot and `diffVersions` found nothing. A duplicate can be deduped; a wrong order cannot be detected from the data.
188
+
189
+ The recorder wrote a constant `version: 0` on purpose, with a design note arguing that ordering could come from `changedAt` and that a read per covered write was too expensive. Both halves were wrong: `changedAt` is millisecond-resolution, so two writes to one row inside one transaction tie routinely, and the number is what every reader consults.
190
+
191
+ **BREAKING —** a `WriteRecorder` now receives a PORT (`{ append, maxOf }`) rather than a bare `append`. `maxOf` is one aggregate with an equality filter on the connection the write already holds; it is what lets an append-only trail number its own entries. A recorder still cannot UPDATE, DELETE or open a nested transaction, and a throw from either operation still rolls the caller's write back. Apps that merely ENABLE the timing need no change — only a hand-written recorder does, and `tsc` names every site.
192
+
193
+ **Cost, stated rather than avoided:** `'in-transaction'` now takes TWO round-trips per recorded write, roughly doubling this timing's published per-write overhead. Both timings number from 1, so switching `timing` no longer shifts version numbers.
194
+
195
+ ### Fixed
196
+
197
+ - **@voltro/database, @voltro/sql-postgres, @voltro/sql-mysql, @voltro/sql-sqlite, @voltro/sql-mssql** — The correlation bridge did not survive a transaction, and did not survive CDC. Both are fixed, and both were found by measuring against live databases after a consumer isolated the symptom in a scratch app.
198
+
199
+ **Every write a framework mutation makes was unattributed.** `transactional()` is entered from the request's async-local scope, but its callback runs from inside the Effect the store builds — and measured against live postgres AND live mariadb, the scope is active at the call site and EMPTY inside the callback. Framework mutations are auto-transactional, so this was every handler write. Same class as the `bindMutation` defect fixed alongside it: a scope covering the construction of an Effect and not its execution. The caller's attribution is now captured at `transactional()` entry and re-established around the callback, in all four dialect stores.
200
+
201
+ **And the CDC transports could not carry it at all.** Under `changeStrategy: 'cdc'` — the DEFAULT — the event a subscriber receives is rebuilt from a postgres NOTIFY payload or a mysql binlog row image, neither of which can hold a request context. `registerPendingAttribution` / `claimPendingAttribution` (`@voltro/database`) let the write path hand its identity to the echo, keyed by `(table, op, id)` and claimed once. A write made on ANOTHER replica has nothing pending and stays unattributed, which is the correct answer rather than a gap.
202
+
203
+ **Plus one nobody had reported, found on the way:** on postgres under CDC the write path skipped `routeEvent` entirely, and `runWriteRecorders` lives inside it — so `versioningPlugin({ timing: 'in-transaction' })` with the default `CDC=1` recorded NOTHING. The mode whose entire promise is "if the change committed, the entry is there" wrote an empty trail, silently. `routeEvent` now runs in both modes; only the DELIVERY decision is strategy-dependent.
204
+
205
+ New live-dialect suites (`cdcAttribution.integration.test.ts` in `sql-postgres` and `sql-mysql`) pin all of it, and were verified red against the previous code.
206
+ - **@voltro/plugin-versioning, @voltro/runtime, @voltro/cli** — `_voltro_row_history.traceId` and `.subjectId` were NULL on every write. Three independent causes, all found from one consumer report whose evidence pinned the diagnosis before we looked: `subjectId` was NULL while `changedBy` on the SAME row carried the acting user — so the identity was known and was not travelling.
207
+
208
+ - **The adapter dropped them.** `dataStoreHistoryStore.append` hand-wrote its insert object and listed `changedBy` but not `traceId` / `subjectId`. This is the second time that shape has bitten in this file — the READ side (`rowToVersion`) had drifted identically. A row built by hand in one place and read by hand in another disagree exactly when a field is ADDED, because nothing fails. Both now spread the row. - **An Effect-returning handler was unattributed.** `bindMutation` established the scope around the CALL, which covers an async executor for its whole run — but an Effect-returning one is only CONSTRUCTED there and runs later. It is now forked inside the scope, with interruption and typed failures preserved (both pinned by tests). Verified by measurement, not assumption: an Effect forked inside an ALS scope keeps seeing it across `sleep`, `yieldNow` and a `setTimeout` promise, while the same effect merely constructed inside sees nothing. - **The devtools `/invoke` path never entered the scope at all.** It bypasses the rpc stack by design, and that also bypassed everything `bindMutation` sets up. The audit plugin recorded a traceId (it reads `requestContext.traceId`, which this path does build) while every write underneath carried none — three consumers of one call disagreeing about its trace. It also synthesised `inspect-<8 random chars>`, which no trace consumer can parse; the reporter's framing is the rule worth keeping — *a synthesised id produces a column that looks joinable and is not; NULL at least fails honestly.* It is a real 32-hex id now, and it reaches all three sinks.
209
+
210
+ `actingUserId` is imported at the new call site rather than re-derived — one answer to "who is writing", shared with what `audit()` stamps.
211
+ - **@voltro/cli** — Three ways a check reported nothing while checking nothing, all found by a consumer verifying the silence instead of trusting it.
212
+
213
+ - **`unexercised-row-filter` never fired on a typed registration.** The match was `/\bsetRowFilter\s*\(/`, which demands the paren directly after the name, so `setRowFilter<Ctx>({…})` — the spelling our own generic signature invites — broke it. The rule was blind for exactly the teams that had wired `load`/`predicate` carefully. It counts CALLS now. - **…and its test-side condition was satisfiable by a COMMENT.** It matched `rowFilter:` in raw text. Comments and string literals are stripped, and the suite must both call `makeTestContext` and bind `rowFilter` in real code. - **The same paren-adjacent shape sat in two shipped codemod gates.** `0.7.0/01` (row filter) and `0.7.0/02` (`invoke`) both gate on a generic export, so a typed call made `voltro update` print nothing at all: the upgrade reads as clean and the behaviour change lands unread. Both now use the shared `callPattern`, which allows type arguments including nested ones.
214
+
215
+ Two false-positive fixes in the hand-roll detector, from the same report:
216
+
217
+ - **A file that WIRES a plugin is no longer told to adopt it.** The `presence` rule reported `app.config.ts` (which calls `presencePlugin()`) to an app that had just deleted its hand-rolled table. Rules that recommend a package now declare it, and a file referencing that package is skipped. - **Generated files and `.d.ts` are out of the scan.** A recommendation aimed at a file the next boot overwrites is never actionable.
218
+
219
+ And one more of the first kind, found while checking why a withdrawn report's probe had stayed silent: `raw-fetch` counted only a BARE `fetch(…)` callee, so `globalThis.fetch(url)` / `self.fetch(url)` in a server file read as clean.
220
+ - **@voltro/cli** — `voltro doctor`'s `serverOnly: NOT CHECKED` line now names the failure, and the field exists in `--json`.
221
+
222
+ The refusal to claim a pass was right. What shipped with it was nothing to act on: the `catch` discarded the error entirely, so there was no reason, no failing module, and — because the field was absent from `--json` — no way for CI to assert "still unchecked" rather than reading silence as a pass.
223
+
224
+ A consumer's verdict, which is the useful part: *"The message is honest and that is the problem."* They had already verified that every descriptor, `app.config.ts` and the generated rpc group imported cleanly under `tsx` on their own, so the difference had to be in what `loadDiscovered` does BEYOND importing — and none of that was visible from outside. It matters more than its size because `.serverOnly()` is what guards their `sessions.tokenHash` and `apiKeys.keyHash`, markers they added after finding a query whose output schema shipped a hash over the wire.
225
+
226
+ `--json` now carries `serverOnly: { checked, reason?, leaks? }`. Gate CI on `checked === false`.
227
+ - **@voltro/plugin-versioning** — A version snapshot no longer copies `.serverOnly()` columns into `_voltro_row_history`. `.encrypted()` columns are KEPT, and that distinction is the whole finding.
228
+
229
+ Reported by a team choosing which tables to version: `sessions` holds `.encrypted()` PATs and a `tokenHash`, `apiKeys` holds a `keyHash`, and they could not determine from outside what the snapshot would contain. They excluded both tables — then went and measured it, which corrected their own report:
230
+
231
+ ```
232
+ probeItems.secret enc:v1:a56iziEV9THLhzmJ:Vk0ux+0bECleTLBJkCa0Rg==:3AtMwP…
233
+ _voltro_row_history {"secret":"enc:v1:a56iziEV9THLhzmJ:Vk0ux+0bECleTLBJkCa0Rg==:…"}
234
+ ```
235
+
236
+ **`.encrypted()` lands as ciphertext, byte-identical to the source column**, so versioning such a table widens nothing — the history is exactly as readable as the row it came from. Withholding it would have cost real audit data to prevent an exposure that does not exist.
237
+
238
+ **`.serverOnly()` is withheld**, and the reason is not "a second copy under different retention" — that argument is weak on its own, since the hash already sits in the source table. The decisive one: `crud.*` STRIPS `.serverOnly()` columns from every row it returns, and a snapshot would smuggle the same value back past that stripping inside a `json()` blob, where no column-level rule applies.
239
+
240
+ Withheld names are listed under `data._omitted`, so a reader can tell "this column was withheld" from "this column did not exist then". Both timings apply the same policy. `.sensitive()` is not involved: it is an export-masking marker for values that are legitimately readable in the app.
241
+ - **@voltro/cli** — A page that RE-EXPORTS its component (`export { default, renderMode } from '../page'`) no longer fails the codegen gate with "exports no default". The check required the literal words `as default`, so the one spelling that lets two routes share a screen without copying it was the one spelling it refused — and it refused in `voltro build`, while dev and tests stayed green because nothing prerenders there. `export { default as Screen }` is still correctly rejected: it renames the default away.
242
+
243
+ Two follow-ons from the same shape:
244
+
245
+ - The refusal message said the file "ends in `.page.tsx`" and offered "drop the `.page` suffix" as a fix. That is the 0.15.0 convention, replaced by directory routing in 0.17.0 — it named a convention that no longer exists and a fix that could not work. It now names `page.tsx` and both real fixes. - `scanRenderProfile` read a forwarded `renderMode` as absent and fell back to `'static'`, so `staticSafe` and the deploy-target classification could call an app CDN-deployable with an `ssr` route in it. The forward is now followed (relative specifiers, depth-capped); an unresolvable one still falls back rather than failing the scan.
246
+ - **@voltro/database** — `VOLTRO_SOFT_DROP=1` could never converge. The applier renames the object to `<name>__dropped_<ts>` instead of dropping it, which leaves it undeclared — and the differ read that as one more forgotten table, planning the drop again. The re-plan inside `applyPlan` then found an operation still outstanding and aborted with "the DDL for these operations is a no-op — this is a framework bug", which was a wrong diagnosis of a real defect: the DDL had worked. No fingerprint was recorded, so the migration counted as unapplied and every later `db apply` / boot hit the same wall. The only exit was a hard drop of the snapshot — exactly the recoverability the flag is chosen for.
247
+
248
+ The planner now treats `<name>__dropped_<YYYYMMDDHHMMSS>` as framework-managed, alongside `_voltro_*` / `cluster_*`. Deliberately not retention-aware: a planner whose output depends on the clock would produce different plans before and after midnight, and `db gc-snapshots` already owns expiry.
249
+
250
+ Reported against tables; the same defect existed one level down for soft-dropped COLUMNS, where it was worse — a re-planned `drop-column` carries no `dropped()` marker and so refuses to plan at all. Both are fixed.
251
+
252
+ The convergence message itself no longer asserts a cause it cannot know. It said "the DDL for these operations is a no-op", which was flatly wrong here and sent the reporter looking for dead DDL. It now names both causes — no-op DDL, and a planner that cannot see what the DDL did — and says which one an operation naming a just-renamed object usually is.
253
+
254
+ ### Internal (no consumer-facing effect)
255
+
256
+ - **The `0.20.0/01_write-recorder-port` codemod gains the gate test its two predecessors have.**
257
+
258
+ `codemodRegistry.test.ts` asserts that every `*.codemod.ts` on disk is registered and that ids are unique — registration, not behaviour. What it cannot see is the one way a `manual` codemod fails in practice: an `appliesTo` that is too broad, so the note prints for projects that have nothing to do. That is not a cosmetic problem. A note which fires on every app is how readers learn to skip notes, and the next one carries a boot refusal.
259
+
260
+ This codemod is the case where the silent direction matters most. The break is a TYPE error, so `tsc` already names every affected site; the note exists only to explain `maxOf`, which the compiler cannot. Apps that merely ENABLE `timing: 'in-transaction'` need to do nothing — `plugin-versioning` ships the recorder and it is already updated — and they are the large majority.
261
+
262
+ Four cases, covering both directions: a project registering its own recorder (note prints, and names `{ append }`, `maxOf`, and the `null`-is-not-zero distinction that a hand-written sequence gets wrong), an app that only enables the timing (silent), the identifier in a comment or a string (silent), and the generic call form `registerWriteRecorder<Row>(…)`, which `callPattern` admits and a naive match would miss.
263
+
264
+ ---
265
+
42
266
  ## [0.19.0] — 2026-07-29
43
267
 
44
268
  ### ⚠ BREAKING
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ConfigError } from 'effect';
2
2
  import { Effect } from 'effect';
3
+ import { Exit } from 'effect';
3
4
  import { Layer } from 'effect';
4
5
  import { Schedule } from 'effect';
5
6
  import { Schema } from 'effect';
@@ -177,6 +178,12 @@ export declare const attributionFields: () => {
177
178
  subjectId?: string | null;
178
179
  };
179
180
 
181
+ /** The write's identity, as both sides can compute it. NOT the row image: the
182
+ * transport re-encodes values (dates as strings, numbers as strings on some
183
+ * drivers), so an image hash would disagree across the two sides and silently
184
+ * never match. `(table, op, pk)` is stable through any re-encoding. */
185
+ export declare const attributionKey: (table: string, op: string, primaryKey: unknown) => string;
186
+
180
187
  /**
181
188
  * Audit a list of tables in one call. Convenience for the CLI's boot
182
189
  * path; same shape as calling `auditTableIndexes` per table and
@@ -522,9 +529,22 @@ export declare type ChangeEvent = {
522
529
  */
523
530
  export declare type ChangeStrategy = 'inline' | 'cdc';
524
531
 
532
+ /**
533
+ * Claim the attribution for an echo, or `undefined` if this write did not
534
+ * originate here.
535
+ *
536
+ * Claiming REMOVES it: one registration answers exactly one echo, so a second
537
+ * echo of a different write to the same row cannot inherit the first's
538
+ * identity.
539
+ */
540
+ export declare const claimPendingAttribution: (key: string) => WriteAttribution | undefined;
541
+
525
542
  /** Wipe — used by tests + the dev-loop hot-reload. */
526
543
  export declare const clearEnumRenames: () => void;
527
544
 
545
+ /** Test seam. */
546
+ export declare const clearPendingAttribution: () => void;
547
+
528
548
  /** Wipe the registry. Used by tests + the dev-loop hot-reload. */
529
549
  export declare const clearRelationsRegistry: () => void;
530
550
 
@@ -2617,6 +2637,25 @@ export declare const interval: () => ColumnBuilder<string, "interval", boolean>;
2617
2637
  * tenant namespace). */
2618
2638
  export declare const isBranchNamespace: (namespace: string) => boolean;
2619
2639
 
2640
+ /**
2641
+ * A `relations(...)` result whose map is EMPTY — a spec in shape, contributing
2642
+ * nothing.
2643
+ *
2644
+ * `isRelationsSpec` rejects it (registering nothing has no meaning), which is
2645
+ * right, but the caller then cannot tell it apart from a module with no
2646
+ * `relations(...)` export at all. `voltro dev` reported both as *"no relations(...)
2647
+ * export found"*, and a consumer with 368 relations files got exactly one warning
2648
+ * pointing at a file that HAS the export:
2649
+ *
2650
+ * export const easyProxyIntegrationsRelations = relations(easyProxyIntegrations, ({ one }) => ({
2651
+ * }))
2652
+ *
2653
+ * A message that sends you looking for something that is right there is worse than
2654
+ * no message. Almost certainly an unfinished edit, so it is still worth warning
2655
+ * about — just about the truth.
2656
+ */
2657
+ export declare const isEmptyRelationsSpec: (value: unknown) => boolean;
2658
+
2620
2659
  export declare const isEncrypted: (value: unknown) => value is string;
2621
2660
 
2622
2661
  export declare const isFieldDecryptionError: (e: unknown) => e is FieldDecryptionError;
@@ -2644,15 +2683,6 @@ export declare const isPrimaryKeyConflictError: (err: unknown) => err is Primary
2644
2683
  /** Can THIS deployment serve the region? */
2645
2684
  export declare const isRegionServable: (region: string, config: ResidencyConfig) => boolean;
2646
2685
 
2647
- /**
2648
- * Runtime guard — is `value` the result of a `relations(...)` call?
2649
- *
2650
- * `voltro dev`'s discovery uses this to pick the relation specs out of a
2651
- * `*.relations.ts` module's exports (or `relations(...)` declared inline in a
2652
- * `*.entity.ts`). Strict enough to reject tables, schemas, and arbitrary
2653
- * consts: a spec has a `source` THUNK plus a non-empty `relations` map whose
2654
- * every entry carries a `Relation` `kind` discriminator.
2655
- */
2656
2686
  export declare const isRelationsSpec: (value: unknown) => value is RelationsSpec;
2657
2687
 
2658
2688
  export declare const isSeedDefinition: (value: unknown) => value is SeedDefinition;
@@ -3240,6 +3270,9 @@ export declare const paginateBy: (descriptor: QueryDescriptor, column: string, c
3240
3270
  */
3241
3271
  export declare const paginateById: (descriptor: QueryDescriptor, cursor: string | undefined, limit: number) => QueryDescriptor;
3242
3272
 
3273
+ /** Test seam — how many registrations are outstanding. */
3274
+ export declare const pendingAttributionCount: () => number;
3275
+
3243
3276
  /**
3244
3277
  * Dispatch the provision plan by mechanism — the instant Neon CoW branch-create,
3245
3278
  * or the portable namespace snapshot fan-out. One call site for the cloud
@@ -4202,11 +4235,38 @@ export declare const registerCoreTables: (options: CoreTableRegistration) => voi
4202
4235
  */
4203
4236
  export declare const registerDiscoveredRelations: (moduleExports: Record<string, unknown>) => number;
4204
4237
 
4238
+ /**
4239
+ * Remember this write's attribution so its transport echo can be re-attributed.
4240
+ *
4241
+ * No-op when there is nothing to remember — a write with no request behind it
4242
+ * must stay unattributed, and registering an empty entry would make the queue
4243
+ * lie about which echo belongs to which write.
4244
+ */
4245
+ export declare const registerPendingAttribution: (key: string, attribution: WriteAttribution) => void;
4246
+
4205
4247
  /**
4206
4248
  * Register a single `relations()` spec. Multiple specs on the same
4207
4249
  * source MERGE — a second spec adds to the first one. A name
4208
- * collision between two specs throws here so the offending
4250
+ * collision between two DIFFERENT specs throws here so the offending
4209
4251
  * declaration site is the error scope, not a downstream consumer.
4252
+ *
4253
+ * Re-registering the SAME relation object is a no-op, mirroring
4254
+ * `registerTable`'s `existing === table` tolerance — and for the same reason:
4255
+ * a module that gets executed twice in one process must not look like two
4256
+ * conflicting declarations. Reference equality, not a structural compare: a
4257
+ * `Relation` holds target thunks, so "identical" can only honestly mean "the
4258
+ * very same declaration". A hot-reload re-import produces new objects, and that
4259
+ * path clears the registry first.
4260
+ *
4261
+ * This was NOT a hypothetical. `voltro doctor` calls `loadDiscovered` several
4262
+ * times in one run (the serve preflight, then the `.serverOnly()` wire audit,
4263
+ * then the workflow-start audit); ESM caches the module, so the second call
4264
+ * handed the identical spec back and this threw `duplicate relation 'owner' on
4265
+ * 'projects'` for an app that declared it exactly once. Renaming the relation
4266
+ * moved the name in the message and changed nothing else, which is how a
4267
+ * consumer proved it was the module and not the name. The consequence was worse
4268
+ * than the noise: the throw aborted the `.serverOnly()` audit, so the check that
4269
+ * a token cannot reach the wire had not run since that app adopted the marker.
4210
4270
  */
4211
4271
  export declare const registerRelations: (spec: RelationsSpec) => void;
4212
4272
 
@@ -4464,7 +4524,7 @@ export declare const runWithWriteAttribution: <T>(attribution: WriteAttribution,
4464
4524
  * reproduce the post-commit hole while looking like it had closed it, which is
4465
4525
  * the worse of the two by a distance.
4466
4526
  */
4467
- export declare const runWriteRecorders: (append: TxnAppend, write: RecordedWrite) => Promise<void>;
4527
+ export declare const runWriteRecorders: (port: TxnRecorderPort, write: RecordedWrite) => Promise<void>;
4468
4528
 
4469
4529
  /**
4470
4530
  * Lower a tenant id to the safe identifier fragment used inside a
@@ -4655,6 +4715,22 @@ export declare const serverOnlyColumns: (table: TableLike) => ReadonlyArray<stri
4655
4715
  * to the pure resolvers in tests instead. */
4656
4716
  export declare const setResidencyConfig: (config: ResidencyConfig) => ResidencyConfig;
4657
4717
 
4718
+ /**
4719
+ * Unwrap a transaction program's `Exit`: return the value, or throw the
4720
+ * ORIGINAL error rather than Effect's `FiberFailure` wrapper.
4721
+ *
4722
+ * Use with `runtime.runPromiseExit`, never `runPromise` — the wrapper is
4723
+ * created by `runPromise` itself, so there is nothing left to unwrap by the
4724
+ * time it rejects.
4725
+ *
4726
+ * `Cause.squash` is what preserves the typing: for a `Fail` it yields the value
4727
+ * that was thrown (the app's `TaggedError`, so the rpc encoder can still match
4728
+ * it against the descriptor's `error:` schema); for a `Die` the defect; for an
4729
+ * interrupt an `InterruptedException`. Retry filtering has already run inside
4730
+ * the program, so an Exit reaching here is final.
4731
+ */
4732
+ export declare const settleTransactionExit: <A>(exit: Exit.Exit<A, unknown>) => A;
4733
+
4658
4734
  /**
4659
4735
  * PostGIS spatial-distance clause carried on a {@link QueryDescriptor}.
4660
4736
  * Drives a `ST_Distance` projected column (distance-as-a-value) and/or a
@@ -5471,6 +5547,23 @@ export declare const timestampMsOrNull: Schema.Schema<Date | null, number | null
5471
5547
  /** Append one row inside the caller's transaction. Insert-only by design. */
5472
5548
  export declare type TxnAppend = (table: string, row: Row) => Promise<void>;
5473
5549
 
5550
+ /**
5551
+ * `MAX(column)` over the rows matching an equality filter, on the caller's
5552
+ * transaction connection. `null` when nothing matches.
5553
+ *
5554
+ * Equality-only and single-aggregate on purpose — see the header. It exists so
5555
+ * an append-only trail can number its own entries; it is not a query facility,
5556
+ * and widening it into one would give back exactly the read-modify-write reach
5557
+ * this seam was shaped to withhold.
5558
+ */
5559
+ export declare type TxnMaxOf = (table: string, column: string, where: Readonly<Record<string, string>>) => Promise<number | null>;
5560
+
5561
+ /** Everything a recorder may do inside the caller's transaction. */
5562
+ export declare interface TxnRecorderPort {
5563
+ readonly append: TxnAppend;
5564
+ readonly maxOf: TxnMaxOf;
5565
+ }
5566
+
5474
5567
  /** The minimal store surface `insertRow` needs — satisfied by `ctx.store`. */
5475
5568
  export declare interface TypedInsertStore {
5476
5569
  readonly insert: (table: string, row: Row) => Promise<Row>;
@@ -5888,6 +5981,6 @@ export declare interface WriteAttribution {
5888
5981
  readonly subjectId?: string | null;
5889
5982
  }
5890
5983
 
5891
- export declare type WriteRecorder = (append: TxnAppend, write: RecordedWrite) => Promise<void>;
5984
+ export declare type WriteRecorder = (port: TxnRecorderPort, write: RecordedWrite) => Promise<void>;
5892
5985
 
5893
5986
  export { }