@starci/eslint-canon-be 3.12.0 → 3.14.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.
@@ -236,17 +236,29 @@ 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
243
+ nodemailer: [] # the SMTP client is a dependency of @starci/mail alone; no app file imports it
244
+ "@starci/mail": [integrations/mail] # outgoing mail: the Mailer port, parsed and registered by its one glue
242
245
  "@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]
246
+ "@nestjs/passport": [] # the identity libraries are @starci/auth's dependencies, never an app's (R328)
247
+ passport: []
248
+ passport-google-oauth20: []
249
+ passport-local: []
250
+ "@nestjs/jwt": []
251
+ jose: []
252
+ bcryptjs: []
253
+ jsonwebtoken: [] # no other JWT or OIDC client library in a back end: the tokens of an identity provider are verified by @starci/auth-oidc (R328)
254
+ jwks-rsa: []
255
+ jwt-decode: []
256
+ passport-jwt: []
257
+ openid-client: []
258
+ "@starci/auth": [integrations/passport] # the lite sign-in package: its server entry is reached only through integrations/passport (R328)
259
+ "@starci/auth/testing": [integrations/passport] # its test doubles, for the glue's specs
260
+ "@starci/auth-oidc": [integrations/keycloak] # the full sign-in package (jose is its dependency, imported by no app file): its server entry is reached only through integrations/keycloak (R328)
261
+ "@starci/auth-oidc/testing": [integrations/keycloak] # its fake issuer, for the glue's specs
250
262
  bcrypt: []
251
263
  cache-manager: [integrations/cache, integrations/redis]
252
264
  "@nestjs/cache-manager": [integrations/cache, integrations/redis] # the CACHE_MANAGER token: caching goes through the cache capability
@@ -460,6 +472,14 @@ ruleParams:
460
472
  - {name: public.event_bus_bury, reason: "platform/event-bus (add webhook, lite): the move of an exhausted or malformed message to its consumer's dead-letter queue"}
461
473
  - {name: public.event_bus_dead_letters, reason: "platform/event-bus (add webhook, lite): the operator read of a consumer's dead-letter queue"}
462
474
  - {name: public.event_bus_requeue, reason: "platform/event-bus (add webhook, lite): the operator requeue of one dead letter"}
475
+ - {name: public.be_auth_user_by_email, reason: "domain/identity (lite sign-in): the account of an exact sign-in address with its bcrypt hash, through the account-doors definer of the baseline"}
476
+ - {name: public.be_auth_user_by_id, reason: "domain/identity (lite sign-in): the standing of one account by id (a refresh), through the account-doors definer"}
477
+ - {name: public.be_auth_user_by_google, reason: "domain/identity (lite sign-in): the account a Google subject is linked to, through the account-doors definer"}
478
+ - {name: public.be_auth_create_user, reason: "domain/identity (lite sign-in): the account a first Google sign-in creates, through the account-doors definer"}
479
+ - {name: public.be_auth_link_google, reason: "domain/identity (lite sign-in): the link of a Google subject to an account, through the account-doors definer"}
480
+ - {name: public.be_auth_touch_user, reason: "domain/identity (lite sign-in): the sign-in record of an account and its profile keys, through the account-doors definer"}
481
+ - {name: public.be_auth_confirm_user, reason: "domain/identity (lite sign-in): the confirmation stamp of a mailbox whose link was spent, through the account-doors definer"}
482
+ - {name: public.be_auth_set_password, reason: "domain/identity (lite sign-in): the new password hash of a spent reset link (and the mailbox it proved), through the account-doors definer"}
463
483
  # R334 (lite): the only `.query(` outside platform/database's composer and the test world is the pass-through of a file listed here
464
484
  # (or in hfs.json sides.be.sqlPassThrough), whose SQL text is not the app's own. Paths are relative to the side folder.
465
485
  sqlPassThrough:
@@ -587,13 +607,24 @@ slots:
587
607
  - id: app.tool-config-local
588
608
  since: 3.1.0
589
609
  profiles: [app]
590
- path: "{tsconfig.json,.eslintrc,.eslintrc.*,.eslintignore,eslint.config.*,.stylelintrc,.stylelintrc.*,.stylelintignore,stylelint.config.*,.prettierrc.*,prettier.config.*,jest.config.*,lint-staged.config.*,.lintstagedrc*}"
610
+ path: "{tsconfig.json,.eslintrc,.eslintrc.*,.eslintignore,eslint.config.js,eslint.config.cjs,eslint.config.ts,eslint.config.mts,eslint.config.cts,.stylelintrc,.stylelintrc.*,.stylelintignore,stylelint.config.*,.prettierrc.*,prettier.config.*,jest.config.*,lint-staged.config.*,.lintstagedrc*}"
591
611
  presence: forbidden
