@ultimat3/cli 30.7.0 → 30.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/cli",
3
- "version": "30.7.0",
3
+ "version": "30.9.0",
4
4
  "description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -53,33 +53,33 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@babel/core": "^8.0.7",
56
- "@ultimat3/action": "30.7.0",
57
- "@ultimat3/admin": "30.7.0",
58
- "@ultimat3/ai": "30.7.0",
59
- "@ultimat3/auth": "30.7.0",
60
- "@ultimat3/cache": "30.7.0",
61
- "@ultimat3/core": "30.7.0",
62
- "@ultimat3/db": "30.7.0",
63
- "@ultimat3/entity": "30.7.0",
64
- "@ultimat3/flags": "30.7.0",
65
- "@ultimat3/http": "30.7.0",
66
- "@ultimat3/i18n": "30.7.0",
67
- "@ultimat3/jobs": "30.7.0",
68
- "@ultimat3/mail": "30.7.0",
69
- "@ultimat3/manifest": "30.7.0",
70
- "@ultimat3/mcp": "30.7.0",
71
- "@ultimat3/money": "30.7.0",
72
- "@ultimat3/notify": "30.7.0",
73
- "@ultimat3/policy": "30.7.0",
74
- "@ultimat3/pwa": "30.7.0",
75
- "@ultimat3/query": "30.7.0",
76
- "@ultimat3/realtime": "30.7.0",
77
- "@ultimat3/render": "30.7.0",
78
- "@ultimat3/schema": "30.7.0",
79
- "@ultimat3/seo": "30.7.0",
80
- "@ultimat3/storage": "30.7.0",
81
- "@ultimat3/testing": "30.7.0",
82
- "@ultimat3/time": "30.7.0",
56
+ "@ultimat3/action": "30.9.0",
57
+ "@ultimat3/admin": "30.9.0",
58
+ "@ultimat3/ai": "30.9.0",
59
+ "@ultimat3/auth": "30.9.0",
60
+ "@ultimat3/cache": "30.9.0",
61
+ "@ultimat3/core": "30.9.0",
62
+ "@ultimat3/db": "30.9.0",
63
+ "@ultimat3/entity": "30.9.0",
64
+ "@ultimat3/flags": "30.9.0",
65
+ "@ultimat3/http": "30.9.0",
66
+ "@ultimat3/i18n": "30.9.0",
67
+ "@ultimat3/jobs": "30.9.0",
68
+ "@ultimat3/mail": "30.9.0",
69
+ "@ultimat3/manifest": "30.9.0",
70
+ "@ultimat3/mcp": "30.9.0",
71
+ "@ultimat3/money": "30.9.0",
72
+ "@ultimat3/notify": "30.9.0",
73
+ "@ultimat3/policy": "30.9.0",
74
+ "@ultimat3/pwa": "30.9.0",
75
+ "@ultimat3/query": "30.9.0",
76
+ "@ultimat3/realtime": "30.9.0",
77
+ "@ultimat3/render": "30.9.0",
78
+ "@ultimat3/schema": "30.9.0",
79
+ "@ultimat3/seo": "30.9.0",
80
+ "@ultimat3/storage": "30.9.0",
81
+ "@ultimat3/testing": "30.9.0",
82
+ "@ultimat3/time": "30.9.0",
83
83
  "babel-preset-solid": "^1.9.16"
84
84
  }
85
85
  }
@@ -9,7 +9,7 @@ import { identifier, sql } from '@ultimat3/db';
9
9
  import type { EntityCore, RegistryEntry } from '@ultimat3/entity';
10
10
  import type { Subject } from '@ultimat3/jobs';
11
11
  import { planSubject } from '@ultimat3/jobs';
12
- import type { SeedFactory } from '@ultimat3/testing';
12
+ import type { SeedFactory, SeedGraph } from '@ultimat3/testing';
13
13
  import { entitySeedWriter, subjectProof } from '@ultimat3/testing';
