@starci/eslint-canon-be 2.0.1 → 2.1.1

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 (77) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/data-access.mjs +1 -1
  4. package/index.mjs +2 -0
  5. package/lib/unit-spec.mjs +3 -3
  6. package/package.json +1 -1
  7. package/project-graph.mjs +23 -0
  8. package/runtime/knowledge/hfs/canon-pins.yaml +170 -0
  9. package/runtime/knowledge/patterns/fe/folder.yaml +309 -0
  10. package/runtime/knowledge/sonar-gate.yaml +86 -0
  11. package/runtime/packages/hfs/templates/be/package-scripts/package.json +19 -0
  12. package/runtime/packages/hfs/templates/fe/package-scripts/package.json +13 -0
  13. package/runtime/scripts/checks/architecture/backend.mjs +350 -0
  14. package/runtime/scripts/checks/architecture/background-unowned.mjs +107 -0
  15. package/runtime/scripts/checks/architecture/client-reaches-server.mjs +94 -0
  16. package/runtime/scripts/checks/architecture/clones.mjs +200 -0
  17. package/runtime/scripts/checks/architecture/config-unread.mjs +35 -0
  18. package/runtime/scripts/checks/architecture/config.mjs +310 -0
  19. package/runtime/scripts/checks/architecture/connection-map.mjs +208 -0
  20. package/runtime/scripts/checks/architecture/constructor-deps.mjs +100 -0
  21. package/runtime/scripts/checks/architecture/contract-fixture-guard.mjs +128 -0
  22. package/runtime/scripts/checks/architecture/contracts.mjs +792 -0
  23. package/runtime/scripts/checks/architecture/cross-app-duplicate.mjs +73 -0
  24. package/runtime/scripts/checks/architecture/dead-exports.mjs +265 -0
  25. package/runtime/scripts/checks/architecture/default-deny.mjs +129 -0
  26. package/runtime/scripts/checks/architecture/doc-language.mjs +39 -0
  27. package/runtime/scripts/checks/architecture/entrypoint.mjs +57 -0
  28. package/runtime/scripts/checks/architecture/error-codes.mjs +45 -0
  29. package/runtime/scripts/checks/architecture/error-masked.mjs +60 -0
  30. package/runtime/scripts/checks/architecture/fe-slot-allows.mjs +38 -0
  31. package/runtime/scripts/checks/architecture/feature-shape.mjs +49 -0
  32. package/runtime/scripts/checks/architecture/framework-pinned.mjs +83 -0
  33. package/runtime/scripts/checks/architecture/frontend.mjs +995 -0
  34. package/runtime/scripts/checks/architecture/hfs-graph.mjs +61 -0
  35. package/runtime/scripts/checks/architecture/hfs.mjs +521 -0
  36. package/runtime/scripts/checks/architecture/hooks-are-hooks.mjs +88 -0
  37. package/runtime/scripts/checks/architecture/i18n-keys.mjs +146 -0
  38. package/runtime/scripts/checks/architecture/index.mjs +321 -0
  39. package/runtime/scripts/checks/architecture/injection-token-exported.mjs +62 -0
  40. package/runtime/scripts/checks/architecture/machine-ast.mjs +138 -0
  41. package/runtime/scripts/checks/architecture/module-per-transport.mjs +130 -0
  42. package/runtime/scripts/checks/architecture/next-data.mjs +775 -0
  43. package/runtime/scripts/checks/architecture/owners.mjs +95 -0
  44. package/runtime/scripts/checks/architecture/package-shape.mjs +63 -0
  45. package/runtime/scripts/checks/architecture/reachability.mjs +233 -0
  46. package/runtime/scripts/checks/architecture/register-once.mjs +141 -0
  47. package/runtime/scripts/checks/architecture/registration.mjs +319 -0
  48. package/runtime/scripts/checks/architecture/required-files.mjs +172 -0
  49. package/runtime/scripts/checks/architecture/route-files-thin.mjs +97 -0
  50. package/runtime/scripts/checks/architecture/schema-owner.mjs +261 -0
  51. package/runtime/scripts/checks/architecture/source-names.mjs +607 -0
  52. package/runtime/scripts/checks/architecture/sql-owner.mjs +142 -0
  53. package/runtime/scripts/checks/architecture/sql-tokens.mjs +327 -0
  54. package/runtime/scripts/checks/architecture/surface.mjs +91 -0
  55. package/runtime/scripts/checks/architecture/symbols.mjs +193 -0
  56. package/runtime/scripts/checks/architecture/test-world-files.mjs +163 -0
  57. package/runtime/scripts/checks/architecture/tiers.mjs +130 -0
  58. package/runtime/scripts/checks/architecture/transport-owner.mjs +112 -0
  59. package/runtime/scripts/checks/architecture/typescript.mjs +573 -0
  60. package/runtime/scripts/checks/architecture/unit-spec-providers.mjs +122 -0
  61. package/runtime/scripts/checks/common.mjs +44 -0
  62. package/runtime/scripts/checks/typescript-programs.mjs +82 -0
  63. package/runtime/scripts/lib/hfs-path-findings.mjs +84 -0
  64. package/runtime/scripts/lib/hfs-rules/fe-no-tests.mjs +47 -0
  65. package/runtime/scripts/lib/hfs-rules/read.mjs +28 -0
  66. package/runtime/scripts/lib/hfs-rules/secrets.mjs +54 -0
  67. package/runtime/scripts/lib/hfs-rules/spec-placement.mjs +29 -0
  68. package/runtime/scripts/lib/json.mjs +22 -0
  69. package/runtime/scripts/lib/project-graph.mjs +0 -0
  70. package/runtime/scripts/lib/project-rule.mjs +39 -0
  71. package/runtime/scripts/lib/repo-identity.mjs +50 -0
  72. package/runtime/scripts/lib/secret-patterns.mjs +44 -0
  73. package/runtime/scripts/lib/stack-services.mjs +217 -0
  74. package/runtime/scripts/lib/test-secrets.mjs +120 -0
  75. package/test-world.mjs +2 -3
  76. package/testing.mjs +1 -1
  77. package/unit-spec.mjs +43 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.1 - 2026-10-01
