@starci/eslint-canon-be 3.8.14 → 3.8.16

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.8.16 - 2026-10-30
4
+
5
+ - Added: a `compose/<area>.ts` group may carry its area's catalogs: a typed list of error-kind tables (every value `platform/errors`' `ErrorKind`) or of `platform/i18n` `MessageBundle`s, which `compose/platform.ts` spreads into `ErrorsModule` and `I18nModule` (`app-composition-typed`, R265 `BE_COMPOSITION_UNTYPED`), so a large app keeps each compose file within its budget. An untyped catalog list, or a list of anything else, is still refused. Spec: `src/app-composition.spec.ts` (typed fixture `MessageBundle`).
6
+ - Fixed: `persisting-builder-in-builders-slot` no longer judges a raw INSERT (`.query(`) in the test world (`be.tests.world`, `be.tests.world.kit`) into a table NO entity of the program maps (`storage.objects`, a pgmq queue, a policy table) as a builder: it is a named probe of what entities cannot express, which `no-raw-sql` admits only in the test world and refuses in the builders slot. A raw INSERT into a mapped table, an entity write (`save`, `insert`, `upsert`), and any write outside the world are still builders. Specs: `src/builders.spec.ts`, `src/persisting-builder-home-coverage.spec.ts`.
7
+ - Fixed: `event-consumer-shape` names a consumer file after its event with dots AND underscores as dashes (`installation_changed` -> `installation-changed.consumer.ts`), the kebab case `source-suffix` requires of every file; the two rules could not both pass for an underscored event name. Spec: an underscored event in `src/event-bus.spec.ts` (typed fixture `InstallationChangedEvent`).
8
+ - Fixed: `jobs-scheduler-owner` requires the tick claim as `callDbFunction(tx, "public.job_tick_claim", ...)`, the schema-qualified name `no-raw-sql` lists and the hfs jobs template calls; the bare `"job_tick_claim"` could not pass both rules.
9
+ - Changed: the bundled canon pins name ai-router 0.4.0 (mounted keys), hfs 4.11.17, eslint-canon-be 3.8.16, eslint-canon-fe 9.5.18 and the Grammar family 0.15.29. No rule changed.
10
+
11
+ ## 3.8.15 - 2026-10-30
12
+
13
+ - Changed: R260 `jwt-alg-pinned` (`BE_JWT_ALG_PINNED`) admits a non-Supabase OIDC verifier such as the Keycloak client of full: every `jose` `jwtVerify` still pins a non-empty literal subset of ES256, RS256 and EdDSA and derives its issuer from typed configuration, and the principal is now bound either by an `audience` that derives from typed configuration (traced like the issuer: a `*Options`/`*Config`/`*Env` parameter or property, a configuration file, a local variable or a string transformation of one) or, where the audience is the issuer-wide literal (Supabase-style `authenticated`), by rejecting every role other than authenticated before the principal is returned, as before. A verifier with neither is refused naming both. The lite Passport verifier (own ES256 tokens, configured audience) passes on its audience. Shared in `runtime/scripts/hfs/architecture/jwt-ast.mjs` (`fromConfig`, formerly `issuerFromConfig`); the bundled `rules.yaml` states the law. Specs: `src/jwt-alg.spec.ts` (role-free OIDC verifiers with a configured client id, audience list, aliased or namespace `jwtVerify` admitted; a literal, `authenticated`, missing or untyped audience, a literal issuer and insecure algorithms refused; the Passport-shaped verifier with a configured audience admitted; every Supabase-style guard case unchanged).
14
+ - Proven: R25 (`dead-exports`) counts a unit service spec and a logic client spec that import a public injection token through a `@modules` alias (`KEYCLOAK` of `integrations/keycloak`, `HTTP_CLIENT` of `platform/http`) as consumers of that entry. Spec: `src/hfs-unused-export.spec.ts`. No rule changed.
15
+ - Changed: the bundled canon pins name hfs 4.11.16, eslint-canon-be 3.8.15, eslint-canon-fe 9.5.17, the Grammar family 0.15.28 and test-world 1.3.2.
16
+
3
17
  ## 3.8.14 - 2026-10-29
