create-stitchkit 0.6.17 → 0.6.19

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 (80) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/cli.js +62 -27
  3. package/examples/repository/packages/frontend/src/app/[locale]/page.tsx +2 -0
  4. package/examples/repository/packages/frontend/src/app/[locale]/starter-page.tsx +12 -8
  5. package/examples/repository/project.json +9 -0
  6. package/package.json +10 -9
  7. package/template/README.md +7 -0
  8. package/template/_env.example +5 -0
  9. package/template/biome.json +4 -1
  10. package/template/bun.lock +303 -301
  11. package/template/docs/ADMIN_MOCK.md +38 -0
  12. package/template/e2e/starter.spec.ts +2 -2
  13. package/template/package.json +17 -16
  14. package/template/packages/backend/package.json +6 -6
  15. package/template/packages/backend/src/cleanup.ts +4 -7
  16. package/template/packages/backend/src/index.ts +2 -1
  17. package/template/packages/backend/src/surface-manifest.test.ts +3 -3
  18. package/template/packages/backend/src/surface.ts +7 -6
  19. package/template/packages/backend/src/trusted-origins.test.ts +40 -0
  20. package/template/packages/backend/src/trusted-origins.ts +21 -0
  21. package/template/packages/config/package.json +3 -3
  22. package/template/packages/config/src/shutdown.ts +3 -4
  23. package/template/packages/config/src/variables.ts +21 -9
  24. package/template/packages/db/package.json +4 -4
  25. package/template/packages/frontend/next.config.ts +10 -1
  26. package/template/packages/frontend/package.json +29 -29
  27. package/template/packages/frontend/scripts/serve.ts +4 -4
  28. package/template/packages/frontend/src/app/[locale]/admin/[[...section]]/page.dev.tsx +21 -0
  29. package/template/packages/frontend/src/app/[locale]/page.tsx +2 -1
  30. package/template/packages/frontend/src/app/[locale]/starter-page.tsx +12 -8
  31. package/template/packages/frontend/src/app/api/[...path]/route.ts +2 -37
  32. package/template/packages/frontend/src/app/sitemap.ts +4 -1
  33. package/template/packages/frontend/src/components/ui/toaster.tsx +2 -2
  34. package/template/packages/frontend/src/env.ts +12 -3
  35. package/template/packages/frontend/src/features/admin/admin-data.ts +13 -0
  36. package/template/packages/frontend/src/features/admin/admin-sections.ts +78 -0
  37. package/template/packages/frontend/src/features/admin/admin-workspace.test.tsx +59 -0
  38. package/template/packages/frontend/src/features/admin/admin-workspace.tsx +127 -0
  39. package/template/packages/frontend/src/features/admin/fixture/admin-fixture.ts +35 -0
  40. package/template/packages/frontend/src/lib/api-proxy.test.ts +131 -0
  41. package/template/packages/frontend/src/lib/api-proxy.ts +89 -0
  42. package/template/packages/frontend/src/lib/query-client.test.ts +1 -1
  43. package/template/packages/frontend/src/lib/query-client.ts +2 -3
  44. package/template/packages/frontend/src/lib/seo/cache-by-origin.ts +2 -2
  45. package/template/packages/frontend/src/lib/seo/request-origin.ts +5 -5
  46. package/template/packages/frontend/src/proxy.ts +12 -1
  47. package/template/packages/shared/package.json +2 -2
  48. package/template/packages/shared/src/contracts/board.ts +1 -3
  49. package/template/packages/shared/src/contracts/system.ts +1 -3
  50. package/template/project.json +9 -0
  51. package/template/scripts/acceptance-database.test.ts +4 -4
  52. package/template/scripts/acceptance-database.ts +4 -6
  53. package/template/scripts/acceptance-local.ts +14 -9
  54. package/template/scripts/build-stamp.test.ts +3 -5
  55. package/template/scripts/build-stamp.ts +8 -11
  56. package/template/scripts/check-authored.test.ts +16 -1
  57. package/template/scripts/check-authored.ts +7 -6
  58. package/template/scripts/client-boundary.test.ts +26 -8
  59. package/template/scripts/client-boundary.ts +30 -27
  60. package/template/scripts/declaration.test.ts +5 -7
  61. package/template/scripts/declaration.ts +14 -19
  62. package/template/scripts/deployment-preflight.ts +2 -3
  63. package/template/scripts/dev.ts +6 -8
  64. package/template/scripts/fixture-boundary.test.ts +34 -0
  65. package/template/scripts/fixture-boundary.ts +25 -0
  66. package/template/scripts/guide-paths.ts +2 -4
  67. package/template/scripts/readiness.ts +4 -5
  68. package/template/scripts/release-steps.test.ts +2 -4
  69. package/template/scripts/release-steps.ts +2 -2
  70. package/template/scripts/runtime-smoke.test.ts +6 -7
  71. package/template/scripts/serve-mode.test.ts +2 -2
  72. package/template/scripts/service-surfaces-closed.ts +13 -0
  73. package/template/scripts/shutdown-budget.fixture.ts +3 -5
  74. package/template/scripts/shutdown-budget.test.ts +4 -8
  75. package/template/scripts/supervision-signal.test.ts +1 -1
  76. package/template/scripts/web-surface-smoke.ts +38 -8
  77. package/templates/agent/biome.json +4 -1
  78. package/templates/agent/package.json +11 -7
  79. package/templates/telegram-bot/biome.json +4 -1
  80. package/templates/telegram-bot/package.json +8 -4
