@ultimat3/cli 31.47.1 → 31.49.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 (276) hide show
  1. package/CLAUDE.md +30 -23
  2. package/README.md +96 -4
  3. package/package.json +29 -29
  4. package/src/api-registration.ts +28 -14
  5. package/src/app-load.ts +6 -1
  6. package/src/app-root.ts +7 -1
  7. package/src/clean-services.ts +142 -0
  8. package/src/cmd-auth.ts +3 -0
  9. package/src/cmd-clean-spec.ts +10 -3
  10. package/src/cmd-clean.ts +23 -9
  11. package/src/cmd-db-backfill.ts +6 -0
  12. package/src/cmd-db-branch.ts +10 -4
  13. package/src/cmd-db-recount.ts +5 -12
  14. package/src/cmd-db-rollback.ts +77 -0
  15. package/src/cmd-db-spec.ts +18 -2
  16. package/src/cmd-db-status.ts +5 -10
  17. package/src/cmd-db.ts +105 -33
  18. package/src/cmd-deploy-verify.ts +14 -6
  19. package/src/cmd-docs-topic.ts +94 -0
  20. package/src/cmd-docs.ts +15 -1
  21. package/src/cmd-doctor.ts +109 -41
  22. package/src/cmd-drill.ts +100 -19
  23. package/src/cmd-env.ts +30 -8
  24. package/src/cmd-errors-app.ts +63 -0
  25. package/src/cmd-errors.ts +50 -14
  26. package/src/cmd-generate.ts +17 -4
  27. package/src/cmd-heavy-spec.ts +36 -0
  28. package/src/cmd-heavy.ts +244 -0
  29. package/src/cmd-jobs.ts +27 -1
  30. package/src/cmd-merge-driver-spec.ts +12 -0
  31. package/src/cmd-merge-driver.ts +95 -0
  32. package/src/cmd-new.ts +23 -3
  33. package/src/cmd-policy-spec.ts +9 -1
  34. package/src/cmd-policy.ts +72 -17
  35. package/src/cmd-stop.ts +18 -4
  36. package/src/cmd-tasks-run.ts +87 -0
  37. package/src/cmd-tasks-spec.ts +10 -3
  38. package/src/cmd-tasks.ts +8 -5
  39. package/src/cmd-test.ts +15 -4
  40. package/src/cmd-upgrade-spec.ts +8 -1
  41. package/src/cmd-upgrade.ts +32 -5
  42. package/src/cmd-verify.ts +9 -41
  43. package/src/codemods/agents-doc-row.ts +73 -0
  44. package/src/codemods/define-error-leaf.ts +37 -12
  45. package/src/codemods/docs-many-agents.ts +26 -0
  46. package/src/codemods/docs-worker-commands.ts +26 -0
  47. package/src/codemods/index.ts +6 -0
  48. package/src/codemods/merge-drivers.ts +66 -0
  49. package/src/command.ts +3 -0
  50. package/src/db-applied-edits.ts +117 -0
  51. package/src/db-dev-wire.ts +18 -0
  52. package/src/db-diagnostics.ts +5 -10
  53. package/src/db-generate.ts +82 -7
  54. package/src/db-migrate-pass.ts +51 -0
  55. package/src/db-migrate-through-dev.ts +209 -0
  56. package/src/db-rollback-consent.ts +128 -0
  57. package/src/db-rollback-pass.ts +76 -0
  58. package/src/db-seed-generate.ts +5 -1
  59. package/src/db-seed.ts +7 -1
  60. package/src/deploy-verify-findings.ts +3 -0
  61. package/src/deploy-verify-grade.ts +3 -0
  62. package/src/deploy-verify-processes.ts +32 -0
  63. package/src/dev-boot.ts +3 -0
  64. package/src/dev-db-migrate.ts +155 -0
  65. package/src/dev-db-rollback.ts +33 -0
  66. package/src/dev-db-settled.ts +22 -0
  67. package/src/dev-lock-errors.ts +78 -0
  68. package/src/dev-lock-holder-dir.ts +64 -0
  69. package/src/dev-lock-live.ts +44 -0
  70. package/src/dev-lock.ts +59 -84
  71. package/src/dev-policy.ts +11 -8
  72. package/src/dev-rebuild-schema.ts +116 -13
  73. package/src/dev-rebuild.ts +13 -4
  74. package/src/dev-route-table.ts +7 -0
  75. package/src/dispatch.ts +21 -1
  76. package/src/doctor-advisory-floors.ts +30 -8
  77. package/src/doctor-api-listing.ts +114 -0
  78. package/src/doctor-guarded.ts +41 -0
  79. package/src/doctor-port.ts +90 -17
  80. package/src/doctor-probe.ts +36 -5
  81. package/src/doctor-processes-probe.ts +127 -0
  82. package/src/doctor-processes.ts +136 -0
  83. package/src/doctor-warnings.ts +17 -0
  84. package/src/error-codes-agents.ts +35 -0
  85. package/src/error-codes-processes.ts +30 -0
  86. package/src/error-codes-tooling.ts +11 -3
  87. package/src/error-codes.ts +12 -13
  88. package/src/errors-suite.ts +27 -0
  89. package/src/errors.ts +18 -22
  90. package/src/exec.ts +11 -3
  91. package/src/exercise-registration.ts +4 -3
  92. package/src/framework-env.ts +7 -3
  93. package/src/generate-files.ts +1 -0
  94. package/src/generate-grant-findings.ts +7 -5
  95. package/src/generate-grants.ts +9 -8
  96. package/src/generate-kinds.ts +30 -6
  97. package/src/generate-roles-file.ts +30 -0
  98. package/src/generate-slice-policy.ts +3 -3
  99. package/src/guards.ts +2 -2
  100. package/src/heavy-cores.ts +51 -0
  101. package/src/heavy-env.ts +21 -0
  102. package/src/heavy-errors.ts +54 -0
  103. package/src/heavy-flock.ts +73 -0
  104. package/src/heavy-holders.ts +78 -0
  105. package/src/heavy-ledger.ts +400 -0
  106. package/src/heavy-memory.ts +67 -0
  107. package/src/heavy-pressure.ts +104 -0
  108. package/src/heavy-weights.ts +47 -0
  109. package/src/heavy.ts +308 -0
  110. package/src/i18n-registration.ts +22 -2
  111. package/src/island-harness.ts +2 -2
  112. package/src/job-budget.ts +4 -2
  113. package/src/job-registration.ts +64 -8
  114. package/src/jobs-queue-known.ts +43 -0
  115. package/src/local-cli.ts +6 -5
  116. package/src/mcp-errors-agents.ts +20 -0
  117. package/src/mcp-errors-doctor.ts +27 -0
  118. package/src/mcp-errors-processes.ts +23 -0
  119. package/src/mcp-errors.ts +18 -29
  120. package/src/mcp-host.ts +2 -2
  121. package/src/merge-driver-catalog.ts +58 -0
  122. package/src/merge-driver-config.ts +43 -0
  123. package/src/merge-driver-lines.ts +140 -0
  124. package/src/merge-state.ts +105 -0
  125. package/src/messages-db.ts +22 -1
  126. package/src/messages-processes.ts +13 -0
  127. package/src/messages-upgrade.ts +6 -0
  128. package/src/messages.ts +62 -1
  129. package/src/output-findings.ts +48 -21
  130. package/src/parse.ts +37 -6
  131. package/src/policy-facts.ts +38 -21
  132. package/src/policy-row.ts +99 -0
  133. package/src/port-pair-free.ts +28 -0
  134. package/src/registry-lines.ts +110 -0
  135. package/src/registry.ts +4 -0
  136. package/src/retain-sweep.ts +1 -1
  137. package/src/role-replicator.ts +9 -4
  138. package/src/role-select.ts +86 -0
  139. package/src/role-start.ts +13 -55
  140. package/src/role-sync.ts +10 -5
  141. package/src/runtime-cache-frame.ts +46 -0
  142. package/src/runtime-cache-ttl.ts +23 -0
  143. package/src/runtime-cache.ts +56 -18
  144. package/src/runtime-database-ssl.ts +84 -0
  145. package/src/runtime-idempotency-scope.ts +16 -2
  146. package/src/runtime-jobs-share.ts +52 -0
  147. package/src/runtime-jobs.ts +43 -12
  148. package/src/runtime-overrides.ts +4 -2
  149. package/src/runtime-queue.ts +18 -3
  150. package/src/runtime-services.ts +8 -1
  151. package/src/schema-drift.ts +19 -2
  152. package/src/schema-dump-drift.ts +4 -1
  153. package/src/serve-boot-probe.ts +30 -2
  154. package/src/serve-boot.ts +11 -1
  155. package/src/serve-env.ts +39 -3
  156. package/src/serve.ts +61 -10
  157. package/src/stop-run-start.ts +12 -0
  158. package/src/supervise-boot.ts +61 -0
  159. package/src/supervise-cgroup.ts +84 -0
  160. package/src/supervise-child.ts +206 -0
  161. package/src/supervise-count.ts +244 -0
  162. package/src/supervise-errors.ts +83 -0
  163. package/src/supervise-facts.ts +40 -0
  164. package/src/supervise-messages.ts +84 -0
  165. package/src/supervise-policy.ts +46 -0
  166. package/src/supervise-pool.ts +10 -0
  167. package/src/supervise-probe.ts +158 -0
  168. package/src/supervise-run.ts +54 -0
  169. package/src/supervise.ts +383 -0
  170. package/src/templates/generate-purge.ts +6 -6
  171. package/src/templates/guard-animated-layout-property.ts +2 -2
  172. package/src/templates/guard-bare-error.ts +1 -1
  173. package/src/templates/guard-error-declared.ts +2 -2
  174. package/src/templates/guard-focus-visible.ts +1 -1
  175. package/src/templates/guard-image-dimensions.ts +2 -2
  176. package/src/templates/guard-island-mount-clears.ts +1 -1
  177. package/src/templates/guard-native-confirm.ts +1 -1
  178. package/src/templates/guard-raw-breakpoint.ts +2 -2
  179. package/src/templates/guard-raw-colour.ts +2 -2
  180. package/src/templates/guard-raw-fetch.ts +1 -1
  181. package/src/templates/guard-raw-interval.ts +1 -1
  182. package/src/templates/guard-raw-length.ts +3 -3
  183. package/src/templates/guard-raw-motion.ts +1 -1
  184. package/src/templates/guard-raw-shadow.ts +1 -1
  185. package/src/templates/guard-raw-z-index.ts +1 -1
  186. package/src/templates/guard-released-forms.ts +59 -13
  187. package/src/templates/guard-repo-await-in-loop.ts +1 -1
  188. package/src/templates/guard-repo-raw-sql.ts +4 -4
  189. package/src/templates/guard-repo-unbounded.ts +1 -1
  190. package/src/templates/guard-runtime-pin.ts +1 -1
  191. package/src/templates/guard-semantic-interactive.ts +2 -2
  192. package/src/templates/guard-unbounded-fanout.ts +1 -1
  193. package/src/templates/guard-undeclared-custom-property.ts +3 -3
  194. package/src/templates/guard-undefined-style-class.ts +3 -3
  195. package/src/templates/guard-unzoned-date.ts +3 -3
  196. package/src/templates/query-slice.ts +82 -0
  197. package/src/templates/query.ts +76 -30
  198. package/src/templates/resource-page.ts +3 -2
  199. package/src/templates/scaffold-bin.ts +2 -0
  200. package/src/templates/scaffold-claude-agents.ts +9 -6
  201. package/src/templates/scaffold-claude-commands.ts +7 -1
  202. package/src/templates/scaffold-claude.ts +4 -4
  203. package/src/templates/scaffold-container-compose.ts +47 -7
  204. package/src/templates/scaffold-docs.ts +11 -6
  205. package/src/templates/scaffold-gitattributes.ts +18 -1
  206. package/src/templates/scaffold-helm-templates.ts +9 -0
  207. package/src/templates/scaffold-repo.ts +4 -1
  208. package/src/templates/scaffold-test-services.ts +33 -11
  209. package/src/templates/shapes/offline.ts +0 -7
  210. package/src/templates/shapes/realtime.ts +2 -6
  211. package/src/templates/sign-in-action-tests.ts +6 -4
  212. package/src/templates/sign-in-challenge.ts +62 -0
  213. package/src/templates/sign-in-oidc-mfa.ts +31 -0
  214. package/src/templates/sign-in-oidc.ts +11 -3
  215. package/src/templates/sign-in-password.ts +18 -56
  216. package/src/test-batches.ts +9 -3
  217. package/src/test-shards.ts +117 -37
  218. package/src/test-slots.ts +35 -161
  219. package/src/test-verdict.ts +79 -0
  220. package/src/test-workers.ts +15 -0
  221. package/src/upgrade-gate-codemods.ts +5 -3
  222. package/src/upgrade-gate.ts +19 -1
  223. package/src/upgrade-merge-drivers.ts +25 -0
  224. package/src/upgrade-report.ts +18 -4
  225. package/src/upgrade-scope.ts +62 -0
  226. package/src/verify-checks.ts +6 -11
  227. package/src/verify-coverage-run.ts +9 -5
  228. package/src/verify-deadline.ts +18 -2
  229. package/src/verify-heavy-steps.ts +26 -0
  230. package/src/verify-live.ts +38 -14
  231. package/src/verify-only.ts +67 -0
  232. package/src/verify-progress.ts +7 -3
  233. package/src/verify-run.ts +20 -2
  234. package/src/verify-services-stack.ts +165 -0
  235. package/src/verify-services.ts +84 -2
  236. package/src/verify-test-run.ts +9 -9
  237. package/src/verify-tests.ts +35 -22
  238. package/src/verify-typecheck.ts +25 -2
  239. package/wiki/Actions.md +2 -1
  240. package/wiki/Admin-Dashboard.md +2 -2
  241. package/wiki/Agents.md +5 -5
  242. package/wiki/Auth.md +15 -5
  243. package/wiki/Bare-VM.md +1 -1
  244. package/wiki/Building-Your-Own-Base.md +15 -2
  245. package/wiki/CI-Parallel-Gate.md +4 -4
  246. package/wiki/CLI-Reference.md +127 -48
  247. package/wiki/Caching-And-Invalidation.md +2 -2
  248. package/wiki/Client-Navigation.md +1 -1
  249. package/wiki/Configuration.md +32 -13
  250. package/wiki/Deployment.md +44 -4
  251. package/wiki/Entities-And-Migrations.md +5 -1
  252. package/wiki/FAQ.md +1 -1
  253. package/wiki/Getting-Started.md +2 -2
  254. package/wiki/Home.md +2 -1
  255. package/wiki/I18n.md +5 -3
  256. package/wiki/Installation.md +12 -11
  257. package/wiki/Interface-Rules.md +1 -1
  258. package/wiki/Jobs-And-Workflows.md +24 -4
  259. package/wiki/Known-Gaps.md +2 -2
  260. package/wiki/MCP-And-AI.md +8 -5
  261. package/wiki/Mail.md +1 -1
  262. package/wiki/Many-Agents.md +127 -0
  263. package/wiki/Migrations-And-Backfills.md +18 -0
  264. package/wiki/Notify.md +1 -1
  265. package/wiki/Observability.md +13 -0
  266. package/wiki/Queries-And-Live-Queries.md +2 -2
  267. package/wiki/Realtime.md +10 -1
  268. package/wiki/Routes-And-Render-Modes.md +1 -1
  269. package/wiki/Scheduled-Tasks.md +4 -1
  270. package/wiki/Testing.md +12 -9
  271. package/wiki/Timezones-And-Dates.md +5 -1
  272. package/wiki/Troubleshooting.md +1 -0
  273. package/wiki/Tutorial-01-First-App.md +5 -5
  274. package/wiki/Tutorial-02-First-Feature.md +1 -1
  275. package/wiki/Tutorial-03-Auth-And-Admin.md +7 -6
  276. package/wiki/Upgrading.md +37 -0
