create-stitchkit 0.6.18 → 0.6.20

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 (55) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/cli.js +62 -27
  3. package/package.json +10 -9
  4. package/template/biome.json +4 -1
  5. package/template/bun.lock +303 -301
  6. package/template/e2e/starter.spec.ts +2 -2
  7. package/template/package.json +16 -16
  8. package/template/packages/backend/package.json +6 -6
  9. package/template/packages/backend/src/cleanup.ts +4 -7
  10. package/template/packages/backend/src/index.ts +1 -1
  11. package/template/packages/backend/src/surface-manifest.test.ts +3 -3
  12. package/template/packages/config/package.json +3 -3
  13. package/template/packages/config/src/shutdown.ts +3 -4
  14. package/template/packages/config/src/variables.ts +5 -8
  15. package/template/packages/db/package.json +4 -4
  16. package/template/packages/frontend/package.json +29 -29
  17. package/template/packages/frontend/scripts/serve.ts +4 -4
  18. package/template/packages/frontend/src/components/ui/toaster.tsx +2 -2
  19. package/template/packages/frontend/src/env.ts +1 -2
  20. package/template/packages/frontend/src/lib/query-client.test.ts +1 -1
  21. package/template/packages/frontend/src/lib/query-client.ts +2 -3
  22. package/template/packages/frontend/src/lib/seo/cache-by-origin.ts +2 -2
  23. package/template/packages/frontend/src/lib/seo/request-origin.ts +5 -5
  24. package/template/packages/shared/package.json +2 -2
  25. package/template/packages/shared/src/contracts/board.ts +1 -3
  26. package/template/packages/shared/src/contracts/system.ts +1 -3
  27. package/template/scripts/acceptance-database.test.ts +4 -4
  28. package/template/scripts/acceptance-database.ts +4 -6
  29. package/template/scripts/acceptance-local.ts +6 -8
  30. package/template/scripts/build-stamp.test.ts +3 -5
  31. package/template/scripts/build-stamp.ts +8 -11
  32. package/template/scripts/check-authored.test.ts +16 -1
  33. package/template/scripts/check-authored.ts +7 -6
  34. package/template/scripts/client-boundary.test.ts +26 -8
  35. package/template/scripts/client-boundary.ts +30 -27
  36. package/template/scripts/declaration.test.ts +5 -7
  37. package/template/scripts/declaration.ts +14 -19
  38. package/template/scripts/deployment-preflight.ts +2 -3
  39. package/template/scripts/dev.ts +6 -8
  40. package/template/scripts/guide-paths.ts +2 -4
  41. package/template/scripts/readiness.ts +4 -5
  42. package/template/scripts/release-steps.test.ts +2 -4
  43. package/template/scripts/release-steps.ts +2 -2
  44. package/template/scripts/runtime-smoke.test.ts +6 -7
  45. package/template/scripts/serve-mode.test.ts +2 -2
  46. package/template/scripts/shutdown-budget.fixture.ts +3 -5
  47. package/template/scripts/shutdown-budget.test.ts +4 -8
  48. package/template/scripts/supervision-signal.test.ts +1 -1
  49. package/template/scripts/surface-conformance.ts +1 -1
  50. package/template/scripts/web-surface-smoke.ts +5 -8
  51. package/templates/agent/biome.json +4 -1
  52. package/templates/agent/package.json +11 -7
  53. package/templates/agent/src/runtime.ts +1 -1
  54. package/templates/telegram-bot/biome.json +4 -1
  55. package/templates/telegram-bot/package.json +8 -4
@@ -40,8 +40,8 @@ test('a note posted in one tab reaches another through the web origin and the so
40
40
  }) => {
41
41
  // The browser's own origin carries HTTP (`/api` is forwarded by the web
42
42
  // role) and the socket dials the API role; a post in one tab must reach a
43
- // second tab that never asked for it. Both halves failed silently before:
44
- // `/api` was a 404 on the web port, and the browser build had no socket.
43
+ // second tab that never asked for it. The assertion requires both HTTP
44
+ // forwarding on the web port and a working socket in the browser build.
45
45
  const writer = await browser.newPage();
46
46
  const reader = await browser.newPage();
47
47
  await Promise.all([writer.goto('/en'), reader.goto('/en')]);
@@ -7,13 +7,13 @@
7
7
  "packages/*"
8
8
  ],