@@ -12,11 +12,10 @@ import { applicationVariables } from '../packages/config/src/variables';
12
12
  /**
13
13
  * Everything derived from the project declaration.
14
14
  *
15
- * Two things used to be written by hand and had already drifted: the list of
16
- * environment variables (three overlapping copies) and the two PM2 files (nine
17
- * diverging lines, one of which killed the backend mid-drain every time). Both
18
- * are now DERIVED — from `variables.ts` and from `project.json` — and the gate
19
- * refuses a checked-in file that does not match what this module renders.
15
+ * Environment variables are derived from `variables.ts`; both PM2 files are
16
+ * derived from `project.json`. Independent copies can disagree about required
17
+ * variables or kill a backend before its drain ends. The gate refuses a
18
+ * checked-in file that does not match what this module renders.
20
19
  *
21
20
  * Note what stays on which side. Roles, commands, readiness and the drain floor
22
21
  * come from the declaration, because they are true of the code. Restart policy
@@ -49,13 +48,11 @@ export const LOCAL_SUPERVISION: SupervisionPolicy = {
49
48
  *
50
49
  * The server forces for `forceTimeoutMs` (5s by default) once the grace period
51
50
  * ends, and `onComplete` then closes MCP and the database. A supervisor sized to
52
- * the drain floor alone kills the role in the middle of that tail — which is why
53
- * the earlier check, comparing against the floor only, reported that supervision
54
- * "allows the full shutdown" while 15s + 5s met a 20s kill timeout exactly.
51
+ * the drain floor alone can kill the role in the middle of that tail. A 15s
52
+ * drain plus 5s of forcing already spends a 20s timeout before cleanup begins.
55
53
  */
56
54
  // Imported, not restated: the role enforces these, and a number in two places
57
- // is two numbers that can disagree — which is exactly how a 15s drain met a
58
- // 20s kill timeout.
55
+ // is two numbers that can disagree about how long shutdown needs.
59
56
  const { FORCE_BUDGET_MS, CLEANUP_BUDGET_MS } = shutdownBudgets;
60
57
 
61
58
  /** The shortest time a supervisor may allow this role and still see it finish. */