592
612
  tracked: external
593
613
  tier: none
594
614
  tests: none
595
- goesTo: "nowhere at the app root: each side holds exactly its managed tool configuration (be.tool-config, fe.tool-config) and the root only the formatter (app.format-config)"
615
+ goesTo: "nowhere at the app root: each side holds exactly its managed tool configuration (be.tool-config, fe.tool-config) and the root only the formatter (app.format-config) and the eslint config of its root packages (app.packages-lint)"
596
616
  rules: [HFS_TOOL_CONFIG_LOCAL]
617
+ - id: app.packages-lint
618
+ since: 3.17.0
619
+ profiles: [app]
620
+ # The one eslint config at the app root: `starci app sync` renders it when the app has root workspace packages (app.packages), and it lints their
621
+ # source by subpath (the back-end canon, the front-end canon and the Grammar family each over their own subpaths). No other tool config lives here.
622
+ path: eslint.config.mjs
623
+ presence: optional
624
+ tracked: tracked
625
+ tier: none
626
+ tests: none
627
+ rules: [HFS_MANAGED_FILE_DRIFT]
597
628
  - id: app.quality-config
598
629
  since: 3.1.0
599
630
  profiles: [app]
@@ -825,6 +856,31 @@ slots:
825
856
  rules: [HFS_PLAINTEXT_SECRET, HFS_SCRIPT_ONE_OFF, BE_SPEC_PLACEMENT, HFS_REPO_LOCAL_CHECK]
826
857
  exemplifiedBy:
827
858
  - {path: packages/hfs/src/hfs-slot-ownership.spec.mjs, editions: [lite, full]}
859
+ - id: app.packages
860
+ since: 3.17.0
861
+ profiles: [app]
862
+ editionWhy: Lite and full share the slot; a product's agent SDK and its agent modules are workspace packages in both.
863
+ # A workspace package of the app ROOT (packages/agent-sdk, packages/module-<name>): first-party source that both sides import through its
864
+ # package entry points and never past them (ARCH_INTERNAL_IMPORT_OUTSIDE), linted by the root eslint config by subpath.
865
+ path: "packages/{agent-sdk,module-<name>}/"
866
+ presence: optional
867
+ tracked: tracked
868
+ tier: none
869
+ requires: [package.json, tsconfig.json, src/index.ts]
870
+ tests: unit-beside
871
+ rules: [HFS_UNUSED_EXPORT]
872
+ - id: app.module-registry
873
+ since: 3.17.0
874
+ profiles: [app]
875
+ editionWhy: Lite and full share the slot; the registry lists the module packages of the app.
876
+ path: packages/modules/
877
+ presence: optional
878
+ tracked: tracked
879
+ tier: none
880
+ requires: [package.json, src/index.ts]
881
+ allows: [package.json, tsconfig.json, tsconfig.build.json, src/index.ts, src/template/index.ts, src/manifest/index.ts]
882
+ tests: none
883
+ rules: [HFS_MANAGED_FILE_DRIFT]
828
884
  - id: app.sides
829
885
  since: 3.1.0
830
886
  profiles: [app]
@@ -1978,40 +2034,110 @@ slots:
1978
2034
  editions: [lite]
1979
2035
  exemplifiedBy:
1980
2036
  - 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).
2037
+ # The glue of @starci/auth, the lite sign-in package (Google OAuth with state and PKCE, email and password, EdDSA access tokens with
2038
+ # their JWKS, rotating refresh sessions): the one importer of the package (ruleParams.be.infraOwners), which owns the identity
2039
+ # libraries (@nestjs/passport, passport, passport-google-oauth20, passport-local, @nestjs/jwt, jose, bcryptjs) that no app imports.
2040
+ # It parses the typed options, builds the verifier and names the injectors; domain/identity verifies a token through the kit and
2041
+ # builds the principal (contexts/code/be/api-auth.md).
1985
2042
  path: "src/modules/integrations/passport/"
1986
2043
  presence: required
1987
2044
  tracked: tracked
1988
2045
  tier: integrations
