@skyf0xx/hedgehog-core-full-stack-app 1.2.0 → 1.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyf0xx/hedgehog-core-full-stack-app",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Hedgehog's full-stack-app core: an Nx/pnpm/NestJS/Next.js workspace, backend-first domain module build discipline, and the agents and skills that drive it.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -9,9 +9,10 @@ The operating loop for a bootstrapped Hedgehog project: `hedgehog claim`
9
9
  reserves the packet(s) for ready layers, build them, `hedgehog verify`
10
10
  gates and commits each. The build graph (`.hedgehog/hedgehog.db`) is the
11
11
  live list — query it via `hedgehog status`/`hedgehog ready`, never
12
- re-derive state from prose. The step tables below mirror this core's
12
+ re-derive state from prose. The step table in the [scaffolding
13
+ reference](references/scaffolding.md) mirrors this core's
13
14
  `workspace/core.yaml`, the design source of truth
14
- for layer order, scope, and verify command per layer — read the tables
15
+ for layer order, scope, and verify command per layer — read the table
15
16
  for the human-readable shape, and the YAML when they seem to disagree.
16
17
 
17
18
  The packet, though, is what actually runs. `hedgehog plan` copies each
@@ -96,49 +97,30 @@ What's authored on top is the entity-specific delta: the field list and
96
97
  its types, the module's business rules, and the UX intent behind its
97
98
  screen.
98
99
 
99
- ## Domain Module — Backend Steps (Phase A, every module in scope)
100
-
101
- A horizontal pass across the whole backend — every module goes through
102
- these before any module gets a hook or screen. Each row is one compiled
103
- layer in `full-stack-app/core.yaml`; delegate each module's Phase A
104
- layers to the `backend-eng` agent, one claimed packet per dispatch — it
105
- builds the layer, `hedgehog verify` gates and commits it.
106
-
107
- | # | Layer | Lives in | Commit |
108
- |---|---|---|---|
109
- | 1 | `schema` | `packages/db` (Drizzle) | `feat(<module>): schema` |
110
- | 2 | `contract` | `packages/contracts` (Zod via `drizzle-zod` + ts-rest) | `feat(<module>): contract` |
111
- | 3 | `repository` | `libs/<module>/repository` (port + Drizzle adapter) | `feat(<module>): repository` |
112
- | 4 | `service` | `libs/<module>/service` (domain logic — imports only ports) | `feat(<module>): service` |
113
- | 5 | `controller` | `apps/api` (thin HTTP, wires contract → service; bundles Queue infra, see above, if that add-on is on and this module needs it) | `feat(<module>): api` |
114
-
115
- Repeat 1–5 per module in scope, via `hedgehog claim`/`hedgehog verify`.
116
- The API is complete, typed, and callable (Postman/curl/contract tests)
117
- before frontend work starts.
118
-
119
- ## Domain Module — Frontend Steps (Phase B, after Phase A closes for the module)
120
-
121
- | # | Layer | Lives in | Commit |
122
- |---|---|---|---|
123
- | 6 | `hook` | `packages/hooks` (TanStack Query) | `feat(<module>): hooks` |
124
- | 6a | UX rationale | `docs/design/<module>.md`, `ux-planner` agent | bundled into layer 7's commit |
125
- | 7 | `screen` | `apps/web`, plus `apps/mobile` when the Mobile add-on is on | `feat(<module>): screen-web`, or `feat(<module>): screen` when the Mobile add-on is on |
126
-
127
- Phase B starts once Phase A is done for the scope. The frontend is a pure
128
- consumer of an already-finished API. Delegate each module's Phase B
129
- layers to the `front-end-eng` agent, same reasoning as `backend-eng` for
130
- Phase A — one claimed packet per dispatch, in its own context. Step
131
- 6a is where "how it should feel" gets decided — once per module, after
132
- the `hook` layer's task is `complete` and before `front-end-eng` starts
133
- the `screen` layer — via `ux-planner`, starting from whatever `planner`
134
- filed in `docs/design/<module>-notes.md` at planning intake, or the raw
135
- UX spec directly if that file is absent, or — where the archive holds
136
- neither — from the contract and hook plus whatever the user supplies when
137
- it asks. Its first run for a module also
138
- signals to the user that Phase B has started, and is the point a mockup,
139
- screenshot, or export (Google Stitch, Figma) can be handed over. It
140
- writes `docs/design/<module>.md`, not its own compiled layer — the
141
- `screen` layer's `hedgehog verify` is what gates and commits it.
100
+ ## Domain Module — Backend and Frontend Steps
101
+
102
+ Each module goes through `schema` → `contract` → `repository` → `service`
103
+ → `controller` in Phase A, then `hook` → `screen` in Phase B — the same
104
+ sequence "The Domain Module Pattern" above states. Read the [scaffolding
105
+ reference](references/scaffolding.md) for the full step table (layer,
106
+ where it lives, its commit message) and the generator command each layer
107
+ starts from. Delegate each module's Phase A layers to `backend-eng` and
108
+ Phase B layers to `front-end-eng`, one claimed packet per dispatch — it
109
+ builds the layer, `hedgehog verify` gates and commits it. The API is
110
+ complete, typed, and callable (Postman/curl/contract tests) before
111
+ frontend work starts.
112
+
113
+ Between the `hook` layer's task going `complete` and `front-end-eng`
114
+ starting the `screen` layer, `ux-planner` runs once per module to decide
115
+ "how it should feel" — starting from whatever `planner` filed in
116
+ `docs/design/<module>-notes.md` at planning intake, or the raw UX spec
117
+ directly if that file is absent, or — where the archive holds neither —
118
+ from the contract and hook plus whatever the user supplies when it asks.
119
+ Its first run for a module also signals to the user that Phase B has
120
+ started, and is the point a mockup, screenshot, or export (Google Stitch,
121
+ Figma) can be handed over. It writes `docs/design/<module>.md`, not its
122
+ own compiled layer — the `screen` layer's `hedgehog verify` is what gates
123
+ and commits it.
142
124
 
