@dailephd/my-frontend-observer 0.8.1

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 (316) hide show
  1. package/CHANGELOG.md +397 -0
  2. package/LICENSE +21 -0
  3. package/README.md +255 -0
  4. package/dist/application/browserCaptureService.d.ts +11 -0
  5. package/dist/application/browserCaptureService.js +12 -0
  6. package/dist/application/browserCaptureService.js.map +1 -0
  7. package/dist/application/comparisonService.d.ts +56 -0
  8. package/dist/application/comparisonService.js +77 -0
  9. package/dist/application/comparisonService.js.map +1 -0
  10. package/dist/application/externalReferencePersistenceService.d.ts +75 -0
  11. package/dist/application/externalReferencePersistenceService.js +182 -0
  12. package/dist/application/externalReferencePersistenceService.js.map +1 -0
  13. package/dist/application/frontendContractEvaluationService.d.ts +49 -0
  14. package/dist/application/frontendContractEvaluationService.js +112 -0
  15. package/dist/application/frontendContractEvaluationService.js.map +1 -0
  16. package/dist/application/frontendContractPersistenceService.d.ts +56 -0
  17. package/dist/application/frontendContractPersistenceService.js +91 -0
  18. package/dist/application/frontendContractPersistenceService.js.map +1 -0
  19. package/dist/application/observationPersistence.d.ts +59 -0
  20. package/dist/application/observationPersistence.js +79 -0
  21. package/dist/application/observationPersistence.js.map +1 -0
  22. package/dist/application/projectCheckService.d.ts +3 -0
  23. package/dist/application/projectCheckService.js +169 -0
  24. package/dist/application/projectCheckService.js.map +1 -0
  25. package/dist/application/projectWorkflowService.d.ts +46 -0
  26. package/dist/application/projectWorkflowService.js +92 -0
  27. package/dist/application/projectWorkflowService.js.map +1 -0
  28. package/dist/application/referenceFidelityEvaluationService.d.ts +28 -0
  29. package/dist/application/referenceFidelityEvaluationService.js +45 -0
  30. package/dist/application/referenceFidelityEvaluationService.js.map +1 -0
  31. package/dist/artifacts/artifactReader.d.ts +19 -0
  32. package/dist/artifacts/artifactReader.js +36 -0
  33. package/dist/artifacts/artifactReader.js.map +1 -0
  34. package/dist/artifacts/artifactWriter.d.ts +25 -0
  35. package/dist/artifacts/artifactWriter.js +68 -0
  36. package/dist/artifacts/artifactWriter.js.map +1 -0
  37. package/dist/artifacts/comparisonArtifactReader.d.ts +18 -0
  38. package/dist/artifacts/comparisonArtifactReader.js +35 -0
  39. package/dist/artifacts/comparisonArtifactReader.js.map +1 -0
  40. package/dist/artifacts/comparisonArtifactWriter.d.ts +41 -0
  41. package/dist/artifacts/comparisonArtifactWriter.js +67 -0
  42. package/dist/artifacts/comparisonArtifactWriter.js.map +1 -0
  43. package/dist/artifacts/externalReferenceArtifactReader.d.ts +18 -0
  44. package/dist/artifacts/externalReferenceArtifactReader.js +35 -0
  45. package/dist/artifacts/externalReferenceArtifactReader.js.map +1 -0
  46. package/dist/artifacts/externalReferenceArtifactWriter.d.ts +44 -0
  47. package/dist/artifacts/externalReferenceArtifactWriter.js +77 -0
  48. package/dist/artifacts/externalReferenceArtifactWriter.js.map +1 -0
  49. package/dist/artifacts/frontendContractArtifactReader.d.ts +24 -0
  50. package/dist/artifacts/frontendContractArtifactReader.js +47 -0
  51. package/dist/artifacts/frontendContractArtifactReader.js.map +1 -0
  52. package/dist/artifacts/frontendContractArtifactWriter.d.ts +34 -0
  53. package/dist/artifacts/frontendContractArtifactWriter.js +70 -0
  54. package/dist/artifacts/frontendContractArtifactWriter.js.map +1 -0
  55. package/dist/artifacts/frontendContractEvaluationArtifactReader.d.ts +17 -0
  56. package/dist/artifacts/frontendContractEvaluationArtifactReader.js +34 -0
  57. package/dist/artifacts/frontendContractEvaluationArtifactReader.js.map +1 -0
  58. package/dist/artifacts/frontendContractEvaluationArtifactWriter.d.ts +32 -0
  59. package/dist/artifacts/frontendContractEvaluationArtifactWriter.js +58 -0
  60. package/dist/artifacts/frontendContractEvaluationArtifactWriter.js.map +1 -0
  61. package/dist/artifacts/types.d.ts +17 -0
  62. package/dist/artifacts/types.js +2 -0
  63. package/dist/artifacts/types.js.map +1 -0
  64. package/dist/browser/chromiumAdapter.d.ts +21 -0
  65. package/dist/browser/chromiumAdapter.js +204 -0
  66. package/dist/browser/chromiumAdapter.js.map +1 -0
  67. package/dist/browser/evidenceCapture.d.ts +62 -0
  68. package/dist/browser/evidenceCapture.js +500 -0
  69. package/dist/browser/evidenceCapture.js.map +1 -0
  70. package/dist/browser/scrollCapture.d.ts +32 -0
  71. package/dist/browser/scrollCapture.js +163 -0
  72. package/dist/browser/scrollCapture.js.map +1 -0
  73. package/dist/browser/types.d.ts +24 -0
  74. package/dist/browser/types.js +2 -0
  75. package/dist/browser/types.js.map +1 -0
  76. package/dist/cli.d.ts +8 -0
  77. package/dist/cli.js +2411 -0
  78. package/dist/cli.js.map +1 -0
  79. package/dist/domain/boundedAgentContext.d.ts +226 -0
  80. package/dist/domain/boundedAgentContext.js +355 -0
  81. package/dist/domain/boundedAgentContext.js.map +1 -0
  82. package/dist/domain/boundedAgentContextCorrelation.d.ts +74 -0
  83. package/dist/domain/boundedAgentContextCorrelation.js +441 -0
  84. package/dist/domain/boundedAgentContextCorrelation.js.map +1 -0
  85. package/dist/domain/boundedAgentContextIdentity.d.ts +26 -0
  86. package/dist/domain/boundedAgentContextIdentity.js +69 -0
  87. package/dist/domain/boundedAgentContextIdentity.js.map +1 -0
  88. package/dist/domain/boundedAgentContextProjection.d.ts +71 -0
  89. package/dist/domain/boundedAgentContextProjection.js +477 -0
  90. package/dist/domain/boundedAgentContextProjection.js.map +1 -0
  91. package/dist/domain/comparison.d.ts +220 -0
  92. package/dist/domain/comparison.js +350 -0
  93. package/dist/domain/comparison.js.map +1 -0
  94. package/dist/domain/comparisonEngine.d.ts +76 -0
  95. package/dist/domain/comparisonEngine.js +734 -0
  96. package/dist/domain/comparisonEngine.js.map +1 -0
  97. package/dist/domain/comparisonIdentity.d.ts +13 -0
  98. package/dist/domain/comparisonIdentity.js +46 -0
  99. package/dist/domain/comparisonIdentity.js.map +1 -0
  100. package/dist/domain/completion.d.ts +30 -0
  101. package/dist/domain/completion.js +22 -0
  102. package/dist/domain/completion.js.map +1 -0
  103. package/dist/domain/diagnostics.d.ts +17 -0
  104. package/dist/domain/diagnostics.js +77 -0
  105. package/dist/domain/diagnostics.js.map +1 -0
  106. package/dist/domain/evidence.d.ts +29 -0
  107. package/dist/domain/evidence.js +59 -0
  108. package/dist/domain/evidence.js.map +1 -0
  109. package/dist/domain/explicitState.d.ts +40 -0
  110. package/dist/domain/explicitState.js +54 -0
  111. package/dist/domain/explicitState.js.map +1 -0
  112. package/dist/domain/externalReference.d.ts +158 -0
  113. package/dist/domain/externalReference.js +167 -0
  114. package/dist/domain/externalReference.js.map +1 -0
  115. package/dist/domain/externalReferenceApplicability.d.ts +43 -0
  116. package/dist/domain/externalReferenceApplicability.js +52 -0
  117. package/dist/domain/externalReferenceApplicability.js.map +1 -0
  118. package/dist/domain/externalReferenceCompatibility.d.ts +40 -0
  119. package/dist/domain/externalReferenceCompatibility.js +48 -0
  120. package/dist/domain/externalReferenceCompatibility.js.map +1 -0
  121. package/dist/domain/externalReferenceFidelity.d.ts +171 -0
  122. package/dist/domain/externalReferenceFidelity.js +419 -0
  123. package/dist/domain/externalReferenceFidelity.js.map +1 -0
  124. package/dist/domain/externalReferenceIdentity.d.ts +38 -0
  125. package/dist/domain/externalReferenceIdentity.js +70 -0
  126. package/dist/domain/externalReferenceIdentity.js.map +1 -0
  127. package/dist/domain/externalReferenceImage.d.ts +35 -0
  128. package/dist/domain/externalReferenceImage.js +160 -0
  129. package/dist/domain/externalReferenceImage.js.map +1 -0
  130. package/dist/domain/externalReferenceRegionRelationships.d.ts +63 -0
  131. package/dist/domain/externalReferenceRegionRelationships.js +98 -0
  132. package/dist/domain/externalReferenceRegionRelationships.js.map +1 -0
  133. package/dist/domain/externalReferenceRegions.d.ts +65 -0
  134. package/dist/domain/externalReferenceRegions.js +105 -0
  135. package/dist/domain/externalReferenceRegions.js.map +1 -0
  136. package/dist/domain/externalReferenceRequirementIdentity.d.ts +12 -0
  137. package/dist/domain/externalReferenceRequirementIdentity.js +35 -0
  138. package/dist/domain/externalReferenceRequirementIdentity.js.map +1 -0
  139. package/dist/domain/externalReferenceRequirements.d.ts +215 -0
  140. package/dist/domain/externalReferenceRequirements.js +401 -0
  141. package/dist/domain/externalReferenceRequirements.js.map +1 -0
  142. package/dist/domain/externalReferenceRuntimeBinding.d.ts +146 -0
  143. package/dist/domain/externalReferenceRuntimeBinding.js +183 -0
  144. package/dist/domain/externalReferenceRuntimeBinding.js.map +1 -0
  145. package/dist/domain/frontendContractEvaluation.d.ts +57 -0
  146. package/dist/domain/frontendContractEvaluation.js +454 -0
  147. package/dist/domain/frontendContractEvaluation.js.map +1 -0
  148. package/dist/domain/frontendContractEvaluationArtifact.d.ts +65 -0
  149. package/dist/domain/frontendContractEvaluationArtifact.js +108 -0
  150. package/dist/domain/frontendContractEvaluationArtifact.js.map +1 -0
  151. package/dist/domain/frontendContractIdentity.d.ts +39 -0
  152. package/dist/domain/frontendContractIdentity.js +70 -0
  153. package/dist/domain/frontendContractIdentity.js.map +1 -0
  154. package/dist/domain/frontendContracts.d.ts +188 -0
  155. package/dist/domain/frontendContracts.js +260 -0
  156. package/dist/domain/frontendContracts.js.map +1 -0
  157. package/dist/domain/identity.d.ts +21 -0
  158. package/dist/domain/identity.js +47 -0
  159. package/dist/domain/identity.js.map +1 -0
  160. package/dist/domain/referenceCorrectionIdentity.d.ts +40 -0
  161. package/dist/domain/referenceCorrectionIdentity.js +77 -0
  162. package/dist/domain/referenceCorrectionIdentity.js.map +1 -0
  163. package/dist/domain/referenceCorrectionWorkflow.d.ts +160 -0
  164. package/dist/domain/referenceCorrectionWorkflow.js +165 -0
  165. package/dist/domain/referenceCorrectionWorkflow.js.map +1 -0
  166. package/dist/domain/referenceFidelityProjection.d.ts +65 -0
  167. package/dist/domain/referenceFidelityProjection.js +135 -0
  168. package/dist/domain/referenceFidelityProjection.js.map +1 -0
  169. package/dist/domain/relationships.d.ts +210 -0
  170. package/dist/domain/relationships.js +352 -0
  171. package/dist/domain/relationships.js.map +1 -0
  172. package/dist/domain/schema.d.ts +269 -0
  173. package/dist/domain/schema.js +442 -0
  174. package/dist/domain/schema.js.map +1 -0
  175. package/dist/domain/scrollEvidence.d.ts +51 -0
  176. package/dist/domain/scrollEvidence.js +134 -0
  177. package/dist/domain/scrollEvidence.js.map +1 -0
  178. package/dist/index.d.ts +114 -0
  179. package/dist/index.js +64 -0
  180. package/dist/index.js.map +1 -0
  181. package/dist/projectWorkflow/aliasCatalog.d.ts +21 -0
  182. package/dist/projectWorkflow/aliasCatalog.js +67 -0
  183. package/dist/projectWorkflow/aliasCatalog.js.map +1 -0
  184. package/dist/projectWorkflow/checkAcceptance.d.ts +25 -0
  185. package/dist/projectWorkflow/checkAcceptance.js +55 -0
  186. package/dist/projectWorkflow/checkAcceptance.js.map +1 -0
  187. package/dist/projectWorkflow/checkResult.d.ts +85 -0
  188. package/dist/projectWorkflow/checkResult.js +101 -0
  189. package/dist/projectWorkflow/checkResult.js.map +1 -0
  190. package/dist/projectWorkflow/projectConfig.d.ts +43 -0
  191. package/dist/projectWorkflow/projectConfig.js +84 -0
  192. package/dist/projectWorkflow/projectConfig.js.map +1 -0
  193. package/dist/projectWorkflow/projectDiscovery.d.ts +9 -0
  194. package/dist/projectWorkflow/projectDiscovery.js +20 -0
  195. package/dist/projectWorkflow/projectDiscovery.js.map +1 -0
  196. package/dist/projectWorkflow/projectPaths.d.ts +8 -0
  197. package/dist/projectWorkflow/projectPaths.js +23 -0
  198. package/dist/projectWorkflow/projectPaths.js.map +1 -0
  199. package/dist/request/paths.d.ts +14 -0
  200. package/dist/request/paths.js +33 -0
  201. package/dist/request/paths.js.map +1 -0
  202. package/dist/request/request.d.ts +111 -0
  203. package/dist/request/request.js +464 -0
  204. package/dist/request/request.js.map +1 -0
  205. package/dist/safety/policy.d.ts +14 -0
  206. package/dist/safety/policy.js +81 -0
  207. package/dist/safety/policy.js.map +1 -0
  208. package/dist/viewer/assets/index-CN_yb9Uf.css +1 -0
  209. package/dist/viewer/assets/index-D98S1_2d.js +9 -0
  210. package/dist/viewer/icons/icon-192.png +0 -0
  211. package/dist/viewer/icons/icon-512.png +0 -0
  212. package/dist/viewer/index.html +15 -0
  213. package/dist/viewer/manifest.webmanifest +1 -0
  214. package/dist/viewer/registerSW.js +1 -0
  215. package/dist/viewer/sw.js +1 -0
  216. package/dist/viewer/workbox-9c191d2f.js +1 -0
  217. package/dist/viewerServer/context.d.ts +48 -0
  218. package/dist/viewerServer/context.js +60 -0
  219. package/dist/viewerServer/context.js.map +1 -0
  220. package/dist/viewerServer/evidence/classify.d.ts +59 -0
  221. package/dist/viewerServer/evidence/classify.js +124 -0
  222. package/dist/viewerServer/evidence/classify.js.map +1 -0
  223. package/dist/viewerServer/evidence/comparisonView.d.ts +28 -0
  224. package/dist/viewerServer/evidence/comparisonView.js +43 -0
  225. package/dist/viewerServer/evidence/comparisonView.js.map +1 -0
  226. package/dist/viewerServer/evidence/contextSourceView.d.ts +25 -0
  227. package/dist/viewerServer/evidence/contextSourceView.js +20 -0
  228. package/dist/viewerServer/evidence/contextSourceView.js.map +1 -0
  229. package/dist/viewerServer/evidence/discovery.d.ts +31 -0
  230. package/dist/viewerServer/evidence/discovery.js +78 -0
  231. package/dist/viewerServer/evidence/discovery.js.map +1 -0
  232. package/dist/viewerServer/evidence/evaluationView.d.ts +32 -0
  233. package/dist/viewerServer/evidence/evaluationView.js +50 -0
  234. package/dist/viewerServer/evidence/evaluationView.js.map +1 -0
  235. package/dist/viewerServer/evidence/handles.d.ts +21 -0
  236. package/dist/viewerServer/evidence/handles.js +43 -0
  237. package/dist/viewerServer/evidence/handles.js.map +1 -0
  238. package/dist/viewerServer/evidence/index.d.ts +41 -0
  239. package/dist/viewerServer/evidence/index.js +82 -0
  240. package/dist/viewerServer/evidence/index.js.map +1 -0
  241. package/dist/viewerServer/evidence/limits.d.ts +27 -0
  242. package/dist/viewerServer/evidence/limits.js +28 -0
  243. package/dist/viewerServer/evidence/limits.js.map +1 -0
  244. package/dist/viewerServer/evidence/linkedEvidence.d.ts +43 -0
  245. package/dist/viewerServer/evidence/linkedEvidence.js +151 -0
  246. package/dist/viewerServer/evidence/linkedEvidence.js.map +1 -0
  247. package/dist/viewerServer/evidence/mediaResolver.d.ts +16 -0
  248. package/dist/viewerServer/evidence/mediaResolver.js +85 -0
  249. package/dist/viewerServer/evidence/mediaResolver.js.map +1 -0
  250. package/dist/viewerServer/evidence/observationView.d.ts +29 -0
  251. package/dist/viewerServer/evidence/observationView.js +46 -0
  252. package/dist/viewerServer/evidence/observationView.js.map +1 -0
  253. package/dist/viewerServer/evidence/pathSafety.d.ts +11 -0
  254. package/dist/viewerServer/evidence/pathSafety.js +31 -0
  255. package/dist/viewerServer/evidence/pathSafety.js.map +1 -0
  256. package/dist/viewerServer/evidence/projection.d.ts +55 -0
  257. package/dist/viewerServer/evidence/projection.js +152 -0
  258. package/dist/viewerServer/evidence/projection.js.map +1 -0
  259. package/dist/viewerServer/evidence/referenceView.d.ts +133 -0
  260. package/dist/viewerServer/evidence/referenceView.js +169 -0
  261. package/dist/viewerServer/evidence/referenceView.js.map +1 -0
  262. package/dist/viewerServer/httpServer.d.ts +27 -0
  263. package/dist/viewerServer/httpServer.js +381 -0
  264. package/dist/viewerServer/httpServer.js.map +1 -0
  265. package/dist/viewerServer/openBrowser.d.ts +7 -0
  266. package/dist/viewerServer/openBrowser.js +32 -0
  267. package/dist/viewerServer/openBrowser.js.map +1 -0
  268. package/dist/viewerServer/port.d.ts +16 -0
  269. package/dist/viewerServer/port.js +19 -0
  270. package/dist/viewerServer/port.js.map +1 -0
  271. package/dist/viewerServer/viewerService.d.ts +62 -0
  272. package/dist/viewerServer/viewerService.js +88 -0
  273. package/dist/viewerServer/viewerService.js.map +1 -0
  274. package/docs/ARCHITECTURE.md +1286 -0
  275. package/docs/CI_CD.md +250 -0
  276. package/docs/COMMANDS.md +972 -0
  277. package/docs/CONTRACTS.md +1856 -0
  278. package/docs/CURRENT_STATE.md +1049 -0
  279. package/docs/DEVELOPMENT.md +202 -0
  280. package/docs/DOCUMENTATION_PRESERVATION_POLICY.md +50 -0
  281. package/docs/PROJECT_DESCRIPTION.md +2221 -0
  282. package/docs/PROJECT_MILESTONES.md +2526 -0
  283. package/docs/PROJECT_OVERVIEW.md +150 -0
  284. package/docs/QUICKSTART.md +83 -0
  285. package/docs/RELEASE.md +27 -0
  286. package/docs/ROADMAP.md +641 -0
  287. package/docs/SECURITY.md +218 -0
  288. package/docs/WORKFLOWS.md +642 -0
  289. package/docs/plans/v0.8-implementation-plan.md +655 -0
  290. package/docs/plans/v0.8.1-cli-usability-patch-plan.md +505 -0
  291. package/docs/reports/v0.7-bounded-fidelity-context-prompt7.md +243 -0
  292. package/docs/reports/v0.7-implementation-completeness-documentation-reconciliation.md +497 -0
  293. package/docs/reports/v0.7-pre-release-readiness.md +337 -0
  294. package/docs/reports/v0.7-reference-binding-prompt5.md +223 -0
  295. package/docs/reports/v0.7-reference-compatibility-prompt4.md +234 -0
  296. package/docs/reports/v0.7-reference-correction-workflow-prompt8.md +222 -0
  297. package/docs/reports/v0.7-reference-fidelity-prompt6.md +216 -0
  298. package/docs/reports/v0.7-reference-foundation-prompt1.md +151 -0
  299. package/docs/reports/v0.7-reference-regions-prompt2.md +195 -0
  300. package/docs/reports/v0.7-reference-requirements-prompt3.md +217 -0
  301. package/docs/reports/v0.7-release-prep.md +423 -0
  302. package/docs/reports/v0.8-binding-fidelity-interaction-batch6.md +279 -0
  303. package/docs/reports/v0.8-bounded-context-correlation-batch7.md +233 -0
  304. package/docs/reports/v0.8-comparison-contract-inspection-batch4.md +279 -0
  305. package/docs/reports/v0.8-evidence-index-readers-batch2.md +247 -0
  306. package/docs/reports/v0.8-implementation-completeness-documentation-reconciliation.md +741 -0
  307. package/docs/reports/v0.8-integrated-viewer-acceptance-batch8.md +128 -0
  308. package/docs/reports/v0.8-observation-svg-inspection-batch3.md +223 -0
  309. package/docs/reports/v0.8-prerelease-readiness-cross-platform-security-code-rot.md +687 -0
  310. package/docs/reports/v0.8-reference-candidate-inspection-batch5.md +232 -0
  311. package/docs/reports/v0.8-viewer-runtime-pwa-batch1.md +278 -0
  312. package/docs/reports/v0.8.1-check-orchestration-prompt2.md +69 -0
  313. package/docs/reports/v0.8.1-implementation-completeness-documentation-reconciliation.md +114 -0
  314. package/docs/reports/v0.8.1-prerelease-readiness-cross-platform-security-code-rot.md +170 -0
  315. package/docs/reports/v0.8.1-project-workflow-foundation-prompt1.md +66 -0
  316. package/package.json +58 -0
