@starci/hfs 4.7.14 → 4.7.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.7.16 - 2026-10-21
4
+ - Fixed: `DB_MIGRATION_DESTRUCTIVE` counts a be/src source as a reference of a dropped or altered column only when the source names the column's table too, so a same-named column of another table (`public.brain_lessons.origin` beside a drop of `transactions.origin`) no longer blocks a contract migration; table and other object drops keep the leaf match; canon pins follow the matching package cohort.
5
+
6
+ ## 4.7.15 - 2026-10-21
7
+ - Added: slot `be.contract.mcp-tools` (opt-in, slot manifest 3.4.0) for the committed MCP tool catalog `be/contracts/<app>/<contract>.tools.json`, and R302 `HFS_MCP_TOOLS_SNAPSHOT`: the catalog names a declared be app, its contract is `<server>@<major>` equal to the file name and the server name, and every tool has a unique name, a description and an object `inputSchema`; canon pins follow the matching package cohort.
8
+
3
9
  ## 4.7.14 - 2026-10-20
4
10
  - Added: `starci app hygiene` (the managed pre-commit hook) refuses a back-end logic file the index adds without its `<name>.<role>.spec.ts` beside it, naming the file (`BE_UNIT_SPEC_NOT_STAGED`, R47); the measured roles and roots come from the coverage scope.
5
11
  - Added: `starci app check` reports `HFS_HOOKS_NOT_INSTALLED` (R13, error) when a set `core.hooksPath` names a hooks folder that is missing or holds no husky dispatcher in the checkout, with the install remedy.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/hfs",
3
- "version": "4.7.14",
3
+ "version": "4.7.16",
4
4
  "description": "The StarCi app command implementation for scaffolding, linting, checking and synchronizing one product repository.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,14 +29,14 @@ pins:
29
29
  source: packages/grammar/package.json
30
30
  why: 'the grammar front ends read: the brand layer sets `--font-sans` and `--font-mono` and the grammar reads them; it carries the Input tel kind, the copyable and read-only Input, the IconButton disclosure props and count badge, ChatBubble, FillViewport, Textarea mentions and Enter-to-send, the leading PrimaryRailLayout rail, the plate-less Image, ListRow, the soft Alert, Progress steps, the floating primary IconButton, FlowGraph, the STATE-8 loading views and the bordered selectable TagGroup chips. The runtime source version wins for a @starci package.'
31
31
  '@starci/eslint-canon-be':
32
- version: 3.4.22
32
+ version: 3.4.24
33
33
  group: starci
34
34
  install: registry
35
35
  side: be
36
36
  source: packages/eslint/be/package.json
37
37
  why: 'the back-end ESLint canon: `loadHfs(import.meta.url)` of be/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the be side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; `starciBeConfig({ hfs: loadHfs(import.meta.url) })` is the typed factory and the BE-CONVENTION laws are its rules.'
38
38
  '@starci/eslint-canon-fe':
39
- version: 8.4.21
39
+ version: 8.4.23
40
40
  group: starci
41
41
  install: registry
42
42
  side: fe
@@ -76,14 +76,14 @@ pins:
76
76
  source: packages/test-world/package.json
77
77
  why: 'the shared e2e library of every back end (R47, R48), a devDependency of every back end: the warm stack behind toxiproxy, the network-edge fakes, the Nest boot, the typed useTestWorld handle, useSandbox for contract specs and the outage lock. Kafka is real own infra (the one digest-pinned apache/kafka KRaft image, a broker listener and proxy per slot, slot-prefixed topics, consumer groups and client ids) and Postgres is schema-per-context (a schema and a login role per context in a shared database). Each worker has its own data slot (<ns>_w<k>) with its own databases, Keycloak realm, leased Redis DB, bucket/collection/topic prefixes, fakes host, toxiproxy proxies and outage lock; a run provisions min(jest workers, workers cap, default 2) slots, and state file protocol 2 pairs exactly with @starci/jest-preset (TEST_WORLD_PAIR_MISMATCH otherwise). A modules world boots real peer apps beside its modules, world.apps.<name>.during(fn) is the outage of a peer app, w.keycloak.clientSecret(client) answers the run-generated secret of a confidential realm client, world.keycloak.events/sessions read the realm user events and live sessions, world.infra.postgresql.connection(name) takes one database connection down while the others serve, and world.resolve and scope.resolve take any Nest token. Every path a declaration names (`stack`, seeds, the realm, Dockerfiles) resolves from the app root (the directory of hfs.json); the globalSetup registers the path aliases as TypeScript resolves them. Its CLI main is exported at ./cli for starci app stack.'