9
9
  "catalog": {
10
- "stitchkit": "^0.111.3"
10
+ "stitchkit": "^0.120.0"
11
11
  },
12
12
  "overrides": {
13
- "@playwright/test": "1.63.0",
14
- "playwright": "1.63.0",
15
- "playwright-core": "1.63.0",
16
- "zod": "4.6.5"
13
+ "@playwright/test": "1.64.1",
14
+ "playwright": "1.64.1",
15
+ "playwright-core": "1.64.1",
16
+ "zod": "4.6.7"
17
17
  },
18
18
  "scripts": {
19
19
  "dev": "bun scripts/dev.ts",
@@ -44,26 +44,26 @@
44
44
  "gen:declaration": "bun scripts/declaration.ts"
45
45
  },
46
46
  "dependencies": {
47
- "dotenv": "^18.0.3"
47
+ "dotenv": "^18.0.9"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@app/config": "workspace:*",
51
51
  "@app/shared": "workspace:*",
52
- "@axe-core/playwright": "^4.13.0",
53
- "@biomejs/biome": "^2.5.14",
54
- "@modelcontextprotocol/client": "^2.0.0",
55
- "@playwright/test": "^1.63.0",
56
- "@types/bun": "^1.4.2",
57
- "@types/node": "^26.6.2",
58
- "oxc-parser": "^0.151.0",
59
- "socket.io-client": "^4.8.3",
52
+ "@axe-core/playwright": "^4.14.0",
53
+ "@biomejs/biome": "2.6.5",
54
+ "@modelcontextprotocol/client": "^2.4.0",
55
+ "@playwright/test": "^1.64.1",
56
+ "@types/bun": "^1.4.4",
57
+ "@types/node": "^26.6.6",
58
+ "oxc-parser": "^0.157.0",
59
+ "socket.io-client": "^4.8.4",
60
60
  "stitchkit": "catalog:",
61
61
  "typescript": "^7.0.2",
62
- "zod": "^4.6.5"
62
+ "zod": "^4.6.7"
63
63
  },
64
64
  "engines": {
65
65
  "bun": ">=1.2.0",
66
66
  "node": ">=22"
67
67
  },
68
- "packageManager": "bun@1.4.2"
68
+ "packageManager": "bun@1.4.4"
69
69
  }
@@ -16,16 +16,16 @@
16
16
  "@app/config": "workspace:*",
17
17
  "@app/db": "workspace:*",
18
18
  "@app/shared": "workspace:*",
19
- "@modelcontextprotocol/server": "^2.0.0",
20
- "@prisma/adapter-pg": "^7.10.0",
19
+ "@modelcontextprotocol/server": "^2.4.0",
20
+ "@prisma/adapter-pg": "^7.10.1",
21
21
  "@socket.io/bun-engine": "^0.1.2",
22
- "ai": "^7.0.111",
23
- "socket.io": "^4.8.3",
22
+ "ai": "^7.0.162",
23
+ "socket.io": "^4.8.4",
24
24
  "stitchkit": "catalog:",
25
- "zod": "^4.6.5"
25
+ "zod": "^4.6.7"
26
26
  },
27
27
  "devDependencies": {
28
- "@types/bun": "^1.4.2",
28
+ "@types/bun": "^1.4.4",
29
29
  "typescript": "^7.0.2"
30
30
  }
31
31
  }
@@ -38,14 +38,11 @@ type StepOutcome =
38
38
  *
39
39
  * The two ways a step can end are kept apart. Running out of time and throwing
40
40
  * are different facts about a shutdown — one says a resource is still held, the
41
- * other says closing it is broken — and collapsing them (this used to discard
42
- * the rejection entirely) turned a failed shutdown into a clean exit with the
43
- * reason gone.
41
+ * other says closing it is broken. Both must retain their cause so a failed
42
+ * shutdown cannot appear as a clean exit.
44
43
  *