@@ -0,0 +1,11 @@
1
+ import type { NormalizedObservationRequest } from '../request/request.js';
2
+ import type { BrowserCaptureResult } from '../browser/types.js';
3
+ export type { BrowserCaptureResult, BrowserProvenance } from '../browser/types.js';
4
+ /**
5
+ * Minimum application-facing seam over the browser adapter: takes an
6
+ * already-validated request and returns the observer-owned browser-boundary
7
+ * result. Coordinates nothing beyond that single invocation - no page/target
8
+ * evidence, no artifact writing, no CLI reporting. Later batches extend this
9
+ * seam rather than calling the browser adapter directly.
10
+ */
11
+ export declare function runBrowserCapture(request: NormalizedObservationRequest): Promise<BrowserCaptureResult>;
@@ -0,0 +1,12 @@
1
+ import { captureViewport } from '../browser/chromiumAdapter.js';
2
+ /**
3
+ * Minimum application-facing seam over the browser adapter: takes an
4
+ * already-validated request and returns the observer-owned browser-boundary
5
+ * result. Coordinates nothing beyond that single invocation - no page/target
6
+ * evidence, no artifact writing, no CLI reporting. Later batches extend this
7
+ * seam rather than calling the browser adapter directly.
8
+ */
9
+ export async function runBrowserCapture(request) {
10
+ return captureViewport(request);
11
+ }
12
+ //# sourceMappingURL=browserCaptureService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browserCaptureService.js","sourceRoot":"","sources":["../../src/application/browserCaptureService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAKhE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAqC;IAC3E,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { ObservationArtifact } from '../domain/schema.js';
2
+ import type { ComparabilityState, ComparisonConfig } from '../domain/comparison.js';
3
+ import type { Diagnostic } from '../domain/diagnostics.js';
4
+ import type { WriteComparisonArtifactOptions } from '../artifacts/comparisonArtifactWriter.js';
5
+ export type { PersistedComparisonResult } from '../artifacts/comparisonArtifactWriter.js';
6
+ /** Default comparison output location, mirroring `request.ts`'s `DEFAULT_OUTPUT_LOCATION` for observations - distinct directories so comparisons never collide with source observations. */
7
+ export declare const DEFAULT_COMPARISON_OUTPUT_LOCATION = "comparisons";
8
+ export interface CompareAndPersistOptions {
9
+ config?: Partial<ComparisonConfig>;
10
+ /** Portable, relative output location (validated the same way as an observation's `outputLocation`). Defaults to `DEFAULT_COMPARISON_OUTPUT_LOCATION`. */
11
+ outputLocation?: string;
12
+ cwd?: WriteComparisonArtifactOptions['cwd'];
13
+ }
14
+ /**
15
+ * Observer-owned summary of one full compare-and-persist attempt, with just
16
+ * enough information for a presentation layer (a future Batch 4 CLI) to
17
+ * report a result without seeing a raw filesystem exception or persistence
18
+ * implementation detail.
19
+ */
20
+ export type ApplicationComparisonResult = {
21
+ ok: true;
22
+ comparisonId: string;
23
+ comparisonRequestId: string;
24
+ comparability: ComparabilityState;
25
+ artifactRoot: string;
26
+ manifestPath: string;
27
+ differenceCount: number;
28
+ relationshipChangeCount: number;
29
+ diagnosticsCount: number;
30
+ } | {
31
+ ok: false;
32
+ diagnostics: Diagnostic[];
33
+ };
34
+ /**
35
+ * The one canonical application-level comparison use case: takes two
36
+ * already-validated/in-memory `ObservationArtifact`s, runs the existing pure
37
+ * `compareObservations` exactly once, and - only for a structurally valid
38
+ * result - persists it exactly once through the existing comparison
39
+ * writer. Never launches Chromium, never re-resolves targets, never mutates
40
+ * either source observation.
41
+ */
42
+ export declare function compareAndPersist(before: ObservationArtifact, after: ObservationArtifact, options?: CompareAndPersistOptions): Promise<ApplicationComparisonResult>;
43
+ /**
44
+ * The canonical Batch 4 CLI-facing orchestration: reads two already-persisted
45
+ * observation artifacts by their root directory (each expected to contain
46
+ * `manifest.json`, mirroring `writeObservationArtifact`'s own layout) through
47
+ * the existing `readObservationArtifact` reader, then delegates to
48
+ * `compareAndPersist` exactly once. A thin wrapper only - artifact reading
49
+ * stays owned by `artifacts/artifactReader.ts`, comparison stays owned by
50
+ * `domain/comparisonEngine.ts`, and persistence stays owned by
51
+ * `artifacts/comparisonArtifactWriter.ts`. Kept in `application/` (not
52
+ * `artifacts/`) so `src/cli.ts` can depend on it without importing the
53
+ * artifacts layer directly - see `tests/unit/cli.test.ts`'s import-boundary
54
+ * assertion. Never launches a browser, never re-resolves targets.
55
+ */
56
+ export declare function compareAndPersistFromArtifactRoots(beforeRoot: string, afterRoot: string, options?: CompareAndPersistOptions): Promise<ApplicationComparisonResult>;
@@ -0,0 +1,77 @@
1
+ import path from 'node:path';
2
+ import { compareObservations } from '../domain/comparisonEngine.js';
3
+ import { DIAGNOSTIC_SEVERITY } from '../domain/diagnostics.js';
4
+ import { normalizeOutputLocation } from '../request/paths.js';
5
+ import { writeComparisonArtifact } from '../artifacts/comparisonArtifactWriter.js';
6
+ import { readObservationArtifact } from '../artifacts/artifactReader.js';
7
+ import { MANIFEST_FILENAME as OBSERVATION_MANIFEST_FILENAME } from '../artifacts/artifactWriter.js';
8
+ /** Default comparison output location, mirroring `request.ts`'s `DEFAULT_OUTPUT_LOCATION` for observations - distinct directories so comparisons never collide with source observations. */
9
+ export const DEFAULT_COMPARISON_OUTPUT_LOCATION = 'comparisons';
10
+ /**
11
+ * The one canonical application-level comparison use case: takes two
12
+ * already-validated/in-memory `ObservationArtifact`s, runs the existing pure
13
+ * `compareObservations` exactly once, and - only for a structurally valid
14
+ * result - persists it exactly once through the existing comparison
15
+ * writer. Never launches Chromium, never re-resolves targets, never mutates
16
+ * either source observation.
17
+ */
18
+ export async function compareAndPersist(before, after, options = {}) {
19
+ const result = compareObservations(before, after, options.config ?? {});
20
+ if (!result.ok) {
21
+ return {
22
+ ok: false,
23
+ diagnostics: [{ code: 'invalid-request', severity: DIAGNOSTIC_SEVERITY['invalid-request'], message: result.reason }],
24
+ };
25
+ }
26
+ const rawOutputLocation = options.outputLocation ?? DEFAULT_COMPARISON_OUTPUT_LOCATION;
27
+ const normalized = normalizeOutputLocation(rawOutputLocation);
28
+ if (!normalized.ok) {
29
+ return { ok: false, diagnostics: [normalized.diagnostic] };
30
+ }
31
+ const persisted = await writeComparisonArtifact(result.artifact, normalized.value, options.cwd === undefined ? {} : { cwd: options.cwd });
32
+ if (!persisted.ok) {
33
+ return { ok: false, diagnostics: persisted.diagnostics };
34
+ }
35
+ return {
36
+ ok: true,
37
+ comparisonId: result.artifact.comparisonId,
38
+ comparisonRequestId: result.artifact.comparisonRequestId,
39
+ comparability: result.artifact.comparability.state,
40
+ artifactRoot: persisted.artifactRoot,
41
+ manifestPath: persisted.manifestPath,
42
+ differenceCount: result.artifact.differences.length,
43
+ relationshipChangeCount: result.artifact.relationshipChanges.length,
44
+ diagnosticsCount: result.artifact.diagnostics.length,
45
+ };
46
+ }
47
+ /**
48
+ * The canonical Batch 4 CLI-facing orchestration: reads two already-persisted
49
+ * observation artifacts by their root directory (each expected to contain
50
+ * `manifest.json`, mirroring `writeObservationArtifact`'s own layout) through
51
+ * the existing `readObservationArtifact` reader, then delegates to
52
+ * `compareAndPersist` exactly once. A thin wrapper only - artifact reading
53
+ * stays owned by `artifacts/artifactReader.ts`, comparison stays owned by
54
+ * `domain/comparisonEngine.ts`, and persistence stays owned by
55
+ * `artifacts/comparisonArtifactWriter.ts`. Kept in `application/` (not
56
+ * `artifacts/`) so `src/cli.ts` can depend on it without importing the
57
+ * artifacts layer directly - see `tests/unit/cli.test.ts`'s import-boundary
58
+ * assertion. Never launches a browser, never re-resolves targets.
59
+ */
60
+ export async function compareAndPersistFromArtifactRoots(beforeRoot, afterRoot, options = {}) {
61
+ const beforeRead = await readObservationArtifact(path.join(beforeRoot, OBSERVATION_MANIFEST_FILENAME));
62
+ if (!beforeRead.ok) {
63
+ return {
64
+ ok: false,
65
+ diagnostics: [{ code: 'invalid-request', severity: DIAGNOSTIC_SEVERITY['invalid-request'], message: `--before observation artifact: ${beforeRead.reason}` }],
66
+ };
67
+ }
68
+ const afterRead = await readObservationArtifact(path.join(afterRoot, OBSERVATION_MANIFEST_FILENAME));
69
+ if (!afterRead.ok) {
70
+ return {
71
+ ok: false,
72
+ diagnostics: [{ code: 'invalid-request', severity: DIAGNOSTIC_SEVERITY['invalid-request'], message: `--after observation artifact: ${afterRead.reason}` }],
73
+ };
74
+ }
75
+ return compareAndPersist(beforeRead.artifact, afterRead.artifact, options);
76
+ }
77
+ //# sourceMappingURL=comparisonService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comparisonService.js","sourceRoot":"","sources":["../../src/application/comparisonService.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAEnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,iBAAiB,IAAI,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAIpG,4LAA4L;AAC5L,MAAM,CAAC,MAAM,kCAAkC,GAAG,aAAa,CAAC;AAgChE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA2B,EAC3B,KAA0B,EAC1B,UAAoC,EAAE;IAEtC,MAAM,MAAM,GAAG,mBAAmB,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;IACxE,IAAI,CAAC,MAAM,CAAC,EAAE,E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,CAAC,mBAAmB,CAAC,MAAM;QACnE,gBAAgB,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM;KACrD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,UAAkB,EAClB,SAAiB,EACjB,UAAoC,EAAE;IAEtC,MAAM,UAAU,GAAG,MAAM,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,6BAA6B,CAAC,CAAC,CAAC;IACvG,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC;QACnB,OAAO;YACL,EAAE,EAAE,KAAK;YACT,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,kCAAkC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;SAC7J,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,CAAC;IACrG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;QAClB,OAAO;YACL,EAAE,EAAE,KAAK;YACT,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,iCAAiC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;SAC3J,CAAC;IACJ,CAAC;IAED,OAAO,iBAAiB,CAAC,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,75 @@
1
+ import type { Diagnostic } from '../domain/diagnostics.js';
2
+ import type { ReferenceRegion } from '../domain/externalReferenceRegions.js';
3
+ import type { RawReferenceRequirement, ReferenceRequirementAdequacy } from '../domain/externalReferenceRequirements.js';
4
+ import type { ExternalReferenceApplicability } from '../domain/externalReferenceApplicability.js';
5
+ import type { WriteExternalReferenceArtifactOptions } from '../artifacts/externalReferenceArtifactWriter.js';
6
+ export interface ImportExternalReferenceOptions {
7
+ outputLocation: string;
8
+ cwd?: WriteExternalReferenceArtifactOptions['cwd'];
9
+ label?: string;
10
+ /** Root directory of a prior external-reference artifact this import explicitly supersedes. */
11
+ supersedesReferenceRoot?: string;
12
+ /** v0.7 Prompt 2: explicit, user/configuration-authored reference-image regions. Identity-bearing when present - see externalReferenceIdentity.ts. */
13
+ regions?: ReferenceRegion[];
14
+ /** v0.7 Prompt 3: explicit, user/configuration-selected design requirements over `regions` above. Raw (not yet identified) authored input - see domain/externalReferenceRequirements.ts#RawReferenceRequirement. Identity-bearing when present. */
15
+ requirements?: RawReferenceRequirement[];
16
+ /** v0.7 Prompt 4: the runtime frontend state (applicable viewport/theme/application-state/authenticated-state) this reference is intended to represent. Identity-bearing when present. */
17
+ applicability?: ExternalReferenceApplicability;
18
+ }
19
+ export interface ApproveExternalReferenceOptions {
20
+ outputLocation: string;
21
+ cwd?: WriteExternalReferenceArtifactOptions['cwd'];
22
+ /** Root directory of a prior external-reference artifact this approval explicitly supersedes. */
23
+ supersedesReferenceRoot?: string;
24
+ }
25
+ export type ApplicationImportExternalReferenceResult = {
26
+ ok: true;
27
+ referenceId: string;
28
+ referenceRequestId: string;
29
+ artifactRoot: string;
30
+ manifestPath: string;
31
+ imagePath: string;
32
+ regionCount: number;
33
+ requirementCount: number;
34
+ adequacy: ReferenceRequirementAdequacy;
35
+ hasApplicability: boolean;
36
+ } | {
37
+ ok: false;
38
+ diagnostics: Diagnostic[];
39
+ };
40
+ export type ApplicationApproveExternalReferenceResult = {
41
+ ok: true;
42
+ referenceId: string;
43
+ referenceRequestId: string;
44
+ artifactRoot: string;
45
+ manifestPath: string;
46
+ regionCount: number;
47
+ requirementCount: number;
48
+ adequacy: ReferenceRequirementAdequacy;
49
+ hasApplicability: boolean;
50
+ } | {
51
+ ok: false;
52
+ diagnostics: Diagnostic[];
53
+ };
54
+ /**
55
+ * The one canonical application-level "import" use case: validates the raw
56
+ * image bytes through the existing pure image-format/dimension boundary
57
+ * (`domain/externalReferenceImage.ts`), resolves an optional explicit
58
+ * supersession target through the existing reader, computes identity through
59
+ * the existing identity module, and persists exactly once through the
60
+ * existing writer. Never approves the result - the persisted artifact's
61
+ * `lifecycle.state` is always `'imported'`, regardless of a supplied label or
62
+ * supersession target (see behavior-model.txt INV-007).
63
+ */
64
+ export declare function importExternalReference(imageBytes: Uint8Array, options: ImportExternalReferenceOptions): Promise<ApplicationImportExternalReferenceResult>;
65
+ /**
66
+ * The one canonical application-level "approval" use case, mirroring
67
+ * `application/frontendContractPersistenceService.ts#approveAndPersistBaseline`'s
68
+ * shape: reads the target through the existing reader, refuses to approve
69
+ * anything not currently in the `'imported'` lifecycle state, resolves an
70
+ * optional explicit supersession target through the same reader, and
71
+ * persists a brand-new artifact instance - never mutating the imported
72
+ * artifact's own manifest - carrying a `sourceReference` back to it instead
73
+ * of a second copy of the image bytes.
74
+ */
75
+ export declare function approveExternalReference(importedArtifactRoot: string, options: ApproveExternalReferenceOptions): Promise<ApplicationApproveExternalReferenceResult>;
@@ -0,0 +1,182 @@
1
+ import { createHash } from 'node:crypto';
2
+ import path from 'node:path';
3
+ import { DIAGNOSTIC_SEVERITY } from '../domain/diagnostics.js';
4
+ import { deriveCompletion } from '../domain/completion.js';
5
+ import { getProducerInfo } from '../domain/schema.js';
6
+ import { detectExternalReferenceImageFormat, readExternalReferenceImageDimensions, isValidExternalReferenceImageDimensions, fileExtensionForFormat, EXTERNAL_REFERENCE_MAX_IMAGE_BYTES, } from '../domain/externalReferenceImage.js';
7
+ import { EXTERNAL_REFERENCE_ARTIFACT_KIND, EXTERNAL_REFERENCE_SCHEMA_VERSION, isImportedExternalReferenceArtifact } from '../domain/externalReference.js';
8
+ import { buildExternalReferenceRequestIdentity, buildExternalReferenceInstanceIdentity } from '../domain/externalReferenceIdentity.js';
9
+ import { isValidReferenceRegions } from '../domain/externalReferenceRegions.js';
10
+ import { isValidRawReferenceRequirement, buildReferenceRequirement, isValidReferenceRequirements, deriveReferenceRequirementAdequacy } from '../domain/externalReferenceRequirements.js';
11
+ import { isValidExternalReferenceApplicability } from '../domain/externalReferenceApplicability.js';
12
+ import { normalizeOutputLocation } from '../request/paths.js';
13
+ import { writeExternalReferenceArtifact } from '../artifacts/externalReferenceArtifactWriter.js';
14
+ import { EXTERNAL_REFERENCE_MANIFEST_FILENAME } from '../artifacts/externalReferenceArtifactWriter.js';
15
+ import { readExternalReferenceArtifact } from '../artifacts/externalReferenceArtifactReader.js';
16
+ function failure(code, message) {
17
+ return { ok: false, diagnostics: [{ code, severity: DIAGNOSTIC_SEVERITY[code], message }] };
18
+ }
19
+ async function resolveSupersedesReferenceId(supersedesReferenceRoot) {
20
+ if (supersedesReferenceRoot === undefined)
21
+ return { ok: true };
22
+ const read = await readExternalReferenceArtifact(path.join(supersedesReferenceRoot, EXTERNAL_REFERENCE_MANIFEST_FILENAME));
23
+ if (!read.ok)
24
+ return failure('reference-not-found', `supersedesReferenceRoot: ${read.reason}`);
25
+ return { ok: true, referenceId: read.artifact.referenceId };
26
+ }
27
+ /**
28
+ * The one canonical application-level "import" use case: validates the raw
29
+ * image bytes through the existing pure image-format/dimension boundary
30
+ * (`domain/externalReferenceImage.ts`), resolves an optional explicit
31
+ * supersession target through the existing reader, computes identity through
32
+ * the existing identity module, and persists exactly once through the
33
+ * existing writer. Never approves the result - the persisted artifact's
34
+ * `lifecycle.state` is always `'imported'`, regardless of a supplied label or
35
+ * supersession target (see behavior-model.txt INV-007).
36
+ */
37
+ export async function importExternalReference(imageBytes, options) {
38
+ const format = detectExternalReferenceImageFormat(imageBytes);
39
+ if (format === undefined)
40
+ return failure('unsupported-image-format', 'the supplied bytes do not match any supported reference image format (png, jpeg, webp)');
41
+ if (imageBytes.length > EXTERNAL_REFERENCE_MAX_IMAGE_BYTES) {
42
+ return failure('image-too-large', `reference image is ${imageBytes.length} bytes, exceeding the maximum of ${EXTERNAL_REFERENCE_MAX_IMAGE_BYTES} bytes`);
43
+ }
44
+ const dimensions = readExternalReferenceImageDimensions(imageBytes, format);
45
+ if (dimensions === undefined || !isValidExternalReferenceImageDimensions(dimensions)) {
46
+ return failure('invalid-image-dimensions', 'the supplied reference image header does not contain valid, bounded dimensions');
47
+ }
48
+ if (options.regions !== undefined) {
49
+ const regionsValidation = isValidReferenceRegions(options.regions, dimensions.width, dimensions.height);
50
+ if (!regionsValidation.valid)
51
+ return failure('invalid-reference-region', regionsValidation.reason);
52
+ }
53
+ let requirements;
54
+ if (options.requirements !== undefined) {
55
+ const built = [];
56
+ for (const raw of options.requirements) {
57
+ const rawValidation = isValidRawReferenceRequirement(raw);
58
+ if (!rawValidation.valid)
59
+ return failure('invalid-reference-requirement', rawValidation.reason);
60
+ built.push(buildReferenceRequirement(raw));
61
+ }
62
+ const collectionValidation = isValidReferenceRequirements(built, options.regions ?? []);
63
+ if (!collectionValidation.valid)
64
+ return failure('invalid-reference-requirement', collectionValidation.reason);
65
+ requirements = built;
66
+ }
67
+ if (options.applicability !== undefined) {
68
+ const applicabilityValidation = isValidExternalReferenceApplicability(options.applicability);
69
+ if (!applicabilityValidation.valid)
70
+ return failure('invalid-reference-applicability', applicabilityValidation.reason);
71
+ }
72
+ const supersedes = await resolveSupersedesReferenceId(options.supersedesReferenceRoot);
73
+ if (!supersedes.ok)
74
+ return supersedes;
75
+ const normalizedOutput = normalizeOutputLocation(options.outputLocation);
76
+ if (!normalizedOutput.ok)
77
+ return { ok: false, diagnostics: [normalizedOutput.diagnostic] };
78
+ const imageSha256 = createHash('sha256').update(imageBytes).digest('hex');
79
+ const referenceRequestId = buildExternalReferenceRequestIdentity(imageSha256, format, dimensions.width, dimensions.height, supersedes.referenceId, options.regions, requirements, options.applicability);
80
+ const referenceId = buildExternalReferenceInstanceIdentity(referenceRequestId);
81
+ const artifact = {
82
+ artifactKind: EXTERNAL_REFERENCE_ARTIFACT_KIND,
83
+ schemaVersion: EXTERNAL_REFERENCE_SCHEMA_VERSION,
84
+ referenceRequestId,
85
+ referenceId,
86
+ producer: getProducerInfo(),
87
+ provenance: { importedAt: new Date().toISOString(), ...(options.label === undefined ? {} : { label: options.label }) },
88
+ image: {
89
+ path: `reference.${fileExtensionForFormat(format)}`,
90
+ format,
91
+ width: dimensions.width,
92
+ height: dimensions.height,
93
+ byteLength: imageBytes.length,
94
+ sha256: imageSha256,
95
+ },
96
+ lifecycle: { state: 'imported' },
97
+ ...(supersedes.referenceId === undefined ? {} : { supersedesReferenceId: supersedes.referenceId }),
98
+ ...(options.regions === undefined ? {} : { regions: options.regions }),
99
+ ...(requirements === undefined ? {} : { requirements }),
100
+ ...(options.applicability === undefined ? {} : { applicability: options.applicability }),
101
+ diagnostics: [],
102
+ completion: deriveCompletion([], 'post-capture'),
103
+ };
104
+ const persisted = await writeExternalReferenceArtifact(artifact, imageBytes, normalizedOutput.value, options.cwd === undefined ? {} : { cwd: options.cwd });
105
+ if (!persisted.ok)
106
+ return { ok: false, diagnostics: persisted.diagnostics };
107
+ return {
108
+ ok: true,
109
+ referenceId: artifact.referenceId,
110
+ referenceRequestId: artifact.referenceRequestId,
111
+ artifactRoot: persisted.artifactRoot,
112
+ manifestPath: persisted.manifestPath,
113
+ imagePath: persisted.imagePath,
114
+ regionCount: artifact.regions?.length ?? 0,
115
+ requirementCount: artifact.requirements?.length ?? 0,
116
+ adequacy: deriveReferenceRequirementAdequacy(artifact.regions ?? [], artifact.requirements ?? []),
117
+ hasApplicability: artifact.applicability !== undefined,
118
+ };
119
+ }
120
+ /**
121
+ * The one canonical application-level "approval" use case, mirroring
122
+ * `application/frontendContractPersistenceService.ts#approveAndPersistBaseline`'s
123
+ * shape: reads the target through the existing reader, refuses to approve
124
+ * anything not currently in the `'imported'` lifecycle state, resolves an
125
+ * optional explicit supersession target through the same reader, and
126
+ * persists a brand-new artifact instance - never mutating the imported
127
+ * artifact's own manifest - carrying a `sourceReference` back to it instead
128
+ * of a second copy of the image bytes.
129
+ */
130
+ export async function approveExternalReference(importedArtifactRoot, options) {
131
+ const read = await readExternalReferenceArtifact(path.join(importedArtifactRoot, EXTERNAL_REFERENCE_MANIFEST_FILENAME));
132
+ if (!read.ok)
133
+ return failure('reference-not-found', read.reason);
134
+ if (!isImportedExternalReferenceArtifact(read.artifact)) {
135
+ return failure('invalid-request', `external-reference artifact "${read.artifact.referenceId}" is not in the "imported" lifecycle state; only a freshly imported reference can be approved`);
136
+ }
137
+ const imported = read.artifact;
138
+ const supersedes = await resolveSupersedesReferenceId(options.supersedesReferenceRoot);
139
+ if (!supersedes.ok)
140
+ return supersedes;
141
+ const normalizedOutput = normalizeOutputLocation(options.outputLocation);
142
+ if (!normalizedOutput.ok)
143
+ return { ok: false, diagnostics: [normalizedOutput.diagnostic] };
144
+ const referenceId = buildExternalReferenceInstanceIdentity(imported.referenceRequestId);
145
+ const artifact = {
146
+ artifactKind: EXTERNAL_REFERENCE_ARTIFACT_KIND,
147
+ schemaVersion: EXTERNAL_REFERENCE_SCHEMA_VERSION,
148
+ referenceRequestId: imported.referenceRequestId,
149
+ referenceId,
150
+ producer: getProducerInfo(),
151
+ provenance: { importedAt: imported.provenance.importedAt, ...(imported.provenance.label === undefined ? {} : { label: imported.provenance.label }) },
152
+ sourceReference: {
153
+ referenceId: imported.referenceId,
154
+ referenceRequestId: imported.referenceRequestId,
155
+ producer: imported.producer,
156
+ schemaVersion: imported.schemaVersion,
157
+ image: imported.image,
158
+ },
159
+ lifecycle: { state: 'approved', approvedAt: new Date().toISOString() },
160
+ ...(supersedes.referenceId === undefined ? {} : { supersedesReferenceId: supersedes.referenceId }),
161
+ ...(imported.regions === undefined ? {} : { regions: imported.regions }),
162
+ ...(imported.requirements === undefined ? {} : { requirements: imported.requirements }),
163
+ ...(imported.applicability === undefined ? {} : { applicability: imported.applicability }),
164
+ diagnostics: [],
165
+ completion: deriveCompletion([], 'post-capture'),
166
+ };
167
+ const persisted = await writeExternalReferenceArtifact(artifact, undefined, normalizedOutput.value, options.cwd === undefined ? {} : { cwd: options.cwd });
168
+ if (!persisted.ok)
169
+ return { ok: false, diagnostics: persisted.diagnostics };
170
+ return {
171
+ ok: true,
172
+ referenceId: artifact.referenceId,
173
+ referenceRequestId: artifact.referenceRequestId,
174
+ artifactRoot: persisted.artifactRoot,
175
+ manifestPath: persisted.manifestPath,
176
+ regionCount: artifact.regions?.length ?? 0,
177
+ requirementCount: artifact.requirements?.length ?? 0,
178
+ adequacy: deriveReferenceRequirementAdequacy(artifact.regions ?? [], artifact.requirements ?? []),
179
+ hasApplicability: artifact.applicability !== undefined,
180
+ };
181
+ }
182
+ //# sourceMappingURL=externalReferencePersistenceService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"externalReferencePersistenceService.js","sourceRoot":"","sources":["../../src/application/externalReferencePersistenceService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EACL,kCAAkC,EAClC,oCAAoC,EACpC,uCAAuC,EACvC,sBAAsB,EACtB,kCAAkC,GACnC,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,gCAAgC,EAAE,iCAAiC,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAC1J,OAAO,EAAE,qCAAqC,EAAE,sCAAsC,EAAE,MAAM,wCAAwC,CAAC;AAEvI,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,kCAAkC,EAAE,MAAM,4CAA4C,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AQ,EAAE,kCAAkC,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,EAAE,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC;QACjG,gBAAgB,EAAE,QAAQ,CAAC,aAAa,KAAK,SAAS;KACvD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { FrontendContractEvaluationInput } from '../domain/frontendContractEvaluation.js';
2
+ import type { OverallVerdict } from '../domain/frontendContracts.js';
3
+ import type { Diagnostic } from '../domain/diagnostics.js';
4
+ import type { WriteFrontendContractEvaluationArtifactOptions } from '../artifacts/frontendContractEvaluationArtifactWriter.js';
5
+ export type { PersistedFrontendContractEvaluationResult } from '../artifacts/frontendContractEvaluationArtifactWriter.js';
6
+ /** Distinct from `DEFAULT_COMPARISON_OUTPUT_LOCATION`/observation `outputLocation` so evaluations never collide with source evidence. */
7
+ export declare const DEFAULT_EVALUATION_OUTPUT_LOCATION = "evaluations";
8
+ export interface EvaluateAndPersistOptions {
9
+ outputLocation?: string;
10
+ cwd?: WriteFrontendContractEvaluationArtifactOptions['cwd'];
11
+ }
12
+ export type ApplicationFrontendContractEvaluationResult = {
13
+ ok: true;
14
+ evaluationId: string;
15
+ evaluationRequestId: string;
16
+ overallVerdict: OverallVerdict;
17
+ artifactRoot: string;
18
+ manifestPath: string;
19
+ clauseResultCount: number;
20
+ unexpectedChangeCount: number;
21
+ } | {
22
+ ok: false;
23
+ diagnostics: Diagnostic[];
24
+ };
25
+ /**
26
+ * The one canonical application-level frontend-contract evaluation use case:
27
+ * takes already-validated/in-memory evidence, runs the existing pure
28
+ * `evaluateFrontendContract` exactly once, and - only for a structurally
29
+ * constructible result (`ok: true`, whether the verdict itself is `PASS` or
30
+ * `FAIL`) - persists it exactly once through the existing evaluation writer.
31
+ * Never re-evaluates, never launches Chromium, never mutates any input
32
+ * artifact. A `{ ok: false }` evaluator result (evidence could not even be
33
+ * constructed into an evaluation) is never persisted as a fabricated
34
+ * successful artifact - that is an application-level `invalid-request`
35
+ * diagnostic, distinct from a legitimate `FAIL` verdict.
36
+ */
37
+ export declare function evaluateAndPersist(input: FrontendContractEvaluationInput, options?: EvaluateAndPersistOptions): Promise<ApplicationFrontendContractEvaluationResult>;
38
+ /**
39
+ * The canonical future-CLI-facing orchestration: reads before/after
40
+ * observations (through the existing `readObservationArtifact` reader -
41
+ * never a second observation reader), the comparison (through the new
42
+ * `readComparisonArtifact`), and the baseline/per-change contracts (through
43
+ * `frontendContractArtifactReader.ts`) by their root directories, then
44
+ * delegates to `evaluateAndPersist` exactly once. A thin wrapper only -
45
+ * reading stays owned by the artifacts layer, evaluation stays owned by
46
+ * `domain/frontendContractEvaluation.ts`, persistence stays owned by
47
+ * `artifacts/frontendContractEvaluationArtifactWriter.ts`.
48
+ */
49
+ export declare function evaluateAndPersistFromArtifactRoots(beforeRoot: string, afterRoot: string, comparisonRoot: string, baselineRoot: string, changeRoot: string, options?: EvaluateAndPersistOptions): Promise<ApplicationFrontendContractEvaluationResult>;
@@ -0,0 +1,112 @@
1
+ import path from 'node:path';
2
+ import { getProducerInfo } from '../domain/schema.js';
3
+ import { evaluateFrontendContract } from '../domain/frontendContractEvaluation.js';
4
+ import { buildFrontendContractEvaluationArtifact } from '../domain/frontendContractEvaluationArtifact.js';
5
+ import { buildFrontendContractEvaluationRequestIdentity, buildFrontendContractInstanceIdentity } from '../domain/frontendContractIdentity.js';
6
+ import { DIAGNOSTIC_SEVERITY } from '../domain/diagnostics.js';
7
+ import { normalizeOutputLocation } from '../request/paths.js';
8
+ import { writeFrontendContractEvaluationArtifact } from '../artifacts/frontendContractEvaluationArtifactWriter.js';
9
+ import { readObservationArtifact } from '../artifacts/artifactReader.js';
10
+ import { MANIFEST_FILENAME as OBSERVATION_MANIFEST_FILENAME } from '../artifacts/artifactWriter.js';
11
+ import { readComparisonArtifact } from '../artifacts/comparisonArtifactReader.js';
12
+ import { COMPARISON_MANIFEST_FILENAME } from '../artifacts/comparisonArtifactWriter.js';
13
+ import { readPersistentBaselineContract, readPerChangeContract } from '../artifacts/frontendContractArtifactReader.js';
14
+ import { FRONTEND_CONTRACT_MANIFEST_FILENAME } from '../artifacts/frontendContractArtifactWriter.js';
15
+ /** Distinct from `DEFAULT_COMPARISON_OUTPUT_LOCATION`/observation `outputLocation` so evaluations never collide with source evidence. */
16
+ export const DEFAULT_EVALUATION_OUTPUT_LOCATION = 'evaluations';
17
+ function invalidRequest(message) {
18
+ return { ok: false, diagnostics: [{ code: 'invalid-request', severity: DIAGNOSTIC_SEVERITY['invalid-request'], message }] };
19
+ }
20
+ /**
21
+ * The one canonical application-level frontend-contract evaluation use case:
22
+ * takes already-validated/in-memory evidence, runs the existing pure
23
+ * `evaluateFrontendContract` exactly once, and - only for a structurally
24
+ * constructible result (`ok: true`, whether the verdict itself is `PASS` or
25
+ * `FAIL`) - persists it exactly once through the existing evaluation writer.
26
+ * Never re-evaluates, never launches Chromium, never mutates any input
27
+ * artifact. A `{ ok: false }` evaluator result (evidence could not even be
28
+ * constructed into an evaluation) is never persisted as a fabricated
29
+ * successful artifact - that is an application-level `invalid-request`
30
+ * diagnostic, distinct from a legitimate `FAIL` verdict.
31
+ */
32
+ export async function evaluateAndPersist(input, options = {}) {
33
+ const result = evaluateFrontendContract(input);
34
+ if (!result.ok)
35
+ return invalidRequest(result.reason);
36
+ const rawOutputLocation = options.outputLocation ?? DEFAULT_EVALUATION_OUTPUT_LOCATION;
37
+ const normalized = normalizeOutputLocation(rawOutputLocation);
38
+ if (!normalized.ok)
39
+ return { ok: false, diagnostics: [normalized.diagnostic] };
40
+ const evaluationRequestId = buildFrontendContractEvaluationRequestIdentity(input.baseline.baselineId, input.change.contractId, input.comparison.before.observationId, input.comparison.after.observationId, input.comparison.comparisonRequestId);
41
+ const evaluationId = buildFrontendContractInstanceIdentity(evaluationRequestId);
42
+ const artifact = buildFrontendContractEvaluationArtifact({
43
+ evaluationId,
44
+ evaluationRequestId,
45
+ producerVersion: getProducerInfo().version,
46
+ evaluatedAt: new Date().toISOString(),
47
+ baselineId: input.baseline.baselineId,
48
+ contractId: input.change.contractId,
49
+ before: {
50
+ observationId: input.comparison.before.observationId,
51
+ requestId: input.comparison.before.requestId,
52
+ producer: input.comparison.before.producer,
53
+ observationSchemaVersion: input.comparison.before.observationSchemaVersion,
54
+ },
55
+ after: {
56
+ observationId: input.comparison.after.observationId,
57
+ requestId: input.comparison.after.requestId,
58
+ producer: input.comparison.after.producer,
59
+ observationSchemaVersion: input.comparison.after.observationSchemaVersion,
60
+ },
61
+ comparisonId: input.comparison.comparisonId,
62
+ comparisonRequestId: input.comparison.comparisonRequestId,
63
+ overallVerdict: result.evaluation.overallVerdict,
64
+ activeBaselineClauseIds: result.evaluation.activeBaselineClauseIds,
65
+ supersededBaselineClauseIds: result.evaluation.supersededBaselineClauseIds,
66
+ clauseResults: result.evaluation.clauseResults,
67
+ unexpectedChanges: result.evaluation.unexpectedChanges,
68
+ });
69
+ const persisted = await writeFrontendContractEvaluationArtifact(artifact, normalized.value, options.cwd === undefined ? {} : { cwd: options.cwd });
70
+ if (!persisted.ok)
71
+ return { ok: false, diagnostics: persisted.diagnostics };
72
+ return {
73
+ ok: true,
74
+ evaluationId: artifact.evaluationId,
75
+ evaluationRequestId: artifact.evaluationRequestId,
76
+ overallVerdict: artifact.overallVerdict,
77
+ artifactRoot: persisted.artifactRoot,
78
+ manifestPath: persisted.manifestPath,
79
+ clauseResultCount: artifact.clauseResults.length,
80
+ unexpectedChangeCount: artifact.unexpectedChanges.length,
81
+ };
82
+ }
83
+ /**
84
+ * The canonical future-CLI-facing orchestration: reads before/after
85
+ * observations (through the existing `readObservationArtifact` reader -
86
+ * never a second observation reader), the comparison (through the new
87
+ * `readComparisonArtifact`), and the baseline/per-change contracts (through
88
+ * `frontendContractArtifactReader.ts`) by their root directories, then
89
+ * delegates to `evaluateAndPersist` exactly once. A thin wrapper only -
90
+ * reading stays owned by the artifacts layer, evaluation stays owned by
91
+ * `domain/frontendContractEvaluation.ts`, persistence stays owned by
92
+ * `artifacts/frontendContractEvaluationArtifactWriter.ts`.
93
+ */
94
+ export async function evaluateAndPersistFromArtifactRoots(beforeRoot, afterRoot, comparisonRoot, baselineRoot, changeRoot, options = {}) {
95
+ const beforeRead = await readObservationArtifact(path.join(beforeRoot, OBSERVATION_MANIFEST_FILENAME));
96
+ if (!beforeRead.ok)
97
+ return invalidRequest(`before observation artifact: ${beforeRead.reason}`);
98
+ const afterRead = await readObservationArtifact(path.join(afterRoot, OBSERVATION_MANIFEST_FILENAME));
99
+ if (!afterRead.ok)
100
+ return invalidRequest(`after observation artifact: ${afterRead.reason}`);
101
+ const comparisonRead = await readComparisonArtifact(path.join(comparisonRoot, COMPARISON_MANIFEST_FILENAME));
102
+ if (!comparisonRead.ok)
103
+ return invalidRequest(`comparison artifact: ${comparisonRead.reason}`);
104
+ const baselineRead = await readPersistentBaselineContract(path.join(baselineRoot, FRONTEND_CONTRACT_MANIFEST_FILENAME));
105
+ if (!baselineRead.ok)
106
+ return invalidRequest(`baseline contract artifact: ${baselineRead.reason}`);
107
+ const changeRead = await readPerChangeContract(path.join(changeRoot, FRONTEND_CONTRACT_MANIFEST_FILENAME));
108
+ if (!changeRead.ok)
109
+ return invalidRequest(`per-change contract artifact: ${changeRead.reason}`);
110
+ return evaluateAndPersist({ before: beforeRead.artifact, after: afterRead.artifact, comparison: comparisonRead.artifact, baseline: baselineRead.contract, change: changeRead.contract }, options);
111
+ }
112
+ //# sourceMappingURL=frontendContractEvaluationService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontendContractEvaluationService.js","sourceRoot":"","sources":["../../src/application/frontendContractEvaluationService.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAEnF,OAAO,EAAE,uCAAuC,EAAE,MAAM,iDAAiD,CAAC;AAE1G,OAAO,EAA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