@ultimat3/cli 31.48.0 → 31.50.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 (287) hide show
  1. package/CLAUDE.md +30 -23
  2. package/README.md +96 -4
  3. package/package.json +30 -30
  4. package/src/api-registration.ts +45 -14
  5. package/src/api-routes.ts +1 -0
  6. package/src/app-load.ts +7 -3
  7. package/src/app-openapi.ts +7 -1
  8. package/src/app-root.ts +7 -1
  9. package/src/budgets.ts +2 -1
  10. package/src/clean-services.ts +142 -0
  11. package/src/cmd-auth.ts +3 -0
  12. package/src/cmd-clean-spec.ts +10 -3
  13. package/src/cmd-clean.ts +23 -9
  14. package/src/cmd-db-backfill.ts +6 -0
  15. package/src/cmd-db-branch.ts +10 -4
  16. package/src/cmd-db-recount.ts +5 -12
  17. package/src/cmd-db-rollback.ts +77 -0
  18. package/src/cmd-db-spec.ts +18 -2
  19. package/src/cmd-db-status.ts +5 -10
  20. package/src/cmd-db.ts +105 -33
  21. package/src/cmd-deploy-verify.ts +14 -6
  22. package/src/cmd-docs-topic.ts +94 -0
  23. package/src/cmd-docs.ts +15 -1
  24. package/src/cmd-doctor.ts +109 -41
  25. package/src/cmd-drill.ts +80 -18
  26. package/src/cmd-env.ts +30 -8
  27. package/src/cmd-errors-app.ts +63 -0
  28. package/src/cmd-errors.ts +50 -14
  29. package/src/cmd-generate.ts +17 -4
  30. package/src/cmd-heavy-spec.ts +9 -1
  31. package/src/cmd-heavy.ts +111 -27
  32. package/src/cmd-i18n.ts +33 -1
  33. package/src/cmd-jobs.ts +27 -1
  34. package/src/cmd-merge-driver-spec.ts +12 -0
  35. package/src/cmd-merge-driver.ts +95 -0
  36. package/src/cmd-new.ts +23 -3
  37. package/src/cmd-policy-spec.ts +9 -1
  38. package/src/cmd-policy.ts +72 -17
  39. package/src/cmd-stop.ts +18 -4
  40. package/src/cmd-tasks-run.ts +87 -0
  41. package/src/cmd-tasks-spec.ts +10 -3
  42. package/src/cmd-tasks.ts +8 -5
  43. package/src/cmd-test.ts +2 -1
  44. package/src/cmd-upgrade-spec.ts +8 -1
  45. package/src/cmd-upgrade.ts +15 -1
  46. package/src/cmd-verify.ts +9 -41
  47. package/src/codemods/agents-doc-row.ts +73 -0
  48. package/src/codemods/define-error-leaf.ts +37 -12
  49. package/src/codemods/docs-many-agents.ts +11 -15
  50. package/src/codemods/docs-worker-commands.ts +26 -0
  51. package/src/codemods/engine-fs.ts +9 -2
  52. package/src/codemods/index.ts +4 -0
  53. package/src/codemods/merge-drivers.ts +147 -0
  54. package/src/command.ts +3 -0
  55. package/src/db-applied-edits.ts +117 -0
  56. package/src/db-dev-wire.ts +18 -0
  57. package/src/db-diagnostics.ts +5 -10
  58. package/src/db-generate.ts +82 -7
  59. package/src/db-migrate-pass.ts +51 -0
  60. package/src/db-migrate-through-dev.ts +209 -0
  61. package/src/db-rollback-consent.ts +128 -0
  62. package/src/db-rollback-pass.ts +76 -0
  63. package/src/db-seed-generate.ts +5 -1
  64. package/src/db-seed.ts +7 -1
  65. package/src/deploy-verify-findings.ts +3 -0
  66. package/src/deploy-verify-grade.ts +3 -0
  67. package/src/deploy-verify-processes.ts +32 -0
  68. package/src/dev-boot.ts +3 -0
  69. package/src/dev-db-migrate.ts +155 -0
  70. package/src/dev-db-rollback.ts +33 -0
  71. package/src/dev-db-settled.ts +22 -0
  72. package/src/dev-lock-errors.ts +78 -0
  73. package/src/dev-lock-holder-dir.ts +64 -0
  74. package/src/dev-lock-live.ts +44 -0
  75. package/src/dev-lock.ts +59 -84
  76. package/src/dev-policy.ts +11 -8
  77. package/src/dev-rebuild-schema.ts +116 -13
  78. package/src/dev-rebuild.ts +13 -4
  79. package/src/dev-route-table.ts +7 -0
  80. package/src/dispatch.ts +21 -1
  81. package/src/doctor-api-listing.ts +114 -0
  82. package/src/doctor-guarded.ts +41 -0
  83. package/src/doctor-port.ts +90 -17
  84. package/src/doctor-probe.ts +36 -5
  85. package/src/doctor-processes-probe.ts +127 -0
  86. package/src/doctor-processes.ts +136 -0
  87. package/src/doctor-warnings.ts +17 -0
  88. package/src/error-codes-agents.ts +35 -0
  89. package/src/error-codes-processes.ts +30 -0
  90. package/src/error-codes-tooling.ts +2 -0
  91. package/src/error-codes.ts +12 -13
  92. package/src/errors-suite.ts +27 -0
  93. package/src/errors.ts +18 -22
  94. package/src/exercise-registration.ts +4 -3
  95. package/src/exercise-services.ts +13 -3
  96. package/src/framework-env.ts +7 -3
  97. package/src/framework-schema.ts +15 -5
  98. package/src/generate-files.ts +1 -0
  99. package/src/generate-grant-findings.ts +7 -5
  100. package/src/generate-grants.ts +9 -8
  101. package/src/generate-kinds.ts +30 -6
  102. package/src/generate-roles-file.ts +30 -0
  103. package/src/generate-slice-policy.ts +3 -3
  104. package/src/guard-sources.ts +1 -2
  105. package/src/guards.ts +2 -2
  106. package/src/heavy-env.ts +2 -0
  107. package/src/heavy-errors.ts +18 -0
  108. package/src/heavy-holders.ts +78 -0
  109. package/src/heavy-ledger.ts +56 -14
  110. package/src/heavy-pressure.ts +104 -0
  111. package/src/heavy.ts +31 -13
  112. package/src/i18n-registration.ts +22 -2
  113. package/src/island-harness.ts +2 -2
  114. package/src/job-budget.ts +4 -2
  115. package/src/job-registration.ts +64 -8
  116. package/src/jobs-queue-known.ts +43 -0
  117. package/src/mcp-errors-agents.ts +20 -0
  118. package/src/mcp-errors-doctor.ts +27 -0
  119. package/src/mcp-errors-processes.ts +23 -0
  120. package/src/mcp-errors.ts +15 -29
  121. package/src/mcp-host.ts +2 -2
  122. package/src/merge-driver-catalog.ts +58 -0
  123. package/src/merge-driver-config.ts +43 -0
  124. package/src/merge-driver-lines.ts +140 -0
  125. package/src/merge-state.ts +105 -0
  126. package/src/messages-db.ts +22 -1
  127. package/src/messages-processes.ts +13 -0
  128. package/src/messages-upgrade.ts +10 -0
  129. package/src/messages.ts +54 -4
  130. package/src/output-findings.ts +48 -21
  131. package/src/page-navigation.ts +5 -2
  132. package/src/parse.ts +37 -6
  133. package/src/policy-facts.ts +38 -21
  134. package/src/policy-row.ts +99 -0
  135. package/src/port-pair-free.ts +28 -0
  136. package/src/pwa-artifacts.ts +1 -1
  137. package/src/registry-lines.ts +110 -0
  138. package/src/registry.ts +2 -0
  139. package/src/retain-sweep.ts +1 -1
  140. package/src/retained-assets-boot.ts +1 -1
  141. package/src/role-replicator.ts +4 -1
  142. package/src/role-select.ts +86 -0
  143. package/src/role-start.ts +13 -55
  144. package/src/role-sync.ts +10 -5
  145. package/src/runtime-assets-site.ts +2 -2
  146. package/src/runtime-assets.ts +1 -1
  147. package/src/runtime-cache-frame.ts +46 -0
  148. package/src/runtime-cache-ttl.ts +23 -0
  149. package/src/runtime-cache.ts +33 -16
  150. package/src/runtime-database-ssl.ts +84 -0
  151. package/src/runtime-idempotency-scope.ts +16 -2
  152. package/src/runtime-jobs-share.ts +52 -0
  153. package/src/runtime-jobs.ts +43 -12
  154. package/src/runtime-queue.ts +18 -3
  155. package/src/runtime-render-document.ts +1 -2
  156. package/src/runtime-services.ts +8 -1
  157. package/src/schema-drift.ts +19 -2
  158. package/src/schema-dump-drift.ts +4 -1
  159. package/src/serve-boot-probe.ts +30 -2
  160. package/src/serve-boot.ts +11 -1
  161. package/src/serve-env.ts +39 -3
  162. package/src/serve.ts +61 -10
  163. package/src/site-asset-routes.ts +2 -2
  164. package/src/site-assets.ts +5 -158
  165. package/src/stop-run-start.ts +12 -0
  166. package/src/supervise-boot.ts +61 -0
  167. package/src/supervise-cgroup.ts +84 -0
  168. package/src/supervise-child.ts +206 -0
  169. package/src/supervise-count.ts +244 -0
  170. package/src/supervise-errors.ts +83 -0
  171. package/src/supervise-facts.ts +40 -0
  172. package/src/supervise-messages.ts +84 -0
  173. package/src/supervise-policy.ts +46 -0
  174. package/src/supervise-pool.ts +10 -0
  175. package/src/supervise-probe.ts +158 -0
  176. package/src/supervise-run.ts +54 -0
  177. package/src/supervise.ts +383 -0
  178. package/src/sw-precache-plan.ts +1 -1
  179. package/src/templates/generate-purge.ts +6 -6
  180. package/src/templates/guard-animated-layout-property.ts +2 -2
  181. package/src/templates/guard-bare-error.ts +1 -1
  182. package/src/templates/guard-error-declared.ts +2 -2
  183. package/src/templates/guard-focus-visible.ts +1 -1
  184. package/src/templates/guard-image-dimensions.ts +2 -2
  185. package/src/templates/guard-island-mount-clears.ts +1 -1
  186. package/src/templates/guard-native-confirm.ts +1 -1
  187. package/src/templates/guard-raw-breakpoint.ts +2 -2
  188. package/src/templates/guard-raw-colour.ts +2 -2
  189. package/src/templates/guard-raw-fetch.ts +1 -1
  190. package/src/templates/guard-raw-interval.ts +1 -1
  191. package/src/templates/guard-raw-length.ts +3 -3
  192. package/src/templates/guard-raw-motion.ts +97 -1
  193. package/src/templates/guard-raw-shadow.ts +1 -1
  194. package/src/templates/guard-raw-z-index.ts +1 -1
  195. package/src/templates/guard-released-forms.ts +58 -9
  196. package/src/templates/guard-repo-await-in-loop.ts +1 -1
  197. package/src/templates/guard-repo-raw-sql.ts +4 -4
  198. package/src/templates/guard-repo-unbounded.ts +1 -1
  199. package/src/templates/guard-runtime-pin.ts +1 -1
  200. package/src/templates/guard-semantic-interactive.ts +2 -2
  201. package/src/templates/guard-unbounded-fanout.ts +1 -1
  202. package/src/templates/guard-undeclared-custom-property.ts +3 -3
  203. package/src/templates/guard-undefined-style-class.ts +3 -3
  204. package/src/templates/guard-unzoned-date.ts +3 -3
  205. package/src/templates/query-slice.ts +82 -0
  206. package/src/templates/query.ts +76 -30
  207. package/src/templates/resource-page.ts +3 -2
  208. package/src/templates/scaffold-bin.ts +2 -0
  209. package/src/templates/scaffold-claude-commands.ts +6 -0
  210. package/src/templates/scaffold-claude.ts +4 -4
  211. package/src/templates/scaffold-container-compose.ts +47 -7
  212. package/src/templates/scaffold-docs.ts +7 -3
  213. package/src/templates/scaffold-gitattributes.ts +18 -1
  214. package/src/templates/scaffold-helm-templates.ts +9 -0
  215. package/src/templates/scaffold-repo.ts +5 -2
  216. package/src/templates/scaffold-test-services.ts +33 -11
  217. package/src/templates/shapes/offline.ts +0 -7
  218. package/src/templates/shapes/realtime.ts +2 -6
  219. package/src/templates/sign-in-action-tests.ts +6 -4
  220. package/src/templates/sign-in-challenge.ts +62 -0
  221. package/src/templates/sign-in-oidc-mfa.ts +31 -0
  222. package/src/templates/sign-in-oidc.ts +11 -3
  223. package/src/templates/sign-in-password.ts +18 -56
  224. package/src/test-only-shipped.ts +29 -2
  225. package/src/test-shards.ts +134 -42
  226. package/src/test-verdict.ts +79 -0
  227. package/src/test-workers.ts +15 -0
  228. package/src/upgrade-coverage-ratchet.ts +95 -0
  229. package/src/upgrade-gate-codemods.ts +5 -3
  230. package/src/upgrade-gate.ts +42 -4
  231. package/src/upgrade-merge-drivers.ts +25 -0
  232. package/src/upgrade-report.ts +32 -4
  233. package/src/upgrade-scope.ts +62 -0
  234. package/src/verify-checks.ts +2 -8
  235. package/src/verify-coverage-run.ts +4 -1
  236. package/src/verify-e2e.ts +21 -3
  237. package/src/verify-live.ts +38 -14
  238. package/src/verify-only.ts +67 -0
  239. package/src/verify-progress.ts +7 -3
  240. package/src/verify-run.ts +20 -2
  241. package/src/verify-services-stack.ts +165 -0
  242. package/src/verify-services.ts +84 -2
  243. package/src/verify-test-run.ts +6 -7
  244. package/src/verify-tests.ts +8 -2
  245. package/src/verify-typecheck.ts +25 -2
  246. package/src/workspace-checks.ts +4 -1
  247. package/wiki/Actions.md +66 -3
  248. package/wiki/Admin-Dashboard.md +2 -2
  249. package/wiki/Agents.md +5 -5
  250. package/wiki/Auth.md +20 -6
  251. package/wiki/Bare-VM.md +1 -1
  252. package/wiki/CI-Parallel-Gate.md +2 -1
  253. package/wiki/CLI-Reference.md +115 -42
  254. package/wiki/Caching-And-Invalidation.md +1 -1
  255. package/wiki/Client-Navigation.md +35 -5
  256. package/wiki/Configuration.md +12 -10
  257. package/wiki/Deployment.md +44 -4
  258. package/wiki/Entities-And-Migrations.md +17 -3
  259. package/wiki/FAQ.md +1 -1
  260. package/wiki/Getting-Started.md +2 -2
  261. package/wiki/Home.md +3 -3
  262. package/wiki/I18n.md +6 -4
  263. package/wiki/Installation.md +12 -11
  264. package/wiki/Interface-Rules.md +3 -1
  265. package/wiki/Jobs-And-Workflows.md +24 -4
  266. package/wiki/Known-Gaps.md +2 -2
  267. package/wiki/MCP-And-AI.md +48 -13
  268. package/wiki/Many-Agents.md +69 -2
  269. package/wiki/Migrations-And-Backfills.md +18 -0
  270. package/wiki/Notify.md +5 -3
  271. package/wiki/Observability.md +13 -0
  272. package/wiki/Outbound-HTTP.md +53 -2
  273. package/wiki/Policies-And-Authz.md +1 -1
  274. package/wiki/Queries-And-Live-Queries.md +2 -2
  275. package/wiki/Realtime.md +24 -7
  276. package/wiki/Routes-And-Render-Modes.md +2 -2
  277. package/wiki/Scheduled-Tasks.md +4 -1
  278. package/wiki/Static-Assets.md +5 -3
  279. package/wiki/Testing.md +64 -7
  280. package/wiki/Theming.md +6 -3
  281. package/wiki/Timezones-And-Dates.md +5 -1
  282. package/wiki/Troubleshooting.md +1 -0
  283. package/wiki/Tutorial-01-First-App.md +3 -3
  284. package/wiki/Tutorial-02-First-Feature.md +1 -1
  285. package/wiki/Tutorial-03-Auth-And-Admin.md +7 -6
  286. package/wiki/UI-Components.md +1 -0
  287. package/wiki/Upgrading.md +38 -0