4
+
5
+ - Fixed: every rule failed to load in product repositories ("the managed package-scripts template ... cannot be found next to the runtime"): the bundled runtime now carries the data files the architecture machine reads beside its code (the managed package-scripts templates, canon-pins and the Sonar gate). A new runtime spec, `tests/canon-packed-load.spec.mjs`, installs each canon from its packed tarball into a real HFS repository and requires every rule to load.
6
+
7
+ ## 2.1.0 - 2026-10-01
8
+
9
+ - New: the `project-graph` law: the TS-attached architecture checks (tiers, owners, dead exports, composition, data, paths) as eslint rules at error on the offending line, from one cached project graph per lint run.
10
+ - New: `spec-exact-values` (R48): `expect.any(String|Number|Date)` in a `*.service.spec.ts` is refused; ids come from `fakeIds()` and dates from `FakeClock` and are asserted exactly.
11
+
12
+ - Changed: Back-end apps have no composition spec, including the migrate app. `unit-test-colocated` has no app exception; only service unit specs and the integration, e2e and contract layers remain.
13
+
3
14
  ## 2.0.1 - 2026-10-01
4
15
 
5
16
  - Fixed: `e2e-asserts-persisted-state` accepts `<world>.db.<connection>` and `<world>.services.<name>.api` state reads, the world identified by its `TestWorld` type (from `@starci/test-world` or the `be.tests.world` slot), not by a variable name.
@@ -8,6 +19,7 @@
8
19
 
9
20
  - Changed (lane PORT): `ruleParams.be.infraOwners` names `@nestjs/cache-manager` (the `CACHE_MANAGER` token) beside `cache-manager`: it is reached only by `integrations/cache` and `integrations/redis`, which is the retired repository rule `must-use-cache-service`; `infra-import-owner` (R90) covers it with a passing and a violating case.
10
21
  - Changed (lane UT): `inbox-dedupe-required` (R80) moves from the door to the service. It judges the public methods of a `*.service.ts` whose first parameter TYPE has an `eventId` property: the first awaited expression must be `claim(source, eventId, ...)` on the `Inbox` port, with an early return on `false`. Consumers and `SignedWebhook` controllers are no longer judged by it, and `transport-is-thin` no longer allows an `Inbox` injection or an inbox guard in a door.
22
+ - New `spec-exact-values` (R48, unit-spec law): a `*.service.spec.ts` never asserts `expect.any(String)`, `expect.any(Number)` or `expect.any(Date)` (`expect` resolved as the jest global or the `@jest/globals` import); ids come from `fakeIds()` and dates from `FakeClock`, so the spec asserts the exact value.
11
23
  - Changed: `transport-is-thin` allows `unwrapOutcome` of `platform/primitives` (resolved by its symbol) beside the bus call and pure mapper functions.
12
24
  - Fixed: `infra-needs-injector` (R85) no longer judges the constructor of a CQRS message (`extends Command<R>` / `Query<R>` of `@nestjs/cqrs`): its `params` is data built with `new`.
13
25
  - Changed (lane UT, unit-test standard 2026-09-30): `unit-test-colocated` (R47) no longer keeps twin specs for handlers, guards, mappers, policies, clients and row mappers. Only a service is unit-tested: a `<name>.service.ts` has its `<name>.service.spec.ts` beside it (message `missing`), a unit spec (a `*.spec.ts` outside `src/tests/{e2e,integration,contract,world}` and `apps/migrate`) must be a `<name>.service.spec.ts` beside its service (`notService`, `orphan`), and a composition spec is no longer a unit kind.