143
125
  ## The Loop (every unit of work)
144
126
 
@@ -245,183 +227,21 @@ or `lease_expired`).
245
227
 
246
228
  ## Scaffolding a layer
247
229
 
248
- `tools/generators/` holds one Nx generator per layer, and every layer
249
- starts from its own:
250
-
251
- ```bash
252
- nx g ./tools/generators:schema --module=<module> --fields='<name:type,...>'
253
- nx g ./tools/generators:contract --module=<module> --fields='<name:type,...>' [--toggleField=<boolField>]
254
- nx g ./tools/generators:repository --module=<module>
255
- nx g ./tools/generators:service --module=<module> [--toggleField=<boolField>]
256
- nx g ./tools/generators:controller --module=<module> --fields='<name:type,...>' [--toggleField=<boolField>]
257
- nx g ./tools/generators:hook --module=<module> [--toggleField=<boolField>]
258
- nx g ./tools/generators:screen --module=<module>
259
- ```
260
-
261
- `--module` is the domain module's plural kebab-case name (`tasks`,
262
- `order-items`). `--fields` is a comma-separated list of `name:type` pairs
263
- over `string`, `text`, `boolean`, `integer`, and `timestamp`, with a
264
- trailing `?` marking the column nullable
265
- (`--fields='title:string,done:boolean,dueDate:timestamp?'`); `contract`
266
- and `controller` take the same list the module's `schema` was generated
267
- with. A `string` field takes an optional length in parentheses
268
- (`title:string(500)`), threaded to both the Drizzle `varchar` and the Zod
269
- `.max()` so the two cannot disagree; omitted, it is 255. Check every
270
- length against the intent's own rules in the packet's **RELEVANT RULES** —
271
- a rule like "at most 500 characters" is the field list's business, not
272
- the authored delta's, and a Zod bound that outruns its column surfaces as
273
- a driver error at the database rather than a 400 at the boundary.
274
-
275
- `--toggleField` names a boolean field from the schema to expose as a
276
- toggle, and is passed to `contract`, `service`, `controller`, and `hook`
277
- alike — one flag, four layers, so the route, the domain method, the
278
- handler, and the mutation are generated from one source. The toggle is
279
- server-side by construction: `POST /<module>/:id/toggle` carries no body,
280
- and the service reads the current value and flips it inside the same
281
- transaction its `update` uses. The client sends only the id, so a stale
282
- cached row cannot overwrite a newer state — which is exactly what
283
- computing the new value on the client would do, losing one of any two
284
- flips that raced. Note that `@ts-rest/core` generates no `body` parameter
285
- for a `c.noBody()` route: the call is `client.toggle({ params: { id } })`,
286
- and passing `body: undefined` is a compile error.
287
-
288
- Each generator lands the whole conventional shape of its layer in one
289
- deterministic step — the package shell (`package.json`, `tsconfig*.json`,
290
- `vitest.config.mts`, `src/index.ts`) where the layer creates one, the
291
- `nx.tags` pair `packages/config/eslint-base.js`'s `depConstraints` keys
292
- on, the port-discipline file suffixes lint checks for, the Nest module
293
- and controller pair with `@Controller()` left bare (the ts-rest contract
294
- already encodes full route paths), and every barrel export the new files
295
- need. Hand-copying a sibling module's files invites exactly the drift
296
- `hedgehog verify`'s lint step then has to catch: missing tags, missing
297
- project references, a doubled route prefix.
298
-
299
- What the generator lands is the layer's skeleton, not the layer. Author
300
- the entity-specific delta on top: the module's business rules in
301
- `service`, its domain-error mapping in `controller`, and — for `screen`,
302
- which is skeleton-only by design — the layout, information hierarchy, and
303
- interaction pattern from `ux-planner`'s rationale, over the placeholders
304
- the generator leaves for the list, filter shell, empty state, and form.
305
-
306
- Registration inside `apps/api` is automatic and stays that way:
307
- `apps/api/src/app/feature-modules.ts` globs
308
- `apps/api/src/app/*/*.module.ts` and is regenerated by the
309
- `generate-feature-modules` Nx target that `build`/`typecheck`/`test`
310
- depend on. Never register a module by editing `app.module.ts` — a shared
311
- file no module-scoped task can safely touch. Validation is ts-rest + Zod,
312
- so this core has no Nest DTOs and no class-validator.
313
-
314
- The root page is the same: `apps/web/src/app/page.tsx` renders whatever
315
- `module-routes.ts` holds, and that file is regenerated by the
316
- `generate-module-routes` Nx target from every
317
- `apps/web/src/app/*/page.tsx` on disk. A screen layer creates its own
318
- `page.tsx` in its own directory and the root page picks it up — never
319
- edit either the root page or the generated file to add a link.
320
-
321
- **A new package needs wiring into the workspace before `hedgehog verify`
322
- runs on it.** A package that exists on disk isn't yet part of the
323
- workspace:
324
-
325
- ```bash
326
- pnpm install # link the new workspace:* deps
327
- pnpm nx sync # regenerate TypeScript project references
328
- ```
329
-
330
- `pnpm-workspace.yaml` already globs `packages/*`, `apps/*` and `libs/*/*`,
331
- so a package under any of those needs no edit there. This is the common
332
- case, not an edge case: any layer that is the first arrival in a package
333
- (`contract`, `hook`, each module's `repository` and `service`) or that
334
- wires a new package into an existing one (`controller`, adding the
335
- module's `contracts`/`repository`/`service` packages to `apps/api`) needs
336
- it — on a module's first pass through Phase A/B that is most of the
337
- layers, not an occasional one.
338
-
339
- The building agent runs `pnpm install` / `pnpm nx sync` and reports back
340
- which shared files changed (typically `pnpm-lock.yaml`, root
341
- `tsconfig.json`, and — on a `controller` layer — `apps/api/package.json`,
342
- `apps/api/tsconfig.app.json`), because it has the shell access to run
343
- them, but it never commits: no agent reporting success moves a task or
344
- touches git, only `hedgehog verify`'s passing exit code does (see the
345
- building agents' own Workflow step on this). Committing those shared
346
- files is the orchestrating session's job, done between dispatch and
347
- `hedgehog verify` on every layer where the agent flagged a change: expect
348
- it, don't wait to be reminded.
349
-
350
- ```bash
351
- git add pnpm-lock.yaml tsconfig.json # plus apps/*/package.json,
352
- # apps/*/tsconfig.app.json on a
353
- # controller layer
354
- git commit -m "chore(workspace): sync project references"
355
- ```
356
-
357
- These files are mechanically derived by `pnpm install` and `pnpm nx
358
- sync`, not authored content, and sit outside every module-scoped layer's
359
- scope — they belong to no layer, and no override covers them. Committing
360
- them separately, before `hedgehog verify` runs, keeps the layer's own
361
- commit exactly the layer.
362
-
363
- This is the orchestrating session's step rather than a verify post-step
364
- on purpose: `hedgehog verify` gates the tree it's handed, and a gate that
365
- mutates that tree would manufacture the scope violation it then reports.
230
+ Every layer starts from its own generator in `tools/generators/`, which
231
+ lands the layer's package shell, tags, and conventional shape in one
232
+ deterministic step, and a new package needs `pnpm install`/`pnpm nx sync`
233
+ wired in before `hedgehog verify` can run on it. Read the [scaffolding
234
+ reference](references/scaffolding.md) for the generator commands, flag
235
+ contract, and workspace-wiring steps.
366
236
 
367
237
  ## First arrival in a package
368
238
 
369
- Every layer scope names a directory *inside* a package
370
- (`packages/contracts/src/{module}/**`, `libs/{module}/repository/**`), and
371
- on the first module through that layer the package itself doesn't exist
372
- yet. Its shell — `package.json`, `tsconfig*.json`, `vitest.config.mts`,
373
- `src/index.ts` — necessarily lands outside the layer's scope glob, because
374
- no `{module}`-bearing glob can cover a package root. Left alone those files
375
- sit on disk uncommitted until the `join` layer's `**` scope sweeps them in,
376
- so `git log -- packages/contracts/` shows source with no buildable package
377
- behind it for the whole middle of the build.
378
-
379
- A generator can also drop shared, package-wide source at the `src/` root
380
- alongside the module's own files on that same first pass — the `contract`
381
- generator's `timestamp.ts` is one (a shared Zod util every module in the
382
- package imports, written once, sibling to `src/index.ts`). That file needs
383
- the same widening as the shell itself.
384
-
385
- The packet says so: when the package a scope points into has no
386
- `package.json` on disk yet, `hedgehog next`/`show` prints a **FIRST
387
- ARRIVAL** section under ALLOWED SCOPE carrying the exact command for that
388
- task. Run it before building — the widening is only available while the
389
- task is still `ready`, and a verify that rejects the shell paths blocks
390
- the task and turns this into a five-command recovery.
391
-
392
- ```bash
393
- hedgehog override add TASKS-CONTRACT \
394
- --scope 'packages/contracts/*' \
395
- --scope 'packages/contracts/src/*' \
396
- --reason 'first module through the contract layer also creates the package shell'
397
- ```
398
-
399
- `packages/contracts/src/*` is non-recursive, so it covers `src/index.ts`
400
- and `src/timestamp.ts` without also granting the module subdirectory the
401
- layer's own `packages/contracts/src/{module}/**` scope already covers.
402
-
403
- `.hedgehog/overrides/*.json` is additive, per-task, committed, and replayed
404
- by `plan`, `--recompile` and `db rebuild` alike, so the exception survives a
405
- rebuild and stays reviewable in the diff — unlike a hand-edited task row,
406
- which the next rebuild silently drops. It widens exactly the one task that
407
- creates the package, not the layer, so module two's task keeps the narrow
408
- scope.
409
-
410
- Which tasks need it: the first module through `contract`
411
- (`packages/contracts`) and through `hook` (`packages/hooks`), and every
412
- module's `repository` and `service`, since `libs/{module}/repository` and
413
- `libs/{module}/service` are new libs per module — there, the layer's own
414
- `libs/{module}/repository/**` glob already covers the package root, so no
415
- override is needed. `packages/db` and `packages/config` ship with core, so
416
- `schema` never needs one. `controller` never needs one either — `apps/api`
417
- ships with core, and its `apps/api/src/app/{module}/**` scope already
418
- covers the module's generated directory.
419
-
420
- Never widen a scope to route around a violation the Correction Protocol
421
- should handle — this is for a package shell the layer genuinely creates,
422
- nothing else. The shell itself comes from the layer's generator
423
- ("Scaffolding a layer" above), which is also where the workspace wiring a
424
- new package needs lives.
239
+ The first module through a layer whose scope names a directory inside a
240
+ package that doesn't exist yet on disk needs its scope widened for that
241
+ one task, since the package shell lands outside the layer's own
242
+ `{module}`-bearing glob. Read the [first arrival
243
+ reference](references/first-arrival.md) for which layers this applies to
244
+ and the `hedgehog override add` command it calls for.
425
245
 
426
246
  ## Intra-step conventions
427
247
 
@@ -0,0 +1,60 @@
1
+ # First arrival in a package
2
+
3
+ Every layer scope names a directory *inside* a package
4
+ (`packages/contracts/src/{module}/**`, `libs/{module}/repository/**`), and
5
+ on the first module through that layer the package itself doesn't exist
6
+ yet. Its shell — `package.json`, `tsconfig*.json`, `vitest.config.mts`,
7
+ `src/index.ts` — necessarily lands outside the layer's scope glob, because
8
+ no `{module}`-bearing glob can cover a package root. Left alone those files
9
+ sit on disk uncommitted until the `join` layer's `**` scope sweeps them in,
10
+ so `git log -- packages/contracts/` shows source with no buildable package
11
+ behind it for the whole middle of the build.
12
+
13
+ A generator can also drop shared, package-wide source at the `src/` root
14
+ alongside the module's own files on that same first pass — the `contract`
15
+ generator's `timestamp.ts` is one (a shared Zod util every module in the
16
+ package imports, written once, sibling to `src/index.ts`). That file needs
17
+ the same widening as the shell itself. See [scaffolding a
18
+ layer](scaffolding.md) for what a layer's generator lands and the
19
+ `pnpm install` / `pnpm nx sync` workspace wiring a new package needs.
20
+
21
+ The packet says so: when the package a scope points into has no
22
+ `package.json` on disk yet, `hedgehog next`/`show` prints a **FIRST
23
+ ARRIVAL** section under ALLOWED SCOPE carrying the exact command for that
24
+ task. Run it before building — the widening is only available while the
25
+ task is still `ready`, and a verify that rejects the shell paths blocks
26
+ the task and turns this into a five-command recovery.
27
+
28
+ ```bash
29
+ hedgehog override add TASKS-CONTRACT \
30
+ --scope 'packages/contracts/*' \
31
+ --scope 'packages/contracts/src/*' \
32
+ --reason 'first module through the contract layer also creates the package shell'
33
+ ```
34
+
35
+ `packages/contracts/src/*` is non-recursive, so it covers `src/index.ts`
36
+ and `src/timestamp.ts` without also granting the module subdirectory the
37
+ layer's own `packages/contracts/src/{module}/**` scope already covers.
38
+
39
+ `.hedgehog/overrides/*.json` is additive, per-task, committed, and replayed
40
+ by `plan`, `--recompile` and `db rebuild` alike, so the exception survives a
41
+ rebuild and stays reviewable in the diff — unlike a hand-edited task row,
42
+ which the next rebuild silently drops. It widens exactly the one task that
43
+ creates the package, not the layer, so module two's task keeps the narrow
44
+ scope.
45
+
46
+ Which tasks need it: the first module through `contract`
47
+ (`packages/contracts`) and through `hook` (`packages/hooks`), and every
48
+ module's `repository` and `service`, since `libs/{module}/repository` and
49
+ `libs/{module}/service` are new libs per module — there, the layer's own
50
+ `libs/{module}/repository/**` glob already covers the package root, so no
51
+ override is needed. `packages/db` and `packages/config` ship with core, so
52
+ `schema` never needs one. `controller` never needs one either — `apps/api`
53
+ ships with core, and its `apps/api/src/app/{module}/**` scope already
54
+ covers the module's generated directory.
55
+
56
+ Never widen a scope to route around a violation the Correction Protocol
57
+ should handle — this is for a package shell the layer genuinely creates,
58
+ nothing else. The shell itself comes from the layer's generator, which is
59
+ also where the workspace wiring a new package needs lives (see
60
+ [scaffolding a layer](scaffolding.md)).
@@ -0,0 +1,151 @@
1
+ # Scaffolding a layer
2
+
3
+ Every module in this core goes through the same layer sequence, in order:
4
+
5
+ ```
6
+ schema (Drizzle) — types before data
7
+ contract (Zod / ts-rest) — the boundary
8
+ repository (port + Drizzle adapter)
9
+ service (domain logic) — imports only ports
10
+ controller (thin HTTP)
11
+ hook (TanStack Query) — Phase B only
12
+ screen (Next.js / Expo) — Phase B only
13
+ ```
14
+
15
+ `workspace/core.yaml` declares this as `pattern: vertical-slice` — every
16
+ layer's scope carries `{module}`, so the chain runs once per module,
17
+ independently, joined only at the exclusive `join` layer. Each row below
18
+ is one compiled layer; `backend-eng` builds the Phase A rows (`schema`
19
+ through `controller`), `front-end-eng` builds the Phase B rows (`hook`,
20
+ `screen`), one claimed packet per dispatch — it builds the layer,
21
+ `hedgehog verify` gates and commits it.
22
+
23
+ | # | Layer | Lives in | Commit |
24
+ |---|---|---|---|
25
+ | 1 | `schema` | `packages/db` (Drizzle) | `feat(<module>): schema` |
26
+ | 2 | `contract` | `packages/contracts` (Zod via `drizzle-zod` + ts-rest) | `feat(<module>): contract` |
27
+ | 3 | `repository` | `libs/<module>/repository` (port + Drizzle adapter) | `feat(<module>): repository` |
28
+ | 4 | `service` | `libs/<module>/service` (domain logic — imports only ports) | `feat(<module>): service` |
29
+ | 5 | `controller` | `apps/api` (thin HTTP, wires contract → service; bundles Queue infra if that add-on is on and this module needs it) | `feat(<module>): api` |
30
+ | 6 | `hook` | `packages/hooks` (TanStack Query) | `feat(<module>): hooks` |
31
+ | 7 | `screen` | `apps/web`, plus `apps/mobile` when the Mobile add-on is on | `feat(<module>): screen-web`, or `feat(<module>): screen` when the Mobile add-on is on |
32
+
33
+ `tools/generators/` holds one Nx generator per layer, and every layer
34
+ starts from its own:
35
+
36
+ ```bash
37
+ nx g ./tools/generators:schema --module=<module> --fields='<name:type,...>'
38
+ nx g ./tools/generators:contract --module=<module> --fields='<name:type,...>' [--toggleField=<boolField>]
39
+ nx g ./tools/generators:repository --module=<module>
40
+ nx g ./tools/generators:service --module=<module> [--toggleField=<boolField>]
41
+ nx g ./tools/generators:controller --module=<module> --fields='<name:type,...>' [--toggleField=<boolField>]
42
+ nx g ./tools/generators:hook --module=<module> [--toggleField=<boolField>]
43
+ nx g ./tools/generators:screen --module=<module>
44
+ ```
45
+
46
+ `--module` is the domain module's plural kebab-case name (`tasks`,
47
+ `order-items`). `--fields` is a comma-separated list of `name:type` pairs
48
+ over `string`, `text`, `boolean`, `integer`, and `timestamp`, with a
49
+ trailing `?` marking the column nullable
50
+ (`--fields='title:string,done:boolean,dueDate:timestamp?'`); `contract`
51
+ and `controller` take the same list the module's `schema` was generated
52
+ with. A `string` field takes an optional length in parentheses
53
+ (`title:string(500)`), threaded to both the Drizzle `varchar` and the Zod
54
+ `.max()` so the two cannot disagree; omitted, it is 255. Check every
55
+ length against the intent's own rules in the packet's **RELEVANT RULES** —
56
+ a rule like "at most 500 characters" is the field list's business, not
57
+ the authored delta's, and a Zod bound that outruns its column surfaces as
58
+ a driver error at the database rather than a 400 at the boundary.
59
+
60
+ `--toggleField` names a boolean field from the schema to expose as a
61
+ toggle, and is passed to `contract`, `service`, `controller`, and `hook`
62
+ alike — one flag, four layers, so the route, the domain method, the
63
+ handler, and the mutation are generated from one source. The toggle is
64
+ server-side by construction: `POST /<module>/:id/toggle` carries no body,
65
+ and the service reads the current value and flips it inside the same
66
+ transaction its `update` uses. The client sends only the id, so a stale
67
+ cached row cannot overwrite a newer state — which is exactly what
68
+ computing the new value on the client would do, losing one of any two
69
+ flips that raced. Note that `@ts-rest/core` generates no `body` parameter
70
+ for a `c.noBody()` route: the call is `client.toggle({ params: { id } })`,
71
+ and passing `body: undefined` is a compile error.
72
+
73
+ Each generator lands the whole conventional shape of its layer in one
74
+ deterministic step — the package shell (`package.json`, `tsconfig*.json`,
75
+ `vitest.config.mts`, `src/index.ts`) where the layer creates one, the
76
+ `nx.tags` pair `packages/config/eslint-base.js`'s `depConstraints` keys
77
+ on, the port-discipline file suffixes lint checks for, the Nest module
78
+ and controller pair with `@Controller()` left bare (the ts-rest contract
79
+ already encodes full route paths), and every barrel export the new files
80
+ need. Hand-copying a sibling module's files invites exactly the drift
81
+ `hedgehog verify`'s lint step then has to catch: missing tags, missing
82
+ project references, a doubled route prefix.
83
+
84
+ What the generator lands is the layer's skeleton, not the layer. Author
85
+ the entity-specific delta on top: the module's business rules in
86
+ `service`, its domain-error mapping in `controller`, and — for `screen`,
87
+ which is skeleton-only by design — the layout, information hierarchy, and
88
+ interaction pattern from `ux-planner`'s rationale, over the placeholders
89
+ the generator leaves for the list, filter shell, empty state, and form.
90
+
91
+ Registration inside `apps/api` is automatic and stays that way:
92
+ `apps/api/src/app/feature-modules.ts` globs
93
+ `apps/api/src/app/*/*.module.ts` and is regenerated by the
94
+ `generate-feature-modules` Nx target that `build`/`typecheck`/`test`
95
+ depend on. Never register a module by editing `app.module.ts` — a shared
96
+ file no module-scoped task can safely touch. Validation is ts-rest + Zod,
97
+ so this core has no Nest DTOs and no class-validator.
98
+
99
+ The root page is the same: `apps/web/src/app/page.tsx` renders whatever
100
+ `module-routes.ts` holds, and that file is regenerated by the
101
+ `generate-module-routes` Nx target from every
102
+ `apps/web/src/app/*/page.tsx` on disk. A screen layer creates its own
103
+ `page.tsx` in its own directory and the root page picks it up — never
104
+ edit either the root page or the generated file to add a link.
105
+
106
+ **A new package needs wiring into the workspace before `hedgehog verify`
107
+ runs on it.** A package that exists on disk isn't yet part of the
108
+ workspace:
109
+
110
+ ```bash
111
+ pnpm install # link the new workspace:* deps
112
+ pnpm nx sync # regenerate TypeScript project references
113
+ ```
114
+
115
+ `pnpm-workspace.yaml` already globs `packages/*`, `apps/*` and `libs/*/*`,
116
+ so a package under any of those needs no edit there. This is the common
117
+ case, not an edge case: any layer that is the first arrival in a package
118
+ (`contract`, `hook`, each module's `repository` and `service`) or that
119
+ wires a new package into an existing one (`controller`, adding the
120
+ module's `contracts`/`repository`/`service` packages to `apps/api`) needs
121
+ it — on a module's first pass through Phase A/B that is most of the
122
+ layers, not an occasional one. See [first arrival in a
123
+ package](first-arrival.md) for the scope-widening override this same
124
+ situation needs.
125
+
126
+ The building agent runs `pnpm install` / `pnpm nx sync` and reports back
127
+ which shared files changed (typically `pnpm-lock.yaml`, root
128
+ `tsconfig.json`, and — on a `controller` layer — `apps/api/package.json`,
129
+ `apps/api/tsconfig.app.json`), because it has the shell access to run
130
+ them, but it never commits: no agent reporting success moves a task or
131
+ touches git, only `hedgehog verify`'s passing exit code does. Committing
132
+ those shared files is the orchestrating session's job, done between
133
+ dispatch and `hedgehog verify` on every layer where the agent flagged a
134
+ change: expect it, don't wait to be reminded.
135
+
136
+ ```bash
137
+ git add pnpm-lock.yaml tsconfig.json # plus apps/*/package.json,
138
+ # apps/*/tsconfig.app.json on a
139
+ # controller layer
140
+ git commit -m "chore(workspace): sync project references"
141
+ ```
142
+
143
+ These files are mechanically derived by `pnpm install` and `pnpm nx
144
+ sync`, not authored content, and sit outside every module-scoped layer's
145
+ scope — they belong to no layer, and no override covers them. Committing
146
+ them separately, before `hedgehog verify` runs, keeps the layer's own
147
+ commit exactly the layer.
148
+
149
+ This is the orchestrating session's step rather than a verify post-step
150
+ on purpose: `hedgehog verify` gates the tree it's handed, and a gate that
151
+ mutates that tree would manufacture the scope violation it then reports.