45
- * The clock is `performance.now()` and cannot be replaced. It used to be
46
- * `Date.now()` behind an injectable parameter, and both halves of that were
47
- * wrong for a deadline: a wall clock stepped backwards widens the very upper
48
- * bound a supervisor's kill timeout was derived from, and an injected clock
44
+ * The clock is `performance.now()` and cannot be replaced: a wall clock stepped
45
+ * backwards widens the upper bound of a supervisor's kill timeout, and an injected clock
49
46
  * that does not advance hands every step a full budget — a shutdown budget that
50
47
  * a test could switch off. Nothing needs to fake it: the regression that
51
48
  * matters runs a real process.
@@ -9,7 +9,7 @@ import {
9
9
  generateOpenApiDocument,
10
10
  openApiRoute,
11
11
  } from 'stitchkit/server';
12
- import { createMcpHandler, createMcpHttpRoute } from 'stitchkit/tools';
12
+ import { createMcpHandler, createMcpHttpRoute } from 'stitchkit/tools/mcp';
13
13
  import { closeWithinBudget, concludeShutdown } from './cleanup';
14
14
  import { prisma } from './lib/db';
15
15
  import { createSurface } from './surface';
@@ -103,8 +103,8 @@ describe('surface conformance', () => {
103
103
  agentToolNames: ['read_note'],
104
104
  cliToolNames: ['read_note'],
105
105
  };
106
- // A silent skip was the hole: no x-stitchkit-* keys meant no comparison at
107
- // all. The default mode now refuses; opting out is an explicit decision.
106
+ // Without x-stitchkit-* metadata there is nothing to compare. The default
107
+ // mode rejects the document; opting out is an explicit decision.
108
108
  expect(() =>
109
109
  assertSurfaceConformance({ manifest, openApi: standardDocument, ...names }),
110
110
  ).toThrow(/no x-stitchkit-\* contract metadata/);
@@ -145,7 +145,7 @@ describe('surface conformance', () => {
145
145
  });
146
146
 
147
147
  test('the committed snapshot catches an expose edit that moves BOTH in-process sides together', () => {
148
- // The probe that defeated the old check: removing AGENT/CLI from `expose`
148
+ // Removing AGENT/CLI from `expose`
149
149
  // changes the manifest AND the in-process tool lists in lockstep. The
150
150
  // snapshot is the anchor that does not move with the source.
151
151
  const snapshot = buildSurfaceManifest([service]);
@@ -16,12 +16,12 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@t3-oss/env-core": "^0.13.11",
19
- "dotenv": "^18.0.3",
19
+ "dotenv": "^18.0.9",
20
20
  "stitchkit": "catalog:",
21
- "zod": "^4.6.5"
21
+ "zod": "^4.6.7"
22
22
  },
23
23
  "devDependencies": {
24
- "@types/bun": "^1.4.2",
24
+ "@types/bun": "^1.4.4",
25
25
  "typescript": "^7.0.2"
26
26
  }
27
27
  }
@@ -3,10 +3,9 @@
3
3
  *
4
4
  * `terminationBudgetMs` adds these to a role's drain floor and refuses a
5
5
  * supervision policy that allows less. That only means something if each part
6
- * is really bounded — and cleanup was not: the drain has a deadline, but the
7
- * closes that run after it (an MCP session, a database pool) had none, so the
8
- * "budget" was an estimate wearing the shape of an upper bound, and a role
9
- * could still be killed mid-shutdown by a timeout the generator had approved.
6
+ * is really bounded: MCP and database closes share a cleanup deadline after the
7
+ * drain. An unbounded close would turn the declared upper bound into an estimate
8
+ * and let the supervisor kill a role before its shutdown ends.
10
9
  *
11
10
  * They live here rather than in the generator because two readers need them and
12
11
  * a number in two places is two numbers: the generator, which tells a
@@ -4,14 +4,12 @@ import { featureServerSchema } from './features';
4
4
  /**
5
5
  * Every environment variable this application reads, declared **once**.
6
6
  *
7
- * There used to be three overlapping copies — the server schema, the frontend
8
- * schema and the tooling schema — and they had already drifted in composition.
9
- * A fourth copy in the project declaration would have been worse still, so this
10
- * module is the source and everything else is a projection of it:
7
+ * This module is the source; the server schema, frontend schema, tooling schema
8
+ * and project declaration are projections so their requirements cannot drift:
11
9
  *
12
10
  * - `server.ts` validates all of them for the API role;
13
11
  * - `frontend/src/env.ts` projects the handful the web role reads;
14
- * - `scripts/declaration.ts` DERIVES `env.required` in `project.json` from
12
+ * - `scripts/declaration.ts` derives `env.variables` in `project.json` from
15
13
  * here, so the declaration a deployment reads can never fall behind.
16
14
  *
17
15
  * Defaults, coercion and error messages live here and only here. The
@@ -111,9 +109,8 @@ const baseVariables = {
111
109
  *
112
110
  * A merge rather than a spread inside one literal, so an overlay can **tighten**
113
111
  * a variable the base declares optional — not only add new ones. Without that,
114
- * a project whose code dereferences a variable without a fallback had no way to
115
- * say so, and its declaration told a deployment the variable was optional while
116
- * the first render threw.
112
+ * a feature that requires a variable could not express that requirement, and
113
+ * the declaration would call it optional while the first render throws.
117
114
  */
118
115
  export const applicationVariables = { ...baseVariables, ...featureServerSchema };
119
116
 
@@ -17,13 +17,13 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@app/config": "workspace:*",
20
- "@prisma/adapter-pg": "^7.10.0",
21
- "@prisma/client": "^7.10.0",
22
- "pg": "^8.23.0"
20
+ "@prisma/adapter-pg": "^7.10.1",
21
+ "@prisma/client": "^7.10.1",
22
+ "pg": "^8.23.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/pg": "^8.23.1",
26
- "prisma": "^7.10.0",
26
+ "prisma": "^7.10.1",
27
27
  "typescript": "^7.0.2"
28
28
  }