4
18
 
5
19
  - Changed: `inbox-dedupe-required` (R80) and `webhook-inbox-key` (R263) accept `claimRow(source, eventId, tx, receipt)` on the `EntityInbox` port of `platform/inbox` (and `claim` on an `EntityInbox`-typed receiver) as a delivery method's first await, with the same guarantees as `claim`: the real port by its owner (a lookalike is refused), the first await (R263: the first statement, keyed by the delivery id, with the transaction callback's own manager), and the return on a repeat, which for `claimRow` is the receipt id answering `undefined` (`!receiptId` or `receiptId === undefined`, inline or stored and tested straight after). A stored answer is compared by binding in either operand. The R263 receipt-port check also admits an `EntityInbox` constructor parameter. Shared in `lib/ports.ts` (`isInboxPortType`, `inboxClaimOf`, `refusesRepeat`); the typed fixture's inbox port declares `EntityInbox`. Specs: `r80-inbox-dedupe-required.spec.ts` and `webhook-handoff-inbox.spec.ts` (valid claimRow intakes; claimRow not first, on a lookalike, keyed by a constant, with another manager, with too few arguments, without the return, or returning on `false`, refused). The bundled `rules.yaml` states both laws with `claimRow`.
@@ -227,7 +227,27 @@ const compositionTypes = (checker) => {
227
227
  const parts = element.isUnion() ? element.types : [element];
228
228
  return parts.every((part) => contains(part, true));
229
229
  };
230
- return { arrayElement, contains, typedList };
230
+ /** Whether a type is declared under the app's `platform/<area>` capability folder. */
231
+ const declaredIn = (symbol, area) => symbol?.getDeclarations()?.some((declaration) => normalizePath(declaration.getSourceFile().fileName).includes(`/modules/platform/${area}/`)) ?? false;
232
+ /** A message bundle of `platform/i18n`, or a table of error kinds: every value (property or index) is `platform/errors`' ErrorKind. */
233
+ const catalogEntry = (type) => {
234
+ if (declaredIn(type.getSymbol(), "i18n") && type.getSymbol()?.name === "MessageBundle")
235
+ return true;
236
+ if (!(type.flags & ts.TypeFlags.Object))
237
+ return false;
238
+ const kind = (value) => value?.aliasSymbol?.name === "ErrorKind" && declaredIn(value.aliasSymbol, "errors");
239
+ const values = [...type.getProperties().map((property) => propertyType(type, property.name)), ...checker.getIndexInfosOfType(type).map((index) => index.type)];
240
+ return values.length > 0 && values.every(kind);
241
+ };
242
+ /** A typed list of catalogs: message bundles or error-kind tables, the catalogs `platform.ts` hands I18nModule and ErrorsModule. */
243
+ const catalogList = (type) => {
244
+ const element = arrayElement(type);
245
+ if (!element || element.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown))
246
+ return false;
247
+ const parts = element.isUnion() ? element.types : [element];
248
+ return parts.every(catalogEntry);
249
+ };
250
+ return { arrayElement, contains, typedList, catalogList };
231
251
  };
232
252
  /** R265: app values compose only in typed groups, never in env/options/bootstrap lists. */
