# Enforcement

Which rule is checked by what: type checks, lint, tests, build and deploy gates, scripts, and the rules that still rely on review.

A rule that nothing checks decays. This page lists the repository's rules, where each one is stated and what fails when it is broken. Use it to decide how much to trust a rule, and to find the next rule that should get a check.

## Levels [#levels]

| Level          | Meaning                                                               |
| -------------- | --------------------------------------------------------------------- |
| `[type]`       | `pnpm check-types` rejects the violation.                             |
| `[lint]`       | `pnpm lint` (oxlint plus repository checks) rejects it.               |
| `[test]`       | A test in `pnpm test`, the integration suite or the RLS matrix fails. |
| `[build]`      | `pnpm --filter web build` fails.                                      |
| `[deploy]`     | A preview or production workflow refuses to publish.                  |
| `[tool]`       | A repository script refuses the action.                               |
| `[manual]`     | A verification script exists, but you run it yourself; CI does not.   |
| `[convention]` | Only review holds it. These are the fragile ones.                     |

## Coverage [#coverage]

| Rule                                                                                                                                                                                                                                                                                                                                                                    | Stated in                                                                                                                                                | Enforcement                                                                                                                                                                                                                                                                                                                                                                               |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Clients import leaves, contracts or types only                                                                                                                                                                                                                                                                                                                          | [ADR-0002](/docs/adr/0002-no-barrels-on-server-capable-modules)                                                                                          | `[lint]` `packages/config/oxlint-client-boundary.mts` (server-only specifiers, including `@fofo/api/mcp/*`), extended by the four client trees, each with a failing fixture in `[test]` `scripts/tooling-tests.mjs` · `[test]` `scripts/leaf-modules.test.mjs` (D1) · `[build]` `apps/web/scripts/assert-client-bundle-clean.mjs`                                                         |
| A feature contract carries the `LEAF MODULE` header                                                                                                                                                                                                                                                                                                                     | [ADR-0011](/docs/adr/0011-backend-feature-shape)                                                                                                         | `[test]` `scripts/leaf-modules.test.mjs`                                                                                                                                                                                                                                                                                                                                                  |
| Package exports are enumerated and documented                                                                                                                                                                                                                                                                                                                           | [ADR-0002](/docs/adr/0002-no-barrels-on-server-capable-modules), [ADR-0011](/docs/adr/0011-backend-feature-shape)                                        | `[test]` `packages/api/src/exports.test.ts` · `[test]` the package-exports check in [`apps/web/src/features/docs/docs.source.server.test.ts`](https://github.com/CarlosZiegler/fofo/blob/main/apps/web/src/features/docs/docs.source.server.test.ts)                                                                                                                                      |
| Clients import canonical API subpaths; no `./routers/*` subpath comes back                                                                                                                                                                                                                                                                                              | [ADR-0013](/docs/adr/0013-mobile-features-mirror-the-backend-shape)                                                                                      | `[test]` `packages/api/src/exports.test.ts` · `[type]` a removed subpath fails `tsc`                                                                                                                                                                                                                                                                                                      |
| Mobile layers, cross-feature edges, platform variants, the route list and data access only in hooks                                                                                                                                                                                                                                                                     | [ADR-0013](/docs/adr/0013-mobile-features-mirror-the-backend-shape)                                                                                      | `[test]` `scripts/mobile-feature-boundaries.test.mjs`, `scripts/import-cycles.test.mjs` (a test, not lint: see the note below) · `[lint]` `max-lines` in `apps/mobile/src/oxlint.config.mts`                                                                                                                                                                                              |
| In the native app TanStack DB is imported only by `features/<f>/<f>.collections.ts`, `platform/db/` and `platform/realtime/`; money, access, identity, Consent, settings and flags have no `collections` file; an Expo export holds no module of the database package, drizzle-orm or Effect                                                                            | [ADR-0024](/docs/adr/0024-client-collections-with-tanstack-db)                                                                                           | `[test]` M12 in `scripts/mobile-feature-boundaries.test.mjs` · `[manual]` `node scripts/assert-mobile-export-clean.mjs <export dir>` after `expo export --source-maps`                                                                                                                                                                                                                    |
| In the native app a reply of the auth client asked under an earlier identity stores nothing, publishes nothing and signs nobody out                                                                                                                                                                                                                                     | [ADR-0013](/docs/adr/0013-mobile-features-mirror-the-backend-shape)                                                                                      | `[test]` `apps/mobile/src/platform/auth/session-gate.test.ts`, `apps/mobile/src/platform/db/scope-verification.test.ts`                                                                                                                                                                                                                                                                   |
| A sealed private snapshot opens only under its namespace and scope, and sign-out destroys the key before it deletes the files (`EXPO_PUBLIC_ENCRYPT_SNAPSHOTS=1`)                                                                                                                                                                                                       | [ADR-0022](/docs/adr/0022-encrypted-private-snapshots)                                                                                                   | `[test]` `apps/mobile/src/platform/offline/sealed-store.test.ts`, `packages/env/src/native.test.ts` · `[manual]` the device check of issue #243 for the native adapters                                                                                                                                                                                                                   |
| Only the app router and the tool catalog import `*.procedures` (D3)                                                                                                                                                                                                                                                                                                     | [ADR-0011](/docs/adr/0011-backend-feature-shape)                                                                                                         | `[lint]` `oxlint.config.ts`, override for `packages/api/src/**`                                                                                                                                                                                                                                                                                                                           |
| Only the job runner imports `*.jobs` (D4)                                                                                                                                                                                                                                                                                                                               | [ADR-0011](/docs/adr/0011-backend-feature-shape)                                                                                                         | `[lint]` `oxlint.config.ts`, override for `packages/api/src/**`                                                                                                                                                                                                                                                                                                                           |
| The job table imports a feature only by `*.jobs`, `*.config`, `*.settings` or `*.outbox` (C6)                                                                                                                                                                                                                                                                           | [Backend conventions](/docs/development/backend-conventions)                                                                                             | `[test]` `scripts/feature-boundaries.test.mjs`                                                                                                                                                                                                                                                                                                                                            |
| `platform/**` does not import features, except `admin.roles` and `admin.api` (D5)                                                                                                                                                                                                                                                                                       | [ADR-0011](/docs/adr/0011-backend-feature-shape)                                                                                                         | `[lint]` `oxlint.config.ts`, override for `packages/api/src/platform/**`                                                                                                                                                                                                                                                                                                                  |
| Features import each other through public roles or declared edges (D6)                                                                                                                                                                                                                                                                                                  | [ADR-0011](/docs/adr/0011-backend-feature-shape)                                                                                                         | `[test]` `scripts/feature-boundaries.test.mjs`                                                                                                                                                                                                                                                                                                                                            |
| No import cycles in `packages/api/src` and `packages/db/src` (D7)                                                                                                                                                                                                                                                                                                       | [ADR-0011](/docs/adr/0011-backend-feature-shape)                                                                                                         | `[test]` `scripts/import-cycles.test.mjs`, run by `pnpm test`                                                                                                                                                                                                                                                                                                                             |
| Procedures hold no queries (D8)                                                                                                                                                                                                                                                                                                                                         | [ADR-0011](/docs/adr/0011-backend-feature-shape)                                                                                                         | `[lint]` `oxlint.config.ts`, procedure glob over every feature (both tiers of ADR-0010): refuses `drizzle-orm`, the schema barrel `@fofo/db/schema` and `@fofo/db/schema/<table>` · `[convention]` `context.db.query.*`, which needs no import                                                                                                                                            |
| Web imports flow routes → features → platform (W1)                                                                                                                                                                                                                                                                                                                      | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` [`scripts/web-feature-boundaries.test.mjs`](https://github.com/CarlosZiegler/fofo/blob/main/scripts/web-feature-boundaries.test.mjs)                                                                                                                                                                                                                                             |
| Web features meet through public roles (queries, hooks, …) or a declared edge (W2)                                                                                                                                                                                                                                                                                      | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` `scripts/web-feature-boundaries.test.mjs`                                                                                                                                                                                                                                                                                                                                        |
| Web server-only code is named `.server`; only server surfaces and the two isomorphic bridges import it (W3)                                                                                                                                                                                                                                                             | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` `scripts/web-feature-boundaries.test.mjs` · `[build]` TanStack Start import protection · `[build]` `assert-client-bundle-clean.mjs`                                                                                                                                                                                                                                              |
| No `createServerFn` in the web (W4)                                                                                                                                                                                                                                                                                                                                     | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` `scripts/web-feature-boundaries.test.mjs` · `[build]` `apps/web/scripts/assert-server-fn-manifest.mjs`                                                                                                                                                                                                                                                                           |
| Web components hold no data access; hooks do (W5)                                                                                                                                                                                                                                                                                                                       | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` `scripts/web-feature-boundaries.test.mjs` (no exemptions)                                                                                                                                                                                                                                                                                                                        |
| A mutation's `onSuccess` never awaits or returns a refetch (web and native app); deliberate waits are allowlisted with a reason                                                                                                                                                                                                                                         | [Conventions](/docs/development/conventions#feedback-never-waits-for-a-refetch)                                                                          | `[test]` `scripts/no-awaited-invalidation.test.mjs`                                                                                                                                                                                                                                                                                                                                       |
| No `.client.` file names in the web (W6)                                                                                                                                                                                                                                                                                                                                | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` `scripts/web-feature-boundaries.test.mjs`                                                                                                                                                                                                                                                                                                                                        |
| No new dynamic `import()` in the web (W7)                                                                                                                                                                                                                                                                                                                               | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` `scripts/web-feature-boundaries.test.mjs`                                                                                                                                                                                                                                                                                                                                        |
| No barrel in the web (W8)                                                                                                                                                                                                                                                                                                                                               | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` `scripts/web-feature-boundaries.test.mjs`                                                                                                                                                                                                                                                                                                                                        |
| `vi.mock`, test `import()` and `new URL` specifiers resolve (W9)                                                                                                                                                                                                                                                                                                        | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` `scripts/web-feature-boundaries.test.mjs`                                                                                                                                                                                                                                                                                                                                        |
| Web tests fake the three server seams once (`@/testing`, installed in `test-setup.ts`); `vi.mock` calls per target only shrink                                                                                                                                                                                                                                          | [Testing and verification](/docs/development/testing#what-to-test)                                                                                       | `[test]` `scripts/web-mock-targets.test.mjs` (baseline per target) · `[type]` the fake oRPC client is typed by the app router                                                                                                                                                                                                                                                             |
| Web feature folders are flat and prefixed (W10)                                                                                                                                                                                                                                                                                                                         | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` `scripts/web-feature-boundaries.test.mjs`                                                                                                                                                                                                                                                                                                                                        |
| No import cycles in `apps/web/src` (W11)                                                                                                                                                                                                                                                                                                                                | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` `scripts/web-feature-boundaries.test.mjs` (W11 case: oxlint `import/no-cycle` with the web `tsconfig`), run by `pnpm test`                                                                                                                                                                                                                                                       |
| Backend files stay under 400 lines; the baseline of longer files only shrinks (C3)                                                                                                                                                                                                                                                                                      | [Backend conventions](/docs/development/backend-conventions#files-stay-short)                                                                            | `[lint]` `max-lines` in `oxlint.config.ts` · `[test]` `scripts/max-lines.test.mjs`                                                                                                                                                                                                                                                                                                        |
| Web files stay short (W12)                                                                                                                                                                                                                                                                                                                                              | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[lint]` `max-lines` error in [`apps/web/src/oxlint.config.mts`](https://github.com/CarlosZiegler/fofo/blob/main/apps/web/src/oxlint.config.mts)                                                                                                                                                                                                                                          |
| Nothing server-only in the web client (W13)                                                                                                                                                                                                                                                                                                                             | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[lint]` client boundary, with server files carved out by path in `apps/web/src/oxlint.config.mts` · `[build]` `assert-client-bundle-clean.mjs`                                                                                                                                                                                                                                           |
| A web loader fails the route only for the page's own data; optional sections and external listings use `prefetch*` or stay in the browser (W14)                                                                                                                                                                                                                         | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` `apps/web/src/features/dashboard/dashboard.queries.test.ts`, `app-shell.queries.test.ts`, `packages/errors/src/query-retry.test.ts` · `[convention]` in a new loader                                                                                                                                                                                                             |
| Nothing before a public page's first paint waits for a script: CSS is manifest CSS (inlined without a session), no `modulepreload` in the head, and startup JavaScript stays within three chunks and the raw/gzip budget (W15)                                                                                                                                          | [Web conventions](/docs/development/web-conventions#w15-nothing-before-the-first-paint-waits-for-a-script)                                               | `[build]` `apps/web/scripts/assert-startup-js-budget.mjs` · `[test]` `scripts/startup-js-budget.test.mjs`, `apps/web/src/platform/app/script-preloads.test.tsx`, `apps/web/src/platform/runtime/first-paint.test.ts` · `[manual]` `scripts/measure-first-paint.mjs` (public and signed-in `--signup --profile slow-4g,unthrottled`) · `[convention]` for a new stylesheet or head preload |
| A web timestamp is shown through `useFormatDate` / `<FormattedDate>`, which render in the zone the server rendered in until hydration, and a relative time through `useFormatTimeAgo`, which counts from the server's clock until hydration (W16)                                                                                                                       | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[test]` `apps/web/src/platform/format/date-format.test.ts`, `packages/intl/src/server.test.tsx`                                                                                                                                                                                                                                                                                          |
| Every web form says `method="post"`, so a submit before hydration never puts its fields in the URL (W17)                                                                                                                                                                                                                                                                | [Web conventions](/docs/development/web-conventions#w17-every-form-posts)                                                                                | `[test]` `scripts/forms-post.test.mjs`                                                                                                                                                                                                                                                                                                                                                    |
| API routes mount an HTTP edge from `packages/api`; only `platform/rpc/orpc.ts` and `platform/auth/read-session.server.ts` value-import the router, `auth`, `db` or `storage` (W18, split seams 1 and 2)                                                                                                                                                                 | [Web conventions](/docs/development/web-conventions), [ADR-0020](/docs/adr/0020-one-worker-and-four-seams)                                               | `[test]` `scripts/web-feature-boundaries.test.mjs`                                                                                                                                                                                                                                                                                                                                        |
| TanStack DB is imported only by `<feature>.collections.ts` and `platform/db/`, never from the startup graph, and refused features have no collection; the build keeps it out of startup chunks, the Worker and unlisted routes (W19)                                                                                                                                    | [Web conventions](/docs/development/web-conventions#w19-collections-stay-in-their-place), [ADR-0024](/docs/adr/0024-client-collections-with-tanstack-db) | `[test]` `scripts/web-feature-boundaries.test.mjs`, `scripts/startup-js-budget.test.mjs` · `[build]` `apps/web/scripts/assert-startup-js-budget.mjs`                                                                                                                                                                                                                                      |
| New web locale keys use their feature's prefix                                                                                                                                                                                                                                                                                                                          | [Web conventions](/docs/development/web-conventions)                                                                                                     | `[convention]` · `[test]` catalog parity in `apps/web/src/locales/locales.test.ts` · CI step `pnpm i18n:check` (x18n, not part of `pnpm test`)                                                                                                                                                                                                                                            |
| Web charts, sparklines and KPI/stat cards come from Bklit UI only: no other chart library is imported in `apps/web/src` or `packages/ui/src` or listed in their `package.json`                                                                                                                                                                                          | [Design patterns](/docs/development/design)                                                                                                              | `[test]` [`scripts/web-chart-library.test.mjs`](https://github.com/CarlosZiegler/fofo/blob/main/scripts/web-chart-library.test.mjs)                                                                                                                                                                                                                                                       |
| Faux product UI on landing, marketing and docs pages is built with Stageshow and its loop passes `film.mjs --gate`                                                                                                                                                                                                                                                      | [Design patterns](/docs/development/design)                                                                                                              | `[convention]`                                                                                                                                                                                                                                                                                                                                                                            |
| Web loading skeletons are skullet through `MeasuredSkeleton`: only `platform/skeleton/` imports `skullet`; no other skeleton component or library, no hand-made pulse box; no public route reaches the wrapper (W15)                                                                                                                                                    | [Design patterns](/docs/development/design)                                                                                                              | `[test]` [`scripts/web-skeletons.test.mjs`](https://github.com/CarlosZiegler/fofo/blob/main/scripts/web-skeletons.test.mjs) · `[convention]` a hand-made placeholder without `animate-pulse` and a muted fill                                                                                                                                                                             |
| Every colour class in `apps/web/src` is a token: no Tailwind palette class, `white`/`black` or arbitrary colour outside the lab pages and Stageshow                                                                                                                                                                                                                     | [Design patterns](/docs/development/design#rules-that-keep-it-consistent)                                                                                | `[test]` `scripts/web-tokens.test.mjs`                                                                                                                                                                                                                                                                                                                                                    |
| Web controls come from ui-sdk through `packages/ui`: `apps/web` imports no `@ui-sdk/*` and lists none in its `package.json`, the agent bridge is imported only by tests and `platform/agent/live-agent.tsx`, delete, pay and send buttons carry `data-agent-confirm` and password inputs `data-agent-secret`, and the `ui-sdk` skill links to the pinned `@ui-sdk/core` | [Design patterns](/docs/development/design)                                                                                                              | `[test]` [`scripts/web-ui-sdk.test.mjs`](https://github.com/CarlosZiegler/fofo/blob/main/scripts/web-ui-sdk.test.mjs) · `[convention]` the component choice, wrappers and tests of the `ui-sdk` skill                                                                                                                                                                                     |
| Generated UI (OpenUI): only `apps/web/src/platform/openui/` imports `@openuidev/*`, each module there loads `openui-devtools-off.ts` before react-lang, and the workspace never runs `@openuidev/lang-core`'s install telemetry                                                                                                                                         | [Design patterns](/docs/development/design)                                                                                                              | `[test]` [`scripts/web-openui.test.mjs`](https://github.com/CarlosZiegler/fofo/blob/main/scripts/web-openui.test.mjs)                                                                                                                                                                                                                                                                     |
| Vendored agent skills (`skills-lock.json`) are their upstream files byte for byte outside the repo note, every note in `.agents/skill-notes/` is written into its skill, and they change only through `pnpm skills:update`                                                                                                                                              | [Scripts](/docs/development/scripts)                                                                                                                     | `[test]` [`scripts/skill-notes.test.mjs`](https://github.com/CarlosZiegler/fofo/blob/main/scripts/skill-notes.test.mjs) · `[manual]` `node scripts/apply-skill-notes.mjs --check` · `[convention]` the diff review in the `dependency-upgrades` skill                                                                                                                                     |
| Tenant data only through `context.db`                                                                                                                                                                                                                                                                                                                                   | [ADR-0009](/docs/adr/0009-row-level-security)                                                                                                            | `[test]` `packages/api/src/platform/rpc/rls.isolation.test.ts`, `packages/db/src/rls-catalog.test.ts`, `test:rls-matrix` (CI job `rls-matrix`)                                                                                                                                                                                                                                            |
| RLS survives restores and host moves                                                                                                                                                                                                                                                                                                                                    | [ADR-0009](/docs/adr/0009-row-level-security)                                                                                                            | `[deploy]` `db:verify-rls` at the end of `db:apply-pending`                                                                                                                                                                                                                                                                                                                               |
| Cross-tenant paths are listed                                                                                                                                                                                                                                                                                                                                           | [ADR-0009](/docs/adr/0009-row-level-security)                                                                                                            | `[lint]` `scripts/check-system-call-sites.mjs` against `packages/db/src/system-call-sites.txt`; pool-import paths and entry-point exceptions in `oxlint.config.ts`                                                                                                                                                                                                                        |
| No network I/O inside `withTenant`                                                                                                                                                                                                                                                                                                                                      | `AGENTS.md`                                                                                                                                              | `[convention]`                                                                                                                                                                                                                                                                                                                                                                            |
| Isolation holds on a real deploy                                                                                                                                                                                                                                                                                                                                        | [ADR-0009](/docs/adr/0009-row-level-security)                                                                                                            | `[manual]` `scripts/rls-preview-proof.mjs` against the preview                                                                                                                                                                                                                                                                                                                            |
| Hyperdrive query caching stays off                                                                                                                                                                                                                                                                                                                                      | [ADR-0009](/docs/adr/0009-row-level-security)                                                                                                            | `[deploy]` `packages/project-setup-cli/src/hyperdrive.mjs check` in `.github/workflows/deploy-prod.yml`                                                                                                                                                                                                                                                                                   |
| `TENANCY_PROBE`, `NATIVE_DEV_SCHEME` only on previews                                                                                                                                                                                                                                                                                                                   | [ADR-0009](/docs/adr/0009-row-level-security)                                                                                                            | `[deploy]` `scripts/check-production-config.mjs`                                                                                                                                                                                                                                                                                                                                          |
| A project that opted into EU hosting (`DATA_RESIDENCY=eu`) deploys only with an EU placement hint, EU-jurisdiction R2 and an EU database region                                                                                                                                                                                                                         | [ADR-0021](/docs/adr/0021-host-in-europe)                                                                                                                | `[deploy]` `scripts/check-production-config.mjs`, `hyperdrive.mjs check` · `[tool]` `pnpm run setup` refuses a region outside the Union · `[test]` `scripts/check-production-config.test.mjs` · `[convention]` for a database not on Neon, backups and other processors                                                                                                                   |
| A production deploy stops in its first step, naming every missing required secret, before migrations and upload; the step never receives a secret's value                                                                                                                                                                                                               | [Deploy](/docs/deploy#production)                                                                                                                        | `[deploy]` first step of `.github/workflows/deploy-prod.yml` · `[test]` `scripts/deploy-secrets.test.mjs`                                                                                                                                                                                                                                                                                 |
| Domain failures are tagged and mapped once                                                                                                                                                                                                                                                                                                                              | [ADR-0010](/docs/adr/0010-procedures-run-one-effect-program)                                                                                             | `[type]` the `satisfies never` mapper in each `<feature>.errors.ts` · `[lint]` D2 in `oxlint.config.ts`: no `@orpc/*` in services, rules and policies of every feature · `[test]` `packages/api/src/testing/characterization/*.client-errors.test.ts`, `platform/rpc/procedure-edge.test.ts` (`runProcedure`, `runService`)                                                               |
| Every procedure is built with `effectProcedure`                                                                                                                                                                                                                                                                                                                         | [ADR-0010](/docs/adr/0010-procedures-run-one-effect-program)                                                                                             | `[test]` `scripts/feature-boundaries.test.mjs`; `app-config` is the one listed exception                                                                                                                                                                                                                                                                                                  |
| Every error code has a message in every language                                                                                                                                                                                                                                                                                                                        | [error handling](https://github.com/CarlosZiegler/fofo/blob/main/docs/error-handling.md)                                                                 | `[type]` `satisfies` in `packages/errors/src/keys.ts` · `[test]` `packages/errors/src/locales.test.ts`, `apps/web/src/locales/locales.test.ts`                                                                                                                                                                                                                                            |
| Effect never reaches a client                                                                                                                                                                                                                                                                                                                                           | [ADR-0005](/docs/adr/0005-effect-boundary)                                                                                                               | `[build]` `apps/web/scripts/assert-client-bundle-clean.mjs`                                                                                                                                                                                                                                                                                                                               |
| A procedure runs one program; a client abort after it starts does not roll back a write; database work drains                                                                                                                                                                                                                                                           | [ADR-0010](/docs/adr/0010-procedures-run-one-effect-program)                                                                                             | `[test]` `todo.abort.test.ts`, `documents.abort.test.ts`, `packages/api/src/platform/rpc/procedure-edge.test.ts`, `packages/api/src/platform/effect/db.test.ts`                                                                                                                                                                                                                           |
| `Effect.run*` only in the edge modules: one `run*` per entry point                                                                                                                                                                                                                                                                                                      | [ADR-0005](/docs/adr/0005-effect-boundary), [ADR-0010](/docs/adr/0010-procedures-run-one-effect-program)                                                 | `[test]` `scripts/effect-run-sites.test.mjs`                                                                                                                                                                                                                                                                                                                                              |
| No I/O runtime (`Layer`, `ManagedRuntime`) at module scope or per request                                                                                                                                                                                                                                                                                               | [ADR-0005](/docs/adr/0005-effect-boundary), [ADR-0010](/docs/adr/0010-procedures-run-one-effect-program)                                                 | `[convention]`                                                                                                                                                                                                                                                                                                                                                                            |
| An export has a production caller, or it lives under `testing/` (C1)                                                                                                                                                                                                                                                                                                    | [Testing](/docs/development/testing#test-only-code-lives-under-testing)                                                                                  | `[test]` `scripts/test-only-exports.test.mjs` (the allowlist only shrinks)                                                                                                                                                                                                                                                                                                                |
| Shared client policy lives once in a client-safe leaf module; no duplicate exported function names across `apps/web/src/platform` and `apps/mobile/src/platform` (C2)                                                                                                                                                                                                   | [Conventions](/docs/development/conventions#shared-client-policy-lives-in-a-leaf)                                                                        | `[test]` `scripts/duplicate-platform-exports.test.mjs` (platform-hook allowlist fails on stale entries) · `[test]` `scripts/leaf-modules.test.mjs`                                                                                                                                                                                                                                        |
| Only idempotent reads retry                                                                                                                                                                                                                                                                                                                                             | [ADR-0005](/docs/adr/0005-effect-boundary)                                                                                                               | `[test]` `packages/api/src/platform/effect/retry.test.ts` · `[convention]` for new call sites                                                                                                                                                                                                                                                                                             |
| An outbound HTTP call on the Worker goes through the outbound call module (`@fofo/http/outbound`): deadline, `redirect: "manual"` with a 3xx as a failure, bounded body, classified failure. Only it calls `fetch`; only the bounded reader beside it takes a stream reader                                                                                             | [Backend conventions](/docs/development/backend-conventions#external-io-has-a-deadline-only-reads-retry)                                                 | `[test]` `scripts/outbound-http.test.mjs` · `[test]` `packages/http/src/outbound.test.ts`, `read-bounded.test.ts`                                                                                                                                                                                                                                                                         |
| The tunnel and relay use one server-only ingest module and one client-safe tunnel path                                                                                                                                                                                                                                                                                  | [Error reporting](/docs/packages/error-reporting)                                                                                                        | `[lint]` `packages/config/oxlint-client-boundary.mts` (server-only ingest) · `[test]` `packages/error-reporting/src/envelope-ingest.test.ts` (both entry paths) · `[test]` `scripts/leaf-modules.test.mjs`                                                                                                                                                                                |
| Database-backed feature limits use the platform limiter and each feature owns its policy                                                                                                                                                                                                                                                                                | [Backend conventions](/docs/development/backend-conventions#database-rate-limits)                                                                        | `[convention]` shared module · `[test]` `packages/api/src/platform/rate-limit.test.ts` (window, retry delay and concurrency) · `[test]` `scripts/feature-boundaries.test.mjs` (cross-feature edges)                                                                                                                                                                                       |
| Deadlines use production values                                                                                                                                                                                                                                                                                                                                         | [ADR-0005](/docs/adr/0005-effect-boundary)                                                                                                               | `[test]` `@effect/vitest` with `TestClock`, e.g. `documents.jobs.test.ts`, `imports.jobs.test.ts`                                                                                                                                                                                                                                                                                         |
| Queue persistence changes pass the fault gate                                                                                                                                                                                                                                                                                                                           | [ADR-0006](/docs/adr/0006-effect-persisted-queue)                                                                                                        | `[manual]` `scripts/test-persisted-queue-spike.mjs`                                                                                                                                                                                                                                                                                                                                       |
| Configuration is declared in `packages/env`                                                                                                                                                                                                                                                                                                                             | [Backend conventions](/docs/development/backend-conventions)                                                                                             | `[lint]` `node/no-process-env` in `oxlint.config.ts` (`packages/**`) and `apps/web/src/oxlint.config.mts`, with named exceptions                                                                                                                                                                                                                                                          |
| Runtime switches fail safe on an invalid value                                                                                                                                                                                                                                                                                                                          | [Environment and secrets](/docs/development/environments#runtime-switches)                                                                               | `[test]` `packages/env/src/runtime-flags.test.ts`                                                                                                                                                                                                                                                                                                                                         |
| Every RPC response carries `x-request-id`, and the error log records the ID                                                                                                                                                                                                                                                                                             | [Error handling](https://github.com/CarlosZiegler/fofo/blob/main/docs/error-handling.md)                                                                 | `[test]` `packages/auth/src/request-runtime.test.ts`, `packages/api/src/platform/rpc/http.test.ts`                                                                                                                                                                                                                                                                                        |
| The Worker entry derives the request id and the client address and forwards them; no handler reads `cf-ray` or `cf-connecting-ip` (split seam 3)                                                                                                                                                                                                                        | [Backend conventions](/docs/development/backend-conventions#the-entry-forwards-the-request-facts), [ADR-0020](/docs/adr/0020-one-worker-and-four-seams)  | `[test]` `scripts/request-facts.test.mjs`, `packages/auth/src/request-runtime.test.ts`                                                                                                                                                                                                                                                                                                    |
| One module decides who acts: session authority, the captured scope, membership and the tenant handle are the request authority's; `tenantDatabase` is imported only under `platform/rpc/`                                                                                                                                                                               | [Backend conventions](/docs/development/backend-conventions#one-module-decides-who-acts)                                                                 | `[lint]` `oxlint.config.ts` · `[test]` `packages/api/src/platform/rpc/request-authority.test.ts`, `session-authority.test.ts`, `session-revocation.test.ts`                                                                                                                                                                                                                               |
| Authentication has one composition root: `packages/auth/src/index.ts` exports only `createRequestScope`, nothing in the package imports it, and the request scope takes an explicit factory                                                                                                                                                                             | [Backend conventions](/docs/development/backend-conventions#authentication-has-one-composition-root)                                                     | `[test]` `scripts/auth-composition-root.test.mjs`, `packages/auth/src/request-scope.test.ts` · `[lint]` `oxlint.config.ts` (`createDb`), `packages/config/oxlint-client-boundary.mts`                                                                                                                                                                                                     |
| What follows a write waits for COMMIT: Audit Event history, storage deletes and emails are registered on the unit of work (`committed`) and run once, never for a rolled-back unit                                                                                                                                                                                      | [Backend conventions](/docs/development/backend-conventions#what-follows-a-write-waits-for-commit)                                                       | `[test]` `packages/db/src/committed.test.ts`, `packages/api/src/platform/rpc/procedures.test.ts`, `packages/auth/src/unit-of-work.test.ts`, `packages/auth/src/user-objects.test.ts` · `[convention]`                                                                                                                                                                                     |
| Input validation answers HTTP 400 with `INPUT_VALIDATION`                                                                                                                                                                                                                                                                                                               | [Error handling](https://github.com/CarlosZiegler/fofo/blob/main/docs/error-handling.md)                                                                 | `[test]` `packages/errors/src/server.test.ts` (each `APP_ERRORS` status in `errorStatusMap`), `packages/api/src/platform/rpc/http.test.ts` (400 on the wire), characterization tests                                                                                                                                                                                                      |
| Org role checks fail closed and only follow `orgProcedure`                                                                                                                                                                                                                                                                                                              | [Backend conventions](/docs/development/backend-conventions)                                                                                             | `[type]` the middleware's input context requires `organizationRole` · `[test]` `packages/api/src/platform/rpc/require-org-role.test.ts` (including `@ts-expect-error` on other procedures) · `[convention]` where it is applied                                                                                                                                                           |
| Expected failures are not logged as errors                                                                                                                                                                                                                                                                                                                              | [Backend conventions](/docs/development/backend-conventions)                                                                                             | `[test]` `packages/errors/src/server.test.ts`                                                                                                                                                                                                                                                                                                                                             |
| No non-null assertion (`value!`) in `packages/api/src` and `apps/mobile/src` outside tests                                                                                                                                                                                                                                                                              | [Backend conventions](/docs/development/backend-conventions#no-non-null-assertion)                                                                       | `[lint]` `typescript/no-non-null-assertion` (`oxlint.config.ts`, `apps/mobile/src/oxlint.config.mts`)                                                                                                                                                                                                                                                                                     |
| Schema changes are migrations, never pushes                                                                                                                                                                                                                                                                                                                             | [Database](/docs/features/database)                                                                                                                      | `[tool]` `db:push` runs `packages/db/scripts/refuse-push.mjs` · `[test]` CI applies migrations twice                                                                                                                                                                                                                                                                                      |
| Optional features can be removed cleanly                                                                                                                                                                                                                                                                                                                                | [Optional features](https://github.com/CarlosZiegler/fofo/blob/main/docs/optional-features.md)                                                           | `[manual]` `scripts/verify-optional-client-removal.mjs`                                                                                                                                                                                                                                                                                                                                   |
| Dependencies respect the release quarantine and exact pins                                                                                                                                                                                                                                                                                                              | [Library reference](/docs/libraries)                                                                                                                     | `[test]` `scripts/tooling-tests.mjs`                                                                                                                                                                                                                                                                                                                                                      |
| A dated exception (`remove after <date>` in a config or source comment, such as a `minimumReleaseAgeExclude` entry) is removed when its date has passed                                                                                                                                                                                                                 | [Conventions](/docs/development/conventions#configuration-hygiene)                                                                                       | `[test]` `scripts/tooling-tests.mjs` (`scripts/config-hygiene.mjs`)                                                                                                                                                                                                                                                                                                                       |
| No tracked JSON or JSONC file writes a key twice in one object (`wrangler.jsonc`, `package.json`, locale catalogs)                                                                                                                                                                                                                                                      | [Conventions](/docs/development/conventions#configuration-hygiene)                                                                                       | `[test]` `scripts/tooling-tests.mjs` (`scripts/config-hygiene.mjs`)                                                                                                                                                                                                                                                                                                                       |
| A script that is also a command guards the command with `import.meta.main`, never by comparing `process.argv[1]` with its own URL (a symlinked path made the check exit 0 without running)                                                                                                                                                                              | [Conventions](/docs/development/conventions#configuration-hygiene)                                                                                       | `[test]` `scripts/entry-guard.test.mjs`                                                                                                                                                                                                                                                                                                                                                   |
| Every workflow job runs on the self-hosted VPS runner (`runs-on: [self-hosted, vps]`, disabled jobs included) with a `timeout-minutes`; no GitHub-hosted runner, `services:` or `container:`; each workflow has a `concurrency` group; only a pull request into `main` gets a preview                                                                                   | [CI and the runner](/docs/development/ci)                                                                                                                | `[test]` `scripts/ci-runners.test.mjs`                                                                                                                                                                                                                                                                                                                                                    |
| A job leaves nothing outside its workspace and `/tmp`, and writes secrets to files only under `/tmp`                                                                                                                                                                                                                                                                    | [CI and the runner](/docs/development/ci#rules-for-a-job)                                                                                                | `[convention]`                                                                                                                                                                                                                                                                                                                                                                            |
| No spread of the accumulator inside `reduce` (`{ ...acc, [key]: value }` copies it on every step)                                                                                                                                                                                                                                                                       | [Enforcement](/docs/development/enforcement#notes-on-the-lint-configuration)                                                                             | `[lint]` `oxc/no-accumulating-spread` in `oxlint.config.ts`                                                                                                                                                                                                                                                                                                                               |
| Formatting                                                                                                                                                                                                                                                                                                                                                              | [Testing and verification](/docs/development/testing)                                                                                                    | `[lint]` `pnpm format:check` (`scripts/check-format.mjs`)                                                                                                                                                                                                                                                                                                                                 |
| Docs links, ADR pages and package exports pages are valid                                                                                                                                                                                                                                                                                                               | [Writing documentation](/docs/development/docs)                                                                                                          | `[test]` [`apps/web/src/features/docs/docs.source.server.test.ts`](https://github.com/CarlosZiegler/fofo/blob/main/apps/web/src/features/docs/docs.source.server.test.ts)                                                                                                                                                                                                                 |
| A locale catalog holds its own language: no word or letter of the other three languages, and no translated string that repeats the English sentence (web, mobile, errors, email, push texts; en, de, fr, pt-BR)                                                                                                                                                         | [Conventions](/docs/development/conventions#ui-and-language)                                                                                             | `[test]` `scripts/catalog-language.test.mjs` (word lists) · `[convention]` for short one- or two-word labels                                                                                                                                                                                                                                                                              |
| Code and docs are English: no Portuguese or German words in identifiers, comments, test titles, tracked Markdown, MDX and text files, YAML files or `.github/**`; user-facing text only in the catalogs                                                                                                                                                                 | [Conventions](/docs/development/conventions#code-is-written-in-english)                                                                                  | `[test]` `scripts/code-language.test.mjs` · `[convention]` other languages, log messages, commits, branches, pull requests and hard-coded user-facing text on the web                                                                                                                                                                                                                     |
| The native app has no hard-coded copy: JSX text and string literals in copy props (`title`, `label`, `placeholder`, `accessibilityLabel`, …) come from `apps/mobile/src/locales` through `t()`                                                                                                                                                                          | [Conventions](/docs/development/conventions#code-is-written-in-english)                                                                                  | `[test]` `scripts/user-facing-strings.test.mjs`                                                                                                                                                                                                                                                                                                                                           |
| Pull requests stay reviewable: body at most 400 words without an ADR link under `docs/adr/`, and at most 1,500 changed lines outside locales, snapshots and vendored UI/skills (D2)                                                                                                                                                                                     | [Conventions](/docs/development/conventions#reviewable-pull-requests-and-prose)                                                                          | `[convention]` CI warning only ([`scripts/check-pr-reviewability.mjs`](https://github.com/CarlosZiegler/fofo/blob/main/scripts/check-pr-reviewability.mjs) in `.github/workflows/ci.yml`, never fails) · `[test]` `scripts/check-pr-reviewability.test.mjs`, `scripts/skill-notes.test.mjs` (`.agents/skill-notes/pr.md`)                                                                 |
| Changed Markdown and MDX prose avoids mechanical AI tells (`unslop` rules 7, 8, 9, 13, 18, 19, 20, 23 and 31) (D4)                                                                                                                                                                                                                                                      | [Conventions](/docs/development/conventions#reviewable-pull-requests-and-prose)                                                                          | `[convention]` CI warning only ([`scripts/check-prose.mjs`](https://github.com/CarlosZiegler/fofo/blob/main/scripts/check-prose.mjs) on changed `.md`/`.mdx` in `.github/workflows/ci.yml`, never fails) · `[test]` `scripts/check-prose.test.mjs`                                                                                                                                        |
| Runtime and bundle changes are measured                                                                                                                                                                                                                                                                                                                                 | [Conventions](/docs/development/conventions)                                                                                                             | `[convention]`                                                                                                                                                                                                                                                                                                                                                                            |
| A comment carries no code from a past plan or review ("lane C", `R8`, "review P1-1")                                                                                                                                                                                                                                                                                    | [Conventions](/docs/development/conventions#comments-explain-the-code-not-the-projects-history)                                                          | `[test]` `scripts/code-language.test.mjs`                                                                                                                                                                                                                                                                                                                                                 |
| A swallowed failure (`.catch(() => {})`, `.catch(() => null)`, `.then(…, () => {})`, an empty `catch {}`) says why inside or after the handler on the same line                                                                                                                                                                                                         | [Conventions](/docs/development/conventions#a-swallowed-failure-says-why)                                                                                | `[test]` `scripts/swallowed-rejections.test.mjs`                                                                                                                                                                                                                                                                                                                                          |
| The docs chunk of the Worker stays within its budget                                                                                                                                                                                                                                                                                                                    | [ADR-0018](/docs/adr/0018-docs-compile-into-the-worker)                                                                                                  | `[build]` `apps/web/scripts/assert-docs-budget.mjs` · `[test]` `scripts/docs-chunk.test.mjs` · `[manual]` `scripts/measure-worker-build.mjs` for the delta against a baseline                                                                                                                                                                                                             |
| `/api/*` stays on the app's host; `EXPO_PUBLIC_SERVER_URL` is the native app's only server origin (split seam 4)                                                                                                                                                                                                                                                        | [ADR-0019](/docs/adr/0019-api-stays-on-the-app-host)                                                                                                     | `[convention]`                                                                                                                                                                                                                                                                                                                                                                            |
| Production runs on Workers Paid                                                                                                                                                                                                                                                                                                                                         | [ADR-0017](/docs/adr/0017-production-runs-on-workers-paid)                                                                                               | `[convention]` (no deploy check reads the plan)                                                                                                                                                                                                                                                                                                                                           |
| ADR numbers `0001`–`0099` belong to the template; a project numbers its own from `0100`                                                                                                                                                                                                                                                                                 | [Decisions](/docs/adr)                                                                                                                                   | `[convention]`                                                                                                                                                                                                                                                                                                                                                                            |
| Pagination strategy per endpoint                                                                                                                                                                                                                                                                                                                                        | [Backend conventions](/docs/development/backend-conventions)                                                                                             | `[convention]`                                                                                                                                                                                                                                                                                                                                                                            |

## Notes on the lint configuration [#notes-on-the-lint-configuration]

- **An Oxlint override replaces the options for a rule.** The `restrictImports` helper in `oxlint.config.ts` composes the pool paths and direction rules for each override. Later, more specific overrides supply the full restriction for an entry point.
- **D2 and D8 cover every feature.** The transition list (`legacyFeatures`) was deleted on 2026-11-29, when `admin`, `audit` and `agent-tools` took the Tier 1 shape. A split service module joins `serviceTopics` so D2 covers it; nothing is excluded.
- **No JavaScript plugins and no type-aware backend, by measurement.** The anti-slop plugin (23 rules) was run on this repository on 2026-11-28: 16,549 findings, none a defect in the samples read, and a lint run 1.5 to 3.5 times slower with the plugin loaded. The only rule kept is the native `oxc/no-accumulating-spread`, which costs nothing: build the object in a loop or with `Object.fromEntries` instead of `reduce((acc, item) => ({ ...acc, … }))`. Cloudflare's `@cloudflare/oxlint-config` was not adopted either: its type-aware rules need the beta `tsrs` backend, which does not read four of the workspace's tsconfigs. Numbers per rule: [`docs/measurements/2026-11-28-anti-slop-lint.md`](https://github.com/CarlosZiegler/fofo/blob/main/docs/measurements/2026-11-28-anti-slop-lint.md). A rule that should come back needs a new measurement, not a default.
- **Import cycles are a test, not a lint rule.** `import/no-cycle` needs oxlint's `import` plugin, whose module graph made `pnpm lint` about 3.7 times slower. `scripts/import-cycles.test.mjs` runs the rule on the two server trees and `apps/mobile/src` inside `pnpm test`.
- **The web direction rules are a test for the same reason.** `apps/web/src/oxlint.config.mts` extends the client boundary; a direction rule in one of its overrides would replace that boundary in the files it covers. W1–W11 live in `scripts/web-feature-boundaries.test.mjs`; its W11 case runs `import/no-cycle` on `apps/web/src` the way `scripts/import-cycles.test.mjs` does for the server trees. The web config keeps only the boundary, its server carve-out and the `max-lines` rules ([ADR-0012](/docs/adr/0012-web-features-mirror-the-backend-shape)).
- **The web chart ban is a test for the same reason.** A chart-library entry in `apps/web/src/oxlint.config.mts` or `packages/ui/src/oxlint.config.mts` would replace the client boundary there, and one in `packages/config/oxlint-client-boundary.mts` would also reach `apps/mobile`, where Bklit does not run. `scripts/web-chart-library.test.mjs` checks imports in both web trees and the dependencies of their two `package.json` files.
- **The skeleton rule is a test for the same reason.** `scripts/web-skeletons.test.mjs` refuses a direct `skullet` import outside `apps/web/src/platform/skeleton/`, a `*Skeleton*` component imported from a package, a hand-made `animate-pulse` placeholder in `features/` and `routes/`, and another skeleton library, and walks the static imports of every route outside `routes/_auth/` to prove none reaches the wrapper. Skullet has no React Native build, so `apps/mobile` is not covered.
- **The ui-sdk rule is a test for the same reason.** `scripts/web-ui-sdk.test.mjs` refuses a `@ui-sdk/*` import in `apps/web/src` or a `@ui-sdk/*` dependency in `apps/web/package.json`, and `@fofo/ui/lib/agent` outside test files and `platform/agent/live-agent.tsx`, and it scans the screens for an unmarked confirm button or password input; `packages/ui/src` is where ui-sdk belongs, so the shared client boundary cannot carry the ban. It also checks that `.agents/skills/ui-sdk` and `.claude/skills/ui-sdk` are links into the installed `@ui-sdk/core` at the version `packages/ui` pins (skipped before `pnpm install`).
- **Nothing in the root overrides matches `apps/mobile`**, whose lint output stays unchanged.

## Next rules to automate [#next-rules-to-automate]

Session retrospectives (`/retro`, `.agents/skills/retro/`) feed candidates into this list.

- **No network I/O inside `withTenant`.** A test could wrap the tenant handle and fail when a `fetch` starts inside the callback.
- **Tenant isolation on a deploy.** `rls-preview-proof.mjs` could run in the preview workflow after the runtime check.
- **Faux UI built with Stageshow.** A test could require a `*.rehearsal.md` with a passing `--gate` run beside every component that imports `@/platform/stageshow/`. Spotting hand-built faux UI would still need review.
- **Commits and branches in English.** CI could run the word list of `scripts/code-language.test.mjs` over the pull request's commit subjects and branch name.
- **Optional removal.** The six removal runs could become a scheduled CI job. Today the base run and `--remove-server-billing` pass; the MCP and task combinations stop at `packages/api` type errors that wait on a product decision about those recipes.