14
14
  import type { Finding } from './output';
15
15
 
@@ -43,6 +43,9 @@ export async function subjectProofFindings(
43
43
  factories?: Readonly<Record<string, SeedFactory>>,
44
44
  ): Promise<readonly Finding[]> {
45
45
  const findings: Finding[] = [];
46
+ // Every subject's graph lands on this one database: each is seeded beside the last written, so a
47
+ // factory value built from the row index never repeats an earlier subject's on a unique column.
48
+ let beside: SeedGraph | undefined;
46
49
  for (const [index, subject] of subjects.entries()) {
47
50
  // A plan the static half refused is reported there, once; an erase that throws is a finding.
48
51
  const problems = await subjectProof(subject, {
@@ -52,8 +55,12 @@ export async function subjectProofFindings(
52
55
  client.query<Record<string, unknown>>(sql`select * from ${identifier(entity.$table)}`),
53
56
  seed: SUBJECT_PROOF_SEED + index,
54
57
  factories,
58
+ beside,
55
59
  }).then(
56
- (result) => result.problems.filter((p) => p.code === 'X_SUBJECT_ERASE_INCOMPLETE'),
60
+ (result) => {
61
+ beside = result.graph ?? beside;
62
+ return result.problems.filter((p) => p.code === 'X_SUBJECT_ERASE_INCOMPLETE');
63
+ },
57
64
  (error: unknown) => (isUltimateError(error) ? [error] : Promise.reject(error)),
58
65
  );
59
66
  for (const problem of problems) {
@@ -283,6 +283,7 @@ export const mcp = adminMcp({
283
283
  | `include: 'exposed'` | every action and query with `mcp: { expose: true }`, projected as on `/mcp` (opt-in, the one predicate), each under its kind's admin scope: a query `admin:read`, an action `admin:write` |
284
284
  | `actor({ token, facts })` | `facts` is how the request arrived (address, `Origin`) — what a development token is decided on |
285
285
  | where it is built | `apps/<app>/mcp.ts`, never under `apps/admin/app/`: the scan evaluates the former after every primitive registered; one built earlier is `X_MCP_INCLUDE_EARLY` at the mount |
286
+ | a CRUD tool's arguments | one per form field, typed by the field; a `.nullable()` column's also takes `null` (`anyOf [type, null]`), a NOT NULL one does not. A `json()` / `arrayOf()` field is typed by the column's OWN schema — an array, an object, a scalar, `null` where the schema admits it — and untyped (`{}`) where the schema cannot be described; never a blanket `object`. `As of 2026-11` |
286
287
 
287
288
  ### Tool scopes
288
289
 
@@ -666,7 +666,7 @@ is the shape a table already has, `As of 2026-08`.
666
666
  | `enumerated(v)` · `tz(zones)` · `locale(tags)` | `text` + CHECK | the union of the declared values |
667
667
  | `timestamp()` | `timestamptz` | `Date` — an instant, stored UTC |
668
668
  | `money()` | `<n>_minor bigint` + `<n>_currency char(3)` + `<n>_scale integer null` | `MoneyValue` |
669
- | `json(schema)` | `jsonb` | whatever the schema infers. The schema is **required** — a `json()` returning `unknown` is an `any` hole, and the value arrives from the database as often as from a caller |
669
+ | `json(schema)` | `jsonb` | whatever the schema infers. The schema is **required** — a `json()` returning `unknown` is an `any` hole, and the value arrives from the database as often as from a caller. `null` in a NOT NULL `json()` column is the JSON value — the schema judges it (`t.nullable(…)` admits it) and it is stored as `'null'::jsonb`; in a `.nullable()` column `null` is SQL NULL, the clear `is-null` matches |
670
670
  | `decimal({ precision, scale })` | `numeric(p, s)` | `string`, the exact digits. A value with more decimal places than the column stores is refused, not rounded |
671
671
  | `date()` | `date` | `PlainDate` — a calendar date, no time, no zone |
672
672
  | `bigint()` | `bigint` | `string`. A JS `bigint` is what `JSON.stringify` throws on and a `number` loses digits past 2^53, which is where a legacy `int8` key lives |
@@ -428,6 +428,8 @@ The ledger is a **report an operator reads**, never a resume source — the step
428
428
 
429
429
  `rate` (batches per second, default `DEFAULT_BACKFILL_RATE`) is spent as the **first statement inside the batch's own step**, never wrapped around it — an attempt resuming at batch 500 replays 500 already-completed checkpoints that run no body and touch no database, and paying the full throttle for all of them again before reading a new row would make every resume slower than the original pass. There is no way to turn the throttle off: a backfill that saturates the pool has no correct value here, since it shares that pool with the requests the app is still serving live.
430
430
 
431
+ The wait is spent on the **run's clock** — `ctx.clock` (`As of 2026-11-08`, `backfill-rate.ts`). Under a `frozenClock()` the wait advances that clock by the interval instead of arming a real timer, so a test of a 1,000-batch pass finishes in milliseconds and the clock ends `(batches − 1) / rate` seconds later. Before 30.9.0 every batch under a frozen clock paid the full interval in wall time. `runJobs` hands every body the preload's frozen clock, so a backfill drained through it moves `Date.now()` by the same amount, and the lease renewals hear each move.
432
+
431
433
  ### Progress observability
432
434
 
433
435
  One projection, four surfaces, so none of them can disagree about how far a pass has got:
package/wiki/Testing.md CHANGED
@@ -91,8 +91,8 @@ Any test that can pass twice and fail the third time is worse than no test — i
91
91
  | **Seeds** | `seed(name)` builds a named, deterministic fixture graph via entity factories. Same input → identical rows, identical UUIDs |
92
92
  | **Frozen clock** | time starts at a fixed instant. `clock.advance('3d')` moves it, and it also drives `step.sleep` and cron in tests |
93
93
  | **Seeded RNG** | `Math.random`, `crypto.randomUUID`, and Bun's RNG are seeded per test file from its path — reproducible, distinct across files |
94
- | **Sealed network** | a `fetch`, a `new WebSocket(…)` or a `Bun.connect(…)` to anywhere not explicitly mocked or allowed **fails the test** with `X_TEST_NETWORK_SEALED`, naming the URL and the fix — the three dials share one gate, so the allow-list and `offline()` apply to all of them — `offline()` refuses a loopback dial too (`X_TEST_NETWORK_OFFLINE`). A dial that goes around those three globals (a `node:net` socket, `Bun.udpSocket`) is not sealed |
95
- | **Sealed names** | `Bun.dns.lookup`, `dns.lookup` and `dns.promises.lookup` ask the same gate: a host a `mockFetch` route names resolves to `MOCKED_HOST_ADDRESS` (`11.11.11.11`, public, so an SSRF screen such as `screenDial` passes it and the dial it pins still meets the mock by its `Host`); this machine, an address literal and an `allowHost` name resolve for real; offline refuses every name (`X_TEST_NETWORK_OFFLINE`); any other name is `X_TEST_NETWORK_SEALED`. A RegExp route names a host it matches at the origin or spells in its source. Not covered: `lookup` bound by a named ESM import (`import { lookup } from 'node:dns'`) before the seal, and `dns.resolve*` |
94
+ | **Sealed network** | a `fetch`, a `new WebSocket(…)`, a `Bun.connect(…)` or a `node:net` / `node:tls` / `node:http` / `node:https` / `node:http2` connection (all dial through `net.Socket#connect`, sealed there) to anywhere not explicitly mocked or allowed **fails the test** with `X_TEST_NETWORK_SEALED`, naming the URL and the fix — every dial shares one gate, so the allow-list (`allowHost('host:port')` for a socket) and `offline()` apply to all of them — `offline()` refuses a loopback dial too (`X_TEST_NETWORK_OFFLINE`). A `node:*` refusal is the socket's `error` event, as a failed real dial is. A `mockFetch` route answers `fetch` only: a `node:http` request to a mocked host is refused, never dialled. A `Bun.udpSocket` send (and `node:dgram`, which sends through it) asks the same gate per datagram, the connected peer included: a refusal throws from `send`/`sendMany` as Bun's own UDP failures do, a refused `connect` option rejects, and `dgram` hands it to the send callback — or emits `error` when there is none. A unix socket is never sealed |
95
+ | **Sealed names** | Every resolution path asks the same gate — `lookup`, every `resolve*`, `reverse`, `lookupService` (by `node:dns`, `node:dns/promises` or `Bun.dns`, a named import bound before the seal included), both `Resolver` classes and `Bun.dns.prefetch`: a host a `mockFetch` route names answers an address query (`lookup`, `A`, `ANY`) with `MOCKED_HOST_ADDRESS` (`11.11.11.11`, public, so an SSRF screen such as `screenDial` passes it and the dial it pins still meets the mock by its `Host`) and any other record type (`MX`, `TXT`, …) with `X_TEST_NETWORK_SEALED` — a mock declares an endpoint, not a zone; this machine, an `allowHost` name and a `lookup` of an address literal resolve for real (a `reverse` of a public address is sealed: it is a query); offline refuses every name (`X_TEST_NETWORK_OFFLINE`); any other name is `X_TEST_NETWORK_SEALED` — its fix opens with `mockFetch(…)` for an address query and with `allowHost('<name>')` for a record or reverse query, which no mock answers. A RegExp route names a host it matches at the origin or spells in its source |
96
96
  | **Fixed timezone + locale** | `UTC` and `en-US` unless a test declares otherwise; a tz-dependent bug fails deterministically |
97
97
  | **Ordered concurrency** | job workers in tests run deterministically; `runJobs()` drains the queue synchronously |
98
98
  | **Per-test reset** | before EVERY test, not every file, the preload puts the jobs event bus back (`installPerTestReset()`): an answer one test published never resumes the next test's waiting run, with or without `runJobs`. A test that never loaded `@ultimat3/jobs` pays nothing. `As of 2026-10` |
@@ -905,6 +905,7 @@ await insertSeedGraph(graph, writer);
905
905
  | soft delete | a soft-deleting table's `deletedAt` is `null` unless a factory builds it: seeded rows are live |
906
906
  | `factories` | `{ factories: { posts: myFactory } }` — what the factory builds wins, except keys and the tenant column, which stay the graph's |
907
907
  | determinism | defaults `tenants: 2`, `perTable: 3` (per tenant for a tenant-scoped table), `seed` the package's `DEFAULT_SEED`. Same seed, same bytes |
908
+ | `beside` | `{ beside: earlier }` — a graph already written to the same database. Each table's row positions (the ordinal a generated integer, date or money is built from; a factory's `index`, reached by replaying its builds after `reset()`) continue past `earlier.next[table]`, so no value built from a position repeats one of its rows on a unique column. `graph.next` is cumulative: chain a third graph beside the second |
908
909
  | canaries | each row's generated text carries a token; `graph.canaries` lists it per row with the columns holding it, so a later read can say whose row it saw |
909
910
  | writing | `insertSeedGraph(graph, writer)`: every insert in order, then every update, sequentially. `entitySeedWriter({ entities, client })` (Postgres or PGlite) or `entitySeedWriter({ entities, driver? })` (a driver; default `defaultDriver()`) writes through each entity's own repository. A row whose entity the writer was not given is `X_SEED_GRAPH_ENTITY_UNKNOWN` |
910
911
  | `snapshot(rows)` | **required** on a `SeedWriter`: one digest per row, read back by primary key, in the order given; `null` for a row gone. Soft-deleted rows are read too. `entitySeedWriter` answers `md5(t::text)` per row over a client — the whole stored row, undeclared columns included — and an md5 of the row's sorted JSON over a driver. The tenant proof's write half |
@@ -994,16 +995,17 @@ shape, same unreached code. `As of 2026-11`.
994
995
  |---|---|
995
996
  | Database | a scratch one with the framework tables and every migration applied; never the developer's. The pass commits, so the tenant proof can read rows after the call |
996
997
  | Rows | one seed graph for the pass, a fresh pair of tenants per primitive in it — the first the actor's (A), the second the tenant proof's intruder (B); every table seeded off its declaration, parents first, same-tenant keys (`x db seed --generate`'s graph). A view and a `readOnly: '<why>'` table get no row; a NOT NULL key into a `readOnly` one is `X_SEED_GRAPH_UNSATISFIED` naming it ([Read-only tables](Entities-And-Migrations#read-only-tables)) |
997
- | Actor | the entry's `actor` when it declares one, seated in the primitive's tenant — and a top-level value of its bound input equal to the org the entry declared becomes that tenant too, so `input: (drawn) => ({ ...drawn, orgId: '<the actor's org>' })` holds in every tenant the pass seeds; otherwise the first of `x policy explain`'s actors the policy allows, in the primitive's tenant (an `{ input }`-only entry keeps this pick and still binds its input). None allowed is `refused`, by design. Its id has a user's shape: a uuid per role × tenant, the same on every run (`exerciseActorId`), never the role's name. Where the database has `x_users` (the framework schema every pass database is built with) each actor the pass acts as gets its row first — `<id>@exercise.invalid`, its tenant, roles, permissions, scopes — so `findUserById(ctx.actor.id)` finds it; a refused insert is `X_EXERCISE_ACTOR_USER_UNSEATED`. `defineExercise(…, { actor: members })` makes the id a seeded row's key instead (`As of 2026-11-08`) |
998
+ | Actor | the entry's `actor` when it declares one, seated in the primitive's tenant — and a top-level value of its bound input — or of its `facts`, a string or an array holding it — equal to the org the entry declared becomes that tenant too, so `input: (drawn) => ({ ...drawn, orgId: '<the actor's org>' })` holds in every tenant the pass seeds; otherwise the first of `x policy explain`'s actors the policy allows, in the primitive's tenant (an `{ input }`-only entry keeps this pick and still binds its input). None allowed is `refused`, by design. Its id has a user's shape: a uuid per role × tenant, the same on every run (`exerciseActorId`), never the role's name. Where the database has `x_users` (the framework schema every pass database is built with) each actor the pass acts as gets its row first — `<id>@exercise.invalid`, its tenant, roles, permissions, scopes — so `findUserById(ctx.actor.id)` finds it; a refused insert is `X_EXERCISE_ACTOR_USER_UNSEATED`. `defineExercise(…, { actor: members })` makes the id a seeded row's key instead (`As of 2026-11-08`) |
998
999
  | Input | the override, then an id field whose stem names a seeded entity (`postId` → `posts`), then the schema's minimal draw. A wrong guess shows as `unreached` |
999
1000
  | A job's org | the field(s) its `tenant(input)` reads — any name, nested, left out of the draw, or under a parent the draw left out (a scoped backfill's `payload.input.orgId`) — are set to the tenant it is enqueued in, found by reading them: A's for the control, B's for the tenant proof (B's own job, carrying A's ids). A `tenant` no input field moves (one fixed org) is `unreached`, `X_JOB_TENANT_MISMATCH`, its `fix:` the declaration: `tenant: (input) => input.orgId` |
1000
1001
  | A job's run | its own execution alone: enqueued on a queue holding nothing else, run by one worker pass. What it enqueues is left queued, as an action's is — an `enqueue` effect on its record, searched by the tenant proof, never run in its room. Its `statements`, effects, verdict and scale and plan sweeps are its own body's: a job that queues one child per row is flat, a body that reads each row is still `X_QUERY_SCALES_WITH_ROWS`. A child is judged as its own primitive. The crash proof too: its clean and killed runs claim only the job's own row, a child compared as its `enqueue:` effect |
1001
1002
  | A job's failure | judged by the action rule: a coded refusal under 500 (an app's 409) is `unreached` under its own code, never a defect; an uncoded throw or a coded 5xx is `X_CONTRACT_DEFECT` |
1002
- | Async input | an override's `input` may be `async`: it is awaited inside the call's request, as the call's actor, so it can mint what the action checks (a one-time token, a passkey assertion). `x drill`'s load skips an `async` input and says why |
1003
+ | Async input | an override's `input` may be `async`: it is awaited inside the call's request, as the call's actor, so it can mint what the action checks (a one-time token, a passkey assertion). App code in it that enqueues always has a job driver. In the control and the scale sweep it binds on the queue of the call it feeds, so a job it enqueues is there when the call looks it up by id (`jobDriver()`, a cancel, a requeue); only what the CALL adds counts as the primitive's `enqueue` effect, never what the input queued. The tenant proof's first input binds on a queue of its own: it feeds B's calls, each on B's own queue (`As of 2026-11-08`). Its rows are committed, as the call's are: a unique value it inserts is drawn per call. What it sends — a select, a row, a mail — is never the primitive's: each call is recorded alone, so it is not in the record's `statements` or `effects` and the plan sweep never plans it as the primitive's. One that throws is that primitive `unreached` under the throw's own code (an uncoded one `X_EXERCISE_INPUT_THREW`), its `fix` the entry to repair; the rest of the pass runs (`As of 2026-11-08`). `x drill`'s load skips an `async` input and says why |
1003
1004
  | Room | network sealed, mail captured, jobs in memory, clock frozen — from before the app loads and the scratch database boots, as `bun test`'s preload does, so the embedded Postgres never sees its clock jump. A call out is refused and counted, so the primitive is `unreached` |
1004
1005
  | Cost | rows are primitives × tables; statements are not: the graph is written one `insertAll` per table, each tenant-proof snapshot is one statement, and a primitive reads only its own pair's rows of the graph |
1005
- | Overrides | `apps/web/exercise.ts`: `export const exercise = defineExercise({ publishPost: { actor, input }, sendInvoice: { off: '<why>' } })`. The same value is what every contract test hands `.contract({ exercise })` ([one declaration](#the-exercise-assertion)). An unknown name is `X_DECLARATION_UNKNOWN`; a blank `off` is `X_CONTRACT_EXERCISE_UNDECLARED` |
1006
- | A handler that calls a vendor | `defineExercise({ … }, { setup: () => { mockFetch('https://api.vendor.test/*', handler); } })` — or `setup: () => cassette(import.meta.dir, 'exercise')`. Runs once in the exercise process, after the seal and before the first row; what it returns is disposed after the pass. A call a setup route answers is reached, not refused. `allowHost` in it is `X_EXERCISE_SETUP_UNSEALED` |
1006
+ | Overrides | `apps/web/exercise.ts`: `export const exercise = defineExercise({ publishPost: { actor, input }, sendInvoice: { off: '<why>' } })`. The same value is what every contract test hands `.contract({ exercise })` ([one declaration](#the-exercise-assertion)). A key is a registered name or a kind-qualified one — `'job:eraseAccount'`, `'action:eraseAccount'`, `'query:…'` — which is that kind's alone and wins over the bare name — in `x exercise`, the contract step and `x drill` alike: an action and a job sharing a name each get their own entry, and the paste line a shared name prints is the qualified key (`As of 2026-11-08`). An unknown name, or a kind the name is not registered as, is `X_DECLARATION_UNKNOWN`; a blank `off` is `X_CONTRACT_EXERCISE_UNDECLARED` |
1007
+ | A handler that calls a vendor | `defineExercise({ … }, { setup: () => { mockFetch('https://api.vendor.test/*', handler); } })` — or `setup: () => cassette(import.meta.dir, 'exercise')`. Runs once in the exercise process, after the seal and before the first row; what it returns is disposed after the pass. A call a setup route answers is reached, not refused. Several feature groups: `setup: [setupBilling, setupKyc]` — run in order, disposed in reverse, and one that throws disposes those that already ran before the pass refuses (`As of 2026-11-08`). `allowHost` in it is `X_EXERCISE_SETUP_UNSEALED` |
1008
+ | A step held by a cookie | `defineExercise({ finishSignIn: { request: { cookies: { pending: '<value>' } } } })` — the call's inbound request carries it, read by `useRequestCookie()` / `useRequestHeader()` in the handler; `headers: { … }` beside it. A function `request: async (actor) => ({ cookies: { sid: await mintSession(actor) } })` is awaited before each call, as that call's actor (A's and B's each mint their own). A cookie goes in `cookies`, never a `Cookie` header: that, a name outside the token set or a header `Headers` refuses is `X_EXERCISE_REQUEST_INVALID`. Read by `x exercise` and the contract step alike: `.contract({ exercise })` runs each generated run inside that request (`withRequestAs`, `@ultimat3/http`); with no `request` its call has none, so a handler reading a cookie there is `X_CONTRACT_DEFECT` on `X_NO_REQUEST` (`As of 2026-11-08`) |
1007
1009
  | Rows a generated value cannot satisfy | a cross-column `c.satisfies(…)` reads `X_SEED_GRAPH_UNSATISFIED`: `defineExercise({ … }, { factories: { bosses: defineFactory(bosses, { defaults: (i) => ({ … }) }) } })`, keyed by entity name, the graph's keys kept. A column that follows from a key or reference the graph picked: `derive: (row) => ({ scopeKey: … })` beside `build`/`reset`, reading `row.ownerOrgId`. A partial unique whose columns the factory builds is the database's to judge. An unknown name is `X_DECLARATION_UNKNOWN` |
1008
1010
  | Drift | a schema no draw satisfies is `unreached`, `X_CONTRACT_DRIFT`; its `override` binds each field the sampler names as a gap with what it needs (`digest: "<must match ^[0-9a-f]{64}$>"`), the contract step's `fix:` the same `input:` (`As of 2026-11-08`) |
1009
1011
  | Report | `.x/exercise.json` and `--json`: `{ seed, counts, records[] }`, each record `{ kind, name, outcome, code?, reason?, defect?, statements, effects, ms, override?, fix?, tenant?, crash? }` — `fix` where no override reaches it; `defect` on a 5xx: `{ cause, statement?, fields? }`, the error's own cause (a value the input held under a credential key or a `.sensitive()` field masked `[redacted]`), the SQL a database refusal names and the paths a validation failure names, all carried into the `X_CONTRACT_EXERCISE_UNREACHED` finding. The fields before `tenant` are A's call. The human table's `tenant` and `crash` columns are the verdicts, `-` where none ran |
@@ -1052,8 +1054,11 @@ capability is proven); it excuses nothing on an action or a query, which answer
1052
1054
  job B handed one of A's ids — that is B choosing A's row, crossed as ever. `tenant: 'none'` excuses
1053
1055
  only the write half, and only with no id of A's handed: an action or a query runs as B's actor, so a
1054
1056
  write to A's row with no id in the input is a statement no tenant predicate scopes, crossed. A
1055
- finding prints paths, tables and seeded ids, never a bound value. The fix on each: `x exercise
1056
- <name> --json`, then read or write the row through the repository scoped to `ctx.actor`. What this
1057
+ finding prints paths, tables and seeded ids, never a bound value — one per leg and code, its places
1058
+ listed once, a list index that only repeats collapsed (`effect.enqueue[*].input.orgId (3 each)`).
1059
+ The fix on each: `x exercise <name> --json`, then read or write the row through the repository
1060
+ scoped to `ctx.actor`; for a `tenant: 'none'` job handed nothing of A's, whose read has no org to
1061
+ scope to, wrap it in `crossTenant('<why <name> reads every org>', async () => …)`. What this
1057
1062
  does not walk — a `route` `load`, a `task` — is
1058
1063
  [Policies and authz](Policies-And-Authz#the-dynamic-tenant-proof).
1059
1064
 
@@ -1099,14 +1104,18 @@ Source: `packages/testing/src/scale-sweep*.ts`, `plan-oracle.ts`, `plan-sweep*.t
1099
1104
 
1100
1105
  | Sweep | What | Red |
1101
1106
  |---|---|---|
1102
- | scale | every reached primitive once more in a tenant at 2 rows a table, once in one at 8; per statement shape, the counts compared | a shape sent more often at 8: `X_QUERY_SCALES_WITH_ROWS`, fix `preload()` or `expectedQueryLoop('<why>', fn)` |
1103
- | plans | every distinct statement whose first relation is an app table, `PREPARE`d and explained as a generic plan with `enable_seqscan`, `enable_bitmapscan`, `enable_sort` off, in a read-only transaction | `Seq Scan`, or an index scan with no `Index Cond` no `Limit` stops: `X_QUERY_UNINDEXED`. `Sort` under `Limit`: `X_QUERY_SORT_UNSERVED`, on the table its key names. Each prints an `indexes:` entry, one per arm for an `or`; a sort no declarable index serves (an expression, an aggregate, a derived column, keys across tables, mixed directions) or an index the entity already declares prints a rewrite or `expectedSeqScan` instead |
1107
+ | scale | every reached primitive once more in a tenant at 2 rows a table, once in one at 8; per statement shape, the counts compared. Each sized seed is written beside the graph before it: row positions (a generated integer, a factory's `index`) continue past that graph's, so ``code: `c${index}` `` on a unique column never repeats the pass's own row | a shape sent more often at 8: `X_QUERY_SCALES_WITH_ROWS`, fix `preload()` or `expectedQueryLoop('<why>', fn)` |
1108
+ | plans | every distinct statement whose first relation is an app table, `PREPARE`d and explained as a generic plan with `enable_seqscan`, `enable_bitmapscan` off — and, for a statement with a `Limit`, planned again with `enable_sort` off for its sort alone — in a read-only transaction | `Seq Scan`, or an index scan with no `Index Cond` no `Limit` stops: `X_QUERY_UNINDEXED`. `Sort` under `Limit`: `X_QUERY_SORT_UNSERVED`, on the table its key names. Each prints an `indexes:` entry, one per arm for an `or`; a sort no declarable index serves (an expression, an aggregate, a derived column, keys across tables, mixed directions) or an index the entity already declares prints a rewrite or `expectedSeqScan` instead |
1104
1109
 
1105
1110
  With the planner's scans and sorts disabled it picks one only when no index can answer, so the
1106
1111
  verdict reads the schema on empty tables — no volume, no statistics. Never red: `scale.verdict`
1107
1112
  `flat` (a declared loop listed in `expected` with its reason) or `unproven` (a call that did not
1108
1113
  answer at both sizes); a statement whose equality pins a unique key; one a partial index serves once
1109
- its value is bound; one under `expectedSeqScan('<why>', fn)` or on an entity with `scan: '<why>'`
1114
+ its value is bound; a whole read beside a join whose join column leads a declared index on that
1115
+ side, while the other side is bound by its own key — on empty tables a partial index the statement
1116
+ implies looks like one row, so the planner walks it rather than probe it per row (`As of
1117
+ 2026-11-08`; with no such index the read is red and its `indexes:` entry is the join column); one
1118
+ under `expectedSeqScan('<why>', fn)` or on an entity with `scan: '<why>'`
1110
1119
  (`plans.exempt`); one generic planning refuses (`plans.unplannable`). A server below Postgres 12:
1111
1120
  `X_QUERY_PLAN_UNAVAILABLE`.
1112
1121