@agent-teams/engineering-foundation 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/README.md +5 -0
  2. package/dist/capabilities/contract-json-schema-releases/adapters/outbound/filesystem/ajv-json-schema-release-inspector.d.ts +5 -0
  3. package/dist/capabilities/contract-json-schema-releases/adapters/outbound/filesystem/ajv-json-schema-release-inspector.d.ts.map +1 -1
  4. package/dist/capabilities/contract-json-schema-releases/adapters/outbound/filesystem/ajv-json-schema-release-inspector.js +48 -27
  5. package/dist/capabilities/contract-json-schema-releases/adapters/outbound/filesystem/ajv-json-schema-release-inspector.js.map +1 -1
  6. package/dist/capabilities/contract-json-schema-releases/application/ports/json-schema-release-inspector.d.ts +1 -0
  7. package/dist/capabilities/contract-json-schema-releases/application/ports/json-schema-release-inspector.d.ts.map +1 -1
  8. package/dist/capabilities/contract-protobuf-evolution/adapters/outbound/qualification/filesystem-buf-breaking-qualification-evidence.js +1 -1
  9. package/dist/capabilities/contract-protobuf-evolution/application/model/buf-breaking-qualification.d.ts +2 -2
  10. package/dist/capabilities/contract-protobuf-evolution/application/model/buf-breaking-qualification.js +2 -2
  11. package/dist/capabilities/contract-protobuf-evolution/application/model/protobuf-release-evidence.d.ts +4 -4
  12. package/dist/capabilities/contract-protobuf-evolution/application/model/protobuf-release-evidence.d.ts.map +1 -1
  13. package/dist/capabilities/contract-protobuf-evolution/contract/config.d.ts +1 -1
  14. package/dist/capabilities/contract-protobuf-evolution/contract/config.js +4 -4
  15. package/dist/capabilities/contract-protobuf-evolution/contract/config.js.map +1 -1
  16. package/dist/capabilities/executable-specifications/adapters/outbound/filesystem/filesystem-executable-specification-inspector.d.ts +24 -0
  17. package/dist/capabilities/executable-specifications/adapters/outbound/filesystem/filesystem-executable-specification-inspector.d.ts.map +1 -0
  18. package/dist/capabilities/executable-specifications/adapters/outbound/filesystem/filesystem-executable-specification-inspector.js +244 -0
  19. package/dist/capabilities/executable-specifications/adapters/outbound/filesystem/filesystem-executable-specification-inspector.js.map +1 -0
  20. package/dist/capabilities/executable-specifications/application/model/executable-specification.d.ts +58 -0
  21. package/dist/capabilities/executable-specifications/application/model/executable-specification.d.ts.map +1 -0
  22. package/dist/capabilities/executable-specifications/application/model/executable-specification.js +2 -0
  23. package/dist/capabilities/executable-specifications/application/model/executable-specification.js.map +1 -0
  24. package/dist/capabilities/executable-specifications/application/policies/evaluate-executable-specifications.d.ts +6 -0
  25. package/dist/capabilities/executable-specifications/application/policies/evaluate-executable-specifications.d.ts.map +1 -0
  26. package/dist/capabilities/executable-specifications/application/policies/evaluate-executable-specifications.js +277 -0
  27. package/dist/capabilities/executable-specifications/application/policies/evaluate-executable-specifications.js.map +1 -0
  28. package/dist/capabilities/executable-specifications/application/policies/portable-executable-specification-path.d.ts +10 -0
  29. package/dist/capabilities/executable-specifications/application/policies/portable-executable-specification-path.d.ts.map +1 -0
  30. package/dist/capabilities/executable-specifications/application/policies/portable-executable-specification-path.js +76 -0
  31. package/dist/capabilities/executable-specifications/application/policies/portable-executable-specification-path.js.map +1 -0
  32. package/dist/capabilities/executable-specifications/application/ports/executable-specification-inspector.d.ts +9 -0
  33. package/dist/capabilities/executable-specifications/application/ports/executable-specification-inspector.d.ts.map +1 -0
  34. package/dist/capabilities/executable-specifications/application/ports/executable-specification-inspector.js +2 -0
  35. package/dist/capabilities/executable-specifications/application/ports/executable-specification-inspector.js.map +1 -0
  36. package/dist/capabilities/executable-specifications/application/rules.d.ts +22 -0
  37. package/dist/capabilities/executable-specifications/application/rules.d.ts.map +1 -0
  38. package/dist/capabilities/executable-specifications/application/rules.js +23 -0
  39. package/dist/capabilities/executable-specifications/application/rules.js.map +1 -0
  40. package/dist/capabilities/executable-specifications/application/use-cases/analyze-executable-specifications.d.ts +8 -0
  41. package/dist/capabilities/executable-specifications/application/use-cases/analyze-executable-specifications.d.ts.map +1 -0
  42. package/dist/capabilities/executable-specifications/application/use-cases/analyze-executable-specifications.js +36 -0
  43. package/dist/capabilities/executable-specifications/application/use-cases/analyze-executable-specifications.js.map +1 -0
  44. package/dist/capabilities/executable-specifications/contract/config.d.ts +5 -0
  45. package/dist/capabilities/executable-specifications/contract/config.d.ts.map +1 -0
  46. package/dist/capabilities/executable-specifications/contract/config.js +155 -0
  47. package/dist/capabilities/executable-specifications/contract/config.js.map +1 -0
  48. package/dist/capabilities/executable-specifications/module.d.ts +10 -0
  49. package/dist/capabilities/executable-specifications/module.d.ts.map +1 -0
  50. package/dist/capabilities/executable-specifications/module.js +52 -0
  51. package/dist/capabilities/executable-specifications/module.js.map +1 -0
  52. package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-extractor.d.ts.map +1 -1
  53. package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-extractor.js +1 -14
  54. package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-extractor.js.map +1 -1
  55. package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/public-api-baseline-mapper.d.ts +4 -4
  56. package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/public-api-baseline-mapper.d.ts.map +1 -1
  57. package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/public-api-baseline-mapper.js +34 -46
  58. package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/public-api-baseline-mapper.js.map +1 -1
  59. package/dist/capabilities/public-api-compatibility/application/model/public-api.d.ts +18 -75
  60. package/dist/capabilities/public-api-compatibility/application/model/public-api.d.ts.map +1 -1
  61. package/dist/capabilities/public-api-compatibility/application/model/public-api.js +7 -29
  62. package/dist/capabilities/public-api-compatibility/application/model/public-api.js.map +1 -1
  63. package/dist/capabilities/public-api-compatibility/application/policies/accepted-breaking-change.d.ts +1 -5
  64. package/dist/capabilities/public-api-compatibility/application/policies/accepted-breaking-change.d.ts.map +1 -1
  65. package/dist/capabilities/public-api-compatibility/application/policies/accepted-breaking-change.js +1 -8
  66. package/dist/capabilities/public-api-compatibility/application/policies/accepted-breaking-change.js.map +1 -1
  67. package/dist/capabilities/public-api-compatibility/application/policies/evaluate-public-api-compatibility.d.ts.map +1 -1
  68. package/dist/capabilities/public-api-compatibility/application/policies/evaluate-public-api-compatibility.js +5 -38
  69. package/dist/capabilities/public-api-compatibility/application/policies/evaluate-public-api-compatibility.js.map +1 -1
  70. package/dist/capabilities/public-api-compatibility/application/policies/validate-package-export-coverage.d.ts +1 -1
  71. package/dist/capabilities/public-api-compatibility/application/policies/validate-package-export-coverage.js +2 -2
  72. package/dist/capabilities/public-api-compatibility/application/policies/validate-package-export-coverage.js.map +1 -1
  73. package/dist/capabilities/public-api-compatibility/application/use-cases/analyze-public-api-compatibility.d.ts.map +1 -1
  74. package/dist/capabilities/public-api-compatibility/application/use-cases/analyze-public-api-compatibility.js +0 -1
  75. package/dist/capabilities/public-api-compatibility/application/use-cases/analyze-public-api-compatibility.js.map +1 -1
  76. package/dist/capabilities/public-api-compatibility/application/use-cases/promote-public-api-baselines.d.ts.map +1 -1
  77. package/dist/capabilities/public-api-compatibility/application/use-cases/promote-public-api-baselines.js +0 -38
  78. package/dist/capabilities/public-api-compatibility/application/use-cases/promote-public-api-baselines.js.map +1 -1
  79. package/dist/capabilities/public-api-compatibility/contract/config.d.ts +1 -1
  80. package/dist/capabilities/public-api-compatibility/contract/config.d.ts.map +1 -1
  81. package/dist/capabilities/public-api-compatibility/contract/config.js +32 -106
  82. package/dist/capabilities/public-api-compatibility/contract/config.js.map +1 -1
  83. package/dist/capabilities/source-dependencies/application/model/source-workspace.d.ts +2 -0
  84. package/dist/capabilities/source-dependencies/application/model/source-workspace.d.ts.map +1 -1
  85. package/dist/capabilities/source-dependencies/application/policies/evaluate-resolved-source-dependency.d.ts +1 -0
  86. package/dist/capabilities/source-dependencies/application/policies/evaluate-resolved-source-dependency.d.ts.map +1 -1
  87. package/dist/capabilities/source-dependencies/application/policies/evaluate-resolved-source-dependency.js +47 -3
  88. package/dist/capabilities/source-dependencies/application/policies/evaluate-resolved-source-dependency.js.map +1 -1
  89. package/dist/capabilities/source-dependencies/application/policies/evaluate-source-dependencies.d.ts.map +1 -1
  90. package/dist/capabilities/source-dependencies/application/policies/evaluate-source-dependencies.js +14 -1
  91. package/dist/capabilities/source-dependencies/application/policies/evaluate-source-dependencies.js.map +1 -1
  92. package/dist/capabilities/source-dependencies/application/rules.d.ts +2 -0
  93. package/dist/capabilities/source-dependencies/application/rules.d.ts.map +1 -1
  94. package/dist/capabilities/source-dependencies/application/rules.js +2 -0
  95. package/dist/capabilities/source-dependencies/application/rules.js.map +1 -1
  96. package/dist/capabilities/source-dependencies/contract/config.d.ts.map +1 -1
  97. package/dist/capabilities/source-dependencies/contract/config.js +5 -0
  98. package/dist/capabilities/source-dependencies/contract/config.js.map +1 -1
  99. package/dist/composition/capability-registry.d.ts.map +1 -1
  100. package/dist/composition/capability-registry.js +2 -0
  101. package/dist/composition/capability-registry.js.map +1 -1
  102. package/dist/composition/rule-registry.d.ts.map +1 -1
  103. package/dist/composition/rule-registry.js +2 -0
  104. package/dist/composition/rule-registry.js.map +1 -1
  105. package/dist/foundation-config.d.ts +1 -1
  106. package/dist/foundation-config.d.ts.map +1 -1
  107. package/dist/foundation-config.js +2 -0
  108. package/dist/foundation-config.js.map +1 -1
  109. package/dist/scaffolding/adapters/node/filesystem-authority-workspace.js +1 -1
  110. package/dist/scaffolding/adapters/node/filesystem-authority-workspace.js.map +1 -1
  111. package/dist/scaffolding/adapters/node/filesystem-journal-state.js +1 -1
  112. package/dist/scaffolding/adapters/node/filesystem-journal.js +3 -3
  113. package/dist/scaffolding/adapters/node/filesystem-journal.js.map +1 -1
  114. package/dist/scaffolding/adapters/node/filesystem-operation-state.d.ts +4 -11
  115. package/dist/scaffolding/adapters/node/filesystem-operation-state.d.ts.map +1 -1
  116. package/dist/scaffolding/adapters/node/filesystem-operation-state.js +0 -24
  117. package/dist/scaffolding/adapters/node/filesystem-operation-state.js.map +1 -1
  118. package/dist/scaffolding/adapters/node/filesystem-path-guard.d.ts +1 -1
  119. package/dist/scaffolding/adapters/node/filesystem-path-guard.d.ts.map +1 -1
  120. package/dist/scaffolding/adapters/node/node-authority-input-loader.js +7 -7
  121. package/dist/scaffolding/adapters/node/node-authority-input-loader.js.map +1 -1
  122. package/dist/scaffolding/adapters/node/node-authority-receipt-validator.js +1 -1
  123. package/dist/scaffolding/adapters/node/node-authority-receipt-validator.js.map +1 -1
  124. package/dist/scaffolding/contract/receipt-authority-types.d.ts +2 -2
  125. package/dist/scaffolding/contract/scaffold-contract.d.ts +8 -8
  126. package/dist/scaffolding/contract/types.d.ts +9 -214
  127. package/dist/scaffolding/contract/types.d.ts.map +1 -1
  128. package/dist/scaffolding/definitions/registry.d.ts +0 -1
  129. package/dist/scaffolding/definitions/registry.d.ts.map +1 -1
  130. package/dist/scaffolding/definitions/registry.js +0 -3
  131. package/dist/scaffolding/definitions/registry.js.map +1 -1
  132. package/dist/scaffolding/kernel/authority-compiler.js +2 -2
  133. package/dist/scaffolding/kernel/authority-receipt.js +3 -3
  134. package/dist/scaffolding/kernel/plan-validation.js +1 -1
  135. package/dist/schema-catalog.js +3 -3
  136. package/dist/schema-catalog.js.map +1 -1
  137. package/dist/schema-ids.d.ts +2 -5
  138. package/dist/schema-ids.d.ts.map +1 -1
  139. package/dist/schema-ids.js +6 -15
  140. package/dist/schema-ids.js.map +1 -1
  141. package/dist/strict-json.d.ts +7 -0
  142. package/dist/strict-json.d.ts.map +1 -0
  143. package/dist/strict-json.js +41 -0
  144. package/dist/strict-json.js.map +1 -0
  145. package/dist/workspace-inventory/adapters/outbound/pnpm/pnpm-workspace-inventory-reader.d.ts +1 -0
  146. package/dist/workspace-inventory/adapters/outbound/pnpm/pnpm-workspace-inventory-reader.d.ts.map +1 -1
  147. package/dist/workspace-inventory/adapters/outbound/pnpm/pnpm-workspace-inventory-reader.js +7 -0
  148. package/dist/workspace-inventory/adapters/outbound/pnpm/pnpm-workspace-inventory-reader.js.map +1 -1
  149. package/package.json +11 -13
  150. package/schemas/architecture-source-dependencies/v1.schema.json +1 -0
  151. package/schemas/contract-protobuf-breaking-qualification/v1.schema.json +5 -1
  152. package/schemas/contract-protobuf-evolution/v1.schema.json +47 -15
  153. package/schemas/foundation-config/v1.schema.json +10 -0
  154. package/schemas/package-public-api-baseline/v1.schema.json +49 -12
  155. package/schemas/package-public-api-compatibility/v1.schema.json +46 -5
  156. package/schemas/quality-executable-specification-catalog/v1.schema.json +201 -0
  157. package/schemas/quality-executable-specifications/v1.schema.json +20 -0
  158. package/schemas/{scaffold-authority-evidence.schema.json → scaffold-authority-evidence/v1.schema.json} +1 -1
  159. package/schemas/{scaffold-intent.schema.json → scaffold-intent/v1.schema.json} +1 -1
  160. package/schemas/{scaffold-plan.schema.json → scaffold-plan/v1.schema.json} +3 -3
  161. package/schemas/{scaffold-receipt.schema.json → scaffold-receipt/v1.schema.json} +3 -3
  162. package/schemas/{scaffold-recovery-journal.schema.json → scaffold-recovery-journal/v1.schema.json} +3 -3
  163. package/schemas/{scaffold-target-catalog.schema.json → scaffold-target-catalog/v1.schema.json} +2 -2
  164. package/schemas/{scaffolding-config.schema.json → scaffolding-config/v1.schema.json} +2 -2
  165. package/dist/scaffolding/adapters/memory/memory-workspace.d.ts +0 -9
  166. package/dist/scaffolding/adapters/memory/memory-workspace.d.ts.map +0 -1
  167. package/dist/scaffolding/adapters/memory/memory-workspace.js +0 -93
  168. package/dist/scaffolding/adapters/memory/memory-workspace.js.map +0 -1
  169. package/dist/scaffolding/adapters/node/filesystem-rendering-journal.d.ts +0 -6
  170. package/dist/scaffolding/adapters/node/filesystem-rendering-journal.d.ts.map +0 -1
  171. package/dist/scaffolding/adapters/node/filesystem-rendering-journal.js +0 -80
  172. package/dist/scaffolding/adapters/node/filesystem-rendering-journal.js.map +0 -1
  173. package/dist/scaffolding/adapters/node/filesystem-workspace.d.ts +0 -14
  174. package/dist/scaffolding/adapters/node/filesystem-workspace.d.ts.map +0 -1
  175. package/dist/scaffolding/adapters/node/filesystem-workspace.js +0 -207
  176. package/dist/scaffolding/adapters/node/filesystem-workspace.js.map +0 -1
  177. package/dist/scaffolding/adapters/node/node-input-loader.d.ts +0 -17
  178. package/dist/scaffolding/adapters/node/node-input-loader.d.ts.map +0 -1
  179. package/dist/scaffolding/adapters/node/node-input-loader.js +0 -107
  180. package/dist/scaffolding/adapters/node/node-input-loader.js.map +0 -1
  181. package/dist/scaffolding/adapters/node/node-receipt-validator.d.ts +0 -4
  182. package/dist/scaffolding/adapters/node/node-receipt-validator.d.ts.map +0 -1
  183. package/dist/scaffolding/adapters/node/node-receipt-validator.js +0 -10
  184. package/dist/scaffolding/adapters/node/node-receipt-validator.js.map +0 -1
  185. package/dist/scaffolding/adapters/node/node-rendering-plan-authority.d.ts +0 -3
  186. package/dist/scaffolding/adapters/node/node-rendering-plan-authority.d.ts.map +0 -1
  187. package/dist/scaffolding/adapters/node/node-rendering-plan-authority.js +0 -18
  188. package/dist/scaffolding/adapters/node/node-rendering-plan-authority.js.map +0 -1
  189. package/dist/scaffolding/internal-rendering-regression-api.d.ts +0 -8
  190. package/dist/scaffolding/internal-rendering-regression-api.d.ts.map +0 -1
  191. package/dist/scaffolding/internal-rendering-regression-api.js +0 -8
  192. package/dist/scaffolding/internal-rendering-regression-api.js.map +0 -1
  193. package/dist/scaffolding/kernel/receipt.d.ts +0 -35
  194. package/dist/scaffolding/kernel/receipt.d.ts.map +0 -1
  195. package/dist/scaffolding/kernel/receipt.js +0 -206
  196. package/dist/scaffolding/kernel/receipt.js.map +0 -1
  197. package/dist/scaffolding/kernel/rendering-plan-compiler.d.ts +0 -4
  198. package/dist/scaffolding/kernel/rendering-plan-compiler.d.ts.map +0 -1
  199. package/dist/scaffolding/kernel/rendering-plan-compiler.js +0 -43
  200. package/dist/scaffolding/kernel/rendering-plan-compiler.js.map +0 -1
  201. package/dist/scaffolding/kernel/rendering-plan-validation.d.ts +0 -3
  202. package/dist/scaffolding/kernel/rendering-plan-validation.d.ts.map +0 -1
  203. package/dist/scaffolding/kernel/rendering-plan-validation.js +0 -10
  204. package/dist/scaffolding/kernel/rendering-plan-validation.js.map +0 -1
  205. package/dist/scaffolding/service.d.ts +0 -8
  206. package/dist/scaffolding/service.d.ts.map +0 -1
  207. package/dist/scaffolding/service.js +0 -16
  208. package/dist/scaffolding/service.js.map +0 -1
  209. package/schemas/contract-protobuf-breaking-qualification/v2.schema.json +0 -93
  210. package/schemas/contract-protobuf-evolution/v2.schema.json +0 -147
  211. package/schemas/package-public-api-baseline/v2.schema.json +0 -62
  212. package/schemas/package-public-api-compatibility/v2.schema.json +0 -113