@@ -0,0 +1,25 @@
1
+ // After a hop's codemods: the merge drivers its `.gitattributes` names, installed in this clone as
2
+ // `bun run setup` would, so an upgrade leaves no `X_MERGE_DRIVER_UNSET` for a person to act on.
3
+
4
+ // why: Bun exposes no path-join primitive.
5
+ import { join } from 'node:path';
6
+ import type { Runner } from './exec';
7
+ import { LOCAL_CLI_BIN } from './local-cli';
8
+ import { driverUnset } from './merge-driver-config';
9
+
10
+ /**
11
+ * Through the installed CLI, which the hop just installed and which has the subcommand. True when
12
+ * it ran and succeeded; a failure is not thrown, because `x doctor` reports the same unset driver
13
+ * as a warning with its fix, beside the hop's verdict.
14
+ */
15
+ export async function installMergeDrivers(runner: Runner, root: string): Promise<boolean> {
16
+ if (!(await driverUnset(root, runner))) return false;
17
+ const command = [
18
+ process.execPath,
19
+ join(root, LOCAL_CLI_BIN),
20
+ 'merge-driver',
21
+ 'install',
22
+ '--json',
23
+ ];
24
+ return (await runner(command, { cwd: root })).ok;
25
+ }
@@ -34,11 +34,18 @@ export interface PlannedWrites {
34
34
  readonly manual: readonly BunManual[];
35
35
  }