29
29
  }
@@ -13,49 +13,49 @@
13
13
  "dependencies": {
14
14
  "@app/config": "workspace:*",
15
15
  "@app/shared": "workspace:*",
16
- "@radix-ui/react-alert-dialog": "^1.1.23",
17
- "@radix-ui/react-avatar": "^1.2.6",
18
- "@radix-ui/react-checkbox": "^1.3.11",
19
- "@radix-ui/react-dialog": "^1.1.23",
20
- "@radix-ui/react-dropdown-menu": "^2.1.24",
21
- "@radix-ui/react-select": "^2.3.7",
22
- "@radix-ui/react-slider": "^1.4.7",
23
- "@radix-ui/react-slot": "^1.3.3",
24
- "@radix-ui/react-switch": "^1.3.7",
25
- "@radix-ui/react-tabs": "^1.1.21",
26
- "@radix-ui/react-tooltip": "^1.2.16",
16
+ "@radix-ui/react-alert-dialog": "^1.2.1",
17
+ "@radix-ui/react-avatar": "^1.3.1",
18
+ "@radix-ui/react-checkbox": "^1.4.1",
19
+ "@radix-ui/react-dialog": "^1.3.1",
20
+ "@radix-ui/react-dropdown-menu": "^2.2.1",
21
+ "@radix-ui/react-select": "^2.4.1",
22
+ "@radix-ui/react-slider": "^1.6.1",
23
+ "@radix-ui/react-slot": "^1.5.0",
24
+ "@radix-ui/react-switch": "^1.4.1",
25
+ "@radix-ui/react-tabs": "^1.2.1",
26
+ "@radix-ui/react-tooltip": "^1.4.1",
27
27
  "@t3-oss/env-nextjs": "^0.13.11",
28
- "@tabler/icons-react": "^3.48.0",
29
- "@tanstack/react-query": "^5.103.2",
30
- "@tanstack/react-table": "^9.2.4",
31
- "@wrksz/themes": "^1.2.0",
28
+ "@tabler/icons-react": "^3.50.0",
29
+ "@tanstack/react-query": "^5.105.3",
30
+ "@tanstack/react-table": "^9.3.1",
31
+ "@wrksz/themes": "^2.1.1",
32
32
  "class-variance-authority": "^0.7.1",
33
33
  "clsx": "^2.1.1",
34
34
  "date-fns": "^4.4.0",
35
- "dotenv": "^18.0.3",
36
- "framer-motion": "^13.4.1",
37
- "next": "^16.3.6",
38
- "next-intl": "^4.14.6",
39
- "react": "^19.3.0",
40
- "react-dom": "^19.3.0",
41
- "react-query-kit": "^3.3.4",
35
+ "dotenv": "^18.0.9",
36
+ "framer-motion": "^14.9.1",
37
+ "next": "^16.4.5",
38
+ "next-intl": "^4.14.9",
39
+ "react": "^19.3.1",
40
+ "react-dom": "^19.3.1",
41
+ "react-query-kit": "^3.4.0",
42
42
  "recharts": "^3.10.1",
43
- "shiki": "^4.4.3",
44
- "socket.io-client": "^4.8.3",
43
+ "shiki": "^4.6.0",
44
+ "socket.io-client": "^4.8.4",
45
45
  "sonner": "^2.0.8",
46
46
  "stitchkit": "catalog:",
47
47
  "tailwind-merge": "^3.7.0",
48
48
  "vaul": "^1.1.2",
49
- "zod": "^4.6.5"
49
+ "zod": "^4.6.7"
50
50
  },