@@ -0,0 +1,244 @@
1
+ import { createHash } from "node:crypto";
2
+ import { resolve } from "node:path";
3
+ import { compareBinaryStrings } from "../../../../../binary-string-comparator.js";
4
+ import { CapabilityInputError } from "../../../../../capability-runtime.js";
5
+ import { ContainedFileReadError, readContainedRegularFile } from "../../../../../filesystem-path-safety.js";
6
+ import { assertNotCancelled } from "../../../../../strict-yaml.js";
7
+ import { parseStrictJson, StrictJsonError } from "../../../../../strict-json.js";
8
+ import { PnpmWorkspaceInventoryReader } from "../../../../../workspace-inventory/adapters/outbound/pnpm/pnpm-workspace-inventory-reader.js";
9
+ import { AjvJsonSchemaReleaseInspector } from "../../../../contract-json-schema-releases/adapters/outbound/filesystem/ajv-json-schema-release-inspector.js";
10
+ import { executableSpecificationArtifactPaths, executableSpecificationPathDeclarations, portableExecutableSpecificationPathIdentity, portableExecutableSpecificationPathProblem } from "../../../application/policies/portable-executable-specification-path.js";
11
+ const MAX_ARTIFACT_BYTES = 8 * 1024 * 1024;
12
+ const MAX_AGGREGATE_ARTIFACT_BYTES = 32 * 1024 * 1024;
13
+ function inputError(code, message) {
14
+ throw new CapabilityInputError({
15
+ code,
16
+ message,
17
+ phase: "executable-specification-inspection",
18
+ retryable: false
19
+ });
20
+ }
21
+ function isRecord(value) {
22
+ return typeof value === "object" && value !== null && !Array.isArray(value);
23
+ }
24
+ function canonicalJson(value) {
25
+ if (value === null || typeof value === "boolean" || typeof value === "string") {
26
+ return JSON.stringify(value);
27
+ }
28
+ if (typeof value === "number" && Number.isFinite(value)) {
29
+ return JSON.stringify(value);
30
+ }
31
+ if (Array.isArray(value)) {
32
+ return `[${value.map(canonicalJson).join(",")}]`;
33
+ }
34
+ if (isRecord(value)) {
35
+ return `{${Object.entries(value)
36
+ .toSorted(([left], [right]) => compareBinaryStrings(left, right))
37
+ .map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson(entry)}`)
38
+ .join(",")}}`;
39
+ }
40
+ inputError("EXECUTABLE_SPECIFICATION_DIGEST_INVALID", "Artifact digest input is invalid.");
41
+ }
42
+ async function readArtifact(root, repositoryPath) {
43
+ try {
44
+ return await readContainedRegularFile({
45
+ candidate: resolve(root, repositoryPath),
46
+ maxBytes: MAX_ARTIFACT_BYTES,
47
+ root
48
+ });
49
+ }
50
+ catch (error) {
51
+ if (error instanceof ContainedFileReadError) {
52
+ if (error.failure === "missing") {
53
+ return undefined;
54
+ }
55
+ inputError(`EXECUTABLE_SPECIFICATION_ARTIFACT_${error.failure.toUpperCase()}`, `Specification artifact is not a safe contained regular file: ${repositoryPath}.`);
56
+ }
57
+ throw error;
58
+ }
59
+ }
60
+ class ArtifactReadSession {
61
+ root;
62
+ maxAggregateBytes;
63
+ #cache = new Map();
64
+ #aggregateBytes = 0;
65
+ constructor(root, maxAggregateBytes) {
66
+ this.root = root;
67
+ this.maxAggregateBytes = maxAggregateBytes;
68
+ }
69
+ async read(repositoryPath) {
70
+ const identity = portableExecutableSpecificationPathIdentity(repositoryPath);
71
+ const cached = this.#cache.get(identity);
72
+ if (cached !== undefined) {
73
+ if (cached.firstPath !== repositoryPath) {
74
+ inputError("EXECUTABLE_SPECIFICATION_ARTIFACT_PATH_COLLISION", `Artifact paths have the same portable identity: ${cached.firstPath} and ${repositoryPath}.`);
75
+ }
76
+ return cached.result;
77
+ }
78
+ const result = readArtifact(this.root, repositoryPath).then((bytes) => {
79
+ if (bytes !== undefined) {
80
+ if (bytes.byteLength > this.maxAggregateBytes - this.#aggregateBytes) {
81
+ inputError("EXECUTABLE_SPECIFICATION_AGGREGATE_BYTES_EXCEEDED", "Executable specification artifacts and workspace manifests exceed the 32 MiB aggregate inspection budget.");
82
+ }
83
+ this.#aggregateBytes += bytes.byteLength;
84
+ }
85
+ return bytes;
86
+ });
87
+ this.#cache.set(identity, { firstPath: repositoryPath, result });
88
+ return result;
89
+ }
90
+ }
91
+ async function packageCatalog(manifestPaths, artifacts, signal) {
92
+ const packages = new Map();
93
+ for (const manifestPath of manifestPaths) {
94
+ assertNotCancelled(signal);
95
+ const bytes = await artifacts.read(manifestPath);
96
+ if (bytes === undefined) {
97
+ continue;
98
+ }
99
+ let value;
100
+ try {
101
+ value = parseStrictJson(bytes.toString("utf8"));
102
+ }
103
+ catch (error) {
104
+ if (error instanceof StrictJsonError && error.failure === "duplicate-key") {
105
+ inputError("EXECUTABLE_SPECIFICATION_PACKAGE_MANIFEST_DUPLICATE_KEY", `Package manifest contains duplicate object keys: ${manifestPath}.`);
106
+ }
107
+ inputError("EXECUTABLE_SPECIFICATION_PACKAGE_MANIFEST_INVALID", `Package manifest is invalid JSON: ${manifestPath}.`);
108
+ }
109
+ if (!isRecord(value) || typeof value["name"] !== "string") {
110
+ continue;
111
+ }
112
+ const name = value["name"];
113
+ if (packages.has(name)) {
114
+ inputError("EXECUTABLE_SPECIFICATION_PACKAGE_DUPLICATE", `Gate package name is not unique in the workspace: ${name}.`);
115
+ }
116
+ const scripts = isRecord(value["scripts"])
117
+ ? new Set(Object.entries(value["scripts"])
118
+ .filter(([, command]) => typeof command === "string" && command.trim().length > 0)
119
+ .map(([script]) => script))
120
+ : new Set();
121
+ packages.set(name, { manifestPath, scripts });
122
+ }
123
+ return packages;
124
+ }
125
+ function observeGate(binding, packages) {
126
+ const target = packages.get(binding.packageName);
127
+ return Object.freeze({
128
+ ...binding,
129
+ ...(target === undefined ? {} : { manifestPath: target.manifestPath }),
130
+ packageExists: target !== undefined,
131
+ scriptExists: target?.scripts.has(binding.script) ?? false
132
+ });
133
+ }
134
+ function gateEntries(specification) {
135
+ return [
136
+ ["mutation", specification.gateBindings.mutation],
137
+ ["property", specification.gateBindings.property],
138
+ ...(specification.gateBindings.typeGeneration === undefined
139
+ ? []
140
+ : [['typeGeneration', specification.gateBindings.typeGeneration]]),
141
+ ...(specification.stateModel.kind === "xstate"
142
+ ? [['spec-model', specification.stateModel.gateBinding]]
143
+ : [])
144
+ ];
145
+ }
146
+ export class FilesystemExecutableSpecificationInspector {
147
+ #workspaceManifestPathReader;
148
+ #maxAggregateArtifactBytes;
149
+ constructor(workspaceManifestPathReader = new PnpmWorkspaceInventoryReader(), maxAggregateArtifactBytes = MAX_AGGREGATE_ARTIFACT_BYTES) {
150
+ if (!Number.isSafeInteger(maxAggregateArtifactBytes) ||
151
+ maxAggregateArtifactBytes < 1 ||
152
+ maxAggregateArtifactBytes > MAX_AGGREGATE_ARTIFACT_BYTES) {
153
+ throw new TypeError("Aggregate artifact budget must be a positive safe integer up to 32 MiB.");
154
+ }
155
+ this.#workspaceManifestPathReader = workspaceManifestPathReader;
156
+ this.#maxAggregateArtifactBytes = maxAggregateArtifactBytes;
157
+ }
158
+ async inspectCatalog(input) {
159
+ assertNotCancelled(input.signal);
160
+ const artifacts = new ArtifactReadSession(input.consumerRoot, this.#maxAggregateArtifactBytes);
161
+ const jsonSchemaInspector = new AjvJsonSchemaReleaseInspector((repositoryPath) => artifacts.read(repositoryPath));
162
+ const manifestPaths = await this.#workspaceManifestPathReader.discoverManifestPaths(input.consumerRoot, "pnpm-workspace.yaml", input.signal);
163
+ const occupiedPaths = new Map();
164
+ for (const declaration of executableSpecificationPathDeclarations(input.catalog)) {
165
+ const identity = portableExecutableSpecificationPathIdentity(declaration.path);
166
+ occupiedPaths.set(identity, declaration);
167
+ }
168
+ const selectedManifestIdentities = new Map();
169
+ for (const manifestPath of manifestPaths) {
170
+ const portabilityProblem = portableExecutableSpecificationPathProblem(manifestPath);
171
+ if (portabilityProblem !== undefined) {
172
+ inputError("EXECUTABLE_SPECIFICATION_MANIFEST_PATH_NOT_PORTABLE", `Selected workspace manifest path is not portable: ${manifestPath} (${portabilityProblem}).`);
173
+ }
174
+ const identity = portableExecutableSpecificationPathIdentity(manifestPath);
175
+ const previousManifest = selectedManifestIdentities.get(identity);
176
+ if (previousManifest !== undefined && previousManifest !== manifestPath) {
177
+ inputError("EXECUTABLE_SPECIFICATION_MANIFEST_PATH_COLLISION", `Selected workspace manifests have the same portable path identity: ${previousManifest} and ${manifestPath}.`);
178
+ }
179
+ const occupiedPath = occupiedPaths.get(identity);
180
+ if (occupiedPath !== undefined &&
181
+ !(occupiedPath.role === "reserved-root-package" &&
182
+ occupiedPath.path === "package.json" &&
183
+ manifestPath === "package.json")) {
184
+ inputError("EXECUTABLE_SPECIFICATION_MANIFEST_PATH_COLLISION", `Selected workspace manifest collides with a declared or reserved executable specification path: ${manifestPath}.`);
185
+ }
186
+ selectedManifestIdentities.set(identity, manifestPath);
187
+ }
188
+ const uniqueManifestPaths = [...selectedManifestIdentities.values()];
189
+ const paths = [
190
+ ...new Set(input.catalog.specifications.flatMap(executableSpecificationArtifactPaths))
191
+ ].toSorted(compareBinaryStrings);
192
+ if (new Set([...uniqueManifestPaths, ...paths].map(portableExecutableSpecificationPathIdentity)).size > 1_024) {
193
+ inputError("EXECUTABLE_SPECIFICATION_ARTIFACT_COUNT_EXCEEDED", "Executable specification catalogs and selected workspace packages may reference at most 1024 unique artifacts.");
194
+ }
195
+ const packages = await packageCatalog(uniqueManifestPaths, artifacts, input.signal);
196
+ for (const repositoryPath of paths) {
197
+ assertNotCancelled(input.signal);
198
+ await artifacts.read(repositoryPath);
199
+ }
200
+ const observations = [];
201
+ for (const specification of input.catalog.specifications) {
202
+ assertNotCancelled(input.signal);
203
+ const content = new Map();
204
+ const missingArtifactPaths = [];
205
+ for (const repositoryPath of [...new Set(executableSpecificationArtifactPaths(specification))].toSorted(compareBinaryStrings)) {
206
+ const bytes = await artifacts.read(repositoryPath);
207
+ if (bytes === undefined) {
208
+ missingArtifactPaths.push(repositoryPath);
209
+ }
210
+ else {
211
+ content.set(repositoryPath, createHash("sha256").update(bytes).digest("hex"));
212
+ }
213
+ }
214
+ const fixtures = specification.documents.map((document, index) => ({
215
+ id: `${specification.id.slice(0, 90)}.document.${index}`,
216
+ path: document.path,
217
+ schemaId: document.schemaId,
218
+ expectation: "valid"
219
+ }));
220
+ const jsonSchemas = await jsonSchemaInspector.inspect({
221
+ consumerRoot: input.consumerRoot,
222
+ schemaPaths: specification.schemaPaths,
223
+ fixtures,
224
+ requireMixedExpectations: false,
225
+ ...(input.signal === undefined ? {} : { signal: input.signal })
226
+ });
227
+ const gates = Object.fromEntries(gateEntries(specification).map(([role, binding]) => [
228
+ role,
229
+ observeGate(binding, packages)
230
+ ]));
231
+ observations.push(Object.freeze({
232
+ id: specification.id,
233
+ jsonSchemas,
234
+ missingArtifactPaths: Object.freeze(missingArtifactPaths),
235
+ gates: Object.freeze(gates),
236
+ artifactDigest: `sha256:${createHash("sha256")
237
+ .update(canonicalJson(Object.fromEntries(content)), "utf8")
238
+ .digest("hex")}`
239
+ }));
240
+ }
241
+ return Object.freeze(observations);
242
+ }
243
+ }
244
+ //# sourceMappingURL=filesystem-executable-specification-inspector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-executable-specification-inspector.js","sourceRoot":"","sources":["../../../../../../src/capabilities/executable-specifications/adapters/outbound/filesystem/filesystem-executable-specification-inspector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,0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KAAK,CAAC,EAAW;aAC5B,CAAC,CACH,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;CACF"}
@@ -0,0 +1,58 @@
1
+ import type { JsonSchemaInspection } from "../../../contract-json-schema-releases/application/model/json-schema-release.js";
2
+ export interface ExecutableSpecificationDocument {
3
+ readonly path: string;
4
+ readonly schemaId: string;
5
+ }
6
+ export interface GeneratedTypeBinding {
7
+ readonly schemaId: string;
8
+ readonly outputPath: string;
9
+ }
10
+ export interface ConsumerGateBinding {
11
+ readonly packageName: string;
12
+ readonly script: string;
13
+ }
14
+ export interface NoStateModel {
15
+ readonly kind: "none";
16
+ }
17
+ export interface XstateStateModel {
18
+ readonly kind: "xstate";
19
+ readonly axes: readonly string[];
20
+ readonly modelPath: string;
21
+ readonly adapterPath: string;
22
+ readonly tracesPath: string;
23
+ readonly diagramPath: string;
24
+ readonly gateBinding: ConsumerGateBinding;
25
+ }
26
+ export interface ExecutableSpecification {
27
+ readonly id: string;
28
+ readonly ownerDocs: readonly string[];
29
+ readonly adrRefs: readonly string[];
30
+ readonly schemaPaths: readonly string[];
31
+ readonly documents: readonly ExecutableSpecificationDocument[];
32
+ readonly generatedTypes: readonly GeneratedTypeBinding[];
33
+ readonly gateBindings: {
34
+ readonly typeGeneration?: ConsumerGateBinding;
35
+ readonly property: ConsumerGateBinding;
36
+ readonly mutation: ConsumerGateBinding;
37
+ };
38
+ readonly stateModel: NoStateModel | XstateStateModel;
39
+ }
40
+ export interface ExecutableSpecificationCatalog {
41
+ readonly schemaVersion: 1;
42
+ readonly configPath: string;
43
+ readonly catalogPath: string;
44
+ readonly specifications: readonly ExecutableSpecification[];
45
+ }
46
+ export interface ObservedGateBinding extends ConsumerGateBinding {
47
+ readonly manifestPath?: string;
48
+ readonly packageExists: boolean;
49
+ readonly scriptExists: boolean;
50
+ }
51
+ export interface ExecutableSpecificationObservation {
52
+ readonly id: string;
53
+ readonly jsonSchemas: JsonSchemaInspection;
54
+ readonly missingArtifactPaths: readonly string[];
55
+ readonly gates: Readonly<Record<string, ObservedGateBinding>>;
56
+ readonly artifactDigest: `sha256:${string}`;
57
+ }
58
+ //# sourceMappingURL=executable-specification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable-specification.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/executable-specifications/application/model/executable-specification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iFAAiF,CAAC;AAE5H,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;CAC3C;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,SAAS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C;CAC7C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=executable-specification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable-specification.js","sourceRoot":"","sources":["../../../../../src/capabilities/executable-specifications/application/model/executable-specification.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { FoundationDiagnostic } from "../../../../check-contract.js";
2
+ import type { ExecutableSpecificationCatalog, ExecutableSpecificationObservation } from "../model/executable-specification.js";
3
+ /** Pure topology validation. It must run before any consumer artifact inspection. */
4
+ export declare function evaluateExecutableSpecificationTopology(catalog: ExecutableSpecificationCatalog): readonly FoundationDiagnostic[];
5
+ export declare function evaluateExecutableSpecifications(catalog: ExecutableSpecificationCatalog, observations: readonly ExecutableSpecificationObservation[]): readonly FoundationDiagnostic[];
6
+ //# sourceMappingURL=evaluate-executable-specifications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate-executable-specifications.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/executable-specifications/application/policies/evaluate-executable-specifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EAGV,8BAA8B,EAC9B,kCAAkC,EACnC,MAAM,sCAAsC,CAAC;AAoK9C,qFAAqF;AACrF,wBAAgB,uCAAuC,CACrD,OAAO,EAAE,8BAA8B,GACtC,SAAS,oBAAoB,EAAE,CAwGjC;AAkGD,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,8BAA8B,EACvC,YAAY,EAAE,SAAS,kCAAkC,EAAE,GAC1D,SAAS,oBAAoB,EAAE,CASjC"}
@@ -0,0 +1,277 @@
1
+ import { EXECUTABLE_SPECIFICATION_RULES } from "../rules.js";
2
+ import { executableSpecificationPathDeclarations, portableExecutableSpecificationPathIdentity, portableExecutableSpecificationPathProblem } from "./portable-executable-specification-path.js";
3
+ function diagnostic(input) {
4
+ return {
5
+ ruleId: input.rule.id,
6
+ severity: input.rule.severity,
7
+ subject: input.subject,
8
+ message: input.message,
9
+ location: { path: input.path },
10
+ relatedLocations: [],
11
+ evidence: input.evidence ?? [],
12
+ remediation: input.rule.remediation,
13
+ requiresArchitectureReview: input.rule.requiresArchitectureReview
14
+ };
15
+ }
16
+ function duplicateValues(values) {
17
+ const seen = new Set();
18
+ const duplicates = new Set();
19
+ for (const value of values) {
20
+ if (seen.has(value)) {
21
+ duplicates.add(value);
22
+ }
23
+ seen.add(value);
24
+ }
25
+ return [...duplicates].toSorted();
26
+ }
27
+ function duplicatePaths(paths) {
28
+ const firstByIdentity = new Map();
29
+ const duplicates = new Set();
30
+ for (const path of paths) {
31
+ const identity = portableExecutableSpecificationPathIdentity(path);
32
+ const first = firstByIdentity.get(identity);
33
+ if (first === undefined) {
34
+ firstByIdentity.set(identity, path);
35
+ }
36
+ else {
37
+ duplicates.add(first);
38
+ }
39
+ }
40
+ return [...duplicates].toSorted();
41
+ }
42
+ function gateKey(binding) {
43
+ return `${binding.packageName}\u0000${binding.script}`;
44
+ }
45
+ function specificationGates(specification) {
46
+ return [
47
+ ...(specification.gateBindings.typeGeneration === undefined
48
+ ? []
49
+ : [['typeGeneration', specification.gateBindings.typeGeneration]]),
50
+ ["property", specification.gateBindings.property],
51
+ ["mutation", specification.gateBindings.mutation],
52
+ ...(specification.stateModel.kind === "xstate"
53
+ ? [["spec-model", specification.stateModel.gateBinding]]
54
+ : [])
55
+ ];
56
+ }
57
+ function generatedAndModelPaths(specification) {
58
+ return [
59
+ ...specification.generatedTypes.map((binding) => binding.outputPath),
60
+ ...(specification.stateModel.kind === "xstate"
61
+ ? [
62
+ specification.stateModel.modelPath,
63
+ specification.stateModel.adapterPath,
64
+ specification.stateModel.tracesPath,
65
+ specification.stateModel.diagramPath
66
+ ]
67
+ : [])
68
+ ];
69
+ }
70
+ function duplicatePathDiagnostics(paths, description) {
71
+ return duplicatePaths(paths).map((path) => diagnostic({
72
+ rule: EXECUTABLE_SPECIFICATION_RULES.pathCollision,
73
+ subject: `catalog-path:${path}`,
74
+ path,
75
+ message: `${description}: ${path}.`
76
+ }));
77
+ }
78
+ function evaluateSpecificationTopology(specification, catalogPath) {
79
+ const diagnostics = [];
80
+ const hasGeneratedTypes = specification.generatedTypes.length > 0;
81
+ const hasTypeGenerationGate = specification.gateBindings.typeGeneration !== undefined;
82
+ if (hasGeneratedTypes !== hasTypeGenerationGate) {
83
+ diagnostics.push(diagnostic({
84
+ rule: EXECUTABLE_SPECIFICATION_RULES.generatedTypeGateMismatch,
85
+ subject: `${specification.id}:gate:typeGeneration`,
86
+ path: catalogPath,
87
+ message: hasGeneratedTypes
88
+ ? "Generated type outputs require a type-generation gate binding."
89
+ : "A data-only specification must not declare a type-generation gate binding."
90
+ }));
91
+ }
92
+ for (const schemaId of duplicateValues(specification.generatedTypes.map((binding) => binding.schemaId))) {
93
+ diagnostics.push(diagnostic({
94
+ rule: EXECUTABLE_SPECIFICATION_RULES.generatedTypeBindingDuplicate,
95
+ subject: `${specification.id}:schema:${schemaId}`,
96
+ path: specification.generatedTypes[0]?.outputPath ?? catalogPath,
97
+ message: `Schema ID has more than one generated type binding: ${schemaId}.`
98
+ }));
99
+ }
100
+ for (const outputPath of duplicateValues(specification.generatedTypes.map((binding) => binding.outputPath))) {
101
+ diagnostics.push(diagnostic({
102
+ rule: EXECUTABLE_SPECIFICATION_RULES.generatedTypeBindingDuplicate,
103
+ subject: `${specification.id}:output:${outputPath}`,
104
+ path: outputPath,
105
+ message: `Generated type output path is bound more than once: ${outputPath}.`
106
+ }));
107
+ }
108
+ for (const duplicate of duplicateValues(specificationGates(specification).map(([, binding]) => gateKey(binding)))) {
109
+ const [packageName = "", script = ""] = duplicate.split("\u0000");
110
+ diagnostics.push(diagnostic({
111
+ rule: EXECUTABLE_SPECIFICATION_RULES.gateNotDistinct,
112
+ subject: `${specification.id}:gate:${packageName}:${script}`,
113
+ path: catalogPath,
114
+ message: `Gate script is reused by more than one evidence role: ${packageName}#${script}.`
115
+ }));
116
+ }
117
+ return diagnostics;
118
+ }
119
+ /** Pure topology validation. It must run before any consumer artifact inspection. */
120
+ export function evaluateExecutableSpecificationTopology(catalog) {
121
+ const diagnostics = [];
122
+ for (const id of duplicateValues(catalog.specifications.map((specification) => specification.id))) {
123
+ diagnostics.push(diagnostic({
124
+ rule: EXECUTABLE_SPECIFICATION_RULES.specificationIdDuplicate,
125
+ subject: `specification:${id}`,
126
+ path: catalog.catalogPath,
127
+ message: `Executable specification ID is declared more than once: ${id}.`
128
+ }));
129
+ }
130
+ for (const specification of catalog.specifications) {
131
+ diagnostics.push(...evaluateSpecificationTopology(specification, catalog.catalogPath));
132
+ }
133
+ const pathDeclarations = executableSpecificationPathDeclarations(catalog);
134
+ for (const declaration of pathDeclarations) {
135
+ const portabilityProblem = portableExecutableSpecificationPathProblem(declaration.path);
136
+ if (portabilityProblem !== undefined) {
137
+ diagnostics.push(diagnostic({
138
+ rule: EXECUTABLE_SPECIFICATION_RULES.pathCollision,
139
+ subject: `catalog-path:${declaration.path}`,
140
+ path: declaration.path,
141
+ message: `Executable specification path is not portable: ${declaration.path} (${portabilityProblem}).`
142
+ }));
143
+ }
144
+ }
145
+ const firstDeclarationByIdentity = new Map();
146
+ for (const declaration of pathDeclarations) {
147
+ const identity = portableExecutableSpecificationPathIdentity(declaration.path);
148
+ const first = firstDeclarationByIdentity.get(identity);
149
+ if (first === undefined) {
150
+ firstDeclarationByIdentity.set(identity, declaration);
151
+ continue;
152
+ }
153
+ const shareableExactEvidence = first.path === declaration.path &&
154
+ first.role === declaration.role &&
155
+ (first.role === "owner" || first.role === "adr");
156
+ if (!shareableExactEvidence) {
157
+ diagnostics.push(diagnostic({
158
+ rule: EXECUTABLE_SPECIFICATION_RULES.pathCollision,
159
+ subject: `catalog-path:${declaration.path}`,
160
+ path: declaration.path,
161
+ message: `Executable specification path roles collide: ${first.role}:${first.path} and ${declaration.role}:${declaration.path}.`
162
+ }));
163
+ }
164
+ }
165
+ const schemaPaths = catalog.specifications.flatMap((specification) => specification.schemaPaths);
166
+ const documentPaths = catalog.specifications.flatMap((specification) => specification.documents.map((document) => document.path));
167
+ const generatedModelPaths = catalog.specifications.flatMap(generatedAndModelPaths);
168
+ const sourcePaths = catalog.specifications.flatMap((specification) => [
169
+ "foundation.config.yaml",
170
+ catalog.configPath,
171
+ catalog.catalogPath,
172
+ "package.json",
173
+ "pnpm-workspace.yaml",
174
+ ...specification.ownerDocs,
175
+ ...specification.adrRefs,
176
+ ...specification.schemaPaths,
177
+ ...specification.documents.map((document) => document.path)
178
+ ]);
179
+ diagnostics.push(...duplicatePathDiagnostics(schemaPaths, "Schema path is declared more than once"), ...duplicatePathDiagnostics(documentPaths, "Document path is declared more than once"), ...duplicatePathDiagnostics(generatedModelPaths, "Generated or executable artifact path is assigned more than once"));
180
+ const sourcePathSet = new Set(sourcePaths.map(portableExecutableSpecificationPathIdentity));
181
+ for (const path of [...new Set(generatedModelPaths)].toSorted()) {
182
+ if (sourcePathSet.has(portableExecutableSpecificationPathIdentity(path)) ||
183
+ portableExecutableSpecificationPathIdentity(path).endsWith("/package.json")) {
184
+ diagnostics.push(diagnostic({
185
+ rule: EXECUTABLE_SPECIFICATION_RULES.pathCollision,
186
+ subject: `catalog-path:${path}`,
187
+ path,
188
+ message: `Generated or executable artifact collides with a source, owner, ADR, schema, or document path: ${path}.`
189
+ }));
190
+ }
191
+ }
192
+ return diagnostics;
193
+ }
194
+ function evaluateBindings(specification, observation) {
195
+ const diagnostics = [];
196
+ const schemaIds = new Set(observation.jsonSchemas.schemaIds);
197
+ for (const document of specification.documents) {
198
+ if (!schemaIds.has(document.schemaId)) {
199
+ diagnostics.push(diagnostic({
200
+ rule: EXECUTABLE_SPECIFICATION_RULES.schemaBindingUnknown,
201
+ subject: `${specification.id}:document:${document.path}`,
202
+ path: document.path,
203
+ message: `Document binds an unknown local schema ID: ${document.schemaId}.`
204
+ }));
205
+ }
206
+ }
207
+ for (const binding of specification.generatedTypes) {
208
+ if (!schemaIds.has(binding.schemaId)) {
209
+ diagnostics.push(diagnostic({
210
+ rule: EXECUTABLE_SPECIFICATION_RULES.schemaBindingUnknown,
211
+ subject: `${specification.id}:generated-type:${binding.outputPath}`,
212
+ path: binding.outputPath,
213
+ message: `Generated type binds an unknown local schema ID: ${binding.schemaId}.`
214
+ }));
215
+ }
216
+ }
217
+ return diagnostics;
218
+ }
219
+ function evaluateGates(specification, observation) {
220
+ const diagnostics = [];
221
+ const gates = specificationGates(specification);
222
+ for (const [role] of gates) {
223
+ const observed = observation.gates[role];
224
+ if (observed === undefined || !observed.packageExists || !observed.scriptExists) {
225
+ diagnostics.push(diagnostic({
226
+ rule: EXECUTABLE_SPECIFICATION_RULES.gateMissing,
227
+ subject: `${specification.id}:gate:${role}`,
228
+ path: observed?.manifestPath ?? observation.id,
229
+ message: observed?.packageExists === true
230
+ ? `Gate ${role} binds a missing package script: ${observed.packageName}#${observed.script}.`
231
+ : `Gate ${role} binds a missing workspace package: ${observed?.packageName ?? "unknown"}.`
232
+ }));
233
+ }
234
+ }
235
+ return diagnostics;
236
+ }
237
+ function evaluateSpecification(specification, observation) {
238
+ const diagnostics = [];
239
+ for (const path of observation.missingArtifactPaths) {
240
+ diagnostics.push(diagnostic({
241
+ rule: EXECUTABLE_SPECIFICATION_RULES.artifactMissing,
242
+ subject: `${specification.id}:artifact:${path}`,
243
+ path,
244
+ message: `Declared executable specification artifact is missing: ${path}.`,
245
+ evidence: [{ kind: "artifact-corpus-digest", value: observation.artifactDigest }]
246
+ }));
247
+ }
248
+ for (const result of observation.jsonSchemas.fixtureResults) {
249
+ if (!result.matched) {
250
+ const document = specification.documents[Number(result.id.split(".").at(-1))];
251
+ diagnostics.push(diagnostic({
252
+ rule: EXECUTABLE_SPECIFICATION_RULES.documentInvalid,
253
+ subject: `${specification.id}:document:${document?.path ?? result.id}`,
254
+ path: document?.path ?? result.id,
255
+ message: "JSON specification document does not conform to its declared schema.",
256
+ evidence: [
257
+ { kind: "schema-set-digest", value: observation.jsonSchemas.schemaSetDigest },
258
+ { kind: "document-corpus-digest", value: observation.jsonSchemas.fixtureCorpusDigest }
259
+ ]
260
+ }));
261
+ }
262
+ }
263
+ diagnostics.push(...evaluateBindings(specification, observation));
264
+ diagnostics.push(...evaluateGates(specification, observation));
265
+ return diagnostics;
266
+ }
267
+ export function evaluateExecutableSpecifications(catalog, observations) {
268
+ const diagnostics = [];
269
+ for (const [index, specification] of catalog.specifications.entries()) {
270
+ const observation = observations[index];
271
+ if (observation !== undefined) {
272
+ diagnostics.push(...evaluateSpecification(specification, observation));
273
+ }
274
+ }
275
+ return diagnostics;
276
+ }
277
+ //# sourceMappingURL=evaluate-executable-specifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate-executable-specifications.js","sourceRoot":"","sources":["../../../../../src/capabilities/executable-specifications/application/policies/evaluate-executable-specifications.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,8BAA8B,EAE/B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uCAAuC,EACvC,2CAA2C,EAC3C,0CAA0C,EAC3C,MAAM,6CAA6C,CAAC;AAErD,SAAS,UAAU,CAAC,KAMnB;IACC,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE;QACrB,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ;QAC7B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE;QAC9B,gBAAgB,EAAE,EAAE;QACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,EAAE;QAC9B,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW;QACnC,0BAA0B,EAAE,KAAK,CAAC,IAAI,CAAC,0BAA0B;KAClE,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,MAAyB;IAChD,MAAM,IAAI,GAAG,IAAI,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