1989
2046
  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
2047
+ 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
2048
+ allows: [index.ts, passport.config.ts, passport.options.ts, passport.decorators.ts, passport.kit.ts, passport.registration.ts, errors/]
2049
+ logic: [passport.kit.ts] # the verifier mapping over the package: measured at 100 per file
1993
2050
  tests: unit-beside
1994
2051
  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
2052
  coverage: required
1996
2053
  since: 3.9.0
2054
+ - id: be.identity.sign-in
2055
+ since: 3.16.0
2056
+ profiles: [be]
2057
+ editions: [lite]
2058
+ 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."
2059
+ # The identity capability's sign-in glue over @starci/auth: the entities of the session, attempt, refresh-token and email-token tables, the account doors over auth.users and auth.identities, 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.
2060
+ 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/identity-email.log-events.ts,src/modules/domain/identity/identity-email.service.spec.ts,src/modules/domain/identity/identity-email.service.ts,src/modules/domain/identity/identity-sign-in.log-events.ts,src/modules/domain/identity/persistence/account-doors.port.ts,src/modules/domain/identity/persistence/entities/identity-attempt.entity.ts,src/modules/domain/identity/persistence/entities/identity-email-token.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}"
2061
+ presence: optional
2062
+ tracked: tracked
2063
+ tier: inherit
2064
+ tests: unit-beside
2065
+ coverage: none
2066
+ managedBy: auth-lite
2067
+ managedOnly: true # lists files sync renders; the slot owning the path judges them
2068
+ rules: [HFS_MANAGED_FILE_DRIFT]
2069
+ - id: be.feature.auth
2070
+ since: 3.16.0
2071
+ profiles: [be]
2072
+ editions: [lite]
2073
+ 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."
2074
+ # 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.
2075
+ path: "{src/features/api/auth/application/auth.contracts.ts,src/features/api/auth/application/confirm.command.ts,src/features/api/auth/application/confirm.handler.ts,src/features/api/auth/application/forgot.command.ts,src/features/api/auth/application/forgot.handler.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/resend.command.ts,src/features/api/auth/application/resend.handler.ts,src/features/api/auth/application/reset.command.ts,src/features/api/auth/application/reset.handler.ts,src/features/api/auth/application/session.command.ts,src/features/api/auth/application/session.handler.ts,src/features/api/auth/application/signup.command.ts,src/features/api/auth/application/signup.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/forgot.request.ts,src/features/api/auth/transport/http/dto/google-start.request.ts,src/features/api/auth/transport/http/dto/login.request.ts,src/features/api/auth/transport/http/dto/resend.request.ts,src/features/api/auth/transport/http/dto/reset.request.ts,src/features/api/auth/transport/http/dto/signup.request.ts,src/features/api/auth/transport/http/dto/token.request.ts}"
2076
+ presence: optional
2077
+ tracked: tracked
2078
+ tier: inherit
2079
+ tests: none
2080
+ coverage: none
2081
+ managedBy: auth-lite
2082
+ managedOnly: true # lists files sync renders; the slot owning the path judges them
2083
+ rules: [HFS_MANAGED_FILE_DRIFT]
2084
+ - id: be.integrations.mail
2085
+ profiles: [be]
2086
+ editions: [lite]
2087
+ exemplifiedBy:
2088
+ - packages/hfs/templates/be/skeleton-lite/src/modules/integrations/mail/
2089
+ # The glue of @starci/mail, the owner of the SMTP client (nodemailer): this folder parses the settings (the server, the sender and the
2090
+ # link lifetimes of the confirmation and reset mails), registers the module and names the injectors; no app file imports nodemailer,
2091
+ # and no other module imports the package. The words and layout of each mail belong to the domain that sends it.
2092
+ path: "src/modules/integrations/mail/"
2093
+ presence: required
2094
+ tracked: tracked
2095
+ tier: integrations
2096
+ owner: true
2097
+ requires: [index.ts, mail.config.ts, mail.options.ts, mail.decorators.ts, mail.module-definition.ts, mail.module.ts]
2098
+ allows: [index.ts, mail.config.ts, mail.options.ts, mail.decorators.ts, mail.module-definition.ts, mail.module.ts, errors/]
2099
+ tests: unit-beside
2100
+ rules: [BE_TIER_DIRECTION, BE_ERROR_HOME, BE_SECRET_DEFAULT, BE_INFRA_OWNER]
2101
+ coverage: required
2102
+ since: 5.3.0
1997
2103
  - id: be.integrations.object-storage