@@ -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 });
@@ -134,6 +145,19 @@ export const humanLines = (
134
145
  funcs: Math.floor(gate.coverage.measured.funcs * 10) / 10,
135
146
  }),
136
147
  ]),
148
+ ...(gate?.coverageRaised === undefined
149
+ ? []
150
+ : [
151
+ msg('cli.upgrade.coverageRaised', {
152
+ file: gate.coverageRaised.file,
153
+ fromLines: gate.coverageRaised.from.lines,
154
+ fromFuncs: gate.coverageRaised.from.funcs,
155
+ toLines: gate.coverageRaised.to.lines,
156
+ toFuncs: gate.coverageRaised.to.funcs,
157
+ lines: Math.floor(gate.coverageRaised.measured.lines * 10) / 10,
158
+ funcs: Math.floor(gate.coverageRaised.measured.funcs * 10) / 10,
159
+ }),
160
+ ]),
137
161
  ...(gate === undefined || gate.exerciseFloor === null
138
162
  ? []
139
163
  : [
@@ -154,6 +178,9 @@ export const humanLines = (
154
178
  ...scripts
155
179
  .filter((script) => script.ok === false)
156
180
  .map((script) => msg('cli.upgrade.scriptRed', { name: script.name })),
181
+ ...(notRunOf(gate).length === 0
182
+ ? []
183
+ : [msg('cli.upgrade.notRun', { steps: notRunOf(gate).join(',') })]),
157
184
  msg('cli.upgrade.then', { then }),
158
185
  ];
159
186
  };
@@ -206,6 +233,7 @@ export const report = (
206
233
  doctorWarnings: gate?.doctorWarnings ?? [],
207
234
  exercise: gate?.exercise ?? null,
208
235
  exerciseFloor: gate?.exerciseFloor ?? null,
236
+ coverageRaised: gate?.coverageRaised ?? null,
209
237
  verify: gate?.verify ?? null,
210
238
  scripts,
211
239
  then,
@@ -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
+ }
@@ -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';
@@ -67,7 +66,7 @@ import { roleLoadFindings } from './verify-role-load';
67
66
  import type { VerifyStep } from './verify-step';
68
67
  import { fromExec, fromFindings, hostFindings } from './verify-step';
69
68
  import { TEST_STEPS } from './verify-tests';
70
- import { typecheckArgs } from './verify-typecheck';
69
+ import { typecheckArgs, typecheckFinding } from './verify-typecheck';
71
70
  import { checkPackageShape, fileSizeReport, hasWorkspacePackages } from './workspace-checks';
72
71
  import { checkExternalDependencies } from './workspace-external-deps';
73
72
  import { checkWorkspaceDependencies } from './workspace-graph';
@@ -92,12 +91,7 @@ export const VERIFY_STEPS: readonly VerifyStep[] = [
92
91
  const floor = await readVerifyFloor(ctx.root);
93
92
  const argv = await typecheckArgs(ctx.root, floor?.typecheckBin ?? 'tsc');
94
93
  const result = await runTypecheck(ctx, argv);
95
- return fromExec(result, {
96
- code: 'X_TYPECHECK_FAILED',
97
- cause: 'the project does not typecheck',
98
- // Joined, never spliced: `typecheckBin` is a value from the app's `x.verify.json`.
99
- fix: ['bunx', ...argv.map(quoteArg)].join(' '),
100
- });
94
+ return fromExec(result, typecheckFinding(result.stdout));
101
95
  },
102
96
  },