package/README.md CHANGED
@@ -49,7 +49,7 @@ A sample, not the list:
49
49
  | **Log safety** | A call on the `Logger` port (found by the receiver's type) passes no `Secret` or `Pii` value and no value named like a credential or a personal identifier (`no-secret-in-log`) |
50
50
  | **Async and types** | An `async` function awaits; handlers and public methods declare a return type; no `Function` type, no `eval`; an inline object type takes a name; no `const enum`. Casts, `x!` and `any` are refused in every file, specs included, by the typescript-eslint rules the factory turns on (`async-needs-await`, `explicit-handler-return-type`, `no-function-or-eval`, `no-inline-param-type`, `no-inline-object-type`, `no-const-enum`) |
51
51
  | **Migrations and input** | A migration's `down()` reverses its `up()`; every property of an input class has the `class-validator` decorators its type calls for (string `@MaxLength`, enum `@IsEnum`, array `@ArrayMaxSize`, nested `@ValidateNested()` and `@Type`); reads page by cursor, never by `skip`, `offset` or `OFFSET` (`migration-down-reversible`, `input-bounded`, `no-offset-pagination`) |
52
- | **Spec quality** | A spec does not read repository source with `fs` (`spec-no-source-read`); the borrowed `consistent-type-assertions` (`never`) and `no-non-null-assertion` leave no `as` and no `x!` in a spec, and `no-ambient-clock` and `no-direct-env-read` cover specs, so no `Date.now()`, argless `new Date()` or `process.env`. A unit spec is `<name>.service.spec.ts`: it builds its subject with `Test.createTestingModule({ providers })` from `@nestjs/testing`, `.compile()` and `moduleRef.get(...)` (`spec-builds-with-testing-module`), never `new` on the service (`spec-no-new-subject`), no `imports` key and no `override*` (`spec-module-definition-only-providers`), no `jest.mock`/`doMock`/`unstable_mockModule`/`requireMock` of an own module or a library (`spec-no-module-mock`), no cast-laundering helper in a spec or fixture: a return-only generic, an `unknown` handed back as another type, `JSON.parse(JSON.stringify(x))`, `Object.assign(new X(), y)` returned as another type (`no-return-only-generic`); a provider `{ provide: TOKEN, useValue: X }` takes X from the matching `@starci/jest-preset` double, the token table being `ruleParams.be.specDoubles` of the slot manifest (`spec-infra-double-from-kit`); the EntityManager double is the kit's `mockEntityManager()`/`fakeTransaction()`, never ad hoc (`spec-typed-entity-manager`); test data goes through builders, see the **Test data builders** row |
52
+ | **Spec quality** | A spec does not read repository source with `fs` (`spec-no-source-read`); the borrowed `consistent-type-assertions` (`never`) and `no-non-null-assertion` leave no `as` and no `x!` in a spec, and `no-ambient-clock` and `no-direct-env-read` cover specs, so no `Date.now()`, argless `new Date()` or `process.env`. A unit spec is `<name>.service.spec.ts`: it builds its subject with `Test.createTestingModule({ providers })` from `@nestjs/testing`, `.compile()` and `moduleRef.get(...)` (`spec-builds-with-testing-module`), never `new` on the service (`spec-no-new-subject`), no `imports` key and no `override*` (`spec-module-definition-only-providers`), no `jest.mock`/`doMock`/`unstable_mockModule`/`requireMock` of an own module or a library (`spec-no-module-mock`), no cast-laundering helper in a spec or fixture: a return-only generic, an `unknown` handed back as another type, `JSON.parse(JSON.stringify(x))`, `Object.assign(new X(), y)` returned as another type (`no-return-only-generic`); a provider `{ provide: TOKEN, useValue: X }` takes X from the matching `@starci/jest-preset` double, the token table being `ruleParams.be.specDoubles` of the slot manifest (`spec-infra-double-from-kit`); a unit spec asserts exact values, never `expect.any(String)`, `expect.any(Number)` or `expect.any(Date)` (`expect` being the jest global or the `@jest/globals` import): ids come from `fakeIds()` and dates from `FakeClock` (`spec-exact-values`); the EntityManager double is the kit's `mockEntityManager()`/`fakeTransaction()`, never ad hoc (`spec-typed-entity-manager`); test data goes through builders, see the **Test data builders** row |
53
53
  | **Test data builders** (R98 to R101) | Builders live only in `src/tests/fixtures/builders/<area>.builder.ts`: a module of the test tree that exports a function creating persisted rows through an EntityManager, DataSource or QueryRunner is a builder wherever it sits (`persisting-builder-in-builders-slot`, R98); a spec never runs a raw INSERT/UPDATE/DELETE or a direct write (`save`, `insert`, `upsert`, `update`, `delete`, `remove`) on a typeorm receiver and never builds the same `@Entity` class as an object literal twice (`spec-no-raw-insert`, `spec-no-repeated-row-literal`, R99); a builder never asserts and has deterministic defaults (`builder-arranges-only`, R101); nothing under `src/tests` disables or drops a constraint (`tests-keep-constraints`, R100) |
54
54
  | **CQRS** | A message extends `Command<R>` / `Query<R>` from `@nestjs/cqrs`, carries one `readonly params: ExecuteParams<X>` (no entity reachable from `X`), a handler extends `ICQRSHandler` and overrides `process`; a handler is thin: it injects only `*Service` classes and the Logger, and `process` is one `return this.<service>.<method>(...)` with no branch, loop, EntityManager or second call (`handler-is-thin`); no `*.use-case.ts`, no forwarder service, no `EventBus` or `@nestjs/event-emitter` (`handler-overrides-process`, `message-carries-params-only`, `message-typed-result`, `execute-params-shape`, `no-use-case`, `no-event-bus`) |
55
55
  | **Module layering** | Another owner is imported through its public `index.ts` (`@modules/domain/plan`, `@features/plan`), never through a path into it, and a same-owner import is relative and never through the own index (`import-owner-entry`); an owner has one `index.ts` (a nested one is refused) that holds only named `export { }` lines, with no `export *`, and a bounded number of names (`no-folder-reexport`); self-aliases and relative escapes are refused (`no-self-module-alias`, `no-relative-capability-escape`). Owners come from the HFS slots, aliases from the program's `compilerOptions.paths`. |
package/data-access.mjs CHANGED
@@ -69,7 +69,7 @@ export const namedEntityManagerOnly = {
69
69
  schema: [],
70
70
  messages: {
71
71
  property:
72
- "`{{type}}` is injected as a class property. Property injection hides the dependency from the constructor and from the composition spec. Receive the named-injector `EntityManager` as a constructor parameter.",
72
+ "`{{type}}` is injected as a class property. Property injection hides the dependency from the constructor and the app module. Receive the named-injector `EntityManager` as a constructor parameter.",
73
73
  infra:
74
74
  "`{{type}}` is injected here. A `DataSource` or `QueryRunner` is built and held only by the platform database capability, the migrate app and the test world in `src/tests/world`; specs take `world.db.<connection>`; everything else injects the shared `EntityManager` through its named injector and calls it directly.",
75
75
  getRepository:
package/index.mjs CHANGED
@@ -52,9 +52,11 @@ import { recommended as transportRecommended, rules as transportRules } from "./
52
52
  import { recommended as typeSafetyRecommended, rules as typeSafetyRules } from "./type-safety.mjs"
53
53
  import { recommended as unitSpecRecommended, rules as unitSpecRules } from "./unit-spec.mjs"
54
54
  import { recommended as userCopyRecommended, rules as userCopyRules } from "./user-copy.mjs"
55
+ import { recommended as projectGraphRecommended, rules as projectGraphRules } from "./project-graph.mjs"
55
56
 
56
57
  /** Each law's contribution, kept separate so a duplicate name is detectable rather than silent. */
57
58
  const CONTRIBUTIONS = [
59
+ { law: "project-graph", rules: projectGraphRules, recommended: projectGraphRecommended },
58
60
  { law: "async-discipline", rules: asyncDisciplineRules, recommended: asyncDisciplineRecommended },
59
61
  { law: "authorization", rules: authorizationRules, recommended: authorizationRecommended },
60
62
  { law: "builders", rules: buildersRules, recommended: buildersRecommended },
package/lib/unit-spec.mjs CHANGED
@@ -2,13 +2,13 @@
2
2
  * What is a unit spec, decided by the slot manifest and the file's role suffix, never by a path pattern.
3
3
  *
4
4
  * A unit spec is a `*.spec.ts` outside the folders that own the other test kinds (`src/tests/{e2e,integration,contract,world}`)
5
- * and outside `apps/migrate` (the migrate app's own specs). Only a `<name>.service.spec.ts` beside `<name>.service.ts` is a
5
+ * only. Only a `<name>.service.spec.ts` beside `<name>.service.ts` is a
6
6
  * legitimate unit spec (R47); the quality rules of R48 judge exactly those.
7
7
  */
8
8
  import { basename } from "node:path"
9
9
 
10
- /** The slots whose `*.spec.ts` files are not unit specs: the other test kinds and the migrate app. */
11
- const OTHER_KIND_SLOTS = new Set(["be.tests.e2e", "be.tests.integration", "be.tests.contract", "be.tests.world", "be.tests.world.kit", "be.app.migrate"])
10
+ /** The slots whose `*.spec.ts` files are not unit specs: the other test kinds and world infrastructure. */
11
+ const OTHER_KIND_SLOTS = new Set(["be.tests.e2e", "be.tests.integration", "be.tests.contract", "be.tests.world", "be.tests.world.kit"])
12
12
 
13
13
  /** The file name of a linted path. */
14
14
  export const baseOf = (filename) => basename(String(filename || "").replace(/\\/g, "/"))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/eslint-canon-be",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "The StarCi back-end lint canon: every rule its laws publish, gathered as one flat-config plugin.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The rules that read the project graph: the findings of the architecture machine that sit on a TypeScript file.
3
+ *
4
+ * One graph per lint run: `scripts/lib/project-graph.mjs` (a byte copy in this package's runtime/) builds the machine's module
5
+ * graph and slot manifest once for the repository, caches it, and each rule below reports the findings of its own codes on
6
+ * the file ESLint is visiting, on the line the machine names. There is no second graph and no second judge: the list of
7
+ * rules and their codes is `LINT_ENFORCERS` of the machine (scripts/checks/architecture/surface.mjs); `hfs check` keeps the
8
+ * findings that have no TypeScript file to sit on. A graph that cannot be built stops the run with the machine's message.
9
+ */
10
+ import { LINT_ENFORCERS } from "./runtime/scripts/checks/architecture/surface.mjs"
11
+ import { projectRule } from "./runtime/scripts/lib/project-rule.mjs"
12
+ import { hfsOf } from "./lib/hfs.mjs"
13
+ import { dirname, join } from "node:path"
14
+ import { fileURLToPath } from "node:url"
15
+
16
+ const RUNTIME = join(dirname(fileURLToPath(import.meta.url)), "runtime")
17
+ const mine = LINT_ENFORCERS.filter((enforcer) => enforcer.plugins.includes("be"))
18
+
19
+ /** The rules this law contributes to the plugin: one per graph enforcer of this profile. */
20
+ export const rules = Object.fromEntries(mine.map((e) => [e.id, projectRule({ enforcer: e, runtimeRoot: RUNTIME, hfsOf })]))
21
+
22
+ /** Every one at error. */
23
+ export const recommended = Object.fromEntries(mine.map((e) => [`starci-be/${e.id}`, "error"]))
@@ -0,0 +1,170 @@
1
+ schema: starci/canon-pins@1
2
+ purpose: >-
3
+ The exact version of every dependency a StarCi product repository pins. One version per dependency for the whole
4
+ family. Raising a version is a change to this file first (with the package bump when it is a @starci package),
5
+ then the repositories' own upgrade lane (each sets the exact version and reinstalls; nothing else installs a @starci package). Read on 2026-09-29 from the packages under
6
+ .claude/packages and from the installed node_modules of nivo-backend, nivo-fe, starci-next, starci-next-fe,
7
+ mia-mia-backend and miamia-fe; where they disagreed the newest version installed in more than one repository
8
+ won, and the runtime's own version won for @starci packages.
9
+ pins:
10
+ # --- @starci packages. Every @starci package is a PUBLISHED npm package (install: registry): a product repository
11
+ # installs the exact pinned version from the npm registry in the root and every workspace package.json, never `file:`.
12
+ '@starci/grammar':
13
+ version: 0.8.0
14
+ group: starci
15
+ install: registry
16
+ side: fe
17
+ source: packages/grammar/package.json
18
+ why: nivo-fe pins 0.4.11 and 0.5.0 in one workspace, starci-next-fe 0.5.1, miamia-fe 0.5.0; the runtime source is 0.8.0 (the brand layer sets `--font-sans` and `--font-mono`; the grammar reads them; 0.7.2 added the Input tel kind and IconButton disclosure props).
19
+ '@starci/eslint-canon-be':
20
+ version: 2.1.1
21
+ group: starci
22
+ install: registry
23
+ side: be
24
+ source: packages/eslint/be/package.json
25
+ why: '2.0.0 (C0 release): starciBeConfig({ hfs: loadHfs(import.meta.url) }) typed factory and the BE-CONVENTION laws (R36 sql-text-only, R83 no-repository-class, R85/R87/R89 service-deps, R43 config-parsed-in-main, R47/R48 test world, R95 operations, R98-R101 builders).'
26
+ '@starci/eslint-canon-fe':
27
+ version: 7.1.1
28
+ group: starci
29
+ install: registry
30
+ side: fe
31
+ source: packages/eslint/fe/package.json
32
+ why: '7.0.0: the front end has no tests (test rules removed, FE_NO_TESTS R97 in hfs); no-vietnamese-in-source (R91).'
33
+ '@starci/stylelint-canon':
34
+ version: 2.0.1
35
+ group: starci
36
+ install: registry
37
+ side: fe
38
+ source: packages/stylelint/package.json
39
+ why: '2.0.1 accepts `--font-sans` and `--font-mono` in the brand layer (the vocabulary follows the grammar 0.8.0). 2.0.0 adds status-contrast (HeroUI soft pairs measured per theme), fixes brand-layer-shape on the shared :root,.light,.dark block and the info soft pair, and derives appTokens with loadAppTokens(import.meta.url) for the managed one-line stylelint.config.mjs.'
40
+ '@starci/tsconfig':
41
+ version: 2.0.0
42
+ group: starci
43
+ install: registry
44
+ side: both
45
+ source: packages/tsconfig/package.json
46
+ '@starci/prettier-config':
47
+ version: 1.0.0
48
+ group: starci
49
+ install: registry
50
+ side: both
51
+ source: packages/prettier-config/package.json
52
+ '@starci/jest-preset':
53
+ version: 2.1.0
54
+ group: starci
55
+ install: registry
56
+ side: be
57
+ source: packages/jest-preset/package.json
58
+ why: '2.1.0: four projects on the test world, the unit kit (mockEntityManager, fakeTransaction, fakeIds, FakeClock, Outcome matchers) and the recordingOutbox claim side.'
59
+ '@starci/hfs':
60
+ version: 3.0.0
61
+ group: starci
62
+ install: registry
63
+ side: both
64
+ source: packages/hfs/package.json
65
+ why: '2.0.0 (C0 release): the BE-CONVENTION machine, emit-contracts (GraphQL SDL and OpenAPI from the typed operation table), the four-project test layout, FE has no tests, repo.scripts slot, secrets guard in work-hygiene, rule ids R<2-3 digits>.'
66
+ # --- tooling
67
+ typescript:
68
+ version: 5.9.3
69
+ group: tooling
70
+ side: both
71
+ why: all six repositories resolve 5.9.3 already; the declared ranges (^5, ^5.7.3) become exact.
72
+ prettier:
73
+ version: 3.9.6
74
+ group: tooling
75
+ side: both
76
+ why: only nivo-backend has it installed (3.9.6); the other five adopt it with the formatter change.
77
+ stylelint:
78
+ version: 17.15.0
79
+ group: tooling
80
+ side: fe
81
+ why: no repository has it installed; 17.15.0 is the current release, and the canon plugin needs the ESM-only 17 line.
82
+ postcss-value-parser:
83
+ version: 4.2.0
84
+ group: tooling
85
+ side: fe
86
+ why: peer of @starci/stylelint-canon (it parses declaration values); 4.2.0 is what stylelint 17.15.0 itself resolves.
87
+ eslint:
88
+ version: 9.39.5
89
+ group: tooling
90
+ side: both
91
+ why: five repositories resolve 9.39.5, nivo-backend 9.39.4.
92
+ eslint-plugin-react-hooks:
93
+ version: 7.1.1
94
+ group: tooling
95
+ side: fe
96
+ why: '2.0.0 (C0 release): the BE-CONVENTION machine, emit-contracts (GraphQL SDL and OpenAPI from the typed operation table), the four-project test layout, FE has no tests, repo.scripts slot, secrets guard in work-hygiene, rule ids R<2-3 digits>.'
97
+ '@types/node':
98
+ version: 22.20.4
99
+ group: tooling
100
+ side: both
101
+ why: nivo-fe resolves 20.19.43 and nivo-backend 22.20.0; the package engines are node >=22.
102
+ # --- test
103
+ jest:
104
+ version: 29.7.0
105
+ group: test
106
+ side: be
107
+ ts-jest:
108
+ version: 29.4.12
109
+ group: test
110
+ side: be
111
+ '@types/jest':
112
+ version: 29.5.14
113
+ group: test
114
+ side: be
115
+ # --- framework
116
+ next:
117
+ version: 16.1.6
118
+ group: framework
119
+ side: fe
120
+ react:
121
+ version: 19.2.3
122
+ group: framework
123
+ side: fe
124
+ react-dom:
125
+ version: 19.2.3
126
+ group: framework
127
+ side: fe
128
+ '@nestjs/core':
129
+ version: 11.2.5
130
+ group: framework
131
+ side: be
132
+ why: nivo-backend resolves 11.1.27, starci-next and mia-mia-backend 11.2.5.
133
+ '@nestjs/common':
134
+ version: 11.2.5
135
+ group: framework
136
+ side: be
137
+ '@nestjs/platform-express':
138
+ version: 11.2.5
139
+ group: framework
140
+ side: be
141
+ '@nestjs/testing':
142
+ version: 11.2.5
143
+ group: framework
144
+ side: be
145
+ '@nestjs/terminus':
146
+ version: 11.1.1
147
+ group: framework
148
+ side: be
149
+ why: readiness probes with dependency indicators use Terminus (the liveness route of the hfs sync --init skeleton does not, being a thin door over the liveness service); nivo-backend, starci-next and mia-mia-backend all resolve 11.1.1.
150
+ next-intl:
151
+ version: 4.13.6
152
+ group: framework
153
+ side: fe
154
+ why: every HFS front end uses next-intl with the [locale] segment (hfs sync --init writes it); nivo-fe resolves 4.13.6.
155
+ supertest:
156
+ version: 7.3.0
157
+ group: tooling
158
+ side: be
159
+ why: the e2e world of a back end calls the app over HTTP (/health/live in the skeleton); starci-next and mia-mia-backend resolve 7.3.0, nivo-backend 7.2.2.
160
+ # --- ui
161
+ '@heroui/react':
162
+ version: 3.2.6
163
+ group: ui
164
+ side: fe
165
+ why: nivo-fe resolves 3.2.4, starci-next-fe and miamia-fe 3.2.6.
166
+ '@heroui/styles':
167
+ version: 3.2.6
168
+ group: ui
169
+ side: fe
170
+ why: nivo-fe resolves 3.2.4, starci-next-fe and miamia-fe 3.2.6.
@@ -0,0 +1,309 @@
1
+ schema: starci/knowledge-source@1
2
+ id: fe.folder
3
+ title: Folder
4
+ purpose: |
5
+ Given a piece of frontend code, which directory and which file name does it get? Apply the HFS frontend tree
6
+ (knowledge/hfs/README.md section 6, slots fe.*).
7
+ appliesTo:
8
+ - frontend
9
+ family: fe
10
+ provenance:
11
+ reviewedAt: 2026-09-29
12
+ sources:
13
+ - knowledge/hfs/README.md
14
+ - knowledge/hfs/slots.yaml
15
+ - https://nextjs.org/docs/app/getting-started/project-structure
16
+ - https://next-intl.dev/docs/routing
17
+ - packages/grammar/src/**
18
+ limitations: |
19
+ Folder rules place code by responsibility. They do not prove rendered behavior or accessibility. Inspect the
20
+ selected repository's actual source, manifests, aliases and lint and test configuration. Verify installed Grammar
21
+ exports at @starci/grammar/common.
22
+ rules:
23
+ - id: FE-FOLDER-1
24
+ title: Responsibility directories
25
+ kind: mandatory
26
+ hfsRules: [R01, R02, R59, R64]
27
+ requirement: |
28
+ Every frontend repository is an apps/<app>/ monorepo even with one app, named by its role (for example web), and
29
+ all product source lives under apps/<app>/src. A repository-root src/ does not exist. Each Next source root
30
+ (apps/<app>/src) uses app/ for framework adapters; features/{pages,layouts,overlays} for route-facing product
31
+ composition; components/{blocks,composites,branches,leaves} for product visuals; hooks/<domain> for React hooks;
32
+ and modules/<capability> for cohesive reusable technical and domain capabilities. Every app has the modules api,
33
+ config, i18n and routes, and one brand.css under modules/brand when it sets brand tokens. No other empty role
34
+ folder is required. Grammar remains a separate product-agnostic package. The only files that may sit directly in the
35
+ source root (the directory holding app/) are the framework-pinned root files listed in frameworkPinnedRootFiles
36
+ below: Next.js loads them from that exact place. Each is a thin framework adapter whose internal imports enter
37
+ modules or a feature public entry only; every other rule still applies to it, except that the export names the
38
+ framework mandates there (frameworkPinnedRootExports) keep their framework spelling. HFS uses proxy.ts for locale
39
+ routing; a middleware.* file is refused on Next 16 and later by the Next conventions check and the slot
40
+ fe.source-root-pinned, even though the machine list names it as a file Next loads. Any other file at the source
41
+ root, including a helper folder beside a pinned file, has no owner and is refused.
42
+ frameworkPinnedRootFiles:
43
+ # Machine list read by scripts/checks/architecture/framework-pinned.mjs (FE_SOURCE_LAYOUT_INVALID accepts exactly
44
+ # these basenames directly in a Next source root; FE_TIER_DIRECTION keeps them thin). Exact names,
45
+ # case-sensitive, no globs. It lists what the framework loads from the source root. Which of them a repository may
46
+ # keep is decided by the slot fe.source-root-pinned and FE_NEXT_CONVENTIONS, not by this list.
47
+ # Machine list read by scripts/checks/architecture/framework-pinned.mjs (FE_SOURCE_LAYOUT_INVALID
48
+ # accepts exactly these basenames directly in a Next source root;
49
+ # their imports follow the FE_TIER_DIRECTION matrix). Exact names, case-sensitive, no globs. Supervisor rulings for nivo
50
+ # wf-nivo-fe-debt-mug06w7h inc-2e42a24b74e4 and inc-846867b9a34e (proxy is the Next 16 name of
51
+ # middleware, listed so the list survives the upgrade).
52
+ - middleware.ts
53
+ - middleware.js
54
+ - middleware.mjs
55
+ - proxy.ts
56
+ - proxy.js
57
+ - proxy.mjs
58
+ - instrumentation.ts
59
+ - instrumentation.js
60
+ - instrumentation.mjs
61
+ - instrumentation-client.ts
62
+ - instrumentation-client.js
63
+ - instrumentation-client.mjs
64
+ - next-env.d.ts
65
+ frameworkPinnedRootExports:
66
+ # Export names the framework mandates in a pinned root file, keyed by file stem (read by
67
+ # scripts/checks/architecture/framework-pinned.mjs). FE_SOURCE_NAME_SHAPE accepts exactly these names in exactly
68
+ # these files when they sit directly in a Next source root; everywhere else the name-shape rule is unchanged.
69
+ middleware: [config, middleware, default]
70
+ proxy: [config, proxy, default]
71
+ instrumentation: [register, onRequestError]
72
+ instrumentation-client: [onRouterTransitionStart]
73
+ rationale: |
74
+ One fixed source root per app keeps every repository the same shape while preventing app helpers, component-local
75
+ hooks and feature-local transport buckets from becoming undeclared owners.
76
+ cases:
77
+ - id: case-1
78
+ when: "A routed authentication scenario"
79
+ write: "apps/<app>/src/features/pages/AuthenticationPage/index.tsx"
80
+ - id: case-2
81
+ when: "A reusable API client, reader or session capability"
82
+ write: >
83
+ apps/<app>/src/modules/api/ or apps/<app>/src/modules/session/ with one explicit public index.ts entry
84
+ - id: case-3
85
+ when: "A reusable product visual without scenario ownership"
86
+ write: "apps/<app>/src/components/{blocks,composites,branches,leaves}/<Name>/index.tsx"
87
+ - id: case-4
88
+ when: "A React hook"
89
+ write: "apps/<app>/src/hooks/<domain>/useAutoScroll.ts; built-in React hook calls may remain in visuals"
90
+ - id: case-5
91
+ kind: exception
92
+ when: "Next.js only loads the file from the source root (proxy, instrumentation, instrumentation-client, next-env.d.ts)"
93
+ write: >
94
+ apps/<app>/src/proxy.ts beside apps/<app>/src/app/ as a thin adapter; locale routing logic lives in
95
+ apps/<app>/src/modules/i18n/ and the adapter imports it; the names the framework mandates there
96
+ (frameworkPinnedRootExports, for example export const config = { matcher }) keep their framework spelling
97
+ - id: case-6
98
+ when: "Any other file or folder directly under the source root (apps/<app>/src/i18n/request.ts, apps/<app>/src/config.ts), and a repository-root src/"
99
+ write: >
100
+ Move it to its owner, for example apps/<app>/src/modules/i18n/request.ts, and point framework configuration
101
+ (apps/<app>/next.config.ts) at the new path
102
+ - id: case-7
103
+ when: "The per-slot data-status recipe"
104
+ write: >
105
+ apps/<app>/src/components/composites/SlotView/index.tsx, apps/<app>/src/modules/slot/index.ts (Slot, toSlot,
106
+ SlotLabels) and apps/<app>/src/hooks/slot/useSlotLabels.ts, one copy each (examples/shape-slot)
107
+ verification:
108
+ automated:
109
+ - HFS_SLOT_UNDECLARED
110
+ - HFS_SLOT_REQUIRED_MISSING
111
+ - FE_SOURCE_LAYOUT_INVALID
112
+ - FE_NEXT_CONVENTIONS
113
+ - FE_TIER_DIRECTION
114
+ - FE_CUSTOM_HOOK_LOCATION
115
+ - HFS_APPS_REQUIRED
116
+ - HFS_ROOT_SRC_FORBIDDEN_FE
117
+ manual:
118
+ - Confirm the unit's responsibility and public entry, rather than assigning it by consumer count.
119
+ relatedExamples:
120
+ - connected-block
121
+
122
+ - id: FE-FOLDER-2
123
+ title: Discoverable files for one unit
124
+ kind: mandatory
125
+ hfsRules: [R02, R55, R65]
126
+ requirement: |
127
+ A split unit (a connected block, and a feature page, layout or overlay) uses index.tsx for the connected X and
128
+ sibling component.tsx for the pure XBase, its XBaseProps and xDefaultState, plus XState when the shape is its own union
129
+ (a shape that is a domain status is typed with that status, never a second name for it). Only that index.tsx and the
130
+ unit's specs import component.tsx. Pure blocks, composites, branches and leaves use index.tsx only and never gain an
131
+ empty twin. classNames.ts is present only when the unit owns class strings. Budgets: component.tsx 300 lines,
132
+ connected index.tsx 200 lines, at most 6 data hooks and 6 useState per connected unit.
133
+ rationale: |
134
+ Stable basenames make class, tests and the connected and presentational split discoverable without forwarding
135
+ twins, and budgets keep a unit reviewable.
136
+ cases:
137
+ - id: case-1
138
+ when: "Connected block with product-world lifecycle"
139
+ write: "blocks/CatalogBlock/{index.tsx,component.tsx}; every nonempty index render reaches the sibling"
140
+ - id: case-2
141
+ when: "Feature page, layout or overlay"
142
+ write: >
143
+ features/pages/OperatePage/{index.tsx,component.tsx,classNames.ts}, features/layouts/WorkspaceLayout/…,
144
+ features/overlays/SendHandoffOverlay/… (examples/shape-slot)
145
+ - id: case-3
146
+ when: "Single visual unit"
147
+ write: "leaves/ButtonStateSample/{classNames.ts,index.tsx}; no component.tsx twin without a separate world owner"
148
+ - id: case-4
149
+ when: "Custom hook or reusable module"
150
+ write: "hooks/<domain>/useX.ts or modules/<capability>/...; do not create visual twins"
151
+ verification:
152
+ automated:
153
+ - class-names-in-colocated-file
154
+ - no-inline-class-name
155
+ - FE_CONNECTED_BLOCK_RENDER_PAIR
156
+ - FE_SIZE_AND_STATE_BUDGET
157
+ - HFS_SIZE_GROWTH
158
+ - starci-fe/base-import-pair
159
+ manual:
160
+ - Confirm each file owns a real responsibility; do not add a component.tsx twin by habit.
161
+ relatedExamples:
162
+ - connected-block
163
+
164
+ - id: FE-FOLDER-3
165
+ title: Route files adapt to one visual owner and every app has its boundaries
166
+ kind: mandatory
167
+ hfsRules: [R53, R54, R55, R57]
168
+ requirement: |
169
+ Route files under app/[locale]/ (page, layout, template, loading, not-found) are server components. A route may
170
+ resolve framework server inputs (params, searchParams, headers, cookies), then mounts one page-level visual owner.
171
+ A route whose complete responsibility is redirect or notFound mounts none. A route file holds no inline component, no
172
+ drawing decision and no hook, and a redirect from an old URL lives in next.config redirects(), never in a page. Every app has
173
+ app/global-error.tsx, app/[locale]/layout.tsx, app/[locale]/error.tsx and app/[locale]/not-found.tsx, and a loading.tsx
174
+ for each route group that reads data. Each page exports generateMetadata. force-dynamic on a client page is forbidden.
175
+ rationale: |
176
+ Keeping default exports in the App Router layer prevents components from becoming route-coupled, and mandatory
177
+ boundaries turn a render failure into a recoverable screen instead of a blank page.
178
+ cases:
179
+ - id: case-1
180
+ when: "A route"
181
+ write: >
182
+ app/[locale]/authentication/page.tsx: const AuthenticationRoute = async () => <AuthenticationPage />, then export
183
+ default AuthenticationRoute
184
+ - id: case-2
185
+ kind: exception
186
+ when: "Redirect or notFound adapter"
187
+ write: "Resolve framework inputs and redirect or terminate without a visual owner."
188
+ - id: case-3
189
+ when: "Global app files"
190
+ write: >
191
+ app/globals.css, app/global-error.tsx, app/[locale]/error.tsx, app/[locale]/not-found.tsx, app/sitemap.ts,
192
+ app/robots.ts, app/health/{live,ready}/route.ts
193
+ verification:
194
+ automated:
195
+ - FE_ERROR_BOUNDARY_MISSING
196
+ - FE_ROUTE_FILES_THIN
197
+ - FE_CLIENT_BOUNDARY
198
+ - FE_OWNER_REACHABLE
199
+ - FE_TIER_DIRECTION
200
+ manual:
201
+ - Confirm visual routes have one page owner and redirect-only routes have no visual tree.
202
+ relatedExamples: []
203
+
204
+ - id: FE-FOLDER-4
205
+ title: Hooks are hooks; readers and transport live in modules
206
+ kind: mandatory
207
+ hfsRules: [R56, R50, R49]
208
+ requirement: |
209
+ hooks/<domain>/ holds React hooks (use*.ts, one hook per file) and exactly one <domain>.shared.ts for shared
210
+ non-hook helpers of that domain (key builders, token readers). A file in hooks/ that is not a hook and is not the shared
211
+ file is a finding. Server-side readers (fetch and map, no React) live in modules/api/<domain>/read-*.ts and are
212
+ wrapped in React cache() when several blocks call them in one request. Generic client plumbing, the Outcome type,
213
+ the contract copy and generated wire types live in modules/api; environment reading lives in modules/config; every
214
+ href builder lives in modules/routes; locale routing lives in modules/i18n; colour values live in modules/brand.
215
+ A helper name defined twice across hook files is a finding.
216
+ rationale: |
217
+ A rule that says what a hooks folder is also says where everything else goes, so nobody copies a helper sixteen
218
+ times or fills hooks/ with server fetch functions.
219
+ cases:
220
+ - id: case-1
221
+ when: "Authentication request lifecycle"
222
+ write: "apps/<app>/src/hooks/authentication/useAuthentication.ts"
223
+ - id: case-2
224
+ when: "A helper shared by the hooks of one domain"
225
+ write: "apps/<app>/src/hooks/sales/sales.shared.ts, for example useSalesAccessToken's token reader"
226
+ - id: case-3
227
+ when: "A server read used by several blocks"
228
+ write: "apps/<app>/src/modules/api/sales/read-sales-summary.ts, exported through modules/api/index.ts"
229
+ - id: case-4
230
+ when: "The API client"
231
+ write: "apps/<app>/src/modules/api/client.ts and apps/<app>/src/modules/api/outcome.ts"
232
+ - id: case-5
233
+ when: "Intrinsic custom helper"
234
+ write: "apps/<app>/src/hooks/ui/useAutoScroll.ts; direct useRef and useState calls may remain in their visual owner"
235
+ verification:
236
+ automated:
237
+ - FE_HOOKS_ARE_HOOKS
238
+ - FE_CUSTOM_HOOK_LOCATION
239
+ - HFS_DUPLICATE_CODE
240
+ - FE_TIER_DIRECTION
241
+ manual:
242
+ - Confirm each lifecycle has one feature owner and transport mechanics have one module owner.
243
+ relatedExamples:
244
+ - connected-block
245
+
246
+ - id: FE-FOLDER-5
247
+ title: Package unit
248
+ kind: mandatory
249
+ hfsRules: [R63]
250
+ requirement: |
251
+ A shared package is packages/<pkg>/ with package.json (explicit exports), src/index.ts, tsconfig.json and colocated
252
+ specs, built to dist. Grammar components live under packages/grammar/src/core/<tier>/<Name>/ with collocated class
253
+ strings and specs; family entries and built-output proof stay at the package roots. See packages.yaml for the shared
254
+ UI package shape.
255
+ rationale: |
256
+ Package layout separates primitives from app composition and keeps public entry verification against dist.
257
+ cases:
258
+ - id: case-1
259
+ when: "A Grammar component"
260
+ write: "packages/grammar/src/core/<primitive|composite|branch|composition>/<Name>/index.tsx"
261
+ - id: case-2
262
+ when: "A Grammar component's class strings and spec"
263
+ write: "sibling classNames.ts and index.spec.tsx"
264
+ - id: case-3
265
+ when: "Built-output proof"
266
+ write: "common/index.test.mjs, core/index.test.mjs, package-boundary.test.mjs (node:test against dist/)"
267
+ verification:
268
+ automated:
269
+ - FE_PACKAGE_SHAPE
270
+ manual:
271
+ - Verify public app imports use @starci/grammar/common and installed exports, never the package root.
272
+ relatedExamples: []
273
+
274
+ - id: FE-FOLDER-6
275
+ title: Keep units cohesive
276
+ kind: mandatory
277
+ hfsRules: [R49, R21]
278
+ requirement: |
279
+ A unit folder contains files that change for the same responsibility. Do not create generic helpers/ or utils/
280
+ buckets inside components, read deployment configuration in presentation, or split files solely to meet a count.
281
+ Collocated subordinate renders and pure helpers are valid when they remain private to the owner; a separately stable
282
+ responsibility receives its own named owner.
283
+ rationale: |
284
+ Cohesion prevents helper sprawl and duplicated configuration while avoiding one-component-per-folder ceremony that
285
+ has no dependency boundary.
286
+ cases:
287
+ - id: case-1
288
+ when: "A small subordinate render is private to one owner"
289
+ write: "Keep it local with an unexported contract; extract it when it gains a stable public responsibility."
290
+ - id: case-2
291
+ when: "Class strings in component.tsx"
292
+ write: "Never; they go to classNames.ts (lint class-names-in-colocated-file, no-inline-class-name)"
293
+ - id: case-3
294
+ when: "A helpers/ or utils/ folder"
295
+ write: "Do not use it to hide mixed feature, transport or visual responsibilities."
296
+ - id: case-4
297
+ when: "A deployment constant"
298
+ write: >
299
+ Never. process.env.NEXT_PUBLIC_* is read only in apps/<app>/src/modules/config and reached through that module,
300
+ with no localhost fallback; a missing value in production throws when the module loads.
301
+ verification:
302
+ automated:
303
+ - FE_ENV_OWNER
304
+ - class-names-in-colocated-file
305
+ - no-inline-class-name
306
+ - no-helper-folder-in-components
307
+ manual:
308
+ - Confirm extraction is justified by ownership or lifecycle rather than file length or count.
309
+ relatedExamples: []