@ultimat3/cli 31.45.0 → 31.47.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 (105) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +1 -1
  3. package/package.json +29 -29
  4. package/src/affected.ts +3 -2
  5. package/src/app-config-load.ts +8 -5
  6. package/src/app-mcp.ts +2 -5
  7. package/src/app-runtime.ts +4 -4
  8. package/src/cmd-cache.ts +8 -4
  9. package/src/cmd-deploy-compose.ts +11 -12
  10. package/src/cmd-deploy-helm.ts +5 -8
  11. package/src/cmd-exercise-spec.ts +2 -2
  12. package/src/cmd-exercise.ts +7 -19
  13. package/src/cmd-new.ts +4 -3
  14. package/src/cmd-planned.ts +11 -76
  15. package/src/cmd-shot-matrix.ts +3 -2
  16. package/src/cmd-token.ts +11 -3
  17. package/src/codemods/ci-weekly-schedule.ts +61 -0
  18. package/src/codemods/index.ts +2 -0
  19. package/src/codemods/vendored-guards.ts +3 -5
  20. package/src/codemods/verify-floor-skips.ts +4 -6
  21. package/src/codemods/verify-floor-steps.ts +4 -3
  22. package/src/db-seed.ts +3 -2
  23. package/src/dispatch.ts +2 -11
  24. package/src/duplicate-packages.ts +4 -4
  25. package/src/exercise-findings.ts +4 -3
  26. package/src/exercise-floor.ts +1 -1
  27. package/src/exercise-seed.ts +34 -0
  28. package/src/fix-command.ts +2 -3
  29. package/src/flag-reads.ts +6 -3
  30. package/src/generate-files.ts +10 -6
  31. package/src/gitignore.ts +4 -3
  32. package/src/guards-built-in.ts +3 -6
  33. package/src/guards.ts +5 -8
  34. package/src/island-bundle.ts +3 -2
  35. package/src/island-sources.ts +4 -3
  36. package/src/island-states-load.ts +4 -3
  37. package/src/island-store.ts +3 -2
  38. package/src/json-merge.ts +8 -6
  39. package/src/lint-findings.ts +4 -7
  40. package/src/mcp-errors.ts +1 -1
  41. package/src/messages.ts +1 -0
  42. package/src/prerender-out.ts +4 -3
  43. package/src/publish-closure.ts +4 -6
  44. package/src/pwa-manifest-locales.ts +5 -8
  45. package/src/registry.ts +0 -7
  46. package/src/root-env.ts +3 -2
  47. package/src/runtime-admin.ts +2 -4
  48. package/src/runtime-keys.ts +5 -2
  49. package/src/static-report.ts +5 -8
  50. package/src/templates/github/ci-schedule.ts +86 -0
  51. package/src/templates/github/ci.yml.ts +6 -8
  52. package/src/templates/github/dependabot.yml.ts +6 -1
  53. package/src/templates/invite-tests.ts +43 -6
  54. package/src/templates/invite.ts +12 -14
  55. package/src/templates/scaffold-docs.ts +1 -0
  56. package/src/templates/shapes/overlay.ts +4 -7
  57. package/src/templates/sign-in-action-tests.ts +71 -21
  58. package/src/templates/sign-in-password.ts +9 -5
  59. package/src/templates/sign-in-shared.ts +7 -15
  60. package/src/upgrade-guards-baseline.ts +3 -5
  61. package/src/verify-merge-skips.ts +2 -4
  62. package/src/verify-merge.ts +13 -8
  63. package/src/verify-part-step.ts +5 -7
  64. package/src/worker-bundle.ts +4 -2
  65. package/wiki/Actions.md +69 -5
  66. package/wiki/Agents.md +13 -0
  67. package/wiki/Auth.md +4 -0
  68. package/wiki/Batching-And-Preloading.md +77 -3
  69. package/wiki/CLI-Reference.md +18 -5
  70. package/wiki/Caching-And-Invalidation.md +76 -23
  71. package/wiki/Client-Navigation.md +2 -0
  72. package/wiki/Configuration.md +17 -4
  73. package/wiki/Entities-And-Migrations.md +168 -6
  74. package/wiki/FAQ.md +1 -1
  75. package/wiki/Feature-Flags.md +3 -0
  76. package/wiki/Getting-Started.md +27 -1
  77. package/wiki/Jobs-And-Workflows.md +70 -13
  78. package/wiki/Known-Gaps.md +58 -49
  79. package/wiki/MCP-And-AI.md +43 -3
  80. package/wiki/Mail.md +6 -0
  81. package/wiki/Migrations-And-Backfills.md +13 -0
  82. package/wiki/Money.md +20 -1
  83. package/wiki/N-Plus-One-Detection.md +31 -1
  84. package/wiki/Notify.md +13 -2
  85. package/wiki/PWA-And-Offline.md +34 -4
  86. package/wiki/Policies-And-Authz.md +27 -5
  87. package/wiki/Queries-And-Live-Queries.md +41 -4
  88. package/wiki/Realtime.md +22 -0
  89. package/wiki/Resource-Management.md +6 -1
  90. package/wiki/Routes-And-Render-Modes.md +54 -6
  91. package/wiki/SEO.md +24 -2
  92. package/wiki/Scheduled-Tasks.md +29 -11
  93. package/wiki/Scraping.md +33 -2
  94. package/wiki/Static-Assets.md +1 -0
  95. package/wiki/Storage-And-Uploads.md +8 -1
  96. package/wiki/Testing.md +120 -13
  97. package/wiki/The-Eight-Primitives.md +125 -6
  98. package/wiki/Timezones-And-Dates.md +13 -5
  99. package/wiki/Troubleshooting.md +1 -1
  100. package/wiki/Tutorial-02-First-Feature.md +6 -0
  101. package/wiki/Tutorial-03-Auth-And-Admin.md +8 -0
  102. package/wiki/Tutorial-04-Jobs-And-Realtime.md +40 -2
  103. package/wiki/Tutorial-06-Growing-Up.md +1 -2
  104. package/wiki/UI-Components.md +14 -5
  105. package/wiki/Upgrading.md +42 -4