@@ -66,10 +63,9 @@ export function terminationBudgetMs(role: ProjectRole): number {
66
63
  /**
67
64
  * JSON Schema types this projection can carry into the declaration.
68
65
  *
69
- * `number` used to be mapped to `integer`, which quietly told a deployment that
70
- * a fractional value was an integer — the declaration and the Zod contract it
71
- * is derived FROM would then disagree, which is the one failure the derivation
72
- * exists to prevent. A type with no faithful shape is refused instead: the
66
+ * Mapping `number` to `integer` would misrepresent fractional values and make
67
+ * the declaration disagree with its Zod source. A type with no faithful shape
68
+ * is rejected: the
73
69
  * declaration format gains the shape, or the project stops declaring that type.
74
70
  */
75
71
  const SHAPE_BY_JSON_TYPE: Record<string, ProjectEnvVariable['shape']> = {
@@ -115,8 +111,8 @@ function describeVariable(
115
111
  required: boolean,
116
112
  ): ProjectEnvVariable {
117
113
  if (property.enum) {
118
- // Members are refused rather than stringified. `String(member)` turned
119
- // numbers and booleans into text that no longer matched the value the Zod
114
+ // Members are rejected rather than stringified. `String(member)` would turn
115
+ // numbers and booleans into text that does not match the value the Zod
120
116
  // schema accepts, so a deployment reading the declaration would supply
121
117
  // something the application then rejects — the declaration would be derived
122
118
  // and still wrong.
@@ -156,9 +152,8 @@ export function renderProjectJson(): string {
156
152
  /**
157
153
  * The rule the drain floor exists for: a supervisor must allow at least as long
158
154
  * as the role needs to finish — the drain, the force that follows it, and the
159
- * cleanup after that. Shorter, and the process is killed mid-shutdown, which is
160
- * what a 15s kill timeout against a 30s floor did here, every time, for as long
161
- * as the two numbers lived in two hand-written files.
155
+ * cleanup after that. A 15s kill timeout against a 30s drain floor cannot allow
156
+ * orderly shutdown, even before forcing and cleanup take their own time.
162
157
  */
163
158
  export function assertSupervisionAllowsShutdown(
164
159
  declaration: ProjectDeclaration,
@@ -4,9 +4,8 @@
4
4
  * `runtime:smoke` checks a RUNNING deployment — that is what makes it a runtime
5
5
  * smoke rather than a build check. Without this the first `fetch` inside some
6
6
  * assertion fails with a bare `ECONNRESET`, which reads like a broken check
7
- * instead of an absent deployment and says nothing about what to do next. The
8
- * packed lane never saw it because the lane starts the roles itself; everyone
9
- * following the README's gate list saw it first.
7
+ * instead of an absent deployment and says nothing about what to do next. This
8
+ * preflight names the missing roles before any assertion tries to dial them.
10
9
  */
11
10
  export async function assertDeploymentIsAnswering(
12
11
  origins: Readonly<Record<string, string>>,
@@ -105,10 +105,9 @@ function assertToolAvailable(command: string, instruction: string): void {
105
105
  * The validated environment the development processes run with.
106
106
  *
107
107
  * Every variable the DECLARATION names, and no hand-written list beside it: a
108
- * list here went stale the moment a variable was added, and a role declaring a
109
- * port whose name was missing got `Number(undefined)` — reported as
110
- * `Port NaN (WORKER_PORT) is already in use`, which is a false diagnosis of a
111
- * real mistake.
108
+ * separate list can omit a role's port variable, turning a missing binding into
109
+ * `Number(undefined)` and a misleading `Port NaN (WORKER_PORT) is already in use`.
110
+ * Reading the declaration keeps missing bindings distinct from occupied ports.
112
111
  */
113
112
  export async function developmentEnvironment(
114
113
  overrides: Record<string, string> = {},
@@ -128,10 +127,9 @@ if (import.meta.main) {
128
127
 
129
128
  const environment = await developmentEnvironment();
130
129
  const roles = declaredRoleReadiness(appDeclaration, environment);
131
- // Reported only once it is TRUE. The supervisor returns at the spawn, and a
132
- // development build needs seconds after that before it listens — so the line
133
- // below used to be printed at a moment when nothing answered, and the next
134
- // command in the gate list got a connection reset.
130
+ // The supervisor returns at spawn; a development build needs time before it
131
+ // listens. Report readiness only after every role answers so the next gate
132
+ // can connect.
135
133
  await awaitRolesAnswering(roles);
136
134
  console.log(`${appDeclaration.identity.name} development processes are running`);
137
135
  for (const role of roles) console.log(`${role.name}: ${role.url}`);
@@ -0,0 +1,34 @@
1
+ import { describe, expect, test } from 'bun:test';
2
+ import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
3
+ import { tmpdir } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import { assertNoFixtureInBuild } from './fixture-boundary';
6
+
7
+ async function buildWith(content: string | undefined): Promise<string> {
8
+ const root = await mkdtemp(join(tmpdir(), 'fixture-boundary-'));
9
+ if (content !== undefined) {
10
+ await mkdir(join(root, '.next/server/app'), { recursive: true });
11
+ await writeFile(join(root, '.next/server/app/page.js'), content);
12
+ }
13
+ return root;
14
+ }
15
+
16
+ describe('assertNoFixtureInBuild', () => {
17
+ test('a clean build passes', async () => {
18
+ const root = await buildWith('export const page = 1');
19
+ await assertNoFixtureInBuild(root);
20
+ await rm(root, { recursive: true });
21
+ });
22
+
23
+ test('a build that carries the fixture is named', async () => {
24
+ const root = await buildWith('const m = "stitchkit-admin-fixture"');
25
+ await expect(assertNoFixtureInBuild(root)).rejects.toThrow('.next/server/app/page.js');
26
+ await rm(root, { recursive: true });
27
+ });
28
+
29
+ test('a build with no files is not a clean build', async () => {
30
+ const root = await buildWith(undefined);
31
+ await expect(assertNoFixtureInBuild(root)).rejects.toThrow('no built files');
32
+ await rm(root, { recursive: true });
33
+ });
34
+ });
@@ -0,0 +1,25 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { Glob } from 'bun';
4
+
5
+ /** The prefix of every row id in `features/admin/fixture`: data, so a bundler cannot drop it. */
6
+ const FIXTURE_MARKER = 'stitchkit-admin-fixture';
7
+
8
+ /**
9
+ * The fixture has to be absent from what a deployment serves, and only the built
10
+ * files can say so: a guard in the source proves intent, and a bundler that keeps
11
+ * the branch would still ship the rows. A build with no files is a wrong build,
12
+ * not a clean one.
13
+ */
14
+ export async function assertNoFixtureInBuild(webRoot: string): Promise<void> {
15
+ const root = join(webRoot, '.next');
16
+ if (!existsSync(root)) throw new Error(`${root} holds no built files to inspect`);
17
+ let inspected = 0;
18
+ for await (const path of new Glob('{server,static}/**/*.{js,map,json,html,rsc}').scan(root)) {
19
+ inspected += 1;
20
+ if ((await Bun.file(join(root, path)).text()).includes(FIXTURE_MARKER)) {
21
+ throw new Error(`.next/${path} carries the admin fixture`);
22
+ }
23
+ }
24
+ if (inspected === 0) throw new Error(`${root} holds no built files to inspect`);
25
+ }
@@ -5,10 +5,8 @@ import { join, resolve } from 'node:path';
5
5
  /**
6
6
  * Every repository path a guide names has to exist.
7
7
  *
8
- * `ADDING_A_FEATURE.md` is the one document a new consumer executes literally, and two of its
9
- * steps pointed at files the scaffold does not contain — `lib/api/client.ts` and a "shared
10
- * realtime source". The reader does not learn that by reading; they learn it by opening the path
11
- * and finding nothing, after having already trusted the sentence around it.
8
+ * A new consumer executes `ADDING_A_FEATURE.md` literally. Every referenced source file must
9
+ * exist so the reader can follow each step without discovering a missing path along the way.
12
10
  *
13
11
  * A path the guide tells you to CREATE is not a broken reference, so those are declared by the
14
12
  * guide itself: a line that introduces one carries `(created in this step)`. Everything else
@@ -43,9 +43,8 @@ export function declaredRoleReadiness(
43
43
  * An IPv6 literal is bracketed; everything else is written as it stands.
44
44
  *
45
45
  * `http://::1:3211/health` is not an address with a port — it is not a URL at
46
- * all, and `fetch` refuses it. A role bound to a specific IPv6 address is a
47
- * legitimate deployment, and it used to make the readiness wait fail on the
48
- * spelling rather than on the role.
46
+ * all, and `fetch` refuses it. Brackets let readiness probe a legitimate IPv6
47
+ * binding instead of failing on URL syntax.
49
48
  */
50
49
  function authority(host: string, port: string): string {
51
50
  const literal = host.includes(':') && !host.startsWith('[');
@@ -57,8 +56,8 @@ function authority(host: string, port: string): string {
57
56
  *
58
57
  * A supervisor returns as soon as it has SPAWNED a process, and a role needs
59
58
  * seconds after that before it listens. Printing "running" at the moment of the
60
- * spawn is a claim nobody checked: the next command in the gate list dialled
61
- * the declared port and got a connection reset, which reads as a broken check
59
+ * spawn is a claim nobody checked: the next command can dial the declared port
60
+ * before it listens and get a connection reset, which reads as a broken check
62
61
  * rather than an application still booting.
63
62
  */
64
63
  export async function awaitRolesAnswering(
@@ -43,10 +43,8 @@ describe('build artifacts are checked before roles start', () => {
43
43
  artifacts: ['packages/backend/nowhere'],
44
44
  },
45
45
  };
46
- // The test used to stop at the artifact name, which is why nobody noticed
47
- // that the second half of the sentence had become `[object Object]` when
48
- // commands turned into `{ executable, args }`. A diagnostic exists to be
49
- // retyped, so the assertion reads it the way an operator would.
46
+ // The full diagnostic must contain a command an operator can retype;
47
+ // serializing a command object as `[object Object]` is not actionable.
50
48
  expect(() => assertBuildArtifacts(unbuilt)).toThrow(
51
49
  /Missing build artifacts: packages\/backend\/nowhere — run `bun run build` first\./,
52
50
  );
@@ -33,8 +33,8 @@ const MIGRATION_COMMANDS: Record<string, string[]> = {
33
33
  * A declared command as an operator can retype it.
34
34
  *
35
35
  * `${command}` on a `{ executable, args }` object prints `[object Object]`, so
36
- * the one diagnostic that exists to tell an operator what to run told them
37
- * nothing. Quoting is deliberate: an argument with a space has to survive being
36
+ * a diagnostic using it cannot tell an operator what to run. Quoting is
37
+ * deliberate: an argument with a space has to survive being
38
38
  * read back.
39
39
  */
40
40
  export function formatCommand(command: { executable: string; args: string[] }): string {
@@ -21,9 +21,8 @@ describe('the portability check dials addresses the deployment claims', () => {
21
21
  });
22
22
 
23
23
  test('a deployment with nothing but its own address is told what to add', () => {
24
- // The reported failure, from the other side: the check used to carry two
25
- // fixture hosts of its own, so a deployment that had never been told about
26
- // them refused the request and the gate showed a bare 500.
24
+ // Portability probes require explicitly allowed hosts; inventing fixture
25
+ // hosts would make a deployment reject the request before the probe runs.
27
26
  const plan = planPortabilityCheck(dialled, { hosts: '127.0.0.1:3210' });
28
27
  expect(plan.kind).toBe('refuse');
29
28
  if (plan.kind !== 'refuse') return;
@@ -67,8 +66,8 @@ describe('the portability check dials addresses the deployment claims', () => {
67
66
 
68
67
  test('one host written twice is one address, not two', () => {
69
68
  // The count decides whether the property can be proved at all. Without
70
- // deduplication a duplicate entry passed as a second address and the check
71
- // compared the deployment with itself — a proof that cannot fail.
69
+ // deduplication a duplicate could count as a second address, making the
70
+ // check compare the deployment with itself — a proof that cannot fail.
72
71
  const plan = planPortabilityCheck(dialled, {
73
72
  hosts: '127.0.0.1:3210,alpha.example,alpha.example',
74
73
  });
@@ -90,7 +89,7 @@ describe('the portability check dials addresses the deployment claims', () => {
90
89
 
91
90
  describe('a gate list is not a deploy instruction', () => {
92
91
  // `runtime:smoke` and `e2e` check a running deployment, so the list has to
93
- // bring one up — and the wrong way to do that shipped once already:
92
+ // bring one up. It must not do that through `pm2:prod`:
94
93
  // `pm2:prod` applies the declared migrations and reloads the deployment the
95
94
  // developer is running. A gate creates and destroys its OWN deployment, and
96
95
  // that is `acceptance:local`.
@@ -158,7 +157,7 @@ describe('a role is ready when it answers, not when it is spawned', () => {
158
157
 
159
158
  test('an IPv6 bind address is bracketed, or it is not a URL at all', () => {
160
159
  // `http://::1:3211/health` cannot be parsed as an address with a port, so
161
- // the wait failed on the spelling instead of on the role.
160
+ // the wait would fail on URL syntax before it can reach the role.
162
161
  const addresses = declaredRoleReadiness(appDeclaration, {
163
162
  ...environment,
164
163
  BIND_HOST: '::1',
@@ -4,8 +4,8 @@ import { join } from 'node:path';
4
4
  /**
5
5
  * The web role refuses a mode it does not understand.
6
6
  *
7
- * `argv[2] === 'development' ? 'dev' : 'start'` meant a typo, an empty string
8
- * and a missing argument all became production in silence — the one decision
7
+ * `argv[2] === 'development' ? 'dev' : 'start'` would turn a typo, an empty string
8
+ * and a missing argument into production in silence — the one decision
9
9
  * that changes whether the role serves a build or compiles on demand. Run as a
10
10
  * real process, because the failure has to happen before Next is spawned.
11
11
  */
@@ -0,0 +1,13 @@
1
+ /**
2
+ * What a production deployment does not show, checked on a running one with
3
+ * `SERVICE_SURFACES=closed` and on the files it was built from.
4
+ */
5
+ import { join, resolve } from 'node:path';
6
+ import { assertNoFixtureInBuild } from './fixture-boundary';
7
+ import { loadToolingEnv } from './tooling-env';
8
+ import { assertServiceSurfacesClosed } from './web-surface-smoke';
9
+
10
+ const toolingEnv = loadToolingEnv();
11
+ await assertServiceSurfacesClosed(toolingEnv.SMOKE_WEB_ORIGIN, toolingEnv.SMOKE_API_ORIGIN);
12
+ await assertNoFixtureInBuild(join(resolve(import.meta.dir, '..'), 'packages/frontend'));
13
+ console.log('Service surfaces are closed, and the build carries no fixture');
@@ -1,11 +1,9 @@
1
1
  /**
2
2
  * A role whose cleanup will not complete, as a real process.
3
3
  *
4
- * The regression this serves cannot be written against a promise. The defect
5
- * was never "the helper resolved late" — it was that the role set
6
- * `process.exitCode` and then waited for an event loop something was still
7
- * holding, so the process lived until the supervisor's SIGKILL: exactly the
8
- * ending the cleanup budget exists to prevent. Only a process can show that.
4
+ * A promise cannot prove process termination: setting `process.exitCode` still
5
+ * waits for an event loop with held handles. The role must exit before the
6
+ * supervisor's SIGKILL, and only a real process can demonstrate that bound.
9
7
  *
10
8
  * The interval below is the held handle. Nothing ever clears it, so this
11
9
  * process ends only if something ends it — which is the assertion.
@@ -30,10 +30,8 @@ describe('the termination budget is an upper bound, not an estimate', () => {
30
30
  });
31
31
 
32
32
  test('a close that hangs stops being waited for, and is named', async () => {
33
- // The defect this exists for: the drain had a deadline, the closes after it
34
- // had none, so a hung MCP session or database pool ran past the very kill
35
- // timeout the budget had told the supervisor to allow — turning an orderly
36
- // shutdown into the SIGKILL that runs no cleanup at all.
33
+ // MCP and database closes must fit the shutdown budget as well as the drain.
34
+ // An unbounded close would reach the supervisor's SIGKILL, which runs no cleanup.
37
35
  const result = await closeWithinBudget(
38
36
  [{ name: 'MCP', close: () => new Promise<void>(() => undefined) }],
39
37
  25,
@@ -63,10 +61,8 @@ describe('the termination budget is an upper bound, not an estimate', () => {
63
61
  });
64
62
 
65
63
  test('a close that fails is a failure, and keeps its cause', async () => {
66
- // It used to be swallowed into `undefined` with the note that the budget is
67
- // about time. The budget is — but a close that throws is a shutdown that
68
- // did not happen, and reporting it as a clean exit with the reason gone is
69
- // how a broken shutdown looks exactly like a working one.
64
+ // Timeouts and rejections are different shutdown failures. A rejected close
65
+ // must retain its cause rather than appear as a successful clean exit.
70
66
  const result = await closeWithinBudget([
71
67
  { name: 'database', close: () => Promise.reject(new Error('pool already gone')) },
72
68
  ]);
@@ -42,7 +42,7 @@ async function roleReceivesSignal(from: 'role directory' | 'workspace root'): Pr
42
42
  // negative-pid signal below reach the role behind the launcher. The
43
43
  // NEGATIVE case is the point: there the role never sees the signal, so
44
44
  // killing the launcher alone would leave it running for the life of the
45
- // machine — this test used to leak one role per run.
45
+ // machine. Cleanup must reach the role even when the launcher cannot.
46
46
  const child =
47
47
  from === 'role directory'
48
48
  ? Bun.spawn(['bun', 'run', 'start'], {
@@ -9,9 +9,8 @@ function publicUrl(origin: string, path: string): URL {
9
9
  /**
10
10
  * Every dial is bounded.
11
11
  *
12
- * A gate that hangs is worse than one that fails: it reports nothing, ever. An
13
- * endpoint that accepts the connection and never answers used to stop the whole
14
- * run with no output and no deadline.
12
+ * Every request has a deadline: an endpoint can accept the connection without
13
+ * answering, and the gate must report that failure within a bounded time.
15
14
  */
16
15
  function dial(url: URL, init?: RequestInit): Promise<Response> {
17
16
  return fetch(url, { ...init, signal: AbortSignal.timeout(DIAL_TIMEOUT_MS) });
@@ -39,6 +38,39 @@ export async function assertPublicWebSurface(webOrigin: string): Promise<void> {
39
38
  }
40
39
  }
41
40
 
41
+ /** The paths a production deployment hides, with what still has to answer beside them. */
42
+ export async function assertServiceSurfacesClosed(
43
+ webOrigin: string,
44
+ apiOrigin: string,
45
+ ): Promise<void> {
46
+ const home = await dial(publicUrl(webOrigin, '/en'));
47
+ if (home.status !== 200) throw new Error(`GET /en returned ${home.status}`);
48
+ const health = await dial(publicUrl(apiOrigin, '/health'));
49
+ if (health.status !== 200)
50
+ throw new Error(`GET ${apiOrigin}/health returned ${health.status}`);
51
+ const closed = [
52
+ ...[
53
+ '/ui',
54
+ '/starter',
55
+ '/en/ui',
56
+ '/en/ui/components',
57
+ '/ru/ui/themes',
58
+ '/en/admin',
59
+ '/en/admin/people',
60
+ '/openapi.json',
61
+ ].map((path) => publicUrl(webOrigin, path)),
62
+ publicUrl(apiOrigin, '/openapi.json'),
63
+ ];
64
+ for (const url of closed) {
65
+ const response = await dial(url);
66
+ if (response.status !== 404) throw new Error(`GET ${url} returned ${response.status}`);
67
+ }
68
+ const sitemap = await dial(publicUrl(webOrigin, SITEMAP_PATH));
69
+ if ((await sitemap.text()).includes('/ui/')) {
70
+ throw new Error(`GET ${SITEMAP_PATH} still lists the closed catalogue`);
71
+ }
72
+ }
73
+
42
74
  /** What the deployment has been told about the addresses it serves. */
43
75
  export interface PublicHostPolicy {
44
76
  /** `PUBLIC_WEB_ORIGIN` — a single public address, stated outright. */
@@ -80,10 +112,8 @@ function claimedHosts(hosts: string | undefined): string[] {
80
112
  *
81
113
  * The check can only dial an address the deployment claims: a forwarded host
82
114
  * outside `PUBLIC_WEB_HOSTS` is refused on purpose, and rightly so. Naming two
83
- * fixture hosts here therefore meant the deployment had to have been told about
84
- * those exact two names by somebody else — which only the packed lane ever was.
85
- * Everyone running the same command against their own deployment got a bare
86
- * 500 from a policy working exactly as designed.
115
+ * fixture hosts here would require every deployment to allow those exact names,
116
+ * or make the probe fail on host policy before checking portability.
87
117
  *
88
118
  * So the deployment declares and the check reads, instead of two copies of the
89
119
  * same fixture that must agree across two repositories.
@@ -191,7 +221,7 @@ export async function assertArtifactIsPlacementFree(
191
221
 
192
222
  // Same rule, one layer down. A forwarded protocol outside `http | https` is a
193
223
  // misconfigured proxy or a forgery, and both have to be visible: mapping
194
- // every unknown value to `http` produced a plausible canonical origin from
224
+ // every unknown value to `http` would produce a plausible canonical origin from
195
225
  // `ftp`, `javascript` and a truncated header alike.
196
226
  const [claimedAddress] = plan.addresses;
197
227
  for (const proto of ['ftp', 'javascript', 'HTTPS://', '']) {
@@ -1,5 +1,8 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.5.14/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.6.5/schema.json",
3
+ "markdown": {
4
+ "formatter": { "enabled": false }
5
+ },
3
6
  "files": {
4
7
  "includes": ["**", "!!node_modules", "!!dist", "!!project.json", "!!**/.stitchkit"]
5
8
  },
@@ -6,6 +6,9 @@
6
6
  "catalog": {
7
7
  "stitchkit-tui": "^0.1.1"
8
8
  },
9
+ "overrides": {
10
+ "zod": "4.6.7"
11
+ },
9
12
  "scripts": {
10
13
  "dev": "bun --watch src/index.ts",
11
14
  "start": "bun src/index.ts",
@@ -16,21 +19,22 @@
16
19
  "build": "bun build src/index.ts --outdir dist --target bun --packages external"
17
20
  },
18
21
  "dependencies": {
19
- "@modelcontextprotocol/server": "^2.0.0",
22
+ "@modelcontextprotocol/server": "^2.4.0",
20
23
  "@openrouter/ai-sdk-provider": "^3.1.0",
21
- "ai": "^7.0.111",
22
- "stitchkit": "file:../../../core",
23
- "stitchkit-tui": "file:../../../tui",
24
- "zod": "4.6.5"
24
+ "ai": "^7.0.162",
25
+ "stitchkit": "link:../../../core",
26
+ "stitchkit-tui": "link:../../../tui",
27
+ "zod": "4.6.7"
25
28
  },
26
29
  "devDependencies": {
30
+ "@biomejs/biome": "2.6.5",
27
31
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
28
- "@types/bun": "^1.4.2",
32
+ "@types/bun": "^1.4.4",
29
33
  "@types/react": "^19.3.0",
30
34
  "typescript": "^7.0.2"
31
35
  },
32
36
  "engines": {
33
37
  "bun": ">=1.3.0"
34
38
  },
35
- "packageManager": "bun@1.4.2"
39
+ "packageManager": "bun@1.4.4"
36
40
  }
@@ -1,5 +1,8 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.5.14/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.6.5/schema.json",
3
+ "markdown": {
4
+ "formatter": { "enabled": false }
5
+ },
3
6
  "files": {
4
7
  "includes": ["**", "!!node_modules", "!!dist", "!!project.json", "!!**/.data"]
5
8
  },
@@ -3,6 +3,9 @@
3
3
  "private": true,
4
4
  "version": "0.1.0",
5
5
  "type": "module",
6
+ "overrides": {
7
+ "zod": "4.6.7"
8
+ },
6
9
  "scripts": {
7
10
  "dev": "bun --watch src/index.ts",
8
11
  "start": "bun dist/index.js",
@@ -15,16 +18,17 @@
15
18
  "dependencies": {
16
19
  "@grammyjs/auto-retry": "^2.0.2",
17
20
  "grammy": "^1.46.0",
18
- "stitchkit": "file:../../../core",
19
- "zod": "4.6.5"
21
+ "stitchkit": "link:../../../core",
22
+ "zod": "4.6.7"
20
23
  },
21
24
  "devDependencies": {
25
+ "@biomejs/biome": "2.6.5",
22
26
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
23
- "@types/bun": "^1.4.2",
27
+ "@types/bun": "^1.4.4",
24
28
  "typescript": "^7.0.2"
25
29
  },
26
30
  "engines": {
27
31
  "bun": ">=1.3.0"
28
32
  },
29
- "packageManager": "bun@1.4.2"
33
+ "packageManager": "bun@1.4.4"
30
34
  }