233
253
  export const appCompositionTyped = {
@@ -250,7 +270,7 @@ export const appCompositionTyped = {
250
270
  if (!typedRoles.includes(role))
251
271
  return {};
252
272
  const { checker, toTs } = typed(context);
253
- const { arrayElement, contains, typedList } = compositionTypes(checker);
273
+ const { arrayElement, contains, typedList, catalogList } = compositionTypes(checker);
254
274
  const reported = new WeakSet();
255
275
  const hasReport = (node) => {
256
276
  for (let ancestor = node; ancestor; ancestor = ancestor.parent)
@@ -298,7 +318,9 @@ export const appCompositionTyped = {
298
318
  report(node, "business");
299
319
  return;
300
320
  }
301
- if (!annotation || !typedList(result))
321
+ // A group composes modules, providers, queues or schedules, or carries an area's catalogs (error kinds, message bundles) that
322
+ // platform.ts spreads into ErrorsModule and I18nModule, so a large app keeps each compose file within its budget.
323
+ if (!annotation || !(typedList(result) || catalogList(result)))
302
324
  report(node, "group");
303
325
  };
304
326
  const annotationOf = (node) => {
package/dist/builders.js CHANGED
@@ -121,6 +121,49 @@ const BUILDERS = "be.tests.fixtures.builders";
121
121
  /** The spec slots of the test tree; a spec is judged by the spec rules, not as a builder. */
122
122
  const SPEC_SLOTS = new Set(["be.tests.integration", "be.tests.e2e", "be.tests.contract"]);
123
123
  const CREATING_METHODS = new Set(["save", "insert", "upsert"]);
124
+ /** The test world slots: the one test owner of raw SQL (no-raw-sql), for what entities cannot express (an RLS probe, a pgmq queue). */
125
+ const WORLD_SLOTS = new Set(["be.tests.world", "be.tests.world.kit"]);
126
+ /** The table a raw INSERT writes: `INSERT INTO [schema.]table`, quotes dropped, schema default `public`. */
127
+ const INSERT_TARGET = /\binsert\s+into\s+("?[\w$]+"?)(?:\s*\.\s*("?[\w$]+"?))?/iu;
128
+ const unquote = (name) => name.replace(/^"|"$/gu, "").toLowerCase();
129
+ const insertTarget = (sql) => {
130
+ const match = INSERT_TARGET.exec(sql);
131
+ if (!match?.[1])
132
+ return null;
133
+ return match[2] ? `${unquote(match[1])}.${unquote(match[2])}` : `public.${unquote(match[1])}`;
134
+ };
135
+ /** The tables the program's entities map, as `schema.table` (from `@Entity("t")` or `@Entity({ name, schema })`), cached per program. */
136
+ const entityTablesByProgram = new WeakMap();
137
+ const entityTables = (program, checker) => {
138
+ const cached = entityTablesByProgram.get(program);
139
+ if (cached)
140
+ return cached;
141
+ const tables = new Set();
142
+ const literal = (node) => (node && ts.isStringLiteralLike(node) ? node.text.toLowerCase() : null);
143
+ const visit = (node) => {
144
+ if (isEntityClass(checker, node)) {
145
+ for (const decorator of ts.getDecorators(node) ?? []) {
146
+ if (!ts.isCallExpression(decorator.expression))
147
+ continue;
148
+ const [first] = decorator.expression.arguments;
149
+ if (literal(first))
150
+ tables.add(`public.${literal(first)}`);
151
+ else if (first && ts.isObjectLiteralExpression(first)) {
152
+ const value = (key) => literal(first.properties.find((property) => ts.isPropertyAssignment(property) && ts.isIdentifier(property.name) && property.name.text === key)?.initializer);
153
+ const name = value("name");
154
+ if (name)
155
+ tables.add(`${value("schema") ?? "public"}.${name}`);
156
+ }
157
+ }
158
+ }
159
+ ts.forEachChild(node, visit);
160
+ };
161
+ for (const file of program.getSourceFiles())
162
+ if (!file.isDeclarationFile && !file.fileName.includes("/node_modules/"))
163
+ visit(file);
164
+ entityTablesByProgram.set(program, tables);
165
+ return tables;
166
+ };
124
167
  /** A file of the test tree that is not a spec and is not the builders slot. */
125
168
  const isTestSupport = (slot) => typeof slot === "string" && slot.startsWith("be.tests.") && slot !== BUILDERS && !SPEC_SLOTS.has(slot);
126
169
  /** The top-level statement that holds a node. */
@@ -150,8 +193,20 @@ export const persistingBuilderInBuildersSlot = {
150
193
  },
151
194
  },
152
195
  create(context) {
153
- if (!isTestSupport(hfsOf(context).slotOf(context.filename || context.getFilename())))
196
+ const slot = hfsOf(context).slotOf(context.filename || context.getFilename());
197
+ if (!isTestSupport(slot))
154
198
  return {};
199
+ // A raw INSERT in the test world into a table no entity maps (storage.objects, a pgmq queue, a policy table) is a named probe of
200
+ // what entities cannot express, which no-raw-sql admits there and refuses in the builders slot. A raw INSERT into a mapped table,
201
+ // and an entity write (save, insert, upsert), still arranges data and belongs to a builder.
202
+ const inWorld = WORLD_SLOTS.has(slot ?? "");
203
+ const worldProbe = (sql) => {
204
+ if (!inWorld)
205
+ return false;
206
+ const target = insertTarget(sql);
207
+ const { program, checker } = typed(context);
208
+ return target !== null && !entityTables(program, checker).has(target);
209
+ };
155
210
  const sourceCode = context.sourceCode || context.getSourceCode();
156
211
  const writes = new Set();
157
212
  const references = new Map();
@@ -161,7 +216,8 @@ export const persistingBuilderInBuildersSlot = {
161
216
  return false;
162
217
  if (CREATING_METHODS.has(method))
163
218
  return true;
164
- return method === "query" && INSERTING_SQL.test(queryText(node.arguments[0], sourceCode.getScope(node)) ?? "");
219
+ const sql = queryText(node.arguments[0], sourceCode.getScope(node)) ?? "";
220
+ return method === "query" && INSERTING_SQL.test(sql) && !worldProbe(sql);
165
221
  };
166
222
  return {
167
223
  CallExpression(node) {
package/dist/event-bus.js CHANGED
@@ -129,8 +129,8 @@ const eventNameOf = (context, expression) => {
129
129
  };
130
130
  /** True when the node is a `.eventId` member read on a value typed as the `EventDelivery` of `platform/event-bus`. */
131
131
  const readsDeliveryEventId = (context, node) => node.type === "MemberExpression" && !node.computed && node.property.type === "Identifier" && node.property.name === "eventId" && isEventDeliveryType(context, node.object);
132
- /** The kebab stem of an event name: dots become dashes. */
133
- const stemOfEvent = (name) => name.split(".").join("-");
132
+ /** The kebab stem of an event name: dots and underscores become dashes, as source-suffix names every file in kebab case. */
133
+ const stemOfEvent = (name) => name.replaceAll(/[._]/gu, "-");
134
134
  /** A message consumer is the one door of an event: placed in `transport/message`, named after its event, and it forwards the event id. */
135
135
  export const eventConsumerShape = {
136
136
  meta: {
@@ -141,7 +141,7 @@ export const eventConsumerShape = {
141
141
  placement: "`{{name}}` implements `EventConsumer` outside a `.consumer.ts` file of the message transport (`transport/message/<event>.consumer.ts`). A consumer is a transport door: move it there.",
142
142
  notConsumer: "This `.consumer.ts` file declares `{{name}}`, which does not implement `EventConsumer` of `platform/event-bus`. The message transport holds only event consumers.",
143
143
  eventUnknown: "`{{name}}.event` must be an event class whose static `eventName` is a string literal (`static readonly eventName = \"order.placed\"`), so the consumer and its contract entry are one name.",
144
- stem: "The consumer of `{{event}}` is `{{expected}}.consumer.ts`, but this file is `{{actual}}.consumer.ts`. A consumer is named after the event it handles (dots become dashes).",
144
+ stem: "The consumer of `{{event}}` is `{{expected}}.consumer.ts`, but this file is `{{actual}}.consumer.ts`. A consumer is named after the event it handles (dots and underscores become dashes).",
145
145
  noEventId: "`{{name}}.handle` never reads `delivery.eventId`. Delivery is at least once: pass the event id to the command so the domain service claims it in `platform/inbox` inside its own transaction and a redelivery is a no-op.",
146
146
  },
147
147
  },
@@ -6,7 +6,7 @@
6
6
  * `platform/jobs` that hold the scheduler (`job-tick.service.ts`, its spec, and `jobs.module.ts`, which composes
7
7
  * `ScheduleModule.forRoot()`), refuses the `Cron`, `Interval` and `Timeout` decorators of `@nestjs/schedule` everywhere (a
8
8
  * decorated method fires on every replica), and refuses a `job-tick.service.ts` that does not call both `advisoryXactLock`
9
- * and `callDbFunction(..., "job_tick_claim", ...)`: the lock serialises the replicas and the minute claim lets one enqueue.
9
+ * and `callDbFunction(..., "public.job_tick_claim", ...)`: the lock serialises the replicas and the minute claim lets one enqueue.
10
10
  *
11
11
  * `infra-import-owner` (R90) holds the coarser half from the same table (`ruleParams.be.infraOwners` gives both libraries to
12
12
  * `platform/jobs`); this rule names the files and the fence.
@@ -25,8 +25,8 @@ const SCHEDULER_FILES = new Set(["job-tick.service.ts", "job-tick.service.spec.t
25
25
  const TICK_SERVICE = "job-tick.service.ts";
26
26
  /** The decorators that would fire once per replica. */
27
27
  const REPLICA_DECORATORS = new Set(["Cron", "Interval", "Timeout"]);
28
- /** The database function that claims a tick's minute. */
29
- const TICK_CLAIM = "job_tick_claim";
28
+ /** The database function that claims a tick's minute, schema-qualified as no-raw-sql lists every database function. */
29
+ const TICK_CLAIM = "public.job_tick_claim";
30
30
  /** True when a module specifier is a scheduler library or a subpath of one. */
31
31
  const isSchedulerLibrary = (specifier) => SCHEDULER_LIBRARIES.some((library) => specifier === library || specifier.startsWith(`${library}/`));
32
32
  /** Recurring work is a platform/jobs tick: the scheduler libraries stay in its files, no replica decorator, and the tick holds its fence. */
@@ -38,7 +38,7 @@ export const jobsSchedulerOwner = {
38
38
  messages: {
39
39
  owner: "`{{library}}` is imported outside the tick scheduler of platform/jobs (job-tick.service.ts, jobs.module.ts). Declare the tick in JOB_TICKS of platform/jobs/job-ticks.contracts.ts instead.",
40
40
  decorator: "`@{{name}}` of @nestjs/schedule fires once per replica. Declare the tick in JOB_TICKS of platform/jobs/job-ticks.contracts.ts; JobTickService fires it once per minute for the deployment.",
41
- fence: "JobTickService must take `advisoryXactLock(tx, \"tick:<name>\")` and claim the minute with `callDbFunction(tx, \"job_tick_claim\", ...)` before it writes the outbox, or every replica enqueues the tick.",
41
+ fence: "JobTickService must take `advisoryXactLock(tx, \"tick:<name>\")` and claim the minute with `callDbFunction(tx, \"public.job_tick_claim\", ...)` before it writes the outbox, or every replica enqueues the tick.",
42
42
  },
43
43
  },
44
44
  create(context) {
package/dist/jwt-alg.js CHANGED
@@ -1,4 +1,4 @@
1
- /** R260 BE_JWT_ALG_PINNED: remote JWT verification pins algorithms, configuration and principal role. */
1
+ /** R260 BE_JWT_ALG_PINNED: JWT verification pins algorithms and a configured issuer, and binds the principal by a configured audience or the authenticated role. */
2
2
  import ts from "typescript";
3
3
  import { typed } from "./lib/types.js";
4
4
  import { isDeclarationFile } from "./lib/path.js";
@@ -25,7 +25,7 @@ const joseVerifier = (checker, expression, seen = new Set()) => {
25
25
  export const jwtAlgPinned = {
26
26
  meta: {
27
27
  type: "problem",
28
- docs: { description: "R260 BE_JWT_ALG_PINNED: literal secure algorithms, config issuer and authenticated principal role." },
28
+ docs: { description: "R260 BE_JWT_ALG_PINNED: literal secure algorithms, config issuer, and a config audience or the authenticated principal role." },
29
29
  schema: [],
30
30
  messages: { pinned: "{{detail}}" },
31
31
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/eslint-canon-be",
3
- "version": "3.8.14",
3
+ "version": "3.8.16",
4
4
  "description": "The StarCi back-end lint canon: every rule its laws publish, gathered as one flat-config plugin.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -31,35 +31,35 @@ pins:
31
31
  source: packages/event-stream/package.json
32
32
  why: 'the one server-sent-events client of every front end (fe-stack event-stream, owner:event-stream-package): the transport client layer (modules/api/sse/clients) creates one instance for the app with the bearer token source and the stream operations follow on it; it carries Last-Event-ID resume, the capped doubling backoff, the heartbeat timeout, the single 401 renewal and the useSWRSubscription adapter, so no app keeps a hand-written reader.'
33
33
  '@starci/grammar':
34
- version: 0.15.27
34
+ version: 0.15.29
35
35
  group: starci
36
36
  install: registry
37
37
  side: fe
38
38
  source: packages/grammar/package.json
39
39
  why: 'the grammar front ends read: the brand layer sets `--font-sans` and `--font-mono` and the grammar reads them; it carries the Input tel kind, the copyable and read-only Input, the IconButton disclosure props and count badge, ChatBubble, FillViewport, Textarea mentions and Enter-to-send, the leading PrimaryRailLayout rail, the plate-less Image, ListRow, the soft Alert, Progress steps, the floating primary IconButton, FlowGraph, the STATE-8 loading views and the bordered selectable TagGroup chips. The runtime source version wins for a @starci package.'
40
40
  '@starci/eslint-canon-be':
41
- version: 3.8.14
41
+ version: 3.8.16
42
42
  group: starci
43
43
  install: registry
44
44
  side: be
45
45
  source: packages/eslint-canon-be/package.json
46
46
  why: 'the back-end ESLint canon: `loadHfs(import.meta.url)` of be/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the be side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; `starciBeConfig({ hfs: loadHfs(import.meta.url) })` is the typed factory and the BE-CONVENTION laws are its rules.'
47
47
  '@starci/eslint-canon-fe':
48
- version: 9.5.16
48
+ version: 9.5.18
49
49
  group: starci
50
50
  install: registry
51
51
  side: fe
52
52
  source: packages/eslint-canon-fe/package.json
53
53
  why: 'the front-end ESLint canon: `loadHfs(import.meta.url)` of fe/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the fe side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; the front end has no tests (FE_NO_TESTS R97 in hfs) and no-vietnamese-in-source (R91) applies.'
54
54
  '@starci/eslint-grammar-core':
55
- version: 0.15.27
55
+ version: 0.15.29
56
56
  group: starci
57
57
  install: registry
58
58
  side: fe
59
59
  source: packages/eslint-grammar-core/package.json
60
60
  why: 'the StarCi Grammar component API lint, versioned with @starci/grammar; front ends compose this family package with the universal FE canon.'
61
61
  '@starci/eslint-grammar-offset-pop':
62
- version: 0.15.27
62
+ version: 0.15.29
63
63
  group: starci
64
64
  install: registry
65
65
  side: fe
@@ -92,21 +92,21 @@ pins:
92
92
  source: packages/jest-preset/package.json
93
93
  why: 'the Jest preset of a back end: the world runner runs up to min(--maxWorkers, slots) world files at once, each in its own process bound to one data slot of the test world (STARCI_TEST_WORLD_SLOT), and reads test-world state protocol 2 only: it pairs exactly with @starci/test-world, and any other state file is JEST_PRESET_WORLD_PAIR_MISMATCH. The unit run writes the lcov Sonar and Codecov import (services only); the integration, e2e and contract projects run every spec file in a worker process of its own (world-runner.cjs), so a process-global framework registry (@nestjs/graphql type metadata) never leaks between e2e files; it ships the unit kit (mockEntityManager, fakeTransaction, fakeQueryBuilder, queueQueryBuilders, fakeIds, FakeClock, Outcome matchers) and the recordingOutbox claim side.'
94
94
  '@starci/test-world':
95
- version: 1.3.1
95
+ version: 1.3.2
96
96
  group: starci
97
97
  install: registry
98
98
  side: be
99
99
  source: packages/test-world/package.json
100
100
  why: 'the shared e2e library of every back end (R47, R48), a devDependency of every back end: the warm stack behind toxiproxy, the network-edge fakes, the Nest boot, the typed useTestWorld handle, useSandbox for contract specs and the outage lock. A fake declared https (defineHttpFake) serves TLS with the run''s ephemeral in-memory fake CA and publishes its PEM as w.fake.<name>.ca for the app''s own client to trust; verification is never turned off. Kafka is real own infra (the one digest-pinned apache/kafka KRaft image, a broker listener and proxy per slot, slot-prefixed topics, consumer groups and client ids) and Postgres is schema-per-context (a schema and a login role per context in a shared database). Each worker has its own data slot (<ns>_w<k>) with its own databases, Keycloak realm, leased Redis DB, bucket/collection/topic prefixes, fakes host, toxiproxy proxies and outage lock; a run provisions min(jest workers, workers cap, default 2) slots, and state file protocol 2 pairs exactly with @starci/jest-preset (TEST_WORLD_PAIR_MISMATCH otherwise). A modules world boots real peer apps beside its modules, world.apps.<name>.during(fn) is the outage of a peer app, w.keycloak.clientSecret(client) answers the run-generated secret of a confidential realm client, world.keycloak.events/sessions read the realm user events and live sessions, world.infra.postgresql.connection(name) takes one database connection down while the others serve, and world.resolve and scope.resolve take any Nest token. Every path a declaration names (`stack`, seeds, the realm, Dockerfiles) resolves from the app root (the directory of hfs.json); the globalSetup registers the path aliases as TypeScript resolves them. Its CLI main is exported at ./cli for starci app stack.'
101
101
  '@starci/ai-router':
102
- version: 0.3.0
102
+ version: 0.4.0
103
103
  group: starci
104
104
  install: registry
105
105
  side: be
106
106
  source: packages/ai-router/package.json
107
107
  why: 'the AI pool router of a back end: a NestJS module that routes OpenAI-compatible chat, stream and embeddings calls across keys, models and providers, with @starci/ai-router/testing for its specs; @starci/jest-preset compiles it as an ESM-only dependency.'
108
108
  '@starci/hfs':
109
- version: 4.11.15
109
+ version: 4.11.17
110
110
  group: starci
111
111
  install: registry
112
112
  side: both
@@ -4346,7 +4346,7 @@ rules:
4346
4346
  - {path: packages/hfs/src/hfs-database-config.spec.mjs, editions: [lite], codes: [DB_EXTENSION_ALLOWED, DB_MIGRATION_DESTRUCTIVE, HFS_SEED_PII, DB_VAULT_WRITE]}
4347
4347
  - id: R260
4348
4348
  code: "BE_JWT_ALG_PINNED"
4349
- law: "A back-end JWT verifier pins a nonempty literal subset of ES256, RS256 and EdDSA and obtains its issuer from configuration. A principal is built only after verification and rejection of every role other than authenticated, in lite and full."
4349
+ law: "Every back-end JWT verifier pins a nonempty literal subset of ES256, RS256 and EdDSA and obtains its issuer from typed configuration. A principal is built only after verification and is bound either by an audience read from typed configuration (an OIDC verifier such as the Keycloak of full, or the app's own Passport access tokens of lite) or, where every token of the issuer shares one audience (Supabase-style), by rejecting every role other than authenticated first, in lite and full."
4350
4350
  kinds: [check, lint]
4351
4351
  gates: ["pre-commit","settle","land","ci"]
4352
4352
  failureCodes: ["BE_JWT_ALG_PINNED"]
@@ -140,7 +140,7 @@ function checkOwnJwks(input) {
140
140
  return { violations, coverage: { status: 'checked', integrationFiles: integrations.length, verifyCalls: counters.verifyCalls, verifiedCalls: counters.verifiedCalls } };
141
141
  }
142
142
 
143
- /** R260 BE_JWT_ALG_PINNED: every jose jwtVerify call pins a literal secure algorithm list, a configured issuer and the authenticated role. */
143
+ /** 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. */
144
144
  export function checkJwtPolicy(input) {
145
145
  const kit = machineKit(input);
146
146
  const violations = [];
@@ -61,28 +61,28 @@ const configType = (checker, node) => {
61
61
  || /(?:Config|Options|Env)$/u.test(symbol.name)));
62
62
  };
63
63
 
64
- /** Trace issuer construction through configuration values and local URL/string transformations. */
65
- const issuerFromConfig = (ts, checker, expression, seen = new Set()) => {
64
+ /** Trace an issuer or audience to typed configuration values through local URL/string transformations. */
65
+ const fromConfig = (ts, checker, expression, seen = new Set()) => {
66
66
  const node = unwrap(ts, expression);
67
67
  if (!node || seen.has(node)) return false;
68
68
  const next = new Set(seen).add(node);
69
69
  if (ts.isIdentifier(node)) {
70
70
  return declarationsOf(ts, checker, node).some(declaration => {
71
- if (ts.isVariableDeclaration(declaration) && declaration.initializer) return issuerFromConfig(ts, checker, declaration.initializer, next);
71
+ if (ts.isVariableDeclaration(declaration) && declaration.initializer) return fromConfig(ts, checker, declaration.initializer, next);
72
72
  if (ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration)) return configType(checker, node);
73
73
  return /(?:\.config|\.env)\.ts$|\/modules\/config\//u.test(String(declaration.getSourceFile().fileName).replaceAll('\\', '/'));
74
74
  });
75
75
  }
76
76
  if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {
77
- return issuerFromConfig(ts, checker, node.expression, next) || declarationsOf(ts, checker, node).some(declaration =>
77
+ return fromConfig(ts, checker, node.expression, next) || declarationsOf(ts, checker, node).some(declaration =>
78
78
  (ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration)) && !declaration.initializer && configType(checker, node));
79
79
  }
80
- if (ts.isTemplateExpression(node)) return node.templateSpans.some(span => issuerFromConfig(ts, checker, span.expression, next));
80
+ if (ts.isTemplateExpression(node)) return node.templateSpans.some(span => fromConfig(ts, checker, span.expression, next));
81
81
  if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.PlusToken) {
82
- return issuerFromConfig(ts, checker, node.left, next) || issuerFromConfig(ts, checker, node.right, next);
82
+ return fromConfig(ts, checker, node.left, next) || fromConfig(ts, checker, node.right, next);
83
83
  }
84
84
  if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
85
- return issuerFromConfig(ts, checker, node.expression, next) || node.arguments?.some(argument => issuerFromConfig(ts, checker, argument, next));
85
+ return fromConfig(ts, checker, node.expression, next) || node.arguments?.some(argument => fromConfig(ts, checker, argument, next));
86
86
  }
87
87
  return false;
88
88
  };
@@ -201,7 +201,12 @@ export const jwtPolicyProblems = (ts, checker, call) => {
201
201
  || options?.properties.some(entry => ts.isSpreadAssignment(entry))) {
202
202
  problems.push('BE_JWT_ALG_PINNED: algorithms must be a non-empty literal subset of ES256, RS256 and EdDSA.');
203
203
  }
204
- if (!issuerFromConfig(ts, checker, value('issuer'))) problems.push('BE_JWT_ALG_PINNED: issuer must derive from typed configuration.');
205
- if (!rejectsOtherRoles(ts, checker, call)) problems.push('BE_JWT_ALG_PINNED: the verified principal must reject every role other than authenticated before returning it.');
204
+ if (!fromConfig(ts, checker, value('issuer'))) problems.push('BE_JWT_ALG_PINNED: issuer must derive from typed configuration.');
205
+ // The principal is bound either by an audience of typed configuration (an OIDC client such as Keycloak, the app's own
206
+ // Passport tokens) or, where the audience is shared by every token of the issuer (Supabase's literal 'authenticated'),
207
+ // by rejecting every role other than authenticated before the principal is returned.
208
+ if (!fromConfig(ts, checker, value('audience')) && !rejectsOtherRoles(ts, checker, call)) {
209
+ problems.push('BE_JWT_ALG_PINNED: an OIDC verifier audience must derive from typed configuration, or the verified principal must reject every role other than authenticated before returning it.');
210
+ }
206
211
  return problems;
207
212
  };