@webpieces/nx-webpieces-rules 0.4.895 → 0.4.896

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/README.md CHANGED
@@ -158,9 +158,11 @@ is that promoted level. The runtime graph keeps its call-depth levels.
158
158
 
159
159
  - **Product** — which products it belongs to. A project declares a product with the nx tag
160
160
  `product:<name>` (lowercase kebab, several allowed; the `product-tags` rule makes it required on
161
- servers, clients and apps). A library is never tagged: it belongs to every product whose tagged
162
- project reaches it over `dependsOn`, written per project as `"products": [...]` into
163
- `dependencies.json`. One product is a solid fill in that product's color (a fixed palette of 8 in
161
+ servers, clients and apps). A project's declared tags are FINAL: it belongs to exactly those
162
+ products. An untagged library belongs to every product whose tagged project reaches it over
163
+ `dependsOn` without passing through another tagged project, written per project as
164
+ `"products": [...]` into `dependencies.json`. A published library whose entry points live in other
165
+ repos carries its own tag. One product is a solid fill in that product's color (a fixed palette of 8 in
164
166
  sorted-name order; any product past 8 uses the neutral fill and the legend says so); two or more,
165
167
  but not all, are vertical stripes, one per product; a box shared by every product is one neutral
166
168
  fill; a box in no product is white with a dashed border. The legend counts each product's boxes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/nx-webpieces-rules",
3
- "version": "0.4.895",
3
+ "version": "0.4.896",
4
4
  "description": "Nx-specific webpieces validation rules, graph tooling, executors, and inference plugin.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -20,12 +20,12 @@
20
20
  "README.md"
21
21
  ],
22
22
  "dependencies": {
23
- "@webpieces/api-doc-model": "0.4.895",
24
- "@webpieces/core-util": "0.4.895",
25
- "@webpieces/eslint-rules": "0.4.895",
26
- "@webpieces/rules-config": "0.4.895",
23
+ "@webpieces/api-doc-model": "0.4.896",
24
+ "@webpieces/core-util": "0.4.896",
25
+ "@webpieces/eslint-rules": "0.4.896",
26
+ "@webpieces/rules-config": "0.4.896",
27
27
  "madge": "8.0.0",
28
- "@webpieces/rules-sdk": "0.4.895"
28
+ "@webpieces/rules-sdk": "0.4.896"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@nx/devkit": ">=18.0.0"
@@ -41,7 +41,7 @@
41
41
  "access": "public"
42
42
  },
43
43
  "devDependencies": {
44
- "@webpieces/tooling-testkit": "0.4.895"
44
+ "@webpieces/tooling-testkit": "0.4.896"
45
45
  },
46
46
  "types": "./src/index.d.ts",