@@ -7,7 +7,7 @@
7
7
  // that names a different set of islands than the app has, or a chunk whose bytes do not hash to
8
8
  // what the index recorded is refused, and the boot builds instead — and says so.
9
9
 
10
- import { join, relative, sep } from 'node:path'; // why: Bun ships no path-join primitive.
10
+ import { join } from 'node:path'; // why: Bun ships no path-join primitive.
11
11
  import { frameworkVersion } from '@ultimat3/core';
12
12
  import { contentHash, loadStylesheet } from '@ultimat3/render/server';
13
13
  import { IslandBuildFailedError } from './errors';
@@ -17,6 +17,7 @@ import type { IslandRealtime } from './island-realtime-state';
17
17
  import type { SourceDigester, SourceStamp } from './island-sources';
18
18
  import { changedSource, isRecordableSource, sourceDigester, stampSources } from './island-sources';
19
19
  import { islandStylesheets } from './island-styles';
20
+ import { posixRelative } from './posix-path';
20
21
  import { PREBUILT_ISLANDS_DIR } from './serve-prebuilt-paths';
21
22
 
22
23
  /** App-root-relative, inside the image's prebuilt store (`serve-prebuilt-paths.ts` says why there). */
@@ -118,7 +119,7 @@ export async function writeIslandStore(
118
119
  });
119
120
  }
120
121
  const stylesheets = islandStylesheets()
121
- .map((path) => relative(root, path).split(sep).join('/'))
122
+ .map((path) => posixRelative(root, path))
122
123
  .filter((path) => !path.startsWith('..'))
123
124
  .sort();
124
125
  const index: StoreIndex = {
package/src/json-merge.ts CHANGED
@@ -2,12 +2,11 @@
2
2
  // nested (`{ site: { home: { title } } }`) — a shallow spread of two generators' contributions
3
3
  // under the same top-level key drops one of them entirely, and neither generator can see the other.
4
4
 
5
+ import { isJsonObject } from '@ultimat3/core';
6
+
5
7
  /** A parsed JSON object: the only shape a `merge: 'json'` file is ever allowed to hold. */
6
8
  export type JsonObject = Record<string, unknown>;
7
9
 
8
- const isObject = (value: unknown): value is JsonObject =>
9
- typeof value === 'object' && value !== null && !Array.isArray(value);
10
-
11
10
  /**
12
11
  * `incoming` merged under `held`, leaf by leaf. `held` always wins — on disk it is the file a
13
12
  * human may have translated, and in `dedupe` it is the contribution that got there first — so a
@@ -30,7 +29,7 @@ export function mergeJsonDeep(
30
29
  continue;
31
30
  }
32
31
  const current = held[key];
33
- if (!isObject(current) || !isObject(value)) continue;
32
+ if (!isJsonObject(current) || !isJsonObject(value)) continue;
34
33
  const nested = mergeJsonDeep(current, value);
35
34
  if (!nested.gained) continue;
36
35
  merged[key] = nested.merged;
@@ -48,7 +47,7 @@ const isSorted = (keys: readonly string[]): boolean =>
48
47
  /** Every key of every level, sorted — the order a generator's own fresh output is written in. */
49
48
  export function sortJsonDeep(value: unknown): unknown {
50
49
  if (Array.isArray(value)) return value.map(sortJsonDeep);
51
- if (!isObject(value)) return value;
50
+ if (!isJsonObject(value)) return value;
52
51
  return Object.fromEntries(
53
52
  Object.keys(value)
54
53
  .sort(byCodeUnit)
@@ -80,7 +79,10 @@ export function mergeJsonInPlace(held: JsonObject, incoming: JsonObject): JsonOb
80
79
  if (!Object.hasOwn(held, key)) return [key, sortJsonDeep(incoming[key])];
81
80
  const current = held[key];
82
81
  const next = incoming[key];
83
- return [key, isObject(current) && isObject(next) ? mergeJsonInPlace(current, next) : current];
82
+ return [
83
+ key,
84
+ isJsonObject(current) && isJsonObject(next) ? mergeJsonInPlace(current, next) : current,
85
+ ];
84
86
  }),
85
87
  );