51
51
  "devDependencies": {
52
- "@tailwindcss/postcss": "^4.3.3",
53
- "@types/bun": "^1.4.2",
54
- "@types/node": "^26.6.2",
52
+ "@tailwindcss/postcss": "^4.3.4",
53
+ "@types/bun": "^1.4.4",
54
+ "@types/node": "^26.6.6",
55
55
  "@types/react": "^19.3.0",
56
56
  "@types/react-dom": "^19.3.0",
57
57
  "babel-plugin-react-compiler": "^1.0.0",
58
- "tailwindcss": "^4.3.3",
58
+ "tailwindcss": "^4.3.4",
59
59
  "tw-animate-css": "^1.4.0",
60
60
  "typescript": "^7.0.2"
61
61
  }
@@ -17,8 +17,8 @@ import { env } from '../src/env';
17
17
  /**
18
18
  * The run mode, fail-closed.
19
19
  *
20
- * `argv[2] === 'development' ? 'dev' : 'start'` meant a typo, an empty string
21
- * and a missing argument all silently became production. A wrong mode is not a
20
+ * `argv[2] === 'development' ? 'dev' : 'start'` would turn a typo, an empty string
21
+ * and a missing argument into production. A wrong mode is not a
22
22
  * detail — it decides whether the role serves a build or compiles on demand —
23
23
  * and the supervision files pass it explicitly, so anything else is a mistake
24
24
  * worth seeing.
@@ -60,8 +60,8 @@ const code = await child.exited;
60
60
  * A stop that was ASKED for is a success — but only for the codes a stop
61
61
  * actually produces.
62
62
  *
63
- * `stopping ? 0 : code` reported success for ANY exit during shutdown, so a
64
- * role that crashed while draining looked identical to one that drained. Next
63
+ * `stopping ? 0 : code` would report success for any exit during shutdown and
64
+ * hide a crash during drain. Next
65
65
  * exits 130 on SIGINT and 143 on SIGTERM, and reporting those upward would make
66
66
  * every ordinary supervised stop look like a failure; anything else during a
67
67
  * shutdown is a real failure and keeps its code.
@@ -38,9 +38,9 @@ export const toast = {
38
38
  };
39
39
 
40
40
  export function Toaster() {
41
- // No explicit type argument: since @wrksz/themes 1.2 the parameter describes
41
+ // No explicit type argument: the parameter describes
42
42
  // the MAP, not the value, and it infers `const` — so naming the value union
43
- // here made the result every member of `string` instead of narrowing it.
43
+ // here would widen the result to `string` instead of preserving the literals.
44
44
  const theme = useThemeValue({
45
45
  light: 'light',
46
46
  dark: 'dark',
@@ -11,8 +11,7 @@ config({ path: path.resolve(process.cwd(), '../../.env'), quiet: true });
11
11
  *
12
12
  * There is deliberately NO `client` block. A `NEXT_PUBLIC_` variable is
13
13
  * substituted at BUILD time, so declaring one freezes a value of the place into
14
- * the artifact — the built server chunk once carried
15
- * `NEXT_PUBLIC_API_URL:"http://…"` as a literal while a plain `WEB_PORT` stayed
14
+ * the artifact: `NEXT_PUBLIC_API_URL:"http://…"` becomes a literal while a plain `WEB_PORT` stays
16
15
  * a runtime read. Anything the browser needs is either relative (so it needs no
17
16
  * address at all), derived from the request, or read on the server and handed
18
17
  * down per request — never compiled in.
@@ -23,7 +23,7 @@ describe('query dehydration policy', () => {
23
23
 
24
24
  test('retries a server failure once and never retries a mutation', () => {
25
25
  // Asserted through the decision, not through the literal: the policy is a
26
- // predicate now, and `retry === 1` would pass for a client that retries an
26
+ // predicate, and `retry === 1` would pass for a client that retries an
27
27
  // unauthorized request too.
28
28
  const defaults = getQueryClient().getDefaultOptions();
29
29
  const retry = defaults.queries?.retry;
@@ -2,9 +2,8 @@ import { cache } from 'react';
2
2
  import { createQueryClientFactory } from 'stitchkit/react';
3
3
 
4
4
  // One request-local server client and one browser singleton, both from the
5
- // framework. The local construction this replaced was a second implementation
6
- // of the same thing: it restated the dehydration policy and the mutation rule,
7
- // and it spelled the query retry as a plain `1`, which retries an unauthorized
5
+ // framework. The factory owns the dehydration policy, mutation rule and query
6
+ // retry. A plain retry count of `1` would retry an unauthorized
8
7
  // or invalid request exactly as eagerly as a network blip. `apiErrorRetry` —
9
8
  // the factory's default — retries what is worth retrying and nothing else.
10
9
  // Project-specific cache configuration and mutation toasts belong in these
@@ -3,8 +3,8 @@
3
3
  * each answer once rather than once per request.
4
4
  *
5
5
  * This is the price of deriving the public origin from the request instead of
6
- * the build: `robots.txt`, `sitemap.xml` and page metadata stopped being
7
- * prerendered constants. They are still constants *per address*, and this is
6
+ * the build: `robots.txt`, `sitemap.xml` and page metadata depend on the served
7
+ * address. They are constants *per address*, and this is
8
8
  * where that is spent — one render per address, not one per hit.
9
9
  *
10
10
  * Bounded and least-recently-used on purpose: part of every key comes from a
@@ -5,9 +5,9 @@ import { env } from '@/env';
5
5
  * The public origin this response is being served on.
6
6
  *
7
7
  * Derived from the REQUEST, never from the build. An absolute address read at
8
- * build time is frozen into the artifact — `robots.txt` and `sitemap.xml` were
9
- * prerendered with one origin inside their bytes, so a single build could not
10
- * serve a second address. Reading the request instead makes one artifact
8
+ * build time is frozen into the artifact: prerendering `robots.txt` and
9
+ * `sitemap.xml` with one origin would prevent that build from serving a second
10
+ * address correctly. Reading the request makes one artifact
11
11
  * correct at every address it is ever routed to.
12
12
  *
13
13
  * **The request is not trusted on its own.** `x-forwarded-host` is set by
@@ -68,8 +68,8 @@ function isAllowedHost(host: string): boolean {
68
68
  *
69
69
  * Only two are possible, and anything else is a misconfigured proxy or a
70
70
  * forgery — both of which must be seen, not normalised. Mapping every unknown
71
- * value to `http` meant `ftp`, `javascript` and a truncated header all produced
72
- * a plausible-looking origin, and the answer went into canonical URLs.
71
+ * value to `http` would turn `ftp`, `javascript` and a truncated header into a
72
+ * plausible origin and put an unverified value into canonical URLs.
73
73
  *
74
74
  * A missing header is not a failure: a deployment reached directly has no
75
75
  * forwarding layer, and `http` is then the truth.
@@ -13,10 +13,10 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "stitchkit": "catalog:",
16
- "zod": "^4.6.5"
16
+ "zod": "^4.6.7"
17
17
  },
18
18
  "devDependencies": {
19
- "@types/bun": "^1.4.2",
19
+ "@types/bun": "^1.4.4",
20
20
  "typescript": "^7.0.2"
21
21
  }
22
22
  }
@@ -2,9 +2,7 @@ import { createContractFactory } from 'stitchkit';
2
2
  import { defineEvents } from 'stitchkit/live';
3
3
  import { BoardChangedSchema, BoardSchema, PostNoteSchema } from '../schemas/board';
4
4
 
5
- const { defineContract } = createContractFactory<'public'>({
6
- toolExposure: 'explicit',
7
- });
5
+ const { defineContract } = createContractFactory<'public'>();
8
6
 
9
7
  /**
10
8
  * The board: read it, add to it.
@@ -1,9 +1,7 @@
1
1
  import { createContractFactory } from 'stitchkit';
2
2
  import { SystemStatusSchema } from '../schemas/system';
3
3
 
4
- const { defineContract } = createContractFactory<'public'>({
5
- toolExposure: 'explicit',
6
- });
4
+ const { defineContract } = createContractFactory<'public'>();
7
5
 
8
6
  export const systemContract = defineContract(
9
7
  { prefix: 'system', scope: 'public' },
@@ -14,8 +14,8 @@ describe('the acceptance gate writes only to a database of its own', () => {
14
14
  });
15
15
 
16
16
  test('an unset variable is refused with the line to paste', () => {
17
- // The gate used to inherit DATABASE_URL. Defaulting to it is exactly the
18
- // behaviour this replaces, so absence has to be a refusal, not a fallback.
17
+ // Falling back to DATABASE_URL would let the gate write to the deployment's
18
+ // database, so an absent acceptance URL must be rejected.
19
19
  expect(() => resolveAcceptanceDatabase({ DATABASE_URL: deployment })).toThrow(
20
20
  /ACCEPTANCE_DATABASE_URL=postgresql:\/\/app:secret@127\.0\.0\.1:5432\/starter_acceptance/,
21
21
  );
@@ -44,8 +44,8 @@ describe('the acceptance gate writes only to a database of its own', () => {
44
44
 
45
45
  test('the same name on another hostname is refused, because a hostname proves nothing', () => {
46
46
  // `localhost` and `127.0.0.1` are one server; so are two DNS names for the
47
- // same PostgreSQL. A guard that compared `host:port/name` called these two
48
- // different databases and let the gate migrate the deployment's own.
47
+ // same PostgreSQL. Comparing `host:port/name` cannot prove the databases
48
+ // are separate and could let a gate migrate the deployment's own.
49
49
  expect(() =>
50
50
  resolveAcceptanceDatabase({
51
51
  DATABASE_URL: 'postgresql://app@localhost:5432/starter',
@@ -2,12 +2,10 @@
2
2
  * The database the local acceptance gate is allowed to write to.
3
3
  *
4
4
  * `acceptance:local` creates and destroys its own deployment — its own PM2 home,
5
- * its own ephemeral ports, its own host allowlist. The database was the one
6
- * thing it still borrowed: it inherited `DATABASE_URL`, and the runtime gates
7
- * WRITE. The repository example's smoke posts `/api/repository/refresh` twice,
8
- * which upserts. So a gate a developer is told to run before handing work off
9
- * wrote rows into whatever `.env` happened to name — including a production
10
- * database, if that is what the machine was pointed at.
5
+ * its own ephemeral ports, its own host allowlist and its own database. Runtime
6
+ * gates WRITE: the repository example posts `/api/repository/refresh`, which
7
+ * upserts. Inheriting `DATABASE_URL` would let a verification run write to the
8
+ * deployment named by `.env`, including production.
11
9
  *
12
10
  * Fail-closed on purpose. An acceptance database that is merely *probably*
13
11
  * separate is the same defect one edit later, so an unset variable and one that
@@ -2,9 +2,9 @@
2
2
  * The runtime gates, against a deployment this script owns.
3
3
  *
4
4
  * `runtime:smoke` and `e2e` check a RUNNING deployment, so a gate list has to
5
- * bring one up. The wrong way to do that — and the way this replaced — is
5
+ * bring one up. A gate must not do so through
6
6
  * `pm2:prod`: it applies the declared migrations and reloads the developer's
7
- * own PM2 daemon, so "run these before handing work off" quietly meant "deploy".
7
+ * own PM2 daemon, turning verification into a deployment.
8
8
  * A gate may not mutate a deployment; it may only create and destroy its own.
9
9
  *
10
10
  * So everything here is this run's and nothing else's: its own `PM2_HOME`, its
@@ -12,12 +12,10 @@
12
12
  * stop that names the roles the declaration declares rather than deleting
13
13
  * whatever the daemon happened to hold.
14
14
  *
15
- * The database is the last thing this owned. It used to inherit `DATABASE_URL`,
16
- * which made a GATE a writer: the repository example's smoke posts a refresh,
17
- * and that upserts. It now runs against `ACCEPTANCE_DATABASE_URL` and refuses to
18
- * start when that is unset or names the deployment's own database — and the
19
- * deployment's URL is not in the child environment at all, so no role here can
20
- * reach it even by asking.
15
+ * The gate writes: the repository example's smoke posts a refresh that upserts.
16
+ * It requires `ACCEPTANCE_DATABASE_URL`, distinct from the deployment's own
17
+ * database. The deployment's URL is excluded from the child environment so no
18
+ * role here can reach it.
21
19
  */