1998
2104
  profiles: [be]
1999
2105
  exemplifiedBy:
2000
2106
  - 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.
2107
+ # The glue of @starci/object-storage, the owner of the S3 client (@aws-sdk/client-s3 and @aws-sdk/s3-request-presigner) over
2108
+ # S3-compatible storage (MinIO in lite): this folder keeps the bucket, parses the settings and registers the module; no app
2109
+ # file imports an S3 SDK or minio, and no other module imports the package.
2003
2110
  path: "src/modules/integrations/object-storage/"
2004
2111
  presence: optional
2005
2112
  litePresence: required
2006
2113
  tracked: tracked
2007
2114
  tier: integrations
2008
2115
  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/]
2116
+ requires: [index.ts, object-storage.config.ts, object-storage.options.ts, object-storage.decorators.ts, object-storage.module-definition.ts, object-storage.module.ts]
2117
+ 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
2118
  tests: unit-beside
2012
2119
  rules: [BE_TIER_DIRECTION, BE_ERROR_HOME, BE_SECRET_DEFAULT, BE_INFRA_OWNER, BE_STORAGE_OWNER]
2013
2120
  coverage: required
2014
2121
  since: 3.9.0
2122
+ - id: be.integrations.keycloak
2123
+ profiles: [be]
2124
+ editions: [full]
2125
+ # The glue of @starci/auth-oidc, the OIDC client of the full edition's identity provider (Keycloak): discovery, the provider's JWKS,
2126
+ # algorithm-pinned token checks and the authorization code flow with PKCE and nonce behind the PrincipalVerifier of @starci/auth.
2127
+ # This folder parses the typed options, hands the package the app's bounded HTTP client and clock, and names the injectors;
2128
+ # no app file imports jose, and no other module imports the package (ruleParams.be.infraOwners).
2129
+ path: "src/modules/integrations/keycloak/"
2130
+ presence: optional
2131
+ tracked: tracked
2132
+ tier: integrations
2133
+ owner: true
2134
+ requires: [index.ts, keycloak.config.ts, keycloak.options.ts, keycloak.decorators.ts, keycloak.registration.ts]
2135
+ allows: [index.ts, keycloak.config.ts, keycloak.options.ts, keycloak.decorators.ts, keycloak.registration.ts, errors/, messages/]
2136
+ tests: unit-beside
2137
+ rules: [BE_TIER_DIRECTION, BE_ERROR_HOME, BE_SECRET_DEFAULT, BE_INFRA_OWNER, BE_AUTH_PASSPORT_OWNER, BE_INTEGRATION_SPEC_MISSING]
2138
+ coverage: required
2139
+ since: 3.17.0
2140
+
2015
2141
 
2016
2142
  # ----- BE: tests (owner test layout 2026-09-30). Unit specs are <name>.service.spec.ts beside their service and nothing else; everything else
2017
2143
  # lives under src/tests/, one folder per kind, and the folder and the file suffix always agree (a file whose suffix does
@@ -2485,9 +2611,9 @@ slots:
2485
2611
  presence: required
2486
2612
  tracked: tracked
2487
2613
  tier: foundation
2488
- # The app's routing, request config and catalogs, or its adapter to the shared i18n factory. A single app
2489
- # owns createNavigation in fe.modules.routes, keeping this public entry safe for its proxy. Shared stacks
2490
- # belong to fe.package.i18n and expose a routing-only proxy entry separately from navigation.
2614
+ # The app's description of its languages (defineI18n of @starci/next-i18n), its request config and catalogs, or its adapter to the
2615
+ # shared i18n workspace package. A single app builds its navigation (createI18nNavigation) in fe.modules.routes, keeping this
2616
+ # public entry safe for its proxy. A description shared by several apps belongs to fe.package.i18n.
2491
2617
  requires: [index.ts]
2492
2618
  tests: none
2493
2619
  rules: [FE_I18N_PLACEMENT, FE_I18N_CATALOG]
@@ -2541,7 +2667,7 @@ slots:
2541
2667
  profiles: [fe]
2542
2668
  # The identity-provider client (fe-stack auth, FE-AUTH): the session, the access token the Apollo link attaches and the
2543
2669
  # 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).
2670
+ # 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
2671
  path: "apps/<app>/src/modules/auth/"
2546
2672
  presence: optional
