@voltro/runtime 0.41.0 → 0.43.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.
package/CHANGELOG.md CHANGED
@@ -39,6 +39,194 @@ _Changes staged for the next release accumulate here (rolled up from
39
39
 
40
40
  ---
41
41
 
42
+ ## [0.43.0] — 2026-08-18
43
+
44
+ ### ⚠ BREAKING
45
+
46
+ - **@voltro/data-transfer, @voltro/cli** — `DanglingReferenceError` is now `RowsRefusedError`, and it separates the rows that failed from the rows that failed because those rows did.
47
+
48
+ **The name.** The import raised it for EVERY row still refused after deferred-FK resolution, whatever the reason — a NOT NULL violation, a duplicate key, a value the database computes for itself. The tag named ONE possible cause and put it where a reader looks first, so any other refusal arrived mislabelled. The new name states the outcome; each row's `reason` states the cause, which is where a cause can honestly be claimed.
49
+
50
+ **The split.** A row is `derived` when one of its reference columns holds the primary key of another row that also failed in this run: it could not have landed whatever it contained, so its reason describes the parent's problem. The relation is transitive, decided from the DATA (the failed ids against the reference-typed values), so no schema knowledge is needed. `primaryCount` is the number an operator acts on, `rows` lists primary failures FIRST so the cap never spends its budget on consequences, and the CLI leads with both numbers:
51
+
52
+ ```
53
+ import refused 300 row(s), of which 1 are the actual failures — the rest could
54
+ not land because a row they reference did not.
55
+ teams t1 foreign key teams_ibfk_1: the referenced row does not exist [1452]
56
+ … and 299 row(s) behind them. Fix the 1 above and re-run; they resolve with
57
+ their parents.
58
+ ```
59
+
60
+ In an FK-dense bundle one refused parent takes its whole subtree with it, so the length of a flat list says how connected the data is, not how many problems there are — and the single row that explains all of them sits somewhere in the middle of it.
61
+
62
+ The codemod rewrites the import and every use of the symbol. It does NOT rewrite a tag STRING (`Effect.catchTag('DanglingReferenceError', …)`, `err._tag === '…'`) — change those to `'RowsRefusedError'` — and the payload gained `primaryCount` plus a `derived` flag per row.
63
+
64
+ ### Fixed
65
+
66
+ - **@voltro/cli** — `voltro doctor`'s `subject-write-no-guard` rule reads the DESCRIPTOR before it reports. It looked only at the executor, and the access decision is not declared there.
67
+
68
+ Every form of access decision the framework has — `internal: true`, `guards: [...]`, `openAccess:` — is declared on the DESCRIPTOR. So an app that declares them properly got a finding for each one, and on a codebase whose procedures are mostly `internal: true` the rule fires on essentially all of them and is wrong essentially every time.
69
+
70
+ That is worse than a rule that finds nothing: it is the longest line in the report and it reads like a security finding, so it teaches the reader to skim the place a real finding would have appeared.
71
+
72
+ The premise was structurally impossible for most of them, and the framework says so itself: `security.defaultDeny` refuses at boot any wire-exposed procedure declaring neither `guards:` nor `openAccess:`. So "an anonymous caller reaches the write" can only be true of an `openAccess` procedure. That is what the rule looks for now — plus the handler check it always honoured, plus an ownership comparison against `subject.id`, which is the refusal the rule says is missing. Where no descriptor can be read, it says nothing: the claim is about a declaration, and a finding whose evidence was never opened is the failure mode this fixes.
73
+
74
+ The `use:` line changed with it. It recommended `.guard(requireScope('…'))`; the shipped guide teaches declarative `guards:` and calls a hand-written per-executor scope check the thing `guards:` exists to delete. A rule may not recommend the shape the guide argues against.
75
+ - **@voltro/database, @voltro/data-transfer** — A `voltro data` transfer no longer carries GENERATED column values, and no longer loses every row that has one.
76
+
77
+ The export wrote the computed values into the bundle and the import sent them back in the `INSERT` column list. MariaDB refuses that for any value except NULL (`1906: The value specified for generated column 'x' in table 't' has been ignored`); postgres refuses a non-DEFAULT value outright. So the transfer failed per ROW, not per table, and only for the rows whose generated value was non-NULL.
78
+
79
+ That selectivity is the dangerous part. `.uniqueActive()` lowers to exactly such a column on mysql/mariadb — a STORED generated column holding the key while the row is live and NULL once it is soft-deleted — so the refused rows are the LIVE ones and the accepted ones are the tombstones. A table can come out looking like "a few rows failed" or empty, depending only on how many of its rows are deleted, and any table with a foreign key into it fails behind it.
80
+
81
+ Both ends are fixed from one source of truth: **introspection now reports generated columns on every dialect** (`generatedAs`, from `information_schema.generation_expression` on mysql/mariadb, `is_generated` on postgres, `PRAGMA table_xinfo`'s hidden flag on sqlite, `sys.computed_columns` on mssql). It was declared-side only before — invisible to the planner, which does not compare it, and load-bearing for anything that writes rows back.
82
+
83
+ The exporter omits those columns, values and all. The importer strips them from every incoming row using the TARGET's snapshot, because a bundle already written still carries them and a file on disk is data, read where it is.
84
+
85
+ **`voltro serve`'s admin export/import needed a second fix, and without it this one reached only the direct transport.** The running instance hands those handlers `declaredSnapshot(tables)` — no dialect — and `.uniqueActive()` lowers to a generated column only when the snapshot knows the engine. So over `--target api` the snapshot described a schema with no generated columns while the database had several, and the export wrote their values back into the bundle exactly as before. It passes the dialect now (the variable was already on the next line).
86
+
87
+ `generatedAs` is also kept OUT of the schema fingerprint. Introspection can read the fact back but not a comparable value — the engine returns its own normalisation of the expression, never the declared spelling — so hashing it would make declared and live disagree permanently: a schema nobody touched reporting a changed declaration on every boot, and a transfer target that matches its bundle exactly refused as drifted.
88
+
89
+ Covered by a live mariadb→mariadb and mysql→mysql round trip over a `.uniqueActive()` table with live and soft-deleted rows, asserting the target recomputed the value rather than that the row merely arrived.
90
+ - **@voltro/sql-mysql** — On mysql/mariadb, a write REJECTED by the database through `insertIgnore` was reported as a conflict when the caller was not inside a transaction — and never reached the caller as a typed `ConstraintViolation` at all.
91
+
92
+ Two causes, both measured against live MySQL 8.4 and MariaDB 11.
93
+
94
+ **The connection.** `INSERT IGNORE` demotes every error to a warning, so the store reads `SHOW WARNINGS` to tell a rejection from a conflict. That describes the last statement on a CONNECTION, and outside a transaction every statement acquires its own from the pool — so the read was unattributable and came back empty. The rejected write then surfaced as "the insert was skipped as a conflict, but no existing row matches conflictColumns […] the constraint that fired is unknown", whose enumeration lists only conflict causes. A rejection described as a conflict is the exact sentence this path was fixed once already for producing; it survived on the path that had no transaction to read on. The store now pins one connection for the whole decision — the same pinning `insertRecoverAutoId` does for `LAST_INSERT_ID()`.
95
+
96
+ **The classification.** The store swallowed the driver's error and raised a prose one of its own, so `classifyConstraintViolation` had nothing to read: this was the one write path where the typed error could not fire, while every other one produced it. The warning IS the driver's payload — `INSERT IGNORE` only changed how it was delivered — so it is handed on in the shape the driver would have thrown. A rejection now arrives as the same `ConstraintViolation { kind: 'foreignKey', … }` a plain `insert` produces. Nothing new crosses the wire: the classifier extracts the constraint NAME as a delimited group, never the sentence.
97
+
98
+ This is the default `voltro data import` path (`--mode append`, `--on-conflict skip`, without `--atomic`), so a row rejected by a foreign key was reported to the operator as a conflict with an unknown cause.
99
+
100
+ `constraintViolation.integration.test.ts` now asserts the `insertIgnore` seam per dialect against live postgres 17, MySQL 8.4, MariaDB 11 and SQL Server 2022. It was the missing assertion behind a claim derived from the wiring — the classification does sit on all ten write paths, which is not the same as a classifiable error arriving on all ten.
101
+ - **@voltro/protocol, @voltro/runtime** — The framework's store errors — `ConstraintViolation`, `TenantScopeViolation`, `TenantRowNotFound`, `ServerOnlyColumnWrite`, `TableValidationFailed`, `StoreOperationFailed` — are exported from `@voltro/protocol` and can therefore be declared in a descriptor's `error:` union. They could not be.
102
+
103
+ They lived in `@voltro/runtime`, which reaches `node:child_process`, `node:http` and `node:crypto`. A descriptor is loaded VALUE-LEVEL by the web client (the `RpcClient` needs every procedure's Schema), so a descriptor importing from there is refused at boot by the browser-safety guard — correctly. The typed half of these errors was therefore unreachable: the docs told you to declare them, and the boot said no.
104
+
105
+ What that leaves is the untyped half only. The error still arrives as an `InternalError` carrying a readable sentence, so telling `foreignKey` ("the row you picked is gone") from `foreignKeyInUse` ("this row is still referenced") — two different messages for the user — means parsing that sentence. Over a set of generated delete mutations that is a string comparison per procedure, which is the thing the typed error exists to delete.
106
+
107
+ `@voltro/runtime` re-exports all six, so server code is unchanged. The classes have no server dependency of any kind — the file imports `Schema` from `effect` and nothing else, and `browserSafetyGuard.test.ts` now pins a descriptor that declares one, so moving them back reads as a boot failure rather than as a passing rename.
108
+ - **@voltro/database, @voltro/sql-mysql** — A blocked `alter-column-type` told every dialect to write a postgres cast.
109
+
110
+ The refusal is correct — a bare type change may not be value-preserving, so it is refused until acknowledged. Its `fix:` line was not:
111
+
112
+ ```
113
+ acknowledge it on the column: `.narrowedFrom('json', { using: 'meta::text' })`
114
+ ```
115
+
116
+ `USING <expr>` is postgres syntax and a postgres capability. The mysql arm of the applier emits `MODIFY COLUMN`, the mssql arm `ALTER COLUMN`, and sqlite rebuilds the table — none of them can carry a cast expression and none of them reads `using`. So an operator on any other engine was handed a line to paste into their schema containing syntax their database has never seen, inside an argument that is discarded. A refusal is read as an instruction, and the more carefully it is read the more thoroughly a wrong one is followed.
117
+
118
+ The fix line is dialect-aware now: postgres keeps the `using` half, everything else gets `.narrowedFrom('<type>')` plus the fact that the engine converts in place — because a refusal that offers no expressible fix reads as "the framework cannot do this at all".
119
+
120
+ Covered on live MySQL and MariaDB by both halves at once: what the refusal SAYS, and that following it applies AND converges with the row intact. A message test alone would keep passing over a broken apply; a convergence test alone is what let the wrong message survive this long.
121
+
122
+ Also on the same path: `upsert` with a PARTIAL row (one omitting a NOT NULL column that has no default) failed on MariaDB and succeeded on MySQL. The native `INSERT … ON DUPLICATE KEY UPDATE` validates its insert half even when only the update half runs, so the row was rejected although the target existed and only needed patching. A partial row takes the lookup path on both engines now; the single-statement form still covers the complete-row case, which is what a data transfer and every generated CRUD write send.
123
+ - **@voltro/sql-mysql** — On MariaDB, `upsert` could write a DIFFERENT row than the one it was given and report success.
124
+
125
+ `INSERT … ON DUPLICATE KEY UPDATE` fires on ANY unique key, not on the one named in `conflictColumns`. So an incoming row whose (say) `email` already belonged to a different primary key updated THAT row instead — and since `id` is excluded from the SET list, the row the caller handed over was never written. Measured on a live server: the call returned a row, the target kept the old id, the new row was absent, and the existing row had silently taken the incoming values. A bulk transfer on top of that prints `import complete` over missing data, which is the worst failure shape available: there is nothing to investigate.
126
+
127
+ The two engines of the family disagreed here, which is part of why it survived. The non-RETURNING path (MySQL) looks the row up by `conflictColumns` first, does not find it, and lets the INSERT fail with a duplicate-key error. Loud was always right.
128
+
129
+ Both refuse now, with a message naming both ids and the fact that the collision was on a constraint other than the one named. The check runs inside a transaction — a short one of the store's own when the caller is not already in one — so the wrong row is rolled back rather than reported after the fact: detecting this afterwards still leaves someone else's row overwritten.
130
+
131
+ ---
132
+
133
+ ## [0.42.0] — 2026-08-17
134
+
135
+ ### ⚠ BREAKING
136
+
137
+ - **@voltro/cli, @voltro/data-transfer** — **Two security defects on the data-transfer surface, both found by using the feature rather than by reading it.**
138
+
139
+ **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.
140
+
141
+ `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`.
142
+
143
+ **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.
144
+
145
+ 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.
146
+
147
+ ### Added
148
+
149
+ - **@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`.
150
+
151
+ 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.
152
+
153
+ 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.
154
+
155
+ ### Fixed
156
+
157
+ - **@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.
158
+
159
+ **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.
160
+
161
+ **`--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.
162
+
163
+ **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.
164
+
165
+ **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.
166
+
167
+ 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`).
168
+
169
+ **Three more, found by running the whole thing against live MariaDB and MySQL** rather than against sqlite:
170
+
171
+ - 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.
172
+ - **@voltro/database** — CHECK constraints were invisible to introspection on **MySQL** — and with them every `.oneOf()` column and every `json_valid` marker.
173
+
174
+ `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.
175
+
176
+ `parseEnumCheck` also learned MySQL's rendering. The same clause is stored differently:
177
+
178
+ mariadb 11 `status` in ('draft','live','done') mysql 8.4 (`status` in (_latin1'draft',_latin1'live',_latin1'done'))
179
+
180
+ 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`.
181
+
182
+ 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`.
183
+ - **@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.
184
+
185
+ `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.
186
+
187
+ 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.
188
+
189
+ 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.
190
+
191
+ **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`).
192
+
193
+ `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.
194
+
195
+ **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.
196
+
197
+ `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.
198
+
199
+ **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.
200
+ - **@voltro/sql-mysql** — `insertIgnore` on MySQL was a different feature from `insertIgnore` on MariaDB — and the difference could turn a conflict into an error.
201
+
202
+ 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).
203
+
204
+ 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`.
205
+
206
+ 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.
207
+
208
+ 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`.
209
+ - **@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.
210
+
211
+ 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.
212
+
213
+ 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.
214
+ - **@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.
215
+
216
+ 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.
217
+
218
+ Any schema-changing statement now drops that connection's cached statements, whichever path it arrived on.
219
+
220
+ 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).
221
+
222
+ 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.
223
+
224
+ **`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.
225
+
226
+ 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.
227
+
228
+ ---
229
+
42
230
  ## [0.41.0] — 2026-08-17
43
231
 
44
232
  ### ⚠ BREAKING
package/dist/index.d.ts CHANGED
@@ -5,12 +5,16 @@ import { AuthMiddleware } from '@voltro/protocol';
5
5
  import { AuthStrategy } from '@voltro/protocol';
6
6
  import { CaughtUpVerdict } from '@voltro/database';
7
7
  import { ChangeEvent } from '@voltro/database';
8
+ import { classifyConstraintViolation } from '@voltro/database';
8
9
  import { clearRetentions } from '@voltro/database';
9
10
  import { ConnectionCredential } from '@voltro/protocol';
10
11
  import { ConnectionInfo } from '@voltro/protocol';
11
12
  import { ConnectionInfoMiddleware } from '@voltro/protocol';
12
13
  import { ConnectionKind } from '@voltro/protocol';
13
14
  import { ConnectionState } from '@voltro/protocol';
15
+ import { ConstraintFacts } from '@voltro/database';
16
+ import { ConstraintKind } from '@voltro/database';
17
+ import { ConstraintViolation } from '@voltro/protocol';
14
18
  import { Context } from 'effect';
15
19
  import { createServer } from 'node:http';
16
20
  import { Cron } from 'effect';
@@ -27,6 +31,7 @@ import { EventPayloadInvalid } from '@voltro/protocol';
27
31
  import { EventPayloadTooLarge } from '@voltro/protocol';
28
32
  import { EventResumePoint } from '@voltro/protocol';
29
33
  import { EventStreamEvent } from '@voltro/protocol';
34
+ import { extractDbCause } from '@voltro/database';
30
35
  import { Fiber } from 'effect';
31
36
  import { FieldCipher } from '@voltro/database';
32
37
  import * as http from 'node:http';
@@ -40,6 +45,8 @@ import { InspectedStep } from '@voltro/workflow';
40
45
  import { InspectedWorkflow } from '@voltro/workflow';
41
46
  import { InspectStore } from '@voltro/workflow';
42
47
  import { inspectWorkflow } from '@voltro/workflow';
48
+ import { isForeignKeyViolation } from '@voltro/database';
49
+ import { isQueryTimeout } from '@voltro/database';
43
50
  import { Kv } from '@voltro/kv';
44
51
  import { KvStoreShape } from '@voltro/kv';
45
52
  import { Layer } from 'effect';
@@ -70,9 +77,12 @@ import { Sampler } from '@opentelemetry/sdk-trace-base';
70
77
  import { Schedule } from 'effect';
71
78
  import { Schema } from 'effect';
72
79
  import { ScopeError } from '@voltro/protocol';
80
+ import { ServerOnlyColumnWrite } from '@voltro/protocol';
73
81
  import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
74
82
  import { spawn } from 'node:child_process';
75
83
  import { SqlClient } from '@effect/sql';
84
+ import { StoreError } from '@voltro/protocol';
85
+ import { StoreOperationFailed } from '@voltro/protocol';
76
86
  import { Stream } from 'effect';
77
87
  import { Subject } from '@voltro/protocol';
78
88
  import { SubjectResolution } from '@voltro/protocol';
@@ -81,6 +91,9 @@ import { SubscriptionEvent } from '@voltro/protocol';
81
91
  import { sweepRetention } from '@voltro/database';
82
92
  import { SyncLogger } from '@voltro/logger';
83
93
  import { TableLike } from '@voltro/database';
94
+ import { TableValidationFailed } from '@voltro/protocol';
95
+ import { TenantRowNotFound } from '@voltro/protocol';
96
+ import { TenantScopeViolation } from '@voltro/protocol';
84
97
  import { Tracer } from 'effect';
85
98
  import { Unauthenticated } from '@voltro/protocol';
86
99
  import { WorkflowParentClosePolicy } from '@voltro/protocol';
@@ -1001,7 +1014,7 @@ export declare interface AppContext {
1001
1014
  *
1002
1015
  * This was typed as the OLD string-emitter facade (`emit(name, data)`) long
1003
1016
  * after that facade was deleted, so the documented call was a `tsc` error
1004
- * while the runtime carried only `publish` — a consumer measured
1017
+ * while the runtime carried only `publish` — a deployment measured
1005
1018
  * `eventKeys: ["publish"], emitType: undefined` with a cron probe because the
1006
1019
  * type and the docs disagreed and they could not tell which was lying.
1007
1020
  *
@@ -1510,7 +1523,7 @@ export declare const bindMutation: <Input, Output, E = never>(execute: (input: I
1510
1523
  * ~2 KB for a one-line cause, with the message at the END so every tool that
1511
1524
  * truncates shows the useless half.
1512
1525
  *
1513
- * A consumer met it with `TenantScopeViolation`. Adding that tag to
1526
+ * A deployment met it with `TenantScopeViolation`. Adding that tag to
1514
1527
  * `INFRA_ERROR_TAGS` would have been wrong: `effectStore.ts` documents
1515
1528
  * `error: Schema.Union(TenantScopeViolation, StoreOperationFailed, …)` as a
1516
1529
  * supported declaration, so an app that DECLARES it must still receive it
@@ -1692,7 +1705,7 @@ export declare interface CacheScopeLeak {
1692
1705
  * serving another org's rows out of memory, with a TTL. The author has to be
1693
1706
  * wrong exactly once, in a field whose two legal values differ by one word.
1694
1707
  *
1695
- * A consumer named this precisely while asking for the third option: *"'global'
1708
+ * A deployment named this precisely while asking for the third option: *"'global'
1696
1709
  * would share across tenant boundaries. For data derived from
1697
1710
  * `subject.tenantId` that is not a cache, it is a leak."* They chose to
1698
1711
  * recompute an org-wide figure once per employee rather than write it — the
@@ -1864,6 +1877,8 @@ export declare const CLAIM_RETENTION_BUCKETS = 64;
1864
1877
  */
1865
1878
  export declare const claimGraceMs: (bucketWidthMs: number | undefined) => number;
1866
1879
 
1880
+ export { classifyConstraintViolation }
1881
+
1867
1882
  /**
1868
1883
  * Decide whether a state-changing request may proceed.
1869
1884
  *
@@ -2129,6 +2144,12 @@ export declare interface ConnectionTokens {
2129
2144
  readonly scopes: ReadonlyArray<string>;
2130
2145
  }
2131
2146
 
2147
+ export { ConstraintFacts }
2148
+
2149
+ export { ConstraintKind }
2150
+
2151
+ export { ConstraintViolation }
2152
+
2132
2153
  export declare type CoordinatedEffect = () => void | CoordinatedTickOutcome | Promise<void | CoordinatedTickOutcome>;
2133
2154
 
2134
2155
  export declare interface CoordinatedScheduleDeps {
@@ -2827,7 +2848,7 @@ export declare const DEFAULT_ROW_FILTER_RETRY: Schedule.Schedule<unknown, unknow
2827
2848
  * `error:` union. It cannot match, by definition: a defect is precisely the
2828
2849
  * thing that is not in the union. What reached the browser was the entire
2829
2850
  * decode tree — every union member, the full `ExitEncoded<…>` type, and the
2830
- * real cause on the last line. ~2 KB of type names, which one consumer's
2851
+ * real cause on the last line. ~2 KB of type names, which one deployment's
2831
2852
  * account page rendered verbatim where a reason belonged, and which every app
2832
2853
  * otherwise has to condense heuristically to avoid putting a schema on screen.
2833
2854
  *
@@ -3010,7 +3031,7 @@ export declare class DeleteBuilder {
3010
3031
  * nothing at all. Reporting a fixed 1 for all of them (which this used to do)
3011
3032
  * turned the `rows` attribute into a liveness signal that reads like a data
3012
3033
  * signal: an `employees.me` that resolved to `null` still traced `rows=1`, and
3013
- * a downstream consumer used exactly that span to conclude the server had
3034
+ * a downstream deployment used exactly that span to conclude the server had
3014
3035
  * produced a value when it had not. Absent is 0, a single value is 1, an array
3015
3036
  * is its length. */
3016
3037
  export declare const deliveredRowCount: (value: unknown) => number;
@@ -3274,7 +3295,7 @@ export declare const drainForShutdown: (options: {
3274
3295
  readonly exit: () => void;
3275
3296
  /** How the drain ended, for the caller to report. A completed drain and one
3276
3297
  * CUT at the deadline are different incidents and were indistinguishable in
3277
- * the log — asked for by a consumer who could see neither. */
3298
+ * the log — asked for by a deployment who could see neither. */
3278
3299
  readonly onOutcome?: (outcome: {
3279
3300
  readonly reason: "drained" | "deadline";
3280
3301
  readonly ms: number;
@@ -3363,7 +3384,7 @@ export declare const enableGraphObservation: () => void;
3363
3384
  * `cipher.encrypt(JSON.stringify(v))` — two encodings, one `enc:v1:` envelope,
3364
3385
  * nothing to tell them apart. The doc above promises these helpers "expose the
3365
3386
  * SAME registered cipher so those paths can encrypt on write and decrypt on read
3366
- * by hand", and a consumer read that as interchangeable, which it said and was
3387
+ * by hand", and a deployment read that as interchangeable, which it said and was
3367
3388
  * not: their session rows written here were unreadable through the store, and
3368
3389
  * the error blamed the key.
3369
3390
  */
@@ -3546,7 +3567,7 @@ export declare class EventBus {
3546
3567
  /**
3547
3568
  * Called SYNCHRONOUSLY at attach with the route's current watermarks.
3548
3569
  *
3549
- * It is how a consumer learns where the stream stood the instant it joined,
3570
+ * It is how a deployment learns where the stream stood the instant it joined,
3550
3571
  * with no window for a publish to slip in between reading and subscribing.
3551
3572
  * The bridge needs it because a delivery dropped BEFORE the client's first
3552
3573
  * read would otherwise be invisible: with no baseline, the first serial it
@@ -3562,7 +3583,7 @@ export declare class EventBus {
3562
3583
  * since its last serial (from the watermark, which survives ring eviction);
3563
3584
  * `replayed` is what we can actually hand over. An origin the client never
3564
3585
  * mentioned is one that appeared while it was away, so everything retained
3565
- * from it is owed. A `gap` is emitted BEFORE the replay so a consumer reading
3586
+ * from it is owed. A `gap` is emitted BEFORE the replay so a deployment reading
3566
3587
  * in order learns it is behind before it starts processing.
3567
3588
  */
3568
3589
  private replayForResume;
@@ -3649,7 +3670,7 @@ export declare interface EventEnvelope {
3649
3670
  /** `tenant · event · key`, NUL-separated — built by `eventRoute`, read with
3650
3671
  * `parseEventRoute`. Never construct or split one by hand. */
3651
3672
  readonly route: string;
3652
- /** Declared event name, carried separately so a consumer of the raw envelope
3673
+ /** Declared event name, carried separately so a deployment of the raw envelope
3653
3674
  * (broadcast bridge, inspect, metrics) needn't re-parse the route. */
3654
3675
  readonly event: string;
3655
3676
  /** Publishing instance. Serials are only comparable WITHIN one origin. */
@@ -4304,7 +4325,7 @@ export declare interface ExperimentVariantSpec {
4304
4325
  * when the header is missing/invalid (no parent → a fresh root span). */
4305
4326
  export declare const externalSpanFromTraceparent: (header: string | undefined | null) => Tracer.ExternalSpan | undefined;
4306
4327
 
4307
- export declare const extractDbCause: (err: unknown) => Record<string, unknown>;
4328
+ export { extractDbCause }
4308
4329
 
4309
4330
  export declare interface FieldChange {
4310
4331
  readonly from: unknown;
@@ -4877,10 +4898,7 @@ export declare const isExpectationDefinition: (value: unknown) => value is Expec
4877
4898
 
4878
4899
  export declare const isExperimentDefinition: (value: unknown) => value is ExperimentDefinition;
4879
4900
 
4880
- /** Foreign-key-violation SQLSTATE / errno across dialects (pg 23503, mysql/maria
4881
- * 1452, mssql 547, sqlite). Used to turn an opaque tenant-FK SqlError into a
4882
- * typed error. */
4883
- export declare const isForeignKeyViolation: (dbCause: Record<string, unknown>) => boolean;
4901
+ export { isForeignKeyViolation }
4884
4902
 
4885
4903
  /**
4886
4904
  * True iff the app is idle at this instant on every axis AND no wakeup is
@@ -4935,14 +4953,7 @@ export declare const isOrglessUserSubject: (subject: {
4935
4953
  readonly tenantId?: string | null;
4936
4954
  } | null | undefined) => boolean;
4937
4955
 
4938
- /** A query cancelled for exceeding the `statementTimeoutMs` deadline, across
4939
- * dialects: pg `57014` (query_canceled — what `statement_timeout` raises),
4940
- * MySQL `3024` (ER_QUERY_TIMEOUT), MariaDB `1969` (ER_STATEMENT_TIMEOUT), mssql
4941
- * `ETIMEOUT` (tedious request timeout), sqlite `SQLITE_INTERRUPT`. NOT a
4942
- * transient error — a re-run just repeats the runaway, so it must not retry
4943
- * (`servePipeline`'s transient set deliberately excludes it). Lets a consumer /
4944
- * observability layer name the failure instead of reading an opaque SqlError. */
4945
- export declare const isQueryTimeout: (dbCause: Record<string, unknown>) => boolean;
4956
+ export { isQueryTimeout }
4946
4957
 
4947
4958
  /**
4948
4959
  * Optimistic-concurrency guard: an undo is safe only when the row still looks
@@ -5200,7 +5211,7 @@ export declare const makeActionRunner: (deps: ActionRunnerDeps) => (action: Muta
5200
5211
  *
5201
5212
  * The bucket keying makes claims self-expiring as a DECISION: a crashed
5202
5213
  * winner doesn't block the next firing (= next bucket = new key). It did
5203
- * not make them self-expiring as ROWS, and that distinction cost a consumer
5214
+ * not make them self-expiring as ROWS, and that distinction cost a deployment
5204
5215
  * their whole deployment — 86 214 rows / 33 MB over two days, read in full
5205
5216
  * on every claim check, ten of a fifteen-slot pooler pinned on the scan, an
5206
5217
  * SSR render behind them at 300 490 ms, and a `rollout restart` that could
@@ -5644,7 +5655,7 @@ export declare const materializeIvm: (shape: AggregateShape, state: IvmState) =>
5644
5655
  }>;
5645
5656
 
5646
5657
  /** Told when the membership changes. `restarted` is a `left` + `joined` pair
5647
- * for one id, reported as such so a consumer drops the old state rather than
5658
+ * for one id, reported as such so a deployment drops the old state rather than
5648
5659
  * resuming it. */
5649
5660
  export declare type MembershipEvent = {
5650
5661
  readonly kind: 'joined';
@@ -5668,7 +5679,7 @@ export declare interface MembershipHeartbeat {
5668
5679
  *
5669
5680
  * Carried as an IDENTITY, never compared to our clock. Its job is to make a
5670
5681
  * restart distinguishable from a hiccup: an instance that comes back with a
5671
- * NEW `startedAt` is a fresh process whose owned state is gone, so a consumer
5682
+ * NEW `startedAt` is a fresh process whose owned state is gone, so a deployment
5672
5683
  * must drop what it held for the old one rather than resume it. A returning
5673
5684
  * instance with the SAME value only ever missed a few beats.
5674
5685
  */
@@ -8741,32 +8752,7 @@ export declare interface ServeRequestContext {
8741
8752
  */
8742
8753
  export declare const serverOnlyColumnNames: (tableName: string) => ReadonlyArray<string>;
8743
8754
 
8744
- /**
8745
- * A generated CRUD write (`crud.create` / `crud.update`) was handed a
8746
- * `.serverOnly()` column in its INPUT.
8747
- *
8748
- * `.serverOnly()` is the WIRE-exposure axis: the column never crosses the
8749
- * boundary in EITHER direction. Reads strip it; a write that accepts it is the
8750
- * same violation mirrored — mass assignment of a column the schema declared the
8751
- * client may not see, let alone set.
8752
- *
8753
- * Refused rather than silently stripped: a stripped field makes an attack
8754
- * indistinguishable from a no-op and leaves an honest caller wondering why the
8755
- * value it sent never landed. `columns` names what was rejected so the fix
8756
- * (drop the field from the descriptor's input schema, or from the caller) is
8757
- * mechanical.
8758
- */
8759
- export declare class ServerOnlyColumnWrite extends ServerOnlyColumnWrite_base {
8760
- }
8761
-
8762
- declare const ServerOnlyColumnWrite_base: Schema.TaggedErrorClass<ServerOnlyColumnWrite, "ServerOnlyColumnWrite", {
8763
- readonly _tag: Schema.tag<"ServerOnlyColumnWrite">;
8764
- } & {
8765
- /** The table the write targeted. */
8766
- table: typeof Schema.String;
8767
- /** The `.serverOnly()` columns the input tried to set. */
8768
- columns: Schema.Array$<typeof Schema.String>;
8769
- }>;
8755
+ export { ServerOnlyColumnWrite }
8770
8756
 
8771
8757
  /** One leak: a wire query that declares a serverOnly column in its output. */
8772
8758
  export declare interface ServerOnlyLeak {
@@ -9041,12 +9027,7 @@ export declare interface StoreCredentialInput {
9041
9027
  readonly now?: () => Date;
9042
9028
  }
9043
9029
 
9044
- /**
9045
- * Discriminated union of all framework-owned store errors. Use it on
9046
- * a mutation's `error:` schema when you want every kind surfaced
9047
- * typed to the client.
9048
- */
9049
- export declare type StoreError = TenantScopeViolation | TenantRowNotFound | ServerOnlyColumnWrite | StoreOperationFailed | TableValidationFailed;
9030
+ export { StoreError }
9050
9031
 
9051
9032
  export declare interface StoreMiddlewareContext {
9052
9033
  readonly subject: Subject;
@@ -9072,25 +9053,7 @@ export declare interface StoreMiddlewareContext {
9072
9053
  readonly rowFilter?: RowFilterScope;
9073
9054
  }
9074
9055
 
9075
- /**
9076
- * Anything else the underlying `DataStore` raised during a write or
9077
- * query. `cause` is the stringified original error — sufficient for
9078
- * logs + UI, doesn't try to serialise complex error chains across the
9079
- * rpc boundary. The `_tag` discriminator stays cheap to pattern-match.
9080
- */
9081
- export declare class StoreOperationFailed extends StoreOperationFailed_base {
9082
- }
9083
-
9084
- declare const StoreOperationFailed_base: Schema.TaggedErrorClass<StoreOperationFailed, "StoreOperationFailed", {
9085
- readonly _tag: Schema.tag<"StoreOperationFailed">;
9086
- } & {
9087
- /** Which DataStore op was attempted: 'query' | 'insert' | 'update' | 'delete' | 'hardDelete'. */
9088
- operation: typeof Schema.String;
9089
- /** The table the op targeted. */
9090
- table: typeof Schema.String;
9091
- /** `String(originalError)` — round-trip-safe diagnostic form. */
9092
- cause: typeof Schema.String;
9093
- }>;
9056
+ export { StoreOperationFailed }
9094
9057
 
9095
9058
  /**
9096
9059
  * Drop `columns` from every row. Preserves array AND per-row object identity when
@@ -9363,30 +9326,7 @@ export declare interface TableRoutingStats {
9363
9326
  readonly distinctTupleKeys: number;
9364
9327
  }
9365
9328
 
9366
- /**
9367
- * Pre-INSERT row validation against a table's `.validate(Schema)`
9368
- * decoder failed. The MutationStore runs the table's `insertSchema`
9369
- * AFTER defaults + computed + audit/tenant stamps; failure means
9370
- * the stamped row didn't satisfy the decoder. `issues` is the
9371
- * formatted ArrayFormatter output (cheap to render in UI, doesn't
9372
- * leak the original Schema instance).
9373
- */
9374
- export declare class TableValidationFailed extends TableValidationFailed_base {
9375
- }
9376
-
9377
- declare const TableValidationFailed_base: Schema.TaggedErrorClass<TableValidationFailed, "TableValidationFailed", {
9378
- readonly _tag: Schema.tag<"TableValidationFailed">;
9379
- } & {
9380
- /** The table the row targeted. */
9381
- table: typeof Schema.String;
9382
- /** Top-level explanation for logs + UI ("user.email failed pattern check"). */
9383
- summary: typeof Schema.String;
9384
- /** Flat list of `{ path, message }` per failing leaf. Path uses dot-notation. */
9385
- issues: Schema.Array$<Schema.Struct<{
9386
- path: typeof Schema.String;
9387
- message: typeof Schema.String;
9388
- }>>;
9389
- }>;
9329
+ export { TableValidationFailed }
9390
9330
 
9391
9331
  /** The standing compute-cost attribution for one tenant — the chargeback /
9392
9332
  * showback row + the "why is my bill high" breakdown. Maintained incrementally:
@@ -9404,59 +9344,9 @@ export declare interface TenantCostState {
9404
9344
  readonly lastUpdatedAt: number | null;
9405
9345
  }
9406
9346
 
9407
- /**
9408
- * A keyed-by-primary-key write (`ctx.store.update(table, id, patch)`,
9409
- * `delete(table, id)`, `hardDelete(table, id)`, `patchJson(table, id, …)`) on a
9410
- * `tenant()`-scoped table did not resolve to a row inside the CALLER's tenant.
9411
- *
9412
- * **One error for two situations, on purpose.** It is raised identically when
9413
- * the row does not exist at all and when it exists but belongs to another
9414
- * tenant, and it carries no field that separates them. That is the whole point:
9415
- *
9416
- * - Reporting "forbidden" for a foreign row and "not found" for a missing one
9417
- * turns any keyed write into a cross-tenant EXISTENCE ORACLE — an attacker
9418
- * walks ids and learns which ones are real in someone else's tenant, which
9419
- * is exactly the isolation the `tenant()` mixin exists to provide.
9420
- * - Collapsing the other way — silently affecting zero rows — is worse than
9421
- * either: the handler reads it as "the row is gone", not "you may not touch
9422
- * it", so a genuine isolation breach shows up in an app as a confusing
9423
- * absent-row branch and never as a security signal.
9424
- *
9425
- * So both cases fail LOUDLY and IDENTICALLY. `id` is the key the caller itself
9426
- * supplied — never another tenant's data.
9427
- */
9428
- export declare class TenantRowNotFound extends TenantRowNotFound_base {
9429
- }
9347
+ export { TenantRowNotFound }
9430
9348
 
9431
- declare const TenantRowNotFound_base: Schema.TaggedErrorClass<TenantRowNotFound, "TenantRowNotFound", {
9432
- readonly _tag: Schema.tag<"TenantRowNotFound">;
9433
- } & {
9434
- /** The table the keyed write targeted. */
9435
- table: typeof Schema.String;
9436
- /** The primary key the CALLER supplied. Echoing it leaks nothing. */
9437
- id: typeof Schema.String;
9438
- /** Human-readable explanation for diagnostics + UI. */
9439
- reason: typeof Schema.String;
9440
- }>;
9441
-
9442
- /**
9443
- * A write was attempted against a `tenant()`-scoped table, but the
9444
- * authenticated subject's `tenantId` is null — either anonymous, or
9445
- * an apiKey / serviceAccount without a tenant binding. Refusing the
9446
- * write at the boundary is the safe default; a future "system writes"
9447
- * subject type can opt out.
9448
- */
9449
- export declare class TenantScopeViolation extends TenantScopeViolation_base {
9450
- }
9451
-
9452
- declare const TenantScopeViolation_base: Schema.TaggedErrorClass<TenantScopeViolation, "TenantScopeViolation", {
9453
- readonly _tag: Schema.tag<"TenantScopeViolation">;
9454
- } & {
9455
- /** The table the violating write targeted. */
9456
- table: typeof Schema.String;
9457
- /** Human-readable explanation for diagnostics + UI. */
9458
- reason: typeof Schema.String;
9459
- }>;
9349
+ export { TenantScopeViolation }
9460
9350
 
9461
9351
  export declare type TimeBucket = 'minute' | 'hour' | 'day' | 'week' | 'month';
9462
9352
 
@@ -9710,7 +9600,7 @@ export declare interface TransportSecurityOptions {
9710
9600
  * `on:` takes a `defineEvent` descriptor and reads its NAME, so the trigger and
9711
9601
  * the producer cannot drift: rename the event and this call site moves with it,
9712
9602
  * where the string form silently stops matching and the workflow simply never
9713
- * runs again. That failure is exactly what a consumer reported having with their
9603
+ * runs again. That failure is exactly what a deployment reported having with their
9714
9604
  * own string channels — `on-game-scores` beside `games/evo5/on-game-scores`,
9715
9605
  * both live, one dead since the day it was written — and it is the reason the
9716
9606
  * string form is going away rather than being kept as an alternative.
@@ -9767,7 +9657,7 @@ export declare type TupleSource = (req: {
9767
9657
  * The whole caller, not just their id.
9768
9658
  *
9769
9659
  * `subjectId` alone cannot express a credential that is NARROWER than the
9770
- * person holding it, and an API key is exactly that. A consumer reported it
9660
+ * person holding it, and an API key is exactly that. A deployment reported it
9771
9661
  * precisely: their key carries its binding in `metadata` (`keyType`,
9772
9662
  * `teamId`), while `subject.id` is the OWNING USER — so a tuple source could
9773
9663
  * only resolve the owner's memberships and was blind to which team the key