@ultimat3/cli 31.51.0 → 31.52.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/README.md +9 -9
- package/package.json +29 -29
- package/src/catalog-layout.ts +194 -0
- package/src/cmd-i18n-spec.ts +4 -4
- package/src/cmd-i18n-split.ts +133 -0
- package/src/cmd-i18n.ts +46 -66
- package/src/config-redact.ts +20 -4
- package/src/db-rollback-pass.ts +4 -1
- package/src/dev-child-watch.ts +16 -0
- package/src/dev-db-migrate.ts +27 -46
- package/src/dev-db-migrator-hold.ts +131 -0
- package/src/dev-db-rollback.ts +11 -2
- package/src/dev-rebuild-schema.ts +7 -24
- package/src/generate-catalog-locales.ts +25 -2
- package/src/generate-follow-ups.ts +8 -3
- package/src/i18n-audit.ts +17 -33
- package/src/i18n-index.ts +108 -31
- package/src/i18n-locale-parity.ts +14 -6
- package/src/i18n-new-locale.ts +75 -0
- package/src/i18n-registration.ts +52 -27
- package/src/island-capture.ts +36 -7
- package/src/merge-state.ts +3 -2
- package/src/messages-floor.ts +2 -0
- package/src/messages.ts +2 -0
- package/src/serve-boot-telemetry.ts +106 -0
- package/src/serve-boot.ts +23 -4
- package/src/shot-blank.ts +70 -0
- package/src/templates/catalog-barrel.ts +84 -0
- package/src/templates/guard-released-forms.ts +2 -1
- package/src/templates/guard-untranslated-string.ts +27 -6
- package/src/templates/locales.ts +6 -0
- package/src/templates/scaffold-gitattributes.ts +9 -2
- package/src/templates/scaffold-i18n.ts +10 -6
- package/src/templates/shapes/offline.ts +5 -2
- package/src/test-ignores.ts +3 -2
- package/src/verify-floor.ts +9 -1
- package/src/verify-local-only.ts +66 -0
- package/src/verify-run.ts +17 -2
- package/wiki/Actions.md +1 -1
- package/wiki/Auth.md +3 -3
- package/wiki/Batching-And-Preloading.md +1 -0
- package/wiki/CLI-Reference-Data.md +241 -0
- package/wiki/CLI-Reference-Gate.md +572 -0
- package/wiki/CLI-Reference-Project.md +414 -0
- package/wiki/CLI-Reference-Ship.md +348 -0
- package/wiki/CLI-Reference-Tools.md +666 -0
- package/wiki/CLI-Reference.md +14 -2225
- package/wiki/Compared.md +8 -8
- package/wiki/Configuration.md +26 -2
- package/wiki/Deployment.md +1 -1
- package/wiki/Entities-And-Migrations.md +3 -2
- package/wiki/I18n.md +39 -5
- package/wiki/Installation.md +1 -1
- package/wiki/Jobs-And-Workflows.md +29 -1
- package/wiki/Known-Gaps.md +3 -0
- package/wiki/Observability.md +15 -1
- package/wiki/Outbound-HTTP.md +62 -2
- package/wiki/PWA-And-Offline.md +1 -1
- package/wiki/Policies-And-Authz.md +10 -0
- package/wiki/Realtime.md +29 -2
- package/wiki/Static-Assets.md +1 -1
- package/wiki/Testing.md +33 -0
- package/wiki/Theming.md +31 -8
- package/wiki/Troubleshooting.md +1 -1
- package/wiki/Upgrading.md +5 -1
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
# CLI reference: the gate and tests
|
|
2
|
+
|
|
3
|
+
Part of the [CLI reference](CLI-Reference): `x verify`, `x exercise`, `x drill`, `x test`, `x clean`, `x affected`, `x policy`, `x i18n`. Conventions, global flags and the command index are on the index page.
|
|
4
|
+
|
|
5
|
+
## x verify
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
x verify [--only <step>[,<step>…] [--shard i/n [--timings file]] | --changed [--base <ref>] [--dirty]] [--workers N] [--isolate] [--json]
|
|
9
|
+
x verify merge <part.json…> [--json]
|
|
10
|
+
x verify plan [--parts n] [--json]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**`x verify plan`** (`As of 31.17.0`) — the gate cut into CI parts, as data: each part an `x verify
|
|
14
|
+
--only <steps> [--shard i/n]` for one runner, and `data.matrix` a GitHub `strategy.matrix`
|
|
15
|
+
(`{ include: [{ part, only, shard?, needs }] }`) a workflow reads with `fromJSON`. `--parts`: `1`
|
|
16
|
+
(the whole gate on one runner) or `4`–`64`, default `4` — a `static` part (every step that is not a
|
|
17
|
+
suite), an `e2e` part (`typecheck` + `e2e`), and the rest split between shards of `unit,contract,job`
|
|
18
|
+
and of `live`, the unit group taking the odd one. `needs` says what the runner starts first:
|
|
19
|
+
`none`, `database` (the test Postgres) or `services` (every test service). Derived from
|
|
20
|
+
`VERIFY_STEP_NAMES`, so a new gate step lands in a part with no workflow edit, and every step sits in
|
|
21
|
+
exactly one part or every shard of one split — the rule `x verify merge` refuses a run by. `x new`'s
|
|
22
|
+
`.github/workflows/ci.yml` is three jobs: `plan` → one `gate` per part → `verify` (the merge) →
|
|
23
|
+
[CI: the gate across parallel jobs](CI-Parallel-Gate). Pure: it reads no file and starts nothing.
|
|
24
|
+
|
|
25
|
+
**`--changed`**, `As of 31.0` — the steps whose inputs the diff touches, NOT A GATE RUN like `--only`
|
|
26
|
+
and never beside it (`X_CLI_BAD_FLAG`). The diff is `x affected`'s: `<base>...HEAD`, `--base` default
|
|
27
|
+
the remote-tracking default branch (`origin/HEAD`, else `origin/main`, else local `main`; `As of 31.1`), `--dirty` adds uncommitted and untracked work. Each file gets one rule, each rule selects
|
|
28
|
+
steps; `data.changed` carries `{ base, dirty, files: [{ path, rule }], steps: [{ name, files }] }` and
|
|
29
|
+
the human render one `step ← files` line per step. Fail-open: a path no rule speaks for runs the gate.
|
|
30
|
+
Each suite but `eval` then runs only the test files the diff's import closure reaches — `x test
|
|
31
|
+
--affected`'s selection, `data.changed.tests` — a suite none of them belongs to is dropped, and the
|
|
32
|
+
`unit` coverage floor is not judged on the subset; a file the import graph cannot speak for (a root
|
|
33
|
+
config, a catalog) runs every test.
|
|
34
|
+
|
|
35
|
+
| rule | files | steps |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| `doc` | `*.md`, `docs/`, `wiki/` | package-shape, errors, unit, manifest, roadmap |
|
|
38
|
+
| `test` | `*.test.ts(x)`, `e2e/` | typecheck, lint, filesize, package-shape, errors + the suite that owns the file |
|
|
39
|
+
| `generated` | `x.manifest.json` | lint, contract-diff, manifest |
|
|
40
|
+
| `page` (`As of 31.22`) | `apps/<app>/site/**/page.tsx`, `apps/<app>/app/**/page.tsx` | typecheck, lint, boundaries, filesize, i18n + the suites, cut to that route's tests. An inner-loop answer, not proved idle: `budgets`, `seo`, `exercise`, `manifest` wait for the full `x verify` |
|
|
41
|
+
| `source` | `apps/`, `packages/`, `guards/`, `scripts/`, `types/`, `bin/` | every step but `drift` |
|
|
42
|
+
| `drift-input` | `packages/db/**`, `apps/*/clients/**`, `openapi.json`, any module importing `@ultimat3/entity` and everything it imports | every step |
|
|
43
|
+
| `root-config` · `deleted` · `unknown` · `outside` | a root file, any `app.config.ts`, a vanished module, another directory, a path outside the app | every step |
|
|
44
|
+
|
|
45
|
+
**`As of 22.7`** — the width is a memory budget (`max(2.75 GiB, 25% of RAM)` at 1.25 GiB a worker — no fixed 4 GiB cap since 2026-11-07,
|
|
46
|
+
at most one per core, printed on the step line; `ULTIMATE_TEST_MEMORY_BUDGET` /
|
|
47
|
+
`ULTIMATE_TEST_MAX_WORKERS` override, `--workers` wins), shared machine-wide across concurrent runs,
|
|
48
|
+
and test files are NOT isolated unless `--isolate` or `x.verify.json` `"isolate": true` says so →
|
|
49
|
+
[Testing](Testing#memory-width-and-isolation). `--shard i/n` (with `--only unit|contract|live|job|e2e`)
|
|
50
|
+
runs one CI job's deterministic slice — round-robin over the sorted files, or with `--timings
|
|
51
|
+
<file>` (`{ "path": ms }`, committed so every job reads one) heaviest-first to the lightest shard,
|
|
52
|
+
an unknown file at the median; `live` and `e2e` stay one process inside it, a slice per
|
|
53
|
+
runner, each runner with its own services (`As of 2026-11-07`) — and `x verify merge` folds every job's `--json` part back
|
|
54
|
+
into the gate verdict (`X_VERIFY_SHARD_INVALID`, `X_VERIFY_MERGE_INCOMPLETE`,
|
|
55
|
+
`X_VERIFY_MERGE_INPUT`) → [CI: the gate across parallel jobs](CI-Parallel-Gate). The paragraphs
|
|
56
|
+
below on `--workers` and batching describe 22.6 and earlier where they differ.
|
|
57
|
+
|
|
58
|
+
| `x.verify.json` key | What it sets |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `steps` | steps this repo may never report as skipped (`X_VERIFY_SUITE_VANISHED`) |
|
|
61
|
+
| `coverage` | `{ "lines", "funcs", "why"?, "exclude"?: [{ "glob", "why" }] }` — the `unit` step's floor for the app's whole source tree (`X_COVERAGE_BELOW_FLOOR`, `X_COVERAGE_FLOOR_UNSTATED`, `X_COVERAGE_FLOOR_STALE`) → [Testing](Testing#coverage). `x doctor` prints every `exclude` |
|
|
62
|
+
| `stepTimeoutMs` | `{ "<step>": milliseconds }` — a step's own deadline. Default 8 minutes for the six suites, 5 otherwise; past it, `X_VERIFY_STEP_TIMEOUT`, its processes killed |
|
|
63
|
+
| `localOnly` | `{ "<step>": "<why>" }` — steps a `CI` run leaves out, each why in a line and `data.localOnly`; run locally and by `--only`. An unknown step or empty why is a `manifest`-step problem |
|
|
64
|
+
| `exercise` | `{ "unprovenMax"?: <0–1>, "statementsMax"?: <whole ≥ 1> }` — what the `exercise` step's pass may leave unproven, and statements per call (`X_EXERCISE_UNPROVEN_ABOVE_FLOOR`, `X_STATEMENTS_OVER_BUDGET`); absent, a warning → [`x exercise`](#x-exercise), `As of 31.16.0` |
|
|
65
|
+
| `isolate` · `typecheckBin` · `agentsMdMaxBytes` | a fresh global per test file · the `tsc`-compatible binary · the `AGENTS.md` byte budget |
|
|
66
|
+
| `strict` | `true`: each step the run selects runs a check or has a `skip` why, else red (`X_VERIFY_STRICT_UNRUN`). Otherwise a warning line and `data.unwaived` name the steps that ran none. `As of 2026-11-15`; the default flips to `true` on `next` |
|
|
67
|
+
| `skip` | `{ "<step>": "<why>" }` — why a step runs no check here: a gate step not in `steps`, a non-empty why. A why over a step that ran warns `drop its entry` |
|
|
68
|
+
| `guardBaseline` | `{ "<guard>": n }` — a `guards/<guard>.ts` may still report `n` findings: up to `n` notices on `boundaries`, above it red (`X_GUARD_OVER_BASELINE`), below it red naming the lower number (`X_GUARD_BASELINE_STALE`): it only falls. A baseline for a removed guard is stale; a report-only guard (`severity: 'warning'`) is never judged |
|
|
69
|
+
|
|
70
|
+
Either render prints one line per finished step on **stderr** as each finishes — under `--json`
|
|
71
|
+
`{"step":"lint","ok":true,"ms":21987}`, otherwise (`As of 31.22`) `✓ lint 22.0s`, `○ seo 0.0s` for a
|
|
72
|
+
step that did not apply, and for a red step its narrowest re-run: `✗ unit 3.1s → x test unit --filter
|
|
73
|
+
<the test files its findings name> --json`, else `x verify --only <step> --json` — and every minute a step is still running a `still running: unit (12m 3s)` line;
|
|
74
|
+
under `--json` stdout stays the single document. A cancelled job's log ends on the last step that
|
|
75
|
+
finished, and a harness that kills a process after N silent minutes never kills a healthy gate.
|
|
76
|
+
|
|
77
|
+
The single gate. Green means shippable; CI runs exactly this. One step list, in cost order, shared
|
|
78
|
+
with the framework repo's own `bun run verify` — and **the gate is this command with no flag**,
|
|
79
|
+
because "green" has to mean the same thing for everyone. `--only <step>` runs one step for an
|
|
80
|
+
iteration loop, and `--only typecheck,lint,boundaries` runs several in ONE process — one CLI boot
|
|
81
|
+
and one app load instead of one per step — always in the gate's declared order, whatever order they
|
|
82
|
+
were typed in. Neither is a gate run: it announces `NOT A GATE RUN` in the summary and in `--json`
|
|
83
|
+
(`data.notAGateRun`, and `data.only` as the list of steps — a list of one for a single name), exits
|
|
84
|
+
with the steps' own status, and writes no floor file — even a list naming every step. An unknown or
|
|
85
|
+
empty item is refused (`X_CLI_BAD_FLAG`) naming every valid step, with a fix that corrects the typo
|
|
86
|
+
and keeps the rest of the list. There is no `--skip`. A step with nothing to check in this project
|
|
87
|
+
reports as skipped (`-`), never as passed — and the summary counts skips apart from passes and
|
|
88
|
+
names them, so a gate that is green because a suite does not exist has to say so on the one line
|
|
89
|
+
every reader sees:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
✓ 20 of 21 steps passed in …ms — 1 skipped: roadmap
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`--json` carries the same fact twice: `steps[].skipped` per step, and `data.skipped` as the list of
|
|
96
|
+
names beside `data.failed`. `all {n} steps passed` is printed only when nothing was skipped.
|
|
97
|
+
|
|
98
|
+
Every step that ran no check — a skip, a vanished suite, a strict refusal — is printed under the
|
|
99
|
+
table as `skipped: <step> — <reason>` (`no *.e2e.test.ts file in this tree`, `found 3 test(s) and
|
|
100
|
+
every one skipped itself`) and carried in `data.skipReasons` as `{ "<step>": "<reason>" }`,
|
|
101
|
+
`As of 2026-11-15`.
|
|
102
|
+
|
|
103
|
+
`x.verify.json` ratchets those skips. Hand-written, committed at the repo root, read by the gate
|
|
104
|
+
and written by nothing:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{ "steps": ["typecheck", "lint", "boundaries", "unit", "contract", "live", "e2e", "manifest"] }
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Every name in it is a step this repo has already run, so a step in the list with nothing left to
|
|
111
|
+
check is a deleted suite — reported as **failed**, not skipped, with `X_VERIFY_SUITE_VANISHED` and
|
|
112
|
+
the two edits that resolve it. A repo with no such file is not ratcheted, and a name the gate does
|
|
113
|
+
not run is refused by the `manifest` step (`X_CONFIG_INVALID`) rather than silently covering
|
|
114
|
+
nothing. Removing a line is allowed; it just has to be a diff somebody reviews.
|
|
115
|
+
|
|
116
|
+
**`live` starts its own test database, `As of 2026-11-15`.** When `x.verify.json` holds `live`
|
|
117
|
+
(or `--only` names it), the step runs the idempotent `docker compose -f
|
|
118
|
+
docker/docker-compose.test.yml up -d --wait --wait-timeout 120` — the stack `x new` wrote — and
|
|
119
|
+
hands that env file's values to the suites, for every key the shell left unset. It runs even when
|
|
120
|
+
`TEST_DATABASE_URL` already answers: a Postgres still starting is waited for, and Redis, NATS and S3
|
|
121
|
+
come up beside it. If `up` fails while the database answers our login (a concurrent run's container
|
|
122
|
+
conflict, say), only the keys whose service answers are handed over — a suite with no URL skips; one
|
|
123
|
+
with a dead URL would fail. A Postgres on that port that refuses this app's login is another app's
|
|
124
|
+
stack: `X_TEST_SERVICES_UNAVAILABLE`, and nothing is handed over. A `TEST_DATABASE_URL` that is not
|
|
125
|
+
the env file's is your own server, and is never probed or second-guessed. The stack is **left
|
|
126
|
+
running** (RAM only; the next run reuses it) and the step's warning says so, with the stop line,
|
|
127
|
+
`docker compose -f docker/docker-compose.test.yml down`. No Docker, or a start that fails with no
|
|
128
|
+
database answering: a warning carrying `X_TEST_SERVICES_UNAVAILABLE` and the start command as its
|
|
129
|
+
fix, and the suites run exactly as before. When the floor holds `live` and that run executed no
|
|
130
|
+
test, `X_TEST_SERVICES_UNAVAILABLE` is the step's **finding**, first and red, with its working fix —
|
|
131
|
+
not `X_VERIFY_SUITE_VANISHED`, which is no longer added when the step already says why
|
|
132
|
+
(`As of 2026-11-19`). `--only live` with no floor, or a live run where some tests ran, keeps the
|
|
133
|
+
warning.
|
|
134
|
+
One stderr line names the stack: `services: started|reused <project>`, or `services: shared <project>
|
|
135
|
+
with <dir>` for another checkout of this app (same first commit or `origin`). A stack under this
|
|
136
|
+
project name started by a different app is refused before compose runs:
|
|
137
|
+
`X_TEST_SERVICES_UNAVAILABLE`, unless `ULTIMATE_TEST_SERVICES_SHARED=1` says the share is intended.
|
|
138
|
+
A **stopped** one is called stopped, never "already running", and its fix removes it by name:
|
|
139
|
+
`docker compose -p <project> down --volumes` (its data was in RAM), then `x verify --only live`. It
|
|
140
|
+
is reported, never taken over. `x new` (`As of 2026-11-19`) writes the compose `name:` as
|
|
141
|
+
`<app>-test-<8 hex of the scaffold directory's hash>` and picks the ports from name and directory,
|
|
142
|
+
so two scaffolds with one name on one machine get two stacks; an existing app keeps the `name:` its
|
|
143
|
+
compose file states, and a moved checkout keeps its scaffold-time name.
|
|
144
|
+
`x clean --services` stops the stack.
|
|
145
|
+
`packages/cli/src/verify-live.ts` decides when; `verify-services.ts` probes and starts;
|
|
146
|
+
`verify-services-stack.ts` reads whose stack it is.
|
|
147
|
+
|
|
148
|
+
`--workers` widens the test steps only. `unit`, `contract`, `job` and `eval` run as
|
|
149
|
+
`bun test --parallel=N`, each worker with its own database; `live` and `e2e` are serial by
|
|
150
|
+
declaration and say so in the output. **`x test live` and `x test e2e` obey the same declaration,
|
|
151
|
+
`As of 2026-08-27`** — they did not, so `x test live --workers 8` ran eight processes over the very
|
|
152
|
+
files `x verify` ran one over. `--workers` is accepted there and clamps to 1. That clamp read the
|
|
153
|
+
POSITIONAL, so the bare `x test --workers 8` still widened over the same files until 2026-09; the
|
|
154
|
+
selection is now partitioned by each file's own type. `x test`'s e2e pass also LAUNCHES as the
|
|
155
|
+
gate's `e2e` step does, `As of 2026-11`: in an app root with a browser (`CHROME_PATH`, or one
|
|
156
|
+
`x doctor` finds) it runs under `@ultimat3/testing`'s e2e preload, which spawns the app, with the
|
|
157
|
+
device zone `America/Los_Angeles` — before, `x test e2e` never opened a browser and every
|
|
158
|
+
browser-backed case skipped. With no browser both skip those cases alike, and under
|
|
159
|
+
`E2E_BROWSER_REQUIRED=1` those cases refuse instead of skipping, in both. The default width is
|
|
160
|
+
a memory budget, `As of 2026-11-07`: `max(2.75 GiB, 25% of RAM)` (`BUDGET_RULE`) at 1.25 GiB a worker
|
|
161
|
+
(`WORKER_BYTES`, `GATE_BUDGET_FLOOR` and `GATE_BUDGET_SHARE` in
|
|
162
|
+
`packages/cli/src/test-workers.ts`), at most one per core — the paragraph under `x verify` above.
|
|
163
|
+
**No fixed ceiling of 8**: it held a 12-core box with 30 GB free to 8. `--workers` accepts 1 to
|
|
164
|
+
64 on both `x verify` and `x test`; an explicit width is the caller's call and is not held to memory.
|
|
165
|
+
|
|
166
|
+
**A large selection runs in batches, `As of 22.6.2`.** A `--parallel` worker's heap grows with
|
|
167
|
+
every file it runs and is returned only when its `bun test` exits, so one process over the whole
|
|
168
|
+
corpus peaked higher with every test an app added — and the default of 22.6.1 (18 workers on a
|
|
169
|
+
12-core box with 35 GB free, 1 GiB budgeted a worker) took a 45 GB machine with no swap down.
|
|
170
|
+
A pass now runs as `ceil(files / (workers x 24))` `bun test --parallel=N` processes in sequence,
|
|
171
|
+
the files dealt round-robin over the sorted list, so the peak depends on the width and not on the
|
|
172
|
+
corpus. One adopter's `x test unit`, 768 files, 12 cores: 22.6.1's default (18 workers, one
|
|
173
|
+
process) peaked at 17.1-18.2 GB of process tree in 132-167s; 22.6.2's default (13-14 workers,
|
|
174
|
+
3 batches) at 11.3-12.2 GB in 152-163s, on a box shared at load 30-40. At the same width the split
|
|
175
|
+
costs no wall time within noise (12 workers: 150-158s unbatched, 147s in three batches). The split is a pure function of the file list and the width,
|
|
176
|
+
so the `fix:` a failure prints (`x test unit --workers N`) reruns the same batches; a `-- --watch`
|
|
177
|
+
run is never split; a forwarded `-- --bail` starts no batch after a red one. `x test --json` carries `batches`
|
|
178
|
+
when a pass was split, and each batch's output is kept under a line naming it.
|
|
179
|
+
|
|
180
|
+
**Bun owns the pool, `As of 2026-08-27`.** The CLI used to pack the files into N bins itself
|
|
181
|
+
(largest-first greedy over file SIZE) and spawn one `bun test` per bin; `--parallel=N` hands each
|
|
182
|
+
free worker the next file instead. **Expect no speed-up** — the two forms measure the same. Four
|
|
183
|
+
interleaved runs each on this repo's 1296-file unit corpus, 8 workers: 58.2/60.0/65.0/66.5s
|
|
184
|
+
hand-packed against 54.5/57.8/61.7/64.5s under `--parallel=8`. Both are work-bound — the corpus is
|
|
185
|
+
436.7s of file time, so eight workers cannot beat 54.6s however the files are dealt, and the
|
|
186
|
+
slowest single file is 20.5s. The packer is gone because it was 233 lines buying nothing, not
|
|
187
|
+
because it was slow ([#342](https://github.com/developerz-ai/ultimate/issues/342)).
|
|
188
|
+
|
|
189
|
+
| Step | Checks |
|
|
190
|
+
|---|---|
|
|
191
|
+
| `typecheck` | `tsc` across every workspace |
|
|
192
|
+
| `lint` | Biome: no `any`, no default exports, no bare `Error`, no raw colours, no hardcoded user-facing strings |
|
|
193
|
+
| `boundaries` | surface and layer imports, resolved transitively; package tiers in a monorepo; an app's `guards/*.ts`. A guard may spawn a process (`check` is any async function): it runs under this step's deadline, so a slow one sets `stepTimeoutMs.boundaries` in `x.verify.json` |
|
|
194
|
+
| `filesize` | a source file over 500 lines |
|
|
195
|
+
| `package-shape` | a workspace package missing `README.md`, `CLAUDE.md`, `tsconfig.json`, `src/index.ts`; a workspace importing a sibling workspace it does not declare (`X_WORKSPACE_DEP_UNDECLARED`); a workspace's shipped source importing a registry package — `@ultimat3/*` included, type-only imports too — that neither its own `package.json` nor the root's declares (`X_WORKSPACE_EXTERNAL_DEP_UNDECLARED`, fix `bun add <pkg> --cwd <workspace>`). Builtins (`node:*`, `bun`, `bun:*`), workspaces and tsconfig `paths` aliases are exempt. `As of 31.1` |
|
|
196
|
+
| `errors` | every `X_*` code has a runnable fix and a docs page |
|
|
197
|
+
| `unit` | pure logic — services, money, policy predicates, matchers |
|
|
198
|
+
| `contract` | action/query schemas, policy denials, emitted OpenAPI and MCP shapes |
|
|
199
|
+
| `live` | live-query snapshot, incremental patches, reconnect delta, policy-filtered rows |
|
|
200
|
+
| `job` | step replay, idempotency dedupe, retry/backoff, concurrency, outbox atomicity |
|
|
201
|
+
| `e2e` | a real browser (raw CDP) against the app, spawned on a throwaway database when Chrome is present, including offline and SW update |
|
|
202
|
+
| `eval` | prompt scores vs. their recorded baselines, and a prompt with no eval at all |
|
|
203
|
+
| `drift` | schema vs migrations |
|
|
204
|
+
| `contract-diff` | the code vs the **committed** `x.manifest.json`: a breaking change without a major bump |
|
|
205
|
+
| `budgets` | per-route JS bytes, the global style layer every document carries (`X_STYLES_GLOBAL_MISSING`), and every route that reads live rows with no island to receive them (`X_LIVE_ROUTE_NO_ISLAND`). **Builds first** when `.x/build-stats.json` is missing, of an earlier measurement rule, or older than the newest app source: `x build --target static --no-preflight --no-capture --out .x/verify-static`, under this step's deadline (`stepTimeoutMs.budgets`), never over a deployable `.x/static`. A failed build is the step's verdict, with the build's own findings. `As of 30.0` |
|
|
206
|
+
| `manifest` | the files an agent reads: `x.manifest.json` **and `openapi.json`** freshness — the one check `x manifest --check` runs (`X_MANIFEST_MISSING` / `X_MANIFEST_DRIFT` / `X_MANIFEST_STALE`) — `.env.example`, a hand-written `AGENTS.md` that exists and is under 12kB, and `x.verify.json` naming only steps the gate runs |
|
|
207
|
+
| `roadmap` | framework repo only — every `docs/idea/14-roadmap.md` milestone carries a status marker, and a milestone marked shipped still has the artifacts its own row names |
|
|
208
|
+
|
|
209
|
+
A test's type is its filename suffix — `*.contract.test.ts`, `*.live.test.ts`, `*.job.test.ts`,
|
|
210
|
+
`*.e2e.test.ts` (or any test under `e2e/`), `*.eval.test.ts`. Everything else is a unit test, so no
|
|
211
|
+
test can fall between two steps.
|
|
212
|
+
|
|
213
|
+
`eval` is the one step that applies with no suite of its own: a prompt no `defineEval` names is
|
|
214
|
+
`X_EVAL_MISSING`, and an eval whose baseline was never recorded is `X_EVAL_BASELINE_MISSING`,
|
|
215
|
+
because a skipped step — or one gating against nothing — would read as a green gate over untested
|
|
216
|
+
code. It gates on the drop from each eval's committed baseline, never on an absolute score —
|
|
217
|
+
`ULTIMATE_EVAL_RECORD=1 x test eval` re-records those baselines so accepting a new number is a
|
|
218
|
+
reviewable diff. `0`, `false`, `no`, `off` and empty (any case, trimmed) are off and gate; any
|
|
219
|
+
other value records (`As of 2026-11-19`, `packages/ai/src/eval-baseline.ts`).
|
|
220
|
+
|
|
221
|
+
That flag and this step are mutually exclusive. `x verify` with `ULTIMATE_EVAL_RECORD` set is
|
|
222
|
+
`X_EVAL_RECORDING` and the suite does not run: recording makes every eval write the numbers it
|
|
223
|
+
just measured and pass, so a gate that inherited the flag reports green over scores nothing
|
|
224
|
+
compared — and rewrites the committed baselines on its way through.
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
$ x verify --json
|
|
228
|
+
{"ok":false,"command":"verify",
|
|
229
|
+
"summary":"1 of 21 steps failed — 3 skipped: e2e, contract-diff, roadmap","steps":[
|
|
230
|
+
{"name":"budgets","ok":false,"durationMs":812,"skipped":false,"findings":[
|
|
231
|
+
{"code":"X_BUDGET_EXCEEDED","cause":"/pricing ships 61.2kb of JS (minified, uncompressed) over a 40kb budget via site/pricing/page.tsx -> islands/post-form-04f75f18.js; charged: /islands/post-form-04f75f18.js 50123 B, inline scripts 855 B",
|
|
232
|
+
"fix":"edit apps/web/site/pricing/page.tsx — set budget: { js: '62kb' } with // measured: 62682 B (x build --target static) — why: <the function it buys> directly above it, then x manifest (x.manifest.json carries the budget); or x routes --json for the chain and move the heavy import behind hydrate: 'interaction'",
|
|
233
|
+
"docs":"https://github.com/developerz-ai/ultimate/wiki/Error-Codes",
|
|
234
|
+
"at":"apps/web/site/pricing/page.tsx",
|
|
235
|
+
"meta":{"jsBytes":62682,"charged":[{"url":"/islands/post-form-04f75f18.js","bytes":50123}],"inlineJsBytes":855}}]}],
|
|
236
|
+
"data":{"failed":["budgets"],"skipped":["e2e","contract-diff","roadmap"],"durationMs":11153}}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
A finding is `code`, `cause`, `fix`, and optionally `docs`, `at` and `meta`. `at` is the
|
|
240
|
+
path an agent opens — a file, or the stuck test file for a timed-out step — and is absent
|
|
241
|
+
when there is no such path. `meta` is structured facts behind `cause`, never the only home of
|
|
242
|
+
one: an unmeasured budget carries its route in `meta.route` (`X_BUDGET_UNMEASURED` — `at` names
|
|
243
|
+
the file that declares it), while `X_BUDGET_EXCEEDED` carries what the bytes were charged as
|
|
244
|
+
(`meta.jsBytes`, `meta.charged`, `meta.inlineJsBytes`) and spells the route in `cause`.
|
|
245
|
+
`X_VERIFY_STEP_TIMEOUT`
|
|
246
|
+
carries `meta.step`, `meta.deadlineMs`, `meta.killed: [{pid, command}]` and
|
|
247
|
+
`meta.inFlight: [{command, files, workers, stuck}]`; `at` is the stuck test file when
|
|
248
|
+
one could be named, and the failed step's `output` is the tail of what the killed run had printed.
|
|
249
|
+
|
|
250
|
+
Errors: `X_VERIFY_FAILED` (with the failing step names), plus each step's own code.
|
|
251
|
+
|
|
252
|
+
## x exercise
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
x exercise [<name>] [--seed n|random] [--shard i/n] [--json]
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Every action, query and job the app registers, run **once** against generated rows, with no test
|
|
259
|
+
written. The question no written test answers: what does each primitive do when it actually runs?
|
|
260
|
+
|
|
261
|
+
| Step | What happens |
|
|
262
|
+
|---|---|
|
|
263
|
+
| database | a scratch one — embedded, or a server named by `TEST_DATABASE_URL` when a migration needs an extension the embedded one cannot link — with the framework tables and every migration applied. Never the developer's own: the pass commits |
|
|
264
|
+
| rows | a fresh pair of tenants per primitive, every table seeded off its declaration (`x db seed --generate`'s graph) |
|
|
265
|
+
| actor | the first of `x policy explain`'s actors the primitive's policy allows, in its own tenant |
|
|
266
|
+
| input | the override, then an id field whose stem names a seeded entity (`postId` → `posts`), then the minimal draw of its schema |
|
|
267
|
+
| room | network sealed, mail captured, job queue in memory, clock frozen. A call out is refused, so the primitive is `unreached`, never sent |
|
|
268
|
+
|
|
269
|
+
Each primitive ends `reached`, `refused` (no actor its policy allows — by design), `off` (an
|
|
270
|
+
override with a reason) or `unreached`. `--json` and `.x/exercise.json` carry the same document:
|
|
271
|
+
`{ seed, counts, records[] }`, each record `{ kind, name, outcome, code?, reason?, statements,
|
|
272
|
+
effects, ms, override? }`. A `<name>` runs that one primitive; an unknown name is
|
|
273
|
+
`X_DECLARATION_UNKNOWN`.
|
|
274
|
+
|
|
275
|
+
`unreached` is red: `X_CONTRACT_EXERCISE_UNREACHED`, and its `fix:` is the entry to paste into
|
|
276
|
+
`apps/web/exercise.ts` — valid TS naming the actor the pass ran as (`testActor(…).actor`, imported
|
|
277
|
+
from `@ultimat3/policy`) and the seeded row each id field was bound to (`As of 2026-11`). The
|
|
278
|
+
`exercise` option `.contract()` takes, one shape:
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
import type { Actor } from '@ultimat3/core';
|
|
282
|
+
import { defineExercise } from '@ultimat3/testing';
|
|
283
|
+
|
|
284
|
+
declare const author: Actor; // a signed-in actor the policy allows
|
|
285
|
+
|
|
286
|
+
export const exercise = defineExercise({
|
|
287
|
+
publishPost: {
|
|
288
|
+
actor: author,
|
|
289
|
+
input: (drawn) => ({ ...(drawn as Record<string, unknown>), postId: '<a real id>' }),
|
|
290
|
+
},
|
|
291
|
+
sendInvoice: { off: 'charges a card through the payment provider' },
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**The seed** (`As of 31.47.0`). Row ids and tenants are drawn from it, so it is part of the verdict.
|
|
296
|
+
|
|
297
|
+
| Run | Seed | For |
|
|
298
|
+
|---|---|---|
|
|
299
|
+
| `x exercise`, and the gate's `exercise` step | one constant, `DEFAULT_SEED` from `@ultimat3/testing` | one tree, one verdict |
|
|
300
|
+
| `x exercise --seed <n>` | `n`, 0 to 2147483647 | replaying a run |
|
|
301
|
+
| `x exercise --seed random` | a fresh one | looking for a seed-dependent helper; never the gate |
|
|
302
|
+
|
|
303
|
+
The first output line and `seed` in `.x/exercise.json` and `--json` name the seed used. Each pass
|
|
304
|
+
has its own scratch database, so repeating a seed collides with nothing.
|
|
305
|
+
|
|
306
|
+
A blank `off` reason is `X_CONTRACT_EXERCISE_UNDECLARED`; so is an `exercise.ts` with no single
|
|
307
|
+
`defineExercise()` export. The gate's `exercise` step runs this command as a child and is red on
|
|
308
|
+
exactly its findings, plus the static half of the tenant proof: an entity with no tenant column
|
|
309
|
+
that references one with a tenant and declares no `shared` reason.
|
|
310
|
+
|
|
311
|
+
**The `exercise` floor** (`As of 31.16.0`). `x exercise` and the gate step judge the pass against
|
|
312
|
+
`x.verify.json`'s `exercise` key ([Configuration](Configuration#the-gates-file--xverifyjson)). Without the key every
|
|
313
|
+
judgement below is a warning line (`! …`, and `data.warnings[]` under `--json`) naming the figure to
|
|
314
|
+
write, and the run stays green; with it, above a declared figure is red.
|
|
315
|
+
|
|
316
|
+
| Judged | Red, once opted in | Warning otherwise |
|
|
317
|
+
|---|---|---|
|
|
318
|
+
| unproven ÷ reached — a tenant, crash or scale proof that could not ask | `X_EXERCISE_UNPROVEN_ABOVE_FLOOR`, naming the first three | the ratio, rounded up, to write as `unprovenMax`; also when it fell under the floor, naming the lower figure |
|
|
319
|
+
| a sized-seed table the database refused | `X_EXERCISE_SEED_FAILED`, one per table, naming the entity, the driver's words and its readers — red exactly when the unproven ratio is | the same finding as a line |
|
|
320
|
+
| one call over its statement ceiling — `statementsMax`, or the entry's own `statements: { max, why }` | `X_STATEMENTS_OVER_BUDGET`, the busiest call and its three largest shapes | the same finding as a line, judged at 100 |
|
|
321
|
+
|
|
322
|
+
**Route loads** (`As of 31.17.0`). After the primitives, the pass runs every `app/` and `site/`
|
|
323
|
+
file route that declares a `load` — the route table `x routes` prints — once in its own seeded
|
|
324
|
+
tenant, as the runtime calls it: in a request, as the first actor the route's permission allows (a
|
|
325
|
+
signed-in one where it names none), its params a seeded row's id or the route's own `prerender()`
|
|
326
|
+
sample. Each load gets the primitives' proofs: its statements counted against the ceiling (100), a
|
|
327
|
+
scale sweep at 2 and 8 rows a table, and the plan oracle over what it sent. The records ride beside
|
|
328
|
+
`records`, as `routes[]` in `--json` and `.x/exercise.json` (`{ kind: 'route', name, file, outcome,
|
|
329
|
+
reason?, statements, effects, ms, statementCeiling?, plans?, scale? }`), and every finding is a
|
|
330
|
+
**warning line** on `main` — `route /messages (apps/web/app/messages/page.tsx) · X_QUERY_SCALES_WITH_ROWS …`,
|
|
331
|
+
`· X_STATEMENTS_OVER_BUDGET …`, a plan code, or `· load not exercised: <reason>` — never red: no
|
|
332
|
+
floor key opts a page read in yet.
|
|
333
|
+
|
|
334
|
+
**Reached with nothing to prove** (`As of 31.17.0`): a primitive reached that sent no statement and
|
|
335
|
+
had no effect has vacuous proofs — a sweep of nothing is `flat`. One warning line names the first
|
|
336
|
+
five, `X_EXERCISE_EMPTY_REACH … — fix: edit exercise.ts: give each an input that reaches its work, or
|
|
337
|
+
{ off: '<why>' }`. A warning, not red, on a whole-pass run only.
|
|
338
|
+
|
|
339
|
+
**Route entries** (`As of 2026-11-15`). What a page needs that a seeded id and a role cannot give it
|
|
340
|
+
is `defineExercise`'s second argument, keyed by the URL pattern `x routes` prints:
|
|
341
|
+
|
|
342
|
+
```ts
|
|
343
|
+
import type { Actor } from '@ultimat3/core';
|
|
344
|
+
import { defineExercise } from '@ultimat3/testing';
|
|
345
|
+
|
|
346
|
+
declare const author: Actor; // a signed-in actor the policy allows
|
|
347
|
+
declare function asMember(seated: Actor | null): Promise<Actor | null>;
|
|
348
|
+
declare function ownThread(): Promise<{ id: string }>;
|
|
349
|
+
declare function consentQuery(): Promise<string>;
|
|
350
|
+
|
|
351
|
+
export const exercise = defineExercise(
|
|
352
|
+
{ publishPost: { actor: author } },
|
|
353
|
+
{
|
|
354
|
+
routes: {
|
|
355
|
+
'/posts/board': { actor: asMember }, // (seated) => the actor the authenticator resolves: its facts
|
|
356
|
+
'/messages/:id': { params: ownThread }, // computed in the load's own request, as its actor
|
|
357
|
+
'/oauth/consent': { search: consentQuery }, // the query string a load reads off `url`
|
|
358
|
+
'/about': { empty: 'renders a static page: no row' },
|
|
359
|
+
'/admin': { off: 'measured by its own e2e test' },
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
);
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
`params`, `search` and an `actor` function run inside the load's request before the observed call,
|
|
366
|
+
so their statements are never the load's; a function that throws leaves the load `unreached` with
|
|
367
|
+
`its exercise.ts <field> threw`. `statements: { max, why }` moves its ceiling. A blank `off`, `empty`
|
|
368
|
+
or `why` is `X_CONTRACT_EXERCISE_UNDECLARED`; a pattern no route with a `load` has is
|
|
369
|
+
`X_DECLARATION_UNKNOWN` before a row is written. A load that reads the app's own typed client
|
|
370
|
+
(`queries.orgPosts(…)` over `APP_URL`) is answered **in process** by the app's API, as the actor the
|
|
371
|
+
load runs as — `APP_URL` is set to `http://localhost:3000` when the env names none — so its
|
|
372
|
+
statements are counted and swept like the page's own. A route load reached with no statement and no
|
|
373
|
+
effect is its own `· X_EXERCISE_EMPTY_REACH` line, its fix the `empty` entry to paste; a primitive's
|
|
374
|
+
entry takes `empty: '<why>'` too, and a record whose entry gives one carries it as `empty`.
|
|
375
|
+
|
|
376
|
+
**Push is an effect** (`As of 2026-11-15`). Every actor holds one stand-in Web Push device in the
|
|
377
|
+
pass, as the memory mail driver accepts every address, so a notifier's `webPush()` encrypts, signs
|
|
378
|
+
and sends to the captured push service, and the record carries `{ kind: 'push', host, count }`. A
|
|
379
|
+
pusher that sends nothing leaves no effect: its job is an empty reach, not a delivered push.
|
|
380
|
+
|
|
381
|
+
**A storage write is an effect** (`As of 2026-11-15`). An object the call puts, copies or deletes
|
|
382
|
+
through a `defineStorage` disk is `{ kind: 'storage', disk, op, count }` on its record, so an upload
|
|
383
|
+
or export that stores only an object is no empty reach. A read is none, nor is a write the driver
|
|
384
|
+
refused. A multipart session (`grantMultipart`, `abortUpload`) is not counted yet: its calls are not
|
|
385
|
+
on the event bus.
|
|
386
|
+
|
|
387
|
+
**`--shard i/n`** (`As of 2026-11-15`) runs the i-th of n disjoint slices of the pass — primitives,
|
|
388
|
+
then routes, by their position in the registry — on its own scratch database, and writes
|
|
389
|
+
`.x/exercise.<i>-of-<n>.json` (never `.x/exercise.json`). Run the n slices as n processes. Each
|
|
390
|
+
slice's findings are its own; the static findings and the subject proof are slice 1's; the whole-pass
|
|
391
|
+
floor (`unprovenMax`, its warning line) is judged only unsharded. Beside a `<name>`, or not i/n,
|
|
392
|
+
`X_VERIFY_SHARD_INVALID`, fix `x exercise --shard 1/2 --json`.
|
|
393
|
+
|
|
394
|
+
Errors: `X_CONTRACT_EXERCISE_UNREACHED`, `X_CONTRACT_EXERCISE_UNDECLARED`, `X_DECLARATION_UNKNOWN`, `X_CLI_BAD_FLAG`, `X_EXERCISE_UNPROVEN_ABOVE_FLOOR`, `X_EXERCISE_SEED_FAILED`, `X_STATEMENTS_OVER_BUDGET`; warning lines only: `X_EXERCISE_EMPTY_REACH`.
|
|
395
|
+
|
|
396
|
+
## x drill
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
x drill [<name>] [--list] [--budget-ms n] [--json]
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
The app run through its dependencies failing, `As of 2026-11-06`. Each drill boots a fleet on a
|
|
403
|
+
scratch database made on `TEST_DATABASE_URL` and dropped after: `ROLE=migrate`, then `web` and
|
|
404
|
+
`worker` as separate processes (`apps/web/server.ts`), each dialling Postgres, and Redis or NATS
|
|
405
|
+
where the app declares them, through a Bun TCP fault proxy; `nats-down` adds the `sync` role and a
|
|
406
|
+
sync client that dials it. Load runs before, through and after the fault over the site's
|
|
407
|
+
parameterless pages and every action an anonymous POST reaches, each request a fresh input drawn
|
|
408
|
+
as `x exercise` draws one (`apps/web/exercise.ts` honoured; `data.skippedWrites` names every action
|
|
409
|
+
left out and why) — the writes are how a job reaches the queue for the worker drills. `/readyz` is
|
|
410
|
+
sampled throughout.
|
|
411
|
+
|
|
412
|
+
| Drill | Fault | Must hold |
|
|
413
|
+
|---|---|---|
|
|
414
|
+
| `pg-blackhole` | live sockets unanswered, server healthy | `requests-coded`, `requests-bounded`, `recovers`, `jobs-once` |
|
|
415
|
+
| `pg-slow` | every byte delayed half the deadline | `requests-coded`, `requests-bounded`, `recovers` |
|
|
416
|
+
| `pg-restart` | `reset`, then `refuse`, then `pass` | `requests-coded`, `readyz-flips`, `recovers`, `jobs-once` |
|
|
417
|
+
| `redis-down` | the cache tier blackholed | `requests-coded`, `requests-prompt`, `requests-ok`, `recovers` |
|
|
418
|
+
| `nats-down` | the bus refused | `requests-coded`, `recovers`, `sync-resumes` |
|
|
419
|
+
| `worker-sigkill` | `SIGKILL` the worker, then a fresh one | `jobs-terminal`, `jobs-once`, `requests-coded` |
|
|
420
|
+
| `worker-sigterm` | `SIGTERM` the worker, then a fresh one | `role-exits`, `jobs-terminal`, `jobs-once` |
|
|
421
|
+
| `web-sigterm` | `SIGTERM` the web role under load | `requests-ok`, `role-exits` |
|
|
422
|
+
| `roll-before-migrate` | the roles started before `ROLE=migrate`, on a schema stamped by an older build | `roles-wait`, `serves-after-migrate`, `one-wait-line` |
|
|
423
|
+
|
|
424
|
+
`roll-before-migrate`, `As of 2026-11-15`, is the rollout order a deploy cannot always hold: no
|
|
425
|
+
fault and no load. The scratch database is migrated, its framework stamp (`x_jobs`' table comment)
|
|
426
|
+
is rewound to name only an older build, then `web`, `worker` and `scheduler` start on it without
|
|
427
|
+
waiting for readiness, with `sync` when `TEST_NATS_URL` is set and `replicator` when
|
|
428
|
+
`TEST_REPLICATION_URL` names a logical server (the scratch database then lives there) and the app
|
|
429
|
+
has an entity on a table. A role left out is in `data.rolesNotPlayed[]`, `{ drill, role, needs }`. Once each has logged its wait (or exited), they are held 3 s and
|
|
430
|
+
`ROLE=migrate` runs again. Each must stay up (`roles-wait`: an exit is a crash-loop), log exactly
|
|
431
|
+
one line naming `X_FRAMEWORK_SCHEMA_UNAPPLIED` (`one-wait-line`), and answer `/readyz` 200 once
|
|
432
|
+
migrate has run (`serves-after-migrate`). `ULTIMATE_SCHEMA_WAIT_MS` is inherited: `0` — refuse at
|
|
433
|
+
once — turns it red. Its evidence is `evidence.rollout.roles[]`, each
|
|
434
|
+
`{ role, exit, ready, waitLines, logTail }`.
|
|
435
|
+
|
|
436
|
+
Thresholds come from the app: the request deadline (`@ultimat3/http`'s default, 30 s, because
|
|
437
|
+
`configureHttp` is runtime code the CLI does not run), `drain.deadlineMs` plus
|
|
438
|
+
`drain.readinessGraceMs`, and `health.readiness` — under `'process'`, `readyz-flips` expects 200
|
|
439
|
+
throughout. `--budget-ms` replaces the deadline the verdict judges against, not the app's, and is
|
|
440
|
+
printed in `data.budgets.override`. An answer may reach the load up to 500 ms past the deadline
|
|
441
|
+
(`DRILL_ANSWER_SLACK_MS`: the 504 a deadline fires arrives a beat after it). A 5xx with no `X_*`
|
|
442
|
+
code, or `X_INTERNAL`, is always red. A property with no evidence is red, never passed: a job
|
|
443
|
+
property is red when no job ran during the drill, `sync-resumes` when no sync client ran.
|
|
444
|
+
|
|
445
|
+
A service the app uses must be up for every drill; an unset one is refused, never skipped. A named
|
|
446
|
+
drill that faults a service the app does not declare is refused; a whole run lists it under
|
|
447
|
+
`data.notRun`. `--list` prints the table and runs nothing. `--json`: `{ budgets, targets,
|
|
448
|
+
skippedWrites, drills[], notRun, rolesNotPlayed }`, each drill `{ name, verdict, evidence, budgets, baseline }`.
|
|
449
|
+
|
|
450
|
+
Errors: `X_DRILL_FAILED` (one per property that did not hold), `X_DRILL_SERVICE_MISSING`, `X_CLI_UNKNOWN_COMMAND`, `X_CLI_BAD_FLAG`.
|
|
451
|
+
|
|
452
|
+
## x test
|
|
453
|
+
|
|
454
|
+
```bash
|
|
455
|
+
x test [unit|contract|live|job|e2e|eval] [--filter path[,path…]] [--allow-empty] [--sample N]
|
|
456
|
+
[--affected [--base <ref>] [--dirty]] [--workers N] [--seed N] [--json]
|
|
457
|
+
[-- <bun test flags>]
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
| Flag | Type | Default | Meaning |
|
|
461
|
+
|---|---|---|---|
|
|
462
|
+
| *(positional)* | test type | every type | one of the six; a test's type is its filename suffix |
|
|
463
|
+
| `--filter` | string | — | only files whose path contains this substring — or ANY of several, comma-separated (`--filter apps/web/app/billing/,apps/web/app/case/`), in one run. An empty item (`a,,b`) is refused: `''` matches every path |
|
|
464
|
+
| `--allow-empty` | boolean | off | a selection that matches no test file exits **0**, spawns nothing, and says so (`no test file matches … — 0 test file(s) ran`, `data.files: 0`, `data.empty: true`) instead of `X_TEST_NO_FILES`. For a runner that computes the selection; a hand-typed typo stays red without it |
|
|
465
|
+
| `--sample` | string | — | run at most N files of the selection, deterministically. A fast signal for the eval loop — **never a gate** |
|
|
466
|
+
| `--workers` | string | one per 1.25 GiB of a `max(2.75 GiB, 25% of RAM)` budget, at most one per core (the gate's width) | worker count, 1 to 64; each worker gets its own template-cloned database |
|
|
467
|
+
| `--affected` | boolean | off | narrow the selection to the tests the diff can break: in an app root, by import closure (the files `x affected` reports as `data.tests`); elsewhere, the workspaces the diff touches and everything that depends on them. `--base`/`--dirty` without it are refused, not ignored |
|
|
468
|
+
| `--base` | string | `origin/HEAD`'s branch | the ref to diff against, merge-base (`<base>...HEAD`). Unset: `origin/HEAD`'s target, else `origin/main`, else local `main` — `x affected`'s default. Needs `--affected` |
|
|
469
|
+
| `--dirty` | boolean | off | union the working tree in — uncommitted and untracked. Needs `--affected` |
|
|
470
|
+
| `--seed` | string | — | replay one `simulateJobs` seed, the `N` an `X_JOB_SIM_INVARIANT` names: handed to every `bun test` child as `ULTIMATE_JOB_SIM_SEED`, which runs that seed alone. A uint32, else `X_CLI_BAD_FLAG`. The shard reproduce line does not carry it yet |
|
|
471
|
+
| `-- <args>` | tail | — | handed to `bun test` verbatim, before the file list — `x test unit -- --coverage --bail`. The reproduce line carries it back. **`x test` is the only command that reads a `--` tail**: every other one refuses it (`X_CLI_BAD_FLAG`) rather than dropping it, which is what all of them did until 2026-09 |
|
|
472
|
+
|
|
473
|
+
The type rule is `x verify`'s, not a second one — so `x test contract` runs exactly what the gate's `contract` step runs. A selection that matches no files is `X_TEST_NO_FILES` (green with `--allow-empty`); an unknown type is `X_CLI_BAD_FLAG` naming the six and suggesting the nearest.
|
|
474
|
+
|
|
475
|
+
**Exit codes, `As of 2026-11-19`.** `0`: at least one test ran and none failed. `1`: a test failed — `X_TEST_FAILED`, its cause naming the failing files (up to 5) and its fix rerunning the first one alone (`x test <type> --filter <file> --workers 1`; the whole reproduce line only when bun named no file; `data.reproduce` unchanged). **`1` too when every test the run selected skipped itself** (`ran 0`, `skipped N`): `bun test` exits 0 there, but nothing was checked. The summary reads `live — 0 test(s) ran: all 1 skipped themselves, so nothing was checked`; the finding is `X_TEST_FAILED`, its cause naming any unset `TEST_DATABASE_URL`, `TEST_REDIS_URL` or `TEST_NATS_URL` and its fix starting the test services, then the same selection — or, with nothing unset, a `grep -nE 'skip|needs:'` over the files. `x verify` is unaffected: its steps do not go through this verdict.
|
|
476
|
+
|
|
477
|
+
**In an app root `--affected` narrows by import closure, `As of 2026-11`** — every slice shares the `apps/web` workspace, so the workspace answer ran the whole app. The rule is `x affected`'s `data.tests`, never a second one: a test runs when its imports reach a changed file, transitively; a changed file the import graph cannot speak for (`app.config.ts`, `package.json`, a catalog, anything outside the app) runs every test; a discovered test outside the scanned globs always runs. `data.affected.tests` carries `{ app, all, reason, forcing, files: [{ path, why }] }` — `reason` is `closure: N changed file(s)` or `all: <forcing files>`, `why` is `closure`, `all` or `unmapped`. Outside an app root, `data.affected` has no `tests` and the workspace scope is unchanged.
|
|
478
|
+
|
|
479
|
+
`--affected` narrows the FEEDBACK, never the gate. The GATE stays un-narrowable — `x verify` with no flag is the gate, and `x verify --only <step>` announces `NOT A GATE RUN` in both renderers precisely so a narrowed run can never be read as one — because a gate that can be scoped is a gate that can be scoped wrong. Nothing affected is **green with zero spawns**, not a failure: editing a `.md` should not fail a build. A failure's `fix:` carries `--affected --base <ref>` back with it, because `--affected` decides which files exist to run at all and a rerun without it selects the whole corpus.
|
|
480
|
+
|
|
481
|
+
**The inner loop in this repository is `bun run test:affected`, `As of 2026-11-07`** — `x test --affected --base origin/main --dirty` from the root: the workspaces the branch and the working tree touch, plus every workspace that depends on one; a changed file no workspace owns (`package.json`, `bun.lock`, `tsconfig*.json`, `biome.json`, `scripts/**`, the test preload) runs everything, and `.md` alone runs nothing. `bun run test` is `x test` over the whole corpus — the same passes and width as the gate's test steps. Neither is the gate: CI and `x verify merge` run full `x verify`.
|
|
482
|
+
|
|
483
|
+
**A selection that mixes serial files with the rest is more than one run, `As of 2026-09`.** `--parallel=N` is the width of the WHOLE `bun test`, so the bare `x test --workers 8` — which selects every type — ran `live` and `e2e` eight at a time beside the unit corpus, over the very files `x verify` runs one at a time. The files are partitioned by type: one pass at the requested width for everything that may share a pool, then one pass at `--parallel=1` per serial type, each reproducible on its own (`x test live --workers 1`). `--json` carries a `passes` array when there was more than one.
|
|
484
|
+
|
|
485
|
+
## x clean
|
|
486
|
+
|
|
487
|
+
```bash
|
|
488
|
+
x clean [--dry-run] [--services] [--json]
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
Every test leftover the framework knows of, cleared (`As of 27.3.0`): the migrated test-database templates under `.x/test-db`, the whole `.x/cache`, any `.x` folder below the app root, and — with `TEST_DATABASE_URL` set — every probe database whose run is over. `--dry-run` names them and removes nothing; `--json` carries `data.paths` and `data.databases`. Never touched: `.x/pgdata` (the dev database), `.x/storage`, the build output. The test runner sweeps the same set before every run, keeping the newest two of each cache, so `x clean` is for reclaiming the rest by hand. [Testing](Testing#database-state-and-what-a-run-leaves-behind) has the table.
|
|
492
|
+
|
|
493
|
+
**`--services`** (`As of 2026-11-18`) also runs `docker compose -f docker/docker-compose.test.yml down --volumes` for this checkout's stack. A stack another existing checkout started is kept, with the line that stops it. Every other test stack on the machine is listed, never touched. `--dry-run` stops nothing. `--json`: `data.services` with `action` (`stopped`, `would-stop`, `kept`, `none`, `failed`), `project`, `services`, `owner`, and `others[]` (`project`, `status`, `root`, `gone`). Docker failing is `X_TEST_SERVICES_UNAVAILABLE`, exit 1.
|
|
494
|
+
|
|
495
|
+
## x affected
|
|
496
|
+
|
|
497
|
+
```bash
|
|
498
|
+
x affected [--base <ref>] [--dirty] [--paths] [--json]
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
| Flag | Type | Default | Meaning |
|
|
502
|
+
|---|---|---|---|
|
|
503
|
+
| `--base` | string | `origin/HEAD`'s branch | the ref to diff against. The diff is `<base>...HEAD` — **three dots**, so it is measured from the merge-base and an unrelated commit on `main` does not widen the answer. Unset, the base is the **remote-tracking** default branch, as already fetched (never fetched for you): `origin/HEAD`'s target, else `origin/main`, else local `main` when there is no remote-tracking ref (`origin/HEAD` or `origin/main`) (`As of 31.1`). `data.base` names the ref used |
|
|
504
|
+
| `--dirty` | boolean | off | union the working tree in: uncommitted changes plus untracked files |
|
|
505
|
+
| `--paths` | boolean | off | stdout is the directories alone, one per line — `bun test $(x affected --paths)`; notes and the `✓` summary go to stderr (`As of 31.1`). Under `--json` stdout stays the one document, and `data` is byte-identical either way |
|
|
506
|
+
|
|
507
|
+
**Transitive, or it is worse than nothing.** `A → B → C` means a change in `C` must reach `A`; a single pass over an unordered list reaches only `B`, and a scoped run that misses a transitive dependent is a green checkmark on a broken repo. The graph it walks is the one every workspace's `package.json` declares — which is why `package-shape` refuses an undeclared cross-workspace import (`X_WORKSPACE_DEP_UNDECLARED`): an edge missing from a manifest is an edge missing from this answer, silently.
|
|
508
|
+
|
|
509
|
+
Three rules the set obeys:
|
|
510
|
+
|
|
511
|
+
| Change | Affected |
|
|
512
|
+
|---|---|
|
|
513
|
+
| any non-doc file no workspace owns — `tsconfig.json`, `tsconfig.base.json`, `biome.json`, `bun.lock`, root `package.json`, `app.config.ts`, `scripts/**`, `guards/**` | **every** workspace, and the root itself: `x test --affected` runs every test file, those under no workspace included. Decided by ownership, never by a list of names |
|
|
514
|
+
| a workspace's own `package.json` | that workspace only |
|
|
515
|
+
| a `.md` | nothing. A doc has no compilation unit to re-check |
|
|
516
|
+
|
|
517
|
+
**Why the default base is `origin/main`, not `main`.** Local `main` moves only on a pull, so in a checkout nobody pulls — or a worktree — it lags origin, and `main...HEAD` counts every file origin merged since as this branch's work. `origin/main` moves on any `git fetch`. `x verify --changed` and `x test --affected` read the same default.
|
|
518
|
+
|
|
519
|
+
**`--base` is the default and `--dirty` is opt-in, which is the reverse of the obvious design.** This repo runs several agents concurrently in **one checkout** (no worktrees), so a working-tree diff returns every agent's uncommitted work at once and the "affected" set quietly expands to nearly the whole monorepo — narrowing nothing while reading as though it did. A ref diff is stable under that. `--dirty` is the right answer for one developer iterating alone.
|
|
520
|
+
|
|
521
|
+
**Typecheck is deliberately not scoped.** `bun run typecheck` is `tsc -b`, a project build over a shared `.tsbuildinfo`, so a "scoped" typecheck is either the whole project anyway or a weaker check. The time is in the tests, which is what `x test --affected` narrows.
|
|
522
|
+
|
|
523
|
+
## x policy
|
|
524
|
+
|
|
525
|
+
```bash
|
|
526
|
+
x policy [list|explain <subject> [--input '<json>']] [--json]
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
| Subcommand | Does |
|
|
530
|
+
|---|---|
|
|
531
|
+
| `list` | every permission, the roles that grant it, and the actions and queries that enforce it — plus the permissions **nothing** enforces, which are grants that do nothing |
|
|
532
|
+
| `explain <subject>` | one row per actor per declaration — every declared role plus `anonymous`, for each action or query that enforces the subject — naming the clause that decided and its reason. Verdict `allow`, `deny`, or `needs input` |
|
|
533
|
+
|
|
534
|
+
| Flag | Does |
|
|
535
|
+
|---|---|
|
|
536
|
+
| `--input '<json>'` | `explain` only: the request's input, as one JSON argument. A predicate that reads input is decided on it. Not JSON is `X_CLI_BAD_FLAG`, reported by length; the value is never echoed back |
|
|
537
|
+
|
|
538
|
+
`<subject>` resolves in order against a permission (`post:publish`), an action name (`publishPost`), a query name (`postFeed`), then an action's HTTP path (`/api/posts/publish`) — so the `fix:` line printed by an `X_FORBIDDEN` is runnable whichever of the four the throwing surface had to hand.
|
|
539
|
+
|
|
540
|
+
```bash
|
|
541
|
+
$ x policy explain closeTicket
|
|
542
|
+
action closeTicket — policy ticket:write
|
|
543
|
+
actor verdict deciding reason
|
|
544
|
+
anonymous deny ticket:write no actor for ticket:write
|
|
545
|
+
admin needs input ticket:write not denied — every actor-only clause passes, and ticket:write has a predicate that reads the request input
|
|
546
|
+
viewer deny ticket:write actor lacks ticket:write
|
|
547
|
+
evaluated with no request input and no row — a rule reading either decides again on the real request
|
|
548
|
+
✓ closeTicket — allowed for 0 of 3 actor evaluation(s); 1 not denied, decided by a predicate that reads the request input — x policy explain closeTicket --input '<the request input as JSON>'
|
|
549
|
+
|
|
550
|
+
$ x policy explain closeTicket --input '{"orgId":"0190…","ticketId":"0190…"}'
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
The verdict comes from `@ultimat3/policy`'s own `policyMatrix()` over the app's real `Policy` objects — the same evaluation the request path runs, never a second one. With no `--input` there is no request to read, so a predicate that reads one is **not decided**: the row says `needs input` (`verdict: "needs-input"`, `allowed: null` in `--json`, counted in `data.pending`), never `deny` (`As of 2026-11-19`). Reading is detected, not assumed: the predicate runs over a stand-in input that records being read, so one reading only the actor (`({ actor }) => …`) still decides. `deny` means what it says — no actor, no grant, or an actor-only predicate that refused. A row-level rule is evaluated with no row and decides again on the real request (`row?.ownerId === actor.id` still reads `deny` under that note). The actors carry no `orgId`, so an org-scoped predicate compares against `undefined` even with `--input`. With `--input`, a policy that throws on it (a field the JSON does not carry) reports `decidable: false` and a note in place of the table, never a table of invented denials.
|
|
554
|
+
|
|
555
|
+
Errors: `X_DECLARATION_UNKNOWN`, `X_CLI_BAD_FLAG`.
|
|
556
|
+
|
|
557
|
+
## x i18n
|
|
558
|
+
|
|
559
|
+
```bash
|
|
560
|
+
x i18n [check|add <locale>|sync <locale>|split [<locale>]] [--json]
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
| Subcommand | Does |
|
|
564
|
+
|---|---|
|
|
565
|
+
| `check` | scan every `t('…')` in the app's source, audit it against every catalog on disk, and **fail** on a missing key |
|
|
566
|
+
| `add <locale>` | write `packages/i18n/catalogs/<locale>.json` (a directory when the default locale is split) seeded with the default locale's keys and values |
|
|
567
|
+
| `sync <locale>` | add the keys that locale is missing (into its namespace file when split); a key it already has is never overwritten, translated or not |
|
|
568
|
+
| `split [<locale>]` | move flat catalogs into `catalogs/<locale>/<namespace>.json` plus a generated `index.ts`; lossless, idempotent ([I18n](I18n#split-catalogs)) |
|
|
569
|
+
|
|
570
|
+
Catalogs are one file per locale under `packages/i18n/catalogs/`, or one directory per locale of namespace files ([I18n](I18n#split-catalogs)). `check` reports three things separately: `missing` (a gap, and an exit code), `unused` (defined and never called), and `dynamic` — a `t(`plans.${plan}.name`)` the extractor cannot resolve. A dynamic call contributes its static head as a runtime-key prefix, so a key only ever reached that way is never listed unused; an expression with no static head contributes nothing, because a guessed prefix would suppress real gaps.
|
|
571
|
+
|
|
572
|
+
Errors: `X_CATALOG_MISSING_KEYS` (per locale, as a finding), `X_I18N_FAMILY_INCOMPLETE` (a `_select_`/`_ordinal_` family with no `_other`), `X_CATALOG_INVALID`, `X_CATALOG_LAYOUT_MIXED` (`<locale>.json` beside `<locale>/`), `X_CATALOG_KEY_DUPLICATE` (one key in two namespace files), `X_GENERATE_CONFLICT` (`add` over an existing catalog), `X_CLI_BAD_FLAG`, `X_SCAFFOLD_PATH_ESCAPE`.
|