@starci/eslint-canon-fe 7.0.0 → 7.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 (74) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/docs/transport.md +4 -4
  3. package/index.mjs +2 -0
  4. package/lib/why.mjs +3 -3
  5. package/package.json +1 -1
  6. package/project-graph.mjs +23 -0
  7. package/runtime/knowledge/hfs/canon-pins.yaml +170 -0
  8. package/runtime/knowledge/patterns/fe/folder.yaml +309 -0
  9. package/runtime/knowledge/sonar-gate.yaml +86 -0
  10. package/runtime/packages/hfs/templates/be/package-scripts/package.json +19 -0
  11. package/runtime/packages/hfs/templates/fe/package-scripts/package.json +13 -0
  12. package/runtime/scripts/checks/architecture/backend.mjs +350 -0
  13. package/runtime/scripts/checks/architecture/background-unowned.mjs +107 -0
  14. package/runtime/scripts/checks/architecture/client-reaches-server.mjs +94 -0
  15. package/runtime/scripts/checks/architecture/clones.mjs +200 -0
  16. package/runtime/scripts/checks/architecture/config-unread.mjs +35 -0
  17. package/runtime/scripts/checks/architecture/config.mjs +310 -0
  18. package/runtime/scripts/checks/architecture/connection-map.mjs +208 -0
  19. package/runtime/scripts/checks/architecture/constructor-deps.mjs +100 -0
  20. package/runtime/scripts/checks/architecture/contract-fixture-guard.mjs +128 -0
  21. package/runtime/scripts/checks/architecture/contracts.mjs +792 -0
  22. package/runtime/scripts/checks/architecture/cross-app-duplicate.mjs +73 -0
  23. package/runtime/scripts/checks/architecture/dead-exports.mjs +265 -0
  24. package/runtime/scripts/checks/architecture/default-deny.mjs +129 -0
  25. package/runtime/scripts/checks/architecture/doc-language.mjs +39 -0
  26. package/runtime/scripts/checks/architecture/entrypoint.mjs +57 -0
  27. package/runtime/scripts/checks/architecture/error-codes.mjs +45 -0
  28. package/runtime/scripts/checks/architecture/error-masked.mjs +60 -0
  29. package/runtime/scripts/checks/architecture/fe-slot-allows.mjs +38 -0
  30. package/runtime/scripts/checks/architecture/feature-shape.mjs +49 -0
  31. package/runtime/scripts/checks/architecture/framework-pinned.mjs +83 -0
  32. package/runtime/scripts/checks/architecture/frontend.mjs +995 -0
  33. package/runtime/scripts/checks/architecture/hfs-graph.mjs +61 -0
  34. package/runtime/scripts/checks/architecture/hfs.mjs +521 -0
  35. package/runtime/scripts/checks/architecture/hooks-are-hooks.mjs +88 -0
  36. package/runtime/scripts/checks/architecture/i18n-keys.mjs +146 -0
  37. package/runtime/scripts/checks/architecture/index.mjs +321 -0
  38. package/runtime/scripts/checks/architecture/injection-token-exported.mjs +62 -0
  39. package/runtime/scripts/checks/architecture/machine-ast.mjs +138 -0
  40. package/runtime/scripts/checks/architecture/module-per-transport.mjs +130 -0
  41. package/runtime/scripts/checks/architecture/next-data.mjs +775 -0
  42. package/runtime/scripts/checks/architecture/owners.mjs +95 -0
  43. package/runtime/scripts/checks/architecture/package-shape.mjs +63 -0
  44. package/runtime/scripts/checks/architecture/reachability.mjs +233 -0
  45. package/runtime/scripts/checks/architecture/register-once.mjs +141 -0
  46. package/runtime/scripts/checks/architecture/registration.mjs +319 -0
  47. package/runtime/scripts/checks/architecture/required-files.mjs +172 -0
  48. package/runtime/scripts/checks/architecture/route-files-thin.mjs +97 -0
  49. package/runtime/scripts/checks/architecture/schema-owner.mjs +261 -0
  50. package/runtime/scripts/checks/architecture/source-names.mjs +607 -0
  51. package/runtime/scripts/checks/architecture/sql-owner.mjs +142 -0
  52. package/runtime/scripts/checks/architecture/sql-tokens.mjs +327 -0
  53. package/runtime/scripts/checks/architecture/surface.mjs +91 -0
  54. package/runtime/scripts/checks/architecture/symbols.mjs +193 -0
  55. package/runtime/scripts/checks/architecture/test-world-files.mjs +163 -0
  56. package/runtime/scripts/checks/architecture/tiers.mjs +130 -0
  57. package/runtime/scripts/checks/architecture/transport-owner.mjs +112 -0
  58. package/runtime/scripts/checks/architecture/typescript.mjs +573 -0
  59. package/runtime/scripts/checks/architecture/unit-spec-providers.mjs +122 -0
  60. package/runtime/scripts/checks/common.mjs +44 -0
  61. package/runtime/scripts/checks/typescript-programs.mjs +82 -0
  62. package/runtime/scripts/lib/hfs-path-findings.mjs +84 -0
  63. package/runtime/scripts/lib/hfs-rules/fe-no-tests.mjs +47 -0
  64. package/runtime/scripts/lib/hfs-rules/read.mjs +28 -0
  65. package/runtime/scripts/lib/hfs-rules/secrets.mjs +54 -0
  66. package/runtime/scripts/lib/hfs-rules/spec-placement.mjs +29 -0
  67. package/runtime/scripts/lib/json.mjs +22 -0
  68. package/runtime/scripts/lib/project-graph.mjs +0 -0
  69. package/runtime/scripts/lib/project-rule.mjs +39 -0
  70. package/runtime/scripts/lib/repo-identity.mjs +50 -0
  71. package/runtime/scripts/lib/secret-patterns.mjs +44 -0
  72. package/runtime/scripts/lib/stack-services.mjs +217 -0
  73. package/runtime/scripts/lib/test-secrets.mjs +120 -0
  74. package/transport.mjs +9 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.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