103
97
  {
@@ -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';
@@ -238,7 +239,9 @@ export async function runCovered(options: CoveredRunOptions): Promise<CoveredRun
238
239
  }),
239
240
  ],
240
241
  workers: width,
241
- ...(options.widthReason === undefined ? {} : { widthReason: options.widthReason }),
242
+ ...(options.widthReason === undefined
243
+ ? {}
244
+ : { widthReason: reachedWidth(width, want, options.widthReason) }),
242
245
  tests: countsOf(results),
243
246
  ...(first === undefined ? {} : { output }),
244
247
  ...(Object.keys(measured).length === 0 ? {} : { slowest: slowestOf(measured, options.files) }),
package/src/verify-e2e.ts CHANGED
@@ -7,7 +7,10 @@
7
7
  // `x.verify.json` requires `e2e` and ran nothing for want of a browser is red by `judgeE2eBrowser`,
8
8
  // with the command that installs one.
9
9
 
10
- import { ERROR_DOCS_URL } from '@ultimat3/core';
10
+ // why: Bun ships no synchronous existence check, and `isAppRoot` answers inside a sync predicate.
11
+ import { existsSync } from 'node:fs';
12
+ import { join } from 'node:path'; // why: Bun exposes no path-join primitive.
13
+ import { APP_CONFIG_FILE, ERROR_DOCS_URL } from '@ultimat3/core';
11
14
  import { CHROME_PATH_ENV, chromeCandidates, findChrome } from '@ultimat3/scraping/cdp';
