@ultimat3/cli 31.16.0 → 31.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +11 -2
  2. package/package.json +29 -29
  3. package/src/cache-graph.ts +67 -0
  4. package/src/cmd-cache-spec.ts +25 -0
  5. package/src/cmd-cache.ts +187 -0
  6. package/src/cmd-config-spec.ts +23 -0
  7. package/src/cmd-config.ts +61 -0
  8. package/src/cmd-doctor.ts +3 -3
  9. package/src/cmd-exercise.ts +34 -10
  10. package/src/cmd-explain-spec.ts +24 -0
  11. package/src/cmd-explain.ts +201 -0
  12. package/src/cmd-generate-spec.ts +3 -3
  13. package/src/cmd-generate.ts +2 -2
  14. package/src/cmd-logs-spec.ts +34 -0
  15. package/src/cmd-logs.ts +80 -0
  16. package/src/cmd-planned.ts +15 -29
  17. package/src/cmd-token-spec.ts +54 -0
  18. package/src/cmd-token.ts +173 -0
  19. package/src/cmd-verify-spec.ts +13 -3
  20. package/src/cmd-verify.ts +2 -0
  21. package/src/config-redact.ts +39 -0
  22. package/src/dev-boot-data-dir.ts +69 -0
  23. package/src/dev-boot.ts +26 -13
  24. package/src/doctor-chart-alerts.ts +50 -22
  25. package/src/error-codes-tooling.ts +6 -4
  26. package/src/error-codes.ts +2 -0
  27. package/src/errors.ts +8 -2
  28. package/src/exercise-entry-edit.ts +5 -1
  29. package/src/exercise-routes.ts +59 -0
  30. package/src/explain-capture.ts +38 -0
  31. package/src/generate-chart-alerts.ts +99 -45
  32. package/src/generate-exercise.ts +2 -2
  33. package/src/generate-factories.ts +133 -0
  34. package/src/generate-files.ts +15 -0
  35. package/src/generate-kinds.ts +15 -0
  36. package/src/mcp-db-target.ts +4 -3
  37. package/src/mcp-errors.ts +4 -0
  38. package/src/messages-gate.ts +2 -0
  39. package/src/messages-ops.ts +32 -0
  40. package/src/messages-upgrade.ts +1 -0
  41. package/src/messages.ts +4 -0
  42. package/src/otlp-export.ts +16 -2
  43. package/src/registry.ts +10 -0
  44. package/src/role-start.ts +11 -5
  45. package/src/runtime-services.ts +35 -19
  46. package/src/serve-boot-phases.ts +30 -0
  47. package/src/serve-boot-warnings.ts +62 -0
  48. package/src/serve-boot.ts +30 -11
  49. package/src/templates/chart-dashboard.ts +245 -0
  50. package/src/templates/generate-cron-job.ts +90 -0
  51. package/src/templates/generate-purge.ts +93 -0
  52. package/src/templates/generate-webhook-receiver.ts +274 -0
  53. package/src/templates/github/ci.yml.ts +101 -36
  54. package/src/templates/guard-repo-raw-sql-test.ts +174 -0
  55. package/src/templates/guard-repo-raw-sql.ts +115 -145
  56. package/src/templates/guard-unbounded-fanout.ts +170 -0
  57. package/src/templates/scaffold-claude-commands.ts +3 -2
  58. package/src/templates/scaffold-docs.ts +3 -2
  59. package/src/templates/scaffold-guards.ts +3 -0
  60. package/src/templates/scaffold-helm-alert-rules.ts +160 -0
  61. package/src/templates/scaffold-helm-alerts.ts +22 -87
  62. package/src/templates/scaffold-helm-templates.ts +2 -0
  63. package/src/templates/scaffold-helm.ts +20 -4
  64. package/src/upgrade-gate.ts +18 -6
  65. package/src/upgrade-report.ts +4 -0
  66. package/src/verify-plan.ts +127 -0
  67. package/wiki/Admin-Dashboard.md +6 -2
  68. package/wiki/CI-Parallel-Gate.md +38 -1
  69. package/wiki/CLI-Reference.md +95 -14
  70. package/wiki/Caching-And-Invalidation.md +10 -10
  71. package/wiki/Configuration.md +4 -2
  72. package/wiki/Known-Gaps.md +1 -1
  73. package/wiki/MCP-And-AI.md +1 -1
  74. package/wiki/Observability.md +6 -1
  75. package/wiki/Testing.md +64 -0
  76. package/wiki/Troubleshooting.md +3 -2
  77. package/wiki/Upgrading.md +10 -0