2547
2673
  tracked: tracked
@@ -2551,6 +2677,20 @@ slots:
2551
2677
  tests: none
2552
2678
  since: 3.0.0
2553
2679
  rules: [FE_STACK_FORBIDDEN]
2680
+ - id: fe.modules.auth.client
2681
+ since: 3.16.0
2682
+ profiles: [fe]
2683
+ editions: [lite]
2684
+ 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."
2685
+ # The AuthClient every edition shares, implemented by one @starci/auth/client instance over the app's own back-end auth doors.
2686
+ path: "apps/web/src/modules/auth/{client.ts,email-doors.ts,index.ts}"
2687
+ presence: optional
2688
+ tracked: tracked
2689
+ tier: inherit
2690
+ tests: none
2691
+ managedBy: auth-lite
2692
+ managedOnly: true # lists files sync renders; the slot owning the path judges them
2693
+ rules: [HFS_MANAGED_FILE_DRIFT]
2554
2694
  - id: fe.modules.toast
2555
2695
  profiles: [fe]
2556
2696
  # Mutation feedback (fe-stack toast, FE-TOAST): the HeroUI toast wrapper, showGraphQLToast over a GraphQLResponse and the
@@ -2625,7 +2765,7 @@ slots:
2625
2765
  owner: true
2626
2766
  requires: [package.json, src/index.ts, tsconfig.json]
2627
2767
  tests: none
2628
- why: the next-intl stack (routing, navigation, request config) written once, exported as the createAppI18n factory every app calls
2768
+ why: the product's languages (defineI18n of @starci/next-i18n) written once and composed into the createAppI18n factory every app calls; the next-intl stack itself is the package's
2629
2769
  rules: [FE_I18N_PLACEMENT, FE_PACKAGE_SHAPE, HFS_UNUSED_EXPORT]
2630
2770
 
2631
2771
  # Checks that read this manifest (all ship from .claude; none keeps its own path list)
@@ -3,7 +3,8 @@ import path from 'node:path';
3
3
  import { slash } from '../../lib/path-key.mjs';
4
4
  import { readJsonFile as readJson } from '../../lib/json.mjs';
5
5
  import { isInside } from '../../lib/walk.mjs';
6
- import { openHfs } from '../slots.mjs';
6
+ import { createSlotResolver, openHfs, readRepoDeclaration } from '../slots.mjs';
7
+ import { ROOT_PACKAGE_SLOTS, rootPackageRecord, rootWorkspaceDirectories } from './root-packages.mjs';
7
8
  import { byCodeUnit } from '../../lib/list.mjs';
8
9
  import { grammarContractFor } from '../../lib/grammar-lint.mjs';
9
10
  /** A file's identity: its resolved real path, or the resolved path when it does not exist. */
@@ -182,6 +183,28 @@ function workspaceDirectories(root, { packageRoot: appPackageRoot = root, side =
182
183
  }
183
184
  return [...directories].sort(byCodeUnit);
184
185
  }