12
15
  import { E2E_ROOT_ENV } from '@ultimat3/testing';
13
16
  import type { ExecResult } from './exec';
@@ -61,11 +64,26 @@ export async function withE2eApp(
61
64
  },
62
65
  run: (e2e: E2eRun) => Promise<ExecResult>,
63
66
  ): Promise<ExecResult> {
64
- const chrome = input.isApp ? await findChrome(input.hostEnv) : undefined;
65
- if (chrome === undefined) return run({ command: input.command, env: input.env });
67
+ if (!(await drivesBrowser(input.isApp, input.hostEnv))) {
68
+ return run({ command: input.command, env: input.env });
69
+ }
66
70
  return run(appE2eRun({ root: input.root, command: input.command, env: input.env }));
67
71
  }
68
72
 
73
+ /** Whether `root` is an app: its `app.config.ts` is what the e2e preload boots. */
74
+ export const isAppRoot = (root: string): boolean => existsSync(join(root, APP_CONFIG_FILE));
75
+
76
+ /**
77
+ * Whether an e2e run drives a browser: an app, on a machine with one. The ONE answer
78
+ * `x verify`'s `e2e` step and `x test`'s e2e pass launch on, so the two never disagree.
79
+ */
80
+ export async function drivesBrowser(
81
+ isApp: boolean,
82
+ hostEnv: Readonly<Record<string, string | undefined>>,
83
+ ): Promise<boolean> {
84
+ return isApp && (await findChrome(hostEnv)) !== undefined;
85
+ }
86
+
69
87
  /** The floored e2e step that ran nothing because this machine has no browser to drive. */