+ ## 7.1.0 - 2026-10-01
8
+
9
+ - New: the `project-graph` law: the TS-attached front-end architecture checks (routes, owners, paths) as eslint rules at error, from one cached project graph per lint run.
10
+
11
+ - Breaking (rule id): `no-http-status-collapse` is renamed `no-failure-collapse`. It fires on UI code that consumes an `Outcome` as well as on HTTP clients, so its name and messages now speak of a failure and its reason (branch on an `Outcome`'s reason code; map an HTTP status to an `Outcome` first). A branch that reads `reason` or `kind` counts as inspecting the failure. Update any `eslint-disable` naming the old id; there is no alias.
12
+
3
13
  ## 7.0.0 - 2026-09-30
4
14
 
5
15
  - **New: `no-vietnamese-in-source` (R91).** Identifiers, string literals, template text, JSX text, comments and test titles carry no Vietnamese letter, specs included. Detection is structural on characters (`scripts/lib/language.mjs` in `runtime/`, folded to NFC, so NFD is caught too). The only exemption is the i18n fixtures slot `fe.e2e-support.i18n` (`e2e/fixtures/i18n/`). Removed: the second-language branches of `no-hardcoded-copy` (its `second` and `comment` messages) and the `SECOND_LANGUAGE_LETTER` export; the one rule holds the law.
package/docs/transport.md CHANGED
@@ -95,9 +95,9 @@ if (r.status === 401 || r.status === 403) return { ok: false, kind: "refused" }
95
95
 
96
96
  **Fix:** Add a branch `response.status === 401 || response.status === 403` returning `{ ok: false, kind: "refused" }` inside the client.
97
97
 
98
- ## `starci-fe/no-http-status-collapse`
98
+ ## `starci-fe/no-failure-collapse`
99
99
 
100
- A non-ok response is not folded into one branch or into null; 401/403 become `refused`.
100
+ A failure, a non-ok HTTP response or a failed `Outcome`, is not folded into one branch or into an empty value; its reason is read and kept (an HTTP status is mapped first: 401/403 `refused`, 404 `not-found`, 422 `invalid`, the rest `unavailable`).
101
101
 
102
102
  **Invalid** (`src/modules/api/client.ts`)
103
103
 
@@ -113,9 +113,9 @@ if (!res.ok) return toOutcome(res.status)
113
113
 
114
114
  **Finding code:** `FE_HTTP_STATUS_COLLAPSE`
115
115
 
116
- **Why:** `<file>` collapses every HTTP code into one branch (or returns null on an error response). 401/403 must become `refused`.
116
+ **Why:** `<file>` collapses every failure (a failed HTTP response or a failed `Outcome`) into one branch or an empty value, so its reason is lost.
117
117
 
118
- **Fix:** Return an `Outcome` by code: `refused` (401/403), `not-found`, `invalid`, `unavailable`; do not return the server's raw error as the reason.
118
+ **Fix:** Keep the reason: branch on an `Outcome`'s reason code; map an HTTP status to an `Outcome` first (`refused` for 401/403, `not-found`, `invalid`, `unavailable`). Never use the server's raw text as the reason.
119
119
 
120
120
  ## `starci-fe/no-hand-typed-wire`
121
121
 
package/index.mjs CHANGED
@@ -46,11 +46,13 @@ import { recommended as translationRecommended, rules as translationRules } from
46
46
  import { recommended as typeSafetyRecommended, rules as typeSafetyRules } from "./type-safety.mjs"
47
47
  import { recommended as typographyRecommended, rules as typographyRules } from "./typography.mjs"
48
48
  import { recommended as vendorRecommended, rules as vendorRules } from "./vendor-boundary.mjs"
49
+ import { recommended as projectGraphRecommended, rules as projectGraphRules } from "./project-graph.mjs"
49
50
  import { buildFeConfig } from "./lib/config.mjs"
50
51
  import { why } from "./lib/why.mjs"
51
52
 
52
53
  /** Each law's contribution, kept separate so a duplicate name is detectable rather than silent. */
53
54
  const CONTRIBUTIONS = [
55
+ { law: "project-graph", rules: projectGraphRules, recommended: projectGraphRecommended },
54
56
  { law: "brand-values", rules: brandValuesRules, recommended: brandValuesRecommended },
55
57
  { law: "client-boundary", rules: clientBoundaryRules, recommended: clientBoundaryRecommended },
56
58
  { law: "comments", rules: commentsRules, recommended: commentsRecommended },
package/lib/why.mjs CHANGED
@@ -46,10 +46,10 @@ export const why = {
46
46
  vi: "Client ở `<file>` không có nhánh so sánh `response.status` với 401 và 403 rồi trả `{ kind: \"refused\" }`, nên trạng thái \"cần đăng nhập\" không bao giờ đạt được.",
47
47
  fixVi: "Thêm nhánh `response.status === 401 || response.status === 403` trả `{ ok: false, kind: \"refused\" }` ngay trong client.",
48
48
  },
49
- "no-http-status-collapse": {
49
+ "no-failure-collapse": {
50
50
  code: "FE_HTTP_STATUS_COLLAPSE",
51
- vi: "`<file>` gộp mọi mã HTTP thành một nhánh (hoặc trả null khi phản hồi lỗi). 401/403 phải thành `refused`.",
52
- fixVi: "Trả `Outcome` theo mã: `refused` (401/403), `not-found`, `invalid`, `unavailable`; không trả nguyên văn lỗi của server làm lý do.",
51
+ vi: "`<file>` gộp mọi thất bại (phản hồi HTTP lỗi hoặc `Outcome` thất bại) thành một nhánh hoặc một giá trị rỗng, nên lý do bị mất.",
52
+ fixVi: "Giữ lý do: với `Outcome` thì rẽ nhánh theo mã lý do; với phản hồi HTTP thì đổi mã trạng thái thành `Outcome` (`refused` cho 401/403, `not-found`, `invalid`, `unavailable`). Không dùng nguyên văn lỗi của server làm lý do.",
53
53
  },
54
54
  "no-hand-typed-wire": {
55
55
  code: "FE_WIRE_GENERATED",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/eslint-canon-fe",
3
- "version": "7.0.0",
3
+ "version": "7.1.1",
4
4
  "description": "The StarCi front-end lint canon: every rule its laws publish, gathered as one flat-config plugin and attached by one factory.",
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("fe"))
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-fe/${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: []