186
+ /**
187
+ * The workspace packages of the app root that no side owns: the `workspaces` patterns of the app's one package.json that do not start
188
+ * with a side folder (`packages/*`), and the directories the slots `app.packages` and `app.module-registry` place under `packages/`
189
+ * even when the manifest forgot to list them. A side imports them as first-party packages (through their entry points), never as
190
+ * "outside the side". A side of the app is judged here; the app root itself already counts them among its workspaces.
191
+ */
192
+ function rootPackageRecords(root, packageRoot, side, opened) {
193
+ if (side === null)
194
+ return [];
195
+ const candidates = new Set(rootWorkspaceDirectories(packageRoot));
196
+ if (opened.manifest && existingDirectory(packageRoot, 'packages')) {
197
+ const resolver = createSlotResolver(opened.manifest, readRepoDeclaration(opened.manifest, packageRoot));
198
+ const container = path.join(packageRoot, 'packages');
199
+ for (const entry of fs.readdirSync(container, { withFileTypes: true }).filter(item => item.isDirectory())) {
200
+ const slot = resolver.classifyPath(`packages/${entry.name}`).slot;
201
+ if (slot !== undefined && ROOT_PACKAGE_SLOTS.has(slot))
202
+ candidates.add(path.join(container, entry.name));
203
+ }
204
+ }
205
+ return [...candidates].sort(byCodeUnit).filter(candidate => !isInside(root, candidate))
206
+ .flatMap(candidate => rootPackageRecord(packageRoot, candidate, canonical) ?? []);
207
+ }
185
208
  function discoveredProjects(root, workspaces) {
186
209
  const projects = [];
187
210
  if (fs.existsSync(path.join(root, 'tsconfig.json')))
@@ -373,6 +396,7 @@ export function loadArchitectureConfig(repositoryRoot, { hfs } = {}) {
373
396
  kinds,
374
397
  projects,
375
398
  workspaces,
399
+ rootPackages: rootPackageRecords(root, packageRoot, side, opened),
376
400
  apps: apps.map(app => ({ name: app.name, kind: app.kind })),
377
401
  hfs: opened,
378
402
  owners: derivedOwners(root, opened),
@@ -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) {
@@ -11,7 +11,7 @@ import { trimTrailingSlashes } from '../trailing-slashes.mjs';
11
11
  *
12
12
  * - a `*.module.ts` file below a transport folder other than `<f>-<protocol>.module.ts`, a `*.module-definition.ts` that is
13
13
  * not the sibling of the application module or of the transport module of its own folder, and an `@Module` class (or a
14
- * `ConfigurableModuleBuilder`/`ConfigurableModuleClass` use) in a feature file that is neither the application module, the
14
+ * `ConfigurableModuleBuilder`/`ConfigurableModuleClass` use or a `defineConfigurableModule`/`defineCapabilityModule` call of `@starci/nest-kit`) in a feature file that is neither the application module, the
15
15
  * transport module of its own folder nor that module's definition are refused;
16
16
  * - apps import only transport modules, of the kinds their app kind allows: the `composedBy` list of each transport slot
17
17
  * in knowledge/hfs/slots.yaml (api: graphql, http, websocket; worker: schedule, message). An app root (app.module.ts
@@ -99,6 +99,8 @@ function reportModuleClassLocation(file, name, place, composedModuleOf, report)
99
99
  if (file.rel !== own)
100
100
  report(file, name, `${name.text} is a Nest module declared in ${file.rel}; a feature declares exactly its application module (${place.feature}.module.ts) and one module per transport folder (${place.feature}-<protocol>.module.ts), never a module per operation.`, { feature: place.feature });
101
101
  }
102
+ /** The module-definition helpers of @starci/nest-kit: each builds the definition of one module, like `ConfigurableModuleBuilder`. */
103
+ const DEFINITION_HELPERS = ['defineConfigurableModule', 'defineCapabilityModule'];
102
104
  function reportConfigurableModuleUses(file, checker, kit, ts, place, env) {
103
105
  const own = ownModuleOf(place, file.rel, env.composedModuleOf);
104
106
  const isDefinition = file.rel === definitionOf(own);
@@ -106,6 +108,9 @@ function reportConfigurableModuleUses(file, checker, kit, ts, place, env) {
106
108
  if (ts.isNewExpression(node) && kit.isImportOf(checker, node.expression, 'ConfigurableModuleBuilder', '@nestjs/common') && !isDefinition) {
107
109
  env.report(file, node, `ConfigurableModuleBuilder builds the module definition of one module; in feature ${place.feature} it is written only in ${path.posix.basename(definitionOf(own))}, beside ${path.posix.basename(own)}.`, { feature: place.feature });
108
110
  }
111
+ else if (ts.isCallExpression(node) && !isDefinition && DEFINITION_HELPERS.some(name => kit.isImportOf(checker, node.expression, name, '@starci/nest-kit'))) {
112
+ env.report(file, node, `${node.expression.getText(file.sourceFile)} builds the module definition of one module; in feature ${place.feature} it is written only in ${path.posix.basename(definitionOf(own))}, beside ${path.posix.basename(own)}.`, { feature: place.feature });
113
+ }
109
114
  else if (ts.isHeritageClause(node) && file.rel !== own) {
110
115
  for (const type of node.types)
111
116
  if (kit.isImportOf(checker, type.expression, 'ConfigurableModuleClass', '@nestjs/common')) {
@@ -0,0 +1,78 @@
1
+ // root-packages.mjs - the workspace packages of an app ROOT (packages/agent-sdk, packages/module-<name>, the managed packages/modules).
2
+ // They lie outside both side folders and belong to no side; both sides import them by package name, through their package entry points
3
+ // (the `exports` of the manifest), so the import graph reads them as first-party packages and the back-end canon never reads them as
4
+ // a third-party library. The app root's one package.json lists them in `workspaces`; the patterns that start with a side folder
5
+ // (`fe/apps/*`) are that side's own workspaces and are not read here.
6
+ import fs from 'node:fs';
7
+ import path from 'node:path';
8
+ import { readJsonFile as readJson } from '../../lib/json.mjs';
9
+ import { byCodeUnit } from '../../lib/list.mjs';
10
+ import { isInside } from '../../lib/walk.mjs';
11
+ import { slash } from '../../lib/path-key.mjs';
12
+ /** The slots whose directories at the app root are first-party packages of the app (agent SDK, module packages, the managed registry). */
13
+ export const ROOT_PACKAGE_SLOTS = new Set(['app.packages', 'app.module-registry']);
14
+ const SIDE_PREFIX = /^(?:be|fe)\//;
15
+ /** A workspace pattern this reader expands (a literal path, or `*` as a whole segment); the others are judged by the workspace rules. */
16
+ const expandablePattern = (written) => !path.isAbsolute(written) && written.split('/').every(segment => segment !== '..' && (!segment.includes('*') || segment === '*'));
17
+ function expandSegment(base, segment) {
18
+ if (segment !== '*')
19
+ return [path.join(base, segment)];
20
+ if (!fs.existsSync(base) || !fs.lstatSync(base).isDirectory())
21
+ return [];
22
+ return fs.readdirSync(base, { withFileTypes: true }).filter(item => item.isDirectory()).sort((a, b) => byCodeUnit(a.name, b.name)).map(item => path.join(base, item.name));
23
+ }
24
+ /** A package folder with a regular package.json (a link is not one). */
25
+ export function packageDirectory(absolute) {
26
+ try {
27
+ if (!fs.lstatSync(absolute).isDirectory())
28
+ return false;
29
+ const manifest = fs.lstatSync(path.join(absolute, 'package.json'));
30
+ return manifest.isFile() && !manifest.isSymbolicLink();
31
+ }
32
+ catch {
33
+ return false;
34
+ }
35
+ }
36
+ /** The folders the `workspaces` of the app root's package.json name that no side owns, as absolute paths in code-unit order. */
37
+ export function rootWorkspaceDirectories(packageRoot) {
38
+ const manifest = readJson(path.join(packageRoot, 'package.json'));
39
+ const declared = manifest?.workspaces;
40
+ const patterns = Array.isArray(declared) ? declared : declared?.packages;
41
+ const found = new Set();
42
+ for (const pattern of Array.isArray(patterns) ? patterns : []) {
43
+ if (typeof pattern !== 'string' || !pattern.trim())
44
+ continue;
45
+ const written = slash(pattern.trim()).replace(/^\.\//, '');
46
+ if (SIDE_PREFIX.test(written) || !expandablePattern(written))
47
+ continue;
48
+ let bases = [packageRoot];
49
+ for (const segment of written.split('/'))
50
+ bases = bases.flatMap(base => expandSegment(base, segment));
51
+ for (const base of bases)
52
+ found.add(path.resolve(base));
53
+ }
54
+ return [...found].sort(byCodeUnit);
55
+ }
56
+ /**
57
+ * The record of one package folder of the app root, or null when it is no named package inside the app root.
58
+ * `canonical` is the file-identity function of the caller (the real path), so a record agrees with the files the graph reads.
59
+ */
60
+ export function rootPackageRecord(packageRoot, directory, canonical) {
61
+ if (!packageDirectory(directory) || !isInside(packageRoot, directory))
62
+ return null;
63
+ const manifest = readJson(path.join(directory, 'package.json'));
64
+ const name = manifest?.['name'];
65
+ if (manifest === null || typeof name !== 'string' || !name)
66
+ return null;
67
+ return { root: canonical(directory), relative: slash(path.relative(packageRoot, directory)), name, exports: manifest['exports'], manifest, workspace: true, app: false };
68
+ }
69
+ /** The names of the workspace packages of the app root: what the back-end canon must not read as third-party libraries. */
70
+ export function rootPackageNames(packageRoot) {
71
+ const names = new Set();
72
+ for (const directory of rootWorkspaceDirectories(packageRoot)) {
73
+ const record = rootPackageRecord(packageRoot, directory, (file) => file);
74
+ if (record !== null)
75
+ names.add(record.name);
76
+ }
77
+ return names;
78
+ }
@@ -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
  }