70
88
  export const E2E_BROWSER_MISSING = 'X_VERIFY_E2E_BROWSER_MISSING';
71
89
 
@@ -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.
@@ -0,0 +1,165 @@
1
+ // Which test stack a compose file means on this machine, and whose it is. Compose names a project
2
+ // after the app, so two checkouts, or two unrelated apps with one name, land on the same containers;
3
+ // the labels compose writes on each one say which checkout started them.
4
+
5
+ // why: Bun ships no synchronous existence check or realpath primitive.
6
+ import { existsSync, realpathSync } from 'node:fs';
7
+ import type { Runner } from './exec';
8
+ import { TEST_COMPOSE_PATH } from './templates/scaffold-test-services';
9
+
10
+ const COMPOSE = ['docker', 'compose', '-f', TEST_COMPOSE_PATH] as const;
11
+
12
+ /** Every container of this file's project, stopped ones too, with its labels. */
13
+ export const SERVICES_LIST: readonly string[] = [...COMPOSE, 'ps', '--all', '--format', 'json'];
14
+ /** `--volumes`: the images declare anonymous volumes, and a stopped stack should leave none. */
15
+ export const SERVICES_STOP: readonly string[] = [...COMPOSE, 'down', '--volumes'];
16
+ /** Every compose project on the machine. */
17
+ export const STACKS_LIST: readonly string[] = [
18
+ 'docker',
19
+ 'compose',
20
+ 'ls',
21
+ '--all',
22
+ '--format',
23
+ 'json',
24
+ ];
25
+
26
+ /** `1` says a stack another app started is shared on purpose. */
27
+ export const SHARED_ENV = 'ULTIMATE_TEST_SERVICES_SHARED';
28
+
29
+ export interface TestStack {
30
+ readonly project: string;
31
+ readonly services: readonly string[];
32
+ /** The checkouts whose compose file started these containers. */
33
+ readonly roots: readonly string[];
34
+ /** Whether any container is up: `ps --all` lists exited ones too, and those hold no server. */
35
+ readonly running: boolean;
36
+ }
37
+
38
+ export type StackRead =
39
+ | { readonly answered: true; readonly stack?: TestStack }
40
+ | { readonly answered: false };
41
+
42
+ export type StackRelation =
43
+ | { readonly kind: 'own' }
44
+ | { readonly kind: 'shared'; readonly with: string; readonly why: 'same-app' | 'declared' }
45
+ | { readonly kind: 'collision'; readonly with: string; readonly running: boolean };
46
+
47
+ type Env = Readonly<Record<string, string | undefined>>;
48
+
49
+ const CONFIG_FILES = /(?:^|,)com\.docker\.compose\.project\.config_files=([^,]*)/;
50
+ const COMPOSE_SUFFIX = `/${TEST_COMPOSE_PATH}`;
51
+
52
+ /** The checkout a compose file sits in, or `undefined` for a file at any other path. */
53
+ export const rootOfCompose = (file: string): string | undefined =>
54
+ file.endsWith(COMPOSE_SUFFIX) ? file.slice(0, -COMPOSE_SUFFIX.length) : undefined;
55
+
56
+ const parseJson = (text: string): unknown => {
57
+ try {
58
+ return JSON.parse(text);
59
+ } catch {
60
+ return undefined;
61
+ }
62
+ };
63
+
64
+ /** One JSON document per line, or (older compose) one array. Anything else is no row. */
65
+ export function jsonRows(stdout: string): readonly Record<string, unknown>[] {
66
+ const text = stdout.trim();
67
+ const values: unknown[] = text.startsWith('[')
68
+ ? [parseJson(text)].flat()
69
+ : text.split('\n').map(parseJson);
70
+ return values.filter(
71
+ (value): value is Record<string, unknown> => typeof value === 'object' && value !== null,
72
+ );
73
+ }
74
+
75
+ const stringOf = (value: unknown): string => (typeof value === 'string' ? value : '');
76
+
77
+ /** Compose's states for a container that still holds its ports; `exited`/`created`/`dead` do not. */
78
+ const LIVE_STATES: ReadonlySet<string> = new Set(['running', 'restarting', 'paused']);
79
+
80
+ export function parseStack(stdout: string): TestStack | undefined {
81
+ const rows = jsonRows(stdout).filter((row) => stringOf(row['Project']) !== '');
82
+ const project = stringOf(rows[0]?.['Project']);
83
+ if (project === '') return undefined;
84
+ const roots = rows.flatMap((row) => {
85
+ const file = CONFIG_FILES.exec(stringOf(row['Labels']))?.[1];
86
+ const root = file === undefined ? undefined : rootOfCompose(file);
87
+ return root === undefined ? [] : [root];
88
+ });
89
+ return {
90
+ project,
91
+ services: [...new Set(rows.map((row) => stringOf(row['Service'])))].sort(),
92
+ roots: [...new Set(roots)],
93
+ running: rows.some((row) => LIVE_STATES.has(stringOf(row['State']))),
94
+ };
95
+ }
96
+
97
+ /** What compose says is up for this checkout's file. `answered: false` means it could not say. */
98
+ export async function readStack(root: string, runner: Runner): Promise<StackRead> {
99
+ try {
100
+ const result = await runner(SERVICES_LIST, { cwd: root });
101
+ if (!result.ok) return { answered: false };
102
+ const stack = parseStack(result.stdout);
103
+ return stack === undefined ? { answered: true } : { answered: true, stack };
104
+ } catch {
105
+ return { answered: false }; // No `docker` on PATH.
106
+ }
107
+ }
108
+
109
+ const real = (path: string): string => {
110
+ try {
111
+ return realpathSync(path);
112
+ } catch {
113
+ return path;
114
+ }
115
+ };
116
+
117
+ /** The checkouts other than `root` that started this stack and still exist. */
118
+ export const otherRoots = (stack: TestStack, root: string): readonly string[] =>
119
+ stack.roots.filter((other) => real(other) !== real(root) && existsSync(other));
120
+
121
+ async function gitFact(cwd: string, args: readonly string[], runner: Runner) {
122
+ try {
123
+ const result = await runner(['git', ...args], { cwd });
124
+ const text = result.stdout.trim();
125
+ return result.ok && text !== '' ? text : undefined;
126
+ } catch {
127
+ return undefined;
128
+ }
129
+ }
130
+
131
+ /** One app in two checkouts shares its first commit, or (a shallow clone) its origin. */
132
+ async function sameApp(one: string, two: string, runner: Runner): Promise<boolean> {
133
+ for (const args of [
134
+ ['rev-list', '--max-parents=0', 'HEAD'],
135
+ ['remote', 'get-url', 'origin'],
136
+ ]) {
137
+ const [first, second] = await Promise.all([
138
+ gitFact(one, args, runner),
139
+ gitFact(two, args, runner),
140
+ ]);
141
+ if (first !== undefined && first === second) return true;
142
+ }
143
+ return false;
144
+ }
145
+
146
+ /**
147
+ * What the stack is to this checkout. A checkout that no longer exists can use nothing, so its
148
+ * stack is simply there to reuse. One git cannot tie to this app is a collision: a shared name
149
+ * proves nothing, and the caller can still say the share is intended.
150
+ */
151
+ export async function relationTo(
152
+ stack: TestStack,
153
+ root: string,
154
+ runner: Runner,
155
+ env: Env,
156
+ ): Promise<StackRelation> {
157
+ let shared: StackRelation = { kind: 'own' };
158
+ for (const other of otherRoots(stack, root)) {
159
+ if (await sameApp(root, other, runner))
160
+ shared = { kind: 'shared', with: other, why: 'same-app' };
161
+ else if (env[SHARED_ENV] === '1') shared = { kind: 'shared', with: other, why: 'declared' };
162
+ else return { kind: 'collision', with: other, running: stack.running };
163
+ }
164
+ return shared;
165
+ }