22
20
  import { mkdtemp, rm } from 'node:fs/promises';
23
21
  import { tmpdir } from 'node:os';
@@ -73,11 +73,9 @@ describe('a release starts this source, not a previous one', () => {
73
73
  });
74
74
 
75
75
  test('a Markdown file counts, because a project may import one', async () => {
76
- // The digest used to skip every `.md`, every test file and every directory
77
- // called `generated`. All three are true of THIS project today and none is
78
- // true by construction: MDX is an import, and a checked-in directory may be
79
- // called anything. A digest that answers "fresh" about a stale build is the
80
- // failure the stamp exists to prevent.
76
+ // Markdown, tests and directories named `generated` can all be source:
77
+ // MDX is an import, and a checked-in directory may be called anything.
78
+ // Excluding them could mark a stale build as fresh.
81
79
  const root = await tree({
82
80
  'src/index.ts': 'export const a = 1;\n',
83
81
  'content/post.md': 'before\n',
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * What the artifact was built FROM, so a release can tell whether it still is.
3
3
  *
4
- * `assertBuildArtifacts()` checked that the declared paths exist. Existence is
4
+ * `assertBuildArtifacts()` checks that the declared paths exist. Existence is
5
5
  * not freshness: `pm2:prod` run without a build applies the migrations this
6
6
  * source declares and then starts the `dist` and `.next` of an earlier one. The
7
7
  * schema moves ahead of the code, which is the worst direction — rolling the
@@ -14,15 +14,12 @@
14
14
  * none.
15
15
  *
16
16
  * **Everything is source until something says otherwise, and the something is
17
- * named.** The first version of this listed what to skip by *kind* — every
18
- * `.md`, every test file, every directory called `generated` — which reads as
19
- * "these cannot affect a build" and is only true of the project as it stands
20
- * today. A project that imports MDX, or keeps checked-in source in a directory
21
- * it happened to call `generated`, would change its content, keep its digest,
22
- * and be told its old artifact was current. A digest that answers "fresh" about
23
- * a stale build is worse than no digest.
17
+ * named.** A Markdown file, a test and a directory named `generated` can affect
18
+ * a build: a project can import MDX or keep authored code in any directory.
19
+ * Excluding source by kind could leave its digest unchanged after an edit and
20
+ * incorrectly mark a stale artifact as current.
24
21
  *
25
- * So the exclusions are now exactly three kinds, each named rather than guessed:
22
+ * The exclusions are exactly three kinds, each named rather than guessed:
26
23
  *
27
24
  * - **The build's own OUTPUTS**, read from `build.artifacts` in the project
28
25
  * declaration. One source of truth: a project that adds an artifact is
@@ -38,7 +35,7 @@
38
35
  * edited its own environment: the same gate, crying wolf in the other
39
36
  * direction.
40
37
  *
41
- * The cost is that editing a README or a test now asks for a rebuild before a
38
+ * The cost is that editing a README or a test requires a rebuild before a
42
39
  * release. That is the safe direction: the gate can be wrong about "stale", and
43
40
  * must never be wrong about "fresh".
44
41
  */
@@ -141,7 +138,7 @@ export function writeBuildStamp(
141
138
  /**
142
139
  * Refuse an artifact that is not this source's.
143
140
  *
144
- * A missing stamp is refused too, and deliberately: it means the artifact was
141
+ * A missing stamp is rejected: it means the artifact was
145
142
  * produced by something other than this build, and "we cannot tell" is not a
146
143
  * reason to start it.
147
144
  */