78
78
  '@starci/cli':
79
- version: 1.7.14
79
+ version: 1.7.16
80
80
  group: starci
81
81
  install: registry
82
82
  side: both
83
83
  source: packages/cli/package.json
84
84
  why: 'the only StarCi command package; product repositories install it for starci app, while @starci/hfs remains its pinned transitive implementation.'
85
85
  '@starci/hfs':
86
- version: 4.7.14
86
+ version: 4.7.16
87
87
  group: starci
88
88
  install: registry
89
89
  side: both
@@ -4985,3 +4985,18 @@ rules:
4985
4985
  - {path: packages/hfs/templates/app/ci-workflows/github/workflows/ci.yml, edition: full}
4986
4986
  specNa: "owner:no-runtime-specs (2026-10-17): the runtime has no specs of its own; the scaffold e2e (e2e/hfs-scaffold-app.spec.mjs: a fresh scaffold has no finding) and the example apps prove it"
4987
4987
  witness: {status: unreachable, reason: "owner:no-runtime-specs (2026-10-17): the runtime has no spec fixtures", date: "2026-10-18"}
4988
+ - id: R302
4989
+ code: "HFS_MCP_TOOLS_SNAPSHOT"
4990
+ law: "An app that commits the MCP tool catalog of its server keeps it at `be/contracts/<app>/<contract>.tools.json` (slot be.contract.mcp-tools, opt-in), `<contract>` being `<server>@<major>`, as the server's `tools/list` result: `{ contract, server: { name, version }, tools }` where the contract equals the file name and the server name, and every tool has a unique name, a description and an object `inputSchema`."
4991
+ kinds: [check]
4992
+ gates: [land, ci]
4993
+ failureCodes: ["HFS_MCP_TOOLS_SNAPSHOT"]
4994
+ enforcers:
4995
+ - {kind: hfs, id: mcp-tools-snapshot, at: scripts/hfs/rules/mcp-tools.mjs}
4996
+ editions: [lite, full]
4997
+ docs:
4998
+ - {path: docs/hfs-contract-snapshots.md#r302, editions: [lite, full]}
4999
+ templateNa: "The canon emits no MCP catalog: the app commits its server's tools/list result, so there is no scaffolded snapshot."
5000
+ exampleNa: "owner:mcp-tools-snapshot-no-example (2026-10-21): no example app serves an MCP server; the package spec judges a passing and a violating catalog"
5001
+ specNa: "owner:no-runtime-specs (2026-10-17): the enforcer is runtime code with no spec of its own; the @starci/hfs package spec packages/hfs/src/mcp-tools-snapshot.spec.mjs runs it from the bundled copy"
5002
+ witness: {status: unreachable, reason: "owner:no-runtime-specs (2026-10-17): the runtime has no spec fixtures; the package spec proves the rule", date: "2026-10-21"}
@@ -7,7 +7,7 @@
7
7
  # catalog READ this file through scripts/hfs/slots.mjs; none of them hardcodes a path.
8
8
  # Shape: modules/schemas/hfs-slots.schema.yaml. The repository side is hfs.json: modules/schemas/hfs-repo.schema.yaml.
9
9
  schema: starci/hfs-slots@3
10
- version: 3.3.0
10
+ version: 3.4.0
11
11
 
12
12
  versioning:
13
13
  # MAJOR.MINOR.PATCH of this manifest. A repository pins only the MAJOR in hfs.json ("hfs": 3).
@@ -38,6 +38,7 @@ versioning:
38
38
  # or environment reads (BE_APP_OPTIONS_COMPOSITION). Secrets use EnvSource.secret(): <NAME>_FILE first, plain <NAME> only
39
39
  # when the file key is absent; .starcistacks owns custody. Capability <capability>.config.ts roles stay unchanged.
40
40
  # 3.3.0 is a minor (alpha.16): it ADDS the optional app.ci-stack-deploy slot, the managed workflow of the starci app stack verbs.
41
+ # 3.4.0 is a minor (alpha.24): it ADDS the opt-in be.contract.mcp-tools slot, the committed MCP tool-catalog snapshot of an app.
41
42
 
42
43
  # Field meaning, per slot.
43
44
  # id stable name, never changes meaning inside a major.
@@ -1153,6 +1154,19 @@ slots:
1153
1154
  why: the previously published event contract of a service, the same format as its events.json (copied over when the contract is published, never edited); the current events.json may only extend it additively, a breaking change is a new `<event>.v2` key (R177 BE_CONTRACT_BREAKING)
1154
1155
  rules: [BE_CONTRACT_BREAKING]
1155
1156
 
1157
+ - id: be.contract.mcp-tools
1158
+ since: 3.4.0
1159
+ profiles: [be]
1160
+ path: "contracts/<app>/<contract>.tools.json"
1161
+ presence: opt-in
1162
+ tracked: tracked
1163
+ tier: none
1164
+ tests: none
1165
+ coverage: none
1166
+ why: the MCP tool catalog an app's MCP server publishes at one contract major (`<server>@<major>`), the `tools/list` result its clients rely on, committed as a cross-repo interface; the canon emits no MCP catalog, so its shape is judged (R302 HFS_MCP_TOOLS_SNAPSHOT)
1167
+ exampleNa: "owner:mcp-tools-snapshot-no-example (2026-10-21): no example app serves an MCP server; the package spec judges the shape"
1168
+ rules: [HFS_MCP_TOOLS_SNAPSHOT]
1169
+
1156
1170
  # ----- BE: apps (one slot per app kind; a new kind = a new slot, minor bump) ---------------------------
1157
1171
  # The files of every app (owner ruling 2026-10-14, R245 and R246, since 3.1.0), each with a line budget that
1158
1172
  # BE_APP_COMPOSITION_BUDGET holds absolutely (not a ratchet):
@@ -3602,6 +3602,17 @@ HFS_MANIFEST_MAJOR_MISMATCH:
3602
3602
  owner: owner
3603
3603
  kind: check-finding
3604
3604
 
3605
+ HFS_MCP_TOOLS_SNAPSHOT:
3606
+ title: "A committed MCP tool catalog has the canonical tools/list shape"
3607
+ title_vi: "Snapshot danh mục tool MCP sai hình dạng chuẩn"
3608
+ meaning_vi: "Tệp `<file>` dưới `be/contracts/<app>/<contract>.tools.json` không phải danh mục tool MCP chuẩn: thiếu app khai báo, `contract` không phải `<server>@<major>` khớp tên tệp và `server.name`, hoặc có tool thiếu tên, mô tả hay `inputSchema` kiểu object, hoặc trùng tên."
3609
+ causes_vi:
3610
+ - "Vi phạm luật R302: snapshot là kết quả `tools/list` của server MCP ở một major hợp đồng, được commit như giao diện giữa các repo."
3611
+ - "Snapshot được chép tay hoặc đặt dưới thư mục của một app không khai báo trong hfs.json"
3612
+ nextStep_vi: "Lấy lại kết quả `tools/list` của server, ghi `{ contract, server: { name, version }, tools }` vào đúng tệp của app phục vụ server đó và khai báo slot `be.contract.mcp-tools` trong `sides.be.optionalSlots`. Op vừa tạo ra bản này sẽ được chạy lại để sửa theo lời nhắn của bộ kiểm tra."
3613
+ owner: op-retry
3614
+ kind: check-finding
3615
+
3605
3616
  HFS_MIN_INSTANCES:
3606
3617
  title: "Fewer instances of a slot than required"
3607
3618
  title_vi: "Số thực thể của ô ít hơn mức tối thiểu"
@@ -1,7 +1,7 @@
1
1
  // GENERATED by scripts/cli/gen-catalog.mjs — do not edit
2
2
  export const CATALOG = {
3
3
  "schema": "starci/cli-catalog@1",
4
- "hash": "1ac457c26ee05922e910a56fab64d9bdc9b0bc251466dd4a2f341bf698ff3e73",
4
+ "hash": "c7ef5f72727b2b906b541669c413050b7abd34206c123a87fe90502330271856",
5
5
  "global": [
6
6
  {
7
7
  "name": "json",
@@ -2729,7 +2729,7 @@ export const CATALOG = {
2729
2729
  {
2730
2730
  "name": "changed",
2731
2731
  "type": "list",
2732
- "summary": "explicit files in the operation slice"
2732
+ "summary": "files added to the slice beside the delta from the base"
2733
2733
  },
2734
2734
  {
2735
2735
  "name": "tests",
@@ -2773,6 +2773,12 @@ export const CATALOG = {
2773
2773
  "impl": {
2774
2774
  "script": "scripts/cli/gate-run.mjs"
2775
2775
  },
2776
+ "conventions": [
2777
+ "the slice is every file that differs from the base (committed, staged, dirty and untracked) plus the --changed files",
2778
+ "--changed extends the slice and never narrows it, so a report cannot hide an edit; narrow it with --base",
2779
+ "the base is --base, else the workflow's previous checkpoint, else the merge-base of HEAD with its upstream or main",
2780
+ "a TypeScript file with no tsconfig.json of its own under a hfs.json sides.<side>.reads tree is checked by that side's programs"
2781
+ ],
2776
2782
  "runtimeSide": "tree"
2777
2783
  },
2778
2784
  "runtime-artifact": {
@@ -20,6 +20,7 @@
20
20
  // HFS_CI_MISSING_CANON (R13, rules/pipeline.mjs) CI without the pinned `starci app check`, pre-push without typecheck or lint
21
21
  // HFS_DEP_VERSION_SKEW (R14, rules/deps.mjs) a dependency at two versions in the workspace, or a nested copy in the lockfile
22
22
  // HFS_CONTRACT_SNAPSHOT_DRIFT (R23, rules/contract.mjs) an uncommitted back-end snapshot, or a front-end copy that differs from it
23
+ // HFS_MCP_TOOLS_SNAPSHOT (R302, rules/mcp-tools.mjs) a committed MCP tool catalog that is not the canonical `tools/list` snapshot
23
24
  // BE_TEST_TOPOLOGY (R47, rules/test-topology.mjs) a `.test` file, a testing/ folder, a second jest configuration
24
25
  // FE_NO_TESTS (R97, rules/fe-no-tests.mjs) a front end holds a spec, e2e or test-tool file, a test script or a test dependency; no exception
25
26
  // FE_STACK_FORBIDDEN (rules/fe-stack.mjs) a front-end manifest (the fe side's, or the app root's minus the back end's own libraries)
@@ -72,6 +73,7 @@ import { gitOutputOf } from '../lib/git.mjs';
72
73
  import { posixPath } from '../lib/path-key.mjs';
73
74
  import { treeFindings } from './tree-findings.mjs';
74
75
  import { contractFindings } from './rules/contract.mjs';
76
+ import { mcpToolsSnapshotFindings } from './rules/mcp-tools.mjs';
75
77
  import { appRootFindings } from './rules/app-root.mjs';
76
78
  import { frontendFindings } from './rules/frontend-tree.mjs';
77
79
  import { lintSuppressionFindings } from './rules/lint-suppression.mjs';
@@ -102,7 +104,7 @@ export const CHECK_CODES = Object.freeze([
102
104
  'HFS_SLOT_UNDECLARED', 'HFS_SLOT_NOT_ENABLED', 'HFS_SLOT_AMBIGUOUS', 'HFS_TRACKED_MUST_BE_IGNORED', 'HFS_FORBIDDEN_PRESENT',
103
105
  'HFS_SLOT_REQUIRED_MISSING', 'HFS_MIN_INSTANCES', 'HFS_CANON_PIN_DRIFT', 'HFS_SIZE_SOFT_BACKLOG', 'BE_SOURCE_FORM',
104
106
  'HFS_MANAGED_FILE_DRIFT', 'HFS_TOOL_CONFIG_LOCAL', 'HFS_RULE_OFF_WITHOUT_REPLACEMENT', 'HFS_TS_STRICT',
105
- 'HFS_PLAINTEXT_SECRET', 'HFS_STACKS_SHAPE', 'HFS_CI_MISSING_CANON', 'HFS_DEP_VERSION_SKEW', 'HFS_CONTRACT_SNAPSHOT_DRIFT',
107
+ 'HFS_PLAINTEXT_SECRET', 'HFS_STACKS_SHAPE', 'HFS_CI_MISSING_CANON', 'HFS_DEP_VERSION_SKEW', 'HFS_CONTRACT_SNAPSHOT_DRIFT', 'HFS_MCP_TOOLS_SNAPSHOT',
106
108
  'BE_TEST_TOPOLOGY', 'BE_SPEC_PLACEMENT', 'HFS_REPO_LOCAL_CHECK', 'HFS_LINT_SUPPRESSION_FILE', 'HFS_PROOF_COMMAND_FILE_MISSING', 'HFS_PEER_INTEGRATION_MISSING', 'BE_INTEGRATION_SPEC_MISSING', 'FE_GRAPHQL_CONTRACT', 'FE_NO_TESTS', 'HFS_MONO_WORKSPACES', 'HFS_MONO_FE_WORKSPACE', 'HFS_MONO_NEST_PROJECTS', 'HFS_MONO_WORKSPACE_DEP', 'BE_CLI_REQUIRED', 'FE_WIRE_GENERATED', 'FE_I18N_PLACEMENT', 'FE_I18N_CATALOG', 'HFS_SERVICE_PLACEMENT', 'HFS_IMAGE_UNPINNED', 'HFS_SERVICE_STACK_DECLARATION', 'HFS_EVENT_CONTRACT', 'BE_ASYNC_SPEC_MISSING', 'BE_SAGA_STEP_COMPENSATION', 'BE_SAGA_STATE_VERSIONED', 'BE_SAGA_EVENT_CONTRACT', 'BE_SAGA_CONSUMER_DEDUPE', 'BE_EVENT_CLASS_CONTRACT', 'BE_PATTERN_SPEC_MISSING', 'BE_CONTRACT_BREAKING', 'BE_KIND_DECLARATION', 'BE_KIND_EMPTY', 'HFS_DOCKER_BUILD_CONTEXT', 'HFS_DOCKER_STAGES', 'HFS_DOCKER_ENTRY', 'HFS_DOCKER_BASE_PIN', 'HFS_DOCKER_SECRETS', 'BE_SAGA_E2E_MISSING',
107
109
  'FE_STACK_FORBIDDEN', 'HFS_EDITION_FORBIDDEN_PRESENT', 'HFS_LITE_SECRET_CUSTODY', 'HFS_STARCIWORK_LITE_FORBIDDEN',
108
110
  'DB_MIGRATION_SHAPE', 'DB_RLS_REQUIRED', 'DB_DYNAMIC_DDL', 'DB_POLICY_SHAPE', 'DB_DEFINER_SAFE', 'DB_STORAGE_POLICY', 'DB_CONFIG_POLICY', 'DB_TYPES_DRIFT',
@@ -220,7 +222,7 @@ function contentRuleFindings({ repoRoot, repo, resolver, files, all, scoped, pin
220
222
  ...checkAppRoot({ root: repoRoot, resolver, tree: trackedTreeView(all) }).violations.map((item) => ({ code: item.ruleId, level: 'error', path: item.path, line: item.line, column: item.column, source: 'machine', message: `${item.path}: ${item.message}` })),
221
223
  );
222
224
  } else if (repo.profile === 'be') {
223
- findings.push(...contractFindings({ repoRoot, files, repo, resolver }), ...testTopologyFindings({ repoRoot, files }));
225
+ findings.push(...contractFindings({ repoRoot, files, repo, resolver }), ...mcpToolsSnapshotFindings({ repoRoot, files, repo }), ...testTopologyFindings({ repoRoot, files }));
224
226
  } else {
225
227
  findings.push(...frontendFindings({ repoRoot, files, repo }), ...feNoTestsFindings({ repoRoot, files: files.filter((file) => inScope(file)) }));
226
228
  }
@@ -392,8 +392,15 @@ function sourceNames(ts, text, file) {
392
392
  return names;
393
393
  }
394
394
 
395
+ /**
396
+ * Whether a be/src source references a destroyed object. A column (`<schema>.<table>.<column>`) is referenced only by a source that
397
+ * names both its table and the column, so a same-named column of another table is not a reference; the check stays conservative,
398
+ * since any mention of the table beside the column counts. Every other object kind is referenced by its leaf name.
399
+ */
400
+ const referencesObject = (names, object) => names.has(object.leaf) && (object.kind !== 'column' || !object.table || names.has(object.table));
401
+
395
402
  function destructiveObjectFinding(file, object, contract, references) {
396
- const reference = references.find(({ names }) => names.has(object.leaf));
403
+ const reference = references.find(({ names }) => referencesObject(names, object));
397
404
  if (contract && !reference) return null;
398
405
  const reason = reference && contract ? `${reference.file} still references this object; remove the reference before the contract migration`
399
406
  : 'use a *_contract_* migration after the application stops using this object';
@@ -0,0 +1,63 @@
1
+ // mcp-tools.mjs - HFS_MCP_TOOLS_SNAPSHOT (R302): the committed MCP tool-catalog snapshot of an app has the canonical shape.
2
+ // An app that serves an MCP server commits the catalog its clients rely on at `contracts/<app>/<contract>.tools.json` (slot
3
+ // be.contract.mcp-tools): `{ contract: "<server>@<major>", server: { name, version }, tools: [{ name, description, inputSchema, ... }] }`,
4
+ // the `tools/list` result of the server at that contract major. The canon emits no MCP catalog, so the check is the shape: the
5
+ // file names a declared be app and its own contract, the contract is the server name at an integer major, every tool has a unique
6
+ // name, a description and an object input schema. A file that is not JSON is a finding too.
7
+ import { isPlainObject as plain } from '../../../engine/plain-object.mjs';
8
+ import { found, readText } from './read.mjs';
9
+
10
+ const MCP_TOOLS_SNAPSHOT = 'HFS_MCP_TOOLS_SNAPSHOT';
11
+ const SNAPSHOT = /^contracts\/([^/]+)\/([^/]+)\.tools\.json$/u;
12
+ const CONTRACT = /^([a-z][a-z0-9-]*)@([1-9]\d*)$/u;
13
+
14
+ const text = (value) => typeof value === 'string' && value.trim() !== '';
15
+
16
+ /** The shape problems of one tool entry at index `index`, given the names already seen. */
17
+ function toolProblems(tool, index, seen) {
18
+ if (!plain(tool)) return [`tools[${index}] is not an object`];
19
+ const at = text(tool.name) ? `tool ${tool.name}` : `tools[${index}]`;
20
+ const problems = [];
21
+ if (!text(tool.name)) problems.push(`${at} has no name`);
22
+ else if (seen.has(tool.name)) problems.push(`${at} is listed twice`);
23
+ else seen.add(tool.name);
24
+ if (!text(tool.description)) problems.push(`${at} has no description`);
25
+ if (!plain(tool.inputSchema) || tool.inputSchema.type !== 'object') problems.push(`${at} has no inputSchema of type object`);
26
+ return problems;
27
+ }
28
+
29
+ /** The shape problems of a parsed snapshot whose file stem is `stem`. */
30
+ function snapshotProblems(doc, stem) {
31
+ if (!plain(doc)) return ['is not a JSON object'];
32
+ const problems = [];
33
+ const contract = CONTRACT.exec(String(doc.contract ?? ''));
34
+ if (!contract) problems.push('contract is not `<server>@<major>` (a kebab-case server name and an integer major from 1)');
35
+ else if (doc.contract !== stem) problems.push(`contract ${doc.contract} differs from the file name ${stem}.tools.json`);
36
+ if (!plain(doc.server) || !text(doc.server.name) || !text(doc.server.version)) problems.push('server has no name and version');
37
+ else if (contract && doc.server.name !== contract[1]) problems.push(`server.name ${doc.server.name} differs from the contract server ${contract[1]}`);
38
+ if (!Array.isArray(doc.tools) || doc.tools.length === 0) return [...problems, 'tools is not a non-empty list'];
39
+ const seen = new Set();
40
+ return [...problems, ...doc.tools.flatMap((tool, index) => toolProblems(tool, index, seen))];
41
+ }
42
+
43
+ /** The findings of R302 for the be side at `repoRoot` (be-relative `files`, the side view `repo`). */
44
+ export function mcpToolsSnapshotFindings({ repoRoot, files, repo }) {
45
+ if (repo.profile !== 'be') return [];
46
+ const apps = new Set((repo.apps ?? []).map((app) => app.name));
47
+ const findings = [];
48
+ for (const file of files) {
49
+ const match = SNAPSHOT.exec(file);
50
+ if (!match) continue;
51
+ const [, app, stem] = match;
52
+ const fix = 'commit the server\'s `tools/list` result as `{ contract: "<server>@<major>", server: { name, version }, tools: [...] }`';
53
+ if (!apps.has(app)) {
54
+ findings.push(found(MCP_TOOLS_SNAPSHOT, file, `${file} belongs to no be app: ${app} is not declared in hfs.json sides.be.apps; a tool catalog lives under contracts/<app>/ of the app that serves it`, { app }));
55
+ continue;
56
+ }
57
+ let doc;
58
+ try { doc = JSON.parse(readText(repoRoot, file) ?? ''); } catch { doc = undefined; }
59
+ const problems = doc === undefined ? ['is not readable JSON'] : snapshotProblems(doc, stem);
60
+ if (problems.length) findings.push(found(MCP_TOOLS_SNAPSHOT, file, `${file} is not a canonical MCP tool catalog: ${problems.join('; ')}; ${fix}`, { app, problems }));
61
+ }
62
+ return findings;
63
+ }