47
47
  "bin": {
@@ -108,7 +108,8 @@ function enrichGraph(graph, infos, workspaceRoot) {
108
108
  if (problems.length > 0) {
109
109
  throw new MetadataValidationError(problems);
110
110
  }
111
- // #1179: a library belongs to every product whose tagged project reaches it — derived, never tagged.
111
+ // #1179/#1201: declared product tags are final; an untagged library belongs to every product whose
112
+ // tagged project reaches it without passing through another tagged project.
112
113
  new graph_products_1.ProductMembership().compute(productSeeds, graph).forEach((member, projectName) => {
113
114
  graph[projectName].products = member;
114
115
  });
@@ -1 +1 @@
1
- {"version":3,"file":"graph-metadata.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-metadata.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAuCH,gDAOC;AAOD,kCAqDC;AAsGD,8DAyBC;AAkBD,4DAuBC;;AAhRD,+CAAyB;AACzB,mDAA6B;AAC7B,uCAAqD;AAErD,iDAA6C;AAC7C,6DAAwD;AACxD,mDAA8C;AAC9C,qEAA8D;AAC9D,2EAAqE;AACrE,yDAAqD;AACrD,qDAAqD;AACrD,6DAAwD;AACxD,iFAA2E;AAC3E,mEAA8G;AAC9G,yDAAuF;AACvF,wCAAqC;AAExB,QAAA,0BAA0B,GAAG,qBAAqB,CAAC;AAEhE;;;;GAIG;AACH,MAAa,uBAAwB,SAAQ,KAAK;IAClB;IAA5B,YAA4B,QAAkB;QAC1C,KAAK,CACD,4CAA4C,QAAQ,CAAC,MAAM,iBAAiB;YACxE,QAAQ,CAAC,GAAG,CAAC,CA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AAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC","sourcesContent":["/**\n * Graph Metadata Enrichment\n *\n * Fills the AI-oriented fields on each architecture/dependencies.json entry:\n * framework — from `framework:<x>` nx tag or package.json inference\n * products — the products reaching it, from the `product:<name>` nx tags (#1179)\n * level — re-levelled so servers, clients and apps form the top row (#1179)\n * serviceName — from project.json metadata.webpieces.serviceName; the\n * name clients address this app by at runtime\n * shortDescription — first paragraph of the project's responsibilities.md\n * responsibilitiesFile — repo-relative path to the required responsibilities.md\n * designFile — repo-relative path to the generated DI design.json\n *\n * Validation is aggregated: ALL problems across ALL projects are collected and\n * thrown as one MetadataValidationError so a repo adopting this sees the full\n * seeding list in a single run. Callers must enrich BEFORE writing any file so\n * a failed run never clobbers dependencies.json.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { createProjectGraphAsync } from '@nx/devkit';\nimport type { EnhancedGraph, GraphEntry } from './graph-sorter';\nimport { ProjectInfo } from './project-info';\nimport { resolveFramework } from './framework-resolver';\nimport { resolveRole } from './role-resolver';\nimport { resolveDrawOnGraph } from './draw-on-graph-resolver';\nimport { resolveCutLegacyCycles } from './cut-legacy-cycle-resolver';\nimport { ProductResolver } from './product-resolver';\nimport { ProductMembership } from './graph-products';\nimport { EntryPointLevels } from './graph-entry-levels';\nimport { resolveRuntimeParticipant } from './runtime-participant-resolver';\nimport { resolveCallsService, resolveServiceName, validateUniqueServiceNames } from './service-name-resolver';\nimport { extractShortDescription, validateShortDescription } from './responsibilities';\nimport { toError } from '../toError';\n\nexport const RESPONSIBILITIES_FILE_NAME = 'responsibilities.md';\n\n/**\n * Thrown when one or more projects fail metadata validation (missing/invalid\n * responsibilities.md, bad framework tags, ...). Executors catch this to point\n * AI at the webpieces.responsibilities.md instructions template.\n */\nexport class MetadataValidationError extends Error {\n constructor(public readonly problems: string[]) {\n super(\n `Architecture metadata validation failed (${problems.length} problem(s)):\\n` +\n problems.map((problem: string) => ` - ${problem}`).join('\\n')\n );\n this.name = 'MetadataValidationError';\n }\n}\n\n/**\n * Read per-project root + tags from nx's project graph.\n */\nexport async function collectProjectInfo(): Promise<Map<string, ProjectInfo>> {\n const projectGraph = await createProjectGraphAsync();\n const infos = new Map<string, ProjectInfo>();\n for (const [name, node] of Object.entries(projectGraph.nodes)) {\n infos.set(name, new ProjectInfo(name, node.data.root, node.data.tags ?? []));\n }\n return infos;\n}\n\n/**\n * Enrich every graph entry in place with framework, shortDescription,\n * responsibilitiesFile and designFile. Throws MetadataValidationError listing\n * every problem when any project fails validation.\n */\nexport function enrichGraph(\n graph: EnhancedGraph,\n infos: Map<string, ProjectInfo>,\n workspaceRoot: string\n): void {\n const problems: string[] = [];\n // project -> declared serviceName, collected so duplicates can be reported across the workspace.\n const serviceNames = new Map<string, string>();\n // project -> the products it DECLARES (`product:` tags); membership is derived from these below.\n const productSeeds = new Map<string, string[]>();\n const products = new ProductResolver();\n\n for (const [projectName, entry] of Object.entries(graph)) {\n const info = infos.get(projectName);\n if (!info) {\n problems.push(`${projectName}: not found in nx project graph`);\n continue;\n }\n\n enrichDeclarations(entry, info, workspaceRoot, problems);\n const declared = products.resolve(info);\n problems.push(...declared.problems);\n if (declared.products.length > 0) productSeeds.set(projectName, declared.products);\n enrichClientNames(entry, info, workspaceRoot, projectName, serviceNames, problems);\n enrichResponsibilities(entry, info, workspaceRoot, problems);\n\n // Set designFile ONLY when the project has a REAL generated design (a\n // non-empty `designs[]`), i.e. it has a @DocumentDesign root. A project\n // without one has NO design.json at all (di-graph-generate stopped writing\n // empty ones and reaps stale ones), and legacy repos may still carry an\n // empty `{ designs: [] }` until their next build — both must read the same\n // way, and neither gets a \"View Design\" item on its node menu in the arch\n // viz (designLinks keys off designFile). See graph-visualizer.ts.\n if (hasGeneratedDesign(workspaceRoot, info.root)) {\n entry.designFile = toRepoRelative(info.root, 'design.json');\n }\n }\n\n validateUniqueServiceNames(serviceNames, problems);\n validateLibraryTypesMatch(graph, problems);\n validateRoleDependencies(graph, problems);\n\n if (problems.length > 0) {\n throw new MetadataValidationError(problems);\n }\n\n // #1179: a library belongs to every product whose tagged project reaches it — derived, never tagged.\n new ProductMembership().compute(productSeeds, graph).forEach((member: string[], projectName: string): void => {\n graph[projectName].products = member;\n });\n // #1179: servers, clients and apps form the top row. Here, once roles are resolved, so generate,\n // validate-architecture-unchanged and validate-api-relations all compute identical levels.\n new EntryPointLevels(APP_ROLES).promote(graph);\n}\n\n/**\n * The fields a project DECLARES about itself — its framework env set and role (nx tags), the\n * webpieces runtime packages it depends on (package.json), and whether it opts out of the drawings\n * (nx tag). Grouped because they share a shape: resolve, record the problem, or write the field.\n *\n * Distinct from enrichResponsibilities/designFile, which read generated or hand-written FILES.\n */\n// webpieces-disable no-function-outside-class -- enrichGraph step helper, matching enrichClientNames/enrichResponsibilities in this file\nfunction enrichDeclarations(\n entry: GraphEntry,\n info: ProjectInfo,\n workspaceRoot: string,\n problems: string[]\n): void {\n const resolution = resolveFramework(info, workspaceRoot);\n if (resolution.problem !== null) {\n problems.push(resolution.problem);\n } else if (resolution.frameworks !== null) {\n entry.framework = resolution.frameworks;\n }\n\n const roleResolution = resolveRole(info);\n if (roleResolution.problem !== null) {\n problems.push(roleResolution.problem);\n } else if (roleResolution.role !== null) {\n entry.role = roleResolution.role;\n }\n\n // Only persist when the project declares at least one — a repo full of\n // \"webpiecesRuntime\": [] lines would be noise, and absence already means \"declares none\".\n const participantResolution = resolveRuntimeParticipant(info, workspaceRoot);\n if (participantResolution.problem !== null) {\n problems.push(participantResolution.problem);\n } else if (participantResolution.markers !== null && participantResolution.markers.length > 0) {\n entry.webpiecesRuntime = participantResolution.markers;\n }\n\n // Only persist the field when hidden (false); drawn projects (the\n // default) stay clean in dependencies.json with no drawOnGraph line.\n const drawResolution = resolveDrawOnGraph(info);\n if (drawResolution.problem !== null) {\n problems.push(drawResolution.problem);\n } else if (drawResolution.drawOnGraph === false) {\n entry.drawOnGraph = false;\n }\n\n // Only persist when the project actually cuts an edge — absence is the normal state, and a repo\n // full of \"cutLegacyCycle\": [] lines would bury the ones that mean something.\n const cutResolution = resolveCutLegacyCycles(info);\n if (cutResolution.problem !== null) {\n problems.push(cutResolution.problem);\n } else if (cutResolution.targets !== null && cutResolution.targets.length > 0) {\n entry.cutLegacyCycle = cutResolution.targets;\n }\n}\n\n/**\n * Roles that are terminal APPS — nothing may depend on them. A server, a\n * non-HTTP `app`, or a client is a top-level runnable; being depended upon means\n * it is really a library and should be retagged `role:lib`/`role:designed-lib`.\n */\nexport const APP_ROLES: ReadonlyArray<string> = ['server', 'app', 'client'];\n\n/**\n * Compatibility lattice — the \"up-set\" of each atomic env is the env itself\n * PLUS every ancestor it can legally consume code from (specialization edges\n * child → parent: react → browser, angular → browser, express → node). A\n * consumer promising env `c` can be satisfied by any dependency env in `up(c)`.\n *\n * `react-native` is a first-class runtime and NOT a specialisation of browser (#1064, D6): it has no\n * DOM, no IndexedDB and no OPFS, so a react-native consumer may only consume libraries that are\n * themselves tagged `framework:react-native` (a universal browser+node+react-native library, a\n * browser+react-native one, or a react-native-only one).\n */\nexport const ENV_UP_SETS: Readonly<Record<string, ReadonlyArray<string>>> = {\n react: ['react', 'browser'],\n angular: ['angular', 'browser'],\n browser: ['browser'],\n express: ['express', 'node'],\n node: ['node'],\n 'react-native': ['react-native'],\n};\n\n/** The up-set of an env (env itself + ancestors); unknown envs map to just themselves. */\nfunction upSet(env: string): ReadonlyArray<string> {\n return ENV_UP_SETS[env] ?? [env];\n}\n\n/**\n * `library-types-match-client` rule.\n *\n * A project's `framework` field is its libType — the SET of runtime\n * environments it is validated to run in (browser | react | angular | node |\n * express | react-native). For a dependency edge Consumer C → Library L, the edge is LEGAL iff\n * for EVERY env `c` in C's set, up(c) ∩ L's set ≠ ∅ — i.e. every environment\n * the consumer promises to run in can be satisfied by the dependency. This keeps\n * an express app from depending on a browser-only lib, and lets a `browser+node`\n * lib be consumed by both react and express projects. Every violation is\n * appended to `problems` so `arch:generate` fails with the full list.\n */\nexport function validateLibraryTypesMatch(graph: EnhancedGraph, problems: string[]): void {\n for (const [projectName, entry] of Object.entries(graph)) {\n const fromSet = entry.framework;\n if (fromSet === undefined) continue; // framework resolution already flagged this project\n\n for (const dep of entry.dependsOn) {\n const depEntry = graph[dep];\n const toSet = depEntry?.framework;\n if (toSet === undefined) continue;\n\n const unsatisfied = fromSet.filter(\n (env: string) => !upSet(env).some((up: string) => toSet.includes(up))\n );\n if (unsatisfied.length === 0) continue;\n\n problems.push(\n `library-types-match-client: '${projectName}' [${fromSet.join(', ')}] must not depend on ` +\n `'${dep}' [${toSet.join(', ')}] — the consumer env(s) ${unsatisfied.join(', ')} cannot be ` +\n `satisfied by the dependency (each consumer env must resolve to itself or an ancestor it ` +\n `consumes from: react/angular→browser, express→node, react-native→react-native only). ` +\n `Widen '${dep}' framework tags or ` +\n `remove the dependency.`\n );\n }\n }\n}\n\n/**\n * `role-dependency` rule.\n *\n * A project's `role` is its function (server | app | bundle | designed-lib | lib | client |\n * api-lib | api-client). The two api roles are libraries, never apps, so this rule leaves them alone;\n * what THEY may depend on is `api-lib-dependencies` (tag-truth.ts).\n * Apps are terminal — libraries and clients consume them, never the reverse:\n * - a `client` is fully terminal: NOTHING may depend on it.\n * - a `server` may only be depended upon by another `server` — the one\n * legitimate case is a server-side orchestrator/e2e harness that boots\n * other servers. A `lib`/`designed-lib`/`client` depending on a `server`\n * inverts the dependency direction and is a violation.\n * - a `bundle` is the one role permitted to depend on ANY app: it aggregates\n * several apps into one distributable (e.g. an nx plugin re-exposing multiple\n * tooling apps), so a `bundle → app` edge is legitimate, not inverted.\n */\nexport function validateRoleDependencies(graph: EnhancedGraph, problems: string[]): void {\n for (const [projectName, entry] of Object.entries(graph)) {\n const fromRole = entry.role;\n for (const dep of entry.dependsOn) {\n const toRole = graph[dep]?.role;\n if (toRole === undefined) continue; // role resolution already flagged this project\n if (!APP_ROLES.includes(toRole)) continue;\n // A server may orchestrate/boot other servers (e.g. an e2e harness).\n if (toRole === 'server' && fromRole === 'server') continue;\n // A bundle aggregates apps — it may depend on any app role.\n if (fromRole === 'bundle') continue;\n\n const why =\n toRole === 'client'\n ? `a 'client' app is terminal and may never be depended upon`\n : `a 'server' may only be depended upon by another 'server' (an orchestrator/e2e harness)`;\n problems.push(\n `role-dependency: '${projectName}' (role:${fromRole ?? 'none'}) must not depend on ` +\n `'${dep}' (role:${toRole}) — ${why}. Retag '${dep}' role:lib/role:designed-lib if it ` +\n `is actually a library, or remove the dependency.`\n );\n }\n }\n}\n\n/**\n * Fill the two symmetric client-addressing fields — `serviceName` (the name clients address THIS app\n * by) and `callsService` (the name THIS app's clients call when no literal ClientConfig sits at the\n * call site). Both are declared in project.json, never derived (see service-name-resolver.ts).\n */\n// webpieces-disable no-function-outside-class -- pure enrichment helper, mirrors enrichResponsibilities\nfunction enrichClientNames(\n entry: EnhancedGraph[string],\n info: ProjectInfo,\n workspaceRoot: string,\n projectName: string,\n serviceNames: Map<string, string>,\n problems: string[]\n): void {\n const serviceResolution = resolveServiceName(info, workspaceRoot);\n if (serviceResolution.problem !== null) {\n problems.push(serviceResolution.problem);\n } else if (serviceResolution.serviceName !== null) {\n entry.serviceName = serviceResolution.serviceName;\n serviceNames.set(projectName, serviceResolution.serviceName);\n }\n\n // Consumed by the runtime graph's target resolution (runtime-graph.ts), between the call-site\n // literal and the fan-out fallback.\n const callsResolution = resolveCallsService(info, workspaceRoot);\n if (callsResolution.problem !== null) {\n problems.push(callsResolution.problem);\n } else if (callsResolution.callsService !== null) {\n entry.callsService = callsResolution.callsService;\n }\n}\n\nfunction enrichResponsibilities(\n entry: EnhancedGraph[string],\n info: ProjectInfo,\n workspaceRoot: string,\n problems: string[]\n): void {\n const responsibilitiesFile = toRepoRelative(info.root, RESPONSIBILITIES_FILE_NAME);\n entry.responsibilitiesFile = responsibilitiesFile;\n\n const absolutePath = path.join(workspaceRoot, info.root, RESPONSIBILITIES_FILE_NAME);\n if (!fs.existsSync(absolutePath)) {\n problems.push(\n `${info.name}: missing required ${responsibilitiesFile} — create it with a heading, ` +\n `one short summary paragraph, then the full responsibilities of the module`\n );\n return;\n }\n\n const summary = extractShortDescription(fs.readFileSync(absolutePath, 'utf-8'));\n const summaryProblem = validateShortDescription(summary, responsibilitiesFile);\n if (summaryProblem !== null) {\n problems.push(`${info.name}: ${summaryProblem}`);\n return;\n }\n entry.shortDescription = summary;\n}\n\n/**\n * Repo-relative path with forward slashes (stable across platforms in the\n * committed JSON).\n */\nfunction toRepoRelative(projectRoot: string, fileName: string): string {\n return [projectRoot.replace(/\\\\/g, '/').replace(/\\/+$/, ''), fileName].join('/');\n}\n\n/**\n * True when the project has a REAL generated DI design — a committed design.json\n * whose `designs[]` is non-empty (i.e. it has ≥1 @DocumentDesign root).\n *\n * MISSING, empty-`designs[]`, and unparseable all read as \"no design\", and that\n * equivalence is load-bearing rather than incidental: di-graph-generate writes NO\n * file for a project without a design root (and reaps a stale one), so \"absent\"\n * is now the normal state for every plain lib and legacy service. Repos that have\n * not rebuilt since still carry `{ designs: [] }` files. Either way the box's node\n * menu must offer no \"View Design\" item. See design-file-emission.spec.ts.\n */\nfunction hasGeneratedDesign(workspaceRoot: string, projectRoot: string): boolean {\n const designPath = path.join(workspaceRoot, projectRoot, 'design.json');\n if (!fs.existsSync(designPath)) return false;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const parsed = JSON.parse(fs.readFileSync(designPath, 'utf-8'));\n return Array.isArray(parsed.designs) && parsed.designs.length > 0;\n } catch (err: unknown) {\n const error = toError(err);\n console.warn(`⚠️ Skipping unparseable ${designPath}: ${error.message}`);\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"graph-metadata.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-metadata.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAuCH,gDAOC;AAOD,kCAsDC;AAsGD,8DAyBC;AAkBD,4DAuBC;;AAjRD,+CAAyB;AACzB,mDAA6B;AAC7B,u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AAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;QAChE,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IACtE,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,IAAA,iBAAO,EAAC,GAAG,CAAC,CAAC;QAC3B,OAAO,CAAC,IAAI,CAAC,4BAA4B,UAAU,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACzE,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC","sourcesContent":["/**\n * Graph Metadata Enrichment\n *\n * Fills the AI-oriented fields on each architecture/dependencies.json entry:\n * framework — from `framework:<x>` nx tag or package.json inference\n * products — the products reaching it, from the `product:<name>` nx tags (#1179)\n * level — re-levelled so servers, clients and apps form the top row (#1179)\n * serviceName — from project.json metadata.webpieces.serviceName; the\n * name clients address this app by at runtime\n * shortDescription — first paragraph of the project's responsibilities.md\n * responsibilitiesFile — repo-relative path to the required responsibilities.md\n * designFile — repo-relative path to the generated DI design.json\n *\n * Validation is aggregated: ALL problems across ALL projects are collected and\n * thrown as one MetadataValidationError so a repo adopting this sees the full\n * seeding list in a single run. Callers must enrich BEFORE writing any file so\n * a failed run never clobbers dependencies.json.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { createProjectGraphAsync } from '@nx/devkit';\nimport type { EnhancedGraph, GraphEntry } from './graph-sorter';\nimport { ProjectInfo } from './project-info';\nimport { resolveFramework } from './framework-resolver';\nimport { resolveRole } from './role-resolver';\nimport { resolveDrawOnGraph } from './draw-on-graph-resolver';\nimport { resolveCutLegacyCycles } from './cut-legacy-cycle-resolver';\nimport { ProductResolver } from './product-resolver';\nimport { ProductMembership } from './graph-products';\nimport { EntryPointLevels } from './graph-entry-levels';\nimport { resolveRuntimeParticipant } from './runtime-participant-resolver';\nimport { resolveCallsService, resolveServiceName, validateUniqueServiceNames } from './service-name-resolver';\nimport { extractShortDescription, validateShortDescription } from './responsibilities';\nimport { toError } from '../toError';\n\nexport const RESPONSIBILITIES_FILE_NAME = 'responsibilities.md';\n\n/**\n * Thrown when one or more projects fail metadata validation (missing/invalid\n * responsibilities.md, bad framework tags, ...). Executors catch this to point\n * AI at the webpieces.responsibilities.md instructions template.\n */\nexport class MetadataValidationError extends Error {\n constructor(public readonly problems: string[]) {\n super(\n `Architecture metadata validation failed (${problems.length} problem(s)):\\n` +\n problems.map((problem: string) => ` - ${problem}`).join('\\n')\n );\n this.name = 'MetadataValidationError';\n }\n}\n\n/**\n * Read per-project root + tags from nx's project graph.\n */\nexport async function collectProjectInfo(): Promise<Map<string, ProjectInfo>> {\n const projectGraph = await createProjectGraphAsync();\n const infos = new Map<string, ProjectInfo>();\n for (const [name, node] of Object.entries(projectGraph.nodes)) {\n infos.set(name, new ProjectInfo(name, node.data.root, node.data.tags ?? []));\n }\n return infos;\n}\n\n/**\n * Enrich every graph entry in place with framework, shortDescription,\n * responsibilitiesFile and designFile. Throws MetadataValidationError listing\n * every problem when any project fails validation.\n */\nexport function enrichGraph(\n graph: EnhancedGraph,\n infos: Map<string, ProjectInfo>,\n workspaceRoot: string\n): void {\n const problems: string[] = [];\n // project -> declared serviceName, collected so duplicates can be reported across the workspace.\n const serviceNames = new Map<string, string>();\n // project -> the products it DECLARES (`product:` tags); membership is derived from these below.\n const productSeeds = new Map<string, string[]>();\n const products = new ProductResolver();\n\n for (const [projectName, entry] of Object.entries(graph)) {\n const info = infos.get(projectName);\n if (!info) {\n problems.push(`${projectName}: not found in nx project graph`);\n continue;\n }\n\n enrichDeclarations(entry, info, workspaceRoot, problems);\n const declared = products.resolve(info);\n problems.push(...declared.problems);\n if (declared.products.length > 0) productSeeds.set(projectName, declared.products);\n enrichClientNames(entry, info, workspaceRoot, projectName, serviceNames, problems);\n enrichResponsibilities(entry, info, workspaceRoot, problems);\n\n // Set designFile ONLY when the project has a REAL generated design (a\n // non-empty `designs[]`), i.e. it has a @DocumentDesign root. A project\n // without one has NO design.json at all (di-graph-generate stopped writing\n // empty ones and reaps stale ones), and legacy repos may still carry an\n // empty `{ designs: [] }` until their next build — both must read the same\n // way, and neither gets a \"View Design\" item on its node menu in the arch\n // viz (designLinks keys off designFile). See graph-visualizer.ts.\n if (hasGeneratedDesign(workspaceRoot, info.root)) {\n entry.designFile = toRepoRelative(info.root, 'design.json');\n }\n }\n\n validateUniqueServiceNames(serviceNames, problems);\n validateLibraryTypesMatch(graph, problems);\n validateRoleDependencies(graph, problems);\n\n if (problems.length > 0) {\n throw new MetadataValidationError(problems);\n }\n\n // #1179/#1201: declared product tags are final; an untagged library belongs to every product whose\n // tagged project reaches it without passing through another tagged project.\n new ProductMembership().compute(productSeeds, graph).forEach((member: string[], projectName: string): void => {\n graph[projectName].products = member;\n });\n // #1179: servers, clients and apps form the top row. Here, once roles are resolved, so generate,\n // validate-architecture-unchanged and validate-api-relations all compute identical levels.\n new EntryPointLevels(APP_ROLES).promote(graph);\n}\n\n/**\n * The fields a project DECLARES about itself — its framework env set and role (nx tags), the\n * webpieces runtime packages it depends on (package.json), and whether it opts out of the drawings\n * (nx tag). Grouped because they share a shape: resolve, record the problem, or write the field.\n *\n * Distinct from enrichResponsibilities/designFile, which read generated or hand-written FILES.\n */\n// webpieces-disable no-function-outside-class -- enrichGraph step helper, matching enrichClientNames/enrichResponsibilities in this file\nfunction enrichDeclarations(\n entry: GraphEntry,\n info: ProjectInfo,\n workspaceRoot: string,\n problems: string[]\n): void {\n const resolution = resolveFramework(info, workspaceRoot);\n if (resolution.problem !== null) {\n problems.push(resolution.problem);\n } else if (resolution.frameworks !== null) {\n entry.framework = resolution.frameworks;\n }\n\n const roleResolution = resolveRole(info);\n if (roleResolution.problem !== null) {\n problems.push(roleResolution.problem);\n } else if (roleResolution.role !== null) {\n entry.role = roleResolution.role;\n }\n\n // Only persist when the project declares at least one — a repo full of\n // \"webpiecesRuntime\": [] lines would be noise, and absence already means \"declares none\".\n const participantResolution = resolveRuntimeParticipant(info, workspaceRoot);\n if (participantResolution.problem !== null) {\n problems.push(participantResolution.problem);\n } else if (participantResolution.markers !== null && participantResolution.markers.length > 0) {\n entry.webpiecesRuntime = participantResolution.markers;\n }\n\n // Only persist the field when hidden (false); drawn projects (the\n // default) stay clean in dependencies.json with no drawOnGraph line.\n const drawResolution = resolveDrawOnGraph(info);\n if (drawResolution.problem !== null) {\n problems.push(drawResolution.problem);\n } else if (drawResolution.drawOnGraph === false) {\n entry.drawOnGraph = false;\n }\n\n // Only persist when the project actually cuts an edge — absence is the normal state, and a repo\n // full of \"cutLegacyCycle\": [] lines would bury the ones that mean something.\n const cutResolution = resolveCutLegacyCycles(info);\n if (cutResolution.problem !== null) {\n problems.push(cutResolution.problem);\n } else if (cutResolution.targets !== null && cutResolution.targets.length > 0) {\n entry.cutLegacyCycle = cutResolution.targets;\n }\n}\n\n/**\n * Roles that are terminal APPS — nothing may depend on them. A server, a\n * non-HTTP `app`, or a client is a top-level runnable; being depended upon means\n * it is really a library and should be retagged `role:lib`/`role:designed-lib`.\n */\nexport const APP_ROLES: ReadonlyArray<string> = ['server', 'app', 'client'];\n\n/**\n * Compatibility lattice — the \"up-set\" of each atomic env is the env itself\n * PLUS every ancestor it can legally consume code from (specialization edges\n * child → parent: react → browser, angular → browser, express → node). A\n * consumer promising env `c` can be satisfied by any dependency env in `up(c)`.\n *\n * `react-native` is a first-class runtime and NOT a specialisation of browser (#1064, D6): it has no\n * DOM, no IndexedDB and no OPFS, so a react-native consumer may only consume libraries that are\n * themselves tagged `framework:react-native` (a universal browser+node+react-native library, a\n * browser+react-native one, or a react-native-only one).\n */\nexport const ENV_UP_SETS: Readonly<Record<string, ReadonlyArray<string>>> = {\n react: ['react', 'browser'],\n angular: ['angular', 'browser'],\n browser: ['browser'],\n express: ['express', 'node'],\n node: ['node'],\n 'react-native': ['react-native'],\n};\n\n/** The up-set of an env (env itself + ancestors); unknown envs map to just themselves. */\nfunction upSet(env: string): ReadonlyArray<string> {\n return ENV_UP_SETS[env] ?? [env];\n}\n\n/**\n * `library-types-match-client` rule.\n *\n * A project's `framework` field is its libType — the SET of runtime\n * environments it is validated to run in (browser | react | angular | node |\n * express | react-native). For a dependency edge Consumer C → Library L, the edge is LEGAL iff\n * for EVERY env `c` in C's set, up(c) ∩ L's set ≠ ∅ — i.e. every environment\n * the consumer promises to run in can be satisfied by the dependency. This keeps\n * an express app from depending on a browser-only lib, and lets a `browser+node`\n * lib be consumed by both react and express projects. Every violation is\n * appended to `problems` so `arch:generate` fails with the full list.\n */\nexport function validateLibraryTypesMatch(graph: EnhancedGraph, problems: string[]): void {\n for (const [projectName, entry] of Object.entries(graph)) {\n const fromSet = entry.framework;\n if (fromSet === undefined) continue; // framework resolution already flagged this project\n\n for (const dep of entry.dependsOn) {\n const depEntry = graph[dep];\n const toSet = depEntry?.framework;\n if (toSet === undefined) continue;\n\n const unsatisfied = fromSet.filter(\n (env: string) => !upSet(env).some((up: string) => toSet.includes(up))\n );\n if (unsatisfied.length === 0) continue;\n\n problems.push(\n `library-types-match-client: '${projectName}' [${fromSet.join(', ')}] must not depend on ` +\n `'${dep}' [${toSet.join(', ')}] — the consumer env(s) ${unsatisfied.join(', ')} cannot be ` +\n `satisfied by the dependency (each consumer env must resolve to itself or an ancestor it ` +\n `consumes from: react/angular→browser, express→node, react-native→react-native only). ` +\n `Widen '${dep}' framework tags or ` +\n `remove the dependency.`\n );\n }\n }\n}\n\n/**\n * `role-dependency` rule.\n *\n * A project's `role` is its function (server | app | bundle | designed-lib | lib | client |\n * api-lib | api-client). The two api roles are libraries, never apps, so this rule leaves them alone;\n * what THEY may depend on is `api-lib-dependencies` (tag-truth.ts).\n * Apps are terminal — libraries and clients consume them, never the reverse:\n * - a `client` is fully terminal: NOTHING may depend on it.\n * - a `server` may only be depended upon by another `server` — the one\n * legitimate case is a server-side orchestrator/e2e harness that boots\n * other servers. A `lib`/`designed-lib`/`client` depending on a `server`\n * inverts the dependency direction and is a violation.\n * - a `bundle` is the one role permitted to depend on ANY app: it aggregates\n * several apps into one distributable (e.g. an nx plugin re-exposing multiple\n * tooling apps), so a `bundle → app` edge is legitimate, not inverted.\n */\nexport function validateRoleDependencies(graph: EnhancedGraph, problems: string[]): void {\n for (const [projectName, entry] of Object.entries(graph)) {\n const fromRole = entry.role;\n for (const dep of entry.dependsOn) {\n const toRole = graph[dep]?.role;\n if (toRole === undefined) continue; // role resolution already flagged this project\n if (!APP_ROLES.includes(toRole)) continue;\n // A server may orchestrate/boot other servers (e.g. an e2e harness).\n if (toRole === 'server' && fromRole === 'server') continue;\n // A bundle aggregates apps — it may depend on any app role.\n if (fromRole === 'bundle') continue;\n\n const why =\n toRole === 'client'\n ? `a 'client' app is terminal and may never be depended upon`\n : `a 'server' may only be depended upon by another 'server' (an orchestrator/e2e harness)`;\n problems.push(\n `role-dependency: '${projectName}' (role:${fromRole ?? 'none'}) must not depend on ` +\n `'${dep}' (role:${toRole}) — ${why}. Retag '${dep}' role:lib/role:designed-lib if it ` +\n `is actually a library, or remove the dependency.`\n );\n }\n }\n}\n\n/**\n * Fill the two symmetric client-addressing fields — `serviceName` (the name clients address THIS app\n * by) and `callsService` (the name THIS app's clients call when no literal ClientConfig sits at the\n * call site). Both are declared in project.json, never derived (see service-name-resolver.ts).\n */\n// webpieces-disable no-function-outside-class -- pure enrichment helper, mirrors enrichResponsibilities\nfunction enrichClientNames(\n entry: EnhancedGraph[string],\n info: ProjectInfo,\n workspaceRoot: string,\n projectName: string,\n serviceNames: Map<string, string>,\n problems: string[]\n): void {\n const serviceResolution = resolveServiceName(info, workspaceRoot);\n if (serviceResolution.problem !== null) {\n problems.push(serviceResolution.problem);\n } else if (serviceResolution.serviceName !== null) {\n entry.serviceName = serviceResolution.serviceName;\n serviceNames.set(projectName, serviceResolution.serviceName);\n }\n\n // Consumed by the runtime graph's target resolution (runtime-graph.ts), between the call-site\n // literal and the fan-out fallback.\n const callsResolution = resolveCallsService(info, workspaceRoot);\n if (callsResolution.problem !== null) {\n problems.push(callsResolution.problem);\n } else if (callsResolution.callsService !== null) {\n entry.callsService = callsResolution.callsService;\n }\n}\n\nfunction enrichResponsibilities(\n entry: EnhancedGraph[string],\n info: ProjectInfo,\n workspaceRoot: string,\n problems: string[]\n): void {\n const responsibilitiesFile = toRepoRelative(info.root, RESPONSIBILITIES_FILE_NAME);\n entry.responsibilitiesFile = responsibilitiesFile;\n\n const absolutePath = path.join(workspaceRoot, info.root, RESPONSIBILITIES_FILE_NAME);\n if (!fs.existsSync(absolutePath)) {\n problems.push(\n `${info.name}: missing required ${responsibilitiesFile} — create it with a heading, ` +\n `one short summary paragraph, then the full responsibilities of the module`\n );\n return;\n }\n\n const summary = extractShortDescription(fs.readFileSync(absolutePath, 'utf-8'));\n const summaryProblem = validateShortDescription(summary, responsibilitiesFile);\n if (summaryProblem !== null) {\n problems.push(`${info.name}: ${summaryProblem}`);\n return;\n }\n entry.shortDescription = summary;\n}\n\n/**\n * Repo-relative path with forward slashes (stable across platforms in the\n * committed JSON).\n */\nfunction toRepoRelative(projectRoot: string, fileName: string): string {\n return [projectRoot.replace(/\\\\/g, '/').replace(/\\/+$/, ''), fileName].join('/');\n}\n\n/**\n * True when the project has a REAL generated DI design — a committed design.json\n * whose `designs[]` is non-empty (i.e. it has ≥1 @DocumentDesign root).\n *\n * MISSING, empty-`designs[]`, and unparseable all read as \"no design\", and that\n * equivalence is load-bearing rather than incidental: di-graph-generate writes NO\n * file for a project without a design root (and reaps a stale one), so \"absent\"\n * is now the normal state for every plain lib and legacy service. Repos that have\n * not rebuilt since still carry `{ designs: [] }` files. Either way the box's node\n * menu must offer no \"View Design\" item. See design-file-emission.spec.ts.\n */\nfunction hasGeneratedDesign(workspaceRoot: string, projectRoot: string): boolean {\n const designPath = path.join(workspaceRoot, projectRoot, 'design.json');\n if (!fs.existsSync(designPath)) return false;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const parsed = JSON.parse(fs.readFileSync(designPath, 'utf-8'));\n return Array.isArray(parsed.designs) && parsed.designs.length > 0;\n } catch (err: unknown) {\n const error = toError(err);\n console.warn(`⚠️ Skipping unparseable ${designPath}: ${error.message}`);\n return false;\n }\n}\n"]}
@@ -5,15 +5,22 @@
5
5
  * on its entry points with the nx tag `product:<name>` (product-resolver.ts); everything else a
6
6
  * product consists of is DERIVED here, never declared:
7
7
  *
8
- * - ProductMembership — the dependency graph. A project belongs to every product whose tagged project
9
- * reaches it by a downward walk over `dependsOn`. That closure is everything that can change the
10
- * product's behaviour, so it is what a reviewer of that product reviews. It must start from EVERY
11
- * entry point, clients and servers both: a client reaches its server only over HTTP, never through
12
- * an nx edge, so a server is in its product only because it is tagged.
13
- * - RuntimeProductMembership — the runtime graph. The services in a product are its seeds plus every
14
- * service reachable over RUNTIME `dependsOn`, including through a queue to its consumers — so a
15
- * call from one product into another product's service shows, which is exactly the cross-product
16
- * coupling a reviewer needs to see.
8
+ * - ProductMembership — the dependency graph. A project's OWN `product:` tags are FINAL (#1201): a
9
+ * project that declares any keeps exactly its declared set. An UNTAGGED project belongs to every
10
+ * product whose tagged project reaches it by a downward walk over `dependsOn` — and that walk stops
11
+ * at a tagged project, whose own dependencies are reached by its own seed walk. That closure is
12
+ * everything that can change the product's behaviour, so it is what a reviewer of that product
13
+ * reviews. It must start from EVERY entry point, clients and servers both: a client reaches its
14
+ * server only over HTTP, never through an nx edge, so a server is in its product only because it is
15
+ * tagged. Why final: a project is one product's, never two by accident — the example apps depend on
16
+ * the platform libraries, and a platform library tagged `product:platform` must not be painted
17
+ * `example` because an example reaches it. A published library whose entry points live in OTHER
18
+ * repos carries its own tag for exactly that reason: no in-repo walk can ever reach it correctly.
19
+ * - RuntimeProductMembership — the runtime graph, under the same rule. A service that already carries
20
+ * products (declared, or derived on the dependency graph above) keeps exactly them; a service with
21
+ * none belongs to every product whose service reaches it over RUNTIME `dependsOn`, including through
22
+ * a queue to its consumers, and that walk stops at a service with products of its own. A call from
23
+ * one product into another product's service still shows — as the runtime EDGE between them.
17
24
  * - ProductPalette — the Product color mode's colors: a fixed palette of eight assigned in sorted
18
25
  * product-name order, a neutral fill for a box shared by EVERY product, and a dashed white box for
19
26
  * one in no product.
@@ -54,25 +61,38 @@ export declare class ProductPalette {
54
61
  /** True when some product is past the palette's eight, so the legend must say it is neutral. */
55
62
  overflows(): boolean;
56
63
  }
57
- /** The architecture graph's product membership: declared seeds walked DOWN over `dependsOn`. */
64
+ /**
65
+ * The architecture graph's product membership: declared seeds walked DOWN over `dependsOn`, where a
66
+ * project's own declared products are final.
67
+ */
58
68
  export declare class ProductMembership {
59
69
  /**
60
70
  * @param seeds project → the products it DECLARES (its `product:` tags)
61
- * @returns project → the sorted products whose tagged projects reach it; a project in no product
62
- * is absent, so with no tag anywhere the map is empty
71
+ * @returns project → its sorted products: exactly its declared set when it declares any; otherwise
72
+ * every product whose tagged project reaches it without passing through another tagged
73
+ * project. A project in no product is absent, so with no tag anywhere the map is empty.
63
74
  */
64
75
  compute(seeds: ReadonlyMap<string, readonly string[]>, graph: EnhancedGraph): Map<string, string[]>;
65
- /** `seed` plus every project it reaches through `dependsOn`. */
76
+ /**
77
+ * Every UNTAGGED project `seed` reaches through `dependsOn`. A tagged project is neither collected
78
+ * nor walked through: its products are final, and its own seed walk covers its dependencies.
79
+ */
66
80
  private closure;
67
81
  }
68
- /** The runtime graph's product membership: tagged services walked over RUNTIME `dependsOn`. */
82
+ /**
83
+ * The runtime graph's product membership: services that carry products walked over RUNTIME
84
+ * `dependsOn`, where a service's own products are final.
85
+ */
69
86
  export declare class RuntimeProductMembership {
70
87
  /**
71
88
  * Stamp `products` onto every service of `graph` that some product reaches. Seeds are the
72
- * services whose dependencies.json entry carries `products`; a `queue:<Api.method>` dependency is
73
- * followed to that queue's consumers. A service in no product gets no field.
89
+ * services whose dependencies.json entry carries `products`, and each keeps exactly those; a
90
+ * service with none gets every product whose seed reaches it without passing through another
91
+ * seed. A `queue:<Api.method>` dependency is followed to that queue's consumers. A service in no
92
+ * product gets no field.
74
93
  */
75
94
  apply(graph: RuntimeGraph, projects: EnhancedGraph): void;
95
+ /** Every service WITHOUT products of its own that `seed` reaches; a seed is neither collected nor walked through. */
76
96
  private closure;
77
97
  /** The services one service calls: direct ones, and the consumers behind every queue it feeds. */
78
98
  private callees;
@@ -6,15 +6,22 @@
6
6
  * on its entry points with the nx tag `product:<name>` (product-resolver.ts); everything else a
7
7
  * product consists of is DERIVED here, never declared:
8
8
  *
9
- * - ProductMembership — the dependency graph. A project belongs to every product whose tagged project
10
- * reaches it by a downward walk over `dependsOn`. That closure is everything that can change the
11
- * product's behaviour, so it is what a reviewer of that product reviews. It must start from EVERY
12
- * entry point, clients and servers both: a client reaches its server only over HTTP, never through
13
- * an nx edge, so a server is in its product only because it is tagged.
14
- * - RuntimeProductMembership — the runtime graph. The services in a product are its seeds plus every
15
- * service reachable over RUNTIME `dependsOn`, including through a queue to its consumers — so a
16
- * call from one product into another product's service shows, which is exactly the cross-product
17
- * coupling a reviewer needs to see.
9
+ * - ProductMembership — the dependency graph. A project's OWN `product:` tags are FINAL (#1201): a
10
+ * project that declares any keeps exactly its declared set. An UNTAGGED project belongs to every
11
+ * product whose tagged project reaches it by a downward walk over `dependsOn` — and that walk stops
12
+ * at a tagged project, whose own dependencies are reached by its own seed walk. That closure is
13
+ * everything that can change the product's behaviour, so it is what a reviewer of that product
14
+ * reviews. It must start from EVERY entry point, clients and servers both: a client reaches its
15
+ * server only over HTTP, never through an nx edge, so a server is in its product only because it is
16
+ * tagged. Why final: a project is one product's, never two by accident — the example apps depend on
17
+ * the platform libraries, and a platform library tagged `product:platform` must not be painted
18
+ * `example` because an example reaches it. A published library whose entry points live in OTHER
19
+ * repos carries its own tag for exactly that reason: no in-repo walk can ever reach it correctly.
20
+ * - RuntimeProductMembership — the runtime graph, under the same rule. A service that already carries
21
+ * products (declared, or derived on the dependency graph above) keeps exactly them; a service with
22
+ * none belongs to every product whose service reaches it over RUNTIME `dependsOn`, including through
23
+ * a queue to its consumers, and that walk stops at a service with products of its own. A call from
24
+ * one product into another product's service still shows — as the runtime EDGE between them.
18
25
  * - ProductPalette — the Product color mode's colors: a fixed palette of eight assigned in sorted
19
26
  * product-name order, a neutral fill for a box shared by EVERY product, and a dashed white box for
20
27
  * one in no product.
@@ -100,19 +107,29 @@ class ProductPalette {
100
107
  }
101
108
  }
102
109
  exports.ProductPalette = ProductPalette;
103
- /** The architecture graph's product membership: declared seeds walked DOWN over `dependsOn`. */
110
+ /**
111
+ * The architecture graph's product membership: declared seeds walked DOWN over `dependsOn`, where a
112
+ * project's own declared products are final.
113
+ */
104
114
  class ProductMembership {
105
115
  /**
106
116
  * @param seeds project → the products it DECLARES (its `product:` tags)
107
- * @returns project → the sorted products whose tagged projects reach it; a project in no product
108
- * is absent, so with no tag anywhere the map is empty
117
+ * @returns project → its sorted products: exactly its declared set when it declares any; otherwise
118
+ * every product whose tagged project reaches it without passing through another tagged
119
+ * project. A project in no product is absent, so with no tag anywhere the map is empty.
109
120
  */
110
121
  compute(seeds, graph) {
111
- const members = new Map();
122
+ const declared = new Map();
112
123
  seeds.forEach((products, seed) => {
113
- if (products.length === 0 || graph[seed] === undefined)
114
- return;
115
- for (const project of this.closure(seed, graph)) {
124
+ if (products.length > 0 && graph[seed] !== undefined)
125
+ declared.set(seed, products);
126
+ });
127
+ const members = new Map();
128
+ declared.forEach((products, seed) => {
129
+ members.set(seed, new Set(products));
130
+ });
131
+ declared.forEach((products, seed) => {
132
+ for (const project of this.closure(seed, graph, declared)) {
116
133
  const set = members.get(project) ?? new Set();
117
134
  for (const product of products)
118
135
  set.add(product);
@@ -125,9 +142,13 @@ class ProductMembership {
125
142
  });
126
143
  return result;
127
144
  }
128
- /** `seed` plus every project it reaches through `dependsOn`. */
129
- closure(seed, graph) {
145
+ /**
146
+ * Every UNTAGGED project `seed` reaches through `dependsOn`. A tagged project is neither collected
147
+ * nor walked through: its products are final, and its own seed walk covers its dependencies.
148
+ */
149
+ closure(seed, graph, declared) {
130
150
  const seen = new Set([seed]);
151
+ const reached = new Set();
131
152
  const stack = [seed];
132
153
  while (stack.length > 0) {
133
154
  const project = stack.pop();
@@ -135,41 +156,57 @@ class ProductMembership {
135
156
  if (seen.has(dep))
136
157
  continue;
137
158
  seen.add(dep);
159
+ if (declared.has(dep))
160
+ continue;
161
+ reached.add(dep);
138
162
  stack.push(dep);
139
163
  }
140
164
  }
141
- return seen;
165
+ return reached;
142
166
  }
143
167
  }
144
168
  exports.ProductMembership = ProductMembership;
145
- /** The runtime graph's product membership: tagged services walked over RUNTIME `dependsOn`. */
169
+ /**
170
+ * The runtime graph's product membership: services that carry products walked over RUNTIME
171
+ * `dependsOn`, where a service's own products are final.
172
+ */
146
173
  class RuntimeProductMembership {
147
174
  /**
148
175
  * Stamp `products` onto every service of `graph` that some product reaches. Seeds are the
149
- * services whose dependencies.json entry carries `products`; a `queue:<Api.method>` dependency is
150
- * followed to that queue's consumers. A service in no product gets no field.
176
+ * services whose dependencies.json entry carries `products`, and each keeps exactly those; a
177
+ * service with none gets every product whose seed reaches it without passing through another
178
+ * seed. A `queue:<Api.method>` dependency is followed to that queue's consumers. A service in no
179
+ * product gets no field.
151
180
  */
152
181
  apply(graph, projects) {
153
- const members = new Map();
182
+ const seeds = new Map();
154
183
  for (const name of Object.keys(graph.services)) {
155
- const seeded = projects[name]?.products ?? [];
156
- if (seeded.length === 0)
157
- continue;
158
- for (const reached of this.closure(name, graph)) {
184
+ const own = projects[name]?.products ?? [];
185
+ if (own.length > 0)
186
+ seeds.set(name, own);
187
+ }
188
+ const members = new Map();
189
+ seeds.forEach((own, name) => {
190
+ members.set(name, new Set(own));
191
+ });
192
+ seeds.forEach((own, name) => {
193
+ for (const reached of this.closure(name, graph, seeds)) {
159
194
  const set = members.get(reached) ?? new Set();
160
- for (const product of seeded)
195
+ for (const product of own)
161
196
  set.add(product);
162
197
  members.set(reached, set);
163
198
  }
164
- }
199
+ });
165
200
  members.forEach((set, name) => {
166
201
  const service = graph.services[name];
167
202
  if (service !== undefined)
168
203
  service.products = [...set].sort();
169
204
  });
170
205
  }
171
- closure(seed, graph) {
206
+ /** Every service WITHOUT products of its own that `seed` reaches; a seed is neither collected nor walked through. */
207
+ closure(seed, graph, seeds) {
172
208
  const seen = new Set([seed]);
209
+ const reached = new Set();
173
210
  const stack = [seed];
174
211
  while (stack.length > 0) {
175
212
  const name = stack.pop();
@@ -177,10 +214,13 @@ class RuntimeProductMembership {
177
214
  if (seen.has(next) || graph.services[next] === undefined)
178
215
  continue;
179
216
  seen.add(next);
217
+ if (seeds.has(next))
218
+ continue;
219
+ reached.add(next);
180
220
  stack.push(next);
181
221
  }
182
222
  }
183
- return seen;
223
+ return reached;
184
224
  }
185
225
  /** The services one service calls: direct ones, and the consumers behind every queue it feeds. */
186
226
  callees(name, graph) {
@@ -1 +1 @@
1
- {"version":3,"file":"graph-products.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-products.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAKH,+FAA+F;AAC/F,qGAAqG;AACrG,yCAAyC;AACzC,MAAM,SAAS,GAAG,SAAS,CAAC;AAC5B,MAAM,UAAU,GAAG,SAAS,CAAC;AAE7B,2EAA2E;AAC3E,MAAa,YAAY;IAED;IACA;IACA;IAEA;IALpB,YACoB,OAAe,EACf,KAAa,EACb,SAAiB;IACjC,4FAA4F;IAC5E,SAAkB;QAJlB,YAAO,GAAP,OAAO,CAAQ;QACf,UAAK,GAAL,KAAK,CAAQ;QACb,cAAS,GAAT,SAAS,CAAQ;QAEjB,cAAS,GAAT,SAAS,CAAS;IACnC,CAAC;CACP;AARD,oCAQC;AAED,iGAAiG;AACjG,MAAM,cAAc,GAA2C;IAC3D,CAAC,SAAS,EAAE,UAAU,CAAC;IACvB,CAAC,SAAS,EAAE,SAAS,CAAC;IACtB,CAAC,SAAS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G,KAAK,CAAC,GAAG,EAAY,CAAC;YACnC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;gBAC3C,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,SAAS;oBAAE,SAAS;gBACnE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACf,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,kGAAkG;IAC1F,OAAO,CAAC,IAAY,EAAE,KAAmB;QAC7C,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,IAAI,EAAE,EAAE,CAAC;YACtD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClB,SAAS;YACb,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAjDD,4DAiDC","sourcesContent":["/**\n * Products on the architecture graphs (#1179).\n *\n * A monorepo can hold several PRODUCTS, each with its own clients and servers. A product is declared\n * on its entry points with the nx tag `product:<name>` (product-resolver.ts); everything else a\n * product consists of is DERIVED here, never declared:\n *\n * - ProductMembership — the dependency graph. A project belongs to every product whose tagged project\n * reaches it by a downward walk over `dependsOn`. That closure is everything that can change the\n * product's behaviour, so it is what a reviewer of that product reviews. It must start from EVERY\n * entry point, clients and servers both: a client reaches its server only over HTTP, never through\n * an nx edge, so a server is in its product only because it is tagged.\n * - RuntimeProductMembership — the runtime graph. The services in a product are its seeds plus every\n * service reachable over RUNTIME `dependsOn`, including through a queue to its consumers — so a\n * call from one product into another product's service shows, which is exactly the cross-product\n * coupling a reviewer needs to see.\n * - ProductPalette — the Product color mode's colors: a fixed palette of eight assigned in sorted\n * product-name order, a neutral fill for a box shared by EVERY product, and a dashed white box for\n * one in no product.\n *\n * Membership is stable per checkout (it depends on tags and edges, never on a diff), so it is written\n * into the committed dependencies.json / runtime-dependencies.json rather than into a sidecar.\n */\n\nimport type { EnhancedGraph } from './graph-sorter';\nimport type { RuntimeGraph } from './runtime-graph-model';\n\n// The same two text colors graph-color-modes.ts writes on every fill. Spelled here rather than\n// imported because graph-color-modes.ts imports THIS file (for the palette), and a file-import cycle\n// is refused by `no-file-import-cycles`.\nconst DARK_TEXT = '#1a1c22';\nconst LIGHT_TEXT = '#ffffff';\n\n/** One product's color, and the text color that reads on it. Data-only. */\nexport class ProductColor {\n constructor(\n public readonly product: string,\n public readonly color: string,\n public readonly fontColor: string,\n /** False for a product past the palette's eight, which is painted with the neutral fill. */\n public readonly inPalette: boolean,\n ) {}\n}\n\n/** The eight product colors, in assignment order. Distinct from every runtime and role color. */\nconst PRODUCT_COLORS: readonly (readonly [string, string])[] = [\n ['#3f6fb5', LIGHT_TEXT],\n ['#f28e2b', DARK_TEXT],\n ['#c0392b', LIGHT_TEXT],\n ['#5cb8b2', DARK_TEXT],\n ['#3d8b3d', LIGHT_TEXT],\n ['#edc948', DARK_TEXT],\n ['#8e5ea2', LIGHT_TEXT],\n ['#ff9da7', DARK_TEXT],\n];\n\n/** How many products get a color of their own; any further product uses the neutral fill. */\nexport const PRODUCT_PALETTE_SIZE = PRODUCT_COLORS.length;\n\n/** A box shared by EVERY product, and every product past the palette's eight. */\nexport const PRODUCT_SHARED_FILL = '#c9ced8';\n/** A box in no product: white, with a dashed border. */\nexport const PRODUCT_NONE_FILL = '#ffffff';\nexport const PRODUCT_NONE_BORDER = '#8a90a0';\n\nexport class ProductPalette {\n /** Every declared product, sorted, each with its color. */\n readonly colors: ProductColor[];\n\n constructor(products: readonly string[]) {\n const sorted = [...new Set(products)].sort();\n this.colors = sorted.map((product: string, index: number): ProductColor => {\n const entry = PRODUCT_COLORS[index];\n if (entry === undefined) return new ProductColor(product, PRODUCT_SHARED_FILL, DARK_TEXT, false);\n return new ProductColor(product, entry[0], entry[1], true);\n });\n }\n\n /** Every product carried by a project of the graph, as one palette. */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static fromGraph(graph: EnhancedGraph): ProductPalette {\n const all: string[] = [];\n for (const entry of Object.values(graph)) all.push(...(entry.products ?? []));\n return new ProductPalette(all);\n }\n\n names(): string[] {\n return this.colors.map((color: ProductColor): string => color.product);\n }\n\n colorOf(product: string): ProductColor {\n return (\n this.colors.find((color: ProductColor): boolean => color.product === product) ??\n new ProductColor(product, PRODUCT_SHARED_FILL, DARK_TEXT, false)\n );\n }\n\n /** True for a box carrying every product of a workspace that declares two or more. */\n sharedByAll(products: readonly string[]): boolean {\n return this.colors.length > 1 && this.colors.every((color: ProductColor): boolean => products.includes(color.product));\n }\n\n /** True when some product is past the palette's eight, so the legend must say it is neutral. */\n overflows(): boolean {\n return this.colors.some((color: ProductColor): boolean => !color.inPalette);\n }\n}\n\n/** The architecture graph's product membership: declared seeds walked DOWN over `dependsOn`. */\nexport class ProductMembership {\n /**\n * @param seeds project → the products it DECLARES (its `product:` tags)\n * @returns project → the sorted products whose tagged projects reach it; a project in no product\n * is absent, so with no tag anywhere the map is empty\n */\n compute(seeds: ReadonlyMap<string, readonly string[]>, graph: EnhancedGraph): Map<string, string[]> {\n const members = new Map<string, Set<string>>();\n seeds.forEach((products: readonly string[], seed: string): void => {\n if (products.length === 0 || graph[seed] === undefined) return;\n for (const project of this.closure(seed, graph)) {\n const set = members.get(project) ?? new Set<string>();\n for (const product of products) set.add(product);\n members.set(project, set);\n }\n });\n const result = new Map<string, string[]>();\n members.forEach((set: Set<string>, project: string): void => {\n result.set(project, [...set].sort());\n });\n return result;\n }\n\n /** `seed` plus every project it reaches through `dependsOn`. */\n private closure(seed: string, graph: EnhancedGraph): Set<string> {\n const seen = new Set<string>([seed]);\n const stack = [seed];\n while (stack.length > 0) {\n const project = stack.pop() as string;\n for (const dep of graph[project]?.dependsOn ?? []) {\n if (seen.has(dep)) continue;\n seen.add(dep);\n stack.push(dep);\n }\n }\n return seen;\n }\n}\n\n/** The runtime graph's product membership: tagged services walked over RUNTIME `dependsOn`. */\nexport class RuntimeProductMembership {\n /**\n * Stamp `products` onto every service of `graph` that some product reaches. Seeds are the\n * services whose dependencies.json entry carries `products`; a `queue:<Api.method>` dependency is\n * followed to that queue's consumers. A service in no product gets no field.\n */\n apply(graph: RuntimeGraph, projects: EnhancedGraph): void {\n const members = new Map<string, Set<string>>();\n for (const name of Object.keys(graph.services)) {\n const seeded = projects[name]?.products ?? [];\n if (seeded.length === 0) continue;\n for (const reached of this.closure(name, graph)) {\n const set = members.get(reached) ?? new Set<string>();\n for (const product of seeded) set.add(product);\n members.set(reached, set);\n }\n }\n members.forEach((set: Set<string>, name: string): void => {\n const service = graph.services[name];\n if (service !== undefined) service.products = [...set].sort();\n });\n }\n\n private closure(seed: string, graph: RuntimeGraph): Set<string> {\n const seen = new Set<string>([seed]);\n const stack = [seed];\n while (stack.length > 0) {\n const name = stack.pop() as string;\n for (const next of this.callees(name, graph)) {\n if (seen.has(next) || graph.services[next] === undefined) continue;\n seen.add(next);\n stack.push(next);\n }\n }\n return seen;\n }\n\n /** The services one service calls: direct ones, and the consumers behind every queue it feeds. */\n private callees(name: string, graph: RuntimeGraph): string[] {\n const callees: string[] = [];\n for (const dep of graph.services[name]?.dependsOn ?? []) {\n if (!dep.startsWith('queue:')) {\n callees.push(dep);\n continue;\n }\n callees.push(...(graph.queues[dep.slice('queue:'.length)]?.consumedBy ?? []));\n }\n return callees;\n }\n}\n"]}
1
+ {"version":3,"file":"graph-products.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-products.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAKH,+FAA+F;AAC/F,qGAAqG;AACrG,yCAAyC;AACzC,MAAM,SAAS,GAAG,SAAS,CAAC;AAC5B,MAAM,UAAU,GAAG,SAAS,CAAC;AAE7B,2EAA2E;AAC3E,MAAa,YAAY;IAED;IACA;IACA;IAEA;IALpB,YACoB,OAAe,EACf,KAAa,EACb,SAAiB;IACjC,4FAA4F;IAC5E,SAAkB;QAJlB,YAAO,GAAP,OAAO,CAAQ;QACf,UAAK,GAAL,KAAK,CAAQ;QACb,cAAS,GAAT,SAAS,CAAQ;QAEjB,cAAS,GAAT,SAAS,CAAS;IACnC,CAAC;CACP;AARD,oCAQC;AAED,iGAAiG;AACjG,MAAM,cAAc,GAA2C;IAC3D,CAAC,SAAS,EAAE,UAAU,CAAC;IACvB,CAAC,SAAS,EAAE,SAAS,CAAC;IACtB,CAAC,SAAS,EAAE,UAAU,CAAC;IACvB,CAAC,SAAS,EAAE,SAAS,CAAC;IACtB,CAAC,SAAS,EAAE,UAAU,CAAC;IACvB,CAAC,SAAS,EAAE,SAAS,CAAC;IACtB,CAAC,SAAS,EAAE,UAAU,CAAC;IACvB,CAAC,SAAS,EAAE,SAAS,CAAC;CACzB,CAAC;AAEF,6FAA6F;AAChF,QAAA,oBAAoB,GAAG,cAAc,CAAC,MAAM,CAAC;AAE1D,iFAAiF;AACpE,QAAA,mBAAmB,GAAG,SAAS,CAAC;AAC7C,wDAAwD;AAC3C,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAC9B,QAAA,mBAAmB,GAAG,SAAS,CAAC;AAE7C,MAAa,cAAc;IACvB,2DAA2D;IAClD,MAAM,CAAiB;IAEhC,YAAY,QAA2B;QACnC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,C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CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClB,SAAS;YACb,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA7DD,4DA6DC","sourcesContent":["/**\n * Products on the architecture graphs (#1179).\n *\n * A monorepo can hold several PRODUCTS, each with its own clients and servers. A product is declared\n * on its entry points with the nx tag `product:<name>` (product-resolver.ts); everything else a\n * product consists of is DERIVED here, never declared:\n *\n * - ProductMembership — the dependency graph. A project's OWN `product:` tags are FINAL (#1201): a\n * project that declares any keeps exactly its declared set. An UNTAGGED project belongs to every\n * product whose tagged project reaches it by a downward walk over `dependsOn` — and that walk stops\n * at a tagged project, whose own dependencies are reached by its own seed walk. That closure is\n * everything that can change the product's behaviour, so it is what a reviewer of that product\n * reviews. It must start from EVERY entry point, clients and servers both: a client reaches its\n * server only over HTTP, never through an nx edge, so a server is in its product only because it is\n * tagged. Why final: a project is one product's, never two by accident — the example apps depend on\n * the platform libraries, and a platform library tagged `product:platform` must not be painted\n * `example` because an example reaches it. A published library whose entry points live in OTHER\n * repos carries its own tag for exactly that reason: no in-repo walk can ever reach it correctly.\n * - RuntimeProductMembership — the runtime graph, under the same rule. A service that already carries\n * products (declared, or derived on the dependency graph above) keeps exactly them; a service with\n * none belongs to every product whose service reaches it over RUNTIME `dependsOn`, including through\n * a queue to its consumers, and that walk stops at a service with products of its own. A call from\n * one product into another product's service still shows — as the runtime EDGE between them.\n * - ProductPalette — the Product color mode's colors: a fixed palette of eight assigned in sorted\n * product-name order, a neutral fill for a box shared by EVERY product, and a dashed white box for\n * one in no product.\n *\n * Membership is stable per checkout (it depends on tags and edges, never on a diff), so it is written\n * into the committed dependencies.json / runtime-dependencies.json rather than into a sidecar.\n */\n\nimport type { EnhancedGraph } from './graph-sorter';\nimport type { RuntimeGraph } from './runtime-graph-model';\n\n// The same two text colors graph-color-modes.ts writes on every fill. Spelled here rather than\n// imported because graph-color-modes.ts imports THIS file (for the palette), and a file-import cycle\n// is refused by `no-file-import-cycles`.\nconst DARK_TEXT = '#1a1c22';\nconst LIGHT_TEXT = '#ffffff';\n\n/** One product's color, and the text color that reads on it. Data-only. */\nexport class ProductColor {\n constructor(\n public readonly product: string,\n public readonly color: string,\n public readonly fontColor: string,\n /** False for a product past the palette's eight, which is painted with the neutral fill. */\n public readonly inPalette: boolean,\n ) {}\n}\n\n/** The eight product colors, in assignment order. Distinct from every runtime and role color. */\nconst PRODUCT_COLORS: readonly (readonly [string, string])[] = [\n ['#3f6fb5', LIGHT_TEXT],\n ['#f28e2b', DARK_TEXT],\n ['#c0392b', LIGHT_TEXT],\n ['#5cb8b2', DARK_TEXT],\n ['#3d8b3d', LIGHT_TEXT],\n ['#edc948', DARK_TEXT],\n ['#8e5ea2', LIGHT_TEXT],\n ['#ff9da7', DARK_TEXT],\n];\n\n/** How many products get a color of their own; any further product uses the neutral fill. */\nexport const PRODUCT_PALETTE_SIZE = PRODUCT_COLORS.length;\n\n/** A box shared by EVERY product, and every product past the palette's eight. */\nexport const PRODUCT_SHARED_FILL = '#c9ced8';\n/** A box in no product: white, with a dashed border. */\nexport const PRODUCT_NONE_FILL = '#ffffff';\nexport const PRODUCT_NONE_BORDER = '#8a90a0';\n\nexport class ProductPalette {\n /** Every declared product, sorted, each with its color. */\n readonly colors: ProductColor[];\n\n constructor(products: readonly string[]) {\n const sorted = [...new Set(products)].sort();\n this.colors = sorted.map((product: string, index: number): ProductColor => {\n const entry = PRODUCT_COLORS[index];\n if (entry === undefined) return new ProductColor(product, PRODUCT_SHARED_FILL, DARK_TEXT, false);\n return new ProductColor(product, entry[0], entry[1], true);\n });\n }\n\n /** Every product carried by a project of the graph, as one palette. */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static fromGraph(graph: EnhancedGraph): ProductPalette {\n const all: string[] = [];\n for (const entry of Object.values(graph)) all.push(...(entry.products ?? []));\n return new ProductPalette(all);\n }\n\n names(): string[] {\n return this.colors.map((color: ProductColor): string => color.product);\n }\n\n colorOf(product: string): ProductColor {\n return (\n this.colors.find((color: ProductColor): boolean => color.product === product) ??\n new ProductColor(product, PRODUCT_SHARED_FILL, DARK_TEXT, false)\n );\n }\n\n /** True for a box carrying every product of a workspace that declares two or more. */\n sharedByAll(products: readonly string[]): boolean {\n return this.colors.length > 1 && this.colors.every((color: ProductColor): boolean => products.includes(color.product));\n }\n\n /** True when some product is past the palette's eight, so the legend must say it is neutral. */\n overflows(): boolean {\n return this.colors.some((color: ProductColor): boolean => !color.inPalette);\n }\n}\n\n/**\n * The architecture graph's product membership: declared seeds walked DOWN over `dependsOn`, where a\n * project's own declared products are final.\n */\nexport class ProductMembership {\n /**\n * @param seeds project → the products it DECLARES (its `product:` tags)\n * @returns project → its sorted products: exactly its declared set when it declares any; otherwise\n * every product whose tagged project reaches it without passing through another tagged\n * project. A project in no product is absent, so with no tag anywhere the map is empty.\n */\n compute(seeds: ReadonlyMap<string, readonly string[]>, graph: EnhancedGraph): Map<string, string[]> {\n const declared = new Map<string, readonly string[]>();\n seeds.forEach((products: readonly string[], seed: string): void => {\n if (products.length > 0 && graph[seed] !== undefined) declared.set(seed, products);\n });\n const members = new Map<string, Set<string>>();\n declared.forEach((products: readonly string[], seed: string): void => {\n members.set(seed, new Set(products));\n });\n declared.forEach((products: readonly string[], seed: string): void => {\n for (const project of this.closure(seed, graph, declared)) {\n const set = members.get(project) ?? new Set<string>();\n for (const product of products) set.add(product);\n members.set(project, set);\n }\n });\n const result = new Map<string, string[]>();\n members.forEach((set: Set<string>, project: string): void => {\n result.set(project, [...set].sort());\n });\n return result;\n }\n\n /**\n * Every UNTAGGED project `seed` reaches through `dependsOn`. A tagged project is neither collected\n * nor walked through: its products are final, and its own seed walk covers its dependencies.\n */\n private closure(seed: string, graph: EnhancedGraph, declared: ReadonlyMap<string, readonly string[]>): Set<string> {\n const seen = new Set<string>([seed]);\n const reached = new Set<string>();\n const stack = [seed];\n while (stack.length > 0) {\n const project = stack.pop() as string;\n for (const dep of graph[project]?.dependsOn ?? []) {\n if (seen.has(dep)) continue;\n seen.add(dep);\n if (declared.has(dep)) continue;\n reached.add(dep);\n stack.push(dep);\n }\n }\n return reached;\n }\n}\n\n/**\n * The runtime graph's product membership: services that carry products walked over RUNTIME\n * `dependsOn`, where a service's own products are final.\n */\nexport class RuntimeProductMembership {\n /**\n * Stamp `products` onto every service of `graph` that some product reaches. Seeds are the\n * services whose dependencies.json entry carries `products`, and each keeps exactly those; a\n * service with none gets every product whose seed reaches it without passing through another\n * seed. A `queue:<Api.method>` dependency is followed to that queue's consumers. A service in no\n * product gets no field.\n */\n apply(graph: RuntimeGraph, projects: EnhancedGraph): void {\n const seeds = new Map<string, readonly string[]>();\n for (const name of Object.keys(graph.services)) {\n const own = projects[name]?.products ?? [];\n if (own.length > 0) seeds.set(name, own);\n }\n const members = new Map<string, Set<string>>();\n seeds.forEach((own: readonly string[], name: string): void => {\n members.set(name, new Set(own));\n });\n seeds.forEach((own: readonly string[], name: string): void => {\n for (const reached of this.closure(name, graph, seeds)) {\n const set = members.get(reached) ?? new Set<string>();\n for (const product of own) set.add(product);\n members.set(reached, set);\n }\n });\n members.forEach((set: Set<string>, name: string): void => {\n const service = graph.services[name];\n if (service !== undefined) service.products = [...set].sort();\n });\n }\n\n /** Every service WITHOUT products of its own that `seed` reaches; a seed is neither collected nor walked through. */\n private closure(seed: string, graph: RuntimeGraph, seeds: ReadonlyMap<string, readonly string[]>): Set<string> {\n const seen = new Set<string>([seed]);\n const reached = new Set<string>();\n const stack = [seed];\n while (stack.length > 0) {\n const name = stack.pop() as string;\n for (const next of this.callees(name, graph)) {\n if (seen.has(next) || graph.services[next] === undefined) continue;\n seen.add(next);\n if (seeds.has(next)) continue;\n reached.add(next);\n stack.push(next);\n }\n }\n return reached;\n }\n\n /** The services one service calls: direct ones, and the consumers behind every queue it feeds. */\n private callees(name: string, graph: RuntimeGraph): string[] {\n const callees: string[] = [];\n for (const dep of graph.services[name]?.dependsOn ?? []) {\n if (!dep.startsWith('queue:')) {\n callees.push(dep);\n continue;\n }\n callees.push(...(graph.queues[dep.slice('queue:'.length)]?.consumedBy ?? []));\n }\n return callees;\n }\n}\n"]}
@@ -62,11 +62,12 @@ export interface GraphEntry {
62
62
  */
63
63
  cutLegacyCycle?: string[];
64
64
  /**
65
- * The products this project belongs to (#1179), sorted: every product whose `product:<name>`-tagged
66
- * project reaches it by a downward walk over `dependsOn` (a tagged project is in its own products).
67
- * It is the project's blast radius — a change here is a change to each of these products. DERIVED,
68
- * never declared on a library; absent when no product reaches it (and everywhere when no project
69
- * carries a `product:` tag). See graph-products.ts.
65
+ * The products this project belongs to (#1179), sorted. A project carrying `product:<name>` tags
66
+ * has exactly those — its declared tags are FINAL (#1201). An untagged project has every product
67
+ * whose tagged project reaches it by a downward walk over `dependsOn` that does not pass through
68
+ * another tagged project. It is the project's blast radius — a change here is a change to each of
69
+ * these products. Absent when no product reaches it (and everywhere when no project carries a
70
+ * `product:` tag). See graph-products.ts.
70
71
  */
71
72
  products?: string[];
72
73
  shortDescription?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"graph-sorter.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-sorter.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAoGH,4DAyCC;AASD,wDAgBC;AAnKD,iDAAsD;AAwFtD;;;;;;;;GAQG;AACH,SAAgB,wBAAwB,CAAC,KAA+B;IACpE,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IACpC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEvC,OAAO,SAAS,CAAC,IAAI,GAAG,WAAW,CAAC,MAAM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AAM,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,+DAA+D;IAC/D,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;QACjC,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE,CAAC;YAC1B,6CAA6C;YAC7C,MAAM,CAAC,OAAO,CAAC,GAAG;gBACd,KAAK,EAAE,UAAU;gBACjB,SAAS,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;aAC3C,CAAC;QACN,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Graph Sorter\n *\n * Performs topological sorting on the dependency graph to:\n * 1. Detect circular dependencies (fails if cycle found)\n * 2. Assign level numbers to each project (level 0 = no deps, level 1 = depends on level 0, etc.)\n * 3. Group projects into layers for deterministic ordering\n */\n\nimport type { ProjectApiRelations } from './api-usage/api-relations';\nimport { ProjectCycleDetector } from './graph-cycles';\n\n/**\n * Graph entry with level metadata plus AI-oriented metadata filled in by\n * enrichGraph() (lib/graph-metadata.ts) before the graph is saved:\n * - framework: the project's libType — the SET of runtime environments it is\n * validated to run in, drawn from browser | react | angular | node | express\n * (e.g. [\"browser\",\"node\"]); from its `framework:` nx tags (source of truth)\n * or inferred from package.json deps\n * - shortDescription: summary extracted from the project's responsibilities.md\n * - responsibilitiesFile: repo-relative path to the FULL responsibilities doc\n * - designFile: repo-relative path to the generated DI design.json (only for\n * project.json projects)\n * - apiRelations: for each api-lib in `dependsOn`, WHY the edge exists — the\n * APIs this project implements (serves) and/or uses (calls), each with its\n * transport (rpc | pubsub). Derived by scanning source (see api-usage/).\n */\nexport interface GraphEntry {\n /**\n * The project's row: its dependency depth (0 = no deps) — except that every server, client and\n * app (APP_ROLES) is pinned to the TOP level, and a bundle above the apps it aggregates (#1179,\n * graph-entry-levels.ts). Every dependency still sits strictly below its dependent.\n */\n level: number;\n dependsOn: string[];\n framework?: string[];\n role?: string;\n /**\n * The name CLIENTS address this app by at runtime (`new ClientConfig('helper-fsdb')`) — its\n * deployed service name, DECLARED in project.json as metadata.webpieces.serviceName. Absent for\n * anything nothing calls by name (libraries, browser apps). See service-name-resolver.ts.\n */\n serviceName?: string;\n /**\n * The service(s) this project's clients call when the call site cannot carry a literal\n * `ClientConfig` — the symmetric half of `serviceName`. DECLARED in project.json as\n * metadata.webpieces.callsService, either a single service name (every untargeted `uses` aims\n * there) or an `{ apiClassName: serviceName }` map (a client that calls several). Absent for a\n * project that never calls anything, or one whose call sites all carry literals.\n * See service-name-resolver.ts.\n */\n callsService?: string | Record<string, string>;\n /**\n * When false, the project is hidden from the rendered architecture graphs\n * (its box AND every edge touching it are omitted from dependencies.html and\n * the runtime graph). It stays in this JSON so the data view is complete.\n * Absent means drawn (the default). From the project's `drawOnGraph:` nx tag.\n */\n drawOnGraph?: boolean;\n /**\n * Target service names whose RUNTIME edge from this project is cut out of leveling and cycle\n * detection, from this project's `cutLegacyCycle:<target>` nx tags. Per EDGE, not per project.\n * An admission of legacy debt, never an approved pattern — see cut-legacy-cycle-resolver.ts.\n * Absent (the overwhelmingly normal case) means this project cuts nothing.\n */\n cutLegacyCycle?: string[];\n /**\n * The products this project belongs to (#1179), sorted: every product whose `product:<name>`-tagged\n * project reaches it by a downward walk over `dependsOn` (a tagged project is in its own products).\n * It is the project's blast radius — a change here is a change to each of these products. DERIVED,\n * never declared on a library; absent when no product reaches it (and everywhere when no project\n * carries a `product:` tag). See graph-products.ts.\n */\n products?: string[];\n shortDescription?: string;\n responsibilitiesFile?: string;\n designFile?: string;\n apiRelations?: ProjectApiRelations;\n runtimeDeclaration?: string;\n runtimeComposition?: boolean;\n /**\n * The @webpieces runtime packages this project's OWN package.json declares — http-routing,\n * http-server, http-client-node, http-client-browser, cloudtasks-client. Omitted when it\n * declares none, so TOTAL absence across the file means the file predates this field and\n * nothing is auto-hidden (see runtime-graph.ts). Core/util/logging packages are deliberately\n * not markers; see runtime-participant-resolver.ts for why.\n *\n * The runtime graph ORs this over a node's library closure: a server whose whole webpieces\n * stack comes from a shared bootstrap lib participates even though it declares nothing itself.\n */\n webpiecesRuntime?: string[];\n}\n\n/**\n * Enhanced graph format with level information\n */\nexport type EnhancedGraph = Record<string, GraphEntry>;\n\n/**\n * Compute topological layers for dependency graph using Kahn's algorithm\n *\n * Projects are grouped into layers where each layer only depends on previous layers.\n * Throws an error if a circular dependency is detected.\n *\n * @param graph - Dependency graph { project: [deps] }\n * @returns Array of layers, each containing sorted project names\n */\nexport function computeTopologicalLayers(graph: Record<string, string[]>): string[][] {\n const layers: string[][] = [];\n const processed = new Set<string>();\n const allProjects = Object.keys(graph);\n\n while (processed.size < allProjects.length) {\n const currentLayer: string[] = [];\n\n for (const project of allProjects) {\n if (processed.has(project)) continue;\n\n const deps = graph[project] || [];\n // Check if all dependencies are in previous layers (already processed)\n const allDepsInPrevLayers = deps.every((dep) => processed.has(dep));\n\n if (allDepsInPrevLayers) {\n currentLayer.push(project);\n }\n }\n\n if (currentLayer.length === 0) {\n // No progress made = circular dependency. ProjectCycleDetector is the ONE cycle\n // implementation in this package — it names every chain, in project keys, with the\n // fix — so this reports through it rather than keeping a second, weaker DFS here.\n new ProjectCycleDetector().assertAcyclic(graph, 'the project graph');\n // Unreachable: Kahn only stalls on a cycle, and the assert above throws on every one.\n const remaining = allProjects.filter((p: string): boolean => !processed.has(p));\n throw new Error(\n `Topological sort stalled with no cycle to report — projects left unlayered: ${remaining.join(', ')}`,\n );\n }\n\n // Sort alphabetically within layer for deterministic output\n currentLayer.sort();\n layers.push(currentLayer);\n\n // Mark as processed\n currentLayer.forEach((p) => processed.add(p));\n }\n\n return layers;\n}\n\n/**\n * Sort graph in topological order with alphabetical sorting within layers\n * Returns enhanced format with level metadata\n *\n * @param graph - Unsorted dependency graph { project: [deps] }\n * @returns Sorted graph with level metadata { project: { level: number, dependsOn: [deps] } }\n */\nexport function sortGraphTopologically(graph: Record<string, string[]>): EnhancedGraph {\n const layers = computeTopologicalLayers(graph);\n const result: EnhancedGraph = {};\n\n // Add projects layer by layer (dependencies before dependents)\n layers.forEach((layer, levelIndex) => {\n for (const project of layer) {\n // Already sorted alphabetically within layer\n result[project] = {\n level: levelIndex,\n dependsOn: (graph[project] || []).sort(),\n };\n }\n });\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"graph-sorter.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/graph-sorter.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAqGH,4DAyCC;AASD,wDAgBC;AApKD,iDAAsD;AAyFtD;;;;;;;;GAQG;AACH,SAAgB,wBAAwB,CAAC,KAA+B;IACpE,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IACpC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEvC,OAAO,SAAS,CAAC,IAAI,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;QACzC,MAAM,YAAY,GAAa,EAAE,CAAC;QAElC,KAAK,MAAM,OAAO,IAAI,WAAW,EAAE,CAAC;YAChC,IAAI,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC;gBAAE,SAAS;YAErC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAClC,uEAAuE;YACvE,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAEpE,IAAI,mBAAmB,EAAE,CAAC;gBACtB,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC;QAED,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,gFAAgF;YAChF,mFAAmF;YACnF,kFAAkF;YAClF,IAAI,mCAAoB,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;YACrE,sFAAsF;YACtF,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAChF,MAAM,IAAI,KAAK,CACX,+EAA+E,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxG,CAAC;QACN,CAAC;QAED,4DAA4D;QAC5D,YAAY,CAAC,IAAI,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE1B,oBAAoB;QACpB,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAC,KAA+B;IAClE,MAAM,MAAM,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,+DAA+D;IAC/D,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;QACjC,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE,CAAC;YAC1B,6CAA6C;YAC7C,MAAM,CAAC,OAAO,CAAC,GAAG;gBACd,KAAK,EAAE,UAAU;gBACjB,SAAS,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;aAC3C,CAAC;QACN,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Graph Sorter\n *\n * Performs topological sorting on the dependency graph to:\n * 1. Detect circular dependencies (fails if cycle found)\n * 2. Assign level numbers to each project (level 0 = no deps, level 1 = depends on level 0, etc.)\n * 3. Group projects into layers for deterministic ordering\n */\n\nimport type { ProjectApiRelations } from './api-usage/api-relations';\nimport { ProjectCycleDetector } from './graph-cycles';\n\n/**\n * Graph entry with level metadata plus AI-oriented metadata filled in by\n * enrichGraph() (lib/graph-metadata.ts) before the graph is saved:\n * - framework: the project's libType — the SET of runtime environments it is\n * validated to run in, drawn from browser | react | angular | node | express\n * (e.g. [\"browser\",\"node\"]); from its `framework:` nx tags (source of truth)\n * or inferred from package.json deps\n * - shortDescription: summary extracted from the project's responsibilities.md\n * - responsibilitiesFile: repo-relative path to the FULL responsibilities doc\n * - designFile: repo-relative path to the generated DI design.json (only for\n * project.json projects)\n * - apiRelations: for each api-lib in `dependsOn`, WHY the edge exists — the\n * APIs this project implements (serves) and/or uses (calls), each with its\n * transport (rpc | pubsub). Derived by scanning source (see api-usage/).\n */\nexport interface GraphEntry {\n /**\n * The project's row: its dependency depth (0 = no deps) — except that every server, client and\n * app (APP_ROLES) is pinned to the TOP level, and a bundle above the apps it aggregates (#1179,\n * graph-entry-levels.ts). Every dependency still sits strictly below its dependent.\n */\n level: number;\n dependsOn: string[];\n framework?: string[];\n role?: string;\n /**\n * The name CLIENTS address this app by at runtime (`new ClientConfig('helper-fsdb')`) — its\n * deployed service name, DECLARED in project.json as metadata.webpieces.serviceName. Absent for\n * anything nothing calls by name (libraries, browser apps). See service-name-resolver.ts.\n */\n serviceName?: string;\n /**\n * The service(s) this project's clients call when the call site cannot carry a literal\n * `ClientConfig` — the symmetric half of `serviceName`. DECLARED in project.json as\n * metadata.webpieces.callsService, either a single service name (every untargeted `uses` aims\n * there) or an `{ apiClassName: serviceName }` map (a client that calls several). Absent for a\n * project that never calls anything, or one whose call sites all carry literals.\n * See service-name-resolver.ts.\n */\n callsService?: string | Record<string, string>;\n /**\n * When false, the project is hidden from the rendered architecture graphs\n * (its box AND every edge touching it are omitted from dependencies.html and\n * the runtime graph). It stays in this JSON so the data view is complete.\n * Absent means drawn (the default). From the project's `drawOnGraph:` nx tag.\n */\n drawOnGraph?: boolean;\n /**\n * Target service names whose RUNTIME edge from this project is cut out of leveling and cycle\n * detection, from this project's `cutLegacyCycle:<target>` nx tags. Per EDGE, not per project.\n * An admission of legacy debt, never an approved pattern — see cut-legacy-cycle-resolver.ts.\n * Absent (the overwhelmingly normal case) means this project cuts nothing.\n */\n cutLegacyCycle?: string[];\n /**\n * The products this project belongs to (#1179), sorted. A project carrying `product:<name>` tags\n * has exactly those — its declared tags are FINAL (#1201). An untagged project has every product\n * whose tagged project reaches it by a downward walk over `dependsOn` that does not pass through\n * another tagged project. It is the project's blast radius — a change here is a change to each of\n * these products. Absent when no product reaches it (and everywhere when no project carries a\n * `product:` tag). See graph-products.ts.\n */\n products?: string[];\n shortDescription?: string;\n responsibilitiesFile?: string;\n designFile?: string;\n apiRelations?: ProjectApiRelations;\n runtimeDeclaration?: string;\n runtimeComposition?: boolean;\n /**\n * The @webpieces runtime packages this project's OWN package.json declares — http-routing,\n * http-server, http-client-node, http-client-browser, cloudtasks-client. Omitted when it\n * declares none, so TOTAL absence across the file means the file predates this field and\n * nothing is auto-hidden (see runtime-graph.ts). Core/util/logging packages are deliberately\n * not markers; see runtime-participant-resolver.ts for why.\n *\n * The runtime graph ORs this over a node's library closure: a server whose whole webpieces\n * stack comes from a shared bootstrap lib participates even though it declares nothing itself.\n */\n webpiecesRuntime?: string[];\n}\n\n/**\n * Enhanced graph format with level information\n */\nexport type EnhancedGraph = Record<string, GraphEntry>;\n\n/**\n * Compute topological layers for dependency graph using Kahn's algorithm\n *\n * Projects are grouped into layers where each layer only depends on previous layers.\n * Throws an error if a circular dependency is detected.\n *\n * @param graph - Dependency graph { project: [deps] }\n * @returns Array of layers, each containing sorted project names\n */\nexport function computeTopologicalLayers(graph: Record<string, string[]>): string[][] {\n const layers: string[][] = [];\n const processed = new Set<string>();\n const allProjects = Object.keys(graph);\n\n while (processed.size < allProjects.length) {\n const currentLayer: string[] = [];\n\n for (const project of allProjects) {\n if (processed.has(project)) continue;\n\n const deps = graph[project] || [];\n // Check if all dependencies are in previous layers (already processed)\n const allDepsInPrevLayers = deps.every((dep) => processed.has(dep));\n\n if (allDepsInPrevLayers) {\n currentLayer.push(project);\n }\n }\n\n if (currentLayer.length === 0) {\n // No progress made = circular dependency. ProjectCycleDetector is the ONE cycle\n // implementation in this package — it names every chain, in project keys, with the\n // fix — so this reports through it rather than keeping a second, weaker DFS here.\n new ProjectCycleDetector().assertAcyclic(graph, 'the project graph');\n // Unreachable: Kahn only stalls on a cycle, and the assert above throws on every one.\n const remaining = allProjects.filter((p: string): boolean => !processed.has(p));\n throw new Error(\n `Topological sort stalled with no cycle to report — projects left unlayered: ${remaining.join(', ')}`,\n );\n }\n\n // Sort alphabetically within layer for deterministic output\n currentLayer.sort();\n layers.push(currentLayer);\n\n // Mark as processed\n currentLayer.forEach((p) => processed.add(p));\n }\n\n return layers;\n}\n\n/**\n * Sort graph in topological order with alphabetical sorting within layers\n * Returns enhanced format with level metadata\n *\n * @param graph - Unsorted dependency graph { project: [deps] }\n * @returns Sorted graph with level metadata { project: { level: number, dependsOn: [deps] } }\n */\nexport function sortGraphTopologically(graph: Record<string, string[]>): EnhancedGraph {\n const layers = computeTopologicalLayers(graph);\n const result: EnhancedGraph = {};\n\n // Add projects layer by layer (dependencies before dependents)\n layers.forEach((layer, levelIndex) => {\n for (const project of layer) {\n // Already sorted alphabetically within layer\n result[project] = {\n level: levelIndex,\n dependsOn: (graph[project] || []).sort(),\n };\n }\n });\n\n return result;\n}\n"]}
@@ -6,9 +6,11 @@
6
6
  * "tags": ["framework:angular", "role:client", "product:lang"]
7
7
  *
8
8
  * A monorepo holding several products tags each product's ENTRY POINTS (servers, clients, apps —
9
- * the `product-tags` rule makes that required) and the architecture graphs derive everything else:
10
- * a library belongs to every product whose tagged project reaches it (graph-products.ts), so a
11
- * library never carries a hand-maintained product tag.
9
+ * the `product-tags` rule makes that required) and the architecture graphs derive the rest: an
10
+ * UNTAGGED library belongs to every product whose tagged project reaches it (graph-products.ts).
11
+ * A library MAY carry its own tag — a published library whose entry points live in other repos, which
12
+ * no in-repo walk can reach correctly — and a project's declared tags are FINAL (#1201): a tagged
13
+ * project keeps exactly its declared set, and no other product's walk paints it or passes through it.
12
14
  *
13
15
  * Several tags are allowed (`product:bugfixer` + `product:helper`). Each name must be lowercase
14
16
  * kebab (`lang`, `job-finder`); a malformed tag (`product:`, `product:Lang`) is a problem that fails
@@ -7,9 +7,11 @@
7
7
  * "tags": ["framework:angular", "role:client", "product:lang"]
8
8
  *
9
9
  * A monorepo holding several products tags each product's ENTRY POINTS (servers, clients, apps —
10
- * the `product-tags` rule makes that required) and the architecture graphs derive everything else:
11
- * a library belongs to every product whose tagged project reaches it (graph-products.ts), so a
12
- * library never carries a hand-maintained product tag.
10
+ * the `product-tags` rule makes that required) and the architecture graphs derive the rest: an
11
+ * UNTAGGED library belongs to every product whose tagged project reaches it (graph-products.ts).
12
+ * A library MAY carry its own tag — a published library whose entry points live in other repos, which
13
+ * no in-repo walk can reach correctly — and a project's declared tags are FINAL (#1201): a tagged
14
+ * project keeps exactly its declared set, and no other product's walk paints it or passes through it.
13
15
  *
14
16
  * Several tags are allowed (`product:bugfixer` + `product:helper`). Each name must be lowercase
15
17
  * kebab (`lang`, `job-finder`); a malformed tag (`product:`, `product:Lang`) is a problem that fails
@@ -1 +1 @@
1
- {"version":3,"file":"product-resolver.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/product-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAIU,QAAA,kBAAkB,GAAG,UAAU,CAAC;AAE7C,kGAAkG;AAClG,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAEhD,MAAa,iBAAiB;IAGN;IAEA;IAJpB;IACI,kGAAkG;IAClF,QAAkB;IAClC,2FAA2F;IAC3E,QAAkB;QAFlB,aAAQ,GAAR,QAAQ,CAAU;QAElB,aAAQ,GAAR,QAAQ,CAAU;IACnC,CAAC;CACP;AAPD,8CAOC;AAED,MAAa,eAAe;IACxB,2DAA2D;IAC3D,OAAO,CAAC,IAAiB;QACrB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC1B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,0BAAkB,CAAC;gBAAE,SAAS;YAClD,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,0BAAkB,CAAC,MAAM,CAAC,CAAC;YAClD,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACnB,SAAS;YACb,CAAC;YACD,QAAQ,CAAC,IAAI,CACT,GAAG,IAAI,CAAC,IAAI,kBAAkB,GAAG,+DAA+D;gBAC5F,mDAAmD,CAC1D,CAAC;QACN,CAAC;QACD,OAAO,IAAI,iBAAiB,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED,WAAW,CAAC,IAAY;QACpB,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACJ;AAvBD,0CAuBC","sourcesContent":["/**\n * Product Resolver (#1179)\n *\n * Reads the products a project DECLARES with the nx tag `product:<name>` on its project.json:\n *\n * \"tags\": [\"framework:angular\", \"role:client\", \"product:lang\"]\n *\n * A monorepo holding several products tags each product's ENTRY POINTS (servers, clients, apps —\n * the `product-tags` rule makes that required) and the architecture graphs derive everything else:\n * a library belongs to every product whose tagged project reaches it (graph-products.ts), so a\n * library never carries a hand-maintained product tag.\n *\n * Several tags are allowed (`product:bugfixer` + `product:helper`). Each name must be lowercase\n * kebab (`lang`, `job-finder`); a malformed tag (`product:`, `product:Lang`) is a problem that fails\n * generation with the project named — the same way two `role:` tags do (role-resolver.ts).\n *\n * Why a tag and not a config key: it moves with the project, nx understands it for free\n * (`nx show projects --projects tag:product:lang`), and a tag an older plugin does not know is ignored,\n * so a consumer can tag BEFORE the release that reads the tags ships.\n */\n\nimport { ProjectInfo } from './project-info';\n\nexport const PRODUCT_TAG_PREFIX = 'product:';\n\n/** Lowercase kebab: letters and digits, single dashes between words, no leading/trailing dash. */\nconst PRODUCT_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;\n\nexport class ProductResolution {\n constructor(\n /** The declared product names, sorted and de-duplicated; empty when the project declares none. */\n public readonly products: string[],\n /** One line per malformed tag, naming the project; empty when every tag is well formed. */\n public readonly problems: string[],\n ) {}\n}\n\nexport class ProductResolver {\n /** Every `product:` tag the project carries, validated. */\n resolve(info: ProjectInfo): ProductResolution {\n const products = new Set<string>();\n const problems: string[] = [];\n for (const tag of info.tags) {\n if (!tag.startsWith(PRODUCT_TAG_PREFIX)) continue;\n const name = tag.slice(PRODUCT_TAG_PREFIX.length);\n if (this.isValidName(name)) {\n products.add(name);\n continue;\n }\n problems.push(\n `${info.name}: product tag '${tag}' is malformed — the name after 'product:' must be lowercase ` +\n `kebab (e.g. 'product:lang', 'product:job-finder')`,\n );\n }\n return new ProductResolution([...products].sort(), problems);\n }\n\n isValidName(name: string): boolean {\n return PRODUCT_NAME.test(name);\n }\n}\n"]}
1
+ {"version":3,"file":"product-resolver.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/product-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAIU,QAAA,kBAAkB,GAAG,UAAU,CAAC;AAE7C,kGAAkG;AAClG,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAEhD,MAAa,iBAAiB;IAGN;IAEA;IAJpB;IACI,kGAAkG;IAClF,QAAkB;IAClC,2FAA2F;IAC3E,QAAkB;QAFlB,aAAQ,GAAR,QAAQ,CAAU;QAElB,aAAQ,GAAR,QAAQ,CAAU;IACnC,CAAC;CACP;AAPD,8CAOC;AAED,MAAa,eAAe;IACxB,2DAA2D;IAC3D,OAAO,CAAC,IAAiB;QACrB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC1B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,0BAAkB,CAAC;gBAAE,SAAS;YAClD,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,0BAAkB,CAAC,MAAM,CAAC,CAAC;YAClD,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACnB,SAAS;YACb,CAAC;YACD,QAAQ,CAAC,IAAI,CACT,GAAG,IAAI,CAAC,IAAI,kBAAkB,GAAG,+DAA+D;gBAC5F,mDAAmD,CAC1D,CAAC;QACN,CAAC;QACD,OAAO,IAAI,iBAAiB,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED,WAAW,CAAC,IAAY;QACpB,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACJ;AAvBD,0CAuBC","sourcesContent":["/**\n * Product Resolver (#1179)\n *\n * Reads the products a project DECLARES with the nx tag `product:<name>` on its project.json:\n *\n * \"tags\": [\"framework:angular\", \"role:client\", \"product:lang\"]\n *\n * A monorepo holding several products tags each product's ENTRY POINTS (servers, clients, apps —\n * the `product-tags` rule makes that required) and the architecture graphs derive the rest: an\n * UNTAGGED library belongs to every product whose tagged project reaches it (graph-products.ts).\n * A library MAY carry its own tag — a published library whose entry points live in other repos, which\n * no in-repo walk can reach correctly — and a project's declared tags are FINAL (#1201): a tagged\n * project keeps exactly its declared set, and no other product's walk paints it or passes through it.\n *\n * Several tags are allowed (`product:bugfixer` + `product:helper`). Each name must be lowercase\n * kebab (`lang`, `job-finder`); a malformed tag (`product:`, `product:Lang`) is a problem that fails\n * generation with the project named — the same way two `role:` tags do (role-resolver.ts).\n *\n * Why a tag and not a config key: it moves with the project, nx understands it for free\n * (`nx show projects --projects tag:product:lang`), and a tag an older plugin does not know is ignored,\n * so a consumer can tag BEFORE the release that reads the tags ships.\n */\n\nimport { ProjectInfo } from './project-info';\n\nexport const PRODUCT_TAG_PREFIX = 'product:';\n\n/** Lowercase kebab: letters and digits, single dashes between words, no leading/trailing dash. */\nconst PRODUCT_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;\n\nexport class ProductResolution {\n constructor(\n /** The declared product names, sorted and de-duplicated; empty when the project declares none. */\n public readonly products: string[],\n /** One line per malformed tag, naming the project; empty when every tag is well formed. */\n public readonly problems: string[],\n ) {}\n}\n\nexport class ProductResolver {\n /** Every `product:` tag the project carries, validated. */\n resolve(info: ProjectInfo): ProductResolution {\n const products = new Set<string>();\n const problems: string[] = [];\n for (const tag of info.tags) {\n if (!tag.startsWith(PRODUCT_TAG_PREFIX)) continue;\n const name = tag.slice(PRODUCT_TAG_PREFIX.length);\n if (this.isValidName(name)) {\n products.add(name);\n continue;\n }\n problems.push(\n `${info.name}: product tag '${tag}' is malformed — the name after 'product:' must be lowercase ` +\n `kebab (e.g. 'product:lang', 'product:job-finder')`,\n );\n }\n return new ProductResolution([...products].sort(), problems);\n }\n\n isValidName(name: string): boolean {\n return PRODUCT_NAME.test(name);\n }\n}\n"]}
@@ -54,10 +54,12 @@ export interface RuntimeService {
54
54
  */
55
55
  drawOnGraph?: boolean;
56
56
  /**
57
- * The products this service belongs to (#1179), sorted: every product whose tagged service
58
- * (its dependencies.json `products`) reaches it over RUNTIME `dependsOn`, through a queue to its
59
- * consumers included — so a call into another product's service shows in this product's view.
60
- * Absent for a service in no product. See graph-products.ts.
57
+ * The products this service belongs to (#1179), sorted. A service whose dependencies.json entry
58
+ * carries `products` keeps exactly those — they are final (#1201). A service with none gets every
59
+ * product whose service reaches it over RUNTIME `dependsOn` (through a queue to its consumers
60
+ * included) without passing through another service that carries products; a call into another
61
+ * product's service shows as the runtime edge, not as a product. Absent for a service in no
62
+ * product. See graph-products.ts.
61
63
  */
62
64
  products?: string[];
63
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-graph-model.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/runtime-graph-model.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG","sourcesContent":["/**\n * Runtime Graph model\n *\n * The serialization DTOs for architecture/runtime-dependencies.json. Split out of runtime-graph.ts,\n * which owns the DERIVATION (and had grown past the file-size limit), so the committed data shape\n * can be read on its own — it is what every consumer of the file, and any future Terraform\n * cross-check, actually programs against.\n *\n * Interfaces rather than classes: these are parsed straight out of JSON with `JSON.parse`, so a\n * class would only ever be a shape assertion over a plain object, never a constructed instance.\n */\n\nimport type {\n ApiRef,\n ApiTransport,\n ExternalSystemDeclaration,\n ExternalSystemKind,\n} from './api-usage/api-relations';\n\nexport interface RuntimeService {\n level: number;\n /**\n * The project's declared nx role — 'server' or 'client' (a library is never a node). Carried so\n * the viz can LABEL the node with what it actually is: it used to infer the role from\n * `implements.length > 0`, which labelled every relation-less server \"client\". Optional so a\n * runtime-dependencies.json written before this field existed still parses and still renders\n * exactly as it did (the visualizer falls back to the old inference).\n */\n role?: string;\n /**\n * The name clients address this service by (`new ClientConfig('helper-fsdb')`), declared in its\n * project.json. Absent for a service nothing calls by name (e.g. a browser app).\n */\n serviceName?: string;\n /**\n * The service(s) this node's clients call when the call site carries no literal `ClientConfig`,\n * declared in its project.json (metadata.webpieces.callsService). A single name, or an\n * `{ apiClassName: serviceName }` map. Absent when the node declares no target. Mirrors\n * GraphEntry.callsService; it is the CALLING-side counterpart of `serviceName`.\n */\n callsService?: string | Record<string, string>;\n implements: string[];\n /**\n * apiClassName -> the LIBRARY project whose apiRelations declared that implements, for the apis\n * this service serves through an embedded library rather than its own source (e.g. a shared\n * route-registration lib). Answers \"who implements WarmupApi, and where did that come from?\",\n * which previously required walking the dependsOn closure by hand.\n */\n implementsVia?: Record<string, string>;\n uses: string[];\n dependsOn: string[];\n /** Reviewed binding provenance and runtime conditions, retained for compact detail views. */\n wiringUses?: ApiRef[];\n wiringImplements?: ApiRef[];\n /**\n * When false, this service is hidden from the rendered runtime graph (its\n * node AND every edge touching it are omitted from the HTML/DOT). It stays\n * in runtime-dependencies.json so the data view is complete. Absent means\n * drawn (the default). Mirrors GraphEntry.drawOnGraph from the `drawOnGraph:`\n * nx tag.\n */\n drawOnGraph?: boolean;\n /**\n * The products this service belongs to (#1179), sorted: every product whose tagged service\n * (its dependencies.json `products`) reaches it over RUNTIME `dependsOn`, through a queue to its\n * consumers included — so a call into another product's service shows in this product's view.\n * Absent for a service in no product. See graph-products.ts.\n */\n products?: string[];\n}\n\nexport interface RuntimeApi {\n implementedBy: string[];\n usedBy: string[];\n /** Transport of this API — 'rpc' (direct call) or 'pubsub' (delivered through a queue). */\n type?: ApiTransport;\n /**\n * The api-lib project that OWNS this contract. For a contract nothing in-repo implements, this\n * is the external library the calls leave the repo through (`lib-firestore`, `lib-gmail`), which\n * is what the runtime viz labels its terminal external nodes with.\n */\n owner?: string;\n /**\n * Set when the contract carries an `@externalSystem <kind> [label]` JSDoc tag — the vendor seam\n * declaring WHAT it is a seam to, so the viz can draw firestore as a database rather than as the\n * same grey box as every other external. Absent on everything else.\n */\n externalSystem?: ExternalSystemDeclaration;\n}\n\nexport interface RuntimeEdge {\n from: string;\n to: string;\n via: string[];\n /**\n * Transport of this edge. 'rpc' → a direct call arrow. 'pubsub' → the producer enqueues and the\n * consumer is delivered later, so the runtime viz draws it as producer → QUEUE → consumer.\n * Edges are split by transport, so every edge is a single kind.\n */\n type?: ApiTransport;\n /**\n * `\"ApiClassName.methodName\"` — the queue this edge flows through. Present iff `type` is\n * 'pubsub'. Queues are per METHOD, not per service pair, because that is the unit Cloud Tasks\n * (and Terraform) actually create, so two services exchanging three queued methods are three\n * queues rather than one arrow.\n */\n queue?: string;\n /**\n * True when the CALLING project carries a `cutLegacyCycle:<target>` nx tag naming this edge's\n * target — an admission that this hop closes a REAL cycle that is being tolerated as legacy\n * debt, not a claim that it is harmless. The edge is still drawn (dashed, labelled \"legacy\n * cycle\"); it is only excluded from leveling and cycle detection. Absent on every other edge.\n */\n cutLegacyCycle?: boolean;\n}\n\n/**\n * One Cloud Tasks queue: the async seam between a producer and a consumer, at METHOD granularity.\n *\n * `producedBy` and `consumedBy` are deliberately not symmetric in confidence — see\n * {@link ApiRef.methodsInferred}. The consumer is derived from `addRoutes` plus the contract's\n * method table and is exact; the producer is attributed to every queued method of the contract it\n * built a client for, because which methods it enqueues is not statically recoverable.\n */\nexport interface RuntimeQueue {\n api: string;\n method: string;\n /** `@Queue(...)` override, else `${Api}-${method}` — the name Terraform must match 1:1. */\n queueName: string;\n producedBy: string[];\n consumedBy: string[];\n}\n\n/**\n * An endpoint driven by something that is NOT an in-repo caller — a clock or an outside system.\n * These never appear as runtime EDGES (there is no in-repo `from`), which is exactly why they were\n * invisible until now: a nightly sweep and a GCP push subscription are real runtime entry points\n * with real Terraform behind them, and the graph showed neither.\n */\nexport interface RuntimeTrigger {\n /** 'cron' → a scheduler fires it; 'external' → a system outside this repo posts to it. */\n kind: 'cron' | 'external';\n api: string;\n method: string;\n /** The service that SERVES the endpoint (the arrow's head). */\n service: string;\n /** Present for 'cron': the Cloud Scheduler job / queue name Terraform must match. */\n queueName?: string;\n /**\n * Present for 'external': WHO outside this repo posts to it, declared as\n * `@Endpoint(POST, p, WRITE, EXTERNAL, { calledBy: 'twilio' })`.\n *\n * The SAME `(kind,label)` an OUTBOUND {@link RuntimeExternalSystem} carries, so an inbound\n * `saas twilio` and an outbound `saas twilio` share a node identity and converge on ONE box —\n * `label` is the identity here too, not display text.\n *\n * Optional only for graphs generated BEFORE the caller was required; generation now fails rather\n * than emitting an `external` method without one.\n */\n caller?: ExternalSystemDeclaration;\n}\n\nexport interface RuntimeUnresolved {\n service: string;\n api: string;\n}\n\n/**\n * A system outside this repo that a service TALKS TO, drawn with a shape that says what it is\n * (a database as a cylinder, a bucket as a folder) instead of the one grey box every external\n * used to collapse into.\n *\n * Two declaration sites feed this, because the two real cases differ in whether a contract exists:\n *\n * - **Wrapped** — the repo has a vendor seam (`FirestoreAdminApi`), so the kind is declared with an\n * `@externalSystem <kind> [label]` JSDoc tag on the contract. A decorator cannot go on a TS\n * `interface`, and these seams are interfaces, so JSDoc is the only marker that fits in place.\n * - **Unwrapped** — the service opens the connection itself with no contract to mark (a `pg.Pool`,\n * a TypeORM `DataSource`), so the declaration is an `external:<kind>:<identity>` nx tag on that\n * project's project.json.\n *\n * `label` is the node IDENTITY, not just display text: two services declaring `postgres` converge on\n * ONE node with two arrows into it, rather than drawing a database each.\n */\nexport interface RuntimeExternalSystem {\n kind: ExternalSystemKind;\n /** Display name AND node identity — declarations sharing a label share a node. */\n label: string;\n /** Services with a direct arrow to it. No transitive fan-out: a tag speaks only for its project. */\n usedBy: string[];\n /** Contracts flowing over it. Empty for the unwrapped (tag-declared) case — there are none. */\n apis: string[];\n}\n\n/**\n * One caller's calls into a {@link RuntimeRemoteService}, one entry per (caller, transport): `via`\n * lists the contracts it calls there.\n */\nexport interface RuntimeRemoteCall {\n from: string;\n via: string[];\n type: ApiTransport;\n}\n\n/**\n * A service OUTSIDE this workspace (another repo, a VM, partner endpoints) declared in the reviewed\n * `remoteServices` table of dependencies.json (#1203). It is a SERVICE — it implements our contracts —\n * so it is drawn as a service node, distinct from a vendor external system. Render-only, like the\n * external systems: it is never leveled or cycle-checked, because its own calls are not in this repo.\n */\nexport interface RuntimeRemoteService {\n /** Display text from the reviewed declaration; the key is the identity. */\n label?: string;\n /** The contracts it is declared to implement, as `Api (transport)`, in reviewed order. */\n implements: string[];\n /** Workspace services that target it, sorted by caller then transport. */\n calledBy: RuntimeRemoteCall[];\n}\n\nexport interface RuntimeGraph {\n services: Record<string, RuntimeService>;\n apis: Record<string, RuntimeApi>;\n runtimeEdges: RuntimeEdge[];\n unresolvedUses: RuntimeUnresolved[];\n /** `\"Api.method\"` -> the queue between its producers and its consumers. */\n queues: Record<string, RuntimeQueue>;\n /** Clock- and outside-driven entry points, sorted for determinism. */\n triggers: RuntimeTrigger[];\n /**\n * Declared external systems, keyed by identity. Optional so every graph written before this\n * existed still parses — an absent map means \"nothing declared\", which renders exactly as before.\n */\n externalSystems?: Record<string, RuntimeExternalSystem>;\n /**\n * Reviewed out-of-workspace services, keyed by service name (#1203). Absent when none are\n * declared, so every graph written before this existed parses and renders exactly as before.\n */\n remoteServices?: Record<string, RuntimeRemoteService>;\n}\n"]}
1
+ {"version":3,"file":"runtime-graph-model.js","sourceRoot":"","sources":["../../../../../../packages/tooling/nx-webpieces-rules/src/lib/runtime-graph-model.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG","sourcesContent":["/**\n * Runtime Graph model\n *\n * The serialization DTOs for architecture/runtime-dependencies.json. Split out of runtime-graph.ts,\n * which owns the DERIVATION (and had grown past the file-size limit), so the committed data shape\n * can be read on its own — it is what every consumer of the file, and any future Terraform\n * cross-check, actually programs against.\n *\n * Interfaces rather than classes: these are parsed straight out of JSON with `JSON.parse`, so a\n * class would only ever be a shape assertion over a plain object, never a constructed instance.\n */\n\nimport type {\n ApiRef,\n ApiTransport,\n ExternalSystemDeclaration,\n ExternalSystemKind,\n} from './api-usage/api-relations';\n\nexport interface RuntimeService {\n level: number;\n /**\n * The project's declared nx role — 'server' or 'client' (a library is never a node). Carried so\n * the viz can LABEL the node with what it actually is: it used to infer the role from\n * `implements.length > 0`, which labelled every relation-less server \"client\". Optional so a\n * runtime-dependencies.json written before this field existed still parses and still renders\n * exactly as it did (the visualizer falls back to the old inference).\n */\n role?: string;\n /**\n * The name clients address this service by (`new ClientConfig('helper-fsdb')`), declared in its\n * project.json. Absent for a service nothing calls by name (e.g. a browser app).\n */\n serviceName?: string;\n /**\n * The service(s) this node's clients call when the call site carries no literal `ClientConfig`,\n * declared in its project.json (metadata.webpieces.callsService). A single name, or an\n * `{ apiClassName: serviceName }` map. Absent when the node declares no target. Mirrors\n * GraphEntry.callsService; it is the CALLING-side counterpart of `serviceName`.\n */\n callsService?: string | Record<string, string>;\n implements: string[];\n /**\n * apiClassName -> the LIBRARY project whose apiRelations declared that implements, for the apis\n * this service serves through an embedded library rather than its own source (e.g. a shared\n * route-registration lib). Answers \"who implements WarmupApi, and where did that come from?\",\n * which previously required walking the dependsOn closure by hand.\n */\n implementsVia?: Record<string, string>;\n uses: string[];\n dependsOn: string[];\n /** Reviewed binding provenance and runtime conditions, retained for compact detail views. */\n wiringUses?: ApiRef[];\n wiringImplements?: ApiRef[];\n /**\n * When false, this service is hidden from the rendered runtime graph (its\n * node AND every edge touching it are omitted from the HTML/DOT). It stays\n * in runtime-dependencies.json so the data view is complete. Absent means\n * drawn (the default). Mirrors GraphEntry.drawOnGraph from the `drawOnGraph:`\n * nx tag.\n */\n drawOnGraph?: boolean;\n /**\n * The products this service belongs to (#1179), sorted. A service whose dependencies.json entry\n * carries `products` keeps exactly those — they are final (#1201). A service with none gets every\n * product whose service reaches it over RUNTIME `dependsOn` (through a queue to its consumers\n * included) without passing through another service that carries products; a call into another\n * product's service shows as the runtime edge, not as a product. Absent for a service in no\n * product. See graph-products.ts.\n */\n products?: string[];\n}\n\nexport interface RuntimeApi {\n implementedBy: string[];\n usedBy: string[];\n /** Transport of this API — 'rpc' (direct call) or 'pubsub' (delivered through a queue). */\n type?: ApiTransport;\n /**\n * The api-lib project that OWNS this contract. For a contract nothing in-repo implements, this\n * is the external library the calls leave the repo through (`lib-firestore`, `lib-gmail`), which\n * is what the runtime viz labels its terminal external nodes with.\n */\n owner?: string;\n /**\n * Set when the contract carries an `@externalSystem <kind> [label]` JSDoc tag — the vendor seam\n * declaring WHAT it is a seam to, so the viz can draw firestore as a database rather than as the\n * same grey box as every other external. Absent on everything else.\n */\n externalSystem?: ExternalSystemDeclaration;\n}\n\nexport interface RuntimeEdge {\n from: string;\n to: string;\n via: string[];\n /**\n * Transport of this edge. 'rpc' → a direct call arrow. 'pubsub' → the producer enqueues and the\n * consumer is delivered later, so the runtime viz draws it as producer → QUEUE → consumer.\n * Edges are split by transport, so every edge is a single kind.\n */\n type?: ApiTransport;\n /**\n * `\"ApiClassName.methodName\"` — the queue this edge flows through. Present iff `type` is\n * 'pubsub'. Queues are per METHOD, not per service pair, because that is the unit Cloud Tasks\n * (and Terraform) actually create, so two services exchanging three queued methods are three\n * queues rather than one arrow.\n */\n queue?: string;\n /**\n * True when the CALLING project carries a `cutLegacyCycle:<target>` nx tag naming this edge's\n * target — an admission that this hop closes a REAL cycle that is being tolerated as legacy\n * debt, not a claim that it is harmless. The edge is still drawn (dashed, labelled \"legacy\n * cycle\"); it is only excluded from leveling and cycle detection. Absent on every other edge.\n */\n cutLegacyCycle?: boolean;\n}\n\n/**\n * One Cloud Tasks queue: the async seam between a producer and a consumer, at METHOD granularity.\n *\n * `producedBy` and `consumedBy` are deliberately not symmetric in confidence — see\n * {@link ApiRef.methodsInferred}. The consumer is derived from `addRoutes` plus the contract's\n * method table and is exact; the producer is attributed to every queued method of the contract it\n * built a client for, because which methods it enqueues is not statically recoverable.\n */\nexport interface RuntimeQueue {\n api: string;\n method: string;\n /** `@Queue(...)` override, else `${Api}-${method}` — the name Terraform must match 1:1. */\n queueName: string;\n producedBy: string[];\n consumedBy: string[];\n}\n\n/**\n * An endpoint driven by something that is NOT an in-repo caller — a clock or an outside system.\n * These never appear as runtime EDGES (there is no in-repo `from`), which is exactly why they were\n * invisible until now: a nightly sweep and a GCP push subscription are real runtime entry points\n * with real Terraform behind them, and the graph showed neither.\n */\nexport interface RuntimeTrigger {\n /** 'cron' → a scheduler fires it; 'external' → a system outside this repo posts to it. */\n kind: 'cron' | 'external';\n api: string;\n method: string;\n /** The service that SERVES the endpoint (the arrow's head). */\n service: string;\n /** Present for 'cron': the Cloud Scheduler job / queue name Terraform must match. */\n queueName?: string;\n /**\n * Present for 'external': WHO outside this repo posts to it, declared as\n * `@Endpoint(POST, p, WRITE, EXTERNAL, { calledBy: 'twilio' })`.\n *\n * The SAME `(kind,label)` an OUTBOUND {@link RuntimeExternalSystem} carries, so an inbound\n * `saas twilio` and an outbound `saas twilio` share a node identity and converge on ONE box —\n * `label` is the identity here too, not display text.\n *\n * Optional only for graphs generated BEFORE the caller was required; generation now fails rather\n * than emitting an `external` method without one.\n */\n caller?: ExternalSystemDeclaration;\n}\n\nexport interface RuntimeUnresolved {\n service: string;\n api: string;\n}\n\n/**\n * A system outside this repo that a service TALKS TO, drawn with a shape that says what it is\n * (a database as a cylinder, a bucket as a folder) instead of the one grey box every external\n * used to collapse into.\n *\n * Two declaration sites feed this, because the two real cases differ in whether a contract exists:\n *\n * - **Wrapped** — the repo has a vendor seam (`FirestoreAdminApi`), so the kind is declared with an\n * `@externalSystem <kind> [label]` JSDoc tag on the contract. A decorator cannot go on a TS\n * `interface`, and these seams are interfaces, so JSDoc is the only marker that fits in place.\n * - **Unwrapped** — the service opens the connection itself with no contract to mark (a `pg.Pool`,\n * a TypeORM `DataSource`), so the declaration is an `external:<kind>:<identity>` nx tag on that\n * project's project.json.\n *\n * `label` is the node IDENTITY, not just display text: two services declaring `postgres` converge on\n * ONE node with two arrows into it, rather than drawing a database each.\n */\nexport interface RuntimeExternalSystem {\n kind: ExternalSystemKind;\n /** Display name AND node identity — declarations sharing a label share a node. */\n label: string;\n /** Services with a direct arrow to it. No transitive fan-out: a tag speaks only for its project. */\n usedBy: string[];\n /** Contracts flowing over it. Empty for the unwrapped (tag-declared) case — there are none. */\n apis: string[];\n}\n\n/**\n * One caller's calls into a {@link RuntimeRemoteService}, one entry per (caller, transport): `via`\n * lists the contracts it calls there.\n */\nexport interface RuntimeRemoteCall {\n from: string;\n via: string[];\n type: ApiTransport;\n}\n\n/**\n * A service OUTSIDE this workspace (another repo, a VM, partner endpoints) declared in the reviewed\n * `remoteServices` table of dependencies.json (#1203). It is a SERVICE — it implements our contracts —\n * so it is drawn as a service node, distinct from a vendor external system. Render-only, like the\n * external systems: it is never leveled or cycle-checked, because its own calls are not in this repo.\n */\nexport interface RuntimeRemoteService {\n /** Display text from the reviewed declaration; the key is the identity. */\n label?: string;\n /** The contracts it is declared to implement, as `Api (transport)`, in reviewed order. */\n implements: string[];\n /** Workspace services that target it, sorted by caller then transport. */\n calledBy: RuntimeRemoteCall[];\n}\n\nexport interface RuntimeGraph {\n services: Record<string, RuntimeService>;\n apis: Record<string, RuntimeApi>;\n runtimeEdges: RuntimeEdge[];\n unresolvedUses: RuntimeUnresolved[];\n /** `\"Api.method\"` -> the queue between its producers and its consumers. */\n queues: Record<string, RuntimeQueue>;\n /** Clock- and outside-driven entry points, sorted for determinism. */\n triggers: RuntimeTrigger[];\n /**\n * Declared external systems, keyed by identity. Optional so every graph written before this\n * existed still parses — an absent map means \"nothing declared\", which renders exactly as before.\n */\n externalSystems?: Record<string, RuntimeExternalSystem>;\n /**\n * Reviewed out-of-workspace services, keyed by service name (#1203). Absent when none are\n * declared, so every graph written before this existed parses and renders exactly as before.\n */\n remoteServices?: Record<string, RuntimeRemoteService>;\n}\n"]}