@@ -42,6 +42,7 @@ const GUARD_DIFFERS = t.object({ name: t.string, refresh: t.string });
42
42
  const DOCTOR = t.object({
43
43
  data: t.optional(
44
44
  t.object({
45
+ warnings: t.optional(t.array(FINDING)),
45
46
  guards: t.optional(
46
47
  t.object({
47
48
  missing: t.optional(t.array(GUARD_MISSING)),
@@ -81,6 +82,7 @@ interface VerifyDocument {
81
82
 
82
83
  interface DoctorDocument {
83
84
  readonly data?: {
85
+ readonly warnings?: readonly RawFinding[];
84
86
  readonly guards?: {
85
87
  readonly missing?: readonly { readonly name: string; readonly add: string }[];
86
88
  readonly differs?: readonly { readonly name: string; readonly refresh: string }[];
@@ -114,6 +116,11 @@ export interface HopExercise {
114
116
 
115
117
  export interface HopGate {
116
118
  readonly manifest: { readonly ok: boolean; readonly findings: readonly GateFinding[] };
119
+ /**
120
+ * The installed `x doctor`'s `data.warnings[]`: never red on this major, the next one's red —
121
+ * said by the hop that installed the doctor saying them (`X_VERIFY_STEP_UNFLOORED` among them).
122
+ */
123
+ readonly doctorWarnings: readonly GateFinding[];
117
124
  readonly guards: HopGuards;
118
125
  /** The coverage floor a Bun-floor hop moved to what it measured; null when none moved. */
119
126
  readonly coverage: HopCoverage | null;
@@ -193,11 +200,14 @@ const readExercise = (result: ExecResult): HopExercise => {
193
200
  return { reported: true, ok: result.ok && document.ok, findings: flatten(document) };
194
201
  };
195
202
 
196
- /** A doctor that exits red is normal (a port, an env key); only its listing is read here. */
197
- const readGuards = (result: ExecResult): HopGuards => {
203
+ /** A doctor that exits red is normal (a port, an env key); its listing and warnings are read. */
204
+ const readDoctor = (result: ExecResult): DoctorDocument['data'] => {
198
205
  const parsed = DOCTOR.safeParse(documentIn(result.stdout));
199
- const guards =
200
- parsed.issues === undefined ? (parsed.value as DoctorDocument).data?.guards : undefined;
206
+ return parsed.issues === undefined ? (parsed.value as DoctorDocument).data : undefined;
207
+ };
208
+
209
+ const readGuards = (doctor: DoctorDocument['data']): HopGuards => {
210
+ const guards = doctor?.guards;
201
211
  if (guards === undefined) {
202
212
  return { reported: false, missing: [], differs: [], installed: [], withheld: [] };
203
213
  }
@@ -230,7 +240,9 @@ export async function runHopGate(input: {
230
240
  onStage('manifest');
231
241
  const manifest = readManifest(await installed(['manifest', '--json']));
232
242
  onStage('doctor');
233
- const listed = readGuards(await installed(['doctor', '--json']));
243
+ const doctor = readDoctor(await installed(['doctor', '--json']));
244
+ const doctorWarnings = (doctor?.warnings ?? []).map(pick);
245
+ const listed = readGuards(doctor);
234
246
  let guards = listed;
235
247
  if (listed.missing.length > 0) {
236
248
  onStage('guards');
@@ -256,7 +268,7 @@ export async function runHopGate(input: {
256
268
  const exerciseFloor = await ratchetExerciseFloor(root, stamp);
257
269
  onStage('verify');
258
270
  const verify = readVerify(await installed(['verify', '--json']));
259
- return { manifest, guards, coverage, exercise, exerciseFloor, verify };
271
+ return { manifest, doctorWarnings, guards, coverage, exercise, exerciseFloor, verify };
260
272
  }
261
273
 
262
274
  /** What a repository with no app can still be asked, in the order an author would run them. */
@@ -118,6 +118,9 @@ export const humanLines = (input: {
118
118
  figures: JSON.stringify(gate.exerciseFloor.written),
119
119
  }),
120
120
  ]),
121
+ ...(gate?.doctorWarnings ?? []).map((warning) =>
122
+ msg('cli.upgrade.doctorWarning', { code: warning.code, fix: warning.fix }),
123
+ ),
121
124
  // The exercise's own list first: every fix it has, before the gate's verdict on the same tree.
122
125
  ...findingLines([
123
126
  ...(gate?.exercise.findings ?? []),
@@ -172,6 +175,7 @@ export const report = (input: {
172
175
  guards: gate?.guards ?? null,
173
176
  coverage: gate?.coverage ?? null,
174
177
  manifest: gate?.manifest ?? null,
178
+ doctorWarnings: gate?.doctorWarnings ?? [],
175
179
  exercise: gate?.exercise ?? null,
176
180
  exerciseFloor: gate?.exerciseFloor ?? null,
177
181
  verify: gate?.verify ?? null,
@@ -0,0 +1,127 @@
1
+ // `x verify plan --parts <n> --json`: the gate cut into CI parts, each `x verify --only <steps>
2
+ // [--shard i/n]` on a runner of its own, as one document a workflow's matrix reads by `fromJSON`.
3
+ // Derived from `VERIFY_STEP_NAMES` and `SHARDABLE_STEPS`, so a new step lands in a part without
4
+ // anyone editing a workflow — and `x verify merge` folds the parts back into the one verdict.
5
+
6
+ import { BadFlagError } from './errors';
7
+ import { readIntFlag } from './flag-number';
8
+ import { msg } from './messages';
9
+ import type { CommandResult, JsonValue } from './output';
10
+ import type { ParsedArgs } from './parse';
11
+ import type { VerifyStepName } from './verify-step';
12
+ import { VERIFY_STEP_NAMES } from './verify-step';
13
+
14
+ /**
15
+ * What a part's runner starts before the gate: nothing, the test Postgres alone, or every test
16
+ * service. A level rather than service names — the compose file is the app's, and the workflow that
17
+ * starts it is the one place its names are spelled.
18
+ */
19
+ export type PartNeeds = 'none' | 'database' | 'services';
20
+
21
+ export interface PlanPart {
22
+ /** The matrix row's name: the job's title and its artifact's, unique across the plan. */
23
+ readonly part: string;
24
+ /** In the gate's declared order, as `--only` runs them. */
25
+ readonly only: readonly VerifyStepName[];
26
+ /** `i/n` — absent on a part that runs its steps whole. */
27
+ readonly shard?: string;
28
+ readonly needs: PartNeeds;
29
+ }
30
+
31
+ /**
32
+ * The three groups that are not "everything else". The suites that read the test database split
33
+ * together; `live` alone, one process per runner (`SHARDABLE_STEPS`); `e2e` beside `typecheck`,
34
+ * the two slow unsharded steps, so the cheap static steps finish on a runner of their own.
35
+ */
36
+ const UNIT_STEPS: readonly VerifyStepName[] = ['unit', 'contract', 'job'];
37
+ const LIVE_STEPS: readonly VerifyStepName[] = ['live'];
38
+ const BROWSER_STEPS: readonly VerifyStepName[] = ['typecheck', 'e2e'];
39
+
40
+ /** What `x new` writes into the workflow: one static, one browser, one unit and one live runner. */
41
+ export const DEFAULT_PLAN_PARTS = 4;
42
+ /** Two unsharded parts and at least one shard of each split group: fewer is not this layout. */
43
+ export const MIN_SPLIT_PARTS = 4;
44
+ /** A bound on a typo, not on cost: GitHub caps one matrix at 256 jobs. */
45
+ export const MAX_PLAN_PARTS = 64;
46
+
47
+ const ordered = (steps: readonly VerifyStepName[]): readonly VerifyStepName[] =>
48
+ VERIFY_STEP_NAMES.filter((name) => steps.includes(name));
49
+
50
+ const shards = (
51
+ prefix: string,
52
+ steps: readonly VerifyStepName[],
53
+ total: number,
54
+ needs: PartNeeds,
55
+ ): readonly PlanPart[] =>
56
+ Array.from({ length: total }, (_, at) => ({
57
+ part: `${prefix}-${String(at + 1)}`,
58
+ only: ordered(steps),
59
+ shard: `${String(at + 1)}/${String(total)}`,
60
+ needs,
61
+ }));
62
+
63
+ /**
64
+ * `parts` runners' worth of the gate. One is the whole gate on one runner. From four, the
65
+ * runners past the two unsharded parts split the unit group and `live`, the unit group taking the
66
+ * odd one: it holds the most files. Every step lands in exactly one part or in every shard of one
67
+ * split — the rule `x verify merge` refuses a run by.
68
+ */
69
+ export function verifyPlan(parts: number): readonly PlanPart[] {
70
+ if (parts === 1) return [{ part: 'gate', only: VERIFY_STEP_NAMES, needs: 'services' }];
71
+ const split = parts - 2;
72
+ const grouped = new Set<VerifyStepName>([...UNIT_STEPS, ...LIVE_STEPS, ...BROWSER_STEPS]);
73
+ return [
74
+ ...shards('unit', UNIT_STEPS, Math.ceil(split / 2), 'database'),
75
+ ...shards('live', LIVE_STEPS, Math.floor(split / 2), 'services'),
76
+ { part: 'static', only: VERIFY_STEP_NAMES.filter((name) => !grouped.has(name)), needs: 'none' },
77
+ { part: 'e2e', only: ordered(BROWSER_STEPS), needs: 'database' },
78
+ ];
79
+ }
80
+
81
+ /** `strategy.matrix` as GitHub reads it: `only` comma-joined, `shard` only where there is one. */
82
+ export const planMatrix = (plan: readonly PlanPart[]): { readonly include: JsonValue[] } => ({
83
+ include: plan.map((part) => ({
84
+ part: part.part,
85
+ only: part.only.join(','),
86
+ ...(part.shard === undefined ? {} : { shard: part.shard }),
87
+ needs: part.needs,
88
+ })),
89
+ });
90
+
91
+ /** `--parts`, screened: an integer in range, and never the two counts this layout cannot make. */
92
+ export function readPlanParts(args: ParsedArgs): number {
93
+ const example = `x verify plan --parts ${String(DEFAULT_PLAN_PARTS)} --json`;
94
+ const parts =
95
+ readIntFlag(args, {
96
+ name: 'parts',
97
+ command: 'verify plan',
98
+ min: 1,
99
+ max: MAX_PLAN_PARTS,
100
+ example,
101
+ }) ?? DEFAULT_PLAN_PARTS;
102
+ if (parts > 1 && parts < MIN_SPLIT_PARTS) {
103
+ throw new BadFlagError({
104
+ flag: 'parts',
105
+ command: 'verify plan',
106
+ reason: `${String(parts)} runners cannot hold the static part, the browser part and a shard of each split group (1, or ${String(MIN_SPLIT_PARTS)} to ${String(MAX_PLAN_PARTS)})`,
107
+ fix: example,
108
+ });
109
+ }
110
+ return parts;
111
+ }
112
+
113
+ /** The subcommand's body: pure, so the workflow's matrix and this answer cannot disagree. */
114
+ export function verifyPlanCommand(args: ParsedArgs): CommandResult {
115
+ const parts = readPlanParts(args);
116
+ const plan = verifyPlan(parts);
117
+ return {
118
+ ok: true,
119
+ command: 'verify plan',
120
+ summary: msg('cli.verify.plan', { parts: plan.length, steps: VERIFY_STEP_NAMES.length }),
121
+ data: { parts: plan.length, matrix: planMatrix(plan) },
122
+ lines: plan.map(
123
+ (part) =>
124
+ `${part.part} x verify --only ${part.only.join(',')}${part.shard === undefined ? '' : ` --shard ${part.shard}`} (${part.needs})`,
125
+ ),
126
+ };
127
+ }
@@ -30,7 +30,7 @@ export const admin = defineAdmin({ entities: adminEntitiesOf(db), db });
30
30
  | `/admin/<entity>/<id>` | detail: sections, related lists, row actions, history (`?history=` pages older) | `POST _operation=action` (`input.<field>`) · `_operation=delete` (needs `confirmation`) |
31
31
  | `/admin/<entity>/<id>?action=<name>` | an action's own form, when it declares an `input` schema | posts at the row |
32
32
  | `/admin/<entity>/<id>/edit` | edit form | `POST` → 303 to the row, or 422 |
33
- | `/admin/search?term=` · `/admin/audit` | built-in screens | — |
33
+ | `/admin/search?term=` · `/admin/audit` | built-in screens — search is case-insensitive, at most three text fields per resource, four resources read at a time | — |
34
34
  | `/admin/jobs` · `/admin/jobs/runs` · `/queues` · `/tasks` · `/workers` | the jobs dashboard every admin carries — [below](#the-jobs-dashboard) | row actions and the batch bar, as any resource |
35
35
  | `/admin/<page path>` | a `pages:` entry | — |
36
36
 
@@ -53,6 +53,8 @@ resources: { posts: { count: true } },
53
53
 
54
54
  A count reads no row, so it is not audited. Upgrading from a release that counted every listable resource: add `count: true` to each resource whose tile you want back.
55
55
 
56
+ **`count: 'estimate'`** (`As of 2026-11`) reads the planner's figure (`AdminRepo.approximateCount()`, constant time) instead of a full count. It applies only when the resource declares no `rows` scope (the estimate is a whole-table figure) and the estimate is at least 10,000 rows (`ESTIMATE_COUNT_FLOOR`). The tile then reads `~1,200,000` (`admin.dashboard.records.approximate`). A small or never-analysed table, a row-scoped resource and a tenant-scoped or soft-deleting table the estimate refuses all show the exact `count()`.
57
+
56
58
  ## The list
57
59
 
58
60
  `As of 2026-10`. Everything on a list page is derived from the entity or declared once on the resource.
@@ -65,6 +67,8 @@ A count reads no row, so it is not audited. Upgrading from a release that counte
65
67
  | Computed columns | `columns: { age: { value, render } }` | `render`: `badge`, `relative-time`, `money`, `truncate`, `link`, `json`, or a component |
66
68
  | Row scope | `rows: (actor) => AdminFilter[]` | applied by the list, the search, the detail read, the lookup, the labels and the MCP tools — one declaration, no second copy of the resource for a second audience |
67
69
 
70
+ **Case.** `As of 2026-11`. What an operator types ignores case: the search box, a `contains` filter and a lookup each use the entity's `contains`, a bound `ilike` that a `gin_trgm_ops` index on the column serves. What the app declares does not: a `contains` in `rows` or in a scope's `where` stays exact and case-sensitive (`like`, `caseSensitive: true` on the filter), on the read and on the write. A row scope is authorization, so it never widens. `rows: () => [{ field: 'company', op: 'contains', value: 'Acme' }]` admits `Acme Ltd` and never `acme corp`, however the operator spells a search.
71
+
68
72
  | URL parameter | Means |
69
73
  |---|---|
70
74
  | `?f.<field>=<value>` | the field's default operator (`contains` for text, `eq` otherwise) |
@@ -162,7 +166,7 @@ export const admin = defineAdmin({
162
166
 
163
167
  | URL | Shows | Actions (`job:manage`) |
164
168
  |---|---|---|
165
- | `/admin/jobs` | tiles: ready, running, delayed, suspended, dead, workers, oldest ready (one `stats()`); done vs failed over `?range=1h\|24h\|7d\|30d` from the settle counters; volume, failure rate and mean duration per job name. Re-read every 30 s by a declared `<meta http-equiv="refresh">` | — |
169
+ | `/admin/jobs` | tiles: ready, running, delayed, suspended, dead, workers, oldest ready (one `stats()`); done vs failed over `?range=1h\|24h\|7d\|30d` from the settle counters; volume, failure rate and mean duration per job name — every name's counters in one grouped read (`countersMany`), so the screen costs 4 statements at any number of names. Re-read every 30 s by a declared `<meta http-equiv="refresh">` | — |
166
170
  | `/admin/jobs/runs` | one tab per state; the search box is an id prefix; filters by name, queue, state, tenant, created time | retry (dead rows), retry from a step, run now (waiting on its clock), cancel (live), remove |
167
171
  | `/admin/jobs/runs/<id>` | input (redacted by `@ultimat3/jobs`), steps, error and stack, progress, tenant, trace, history | the row's own |
168
172
  | `/admin/jobs/queues` | depth per state, paused, a link to the queue's jobs | pause, resume |
@@ -80,7 +80,44 @@ slowest part's, which is the wall time CI waited. A part that is not an `x verif
80
80
  document is `X_VERIFY_MERGE_INPUT` — and so is a step whose `durationMs` is not a number or whose
81
81
  `findings` are not each a `code`, `cause` and `fix`.
82
82
 
83
- ## A GitHub Actions workflow
83
+ ## `x verify plan` — the parts, as data
84
+
85
+ `As of 31.17.0`. `x verify plan [--parts n] --json` answers the split instead of a workflow spelling
86
+ it: `data.matrix` is a GitHub `strategy.matrix`, one row per part —
87
+ `{ part, only, shard?, needs }` — derived from `VERIFY_STEP_NAMES`, so a step the gate gains lands in
88
+ a part with no workflow edit. Pure: no file read, nothing started.
89
+
90
+ ```text
91
+ $ x verify plan --parts 4
92
+ unit-1 x verify --only unit,contract,job --shard 1/1 (database)
93
+ live-1 x verify --only live --shard 1/1 (services)
94
+ static x verify --only lint,boundaries,filesize,package-shape,errors,exercise,eval,drift,contract-diff,budgets,seo,i18n,policy,manifest,roadmap (none)
95
+ e2e x verify --only typecheck,e2e (database)
96
+ ```
97
+
98
+ | `--parts` | Layout |
99
+ |---|---|
100
+ | `1` | `gate`: every step on one runner, `needs: services` |
101
+ | `4`–`64` (default `4`) | `static` and `e2e` (`typecheck` + `e2e`, the two slow unsharded steps) whole; the rest of the runners split between shards of `unit,contract,job` and of `live`, the unit group taking the odd one |
102
+ | `2`, `3`, `0`, `65`+ | `X_CLI_BAD_FLAG` — two or three runners cannot hold this layout |
103
+
104
+ `needs` is a level, not service names: `none`, `database` (the test Postgres alone) or `services`
105
+ (every test service) — the compose file is the app's, and the workflow is the one place its names are
106
+ spelled. **`x new`'s `.github/workflows/ci.yml` reads it**: a `plan` job runs
107
+ `bun run verify plan --parts 4 --json` and hands `.data.matrix` to the `gate` job by `fromJSON`;
108
+ each part runs `bun run setup`, starts what its `needs` asks for, runs
109
+ `bun run verify --only "$ONLY" ${SHARD:+--shard "$SHARD"} --json` and uploads the document, red or
110
+ green; `verify` downloads every part and runs `bun run verify merge`. An app scaffolded before 31.17.0
111
+ keeps its one-job workflow, which still works; to adopt, copy a fresh scaffold's
112
+ `.github/workflows/ci.yml`.
113
+
114
+ This repository's own `ci.yml` stays hand-written — it carries services and URLs only the framework
115
+ has — and `verify-plan.test.ts` holds its `gate` matrix to `verifyPlan(7)`: a step added to the gate
116
+ or a part edited out of the matrix is red there before it is `X_VERIFY_MERGE_INCOMPLETE` after a push.
117
+
118
+ ## A GitHub Actions workflow, by hand
119
+
120
+ The same shape with a matrix you write yourself — for a split the plan does not make:
84
121
 
85
122
  ```yaml
86
123
  name: ci
@@ -33,7 +33,7 @@ x version # CLI version
33
33
  | `x stop [--timeout 30s]` | stop this checkout's `x dev` (the pid its `.x/dev.lock` names, nothing else) and return once the next `x dev` can boot | shipped |
34
34
  | `x g <kind> <name>` | scaffold a primitive with its test | shipped |
35
35
  | `x db <sub>` | gen, migrate, reset, seed, studio, branch, backfill, diagnostics | shipped |
36
- | `x verify [--only <step>[,<step>…] [--shard i/n [--timings f]] \| --changed [--base <ref>] [--dirty]] [--workers N] [--isolate]` · `x verify merge <part.json…>` | the gate — 21 steps, in this order: typecheck, lint, boundaries, filesize, package-shape, errors, unit, contract, live, job, exercise, e2e, eval, drift, contract-diff, budgets, seo, i18n, policy, manifest, roadmap. `--only <step>[,<step>…]` runs the named steps, in one process and in gate order, for an iteration loop and announces `NOT A GATE RUN` in the summary and in `--json` (`data.notAGateRun`, `data.only` — always a list), writing no floor file; an unknown name is refused with every valid name and the nearest match. **The gate is this command with no flag.** There is no `--skip` | shipped |
36
+ | `x verify [--only <step>[,<step>…] [--shard i/n [--timings f]] \| --changed [--base <ref>] [--dirty]] [--workers N] [--isolate]` · `x verify merge <part.json…>` · `x verify plan [--parts n]` | the gate — 21 steps, in this order: typecheck, lint, boundaries, filesize, package-shape, errors, unit, contract, live, job, exercise, e2e, eval, drift, contract-diff, budgets, seo, i18n, policy, manifest, roadmap. `--only <step>[,<step>…]` runs the named steps, in one process and in gate order, for an iteration loop and announces `NOT A GATE RUN` in the summary and in `--json` (`data.notAGateRun`, `data.only` — always a list), writing no floor file; an unknown name is refused with every valid name and the nearest match. **The gate is this command with no flag.** There is no `--skip` | shipped |
37
37
  | `x env [check\|example\|init]` | validate the process env against `envSchema`, regenerate `.env.example` from it, or write `.env.production` (`init --production`) | shipped |
38
38
  | `x secrets <sub>` | the committed encrypted secrets file: show, init, edit, set, rotate | shipped |
39
39
  | `x auth seal-mfa` | one-shot: seal every second-factor secret still stored in the clear | shipped |
@@ -66,14 +66,15 @@ x version # CLI version
66
66
  | `x docs "<question>"` | framework docs and this wiki, offline, from the install — the first lookup | shipped |
67
67
  | `x fix boundary <file>` | plan the minimal cut for an import that crossed a surface boundary (never rewrites) | shipped |
68
68
  | `x upgrade` | one major per run: exact pins, the Bun floor, `bun install`, the gate, the section to read | shipped |
69
- | `x cache` | tag graph, bust, clear, stats | planned |
69
+ | `x token create\|list\|revoke` | MCP and API tokens in the app's `x_api_keys`: issue one with exact scopes (plaintext shown once), list an owner's, revoke one · `grant` is **planned** | shipped |
70
+ | `x config show [--section <key>]` | the resolved `app.config.ts`, defaults merged, credentials redacted | shipped |
71
+ | `x logs tail [--lines n] [--role <role>]` | the last lines of `.x/dev.log` or `.x/logs/<role>.log` — the `logs.tail` MCP tool's file and reader | shipped |
72
+ | `x cache graph\|bust <tag>\|clear` | the tag graph off the manifest (what each write evicts), a bust of one tag or every declared tag through the app's own tiers and bus · `stats` is **planned** | shipped |
73
+ | `x explain <query> [--input <json>] [--org <id>]` | one declared query run once on the dev database, every statement it sent planned by the `exercise` step's oracle | shipped |
70
74
  | `x branch` | copy-on-write branch environments | planned |
71
75
  | `x status` | connected-client build-ID distribution, role health | planned |
72
- | `x logs tail` | structured logs + OTel spans | planned |
73
- | `x token` | create and grant MCP scopes | planned |
74
76
  | `x ai` | eval, cache stats, reindex | planned |
75
77
  | `x money add-currency` | extend the currency table | planned |
76
- | `x config show` | the resolved `app.config.ts` | planned |
77
78
 
78
79
  ## x new
79
80
 
@@ -315,11 +316,13 @@ Errors: `X_DEV_STOP_TIMEOUT`, `X_CLI_BAD_FLAG` (a `--timeout` that is not a posi
315
316
 
316
317
  ```bash
317
318
  x g resource|action|mutator|backfill|job|route|policy|entity|query|task <name> [--feature f]
319
+ x g cron-job|purge|webhook-receiver <name> [--feature f] # a primitive factory's one call + tests
318
320
  x g island <name> [--at <dir>] # a client component on an otherwise static page
319
321
  x g admin:page <name> --permission <perm> [--at <dir>] # a custom admin screen, guarded by construction
320
322
  x g guard <name> # a convention this app enforces, as a build error
321
323
  x g sign-in --password | --oidc <provider> # the app's one sign-in: pages, actions, boot guard
322
324
  x g chart-alerts [--print] # the chart's ServiceMonitor + alert rules, backfilled
325
+ x g chart-dashboard [--print] # the chart's Grafana dashboard + its ConfigMap, backfilled
323
326
  x g app <name> # one more app workspace: apps/<name>/
324
327
  x g package <name> # one more shared package: packages/<name>/
325
328
  ```
@@ -337,8 +340,20 @@ The boot guard is generated, app-owned: `apps/web/runtime.ts` calls `assertSignI
337
340
 
338
341
  **`x g chart-alerts`** (`As of 2026-11`) writes the two monitoring templates `x new`'s chart carries into an app chart that predates them — `docker/helm/templates/servicemonitor.yaml` and `alert-rules.yaml`, named after `Chart.yaml`'s `name` — and appends the `serviceMonitor:` / `alerts:` blocks `values.yaml` lacks. Only what is missing: a template already there is kept (`--force` rewrites both), and a values key already there — `enabled: false` included — is never touched; both templates read a missing block as `auto`, rendering only where the cluster serves the Prometheus operator's kinds. A second run writes nothing. No `<name>`, and any other `x g` flag but `--force`/`--dry-run` is `X_CLI_BAD_FLAG`. **`--print`** writes nothing and needs no chart: the same rules as plain Prometheus rule groups, defaults in place, for a loader outside Kubernetes (`--json`: `data.rules`, the YAML text). No `docker/helm/Chart.yaml` is `X_CHART_MISSING`, fix `x g chart-alerts --print --json`. `x doctor` lists the missing templates. The rules: [Observability](Observability).
339
342
 
343
+ **`x g chart-dashboard`** (`As of 2026-11`) is the same backfill for the chart's Grafana dashboard: `docker/helm/dashboards/ultimate-app.json` (one column of panels over the series the framework declares — requests, latency by route, statements, pool, jobs, realtime, the process) and `templates/dashboard-configmap.yaml`, which ships it as a ConfigMap a Grafana sidecar provisions by label — plus the `dashboard:` block `values.yaml` lacks, `enabled: false` (`x new`'s chart writes the same three). The same rules as `chart-alerts`: only what is missing, `--force` rewrites, no `<name>`, `X_CHART_MISSING` with no chart. **`--print`** writes nothing and needs no chart: the dashboard JSON, to import into a Grafana outside Kubernetes (`--json`: `data.dashboard`).
344
+
340
345
  `x g guard <name>` writes `guards/<name>.ts` and its test. A name the framework ships a guard under — `raw-length`, `raw-breakpoint`, `raw-z-index`, `raw-shadow`, `raw-motion`, `undefined-style-class`, `undeclared-custom-property`, `repo-raw-sql` and every other name in `SHIPPED_GUARD_NAMES` (`packages/cli/src/templates/scaffold-guards.ts`) — writes THAT guard, which is how an app adopts one it does not hold; any other name writes the blank template. `x doctor` lists the shipped ones missing, and the held ones that differ from the current template ([Interface rules](Interface-Rules#stylesheets)).
341
346
 
347
+ **`x g cron-job` · `x g purge` · `x g webhook-receiver`** (`As of 31.17.0`) scaffold a primitive *factory*'s one declaration — each a factory over `job()`, never a ninth primitive — with its tests, into the feature's slice, listed in `apps/web/api/index.ts`'s `jobs:`. None reads a table, so a slice with no `entity.ts` is fine.
348
+
349
+ | Generator | Writes | What the declaration holds |
350
+ |---|---|---|
351
+ | `x g cron-job <name>` | `jobs/<name>.ts`, `<name>.job.test.ts`, `<name>.test.ts` | `cronJob({ name, cron: '0 3 * * *', tz: 'UTC', tenant: 'none' })` — the job and its `.schedule` task from one call, an explicit IANA zone, the org stripped so a tenant read fails closed |
352
+ | `x g purge <name>` | `jobs/<name>.ts`, `<name>.job.test.ts`, `<name>.test.ts`, `tasks/<name>-hourly.ts` | `purge({ name, entities: 'declared' })` — the sweep for every `retain` the schema declares (`X_ENTITY_RETAIN_UNSWEPT` without one), fired on `DEFAULT_PURGE_CRON` |
353
+ | `x g webhook-receiver <name>` | `jobs/<name>.ts`, `<name>.test.ts`, and the job's entry in `apps/web/exercise.ts` (a draw cannot sign an event, so `x exercise` queues a verified-shape one) | `webhookReceiver()` at `/hooks/<name>`: the exact bytes `verifyBodyHmac`-checked under `<NAME>_WEBHOOK_SECRET` (comma-separated, so a rotation keeps the old one live), the event read out of the signed body, queued, then acknowledged; an unreadable event is the app's own `X_<NAME>_UNREADABLE` |
354
+
355
+ Every other factory, and why no generator writes it (`exportRows`, `importRows`, `rollup`, `webhook`, `llm`, `agentJob`, …): `FACTORY_GENERATORS` in `packages/cli/src/generate-factories.ts`, held complete against `PRIMITIVE_FACTORIES` by its test.
356
+
342
357
  Alias: `x generate`.
343
358
 
344
359
  `<name>` is one directory segment for every generator but `route`, whose name is its URL:
@@ -357,7 +372,7 @@ is a word (`a-z`, `0-9`, `-`, `_`) or `[param]` / `[...rest]`; `..`, `.` and emp
357
372
  | `--locales` | string | every locale with a catalog in `packages/i18n/catalogs/`, else `en` | comma-separated locales; lands each generator's catalog entry in every one. **Never starts a catalog** in an app that has any: a non-default locale with no `packages/i18n/catalogs/<locale>.json` is `X_CLI_BAD_FLAG`, `fix: x i18n add <locale>`, before a file is planned — a catalog a generator started would hold only its own keys. A non-default locale's new keys land marked `⟦…⟧`, as `x i18n add` seeds them, so `x i18n check` reports them until translated. In an app with no catalogs yet, a first `--locales en,es` writes `en` bare and `es` marked. `As of 2026-10-06` (`localiseCatalogs`, `packages/cli/src/generate-catalog-locales.ts`) |
358
373
  | `--password` | boolean | `false` | `sign-in` only: an address and a password over `login()` |
359
374
  | `--oidc` | string | — | `sign-in` only: an OpenID Connect provider id (`corp-sso`; lowercase, digits, hyphens, not a built-in), discovered from `<PROVIDER>_ISSUER` |
360
- | `--print` | boolean | `false` | `chart-alerts` only: print the alert rules as plain Prometheus rule groups, write nothing. On any other generator it is `X_CLI_BAD_FLAG` |
375
+ | `--print` | boolean | `false` | `chart-alerts` and `chart-dashboard` only: print the alert rules as plain Prometheus rule groups, or the dashboard as Grafana JSON, write nothing. On any other generator it is `X_CLI_BAD_FLAG` |
361
376
  | `--force` | boolean | `false` | overwrite existing files |
362
377
  | `--dry-run` | boolean | `false` | the write plan, nothing written: **every file the run would touch** — the ones it creates (a slice module already on disk is skipped, not listed) and, `As of 27.6.2`, the ones it EDITS outside the slice (role map, typed handle, API index, manifests, catalogs, the i18n index), in the order the run lists them. `--json`: `data.files` is that list, `data.edits` the subset that already exists, `data.refreshes` the committed contracts (`x.manifest.json`, `openapi.json`) a real run re-projects. `ok: false` with every finding the real run would report — an existing file, an API-index binding already held, a grant or a handle entry it cannot place |
363
378
 
@@ -430,6 +445,8 @@ lands in `apps/admin/app/admin/pages/` without `--at` — beside the declaration
430
445
  | `x g action` · `x g mutator` | `<name>.test.ts` **and** `<name>.contract.test.ts` | `unit`, `contract` |
431
446
  | `x g query --live` | `<name>.live.test.ts` | `live` |
432
447
  | `x g job` · `x g task` · `x g backfill` | `<name>.job.test.ts` | `job` |
448
+ | `x g cron-job` · `x g purge` | `<name>.job.test.ts` **and** `<name>.test.ts` | `job`, `unit` |
449
+ | `x g webhook-receiver` | `<name>.test.ts` | `unit` |
433
450
  | `x g query` (not live) · `x g entity` · `x g policy` · `x g route` | `<name>.test.ts` | `unit` |
434
451
 
435
452
  `--force` writes the new name and does not touch a file under the old one, because the old name is not in its output list. Delete the orphan by hand.
@@ -600,8 +617,21 @@ Errors, backfill: `X_BACKFILL_PENDING` (`--pending`, and the only one that is no
600
617
  ```bash
601
618
  x verify [--only <step>[,<step>…] [--shard i/n [--timings file]] | --changed [--base <ref>] [--dirty]] [--workers N] [--isolate] [--json]
602
619
  x verify merge <part.json…> [--json]
620
+ x verify plan [--parts n] [--json]
603
621
  ```
604
622
 
623
+ **`x verify plan`** (`As of 31.17.0`) — the gate cut into CI parts, as data: each part an `x verify
624
+ --only <steps> [--shard i/n]` for one runner, and `data.matrix` a GitHub `strategy.matrix`
625
+ (`{ include: [{ part, only, shard?, needs }] }`) a workflow reads with `fromJSON`. `--parts`: `1`
626
+ (the whole gate on one runner) or `4`–`64`, default `4` — a `static` part (every step that is not a
627
+ suite), an `e2e` part (`typecheck` + `e2e`), and the rest split between shards of `unit,contract,job`
628
+ and of `live`, the unit group taking the odd one. `needs` says what the runner starts first:
629
+ `none`, `database` (the test Postgres) or `services` (every test service). Derived from
630
+ `VERIFY_STEP_NAMES`, so a new gate step lands in a part with no workflow edit, and every step sits in
631
+ exactly one part or every shard of one split — the rule `x verify merge` refuses a run by. `x new`'s
632
+ `.github/workflows/ci.yml` is three jobs: `plan` → one `gate` per part → `verify` (the merge) →
633
+ [CI: the gate across parallel jobs](CI-Parallel-Gate). Pure: it reads no file and starts nothing.
634
+
605
635
  **`--changed`**, `As of 31.0` — the steps whose inputs the diff touches, NOT A GATE RUN like `--only`
606
636
  and never beside it (`X_CLI_BAD_FLAG`). The diff is `x affected`'s: `<base>...HEAD`, `--base` default
607
637
  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
@@ -1217,7 +1247,7 @@ Four warnings about how the app is held, `As of 31.16.0` — beside the verdict,
1217
1247
  | `X_FRAMEWORK_PIN_RANGE` | an `@ultimat3/*` dependency in any of the app's manifests is anything but an exact version or a `workspace:`/`file:`/`link:` path (`^31.0.0`, `*`, `latest`, `>=31 <32`; an `npm:` alias by its own spec), one finding per manifest | the exact version `bun install` resolved, at the line named; then `bun install` |
1218
1248
  | `X_ENV_NAME_RESERVED` | a name the app declares in `envSchema` or seals in `secrets.enc.json` is one `FRAMEWORK_ENV` (`@ultimat3/core`) lists as a `switch` or `internal` name — setting it for the app also switches that package's behaviour. Deploy-contract names (`DATABASE_URL`, `PORT`) and host names are not collisions | rename it `APP_<name>` (or delete it where the value is meant for the framework); then `x env example` |
1219
1249
 
1220
- **The chart's monitoring templates**, the same way (`As of 2026-11`): an app with a `docker/helm/Chart.yaml` and no `templates/servicemonitor.yaml` or `templates/alert-rules.yaml` gets one line per missing file, then `x g chart-alerts`, which writes only those (`--json`: `data.chartAlerts`, `{ missing[], add }`). A chart that dropped them on purpose keeps a green verdict; an app with no chart is listed nothing.
1250
+ **The chart's monitoring templates**, the same way (`As of 2026-11`): an app with a `docker/helm/Chart.yaml` and no `templates/servicemonitor.yaml` or `templates/alert-rules.yaml` gets one line per missing file, then `x g chart-alerts`, which writes only those (`--json`: `data.chartAlerts`, `{ missing[], add }`). The dashboard is its own row: no `dashboards/ultimate-app.json` or `templates/dashboard-configmap.yaml` lists them, then `x g chart-dashboard` (`data.chartDashboard`, the same shape). A chart that dropped them on purpose keeps a green verdict; an app with no chart is listed nothing.
1221
1251
 
1222
1252
  The embedded half is the bare-VM case: the external-database probe answers nothing the moment `DATABASE_URL` is unset, and that silence *is* the configuration a fresh box has. So `x doctor` also asks whether `@electric-sql/pglite` resolves from the app root — a resolve, never an import, because loading it boots the WASM build and takes the single-writer lock the next command needs. Red only where both hold: `DATABASE_URL` unset **and** the peer unresolvable, reported as `X_DB_UNAVAILABLE` with `@ultimat3/db`'s own sentence and its own runnable fix ([Bare VM](Bare-VM)). The snapshot half is `As of 2026-08` and separate from drift on purpose: they are two questions with two remedies, and `x db gen`'s own `X_MIGRATION_SNAPSHOT_MISSING` was a condition this diagnostic could not see at all, so `x doctor --json` — the `fix:` of the `X_CLI_UNEXPECTED` an author reaches it through — ran clean over a broken app.
1223
1253
 
@@ -1409,7 +1439,24 @@ write, and the run stays green; with it, above a declared figure is red.
1409
1439
  | 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 |
1410
1440
  | 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 |
1411
1441
 
1412
- 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`.
1442
+ **Route loads** (`As of 31.17.0`). After the primitives, the pass runs every `app/` and `site/`
1443
+ file route that declares a `load` — the route table `x routes` prints — once in its own seeded
1444
+ tenant, as the runtime calls it: in a request, as the first actor the route's permission allows (a
1445
+ signed-in one where it names none), its params a seeded row's id or the route's own `prerender()`
1446
+ sample. Each load gets the primitives' proofs: its statements counted against the ceiling (100), a
1447
+ scale sweep at 2 and 8 rows a table, and the plan oracle over what it sent. The records ride beside
1448
+ `records`, as `routes[]` in `--json` and `.x/exercise.json` (`{ kind: 'route', name, file, outcome,
1449
+ reason?, statements, effects, ms, statementCeiling?, plans?, scale? }`), and every finding is a
1450
+ **warning line** on `main` — `route /messages (apps/web/app/messages/page.tsx) · X_QUERY_SCALES_WITH_ROWS …`,
1451
+ `· X_STATEMENTS_OVER_BUDGET …`, a plan code, or `· load not exercised: <reason>` — never red: no
1452
+ floor key opts a page read in yet.
1453
+
1454
+ **Reached with nothing to prove** (`As of 31.17.0`): a primitive reached that sent no statement and
1455
+ had no effect has vacuous proofs — a sweep of nothing is `flat`. One warning line names the first
1456
+ five, `X_EXERCISE_EMPTY_REACH … — fix: edit exercise.ts: give each an input that reaches its work, or
1457
+ { off: '<why>' }`. A warning, not red, on a whole-pass run only.
1458
+
1459
+ 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`.
1413
1460
 
1414
1461
  ## x drill
1415
1462
 
@@ -1916,24 +1963,58 @@ For each violation involving the file it reports the offending edge, the full ch
1916
1963
 
1917
1964
  `<file>` is app-root-relative, or any suffix that matches exactly one source file — the short form a `fix:` line emits. Errors: `X_FIX_TARGET_UNKNOWN` (with the nearest real path as its fix), `X_CLI_BAD_FLAG` on an ambiguous suffix.
1918
1965
 
1966
+ ## x token
1967
+
1968
+ `As of 2026-11`. The app's machine credentials — the keys an MCP endpoint's `apiKeyResolver` and the `/v1` mount accept — in the framework's `x_api_keys`, through `@ultimat3/auth`'s `issueApiKey` / `describeApiKey` / `revokeApiKey`. No default subcommand: `create` writes a credential.
1969
+
1970
+ | Subcommand | Does |
1971
+ |---|---|
1972
+ | `create --scopes <a,b> [--user <id>] [--org <id>] [--env dev\|stage\|prod] [--days n]` | issues one key carrying exactly those scopes (a wildcard is `X_CONFIG_INVALID`). `--env` unsaid is the environment's label: `ULTIMATE_ENV` (else `NODE_ENV`) production → `prod`, staging → `stage`, else `dev`; an unreadable `ULTIMATE_ENV` reads as `prod`. `--user` cuts its scopes to what that user may do and stops it when the user is disabled. The plaintext is printed **once** — in the human lines, or `data.token` under `--json` — and never in the summary; only its SHA-256 is stored |
1973
+ | `list --owner <id>` | the keys of a user or org, as `describeApiKey` answers them: no hash, no secret. A key issued with neither is listed by nobody and revoked by its id |
1974
+ | `revoke <id>` | revokes it; an unknown or already-revoked id answers `revoked: false`, exit 0 — neither is a key that works |
1975
+ | `grant` | **planned**: a key's scopes are fixed when issued. Issue a wider one and revoke the old |
1976
+
1977
+ Every flag is read before the database opens: a refusal costs no boot.
1978
+
1979
+ ## x config
1980
+
1981
+ `As of 2026-11`. `x config show [--section <key>]` — `app.config.ts` as the boot reads it: through `loadAppConfig` and core's `defineConfig`, every default merged. A credential-named key (the logger's own rule, `isRedactedKey`), a `secret()` value and the password in a URL's userinfo print as `[redacted]`. `--section` takes a top-level key the resolved record owns; any other is `X_CLI_BAD_FLAG` listing them.
1982
+
1983
+ ## x logs
1984
+
1985
+ `As of 2026-11`. `x logs tail [--lines n] [--role <role>]` — the last `n` lines (default 100, at most 10,000) of `.x/dev.log`, which `x dev` tees, or of `.x/logs/<role>.log`. The same file, path rule and end-first reader as the `logs.tail` MCP tool. A `--role` that is not a runtime role is `X_CLI_BAD_FLAG` before any path is built; no log yet exits `X_NOT_IMPLEMENTED` with `x dev` as the fix.
1986
+
1987
+ ## x cache
1988
+
1989
+ `As of 2026-11`.
1990
+
1991
+ | Subcommand | Does |
1992
+ |---|---|
1993
+ | `graph` (default) | per tag: the actions whose `invalidates` name it, the queries cached under it and the routes revalidated by it, read off the manifest. `data.neverEvicted` lists the tags something reads and no action invalidates — fresh only until their TTL |
1994
+ | `bust <tag>` | boots the app's declared tiers and bus as a role does (`startServices`), then `invalidateTags`: shared tiers dropped, the edge purged, every replica told. With an in-process bus (no `NATS_URL`, no `REDIS_URL`) the summary says no running server heard it. A tier that failed is `X_CACHE_DRIVER_UNAVAILABLE`, exit 1; an undeclared tag is `X_CACHE_TAG_UNKNOWN` |
1995
+ | `clear` | the same bust over every declared tag. An entry cached under no tag waits for its TTL |
1996
+ | `stats` | **planned**: hit rates live in the serving processes — the `/_x` cache panel reads them there |
1997
+
1998
+ ## x explain
1999
+
2000
+ `As of 2026-11`. `x explain <query> [--input '<json>'] [--org <id>]` — the query run once on the app's dev database (rows discarded; its policy is not asked, as `explainQuery`'s is not), every statement it **sent** captured off `db.statement` and planned by `sweepPlans`: the oracle the `exercise` step judges with. A read no declared index serves is `X_QUERY_UNINDEXED` / `X_QUERY_SORT_UNSERVED` with the `indexes:` entry as its fix, exit 1. A query over a tenant-scoped entity needs `--org`, else `X_CLI_BAD_FLAG`. Tables the dev database lacks are listed as not planned — run `x db migrate` first. An external `DATABASE_URL` where `ULTIMATE_ENV` (else `NODE_ENV`) resolves production — or `ULTIMATE_ENV` is unreadable — is refused before anything opens, `X_EXPLAIN_PRODUCTION_DATABASE`: the query would be sent for real with its policy skipped. Plan on the embedded database, or on a staging restore under `ULTIMATE_ENV=staging`.
2001
+
1919
2002
  ## Planned commands
1920
2003
 
1921
2004
  Specified in the design docs, not yet implemented. Every one is in the command registry: calling it exits `X_NOT_IMPLEMENTED` with a `fix:` naming the closest shipped command, because "not built yet" and "not a command" are different facts and only one of them is true.
1922
2005
 
1923
- The table is `PLANNED_COMMANDS` in `packages/cli/src/cmd-planned.ts`; `cmd-planned.test.ts` asserts every row is reachable through the parser and that no `fix` points at another planned command. `PLANNED_SUBCOMMANDS` in the same file is the one-level-down version — a subcommand of a shipped command that this build does not implement: `x db studio` and `x jobs drain`. Each stays in its command's subcommand list, so the parser reaches it and `x help <command>` lists it.
2006
+ The table is `PLANNED_COMMANDS` in `packages/cli/src/cmd-planned.ts`; `cmd-planned.test.ts` asserts every row is reachable through the parser and that no `fix` points at another planned command. `PLANNED_SUBCOMMANDS` in the same file is the one-level-down version — a subcommand of a shipped command that this build does not implement: `x db studio`, `x jobs drain`, `x token grant` and `x cache stats`. Each stays in its command's subcommand list, so the parser reaches it and `x help <command>` lists it.
1924
2007
 
1925
2008
  | Command | Purpose | `fix:` today |
1926
2009
  |---|---|---|
1927
- | `x cache [graph\|bust <tag>\|clear\|stats]` | what a write evicts; targeted eviction | `x dev` — then the cache panel at `/_x` |
1928
2010
  | `x branch [<name>\|delete <name>]` | copy-on-write database + preview URL + scoped MCP socket | `x db branch list --json` — the database half: `list`, `create <name>`, `delete <name>` |
1929
2011
  | `x status` | role health and the build-ID distribution of connected clients | `x doctor --json` |
1930
- | `x logs tail` | structured logs and spans, filterable | `x dev` — then the timeline panel at `/_x` |
1931
- | `x token [create --scopes <s>\|grant <scope>]` | MCP tokens and scopes | `x mcp serve --help` |
1932
2012
  | `x ai [eval <name>\|cache\|reindex]` | eval scores, cache hit rate and tokens saved, vector reindex | `x test eval --json` |
1933
2013
  | `x money add-currency <ISO> --exponent <n>` | extend the currency table | `x errors explain X_CURRENCY_UNKNOWN --json` — extend it in code: `registerCurrency({ code, exponent, name })` from `@ultimat3/money`, once at boot. Shipped `As of 2026-08`, and it is what this command promised |
1934
- | `x config show` | the resolved configuration, defaults included | `x manifest --json` |
1935
2014
 
1936
- **Flags reach the same answer**, `As of 2026-10`: `x money add-currency USD --exponent 2` and `x logs tail --follow --json` exit `X_NOT_IMPLEMENTED` with the row's `fix:`, as the bare form does.
2015
+ **Flags reach the same answer**, `As of 2026-10`: `x money add-currency USD --exponent 2` and `x status --follow --json` exit `X_NOT_IMPLEMENTED` with the row's `fix:`, as the bare form does.
2016
+
2017
+ `x token`, `x config`, `x logs` and `x cache` left this table `As of 2026-11` (plan 101-full-stack-efficiency-sweeps U5); each has its section above.
1937
2018
 
1938
2019
  ## Names that moved
1939
2020
 
@@ -54,7 +54,7 @@ export const tag = tags({
54
54
  | Actions / mutators | `cache: { invalidates: [...] }` |
55
55
  | LLM calls | `cache: { invalidates: [...] }` |
56
56
 
57
- The graph is a build-time artifact in `x.manifest.json`, so it records exactly what a write will evict — before you run it. `x cache graph --json` is the planned reader of it; today it is `x dev` → the `/_x` cache panel. Tag typing comes from a generated registry augmentation; `x manifest` regenerates it.
57
+ The graph is a build-time artifact in `x.manifest.json`, so it records exactly what a write will evict — before you run it. `x cache graph --json` reads it (since 31.17.0), as does `x dev` → the `/_x` cache panel. Tag typing comes from a generated registry augmentation; `x manifest` regenerates it.
58
58
 
59
59
  ## One hop, all tiers
60
60
 
@@ -229,19 +229,19 @@ No threshold fixes that, because the same number has to keep an honest repeat *a
229
229
 
230
230
  Also cached exactly (tier 3, not semantic): embeddings themselves, keyed by content hash + model. Re-embedding unchanged text is pure waste. See [MCP and AI](MCP-And-AI).
231
231
 
232
- ## CLI — `x cache` is **planned**
232
+ ## CLI — `x cache`
233
233
 
234
- Every row below exits `X_NOT_IMPLEMENTED` `As of 2026-08`, with `x dev` → the `/_x` cache panel as its `fix:`. A planned command declares no flags either, so `x cache graph --tag post` dies at the parser with `X_CLI_BAD_FLAG` before the honest message — call the bare form.
234
+ Ships since **31.17.0** (`graph`, `bust`, `clear`); `stats` is still **planned** and exits `X_NOT_IMPLEMENTED` with `x dev` → the `/_x` cache panel as its `fix:`.
235
235
 
236
- | Command | Will do |
236
+ | Command | Does |
237
237
  |---|---|
238
- | `x cache graph --json` | print the tag → dependents graph: cache keys, ISR routes, CDN paths, live queries. Build-time truth, no runtime call |
238
+ | `x cache graph --json` | the tag graph off the app's manifest: per declared tag, the actions whose `invalidates` name it, the queries cached under it and the ISR routes it revalidates. Build-time truth, no runtime call |
239
239
  | `x cache graph --tag post --json` | the blast radius of one tag |
240
- | `x cache bust <tag>` | run the real fanout for one tag, all tiers, and print the invalidation report |
241
- | `x cache clear` | **dev only.** The only `flushAll` there would be; there is no runtime API for it |
242
- | `x cache stats --json` | per-tier hit rate, byte usage against budget, evictions |
240
+ | `x cache bust <tag> --json` | the real fanout for one tag — the app's own tiers booted as a role boots them, then `invalidateTags`: shared tiers dropped, the edge purged, the bus told — and the invalidation report |
241
+ | `x cache clear --json` | the same bust over every tag the app's modules declare |
242
+ | `x cache stats` | **planned** — hit rates live in the serving processes; `x dev` then the `/_x` cache panel |
243
243
 
244
- Today: `x dev` then the `/_x` cache panel, and `invalidateTags([...])` from `@ultimat3/cache` for a bust from code.
244
+ From code: `invalidateTags([...])` from `@ultimat3/cache`, the call `x cache bust` makes.
245
245
 
246
246
  ## Errors
247
247
 
@@ -260,7 +260,7 @@ Verbatim shapes: [`packages/cache/src/errors.ts`](https://github.com/developerz-
260
260
  - Cache keys are framework-generated. A hand-built key is a rejected PR.
261
261
  - Every cached `query` carries at least one tag. Review catches it `As of 2026-08`, not the gate — `X_CACHE_UNTAGGED_QUERY` is reserved and no `x verify` step reads a query's tags.
262
262
  - Never cache a value whose policy scope is not in its key.
263
- - `flushAll` has no shipped caller: `x cache clear` is planned, and there is no runtime API for it.
263
+ - `flushAll` has no shipped caller: `x cache clear` busts every declared tag through `invalidateTags`, never a flush, and there is no runtime API for it.
264
264
  - Cache misses must be correct and merely slower — no code path may depend on a hit.
265
265
  - Prefer `tag.post.id(x)` over `tag.post`. Narrow eviction is the default, not an optimization.
266
266
  - A cache tier may never fail a business read or write. Tier errors land in the invalidation report, or in a `cache.tier_failure` event on the read ladder.
@@ -51,12 +51,14 @@ There is no `url` field. The canonical origin is an env key the app reads at its
51
51
 
52
52
  ## `database`
53
53
 
54
- `DatabaseConfig` is **two fields**, deliberately — the connection itself is env, not config.
54
+ `DatabaseConfig` is **four fields**, deliberately — the connection itself is env, not config.
55
55
 
56
56
  | field | type | default | notes |
57
57
  |---|---|---|---|
58
58
  | `database.driver` | `'postgres'` | `'postgres'` | one driver; `postgresDriver()` from `@ultimat3/entity` is its only implementation |
59
59
  | `database.ssl` | `boolean` | `false` | `true` on managed Postgres |
60
+ | `database.rowSecurity` | `boolean` | `false` | every `tenant:` table carries a forced row-security policy (`x db gen`), and a serving role Postgres exempts from it is refused at boot (`X_DB_ROW_SECURITY_BYPASSED`) |
61
+ | `database.slowStatementMs` | whole ms ≥ 0 | unset: 500 | `As of 31.17.0`. A statement at or over it writes one `db.statement.slow` warn line in **production** — the normalised shape (never a bound value), duration, rows, the request/job id; one line per shape per 10 s, the rest counted as `suppressed`. `0` is off; `NaN`, a negative or a fraction is `X_CONFIG_INVALID` at boot. Outside production the line is off whatever the key says: a test suite's deliberately slow statements are not an incident |
60
62
  | ~~`database.urlEnv`~~ | — | — | **Deleted 2026-08.** Refused at boot since 25.0.0 (`X_CONFIG_INVALID`, naming the replacement). `@ultimat3/db`'s `client.ts` reads `process.env['DATABASE_URL']` as a hardcoded literal, so a different key here could never be honoured. Migration: delete the key; the connection string is `DATABASE_URL` |
61
63
  | ~~`database.poolSize`~~ | — | — | **Deleted 2026-08.** Refused at boot since 25.0.0 (`X_CONFIG_INVALID`, naming the replacement). A second, non-functioning spelling of `DATABASE_POOL_MAX`, which `baseClient()` layers over the role profile and which works. Migration: delete the key; set `DATABASE_POOL_MAX`. The sizing rule is unchanged — the pool is per PROCESS, so keep `replicas × poolMax` under Postgres `max_connections` |
62
64
  | ~~`database.schema`~~ | — | — | **Deleted 2026-08.** Refused at boot since 25.0.0 (`X_CONFIG_INVALID`, naming the replacement). Nothing emits `SET search_path`. Migration: delete the key; there is no replacement, and `entity()` tables live in `public` |
@@ -880,6 +882,6 @@ Not configuration of the app: what `x verify` holds it to, committed at the repo
880
882
 
881
883
  `x new` writes exactly that; `x upgrade` writes the figures the hop measured into a file that states none, so the floor only falls. A malformed value is a `manifest`-step problem naming the shape → [CLI reference](CLI-Reference#x-exercise).
882
884
 
883
- `x config show` is **planned**, not shipped — it throws `X_NOT_IMPLEMENTED` naming `x manifest --json` as the closest thing today → [CLI reference](CLI-Reference).
885
+ `x config show --json` prints the resolved config — defaults merged, credentials redacted; `--section database` for one key (since 31.17.0) → [CLI reference](CLI-Reference).
884
886
 
885
887
  Error shapes: [Error codes](Error-Codes). Symptom-first fixes: [Troubleshooting](Troubleshooting). Metrics, spans and logs: [Observability](Observability).
@@ -153,7 +153,7 @@ the release that fixed it. Upgrading is the fix, and the breaking entries are th
153
153
  | `on delete` was declared and reached no SQL | **4.0.0** | `references(() => orgs.id, { onDelete: 'cascade' })` type-checked and the rule was dropped one layer below the declaration, so no generated `add constraint` ever spelled one and a drift check had nothing truthful to compare. Now: `ColumnDescription`/`ReferenceDescription` carry `onDelete`, `addForeignKey` writes the clause, and a rule changed on either side is `changed-foreign-key` drift whose `fix:` is the drop/add pair. On 3.0.0, add the clause to the `add constraint` the generator emitted, **before** applying the migration: `… references "orgs" ("id") on delete cascade;`. Editing it after it applies moves the checksum → `X_MIGRATION_CONFLICT` |
154
154
  | A `references()` **removed** from a column emitted nothing | **4.0.0** | the key stayed on the database, the snapshot beside it recorded `foreignKeys: []` — actively denying a constraint the catalog held — and `compareForeignKeys` judges the declared side, so no check could see it. Now `foreignKeyPlan` emits the `drop constraint` in `up` and the `add` in `down`, naming the constraint the **previous snapshot** recorded rather than the name the generator would have picked. On 3.0.0, write the drop into the next generated migration by hand before applying it: `alter table "posts" drop constraint "posts_org_id_fkey";` |
155
155
  | Drift ignored an index's direction and its predicate's presence | **4.0.0** | a `desc` index rebuilt ascending served a feed's newest page off the wrong end, and a partial index recreated as a total one silently widened the constraint — both read `ok: true`. Both are compared now; `asc` is normalised to `null` first, since Postgres stores an ascending index as not-descending. The predicate **text** is still uncompared and always will be — see [Open by decision](#open-by-decision). On 3.0.0, `x db gen` compares all five fields, so regenerate and inspect the diff |
156
- | An unknown flag was refused **before** a planned command could answer honestly | **4.0.0** | the parser read flags against the spec first, so `x logs tail --follow` reported `X_CLI_BAD_FLAG` instead of `X_NOT_IMPLEMENTED`. A planned command now answers with its own status whatever flags it was given; a **shipped** command still refuses an unknown flag, which is correct — `x env` is shipped and declares `--json`, `--help`, `--cwd` and `--verbose`, so anything else is `X_CLI_BAD_FLAG` for the ordinary reason that no such flag exists. On 3.0.0, run the flagless form of a planned command to see the real message |
156
+ | An unknown flag was refused **before** a planned command could answer honestly | **4.0.0** | the parser read flags against the spec first, so a planned command given a flag (then `x logs` with `--follow`) reported `X_CLI_BAD_FLAG` instead of `X_NOT_IMPLEMENTED`. A planned command now answers with its own status whatever flags it was given; a **shipped** command still refuses an unknown flag, which is correct — `x env` is shipped and declares `--json`, `--help`, `--cwd` and `--verbose`, so anything else is `X_CLI_BAD_FLAG` for the ordinary reason that no such flag exists. On 3.0.0, run the flagless form of a planned command to see the real message |
157
157
  | `x deploy --method helm` threw `X_NOT_IMPLEMENTED` in a scaffolded app | **4.0.0** | `x new` wrote no `docker/helm`, and the command carried a "does this build implement helm?" branch over a build that implemented it completely. `x new` now writes the chart — 8 files, `Chart.yaml` + `values.yaml` + 6 templates — and the lying branch is deleted, so a missing chart is helm's own error. The framework repo's own `docker/helm` carried two more templates the scaffold did not (`pdb.yaml`, `servicemonitor.yaml`); `As of 2026-11` only `pdb.yaml` — the scaffold writes `servicemonitor.yaml` and `alert-rules.yaml`, and `x g chart-alerts` backfills them. On 3.0.0, copy [`docker/helm`](https://github.com/developerz-ai/ultimate/tree/main/docker/helm) from the framework repo, or use `--method compose` |
158
158
  | `.env.development` **and `.env.production`** shipped in the image | **4.0.0** | the scaffold's `.dockerignore` excluded `.env` and `.env.*.local` — neither pattern matches `.env.production`, which is the file `docker-compose.prod.yml`'s `env_file:` tells the operator to create. This page said the leak was "harmless as generated"; **that was false**, and a real `docker build` proved both files land in a layer. Now `**/.env` + `**/.env.*` + `!**/.env.example`, in the framework's file, both tracked apps' and the one `x new` writes. On 3.0.0, add those three lines to `docker/Dockerfile.dockerignore` yourself — and rebuild, because an image already built still carries them |
159
159
  | `realtime.heartbeatMs` was read by nothing | **4.0.0**, and BREAKING | the key sat in `RealtimeConfig` with a default of 15 000 and no reader anywhere. It is **deleted**: `RealtimeConfig` is `{ enabled, tier, transport, urlEnv }`, the socket beat is the client's `new LiveClient({ heartbeatMs })` and the presence beat is derived (`PresenceRegistry.heartbeatMs` is `max(1000, floor(ttlMs / 3))`). **Refused at boot since 25.0.0**: `defineConfig` throws `X_CONFIG_INVALID` naming `realtime.heartbeatMs` and its replacement (`REMOVED_CONFIG_KEYS`, `packages/core/src/config-removed.ts`), and any other key it does not declare is refused too (`refuseUnknownKeys`, `packages/core/src/config-keys.ts`). From 4.0.0 until 25.0.0 there was no runtime refusal — `section()` copied the key through and only `TS2353` at typecheck caught it. On 3.0.0, delete the key; setting it changes no behaviour either way |