@starci/eslint-canon-be 3.11.19 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -924,7 +924,7 @@ rules:
924
924
  code: "BE_TEST_TOPOLOGY"
925
925
  editions: [lite, full]
926
926
  docs: [docs/quality-bar.md#r47-test-topology]
927
- law: "One jest config, projects `unit`, `integration`, `e2e` and `contract`, live by folder, `diagnostics: false`; unit specs are `<name>.<role>.spec.ts` beside the file they test: required for the roles of `ruleParams.be.unitRoles` (`<name>.service.spec.ts` beside a `<name>.service.ts`, `<name>.cli.spec.ts` beside a cli command `<name>.cli.ts` of `src/features/cli`), optional for any other logic role (`ruleParams.be.logicRoles`) inside a slot whose `coverage` is required and beside a logic file such a slot declares (`logic`: `passport.tokens.spec.ts` beside `passport.tokens.ts`), except that the commit adding a measured logic file stages its `<name>.<role>.spec.ts` beside it (owner 2026-10-20, judged by `starci app check --staged` in the pre-commit hook), and nowhere else but beside a webhook or realtime door that has no service of its own (`<provider>.webhook.spec.ts`, `<channel>.gateway.spec.ts`, `<x>.subscription.spec.ts`) (every unit-tested subject has exactly one; any other `*.spec.ts` outside `be/src/tests/{world,integration,e2e,contract}` is a finding, including specs in apps), and the unit project collects coverage from the logic roles of the measured roots and the logic files their slots declare only (the scope derived from the slot manifest, R204) with a per-file threshold of 100 on lines, branches, functions and statements (`test` runs `--coverage`; `importHelpers` and `tslib`); `be/src/tests/world/` is the ONLY test infrastructure: `global-setup.ts` starts the app's own stack (`.starcistacks/<env>`, named by `stack` in `test-world.config.ts`, the declaration of the test-world library in its one named form `export const { useTestWorld, useSandbox } = defineTestWorld({...})` (a default export is not read): every service it declares runs REAL, behind toxiproxy, images and versions read from the stack at run time, never spelled in test source) or attaches to a warm one that answers, and runs the migrations once over the cli app's connections (the runner of the cli migrate command); `global-teardown.ts` stops only what its setup started; `use-test-world.ts` exports `useTestWorld({ apps } | { modules })` (`world.apps.<name>.api`, `world.db.<connection>`, `world.infra.<service>` with `latency(ms)`, `cut()` and `restore()` on the real service, `world.fake.<provider>`, `world.waitFor`) and `fakes/<provider>/` holds the network-edge fakes (`failNext`, `replayWebhook`, `delay`, payload fixtures) of external SaaS the team does not operate ONLY: a fake of a service the stack declares is refused, except stateless compute that needs special hardware or an external model (GPU inference, a self-hosted embedding model), whose `stacks` entry in `test-world.config.ts` declares `{ fakedBy: <fake>, reason }` with a non-empty `reason` (a stateful service, or one with a persistent volume, is never accepted); it alone owns containers, DataSource, migrations and `process.env`; nothing under `be/src/tests` overrides a provider or DI token; `be/src/tests/integration/<capability>/*.integration-spec.ts` (`{ modules }`, with the real peer apps its client calls beside them as `apps`; real infrastructure, no HTTP door of ours), `be/src/tests/e2e/<area>/*.e2e-spec.ts` (`{ apps }`) and `be/src/tests/contract/<provider>/*.contract-spec.ts` (provider sandboxes, skipped without sandbox config, run only by `test:contract`, never by `test` or `test:e2e`) agree folder with suffix; an integration or e2e spec passes `useTestWorld` one object literal with plain keys (no variable, spread or computed key) and calls it; the contract layer has no skip either: a contract spec writes `sandbox.describe(...)` from the test-world library's `useSandbox(...)`, and when the sandbox config is absent that describe registers one failing test naming the missing keys (the body never runs), and every `fakes/<provider>/` that serves payload fixtures (`payloads/*.json`) has a `contract/<provider>/*.contract-spec.ts` that references those fixtures and asserts `shapeOf(real)` equals `shapeOf(fixture)` (the helper `shapeOf` is named by `ruleParams.be.contractShape` of the slot manifest; fakes the test-world library provides are guarded by the library); no `.test.ts`, `int-spec` or `harness-spec`, no `live/` and no `be/src/tests/e2e/world`."
927
+ law: "One jest config, projects `unit`, `integration`, `e2e` and `contract`, live by folder, `diagnostics: false`; unit specs are `<name>.<role>.spec.ts` beside the file they test: required for the roles of `ruleParams.be.unitRoles` (`<name>.service.spec.ts` beside a `<name>.service.ts`, `<name>.cli.spec.ts` beside a cli command `<name>.cli.ts` of `src/features/cli`), optional for any other logic role (`ruleParams.be.logicRoles`) inside a slot whose `coverage` is required and beside a logic file such a slot declares (`logic`: `passport.tokens.spec.ts` beside `passport.tokens.ts`), except that the commit adding a measured logic file stages its `<name>.<role>.spec.ts` beside it (owner 2026-10-20, judged by `starci app check --staged` in the pre-commit hook), and nowhere else but beside a webhook or realtime door that has no service of its own (`<provider>.webhook.spec.ts`, `<channel>.gateway.spec.ts`, `<x>.subscription.spec.ts`) (every unit-tested subject has exactly one; any other `*.spec.ts` outside `be/src/tests/{world,integration,e2e,contract}` is a finding, including specs in apps), and the unit project collects coverage from the logic roles of the measured roots and the logic files their slots declare only (the scope derived from the slot manifest, R204) with a per-file threshold of 100 on lines, branches, functions and statements (`test` runs `--coverage`; `importHelpers` and `tslib`); `be/src/tests/world/` is the ONLY test infrastructure: `global-setup.ts` starts the app's own stack (`.starcistacks/<env>`, named by `stack` in `test-world.config.ts`, the declaration of the test-world library in a named form: `export const { useTestWorld, useSandbox } = defineTestWorld({...})`, or `const world: TestWorldApi = defineTestWorld({...})` with `useTestWorld` and `useSandbox` exported typed from it (a default export is not read): every service it declares runs REAL, behind toxiproxy, images and versions read from the stack at run time, never spelled in test source) or attaches to a warm one that answers, and runs the migrations once over the cli app's connections (the runner of the cli migrate command); `global-teardown.ts` stops only what its setup started; `use-test-world.ts` exports `useTestWorld({ apps } | { modules })` (`world.apps.<name>.api`, `world.db.<connection>`, `world.infra.<service>` with `latency(ms)`, `cut()` and `restore()` on the real service, `world.fake.<provider>`, `world.waitFor`) and `fakes/<provider>/` holds the network-edge fakes (`failNext`, `replayWebhook`, `delay`, payload fixtures) of external SaaS the team does not operate ONLY: a fake of a service the stack declares is refused, except stateless compute that needs special hardware or an external model (GPU inference, a self-hosted embedding model), whose `stacks` entry in `test-world.config.ts` declares `{ fakedBy: <fake>, reason }` with a non-empty `reason` (a stateful service, or one with a persistent volume, is never accepted); it alone owns containers, DataSource, migrations and `process.env`; nothing under `be/src/tests` overrides a provider or DI token; `be/src/tests/integration/<capability>/*.integration-spec.ts` (`{ modules }`, with the real peer apps its client calls beside them as `apps`; real infrastructure, no HTTP door of ours), `be/src/tests/e2e/<area>/*.e2e-spec.ts` (`{ apps }`) and `be/src/tests/contract/<provider>/*.contract-spec.ts` (provider sandboxes, skipped without sandbox config, run only by `test:contract`, never by `test` or `test:e2e`) agree folder with suffix; an integration or e2e spec passes `useTestWorld` one object literal with plain keys (no variable, spread or computed key) and calls it; the contract layer has no skip either: a contract spec writes `sandbox.describe(...)` from the test-world library's `useSandbox(...)`, and when the sandbox config is absent that describe registers one failing test naming the missing keys (the body never runs), and every `fakes/<provider>/` that serves payload fixtures (`payloads/*.json`) has a `contract/<provider>/*.contract-spec.ts` that references those fixtures and asserts `shapeOf(real)` equals `shapeOf(fixture)` (the helper `shapeOf` is named by `ruleParams.be.contractShape` of the slot manifest; fakes the test-world library provides are guarded by the library); no `.test.ts`, `int-spec` or `harness-spec`, no `live/` and no `be/src/tests/e2e/world`."
928
928
  kinds: [check, codemod, lint]
929
929
  gates: [land, ci]
930
930
  failureCodes: ["BE_TEST_TOPOLOGY", "BE_CONTRACT_UNGUARDED", "BE_UNIT_SPEC_NOT_STAGED"]
@@ -4084,6 +4084,7 @@ rules:
4084
4084
  enforcers:
4085
4085
  - {kind: hfs, id: fe-stack, at: scripts/hfs/rules/fe-stack.mjs}
4086
4086
  - {kind: eslint-fe, id: fe-stack-import}
4087
+ - {kind: eslint-fe, id: swr-extension-from-package}
4087
4088
  proves:
4088
4089
  - {path: packages/eslint/fe/frontend-boundary-coverage.spec.mjs, editions: [lite, full], codes: [FE_STACK_FORBIDDEN]}
4089
4090
  - {path: packages/hfs/src/frontend-boundary-coverage.spec.mjs, editions: [lite, full], codes: [FE_STACK_FORBIDDEN]}
@@ -5696,7 +5697,7 @@ rules:
5696
5697
  ruling: "A model call made straight from code uses LangChain with retrieved context, through the ai-router gateway (owner ruling be-ai-langchain-gateway): the LangChain clients point at the gateway's base URL with its virtual key."
5697
5698
  - id: R328
5698
5699
  code: "BE_AUTH_PASSPORT_OWNER"
5699
- law: "The identity libraries (@nestjs/passport, passport, passport-google-oauth20, passport-local, @nestjs/jwt, jose and bcryptjs) are imported only by integrations/passport, the one owner of the Google OAuth 2.0 strategy (state and PKCE), the local email and password strategy (bcrypt) and the app's own access tokens; bcrypt and every Supabase client are owned nowhere."
5700
+ law: "The identity libraries (@nestjs/passport, passport, passport-google-oauth20, passport-local, @nestjs/jwt, jose and bcryptjs) are the dependencies of @starci/auth and are imported by no app file; @starci/auth/server is imported only by integrations/passport, its one glue. bcrypt and every Supabase client are owned nowhere."
5700
5701
  kinds: [lint]
5701
5702
  gates: [pre-commit, settle, land, ci]
5702
5703
  failureCodes: ["BE_AUTH_PASSPORT_OWNER"]
@@ -5718,7 +5719,7 @@ rules:
5718
5719
  ruling: "Lite leaves Supabase: its identity is the app own Passport integration (Google OAuth and email/password) on its self-hosted PostgreSQL; full keeps Keycloak."
5719
5720
  - id: R329
5720
5721
  code: "BE_AUTH_JWT_OWN_JWKS"
5721
- law: "A lite back-end principal comes only from the app's own access token verified by integrations/passport against its own key set (jose jwtVerify over createLocalJWKSet, issuer, audience and algorithms pinned), never from a remote JWKS, an unverified decode or a request body claim; domain/identity builds the principal from that verification."
5722
+ law: "A lite back-end principal comes only from the app's own access token, verified by @starci/auth (EdDSA pinned, issuer and audience checked, a local key set that may hold several keys), never from a remote JWKS, a token decoded without its signature check, a jwtVerify call in the app or a body claim."
5722
5723
  kinds: [check, lint]
5723
5724
  gates: [pre-commit, settle, land, ci]
5724
5725
  failureCodes: ["BE_AUTH_JWT_OWN_JWKS"]
@@ -5742,7 +5743,7 @@ rules:
5742
5743
  ruling: "The lite back end verifies its own asymmetric access tokens against its own JWKS; it trusts no remote identity provider."
5743
5744
  - id: R330
5744
5745
  code: "BE_AUTH_REFRESH_COOKIE"
5745
- law: "A refresh token travels only in an httpOnly, Secure, SameSite=Strict cookie scoped to the refresh door (set and cleared only through integrations/passport), is rotated on every use with reuse detection, and never appears as a field of a request or response body."
5746
+ law: "A refresh token travels only in the httpOnly, Secure cookie that @starci/auth sets, rotates (with a reuse grace window and reuse detection) and clears; no app file writes that cookie, and the token never appears as a field of a request or response body."
5746
5747
  kinds: [lint]
5747
5748
  gates: [pre-commit, settle, land, ci]
5748
5749
  failureCodes: ["BE_AUTH_REFRESH_COOKIE"]
@@ -5764,7 +5765,7 @@ rules:
5764
5765
  ruling: "The refresh token of the lite identity rotates and lives only in an httpOnly cookie; the browser holds no credential."
5765
5766
  - id: R331
5766
5767
  code: "BE_STORAGE_OWNER"
5767
- law: "The S3 client (@aws-sdk/client-s3 and @aws-sdk/s3-request-presigner) is imported only by integrations/object-storage, the ObjectStorage port over S3-compatible storage (MinIO in lite) with presigned PUT and GET; no module imports minio."
5768
+ law: "The S3 client libraries (@aws-sdk/client-s3 and @aws-sdk/s3-request-presigner) are the dependencies of @starci/object-storage, the ObjectStorage port over S3-compatible storage (MinIO in lite) with presigned PUT and GET, and are imported by no app file; @starci/object-storage is imported only by integrations/object-storage, its one glue; no module imports minio."
5768
5769
  kinds: [lint]
5769
5770
  gates: [pre-commit, settle, land, ci]
5770
5771
  failureCodes: ["BE_STORAGE_OWNER"]
@@ -5773,11 +5774,11 @@ rules:
5773
5774
  editions: [lite, full]
5774
5775
  docs: [contexts/code/be/infra.md]
5775
5776
  proves:
5776
- - packages/eslint-canon-be/src/auth-passport.spec.ts
5777
+ - packages/eslint-canon-be/src/object-storage-package.spec.ts
5777
5778
  exemplifiedBy:
5778
- - {path: packages/hfs/templates/be/skeleton-lite/src/modules/integrations/object-storage/object-storage.client.ts, edition: lite}
5779
+ - {path: packages/hfs/templates/be/skeleton-lite/src/modules/integrations/object-storage/object-storage.module.ts, edition: lite}
5779
5780
  witness:
5780
- - {path: packages/eslint-canon-be/src/auth-passport.spec.ts, editions: [lite, full], codes: [BE_STORAGE_OWNER]}
5781
+ - {path: packages/eslint-canon-be/src/object-storage-package.spec.ts, editions: [lite, full], codes: [BE_STORAGE_OWNER]}
5781
5782
  cases:
5782
5783
  - id: case-1
5783
5784
  date: "2026-10-29"
@@ -6525,3 +6526,101 @@ rules:
6525
6526
  source: owner
6526
6527
  quote: "The skeleton is the ready structure with its data missing; it is drawn from isLoading alone and from the reads the region shows."
6527
6528
  ruling: "Several reads feed one frame: loading is any read loading with no data; a key change reloads only the region keyed by it; a refresh keeps the content."
6529
+ - id: R368
6530
+ code: "HFS_EXPLICIT_EXPORT_SURFACE"
6531
+ law: "An exported declaration states its type where it is exported: the return type of an exported function, the type of an exported variable and the type of its parameters are written, not inferred from a body or from other files, because the isolated declaration emit must be able to write the file's surface alone. A component that returns only JSX is explicit. Each export that cannot be written is reported at its place with what to annotate, in a front-end and a back-end file alike."
6532
+ kinds: [lint]
6533
+ gates: [pre-commit, settle, land, ci]
6534
+ failureCodes: ["HFS_EXPLICIT_EXPORT_SURFACE"]
6535
+ enforcers:
6536
+ - {kind: eslint-fe, id: explicit-export-surface}
6537
+ - {kind: eslint-be, id: explicit-export-surface}
6538
+ editions: [lite, full]
6539
+ docs: [contexts/code/shared/typing.md]
6540
+ templateNa: "A template exports nothing the lint result cache keys on."
6541
+ proves:
6542
+ - {path: packages/eslint-canon-fe/src/explicit-surface.spec.ts, editions: [lite, full], codes: [HFS_EXPLICIT_EXPORT_SURFACE]}
6543
+ - {path: packages/eslint-canon-be/src/explicit-surface.spec.ts, editions: [lite, full], codes: [HFS_EXPLICIT_EXPORT_SURFACE]}
6544
+ - {path: packages/hfs/src/explicit-surface.spec.mts, editions: [lite, full], codes: [HFS_EXPLICIT_EXPORT_SURFACE]}
6545
+ exemplifiedBy:
6546
+ - {path: packages/eslint-canon-fe/src/explicit-surface.spec.ts, editions: [lite, full], codes: [HFS_EXPLICIT_EXPORT_SURFACE]}
6547
+ witness:
6548
+ - {path: packages/eslint-canon-fe/src/explicit-surface.spec.ts, editions: [lite, full], codes: [HFS_EXPLICIT_EXPORT_SURFACE]}
6549
+ - {path: packages/eslint-canon-be/src/explicit-surface.spec.ts, editions: [lite, full], codes: [HFS_EXPLICIT_EXPORT_SURFACE]}
6550
+ - {path: packages/hfs/src/explicit-surface.spec.mts, editions: [lite, full], codes: [HFS_EXPLICIT_EXPORT_SURFACE]}
6551
+ cases:
6552
+ - id: case-1
6553
+ date: "2026-11-03"
6554
+ source: owner
6555
+ quote: "enforce it by lint"
6556
+ ruling: "A file whose exported surface is inferred is open in the lint result cache: one body edit lints every importer again. The exported surface is written out, and the rule reports exactly what the cache counts as open."
6557
+ - id: R369
6558
+ code: "FE_DIRECTIVE_FIRST"
6559
+ law: "A `use client` or `use server` directive is the first statement of its module, above every import: below another statement it is an expression that does nothing (Prettier writes it as a parenthesised string) and next build refuses the file."
6560
+ kinds: [lint]
6561
+ gates: [pre-commit, settle, land, ci]
6562
+ failureCodes: ["FE_DIRECTIVE_FIRST"]
6563
+ enforcers:
6564
+ - {kind: eslint-fe, id: directive-first}
6565
+ editions: [lite, full]
6566
+ docs: [contexts/code/fe/boundaries.md]
6567
+ templateNa: "A template places its directives first."
6568
+ proves:
6569
+ - {path: packages/eslint-canon-fe/src/directive-first.spec.ts, editions: [lite, full], codes: [FE_DIRECTIVE_FIRST]}
6570
+ exemplifiedBy:
6571
+ - {path: packages/eslint-canon-fe/src/directive-first.spec.ts, editions: [lite, full], codes: [FE_DIRECTIVE_FIRST]}
6572
+ witness:
6573
+ - {path: packages/eslint-canon-fe/src/directive-first.spec.ts, editions: [lite, full], codes: [FE_DIRECTIVE_FIRST]}
6574
+ cases:
6575
+ - id: case-1
6576
+ date: "2026-11-03"
6577
+ source: owner
6578
+ quote: "no lint caught it"
6579
+ ruling: "A directive below an import broke Nivo's CI build on 2026-11-02; the directive is the first statement of its module and a lint reports it elsewhere."
6580
+ - id: R372
6581
+ code: "STACKS_LOCAL_CONFIG_INVALID"
6582
+ law: "In lite and full apps, every docker-compose environment of .starcistacks/application-stacks.yaml declares a coherent `local` block, judged by the same normalizeLocal the dev verbs of `starci app stack` (doctor, prepare, up, status, logs, verify, down) use: closed fields, one loopback port each, compose services that exist in the compose files, an environment-owned database role (never postgres, never the app role), dev-only custody generators and loopback probes; and a lite app declares at least one such dev environment, so `starci app stack up --env dev` has something to run."
6583
+ kinds: [check]
6584
+ gates: [settle, land, ci]
6585
+ failureCodes: ["STACKS_LOCAL_CONFIG_INVALID", "STACKS_DEV_UNDECLARED"]
6586
+ enforcers:
6587
+ - {kind: hfs, id: stacks-local, at: scripts/hfs/rules/stacks-local.mjs}
6588
+ editions: [lite, full]
6589
+ docs:
6590
+ - {path: contexts/project/stacks.md#project-stacks-6-every-runbook-declares-the-same-operations, editions: [lite, full]}
6591
+ proves:
6592
+ - {path: packages/hfs/src/stack-local.spec.mjs, editions: [lite, full]}
6593
+ exemplifiedBy:
6594
+ - {path: packages/hfs/templates/app/skeleton-lite/.starcistacks, edition: lite}
6595
+ witness:
6596
+ - {path: packages/hfs/src/stack-local.spec.mjs, editions: [lite, full]}
6597
+ - id: R373
6598
+ code: "STACKS_RUNBOOK_DOCKER_COMMAND"
6599
+ law: "The runbook of a docker-compose environment names `starci app stack up --env <env>` and carries no `docker build|run|compose|create|start|stop|pull|push` or `docker stack deploy` command: Docker is run by the harness verb, never by hand (hard rule 8)."
6600
+ kinds: [check]
6601
+ gates: [settle, land, ci]
6602
+ failureCodes: ["STACKS_RUNBOOK_DOCKER_COMMAND"]
6603
+ enforcers:
6604
+ - {kind: hfs, id: stacks-local, at: scripts/hfs/rules/stacks-local.mjs}
6605
+ editions: [lite, full]
6606
+ docs:
6607
+ - {path: contexts/project/stacks.md#project-stacks-10-local-runs, editions: [lite, full]}
6608
+ proves:
6609
+ - {path: packages/hfs/src/stack-local.spec.mjs, editions: [lite, full]}
6610
+ exemplifiedBy:
6611
+ - {path: packages/hfs/templates/app/skeleton-lite/.starcistacks, edition: lite}
6612
+ witness:
6613
+ - {path: packages/hfs/src/stack-local.spec.mjs, editions: [lite, full]}
6614
+ - id: R374
6615
+ code: "STACKS_CODE_BIND_MOUNT"
6616
+ law: "A service the app customises runs from an image built out of `.starcistacks/images/<name>/` (a Dockerfile whose every FROM is digest-pinned and whose final stage is the harness's image for that service, the fork or its runtime layer, when the harness owns one), the same image in every environment; no stack or compose file bind-mounts code, plugins or scripts into a service container (data volumes, secrets, least grants and read-only plain config data files stay allowed)."
6617
+ kinds: [check]
6618
+ gates: [settle, land, ci]
6619
+ failureCodes: ["STACKS_CODE_BIND_MOUNT", "STACKS_IMAGE_BASE_UNPINNED", "STACKS_IMAGE_BASE_NOT_FORK", "STACKS_IMAGE_ENV_DIVERGES"]
6620
+ enforcers:
6621
+ - {kind: hfs, id: stacks-service-images, at: scripts/hfs/rules/stacks-service-images.mjs}
6622
+ editions: [lite, full]
6623
+ docs:
6624
+ - {path: contexts/project/stacks.md#project-stacks-11-a-customised-service-is-an-image-the-app-builds-the-same-in-every-environment, editions: [lite, full]}
6625
+ proves:
6626
+ - {path: packages/hfs/src/stacks-service-images.spec.mjs, editions: [lite, full]}
@@ -236,17 +236,20 @@ ruleParams:
236
236
  "node:https": [platform/http]
237
237
  http: [platform/http]
238
238
  https: [platform/http]
239
- "@aws-sdk/client-s3": [integrations/object-storage] # the ObjectStorage port: one S3 adapter for MinIO, S3 and Spaces (R331)
240
- "@aws-sdk/s3-request-presigner": [integrations/object-storage]
241
- minio: [] # storage goes through the S3 client of integrations/object-storage
239
+ "@aws-sdk/client-s3": [] # the S3 client is a dependency of @starci/object-storage, imported by no app file (R331)
240
+ "@aws-sdk/s3-request-presigner": []
241
+ "@starci/object-storage": [integrations/object-storage] # the ObjectStorage port: one S3 adapter for MinIO, S3 and Spaces (R331)
242
+ minio: [] # storage goes through @starci/object-storage
242
243
  "@supabase": [] # no Supabase client in a back end
243
- "@nestjs/passport": [integrations/passport] # the identity libraries (R328)
244
- passport: [integrations/passport]
245
- passport-google-oauth20: [integrations/passport]
246
- passport-local: [integrations/passport]
247
- "@nestjs/jwt": [integrations/passport]
248
- jose: [integrations/passport]
249
- bcryptjs: [integrations/passport]
244
+ "@nestjs/passport": [] # the identity libraries are @starci/auth's dependencies, never an app's (R328)
245
+ passport: []
246
+ passport-google-oauth20: []
247
+ passport-local: []
248
+ "@nestjs/jwt": []
249
+ jose: []
250
+ bcryptjs: []
251
+ "@starci/auth": [integrations/passport] # the lite sign-in package: its server entry is reached only through integrations/passport (R328)
252
+ "@starci/auth/testing": [integrations/passport] # its test doubles, for the glue's specs
250
253
  bcrypt: []
251
254
  cache-manager: [integrations/cache, integrations/redis]
252
255
  "@nestjs/cache-manager": [integrations/cache, integrations/redis] # the CACHE_MANAGER token: caching goes through the cache capability
@@ -1978,36 +1981,68 @@ slots:
1978
1981
  editions: [lite]
1979
1982
  exemplifiedBy:
1980
1983
  - packages/hfs/templates/be/skeleton-lite/src/modules/integrations/passport/
1981
- # The one owner of the lite identity libraries (ruleParams.be.infraOwners: @nestjs/passport, passport, passport-google-oauth20,
1982
- # passport-local, @nestjs/jwt, jose, bcryptjs): the Google OAuth 2.0 strategy (state and PKCE), the local email and password
1983
- # strategy (bcrypt), the app's own asymmetric access tokens and their JWKS, and the rotating refresh cookie. domain/identity
1984
- # verifies a token through this integration's verifier and builds the principal (contexts/code/be/api-auth.md).
1984
+ # The glue of @starci/auth, the lite sign-in package (Google OAuth with state and PKCE, email and password, EdDSA access tokens with
1985
+ # their JWKS, rotating refresh sessions): the one importer of the package (ruleParams.be.infraOwners), which owns the identity
1986
+ # libraries (@nestjs/passport, passport, passport-google-oauth20, passport-local, @nestjs/jwt, jose, bcryptjs) that no app imports.
1987
+ # It parses the typed options, builds the verifier and names the injectors; domain/identity verifies a token through the kit and
1988
+ # builds the principal (contexts/code/be/api-auth.md).
1985
1989
  path: "src/modules/integrations/passport/"
1986
1990
  presence: required
1987
1991
  tracked: tracked
1988
1992
  tier: integrations
1989
1993
  owner: true
1990
- requires: [index.ts, passport.config.ts, passport.options.ts, passport.decorators.ts, passport.tokens.ts, passport.password.ts, passport.cookie.ts] # Secrets, no defaults (R44); options and named injectors (R83); tokens and JWKS; bcrypt; the refresh cookie
1991
- allows: [index.ts, passport.config.ts, passport.options.ts, passport.decorators.ts, passport.tokens.ts, passport.password.ts, passport.cookie.ts, strategies/, errors/]
1992
- logic: [passport.tokens.ts, passport.password.ts, passport.cookie.ts] # JWT sign and verify over the own JWKS, bcrypt, the refresh cookie: measured at 100 per file
1994
+ requires: [index.ts, passport.config.ts, passport.options.ts, passport.decorators.ts, passport.kit.ts, passport.registration.ts] # Secrets, no defaults (R44); options and named injectors (R83); the kit and the module over @starci/auth
1995
+ allows: [index.ts, passport.config.ts, passport.options.ts, passport.decorators.ts, passport.kit.ts, passport.registration.ts, errors/]
1996
+ logic: [passport.kit.ts] # the verifier mapping over the package: measured at 100 per file
1993
1997
  tests: unit-beside
1994
1998
  rules: [BE_TIER_DIRECTION, BE_ERROR_HOME, BE_SECRET_DEFAULT, BE_INFRA_OWNER, BE_AUTH_PASSPORT_OWNER, BE_AUTH_JWT_OWN_JWKS, BE_AUTH_REFRESH_COOKIE]
1995
1999
  coverage: required
1996
2000
  since: 3.9.0
2001
+ - id: be.identity.sign-in
2002
+ since: 3.16.0
2003
+ profiles: [be]
2004
+ editions: [lite]
2005
+ editionWhy: "lite signs people in with the package @starci/auth, so its sign-in glue is rendered, not written (owner ruling auth-package); full uses its identity provider."
2006
+ # The identity capability's sign-in glue over @starci/auth: the entities of the session, attempt and user tables, the stores the package asks for (sessions, accounts, rate counter), the authenticator and the service the doors call, with their specs. `starci app sync` renders them; a hand edit is drift.
2007
+ path: "{src/modules/domain/identity/account-directory.service.spec.ts,src/modules/domain/identity/account-directory.service.ts,src/modules/domain/identity/authenticator.service.spec.ts,src/modules/domain/identity/authenticator.service.ts,src/modules/domain/identity/persistence/entities/auth-identity.entity.ts,src/modules/domain/identity/persistence/entities/auth-user.entity.ts,src/modules/domain/identity/persistence/entities/identity-attempt.entity.ts,src/modules/domain/identity/persistence/entities/identity-refresh-token.entity.ts,src/modules/domain/identity/persistence/entities/identity-session.entity.ts,src/modules/domain/identity/persistence/entities/index.ts,src/modules/domain/identity/rate-counter.service.spec.ts,src/modules/domain/identity/rate-counter.service.ts,src/modules/domain/identity/session-store.service.spec.ts,src/modules/domain/identity/session-store.service.ts,src/modules/domain/identity/sign-in.service.spec.ts,src/modules/domain/identity/sign-in.service.ts,src/tests/fixtures/builders/identity.builder.ts}"
2008
+ presence: optional
2009
+ tracked: tracked
2010
+ tier: inherit
2011
+ tests: unit-beside
2012
+ coverage: none
2013
+ managedBy: auth-lite
2014
+ managedOnly: true # lists files sync renders; the slot owning the path judges them
2015
+ rules: [HFS_MANAGED_FILE_DRIFT]
2016
+ - id: be.feature.auth
2017
+ since: 3.16.0
2018
+ profiles: [be]
2019
+ editions: [lite]
2020
+ editionWhy: "lite signs people in with the package @starci/auth, so its sign-in glue is rendered, not written (owner ruling auth-package); full uses its identity provider."
2021
+ # The auth feature: the REST doors under /auth (login, refresh, session, logout, Google start and callback, jwks) over IdentitySignInService, one command or query and handler per door.
2022
+ path: "{src/features/api/auth/application/auth.contracts.ts,src/features/api/auth/application/get-jwks.handler.ts,src/features/api/auth/application/get-jwks.query.ts,src/features/api/auth/application/google-begin.command.ts,src/features/api/auth/application/google-begin.handler.ts,src/features/api/auth/application/google-complete.command.ts,src/features/api/auth/application/google-complete.handler.ts,src/features/api/auth/application/login.command.ts,src/features/api/auth/application/login.handler.ts,src/features/api/auth/application/logout.command.ts,src/features/api/auth/application/logout.handler.ts,src/features/api/auth/application/refresh.command.ts,src/features/api/auth/application/refresh.handler.ts,src/features/api/auth/application/session.command.ts,src/features/api/auth/application/session.handler.ts,src/features/api/auth/auth.module-definition.ts,src/features/api/auth/auth.module.ts,src/features/api/auth/auth.options.ts,src/features/api/auth/index.ts,src/features/api/auth/transport/http/auth-http.module-definition.ts,src/features/api/auth/transport/http/auth-http.module.ts,src/features/api/auth/transport/http/auth-http.options.ts,src/features/api/auth/transport/http/auth.controller.ts,src/features/api/auth/transport/http/dto/google-start.request.ts,src/features/api/auth/transport/http/dto/login.request.ts}"
2023
+ presence: optional
2024
+ tracked: tracked
2025
+ tier: inherit
2026
+ tests: none
2027
+ coverage: none
2028
+ managedBy: auth-lite
2029
+ managedOnly: true # lists files sync renders; the slot owning the path judges them
2030
+ rules: [HFS_MANAGED_FILE_DRIFT]
1997
2031
  - id: be.integrations.object-storage
1998
2032
  profiles: [be]
1999
2033
  exemplifiedBy:
2000
2034
  - packages/hfs/templates/be/skeleton-lite/src/modules/integrations/object-storage/
2001
- # The one owner of the S3 client (@aws-sdk/client-s3 and @aws-sdk/s3-request-presigner) over S3-compatible storage (MinIO in
2002
- # lite): the ObjectStorage port with presigned PUT and GET; no other module imports an S3 SDK or minio.
2035
+ # The glue of @starci/object-storage, the owner of the S3 client (@aws-sdk/client-s3 and @aws-sdk/s3-request-presigner) over
2036
+ # S3-compatible storage (MinIO in lite): this folder keeps the bucket, parses the settings and registers the module; no app
2037
+ # file imports an S3 SDK or minio, and no other module imports the package.
2003
2038
  path: "src/modules/integrations/object-storage/"
2004
2039
  presence: optional
2005
2040
  litePresence: required
2006
2041
  tracked: tracked
2007
2042
  tier: integrations
2008
2043
  owner: true
2009
- requires: [index.ts, object-storage.config.ts, object-storage.options.ts, object-storage.decorators.ts, object-storage.client.ts]
2010
- allows: [index.ts, object-storage.module.ts, object-storage.module-definition.ts, object-storage.config.ts, object-storage.options.ts, object-storage.decorators.ts, object-storage.client.ts, errors/]
2044
+ requires: [index.ts, object-storage.config.ts, object-storage.options.ts, object-storage.decorators.ts, object-storage.module-definition.ts, object-storage.module.ts]
2045
+ allows: [index.ts, object-storage.config.ts, object-storage.options.ts, object-storage.decorators.ts, object-storage.module-definition.ts, object-storage.module.ts, errors/]
2011
2046
  tests: unit-beside
2012
2047
  rules: [BE_TIER_DIRECTION, BE_ERROR_HOME, BE_SECRET_DEFAULT, BE_INFRA_OWNER, BE_STORAGE_OWNER]
2013
2048
  coverage: required
@@ -2541,7 +2576,7 @@ slots:
2541
2576
  profiles: [fe]
2542
2577
  # The identity-provider client (fe-stack auth, FE-AUTH): the session, the access token the Apollo link attaches and the
2543
2578
  # sign-in/sign-out calls. It talks only to the app's own back-end auth doors and holds no credential: the refresh token lives in
2544
- # the back end's httpOnly cookie and the access token in memory (ruling:lite-self-hosted-postgres-passport-minio).
2579
+ # the back end's httpOnly cookie and the access token in the memory of the one @starci/auth client (ruling:lite-self-hosted-postgres-passport-minio).
2545
2580
  path: "apps/<app>/src/modules/auth/"
2546
2581
  presence: optional
2547
2582
  tracked: tracked
@@ -2551,6 +2586,20 @@ slots:
2551
2586
  tests: none
2552
2587
  since: 3.0.0
2553
2588
  rules: [FE_STACK_FORBIDDEN]
2589
+ - id: fe.modules.auth.client
2590
+ since: 3.16.0
2591
+ profiles: [fe]
2592
+ editions: [lite]
2593
+ editionWhy: "lite signs people in with the package @starci/auth, so its auth client is rendered, not written (owner ruling auth-package); full wires its identity provider."
2594
+ # The AuthClient every edition shares, implemented by one @starci/auth/client instance over the app's own back-end auth doors.
2595
+ path: "apps/web/src/modules/auth/client.ts"
2596
+ presence: optional
2597
+ tracked: tracked
2598
+ tier: inherit
2599
+ tests: none
2600
+ managedBy: auth-lite
2601
+ managedOnly: true # lists files sync renders; the slot owning the path judges them
2602
+ rules: [HFS_MANAGED_FILE_DRIFT]
2554
2603
  - id: fe.modules.toast
2555
2604
  profiles: [fe]
2556
2605
  # Mutation feedback (fe-stack toast, FE-TOAST): the HeroUI toast wrapper, showGraphQLToast over a GraphQLResponse and the
@@ -1,57 +1,17 @@
1
- // identity.mjs - the back-end identity machine. Under lite the one token verifier is be.integrations.passport: jose's jwtVerify
2
- // there checks the app's OWN key set (createLocalJWKSet over the keys it signs with, never createRemoteJWKSet), pins issuer,
3
- // audience and algorithms, and no file decodes a token unverified or reads authorization claims from a request body (R329).
4
- // In both editions every jwtVerify call holds the JWT policy (R260, jwtPolicyProblems).
1
+ // identity.mjs - the back-end identity machine. Under lite the one token verifier is @starci/auth, composed by be.integrations.passport:
2
+ // no app file calls jose's jwtVerify, decodes a token unverified or reads authorization claims from a request body (R329), and the
3
+ // passport integration imports @starci/auth/server. In both editions every jwtVerify call holds the JWT policy (R260, jwtPolicyProblems).
5
4
  import path from 'node:path';
6
5
  import { machineKit } from './machine-ast.mjs';
7
- import { fromConfig, importedFrom, jwtPolicyProblems, reportAt, unwrap } from './jwt-ast.mjs';
6
+ import { jwtPolicyProblems, reportAt, unwrap } from './jwt-ast.mjs';
8
7
  import { accessName } from '../../lib/ts-ast.mjs';
9
8
  const PASSPORT_SLOT = 'be.integrations.passport';
9
+ const PACKAGE_ENTRY = '@starci/auth/server';
10
10
  const BE_JWT_VERIFIED = 'BE_AUTH_JWT_OWN_JWKS';
11
11
  /** The rule ids the back-end identity machine reports. */
12
12
  export const IDENTITY_RULE_IDS = Object.freeze(['BE_AUTH_JWT_OWN_JWKS', 'BE_JWT_ALG_PINNED']);
13
13
  const JWT_MODULES = new Set(['jose', 'jsonwebtoken', 'jwt-decode']);
14
14
  const CLAIM_NAMES = new Set(['role', 'roles', 'membership', 'memberships']);
15
- const objectLiteral = (kit, checker, node) => {
16
- const current = unwrap(kit.ts, node);
17
- if (!current)
18
- return null;
19
- if (kit.ts.isObjectLiteralExpression(current))
20
- return current;
21
- if (!kit.ts.isIdentifier(current))
22
- return null;
23
- for (const declaration of kit.declarationsOf(checker, current)) {
24
- if (kit.ts.isVariableDeclaration(declaration) && declaration.initializer) {
25
- const value = unwrap(kit.ts, declaration.initializer);
26
- if (kit.ts.isObjectLiteralExpression(value))
27
- return value;
28
- }
29
- }
30
- return null;
31
- };
32
- const staticStrings = (kit, checker, node) => {
33
- const current = unwrap(kit.ts, node);
34
- if (kit.ts.isStringLiteralLike(current))
35
- return [current.text];
36
- if (kit.ts.isArrayLiteralExpression(current)) {
37
- const literals = current.elements.filter((element) => kit.ts.isStringLiteralLike(element));
38
- if (literals.length === current.elements.length)
39
- return literals.map((element) => element.text);
40
- }
41
- const value = kit.stringValue(checker, current);
42
- return value === null ? null : [value];
43
- };
44
- const jwksArgument = (kit, checker, node) => {
45
- const current = unwrap(kit.ts, node);
46
- if (!current)
47
- return false;
48
- if (kit.ts.isCallExpression(current))
49
- return importedFrom(kit, checker, current.expression, new Set(['jose']), new Set(['createLocalJWKSet']));
50
- if (!kit.ts.isIdentifier(current))
51
- return false;
52
- return kit.declarationsOf(checker, current).some((declaration) => kit.ts.isVariableDeclaration(declaration) && declaration.initializer
53
- && jwksArgument(kit, checker, declaration.initializer));
54
- };
55
15
  const importedCall = (kit, checker, call) => {
56
16
  const direct = kit.importBinding(checker, call.expression);
57
17
  if (direct?.module === 'jwt-decode' && direct.name === 'default')
@@ -84,41 +44,16 @@ const fromRequestBody = (kit, checker, node, seen = new Set()) => {
84
44
  return kit.declarationsOf(checker, current).some(declaration => kit.ts.isVariableDeclaration(declaration) && declaration.initializer
85
45
  && fromRequestBody(kit, checker, declaration.initializer, seen));
86
46
  };
87
- function verifyJwtCall(kit, checker, file, node, counters, violations) {
88
- counters.verifyCalls += 1;
89
- if (file.slot !== PASSPORT_SLOT) {
90
- reportAt(violations, kit, BE_JWT_VERIFIED, file, node, `jwtVerify is called outside ${PASSPORT_SLOT}; the integration is the one token verifier.`);
91
- return true;
92
- }
93
- const options = objectLiteral(kit, checker, node.arguments[2]);
94
- const property = (name) => options ? kit.propertyOf(options, name) : null;
95
- const values = (name) => {
96
- const entry = property(name);
97
- return entry ? staticStrings(kit, checker, kit.valueOfProperty(entry)) : null;
98
- };
99
- const issuer = property('issuer');
100
- const audience = values('audience');
101
- const algorithms = values('algorithms');
102
- // The audience is pinned by a literal or, as R260 accepts, by typed configuration (the skeleton's TokenOptions.audience).
103
- const audienceEntry = property('audience');
104
- const pinnedAudience = (audience !== null && audience.length > 0)
105
- || (audienceEntry != null && fromConfig(kit.ts, checker, kit.valueOfProperty(audienceEntry)));
106
- const good = jwksArgument(kit, checker, node.arguments[1]) && issuer != null && pinnedAudience
107
- && algorithms !== null && algorithms.length > 0;
108
- if (!good) {
109
- reportAt(violations, kit, BE_JWT_VERIFIED, file, node, 'jwtVerify must check the app\'s own key set (createLocalJWKSet(...) over the keys integrations/passport signs with) and pin issuer, audience and a non-empty algorithms list; jwtVerify then enforces signature and exp.');
110
- }
111
- else
112
- counters.verifiedCalls += 1;
113
- return false;
114
- }
115
47
  function inspectJwtCall(kit, checker, file, node, counters, violations) {
116
48
  const binding = importedCall(kit, checker, node);
117
49
  if (binding && JWT_MODULES.has(binding.module) && ['decode', 'decodeJwt', 'jwtDecode'].includes(binding.name)) {
118
50
  reportAt(violations, kit, BE_JWT_VERIFIED, file, node, `${binding.module}.${binding.name} decodes a token without proving its signature; verify it through integrations/passport.`, { module: binding.module, method: binding.name });
119
51
  }
120
- if (binding?.module === 'jose' && binding.name === 'jwtVerify')
121
- return verifyJwtCall(kit, checker, file, node, counters, violations);
52
+ if (binding?.module === 'jose' && binding.name === 'jwtVerify') {
53
+ counters.verifyCalls += 1;
54
+ reportAt(violations, kit, BE_JWT_VERIFIED, file, node, 'jwtVerify is called in the app; @starci/auth verifies the own access tokens, reached through ' + PASSPORT_SLOT + '.');
55
+ return true;
56
+ }
122
57
  return false;
123
58
  }
124
59
  function inspectRequestClaims(kit, file, node, checker, violations) {
@@ -146,18 +81,18 @@ function checkOwnJwks(input) {
146
81
  const violations = [];
147
82
  const integrations = [...input.graph.files.values()].filter((file) => file.slot === PASSPORT_SLOT);
148
83
  if (!integrations.length)
149
- return { violations, coverage: { status: 'not-applicable', integrationFiles: 0, verifiedCalls: 0 } };
150
- const counters = { verifyCalls: 0, verifiedCalls: 0 };
84
+ return { violations, coverage: { status: 'not-applicable', integrationFiles: 0, verifyCalls: 0 } };
85
+ const counters = { verifyCalls: 0 };
151
86
  for (const file of input.graph.files.values()) {
152
87
  const checker = kit.checkerOf(file.sourceFile);
153
88
  kit.walk(file.sourceFile, (node) => inspectBackendNode(kit, checker, file, node, counters, violations));
154
89
  }
155
- if (counters.verifyCalls === 0) {
156
- const anchor = integrations.find((file) => path.posix.basename(file.rel).endsWith('.tokens.ts')) ?? integrations[0];
157
- if (anchor)
158
- reportAt(violations, kit, BE_JWT_VERIFIED, anchor, anchor.sourceFile, `${PASSPORT_SLOT} has no jose.jwtVerify call backed by createLocalJWKSet over the app's own keys.`);
159
- }
160
- return { violations, coverage: { status: 'checked', integrationFiles: integrations.length, verifyCalls: counters.verifyCalls, verifiedCalls: counters.verifiedCalls } };
90
+ const composes = integrations.some((file) => file.sourceFile.statements.some((statement) => kit.ts.isImportDeclaration(statement)
91
+ && kit.ts.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === PACKAGE_ENTRY));
92
+ const anchor = integrations.find((file) => path.posix.basename(file.rel) === 'index.ts') ?? integrations[0];
93
+ if (!composes && anchor)
94
+ reportAt(violations, kit, BE_JWT_VERIFIED, anchor, anchor.sourceFile, PASSPORT_SLOT + ' does not import ' + PACKAGE_ENTRY + ', the one verifier of the own access tokens.');
95
+ return { violations, coverage: { status: 'checked', integrationFiles: integrations.length, verifyCalls: counters.verifyCalls, composesPackage: composes } };
161
96
  }
162
97
  /** R260 BE_JWT_ALG_PINNED: every jose jwtVerify call pins a literal secure algorithm list and a configured issuer, and binds the principal by a configured audience or the authenticated role. */
163
98
  export function checkJwtPolicy(input) {
@@ -15,9 +15,10 @@ import { byCodeUnit } from '../../lib/list.mjs';
15
15
  * its own slot, be.tests.world.kit) plus files at its root whose role suffix is in ruleParams.be.suffixes
16
16
  * (`stripe.client.ts`, `checkout.contracts.ts`, `test-world.config.ts`, ...). Every tracked file below the world root is
17
17
  * matched by the slot's own entries through `allowsFile`.
18
- * 2. The declaration. `test-world.config.ts` declares the world in ONE form, the named export R89 allows:
19
- * `export const { useTestWorld, useSandbox } = defineTestWorld({ ... })` (an exported `const` initialized by a
20
- * `defineTestWorld(<object literal>)` call). A config without it (a default export, or a declaration the machine cannot
18
+ * 2. The declaration. `test-world.config.ts` declares the world in a named form R89 allows: the destructured export
19
+ * `export const { useTestWorld, useSandbox } = defineTestWorld({ ... })`, or the typed form
20
+ * `const world: TestWorldApi = defineTestWorld({ ... })` whose `useTestWorld` and `useSandbox` are exported consts typed from
21
+ * `TestWorldApi` (a `const` initialized by a `defineTestWorld(<object literal>)` call). A config without it (a default export, or a declaration the machine cannot
21
22
  * read) is refused: the world it declares could not be judged.
22
23
  * 3. Fakes against the stack (owner refinement 2026-09-30). Every service the stack declares runs real in the world; a fake
23
24
  * (a `fakes/<provider>/` folder, or a `fakes` entry of the declaration such as `smtp: smtpFake()`) is a network-edge fake
@@ -38,6 +39,7 @@ const FAKES_DIRECTORY = 'fakes/';
38
39
  const CONFIG_FILE = 'test-world.config.ts';
39
40
  const DEFINE = 'defineTestWorld';
40
41
  const NAMED_FORM = `export const { useTestWorld, useSandbox } = ${DEFINE}({ ... })`;
42
+ const TYPED_FORM = `const world: TestWorldApi = ${DEFINE}({ ... })` + ' with export const useTestWorld / useSandbox typed from it';
41
43
  const defaultEnvironment = DEFAULT_ENVIRONMENT;
42
44
  const KEBAB = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
43
45
  const unwrap = (ts, node) => unwrapEach(ts, node, [ts.isParenthesizedExpression, ts.isAsExpression, ts.isSatisfiesExpression]);
@@ -52,21 +54,38 @@ function defineLiteral(ts, expression) {
52
54
  const literal = first ? unwrap(ts, first) : null;
53
55
  return literal && ts.isObjectLiteralExpression(literal) ? literal : null;
54
56
  }
55
- /** The declaration of the world: the object literal of an exported `const` initialized by `defineTestWorld({ ... })`, or null. */
57
+ /**
58
+ * The declaration of the world: the object literal of a top-level `const` initialized by `defineTestWorld({ ... })`, or null. The config
59
+ * exports `useTestWorld` and `useSandbox` either by destructuring that call (the original form) or, typed, from the world the call
60
+ * built: `const world: TestWorldApi = defineTestWorld({ ... })` with `export const useTestWorld: TestWorldApi["useTestWorld"] = world.useTestWorld`.
61
+ * Both are read; a world no exported name reaches is refused by the caller.
62
+ */
56
63
  function configLiteral(ts, sourceFile) {
57
64
  for (const statement of sourceFile.statements) {
58
- if (!ts.isVariableStatement(statement) || !isExported(ts, statement))
65
+ if (!ts.isVariableStatement(statement))
59
66
  continue;
60
67
  if (!hasAnyFlag(statement.declarationList.flags, ts.NodeFlags.Const))
61
68
  continue;
62
69
  for (const declaration of statement.declarationList.declarations) {
63
70
  const literal = declaration.initializer ? defineLiteral(ts, declaration.initializer) : null;
64
- if (literal)
71
+ if (literal && (isExported(ts, statement) || exportsWorld(ts, sourceFile)))
65
72
  return literal;
66
73
  }
67
74
  }
68
75
  return null;
69
76
  }
77
+ /** Whether the file exports both `useTestWorld` and `useSandbox` as consts (the typed form re-exports them from the built world). */
78
+ function exportsWorld(ts, sourceFile) {
79
+ const exported = new Set();
80
+ for (const statement of sourceFile.statements) {
81
+ if (!ts.isVariableStatement(statement) || !isExported(ts, statement))
82
+ continue;
83
+ for (const declaration of statement.declarationList.declarations)
84
+ if (ts.isIdentifier(declaration.name))
85
+ exported.add(declaration.name.text);
86
+ }
87
+ return exported.has('useTestWorld') && exported.has('useSandbox');
88
+ }
70
89
  /** `stack` as the environment it names: the last segment of `".starcistacks/<env>"`; null when absent or not a literal. */
71
90
  function environmentOf(ts, literal) {
72
91
  const node = literal ? propertyOf(ts, literal, 'stack') : null;
@@ -152,7 +171,7 @@ function worldDeclaration(graph, ts, worldRoot, violations) {
152
171
  if (configFile && !literal) {
153
172
  violations.push({
154
173
  ruleId: RULE, path: configPath, line: 1, column: 1, slot: WORLD_SLOT,
155
- message: `${configPath} declares no world the machine can read. Declare it in the one named form \`${NAMED_FORM}\` (an exported const of a ${DEFINE} call with an object literal, imported from @starci/test-world); a default export is refused by R89 and is not read.`,
174
+ message: `${configPath} declares no world the machine can read. Declare it in the named form \`${NAMED_FORM}\` or the typed form \`${TYPED_FORM}\` (a const of a ${DEFINE} call with an object literal, imported from @starci/test-world); a default export is refused by R89 and is not read.`,
156
175
  });
157
176
  }
158
177
  return { configPath, configFile, literal };
@@ -17,8 +17,7 @@ import { propertyValue } from './function-spec-providers.mjs';
17
17
  * - no file outside the client folder and the stream reader folder (`fe.transport.stream`, `modules/api/sse/clients/`) references the global `fetch`: a call, `globalThis.fetch`, `window.fetch`, or a
18
18
  * reference passed as a value (`useSWR(key, fetch)`, `const send = fetch`), all of which a spelling-based rule misses; with no
19
19
  * client at all every such reference is a finding that says the repository has no client;
20
- * - axios is imported only by the api owner (modules/api, the api package) for its rest calls and by the auth door
21
- * (modules/auth/auth-door.ts) for the app's own auth doors; every other HTTP library is a
20
+ * - axios is imported only by the api owner (modules/api, the api package) for its rest calls; every other HTTP library is a
22
21
  * second transport wherever it is imported, by static import, `import()` or `require()`;
23
22
  * - an `ApolloClient` is constructed only inside the client folder;
24
23
  * - every GraphQL operation (`graphql/queries/query-*.ts`, `graphql/mutations/mutation-*.ts`, `graphql/subscriptions/subscription-*.ts`) imports the client (or the api
@@ -105,17 +104,15 @@ function isApolloClientConstruction(ts, kit, checker, node) {
105
104
  const binding = kit.importBinding(checker, node.expression);
106
105
  return Boolean(binding?.name === 'ApolloClient' && binding.module.startsWith('@apollo/client'));
107
106
  }
108
- /** The one auth door of the session issuer's client (`modules/auth/auth-door.ts`, slot fe.modules.auth): it calls the app's own auth doors with axios. */
109
- const isAuthDoor = (file) => file.slot === 'fe.modules.auth' && path.posix.basename(file.rel) === 'auth-door.ts';
110
107
  function inspectLibraryImport({ ts, file, node, transport, report }) {
111
108
  const specifier = moduleSpecifierOf(ts, node);
112
109
  if (!specifier || !ts.isStringLiteralLike(specifier))
113
110
  return;
114
111
  const library = specifier.text.split('/')[0];
115
- if (!HTTP_LIBRARIES.has(library) || (library === REST_LIBRARY && (API_OWNER_SLOTS.has(file.slot) || isAuthDoor(file))))
112
+ if (!HTTP_LIBRARIES.has(library) || (library === REST_LIBRARY && (API_OWNER_SLOTS.has(file.slot))))
116
113
  return;
117
114
  const where = library === REST_LIBRARY
118
- ? 'axios belongs to the api owner (modules/api/rest, the api package) and the auth door (modules/auth/auth-door.ts) only: call their functions'
115
+ ? 'axios belongs to the api owner (modules/api/rest, the api package) only: call their functions'
119
116
  : `the transport is Apollo GraphQL (${transport}) with axios for the rest calls of modules/api/rest`;
120
117
  report(file, node, `${specifier.text} is a second HTTP transport in ${file.rel}; ${where}.`, { library: specifier.text });
121
118
  }