36
36
 
37
- /** The strongest check a hop had: the verdict `done` rests on, stated rather than implied. */
38
- export type HopProof = 'verify' | 'scripts' | 'none';
37
+ /**
38
+ * The strongest check a hop had: the verdict `done` rests on, stated rather than implied.
39
+ * `verify-only` is `x upgrade --only`'s: green on some steps, the rest in `verify.notRun`.
40
+ */
41
+ export type HopProof = 'verify' | 'verify-only' | 'scripts' | 'none';
39
42
 
40
- export const proofOf = (gate: HopGate | undefined, scripts: readonly RepoScript[]): HopProof =>
41
- gate !== undefined ? 'verify' : scripts.length > 0 ? 'scripts' : 'none';
43
+ const notRunOf = (gate: HopGate | undefined): readonly string[] => gate?.verify.notRun ?? [];
44
+
45
+ export const proofOf = (gate: HopGate | undefined, scripts: readonly RepoScript[]): HopProof => {
46
+ if (gate !== undefined) return notRunOf(gate).length > 0 ? 'verify-only' : 'verify';
47
+ return scripts.length > 0 ? 'scripts' : 'none';
48
+ };
42
49
 
43
50
  /** What the agent does next, as a sentence naming the commands. */
44
51
  export const thenLine = (input: {
@@ -68,6 +75,10 @@ export const thenLine = (input: {
68
75
  : msg('cli.upgrade.then.scriptsRed', { to: hop.to });
69
76
  }
70
77
  if (gate?.verify.ok !== true) return msg('cli.upgrade.then.red', { to: hop.to });
78
+ const notRun = notRunOf(gate);
79
+ if (notRun.length > 0) {
80
+ return msg('cli.upgrade.then.scoped', { to: hop.to, steps: notRun.join(',') });
81
+ }
71
82
  return hop.next === null
72
83
  ? msg('cli.upgrade.then.last', { to: hop.to })
73
84
  : msg('cli.upgrade.then.walk', { to: hop.to, next: hop.next });
@@ -154,6 +165,9 @@ export const humanLines = (
154
165
  ...scripts
155
166
  .filter((script) => script.ok === false)
156
167
  .map((script) => msg('cli.upgrade.scriptRed', { name: script.name })),
168
+ ...(notRunOf(gate).length === 0
169
+ ? []
170
+ : [msg('cli.upgrade.notRun', { steps: notRunOf(gate).join(',') })]),
157
171
  msg('cli.upgrade.then', { then }),
158
172
  ];
159
173
  };
@@ -0,0 +1,62 @@
1
+ // `x upgrade --only`: which of the gate's steps the hop's `x verify` runs, read before anything
2
+ // spawns, and which it leaves out — counted against the installed CLI's gate, which may be older.
3
+ // The list is `x verify --only`'s, read by the same reader (`verify-only.ts`).
4
+
5
+ import { t } from '@ultimat3/schema';
6
+ import type { CommandContext } from './command';
7
+ import { BadFlagError } from './errors';
8
+ import type { ExecResult } from './exec';
9
+ import { documentIn } from './upgrade-document';
10
+ import { readStepList, stepsNotIn } from './verify-only';
11
+
12
+ /** A scoped gate's list and the steps it leaves out: what the hop's report owes to be honest. */
13
+ export interface GateScope {
14
+ readonly steps: readonly string[];
15
+ readonly notRun: readonly string[];
16
+ }
17
+
18
+ /**
19
+ * `--only`, read before anything spawns. Every step named is the full gate, so it runs as one and
20
+ * reports as one; a repository with no `app.config.ts` runs scripts, never `x verify`, so a list
21
+ * there would narrow nothing and is refused rather than ignored.
22
+ */
23
+ export const readScope = (ctx: CommandContext, app: boolean): GateScope | undefined => {
24
+ const steps = readStepList(ctx.args, 'upgrade');
25
+ if (steps === undefined) return undefined;
26
+ if (!app) {
27
+ throw new BadFlagError({
28
+ flag: 'only',
29
+ command: 'upgrade',
30
+ reason: 'no app.config.ts here, so the hop runs the typecheck and test scripts, not x verify',
31
+ fix: 'x upgrade --json',
32
+ });
33
+ }
34
+ const notRun = stepsNotIn(steps);
35
+ return notRun.length === 0 ? undefined : { steps, notRun };
36
+ };
37
+
38
+ const PLAN = t.object({
39
+ data: t.object({
40
+ matrix: t.object({ include: t.array(t.object({ only: t.string })) }),
41
+ }),
42
+ });
43
+
44
+ /**
45
+ * The steps the INSTALLED CLI's gate has and this hop did not run: its `x verify plan --parts 1`,
46
+ * the one form that reads no app. A CLI with no plan (or no answer) leaves this CLI's list
47
+ * standing, the best evidence there is; a step it lacks then fails CI's run by name.
48
+ */
49
+ export async function installedNotRun(
50
+ cli: (args: readonly string[]) => Promise<ExecResult>,
51
+ scope: GateScope,
52
+ ): Promise<readonly string[]> {
53
+ const parsed = PLAN.safeParse(
54
+ documentIn((await cli(['verify', 'plan', '--parts', '1', '--json'])).stdout),
55
+ );
56
+ if (parsed.issues !== undefined) return scope.notRun;
57
+ const rows = (parsed.value as { data: { matrix: { include: readonly { only: string }[] } } }).data
58
+ .matrix.include;
59
+ const gate = new Set(rows.flatMap((row) => row.only.split(',')));
60
+ if (gate.size === 0) return scope.notRun;
61
+ return [...gate].filter((name) => name !== '' && !scope.steps.includes(name));
62
+ }
@@ -30,7 +30,7 @@ import { catalogFindings } from './i18n-registration';
30
30
  import { isrQueryAdvice } from './isr-query-advice';
31
31
  import { readJobBudgetFindings } from './job-budget';
32
32
  import { unregisteredJobFindings } from './job-registration';
33
- import { LINT_ARGV, lintOutcome } from './lint-findings';
33
+ import { lintOutcome } from './lint-findings';
34
34
  import { liveRouteFindings } from './live-routes';
35
35
  import { blockedByLoad, withLoadFindings } from './load-findings';
36
36
  import {
@@ -51,7 +51,6 @@ import {
51
51
  } from './schema-dump-drift';
52
52
  import { cardRouteFindings } from './seo-cards';
53
53
  import { scanSiteMeta } from './seo-meta';
54
- import { quoteArg } from './shell-quote';
55
54
  import { loadSiteSettings } from './site-config';
56
55
  import { readStaticReport } from './static-report';
57
56
  import { unknownToolGateFindings } from './tool-gate-names';
@@ -60,13 +59,14 @@ import { contractDiffStep } from './verify-contract-diff';
60
59
  import { nestedAppRootFindings } from './verify-drift-owner';
61
60
  import { exerciseStep } from './verify-exercise';
62
61
  import { floorProblemFindings, readVerifyFloor } from './verify-floor';
62
+ import { runLint, runTypecheck } from './verify-heavy-steps';
63
63
  import { mcpMountFindings } from './verify-mcp-mount';
64
64
  import { nativeFormWarnings } from './verify-native-form';
65
65
  import { roleLoadFindings } from './verify-role-load';
66
66
  import type { VerifyStep } from './verify-step';
67
67
  import { fromExec, fromFindings, hostFindings } from './verify-step';
68
68
  import { TEST_STEPS } from './verify-tests';
69
- import { typecheckArgs } from './verify-typecheck';
69
+ import { typecheckArgs, typecheckFinding } from './verify-typecheck';
70
70
  import { checkPackageShape, fileSizeReport, hasWorkspacePackages } from './workspace-checks';
71
71
  import { checkExternalDependencies } from './workspace-external-deps';
72
72
  import { checkWorkspaceDependencies } from './workspace-graph';
@@ -90,13 +90,8 @@ export const VERIFY_STEPS: readonly VerifyStep[] = [
90
90
  async run(ctx) {
91
91
  const floor = await readVerifyFloor(ctx.root);
92
92
  const argv = await typecheckArgs(ctx.root, floor?.typecheckBin ?? 'tsc');
93
- const result = await ctx.runner(['bunx', ...argv], { cwd: ctx.root });
94
- return fromExec(result, {
95
- code: 'X_TYPECHECK_FAILED',
96
- cause: 'the project does not typecheck',
97
- // Joined, never spliced: `typecheckBin` is a value from the app's `x.verify.json`.
98
- fix: ['bunx', ...argv.map(quoteArg)].join(' '),
99
- });
93
+ const result = await runTypecheck(ctx, argv);
94
+ return fromExec(result, typecheckFinding(result.stdout));
100
95
  },
101
96
  },
102
97
  {
@@ -107,7 +102,7 @@ export const VERIFY_STEPS: readonly VerifyStep[] = [
107
102
  // the colour rule is `packages/ui/src/tokens/tokens.test.ts`, and rides on the `unit` step.
108
103
  summary: 'biome: format, no any, no default exports, no unused imports',
109
104
  async run(ctx) {
110
- return lintOutcome(await ctx.runner(LINT_ARGV, { cwd: ctx.root }));
105
+ return lintOutcome(await runLint(ctx));
111
106
  },
112
107
  },
113
108
  {
@@ -32,7 +32,7 @@ import { msg } from './messages';
32
32
  import { countsOf } from './test-counts';
33
33
  import { testEnvOverrides } from './test-dotenv';
34
34
  import { failureOf } from './test-shards';
35
- import { SLOT_HELD_ENV } from './test-slots';
35
+ import type { MachineLease } from './test-slots';
36
36
  import {
37
37
  costOf,
38
38
  junitDurations,
@@ -41,6 +41,7 @@ import {
41
41
  recordTimings,
42
42
  slowestOf,
43
43
  } from './test-timings';
44
+ import { reachedWidth } from './test-workers';
44
45
  import type { MachinePace } from './verify-pace';
45
46
  import { defaultTimeoutArgs, paceEnv } from './verify-pace';
46
47
  import type { StepOutcome } from './verify-step';
@@ -99,7 +100,7 @@ export interface CoveredRunOptions {
99
100
  readonly isolate?: boolean;
100
101
  readonly env?: Readonly<Record<string, string | undefined>>;
101
102
  readonly widthReason?: string;
102
- readonly lease?: (want: number) => Promise<{ readonly count: number; release(): void }>;
103
+ readonly lease?: MachineLease;
103
104
  /** Test files per process. Absent is `COVERAGE_SLICE_FILES`; a test cuts smaller. */
104
105
  readonly sliceFiles?: number;
105
106
  /** The machine's pace (`verify-pace.ts`): each test's default and declared deadline stretch by it. */
@@ -144,14 +145,14 @@ export const coveredArgs = (
144
145
  export async function runCovered(options: CoveredRunOptions): Promise<CoveredRun> {
145
146
  const slices = coverageSlices(options.files, options.sliceFiles);
146
147
  const want = Math.max(1, Math.min(Math.trunc(options.workers), slices.length));
147
- const lease = want > 1 ? await options.lease?.(want) : undefined;
148
+ const lease = await options.lease?.(want);
148
149
  const width = Math.min(want, lease?.count ?? want);
149
150
  const base = join(options.root, COVERAGE_DIR, `unit-${String(process.pid)}`);
150
151
  const isolate = options.isolate === true;
151
152
  const overrides = {
152
153
  ...testEnvOverrides(options.root, options.env ?? Bun.env),
153
154
  ...(isolate ? { [ISOLATED_ENV]: '1' } : {}),
154
- ...(lease === undefined ? {} : { [SLOT_HELD_ENV]: '1' }),
155
+ ...lease?.env,
155
156
  ...paceEnv(options.pace),
156
157
  };
157
158
  const results = new Array<ExecResult>(slices.length);
@@ -174,6 +175,7 @@ export async function runCovered(options: CoveredRunOptions): Promise<CoveredRun
174
175
  ),
175
176
  {
176
177
  cwd: options.root,
178
+ ...(lease?.fds === undefined || lease.fds.length === 0 ? {} : { inheritFds: lease.fds }),
177
179
  env: {
178
180
  ...overrides,
179
181
  ULTIMATE_TEST_WORKER: String(slot),
@@ -237,7 +239,9 @@ export async function runCovered(options: CoveredRunOptions): Promise<CoveredRun
237
239
  }),
238
240
  ],
239
241
  workers: width,
240
- ...(options.widthReason === undefined ? {} : { widthReason: options.widthReason }),
242
+ ...(options.widthReason === undefined
243
+ ? {}
244
+ : { widthReason: reachedWidth(width, want, options.widthReason) }),
241
245
  tests: countsOf(results),
242
246
  ...(first === undefined ? {} : { output }),
243
247
  ...(Object.keys(measured).length === 0 ? {} : { slowest: slowestOf(measured, options.files) }),
@@ -5,6 +5,7 @@
5
5
  import { TEST_TYPES } from '@ultimat3/testing';
6
6
  import type { ExecResult, Runner } from './exec';
7
7
  import { execOutput } from './exec';
8
+ import { heavyWaitClock } from './heavy';
8
9
  import type { VerifyStepName } from './verify-step';
9
10
 
10
11
  /** The `x.verify.json` key: `{ "stepTimeoutMs": { "unit": 900000 } }`. */
@@ -462,14 +463,29 @@ export async function killTagged(
462
463
  return [...killed.values()];
463
464
  }
464
465
 
465
- /** `work`, or `{ timedOut: true }` once `ms` passes. The abandoned promise is never unhandled. */
466
+ /**
467
+ * `work`, or `{ timedOut: true }` once `ms` of its own time passes. Time queued for the machine
468
+ * (`waited`, a monotonic clock) is not the step's: a gate behind another gate is not a hung one. The
469
+ * abandoned promise is never unhandled.
470
+ */
466
471
  export async function raceDeadline<T>(
467
472
  work: Promise<T>,
468
473
  ms: number,
474
+ waited: () => number = heavyWaitClock,
469
475
  ): Promise<{ readonly timedOut: false; readonly value: T } | { readonly timedOut: true }> {
470
476
  let timer: ReturnType<typeof setTimeout> | undefined;
477
+ const started = performance.now();
478
+ const waitedAtStart = waited();
471
479
  const expired = new Promise<{ readonly timedOut: true }>((resolve) => {
472
- timer = setTimeout(() => resolve({ timedOut: true }), ms);
480
+ const arm = (delay: number): void => {
481
+ timer = setTimeout(() => {
482
+ const due = started + ms + (waited() - waitedAtStart);
483
+ const left = due - performance.now();
484
+ if (left > 0) arm(left);
485
+ else resolve({ timedOut: true });
486
+ }, delay);
487
+ };
488
+ arm(ms);
473
489
  });
474
490
  try {
475
491
  const raced = await Promise.race([
@@ -0,0 +1,26 @@
1
+ // The gate's two whole-tree tools, each run inside its measured reservation in the machine ledger.
2
+ // Split from `verify-checks.ts`, which owns what the steps conclude from these results.
3
+
4
+ import type { ExecResult } from './exec';
5
+ import { withCheckoutLock, withChild, withHeavy } from './heavy';
6
+ import { LINT_PEAK_MB, typecheckPeakMb } from './heavy-weights';
7
+ import { LINT_ARGV } from './lint-findings';
8
+ import type { VerifyContext } from './verify-step';
9
+
10
+ /** The compiler's peak in the ledger, then this checkout's one `tsc` at a time. */
11
+ export function runTypecheck(ctx: VerifyContext, argv: readonly string[]): Promise<ExecResult> {
12
+ const env = ctx.env ?? Bun.env;
13
+ return withHeavy(
14
+ { label: 'typecheck', cwd: ctx.root, env, unitMb: typecheckPeakMb(argv) },
15
+ (held) =>
16
+ withCheckoutLock({ name: 'typecheck', root: ctx.root, env }, held, (child) =>
17
+ ctx.runner(['bunx', ...argv], withChild({ cwd: ctx.root }, child)),
18
+ ),
19
+ );
20
+ }
21
+
22
+ export const runLint = (ctx: VerifyContext): Promise<ExecResult> =>
23
+ withHeavy(
24
+ { label: 'lint', cwd: ctx.root, env: ctx.env ?? Bun.env, unitMb: LINT_PEAK_MB },
25
+ (child) => ctx.runner(LINT_ARGV, withChild({ cwd: ctx.root }, child)),
26
+ );
@@ -6,7 +6,7 @@
6
6
  import type { Runner } from './exec';
7
7
  import { msg } from './messages';
8
8
  import { floorRequires, readVerifyFloor } from './verify-floor';
9
- import type { LoginProbe, Probe } from './verify-services';
9
+ import type { LoginProbe, Probe, StackReport } from './verify-services';
10
10
  import {
11
11
  ensureTestServices,
12
12
  SERVICES_DOWN,
@@ -14,12 +14,16 @@ import {
14
14
  TEST_DATABASE_KEY,
15
15
  } from './verify-services';
16
16
  import type { StepOutcome, VerifyContext, VerifyStep } from './verify-step';
17
+ import { writeErrorLine } from './write-line';
17
18
 
18
- /** Whether this run asked for `live` by name or the committed floor holds it to running. */
19
- async function liveRequired(ctx: VerifyContext): Promise<boolean> {
19
+ /**
20
+ * Whether this run needs `live`: `floored` when the committed floor holds it (an empty suite is
21
+ * red there), `asked` when only `--only` named it.
22
+ */
23
+ async function liveRequired(ctx: VerifyContext): Promise<'floored' | 'asked' | undefined> {
24
+ if (floorRequires(await readVerifyFloor(ctx.root), 'live')) return 'floored';
20
25
  const only = ctx.only === undefined ? [] : typeof ctx.only === 'string' ? [ctx.only] : ctx.only;
21
- if (only.includes('live')) return true;
22
- return floorRequires(await readVerifyFloor(ctx.root), 'live');
26
+ return only.includes('live') ? 'asked' : undefined;
23
27
  }
24
28
 
25
29
  /** `ctx` whose every child sees `env` beneath its own overrides — an explicit unset still wins. */
@@ -37,17 +41,33 @@ const withWarning = (outcome: StepOutcome, warning: string): StepOutcome => ({
37
41
  warnings: [...(outcome.warnings ?? []), warning],
38
42
  });
39
43
 
44
+ /** The one line about the stack: which it is, and what became of it. Stderr: stdout may be JSON. */
45
+ const stackLine = (stack: StackReport, services: readonly string[]): string =>
46
+ msg(`cli.verify.services.line.${stack.state}`, {
47
+ project: stack.project,
48
+ services: services.join(', '),
49
+ other: stack.with ?? '',
50
+ why: stack.why === undefined ? '' : msg(`cli.verify.services.why.${stack.why}`),
51
+ });
52
+
40
53
  /**
41
- * `step` with its database found or started first. A stack that cannot be started is a WARNING on
42
- * this major, carrying `X_TEST_SERVICES_UNAVAILABLE` and the line to run: the suites skip exactly
43
- * as they did before, and a floor whose every live test skipped is still `X_VERIFY_SUITE_VANISHED`.
54
+ * `step` with its database found or started first. A stack that cannot be started is the step's
55
+ * FINDING when the floor holds `live` and nothing ran — the services are why, and the floor's own
56
+ * `X_VERIFY_SUITE_VANISHED` would only restate the symptom with a fix that reruns it. Otherwise it
57
+ * stays a WARNING carrying `X_TEST_SERVICES_UNAVAILABLE`: tests that ran without it still count.
44
58
  * Never torn down: the next run reuses it, and the warning says how to stop it.
45
59
  */
46
- export function withTestServices(step: VerifyStep, probe?: Probe, login?: LoginProbe): VerifyStep {
60
+ export function withTestServices(
61
+ step: VerifyStep,
62
+ probe?: Probe,
63
+ login?: LoginProbe,
64
+ say: (line: string) => void = writeErrorLine,
65
+ ): VerifyStep {
47
66
  return {
48
67
  ...step,
49
68
  async run(ctx) {
50
- if (!(await liveRequired(ctx))) return step.run(ctx);
69
+ const required = await liveRequired(ctx);
70
+ if (required === undefined) return step.run(ctx);
51
71
  const verdict = await ensureTestServices({
52
72
  root: ctx.root,
53
73
  runner: ctx.runner,
@@ -62,15 +82,19 @@ export function withTestServices(step: VerifyStep, probe?: Probe, login?: LoginP
62
82
  return own === undefined || own === '' ? outcome : reached(outcome);
63
83
  }
64
84
  if (verdict.kind === 'unavailable') {
85
+ const outcome = await step.run(ctx);
86
+ const ranNothing = outcome.tests?.ran === 0 && outcome.shard === undefined;
87
+ if (required === 'floored' && ranNothing) {
88
+ const findings = [verdict.finding, ...outcome.findings];
89
+ return { ...outcome, ok: false, findings, services: 'unavailable' };
90
+ }
65
91
  const { code, cause, fix } = verdict.finding;
66
92
  return {
67
- ...withWarning(
68
- await step.run(ctx),
69
- msg('cli.verify.services.unavailable', { code, cause, fix }),
70
- ),
93
+ ...withWarning(outcome, msg('cli.verify.services.unavailable', { code, cause, fix })),
71
94
  services: 'unavailable',
72
95
  };
73
96
  }
97
+ if (verdict.stack !== undefined) say(stackLine(verdict.stack, verdict.startedServices));
74
98
  const outcome = reached(await step.run(withEnv(ctx, verdict.env)));
75
99
  // Whatever this run's `up` started, by compose's answer — a reachable Postgres beside a
76
100
  // freshly started Redis still leaves containers running; a stack already up says nothing.
@@ -0,0 +1,67 @@
1
+ // `--only <step>[,<step>…]`, read once for every command that narrows the gate: `x verify --only`
2
+ // and `x upgrade --only` take the same list, refused the same way, so the two cannot disagree.
3
+
4
+ import { nearestName, renderFixShellArg } from '@ultimat3/core';
5
+ import { BadFlagError } from './errors';
6
+ import type { ParsedArgs } from './parse';
7
+ import { flagString } from './parse';
8
+ import type { VerifyStepName } from './verify-step';
9
+ import { VERIFY_STEP_NAMES } from './verify-step';
10
+
11
+ /** The commands whose `--only` narrows the gate; each refusal's `fix:` re-runs the one typed. */
12
+ export type StepListCommand = 'verify' | 'upgrade';
13
+
14
+ const isStepName = (raw: string): raw is VerifyStepName =>
15
+ (VERIFY_STEP_NAMES as readonly string[]).includes(raw);
16
+
17
+ /**
18
+ * The steps `--only` names, or nothing: one step (`--only lint`) or a comma-separated list
19
+ * (`--only typecheck,lint,boundaries`), in the gate's declared order whatever order they were
20
+ * typed in. Refused against `VERIFY_STEP_NAMES` — the same constant the runner's list is built
21
+ * from — so a typo can never be read as "narrow to no steps at all", which is a run that passes by
22
+ * checking nothing. An empty item (`lint,,drift`, a trailing comma) is refused for the same reason.
23
+ *
24
+ * A near miss leads with the list as it would be with each typo corrected; an item near NOTHING
25
+ * gets the command itself rather than an invented lead, which is the rule `parse.ts` already
26
+ * follows for a command that resembles none. Both arms are commands that run.
27
+ */
28
+ export const readStepList = (
29
+ args: ParsedArgs,
30
+ command: StepListCommand,
31
+ ): readonly VerifyStepName[] | undefined => {
32
+ const raw = flagString(args, 'only');
33
+ if (raw === undefined) return undefined;
34
+ const items = raw.split(',').map((item) => item.trim());
35
+ const unknown = items.filter((item) => !isStepName(item));
36
+ if (unknown.length === 0) {
37
+ return VERIFY_STEP_NAMES.filter((name) => items.includes(name));
38
+ }
39
+ // An empty item corrects to nothing — never to whichever step is nearest to ''.
40
+ const corrected = items.map((item) =>
41
+ isStepName(item) ? item : item === '' ? undefined : nearestName(item, VERIFY_STEP_NAMES),
42
+ );
43
+ const list = corrected.every((item) => item !== undefined)
44
+ ? renderFixShellArg([...new Set(corrected)].join(','), '<step,step>')
45
+ : undefined;
46
+ throw new BadFlagError({
47
+ flag: 'only',
48
+ command,
49
+ reason: `${reasonOf(unknown)} (${VERIFY_STEP_NAMES.join(', ')})`,
50
+ fix: command === 'verify' ? verifyFix(list) : upgradeFix(list),
51
+ });
52
+ };
53
+
54
+ // One literal per command: the command word never reaches a `fix:` as a spliced value.
55
+ const verifyFix = (list: string | undefined): string =>
56
+ list === undefined ? 'x verify --json' : `x verify --only ${list} --json`;
57
+ const upgradeFix = (list: string | undefined): string =>
58
+ list === undefined ? 'x upgrade --json' : `x upgrade --only ${list} --json`;
59
+
60
+ const reasonOf = (unknown: readonly string[]): string => {
61
+ const named = unknown.map((item) => (item === '' ? '(empty)' : `"${item}"`)).join(', ');
62
+ return `${named} ${unknown.length === 1 ? 'is not a gate step' : 'are not gate steps'}`;
63
+ };
64
+
65
+ /** The gate's steps a narrowed run leaves out, in declared order: what someone else still owes. */
66
+ export const stepsNotIn = (only: readonly string[]): readonly VerifyStepName[] =>
67
+ VERIFY_STEP_NAMES.filter((name) => !only.includes(name));
@@ -8,6 +8,8 @@ import { systemClock } from '@ultimat3/core';
8
8
  import { TEST_TYPES } from '@ultimat3/testing';
9
9
  import { msg } from './messages';
10
10
  import type { StepResult } from './output';
11
+ import type { ReaderOptions } from './output-findings';
12
+ import { fixForReader } from './output-findings';
11
13
  import { quoteArg } from './shell-quote';
12
14
  import { isTest } from './source-files';
13
15
  import type { VerifyStepName } from './verify-step';
@@ -56,10 +58,10 @@ export function narrowestRerun(step: StepResult): string {
56
58
  }
57
59
 
58
60
  /** `✓ lint 22.0s`, `○ seo 0.0s` (did not apply), `✗ unit 3.1s → x test unit --filter … --json`. */
59
- export function humanStepLine(step: StepResult): string {
61
+ export function humanStepLine(step: StepResult, reader: ReaderOptions = {}): string {
60
62
  const mark = step.skipped === true ? '○' : step.ok ? '✓' : '✗';
61
63
  const line = `${mark} ${step.name} ${(step.durationMs / 1000).toFixed(1)}s`;
62
- return step.ok ? line : `${line} → ${narrowestRerun(step)}`;
64
+ return step.ok ? line : `${line} → ${fixForReader(narrowestRerun(step), reader)}`;
63
65
  }
64
66
 
65
67
  /** `12m 3s`, `45s`: a person reading a CI log, not a parser — the step lines carry exact ms. */
@@ -89,6 +91,8 @@ export interface VerifyProgressOptions {
89
91
  * for a person — `x verify` and `scripts/verify.ts` pass it when `--json` is unset.
90
92
  */
91
93
  readonly render?: 'json' | 'human';
94
+ /** Who reads the human line's pointer: `x` is not every reader's command. */
95
+ readonly reader?: ReaderOptions;
92
96
  }
93
97
 
94
98
  /**
@@ -120,7 +124,7 @@ export async function withVerifyProgress<T>(
120
124
  },
121
125
  onStep: (step) => {
122
126
  running.delete(step.name);
123
- write(options.render === 'human' ? humanStepLine(step) : stepLine(step));
127
+ write(options.render === 'human' ? humanStepLine(step, options.reader) : stepLine(step));
124
128
  },
125
129
  });
126
130
  } finally {
package/src/verify-run.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // `cmd-verify.ts` because `x build` and the MCP host run the gate without going through the
3
3
  // command: what a run means — never bail early, count what actually ran — belongs to neither.
4
4
 
5
- import { ERROR_DOCS_URL, renderThrowable } from '@ultimat3/core';
5
+ import { ERROR_DOCS_URL, isUltimateError, renderThrowable, stringField } from '@ultimat3/core';
6
6
  import type { CoverageMap } from './coverage-lcov';
7
7
  import { encodeCoverage } from './coverage-lcov';
8
8
  import { msg } from './messages';
@@ -323,7 +323,11 @@ async function runStep(
323
323
  // A step the floor requires whose suite executed nothing is the same vanished suite as a step
324
324
  // with no files at all — the run just had to finish before it could be seen. Appended to the
325
325
  // step's own findings so `data.failed`, the counts and every gate reading this table carry it.
326
- const vanished = nothingRan && required ? [skippedSuiteFinding(step.name, tests.skipped)] : [];
326
+ // Unless the step already said why: a `live` step whose services could not start carries that
327
+ // finding itself, and a second one here would bury the cause under its symptom.
328
+ const explained = outcome.services === 'unavailable' && outcome.findings.length > 0;
329
+ const vanished =
330
+ nothingRan && required && !explained ? [skippedSuiteFinding(step.name, tests.skipped)] : [];
327
331
  const unrun = nothingRan ? ranNothingReason(tests) : undefined;
328
332
  const strict = unrun === undefined ? [] : judgeUnrun(floor, step.name, unrun, required, command);
329
333
  // A `skip` why over a suite that RAN tests is stale: said on the step, never red. Only on counts
@@ -389,6 +393,20 @@ async function expired(
389
393
  }
390
394
 
391
395
  function findingOf(error: unknown, step: string, command: string): Finding {
396
+ // A coded throw already carries its instruction: print its code and its fix, never the gate's
397
+ // own rerun, which only repeats the step that just threw (an `X_ENV_MISSING` under `manifest`).
398
+ // `stringField` because the read may fight back, like `renderThrowable` below.
399
+ if (isUltimateError(error)) {
400
+ const [code, cause, fix] = ['code', 'cause', 'fix'].map((key) => stringField(error, key));
401
+ if (code !== undefined && cause !== undefined && fix !== undefined && fix !== '') {
402
+ return {
403
+ code: 'X_VERIFY_FAILED',
404
+ cause: `step "${step}" threw ${code}: ${cause}`,
405
+ fix,
406
+ docs: ERROR_DOCS_URL,
407
+ };
408
+ }
409
+ }
392
410
  // A step may throw anything, including an Error that fights being read: `instanceof` runs a
393
411
  // Proxy's `getPrototypeOf` trap and `.message` runs a getter, so a hostile throw would take the
394
412
  // gate's own report down with it — the one message that may never be lost.