86
88
  }
@@ -3,7 +3,7 @@
3
3
  // said `bunx biome check --write .`, which exits "Skipped 1 suggested fixes", still red; a finding
4
4
  // per formatted file was twenty commands for one keystroke's worth of work (plan 101 19b, Y1).
5
5
 
6
- import { ERROR_DOCS_URL } from '@ultimat3/core';
6
+ import { ERROR_DOCS_URL, isJsonObject } from '@ultimat3/core';
7
7
  import { commentSafe } from './comment-safe';
8
8
  import type { ExecResult } from './exec';
9
9
  import { execOutput } from './exec';
@@ -27,12 +27,9 @@ interface Diagnostic {
27
27
  readonly line: number;
28
28
  }
29
29
 
30
- const isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>
31
- typeof value === 'object' && value !== null;
32
-
33
30
  /** Only what fails the step. `info` and `warning` exit 0, so they cannot be why it is red. */
34
31
  const diagnosticFrom = (value: unknown): Diagnostic | undefined => {
35
- if (!isRecord(value) || !isRecord(value['location'])) return undefined;
32
+ if (!isJsonObject(value) || !isJsonObject(value['location'])) return undefined;
36
33
  const { severity, category, message, location } = value as {
37
34
  severity?: unknown;
38
35
  category?: unknown;
@@ -42,7 +39,7 @@ const diagnosticFrom = (value: unknown): Diagnostic | undefined => {
42
39
  if (severity !== 'error' && severity !== 'fatal') return undefined;
43
40
  const { path, start } = location;
44
41
  if (typeof category !== 'string' || typeof path !== 'string') return undefined;
45
- const line = isRecord(start) && typeof start['line'] === 'number' ? start['line'] : 0;
42
+ const line = isJsonObject(start) && typeof start['line'] === 'number' ? start['line'] : 0;
46
43
  return { category, message: typeof message === 'string' ? message : category, path, line };
47
44
  };
48
45
 
@@ -92,7 +89,7 @@ export function lintFindings(stdout: string): readonly Finding[] | undefined {
92
89
  } catch {
93
90
  return undefined;
94
91
  }
95
- if (!isRecord(report) || !Array.isArray(report['diagnostics'])) return undefined;
92
+ if (!isJsonObject(report) || !Array.isArray(report['diagnostics'])) return undefined;
96
93
  const diagnostics = report['diagnostics'].flatMap((value) => {
97
94
  const diagnostic = diagnosticFrom(value);
98
95
  return diagnostic === undefined ? [] : [diagnostic];
package/src/mcp-errors.ts CHANGED
@@ -369,7 +369,7 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
369
369
  X_ASSET_RETAIN_UNDECLARED:
370
370
  "edit app.config.ts: add assets: { retain: { disk: 'assets', builds: 3 } }, naming a disk your defineStorage({ disks }) declares that every web pod reads",
371
371
  X_EXERCISE_UNPROVEN_ABOVE_FLOOR:
372
- 'x exercise --json # each unproven record in .x/exercise.json names the proof and its reason: fix the seed or the override it names; the floor only falls',
372
+ 'x exercise --json # re-measures at the constant seed the gate runs (a floor from before 31.47.0 was measured under random seeds); each unproven record in .x/exercise.json names the proof and its reason: fix the seed helper or override it names, assuming no order between sized calls; the floor only falls',
373
373
  X_ENV_NAME_RESERVED:
374
374
  'edit app.config.ts: add an APP_ prefix to the envSchema name the finding cites (or delete it where the value is meant for the framework); then: x env example --json && x doctor --json',
375
375
  X_FRAMEWORK_PIN_RANGE:
package/src/messages.ts CHANGED
@@ -137,6 +137,7 @@ const CATALOG = {
137
137
  'cli.exercise.none': 'this app registers no action, query or job: nothing to exercise',
138
138
  'cli.exercise.summary':
139
139
  '{total} primitive(s): {reached} reached, {refused} refused, {off} off, {unreached} unreached — {file}',
140
+ 'cli.exercise.seed': 'seed {seed} — replay this pass: x exercise --seed {seed} --json',
140
141
  'cli.exercise.phases': 'took {total} ms — {phases} — slowest: {slowest}',
141
142
  'cli.exercise.slowest': 'slowest: {primitive} · {proof} {ms} ms',
142
143
  // One rendering of "this file was written", for every command that writes files — `x g`, its
@@ -4,8 +4,9 @@
4
4
  // `--out apps` deleted the app's pages and `--out .x` its embedded dev database.
5
5
 
6
6
  import { lstat, readdir, rm } from 'node:fs/promises'; // why: Bun has no recursive delete or readdir.
7
- import { isAbsolute, join, relative, resolve, sep } from 'node:path'; // why: Bun ships no path resolve/relative.
7
+ import { isAbsolute, join, resolve } from 'node:path'; // why: Bun ships no path resolve.
8
8
  import { UltimateError } from '@ultimat3/core';
9
+ import { posixRelative } from './posix-path';
9
10
 
10
11
  /** Written into every export directory a build empties: the proof the next build may empty it. */
11
12
  export const EXPORT_MARKER = '.x-export';
@@ -21,8 +22,8 @@ const MARKER_TEXT =
21
22
 
22
23
  /** True when `dir` is `root` itself or one of its ancestors. */
23
24
  const containsRoot = (dir: string, root: string): boolean => {
24
- const up = relative(resolve(dir), resolve(root));
25
- return up === '' || (up !== '..' && !up.startsWith(`..${sep}`) && !isAbsolute(up));
25
+ const up = posixRelative(resolve(dir), resolve(root));
26
+ return up === '' || (up !== '..' && !up.startsWith('../') && !isAbsolute(up));
26
27
  };
27
28
 
28
29
  /** Why `out` is not the build's to empty, or `undefined` when it is. */
@@ -3,7 +3,7 @@
3
3
  // `src/**/*-fixture.ts`, so a module an entry reaches under that suffix is a published package
4
4
  // that fails on import — and the defect is the name, not the exclusion.
5
5
 
6
- import { ERROR_DOCS_URL } from '@ultimat3/core';
6
+ import { ERROR_DOCS_URL, isJsonObject } from '@ultimat3/core';
7
7
  import type { ClosureHost } from './import-closure';
8
8
  import { importClosure } from './import-closure';
9
9
  import type { Finding } from './output';
@@ -15,13 +15,11 @@ export const FIXTURE_SUFFIX = '-fixture.ts';
15
15
  /** A package directory, read by package-relative POSIX path. */
16
16
  export type PackageReader = Pick<ClosureHost, 'read'>;
17
17
 
18
- const isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>
19
- typeof value === 'object' && value !== null;
20
-
21
18
  /** Every string under `exports` / `bin`, whatever the nesting: a condition map is still a file. */
22
19
  const targetsOf = (value: unknown): readonly string[] => {
23
20
  if (typeof value === 'string') return [value];
24
- return isRecord(value) ? Object.values(value).flatMap(targetsOf) : [];
21
+ // An array is walked too: `exports` allows a fallback list (`".": ["./a.js", { … }]`).
22
+ return Array.isArray(value) || isJsonObject(value) ? Object.values(value).flatMap(targetsOf) : [];
25
23
  };
26
24
 
27
25
  /**
@@ -30,7 +28,7 @@ const targetsOf = (value: unknown): readonly string[] => {
30
28
  * entry to walk from.
31
29
  */
32
30
  export function entryFilesOf(manifest: unknown): readonly string[] {
33
- if (!isRecord(manifest)) return [];
31
+ if (!isJsonObject(manifest)) return [];
34
32
  const targets = [...targetsOf(manifest['exports']), ...targetsOf(manifest['bin'])];
35
33
  const files = targets
36
34
  .map((target) => target.replace(/^\.\//, ''))
@@ -2,7 +2,7 @@
2
2
  // `lang`, its `start_url`, its text and its shortcut URLs. `pwa-artifacts.ts` builds one manifest per
3
3
  // routed locale from this; the `pwa` block is read structurally, for `colorsOf`'s reason there.
4
4
 
5
- import { localeSegment, localizePath } from '@ultimat3/core';
5
+ import { isJsonObject, localeSegment, localizePath } from '@ultimat3/core';
6
6
  import type { AppLocaleSet } from '@ultimat3/i18n/app-catalogs';
7
7
  import type {
8
8
  ManifestIcon,
@@ -17,9 +17,6 @@ export interface AppLocales {
17
17
  readonly fallback: string;
18
18
  }
19
19
 
20
- const isRecord = (value: unknown): value is Record<string, unknown> =>
21
- typeof value === 'object' && value !== null;
22
-
23
20
  const strings = (value: unknown): readonly string[] =>
24
21
  Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : [];
25
22
 
@@ -45,7 +42,7 @@ export const spellIn = (path: string, locale: string, locales: AppLocales): stri
45
42
  */
46
43
  function textIn(value: unknown, locale: string, locales: AppLocales): string | undefined {
47
44
  if (typeof value === 'string') return value.trim() === '' ? undefined : value;
48
- if (!isRecord(value)) return undefined;
45
+ if (!isJsonObject(value)) return undefined;
49
46
  for (const key of [locale, locales.fallback]) {
50
47
  const entry = value[key];
51
48
  if (typeof entry === 'string' && entry.trim() !== '') return entry;
@@ -58,7 +55,7 @@ const PURPOSES = new Set(['any', 'maskable', 'monochrome']);
58
55
  function iconsOf(value: unknown): readonly ManifestIcon[] {
59
56
  if (!Array.isArray(value)) return [];
60
57
  return value.flatMap((icon): readonly ManifestIcon[] => {
61
- if (!isRecord(icon)) return [];
58
+ if (!isJsonObject(icon)) return [];
62
59
  const { src, sizes, type, purpose } = icon;
63
60
  if (typeof src !== 'string' || typeof sizes !== 'string' || typeof type !== 'string') return [];
64
61
  return [
@@ -77,7 +74,7 @@ function iconsOf(value: unknown): readonly ManifestIcon[] {
77
74
  function shortcutsIn(value: unknown, locale: string, locales: AppLocales): ManifestShortcut[] {
78
75
  if (!Array.isArray(value)) return [];
79
76
  return value.flatMap((shortcut): ManifestShortcut[] => {
80
- if (!isRecord(shortcut) || typeof shortcut['url'] !== 'string') return [];
77
+ if (!isJsonObject(shortcut) || typeof shortcut['url'] !== 'string') return [];
81
78
  const name = textIn(shortcut['name'], locale, locales);
82
79
  if (name === undefined) return [];
83
80
  const shortName = textIn(shortcut['shortName'], locale, locales);
@@ -98,7 +95,7 @@ function shortcutsIn(value: unknown, locale: string, locales: AppLocales): Manif
98
95
  function screenshotsIn(value: unknown, locale: string, locales: AppLocales): ManifestScreenshot[] {
99
96
  if (!Array.isArray(value)) return [];
100
97
  return value.flatMap((shot): ManifestScreenshot[] => {
101
- if (!isRecord(shot)) return [];
98
+ if (!isJsonObject(shot)) return [];
102
99
  const src = textIn(shot['src'], locale, locales);
103
100
  const { sizes, type, formFactor } = shot;
104
101
  if (src === undefined || typeof sizes !== 'string' || typeof type !== 'string') return [];
package/src/registry.ts CHANGED
@@ -40,7 +40,6 @@ import { mailSpec } from './cmd-mail-spec';
40
40
  import { manifestSpec } from './cmd-manifest-spec';
41
41
  import { mcpSpec } from './cmd-mcp-spec';
42
42
  import { newSpec } from './cmd-new-spec';
43
- import { plannedCommands } from './cmd-planned';
44
43
  import { policySpec } from './cmd-policy-spec';
45
44
  import { prSpec } from './cmd-pr-spec';
46
45
  import { actionsSpec, entitiesSpec, queriesSpec } from './cmd-registries-spec';
@@ -141,14 +140,8 @@ export const LAZY_COMMANDS: readonly LazyCommand[] = [
141
140
  lazy(statusSpec, async () => (await import('./cmd-status')).statusCommand),
142
141
  ];
143
142
 
144
- /**
145
- * Planned last, so `x help` reads shipped-first and the tail is honestly labelled. They are in the
146
- * registry rather than absent from it because "not built yet" and "not a command" are different
147
- * facts, and only one of them is true — see `cmd-planned.ts`.
148
- */
149
143
  export const COMMANDS: readonly CliCommand[] = [
150
144
  ...LAZY_COMMANDS,
151
- ...plannedCommands(),
152
145
  createHelpCommand(() => SPECS),
153
146
  createVersionCommand(cliVersion),
154
147
  ];
package/src/root-env.ts CHANGED
@@ -3,8 +3,9 @@
3
3
  // run from `apps/web` found the app and none of its `.env`, and silently used the embedded
4
4
  // database. Loaded once, after the root is known, never overriding a real environment variable.
5
5
 
6
- import { isAbsolute, join, relative, resolve } from 'node:path'; // why: Bun ships no path join/resolve.
6
+ import { isAbsolute, join, resolve } from 'node:path'; // why: Bun ships no path join/resolve.
7
7
  import { findAppRoot } from './app-root';
8
+ import { posixRelative } from './posix-path';
8
9
 
9
10
  type Env = Readonly<Record<string, string | undefined>>;
10
11
 
@@ -122,7 +123,7 @@ async function envFilesIn(dir: string, names: readonly string[]): Promise<Map<st
122
123
 
123
124
  /** True when `dir` is `root` or below it. */
124
125
  const isWithin = (root: string, dir: string): boolean => {
125
- const rel = relative(resolve(root), resolve(dir));
126
+ const rel = posixRelative(resolve(root), resolve(dir));
126
127
  return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));
127
128
  };
128
129
 
@@ -4,6 +4,7 @@
4
4
  // nothing else: which screen a URL names, who may see it and what it renders are the admin's.
5
5
 
6
6
  import type { AdminApp, AdminRouteConfig } from '@ultimat3/admin';
7
+ import { isJsonObject } from '@ultimat3/core';
7
8
  import type { Route, RouteMeta } from '@ultimat3/http';
8
9
  import { asCtx, html, redirect, routeNotFound } from '@ultimat3/http';
9
10
  import type { RouteEntry } from '@ultimat3/render';
@@ -91,7 +92,7 @@ async function answer(
91
92
  url: request.url.href,
92
93
  method,
93
94
  // A POST with no body is a form with no fields — a button-only form posts exactly that.
94
- form: method === 'POST' ? (isRecord(form) ? form : {}) : null,
95
+ form: method === 'POST' ? (isJsonObject(form) ? form : {}) : null,
95
96
  });
96
97
  if (response.kind === 'redirect') {
97
98
  // 303, always: the browser must GET the page it lands on, not re-POST the form at it.
@@ -116,9 +117,6 @@ async function answer(
116
117
  return html(document, { status: result.status, headers: result.headers });
117
118
  }
118
119
 
119
- const isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>
120
- typeof value === 'object' && value !== null && !Array.isArray(value);
121
-
122
120
  const METHODS: readonly ('GET' | 'POST')[] = ['GET', 'POST'];
123
121
 
124
122
  /** A file route on a mounted path exists only by a claim the mount accepted (`registerRoute`). */
@@ -17,8 +17,11 @@ const REMOVED: Readonly<Record<string, string>> = Object.freeze({
17
17
  const isPendingPort = (key: string): boolean =>
18
18
  (ADAPTER_PORT_NAMES as readonly string[]).includes(key) && !isWired(key);
19
19
 
20
- /** Throws on the first key `RuntimeOverrides` does not declare. `file` is root-relative. */
21
- export function assertRuntimeKeys(file: string, runtime: Readonly<Record<string, unknown>>): void {
20
+ /**
21
+ * Throws on the first key `RuntimeOverrides` does not declare. `file` is root-relative. `object`,
22
+ * not a record: only its own keys are read, so an array export is refused by its index keys too.
23
+ */
24
+ export function assertRuntimeKeys(file: string, runtime: object): void {
22
25
  for (const key of Object.keys(runtime)) {
23
26
  if (isWired(key) || EXTENSIONS.has(key)) continue;
24
27
  const named = renderCauseValue(key);
@@ -10,7 +10,7 @@
10
10
  import { rm } from 'node:fs/promises';
11
11
  import { join } from 'node:path';
12
12
  import type { RenderMode } from '@ultimat3/core';
13
- import { RENDER_MODES, SURFACES } from '@ultimat3/core';
13
+ import { isJsonObject, RENDER_MODES, SURFACES } from '@ultimat3/core';
14
14
  import type { Surface } from '@ultimat3/render';
15
15
  import { SURFACE_SPECS, surfaceAllows } from '@ultimat3/render';
16
16
  import type { JsonValue } from './output';
@@ -179,9 +179,6 @@ export function skippedRoute(
179
179
  };
180
180
  }
181
181
 
182
- const isRecord = (value: unknown): value is Record<string, unknown> =>
183
- typeof value === 'object' && value !== null;
184
-
185
182
  /**
186
183
  * A closed vocabulary, checked against the vocabulary itself. `typeof value === 'string'` is what
187
184
  * `surface` and `render` were held to, and a string is not a `Surface`: the parse then handed back
@@ -194,7 +191,7 @@ const inDomain = (domain: readonly string[], value: unknown): boolean =>
194
191
  typeof value === 'string' && domain.includes(value);
195
192
 
196
193
  const isSkipped = (value: unknown): value is SkippedRoute =>
197
- isRecord(value) &&
194
+ isJsonObject(value) &&
198
195
  typeof value['route'] === 'string' &&
199
196
  inDomain(SURFACES, value['surface']) &&
200
197
  inDomain(RENDER_MODES, value['render']) &&
@@ -206,7 +203,7 @@ const optionalString = (value: unknown): boolean =>
206
203
 
207
204
  /** The three coded fields are optional TOGETHER on the way in; a present one must be a string. */
208
205
  const isUnmeasured = (value: unknown): value is UnmeasuredRoute =>
209
- isRecord(value) &&
206
+ isJsonObject(value) &&
210
207
  typeof value['path'] === 'string' &&
211
208
  typeof value['reason'] === 'string' &&
212
209
  optionalString(value['code']) &&
@@ -215,7 +212,7 @@ const isUnmeasured = (value: unknown): value is UnmeasuredRoute =>
215
212
  (value['weighable'] === undefined || value['weighable'] === false);
216
213
 
217
214
  const isEmitted = (value: unknown): value is EmittedPage =>
218
- isRecord(value) &&
215
+ isJsonObject(value) &&
219
216
  typeof value['route'] === 'string' &&
220
217
  typeof value['path'] === 'string' &&
221
218
  typeof value['file'] === 'string';
@@ -226,7 +223,7 @@ const isEmitted = (value: unknown): value is EmittedPage =>
226
223
  * already handles, rather than as a report with a `skipped` nobody can render.
227
224
  */
228
225
  export function parseStaticReport(value: unknown): StaticReport | undefined {
229
- if (!isRecord(value)) return undefined;
226
+ if (!isJsonObject(value)) return undefined;
230
227
  const { target, out, buildId, emitted, skipped, unmeasured, serviceWorkerWarnings } = value;
231
228
  if (target !== 'static' || typeof out !== 'string' || typeof buildId !== 'string') {
232
229
  return undefined;
@@ -0,0 +1,86 @@
1
+ // The weekly half of `ci.yml`: the trigger that gates a default branch nobody is pushing to, the
2
+ // concurrency and job condition that let it run, and the alarm that reaches a person when it goes
3
+ // red. Shared with the `ci-weekly-schedule` codemod, so an upgraded app gets these same bytes.
4
+
5
+ import { fnv1a } from '@ultimat3/core';
6
+ import { DEFAULT_RUNNER } from './runner';
7
+
8
+ /** The one issue a red scheduled run opens; the alarm finds it again by this exact title. */
9
+ export const ALARM_ISSUE_TITLE = 'Scheduled gate is red on the default branch';
10
+
11
+ /**
12
+ * Sunday 04:MM UTC, the minute hashed (FNV-1a) from the app's name: apps scaffolded alike do not
13
+ * queue at one instant, and 1–58 stays off the top of the hour, when GitHub delays schedules most.
14
+ */
15
+ export function weeklyCron(name: string): string {
16
+ return `${String(1 + (fnv1a(name) % 58))} 4 * * 0`;
17
+ }
18
+
19
+ /** The `schedule:` entry under `on:`, its reasoning kept beside it. */
20
+ export const scheduleTrigger = (name: string): string =>
21
+ ` # Weekly, so a default branch nobody pushes to still learns that the world moved under it: a
22
+ # yanked dependency, a retired base image, an expired fixture. GitHub runs this on the default
23
+ # branch only, and turns it off in a public repository after 60 days with no activity there.
24
+ schedule:
25
+ - cron: '${weeklyCron(name)}'
26
+ `;
27
+
28
+ /** `concurrency:` and its group: the schedule arm first, then the push and pull request rule. */
29
+ export const CONCURRENCY_GROUP = `concurrency:
30
+ # A scheduled run is keyed by its own id: sharing a group with nothing, it cancels no run and no
31
+ # push can cancel it. The arm comes first because a schedule's event carries little else.
32
+ group: ci-\${{ github.event_name == 'schedule' && format('schedule-{0}', github.run_id) || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || github.ref }}
33
+ `;
34
+
35
+ /** The plan job's condition, which every other gate job inherits through `needs`. */
36
+ export const PLAN_CONDITION = ` # A scheduled run has no pull request to duplicate, so only that event is ever filtered.
37
+ if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
38
+ `;
39
+
40
+ /** The job after the verdict, with the blank line that separates it from `verify`. */
41
+ export const ALARM_JOB = `
42
+ # A failed schedule emails only whoever last edited the cron line, which may be a bot or nobody
43
+ # still here. So the run keeps ONE issue: opened when it goes red, commented on while it stays
44
+ # red, closed by the next green run. It runs no action and checks nothing out, so the only code
45
+ # beside its token is \`gh\`; the \`image\` workflow publishes a push alone, so nothing ships from here.
46
+ alarm:
47
+ needs: verify
48
+ if: \${{ !cancelled() && github.event_name == 'schedule' }}
49
+ # NOT \`vars.CI_RUNNER\`: \`gh\` is on the GitHub-hosted image, and a configured label may lack it.
50
+ runs-on: ${DEFAULT_RUNNER}
51
+ timeout-minutes: 5
52
+ # Replaces the workflow's grant for this job alone: no other job can write an issue.
53
+ permissions:
54
+ issues: write # open, comment on and close the one alarm issue
55
+ steps:
56
+ - name: report the scheduled verdict
57
+ shell: bash
58
+ env:
59
+ GH_TOKEN: \${{ github.token }}
60
+ GH_REPO: \${{ github.repository }}
61
+ VERDICT: \${{ needs.verify.result }}
62
+ run: |
63
+ run_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
64
+ # Its own assignment, so a failed lookup stops the job instead of reading as Issues off.
65
+ issues_enabled="$(gh repo view --json hasIssuesEnabled --jq .hasIssuesEnabled)"
66
+ # With Issues off there is nowhere to write: a green week must not turn red over that.
67
+ if [ "$issues_enabled" != true ]; then
68
+ echo "::warning::Issues are off here, so this verdict ($VERDICT) reaches nobody: $run_url"
69
+ exit 0
70
+ fi
71
+ # Its own issue only: the author filter keeps a look-alike title from being commented on.
72
+ existing="$(gh issue list --state open --author 'app/github-actions' \\
73
+ --search 'in:title "${ALARM_ISSUE_TITLE}"' --json number,title \\
74
+ --jq 'map(select(.title == "${ALARM_ISSUE_TITLE}"))[0].number // empty')"
75
+ if [ "$VERDICT" = success ]; then
76
+ if [ -n "$existing" ]; then
77
+ gh issue close "$existing" --reason completed --comment "Green again: $run_url"
78
+ fi
79
+ elif [ -n "$existing" ]; then
80
+ gh issue comment "$existing" --body "Still red: $run_url"
81
+ else
82
+ gh issue create --title '${ALARM_ISSUE_TITLE}' --body "The weekly gate failed with no push to blame: $run_url
83
+
84
+ Reproduce it with bun run setup, then bun run verify. The next green scheduled run closes this issue."
85
+ fi
86
+ `;
@@ -1,6 +1,6 @@
1
1
  // The CI half of what `x new` writes: the gate workflow, cut into parallel parts by
2
2
  // `x verify plan` and folded back by `x verify merge`, and the image workflow (`image.yml.ts`)
3
- // that publishes only what that gate passed. Every command it runs is one of the app's own scripts
3
+ // that publishes only what that gate passed; `ci-schedule.ts` is its weekly run. Every command it runs is one of the app's own scripts
4
4
  // — `bun run setup`, `bun run verify …` — never a restatement of the gate's steps (axiom 1).
5
5
 
6
6
  import { REQUIRED_BUN } from '../../app-root';
@@ -8,6 +8,7 @@ import { DEFAULT_PLAN_PARTS } from '../../verify-plan';
8
8
  import type { GeneratedFile, NameSet } from '../naming';
9
9
  import { TEST_COMPOSE_PATH, TEST_ENV_PATH } from '../scaffold-test-services';
10
10
  import { CACHE, CHECKOUT, DOWNLOAD_ARTIFACT, UPLOAD_ARTIFACT } from './actions';
11
+ import { ALARM_JOB, CONCURRENCY_GROUP, PLAN_CONDITION, scheduleTrigger } from './ci-schedule';
11
12
  import { DEPENDABOT_PATH, dependabot } from './dependabot.yml';
12
13
  import { IMAGE_WORKFLOW_PATH, imageWorkflow } from './image.yml';
13
14
  import { RUNS_ON } from './runner';
@@ -72,13 +73,11 @@ const ci = (app: NameSet): string => `name: ${CI_WORKFLOW_NAME}
72
73
  on:
73
74
  push:
74
75
  pull_request:
75
-
76
+ ${scheduleTrigger(app.kebab)}
76
77
  # A newer push to a branch makes the run already in flight for it worthless, so it is cancelled —
77
78
  # except on the default branch, where every commit keeps its own verdict: that group is keyed by
78
79
  # SHA, so nothing there can supersede anything.
79
- concurrency:
80
- group: ci-\${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || github.ref }}
81
- cancel-in-progress: true
80
+ ${CONCURRENCY_GROUP} cancel-in-progress: true
82
81
 
83
82
  permissions:
84
83
  contents: read
@@ -90,8 +89,7 @@ jobs:
90
89
  # A branch in THIS repository with an open pull request fires both events for one commit, and
91
90
  # the push run already gates that exact tree — so the pull_request run is skipped, not paid for
92
91
  # twice. A pull request from a FORK fires no push here, and it still runs.
93
- if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
94
- # A free GitHub-hosted runner unless the repository variable \`CI_RUNNER\` names another label.
92
+ ${PLAN_CONDITION} # A free GitHub-hosted runner unless the repository variable \`CI_RUNNER\` names another label.
95
93
  runs-on: ${RUNS_ON}
96
94
  timeout-minutes: 5
97
95
  outputs:
@@ -172,7 +170,7 @@ ${SETUP_STEPS}
172
170
  path: \${{ runner.temp }}/parts
173
171
  merge-multiple: true
174
172
  - run: bun run verify merge "$RUNNER_TEMP"/parts/*.json
175
- `;
173
+ ${ALARM_JOB}`;
176
174
 
177
175
  /** The CI a new app is born with, in reading order: the gate, the image, the dependency updates. */
178
176
  export function githubFiles(app: NameSet): readonly GeneratedFile[] {
@@ -8,6 +8,11 @@ export const DEPENDABOT_PATH = '.github/dependabot.yml';
8
8
  /** The directory `x new` writes its Dockerfile and compose files into. */
9
9
  const DOCKER_DIR = '/docker';
10
10
 
11
+ /** The `docker` ignore entry for the image the Dockerfile builds on. */
12
+ export const BUN_IMAGE_IGNORE = ` # \`FROM oven/bun\` moves with \`engines.bun\` and every other Bun pin (the \`runtime-pin\` guard).
13
+ - dependency-name: oven/bun
14
+ `;
15
+
11
16
  export const dependabot = (): string => `version: 2
12
17
 
13
18
  # Weekly, grouped, and small — a dependency PR nobody can review in one sitting gets merged unread.
@@ -59,7 +64,7 @@ updates:
59
64
  # A Postgres MAJOR is a planned migration (a new data directory), never a weekly bump.
60
65
  - dependency-name: postgres
61
66
  update-types: ['version-update:semver-major']
62
-
67
+ ${BUN_IMAGE_IGNORE}
63
68
  - package-ecosystem: docker-compose
64
69
  directories: ['${DOCKER_DIR}']
65
70
  schedule: