@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,158 @@
1
+ /**
2
+ * v0.7 Prompt 1 external-reference artifact family, extended in Prompt 2
3
+ * with explicit, additive, optional reference regions (identity, provenance,
4
+ * bounded image metadata, two-state lifecycle, forward-only supersession -
5
+ * see the Prompt 1 report for that foundation; region geometry/relationship
6
+ * derivation lives in externalReferenceRegions.ts /
7
+ * externalReferenceRegionRelationships.ts). This module still implements
8
+ * neither design requirements, tolerances, reference-region/runtime binding,
9
+ * nor reference-vs-candidate evaluation - see docs/ARCHITECTURE.md.
10
+ *
11
+ * An external reference is desired-design evidence, not an earlier browser
12
+ * observation: this module never reuses ARTIFACT_KIND/SCHEMA_VERSION
13
+ * (observation), COMPARISON_ARTIFACT_KIND, or CONTRACT_ARTIFACT_KIND, and
14
+ * adds no field to any of those existing types.
15
+ */
16
+ import type { Diagnostic } from './diagnostics.js';
17
+ import type { CompletionState } from './completion.js';
18
+ import { PRODUCER_NAME } from './schema.js';
19
+ import type { ExternalReferenceImageFormat } from './externalReferenceImage.js';
20
+ import type { ReferenceRegion } from './externalReferenceRegions.js';
21
+ import type { ExternalReferenceRequirement } from './externalReferenceRequirements.js';
22
+ import type { ExternalReferenceApplicability } from './externalReferenceApplicability.js';
23
+ export declare const EXTERNAL_REFERENCE_ARTIFACT_KIND: "my-frontend-observer/external-reference";
24
+ export declare const EXTERNAL_REFERENCE_SCHEMA_VERSION: "1.0.0";
25
+ export interface ExternalReferenceImageReference {
26
+ /** Bare relative filename within the artifact's own directory - never an absolute path. */
27
+ path: string;
28
+ format: ExternalReferenceImageFormat;
29
+ width: number;
30
+ height: number;
31
+ byteLength: number;
32
+ /** sha256 hex digest of the raw image bytes - identity-bearing (see externalReferenceIdentity.ts). */
33
+ sha256: string;
34
+ }
35
+ export declare function isValidExternalReferenceImageReference(value: unknown): value is ExternalReferenceImageReference;
36
+ /**
37
+ * Enough logical identity to trace an approved reference back to the
38
+ * imported artifact that owns its image, without ever re-copying the image
39
+ * bytes - mirrors ComparisonSourceObservationReference's
40
+ * {id, requestId, producer, schemaVersion, screenshot: {path}} shape exactly.
41
+ */
42
+ export interface ExternalReferenceSourceReference {
43
+ referenceId: string;
44
+ referenceRequestId: string;
45
+ producer: {
46
+ name: typeof PRODUCER_NAME;
47
+ version: string;
48
+ };
49
+ schemaVersion: typeof EXTERNAL_REFERENCE_SCHEMA_VERSION;
50
+ image: ExternalReferenceImageReference;
51
+ }
52
+ export declare function isValidExternalReferenceSourceReference(value: unknown): value is ExternalReferenceSourceReference;
53
+ /**
54
+ * Exactly two persisted states. There is no literal 'superseded' variant:
55
+ * supersession is represented only as a forward-declared relationship (a
56
+ * newer artifact's `supersedesReferenceId` pointing at an older artifact's
57
+ * `referenceId`) so that an existing persisted artifact's own lifecycle field
58
+ * is never rewritten - "old evidence remains immutable, no hidden rewrite"
59
+ * holds unconditionally rather than depending on careful mutation discipline.
60
+ */
61
+ export type ExternalReferenceLifecycleState = {
62
+ state: 'imported';
63
+ } | {
64
+ state: 'approved';
65
+ approvedAt: string;
66
+ };
67
+ export declare function isValidExternalReferenceLifecycleState(value: unknown): value is ExternalReferenceLifecycleState;
68
+ export interface ExternalReferenceProvenance {
69
+ importedAt: string;
70
+ /** Optional caller-supplied human label - pure provenance, never identity-bearing (see externalReferenceIdentity.ts). */
71
+ label?: string;
72
+ }
73
+ export declare function isValidExternalReferenceProvenance(value: unknown): value is ExternalReferenceProvenance;
74
+ interface ExternalReferenceArtifactBase {
75
+ artifactKind: typeof EXTERNAL_REFERENCE_ARTIFACT_KIND;
76
+ schemaVersion: typeof EXTERNAL_REFERENCE_SCHEMA_VERSION;
77
+ /** Deterministic logical identity - see buildExternalReferenceRequestIdentity. Shared by an imported artifact and every artifact produced by approving it. */
78
+ referenceRequestId: string;
79
+ /** Fresh per-persisted-instance identity - see buildExternalReferenceInstanceIdentity. */
80
+ referenceId: string;
81
+ producer: {
82
+ name: typeof PRODUCER_NAME;
83
+ version: string;
84
+ };
85
+ provenance: ExternalReferenceProvenance;
86
+ /** Explicit, forward-only supersession of a prior reference's referenceId - never inferred from image/content similarity. */
87
+ supersedesReferenceId?: string;
88
+ /**
89
+ * v0.7 Prompt 2 addition (additive, optional - a Prompt 1 artifact predates
90
+ * this field entirely and remains valid without it, so no schema version
91
+ * bump was needed). Explicit, user/configuration-authored reference-image
92
+ * rectangles - identity-bearing wherever present (see
93
+ * externalReferenceIdentity.ts). Never mutated in place: changing region
94
+ * content produces a new referenceRequestId/referenceId, never a rewrite of
95
+ * this array on an existing persisted artifact.
96
+ */
97
+ regions?: ReferenceRegion[];
98
+ /**
99
+ * v0.7 Prompt 3 addition (additive, optional - same backward-compatibility
100
+ * reasoning as `regions`: a Prompt 1/2 artifact predates this field
101
+ * entirely and remains valid without it). Explicit, user/configuration-
102
+ * selected design intent over the `regions` above - never inferred merely
103
+ * because a region property/relationship exists (see docs/CONTRACTS.md
104
+ * "v0.7 Prompt 3"). Identity-bearing wherever present. Never mutated in
105
+ * place: changing selected requirements/tolerances produces a new
106
+ * referenceRequestId/referenceId, never a rewrite of this array on an
107
+ * existing persisted artifact.
108
+ */
109
+ requirements?: ExternalReferenceRequirement[];
110
+ /**
111
+ * v0.7 Prompt 4 addition (additive, optional - same backward-compatibility
112
+ * reasoning as `regions`/`requirements`). The runtime frontend state this
113
+ * reference is intended to represent (applicable viewport/theme/
114
+ * application-state/authenticated-state) - never the reference image's own
115
+ * pixel dimensions (see `image.width`/`height` above and
116
+ * externalReferenceApplicability.ts's doc comment). Identity-bearing
117
+ * wherever present. Never mutated in place; importing applicability never
118
+ * implies approval, and approval carries it forward verbatim.
119
+ */
120
+ applicability?: ExternalReferenceApplicability;
121
+ diagnostics: Diagnostic[];
122
+ completion: CompletionState;
123
+ }
124
+ export interface ImportedExternalReferenceArtifact extends ExternalReferenceArtifactBase {
125
+ lifecycle: {
126
+ state: 'imported';
127
+ };
128
+ image: ExternalReferenceImageReference;
129
+ }
130
+ export interface ApprovedExternalReferenceArtifact extends ExternalReferenceArtifactBase {
131
+ lifecycle: {
132
+ state: 'approved';
133
+ approvedAt: string;
134
+ };
135
+ sourceReference: ExternalReferenceSourceReference;
136
+ }
137
+ export type ExternalReferenceArtifact = ImportedExternalReferenceArtifact | ApprovedExternalReferenceArtifact;
138
+ /** User-defined type guards: TypeScript does not narrow a union of `extends`-based interfaces purely from a nested `artifact.lifecycle.state` comparison, so callers needing the narrowed shape (the writer, the application service) use these instead of re-deriving the check. */
139
+ export declare function isImportedExternalReferenceArtifact(artifact: ExternalReferenceArtifact): artifact is ImportedExternalReferenceArtifact;
140
+ export declare function isApprovedExternalReferenceArtifact(artifact: ExternalReferenceArtifact): artifact is ApprovedExternalReferenceArtifact;
141
+ export type ExternalReferenceValidationResult = {
142
+ valid: true;
143
+ } | {
144
+ valid: false;
145
+ reason: string;
146
+ };
147
+ /**
148
+ * Structural validator for ExternalReferenceArtifact. The single gate used by
149
+ * both the writer and the reader (artifacts/externalReferenceArtifactWriter.ts
150
+ * / externalReferenceArtifactReader.ts) - never a second validator. Rejects a
151
+ * value that mixes the two lifecycle-variant-specific fields (an 'imported'
152
+ * artifact must never carry sourceReference; an 'approved' artifact must
153
+ * never carry image), fails closed on an unsupported schemaVersion, and never
154
+ * re-parses raw image bytes (that already happened before this object was
155
+ * built - see application/externalReferencePersistenceService.ts).
156
+ */
157
+ export declare function isValidExternalReferenceArtifact(value: unknown): ExternalReferenceValidationResult;
158
+ export {};
@@ -0,0 +1,167 @@
1
+ import { PRODUCER_NAME } from './schema.js';
2
+ import { isExternalReferenceImageFormat, isValidExternalReferenceImageDimensions } from './externalReferenceImage.js';
3
+ import { isValidReferenceRegions } from './externalReferenceRegions.js';
4
+ import { isValidReferenceRequirements } from './externalReferenceRequirements.js';
5
+ import { isValidExternalReferenceApplicability } from './externalReferenceApplicability.js';
6
+ function isPlainObject(value) {
7
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
8
+ }
9
+ function isNonEmptyString(value) {
10
+ return typeof value === 'string' && value.length > 0;
11
+ }
12
+ export const EXTERNAL_REFERENCE_ARTIFACT_KIND = 'my-frontend-observer/external-reference';
13
+ export const EXTERNAL_REFERENCE_SCHEMA_VERSION = '1.0.0';
14
+ export function isValidExternalReferenceImageReference(value) {
15
+ if (!isPlainObject(value))
16
+ return false;
17
+ if (!isNonEmptyString(value.path) || value.path.includes('/') || value.path.includes('\\'))
18
+ return false;
19
+ if (!isExternalReferenceImageFormat(value.format))
20
+ return false;
21
+ if (typeof value.width !== 'number' || typeof value.height !== 'number')
22
+ return false;
23
+ if (!isValidExternalReferenceImageDimensions({ width: value.width, height: value.height }))
24
+ return false;
25
+ if (typeof value.byteLength !== 'number' || !Number.isInteger(value.byteLength) || value.byteLength <= 0)
26
+ return false;
27
+ if (typeof value.sha256 !== 'string' || !/^[0-9a-f]{64}$/.test(value.sha256))
28
+ return false;
29
+ return true;
30
+ }
31
+ export function isValidExternalReferenceSourceReference(value) {
32
+ if (!isPlainObject(value))
33
+ return false;
34
+ if (!isNonEmptyString(value.referenceId) || !isNonEmptyString(value.referenceRequestId))
35
+ return false;
36
+ if (!isPlainObject(value.producer) || value.producer.name !== PRODUCER_NAME || !isNonEmptyString(value.producer.version))
37
+ return false;
38
+ if (value.schemaVersion !== EXTERNAL_REFERENCE_SCHEMA_VERSION)
39
+ return false;
40
+ return isValidExternalReferenceImageReference(value.image);
41
+ }
42
+ export function isValidExternalReferenceLifecycleState(value) {
43
+ if (!isPlainObject(value))
44
+ return false;
45
+ if (value.state === 'imported')
46
+ return Object.keys(value).length === 1;
47
+ if (value.state === 'approved')
48
+ return Object.keys(value).length === 2 && isNonEmptyString(value.approvedAt);
49
+ return false;
50
+ }
51
+ export function isValidExternalReferenceProvenance(value) {
52
+ if (!isPlainObject(value))
53
+ return false;
54
+ if (!isNonEmptyString(value.importedAt))
55
+ return false;
56
+ if ('label' in value && value.label !== undefined && !isNonEmptyString(value.label))
57
+ return false;
58
+ return true;
59
+ }
60
+ /** User-defined type guards: TypeScript does not narrow a union of `extends`-based interfaces purely from a nested `artifact.lifecycle.state` comparison, so callers needing the narrowed shape (the writer, the application service) use these instead of re-deriving the check. */
61
+ export function isImportedExternalReferenceArtifact(artifact) {
62
+ return artifact.lifecycle.state === 'imported';
63
+ }
64
+ export function isApprovedExternalReferenceArtifact(artifact) {
65
+ return artifact.lifecycle.state === 'approved';
66
+ }
67
+ function isValidDiagnosticArray(value) {
68
+ return (Array.isArray(value) &&
69
+ value.every((d) => isPlainObject(d) &&
70
+ typeof d.code === 'string' &&
71
+ (d.severity === 'error' || d.severity === 'warning') &&
72
+ typeof d.message === 'string' &&
73
+ d.message.length > 0));
74
+ }
75
+ function isValidCompletionState(value) {
76
+ if (!isPlainObject(value))
77
+ return false;
78
+ if (value.state === 'complete')
79
+ return Object.keys(value).length === 1;
80
+ if (value.state === 'partial' || value.state === 'warning' || value.state === 'invalid-request' || value.state === 'fatal') {
81
+ return Object.keys(value).length === 2 && isValidDiagnosticArray(value.diagnostics);
82
+ }
83
+ return false;
84
+ }
85
+ /**
86
+ * Structural validator for ExternalReferenceArtifact. The single gate used by
87
+ * both the writer and the reader (artifacts/externalReferenceArtifactWriter.ts
88
+ * / externalReferenceArtifactReader.ts) - never a second validator. Rejects a
89
+ * value that mixes the two lifecycle-variant-specific fields (an 'imported'
90
+ * artifact must never carry sourceReference; an 'approved' artifact must
91
+ * never carry image), fails closed on an unsupported schemaVersion, and never
92
+ * re-parses raw image bytes (that already happened before this object was
93
+ * built - see application/externalReferencePersistenceService.ts).
94
+ */
95
+ export function isValidExternalReferenceArtifact(value) {
96
+ if (!isPlainObject(value))
97
+ return { valid: false, reason: 'artifact must be an object' };
98
+ if (value.artifactKind !== EXTERNAL_REFERENCE_ARTIFACT_KIND)
99
+ return { valid: false, reason: 'artifactKind mismatch' };
100
+ if (value.schemaVersion !== EXTERNAL_REFERENCE_SCHEMA_VERSION)
101
+ return { valid: false, reason: 'schemaVersion mismatch' };
102
+ if (!isNonEmptyString(value.referenceRequestId))
103
+ return { valid: false, reason: 'referenceRequestId must be a non-empty string' };
104
+ if (!isNonEmptyString(value.referenceId))
105
+ return { valid: false, reason: 'referenceId must be a non-empty string' };
106
+ if (!isPlainObject(value.producer) || value.producer.name !== PRODUCER_NAME || typeof value.producer.version !== 'string' || value.producer.version.length === 0) {
107
+ return { valid: false, reason: 'producer must be { name: "my-frontend-observer", version: string }' };
108
+ }
109
+ if (!isValidExternalReferenceProvenance(value.provenance))
110
+ return { valid: false, reason: 'provenance is invalid' };
111
+ if ('supersedesReferenceId' in value && value.supersedesReferenceId !== undefined && !isNonEmptyString(value.supersedesReferenceId)) {
112
+ return { valid: false, reason: 'supersedesReferenceId must be a non-empty string when present' };
113
+ }
114
+ if (!isValidDiagnosticArray(value.diagnostics))
115
+ return { valid: false, reason: 'diagnostics must be an array of valid Diagnostic values' };
116
+ if (!isValidCompletionState(value.completion))
117
+ return { valid: false, reason: 'completion is invalid' };
118
+ if (isPlainObject(value.completion) && value.completion.state === 'complete' && value.diagnostics.length > 0) {
119
+ return { valid: false, reason: 'completion "complete" requires an empty diagnostics array' };
120
+ }
121
+ if (!isValidExternalReferenceLifecycleState(value.lifecycle))
122
+ return { valid: false, reason: 'lifecycle is invalid' };
123
+ const lifecycle = value.lifecycle;
124
+ const hasImage = 'image' in value && value.image !== undefined;
125
+ const hasSourceReference = 'sourceReference' in value && value.sourceReference !== undefined;
126
+ let imageWidth;
127
+ let imageHeight;
128
+ if (lifecycle.state === 'imported') {
129
+ if (hasSourceReference)
130
+ return { valid: false, reason: 'an "imported" artifact must not carry sourceReference' };
131
+ if (!hasImage || !isValidExternalReferenceImageReference(value.image))
132
+ return { valid: false, reason: 'an "imported" artifact must carry a valid image reference' };
133
+ const image = value.image;
134
+ imageWidth = image.width;
135
+ imageHeight = image.height;
136
+ }
137
+ else {
138
+ // lifecycle.state === 'approved'
139
+ if (hasImage)
140
+ return { valid: false, reason: 'an "approved" artifact must not carry image (it never owns a copy of the reference image)' };
141
+ if (!hasSourceReference || !isValidExternalReferenceSourceReference(value.sourceReference)) {
142
+ return { valid: false, reason: 'an "approved" artifact must carry a valid sourceReference' };
143
+ }
144
+ const sourceReference = value.sourceReference;
145
+ imageWidth = sourceReference.image.width;
146
+ imageHeight = sourceReference.image.height;
147
+ }
148
+ const hasRegions = 'regions' in value && value.regions !== undefined;
149
+ if (hasRegions) {
150
+ const regionsValidation = isValidReferenceRegions(value.regions, imageWidth, imageHeight);
151
+ if (!regionsValidation.valid)
152
+ return { valid: false, reason: `regions: ${regionsValidation.reason}` };
153
+ }
154
+ if ('requirements' in value && value.requirements !== undefined) {
155
+ const regionsForRequirements = (hasRegions ? value.regions : []);
156
+ const requirementsValidation = isValidReferenceRequirements(value.requirements, regionsForRequirements);
157
+ if (!requirementsValidation.valid)
158
+ return { valid: false, reason: `requirements: ${requirementsValidation.reason}` };
159
+ }
160
+ if ('applicability' in value && value.applicability !== undefined) {
161
+ const applicabilityValidation = isValidExternalReferenceApplicability(value.applicability);
162
+ if (!applicabilityValidation.valid)
163
+ return { valid: false, reason: `applicability: ${applicabilityValidation.reason}` };
164
+ }
165
+ return { valid: true };
166
+ }
167
+ //# sourceMappingURL=externalReference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"externalReference.js","sourceRoot":"","sources":["../../src/domain/externalReference.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,8BAA8B,EAAE,uCAAuC,EAAE,MAAM,6BAA6B,CAAC;AAEtH,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE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AE,UAAU,EAAE,WAAW,CAAC,CAAC;QAC1F,IAAI,CAAC,iBAAiB,CAAC,KAAK;YAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,iBAAiB,CAAC,MAAM,EAAE,EAAE,CAAC;IACxG,CAAC;IAED,IAAI,cAAc,IAAI,KAAK,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QAChE,MAAM,sBAAsB,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAsB,CAAC;QACtF,MAAM,sBAAsB,GAAG,4BAA4B,CAAC,KAAK,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC;QACxG,IAAI,CAAC,sBAAsB,CAAC,KAAK;YAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,sBAAsB,CAAC,MAAM,EAAE,EAAE,CAAC;IACvH,CAAC;IAED,IAAI,eAAe,IAAI,KAAK,IAAI,KAAK,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QAClE,MAAM,uBAAuB,GAAG,qCAAqC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC3F,IAAI,CAAC,uBAAuB,CAAC,KAAK;YAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,uBAAuB,CAAC,MAAM,EAAE,EAAE,CAAC;IAC1H,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * v0.7 Prompt 4 reference applicability - the runtime frontend state that an
3
+ * external reference image is intended to represent, so a later candidate
4
+ * comparison can honestly determine whether the reference and a candidate
5
+ * describe the same state (see domain/externalReferenceCompatibility.ts).
6
+ *
7
+ * `viewport` here is deliberately distinct from the reference image's own
8
+ * pixel dimensions (`ExternalReferenceImageReference.width/height` in
9
+ * externalReference.ts): a reference image may be captured at any
10
+ * resolution/DPI, but `applicability.viewport` describes the CSS-pixel
11
+ * runtime viewport the design represents (e.g. a 960x1240 reference image
12
+ * showing a 480x620 CSS-pixel mobile layout at 2x device pixel ratio). This
13
+ * module never reads or infers a viewport from image dimensions.
14
+ */
15
+ import type { ExplicitStateDimensions } from './explicitState.js';
16
+ /** Intentionally mirrors request/request.ts's VIEWPORT_MIN/MAX values (200/3840) as independently-owned constants - the applicable viewport describes the same kind of CSS-pixel runtime viewport an observation request configures, so the same bounds apply, but this module has no import dependency on request/request.ts. */
17
+ export declare const APPLICABLE_VIEWPORT_MIN = 200;
18
+ export declare const APPLICABLE_VIEWPORT_MAX = 3840;
19
+ export interface ApplicableViewport {
20
+ width: number;
21
+ height: number;
22
+ }
23
+ export declare function isValidApplicableViewport(value: unknown): value is ApplicableViewport;
24
+ /** Every field independently optional - a reference need not declare every applicability dimension, and an unset dimension is never treated as a wildcard match nor a mismatch (see externalReferenceCompatibility.ts's unassessed semantics). */
25
+ export interface ExternalReferenceApplicability extends ExplicitStateDimensions {
26
+ viewport?: ApplicableViewport;
27
+ }
28
+ export type ApplicabilityValidationResult = {
29
+ valid: true;
30
+ } | {
31
+ valid: false;
32
+ reason: string;
33
+ };
34
+ /**
35
+ * Deliberately its own validator rather than a reuse of
36
+ * isValidExplicitStateDimensions: that function requires at least one of its
37
+ * three fields, which would incorrectly reject an applicability object that
38
+ * declares only `viewport` (a fully valid, common case - a reference may
39
+ * constrain viewport without constraining theme/state at all). The three
40
+ * shared state-label/authenticated-state checks are reused field-by-field
41
+ * instead.
42
+ */
43
+ export declare function isValidExternalReferenceApplicability(value: unknown): ApplicabilityValidationResult;
@@ -0,0 +1,52 @@
1
+ import { isValidStateLabel, isValidAuthenticatedState, STATE_LABEL_PATTERN, AUTHENTICATED_STATE_VALUES } from './explicitState.js';
2
+ function isPlainObject(value) {
3
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
4
+ }
5
+ function isInRange(value, min, max) {
6
+ return typeof value === 'number' && Number.isInteger(value) && value >= min && value <= max;
7
+ }
8
+ /** Intentionally mirrors request/request.ts's VIEWPORT_MIN/MAX values (200/3840) as independently-owned constants - the applicable viewport describes the same kind of CSS-pixel runtime viewport an observation request configures, so the same bounds apply, but this module has no import dependency on request/request.ts. */
9
+ export const APPLICABLE_VIEWPORT_MIN = 200;
10
+ export const APPLICABLE_VIEWPORT_MAX = 3840;
11
+ export function isValidApplicableViewport(value) {
12
+ if (!isPlainObject(value))
13
+ return false;
14
+ if (Object.keys(value).length !== 2)
15
+ return false;
16
+ return isInRange(value.width, APPLICABLE_VIEWPORT_MIN, APPLICABLE_VIEWPORT_MAX) && isInRange(value.height, APPLICABLE_VIEWPORT_MIN, APPLICABLE_VIEWPORT_MAX);
17
+ }
18
+ const APPLICABILITY_KEYS = ['viewport', 'theme', 'applicationState', 'authenticatedState'];
19
+ /**
20
+ * Deliberately its own validator rather than a reuse of
21
+ * isValidExplicitStateDimensions: that function requires at least one of its
22
+ * three fields, which would incorrectly reject an applicability object that
23
+ * declares only `viewport` (a fully valid, common case - a reference may
24
+ * constrain viewport without constraining theme/state at all). The three
25
+ * shared state-label/authenticated-state checks are reused field-by-field
26
+ * instead.
27
+ */
28
+ export function isValidExternalReferenceApplicability(value) {
29
+ if (!isPlainObject(value))
30
+ return { valid: false, reason: 'must be an object' };
31
+ const unknownKeys = Object.keys(value).filter((key) => !APPLICABILITY_KEYS.includes(key));
32
+ if (unknownKeys.length > 0)
33
+ return { valid: false, reason: `has unsupported field(s): ${unknownKeys.join(', ')}` };
34
+ const hasViewport = 'viewport' in value && value.viewport !== undefined;
35
+ if (hasViewport && !isValidApplicableViewport(value.viewport)) {
36
+ return { valid: false, reason: `viewport must be { width, height } integers in [${APPLICABLE_VIEWPORT_MIN}, ${APPLICABLE_VIEWPORT_MAX}]` };
37
+ }
38
+ if ('theme' in value && value.theme !== undefined && !isValidStateLabel(value.theme)) {
39
+ return { valid: false, reason: `theme must match ${STATE_LABEL_PATTERN}` };
40
+ }
41
+ if ('applicationState' in value && value.applicationState !== undefined && !isValidStateLabel(value.applicationState)) {
42
+ return { valid: false, reason: `applicationState must match ${STATE_LABEL_PATTERN}` };
43
+ }
44
+ if ('authenticatedState' in value && value.authenticatedState !== undefined && !isValidAuthenticatedState(value.authenticatedState)) {
45
+ return { valid: false, reason: `authenticatedState must be one of ${AUTHENTICATED_STATE_VALUES.join(', ')}` };
46
+ }
47
+ if (Object.keys(value).length === 0) {
48
+ return { valid: false, reason: 'must declare at least one dimension (viewport, theme, applicationState, or authenticatedState)' };
49
+ }
50
+ return { valid: true };
51
+ }
52
+ //# sourceMappingURL=externalReferenceApplicability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"externalReferenceApplicability.js","sourceRoot":"","sources":["../../src/domain/externalReferenceApplicability.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEnI,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,SAAS,CAAC,KAAc,EAAE,GAAW,EAAE,GAAW;IACzD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,CAAC;AAC9F,CAAC;AAED,kUAAkU;AAClU,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAO5C,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACtD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,MAAM,CAAC,IAAI,CAAC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AC;QACrF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,oBAAoB,mBAAmB,EAAE,EAAE,CAAC;IAC7E,CAAC;IACD,IAAI,kBAAkB,IAAI,KAAK,IAAI,KAAK,CAAC,gBAAgB,KAAK,SAAS,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACtH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,+BAA+B,mBAAmB,EAAE,EAAE,CAAC;IACxF,CAAC;IACD,IAAI,oBAAoB,IAAI,KAAK,IAAI,KAAK,CAAC,kBAAkB,KAAK,SAAS,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACpI,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,qCAAqC,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;IAChH,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,gGAAgG,EAAE,CAAC;IACpI,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * v0.7 Prompt 4 reference/candidate compatibility - answers only "does this
3
+ * external reference describe the same frontend state as this candidate
4
+ * ObservationArtifact?" before any later reference-vs-candidate geometry
5
+ * evaluation is attempted (Prompt 6+). This is page/state-level only: no
6
+ * reference-region <-> runtime-target binding (Prompt 5), no geometry
7
+ * difference, no fidelity PASS/FAIL, no style/image comparison.
8
+ *
9
+ * Deliberately reuses domain/comparison.ts's `ComparabilityResult`/
10
+ * `ComparabilityReason`/`ComparabilityState`/`COMPARABILITY_REASON_CODES`/
11
+ * `COMPARABILITY_REASON_SEVERITY` wholesale, and
12
+ * domain/comparisonEngine.ts#assessOptionalComparabilityDimension (the exact
13
+ * same pure rule v0.4's own `evaluateComparability` uses for its explicit-
14
+ * state dimensions) rather than inventing a second compatibility model - an
15
+ * ExternalReferenceArtifact is never treated as if it were an
16
+ * ObservationArtifact, but the *result* and *dimension-comparison rule* are
17
+ * shared.
18
+ */
19
+ import type { ExternalReferenceArtifact } from './externalReference.js';
20
+ import type { ObservationArtifact } from './schema.js';
21
+ import type { ComparabilityResult } from './comparison.js';
22
+ export interface ReferenceCandidateCompatibilityResult {
23
+ referenceId: string;
24
+ referenceRequestId: string;
25
+ candidateObservationId: string;
26
+ candidateRequestId: string;
27
+ compatibility: ComparabilityResult;
28
+ }
29
+ /**
30
+ * Pure and synchronous: same `(reference, candidate)` in, same result out,
31
+ * every time - no browser, no filesystem, no target binding. Only evaluates
32
+ * `reference.applicability` against `candidate.requestConfig` (viewport,
33
+ * always present on an observation) / `candidate.requestConfig.explicitState`
34
+ * (theme/authenticatedState/applicationState, each independently optional on
35
+ * both sides) - reference region/requirement content is never consulted
36
+ * here (see domain/externalReferenceRequirements.ts for that, a distinct,
37
+ * separate concern - reference adequacy and reference/candidate
38
+ * compatibility are never conflated).
39
+ */
40
+ export declare function evaluateReferenceCandidateCompatibility(reference: ExternalReferenceArtifact, candidate: ObservationArtifact): ReferenceCandidateCompatibilityResult;
@@ -0,0 +1,48 @@
1
+ import { COMPARABILITY_REASON_CODES } from './comparison.js';
2
+ import { assessOptionalComparabilityDimension } from './comparisonEngine.js';
3
+ function viewportLabel(viewport) {
4
+ return `${viewport.width}x${viewport.height}`;
5
+ }
6
+ /**
7
+ * Pure and synchronous: same `(reference, candidate)` in, same result out,
8
+ * every time - no browser, no filesystem, no target binding. Only evaluates
9
+ * `reference.applicability` against `candidate.requestConfig` (viewport,
10
+ * always present on an observation) / `candidate.requestConfig.explicitState`
11
+ * (theme/authenticatedState/applicationState, each independently optional on
12
+ * both sides) - reference region/requirement content is never consulted
13
+ * here (see domain/externalReferenceRequirements.ts for that, a distinct,
14
+ * separate concern - reference adequacy and reference/candidate
15
+ * compatibility are never conflated).
16
+ */
17
+ export function evaluateReferenceCandidateCompatibility(reference, candidate) {
18
+ const applicability = reference.applicability;
19
+ const reasons = [];
20
+ const referenceViewportLabel = applicability?.viewport ? viewportLabel(applicability.viewport) : undefined;
21
+ const candidateViewportLabel = viewportLabel(candidate.requestConfig.viewport);
22
+ const viewportReason = assessOptionalComparabilityDimension('viewport-mismatch', 'viewport-unassessed', referenceViewportLabel, candidateViewportLabel, (r, c) => `reference applicable viewport ${r} differs from candidate viewport ${c}`, 'reference does not declare an applicable viewport');
23
+ if (viewportReason)
24
+ reasons.push(viewportReason);
25
+ const candidateState = candidate.requestConfig.explicitState;
26
+ const themeReason = assessOptionalComparabilityDimension('theme-mismatch', 'theme-unassessed', applicability?.theme, candidateState?.theme, (r, c) => `reference applicable theme "${r}" differs from candidate explicit theme "${c}"`, 'theme identity is not assessed unless both the reference applicability and the candidate observation declare it');
27
+ if (themeReason)
28
+ reasons.push(themeReason);
29
+ const authReason = assessOptionalComparabilityDimension('authenticated-state-mismatch', 'authenticated-state-unassessed', applicability?.authenticatedState, candidateState?.authenticatedState, (r, c) => `reference applicable authenticatedState "${r}" differs from candidate explicit authenticatedState "${c}"`, 'authenticated-state identity is not assessed unless both the reference applicability and the candidate observation declare it');
30
+ if (authReason)
31
+ reasons.push(authReason);
32
+ const appStateReason = assessOptionalComparabilityDimension('application-state-mismatch', 'application-state-unassessed', applicability?.applicationState, candidateState?.applicationState, (r, c) => `reference applicable applicationState "${r}" differs from candidate explicit applicationState "${c}"`, 'application-state identity is not assessed unless both the reference applicability and the candidate observation declare it');
33
+ if (appStateReason)
34
+ reasons.push(appStateReason);
35
+ // Deterministic ordering, reusing the exact same shared code-index rule v0.4's evaluateComparability uses.
36
+ reasons.sort((a, b) => COMPARABILITY_REASON_CODES.indexOf(a.code) - COMPARABILITY_REASON_CODES.indexOf(b.code));
37
+ const hasBlocking = reasons.some((reason) => reason.severity === 'blocking');
38
+ const hasWarning = reasons.some((reason) => reason.severity === 'warning');
39
+ const state = hasBlocking ? 'incomparable' : hasWarning ? 'comparable-with-warnings' : 'comparable';
40
+ return {
41
+ referenceId: reference.referenceId,
42
+ referenceRequestId: reference.referenceRequestId,
43
+ candidateObservationId: candidate.observationId,
44
+ candidateRequestId: candidate.requestId,
45
+ compatibility: { state, reasons },
46
+ };
47
+ }
48
+ //# sourceMappingURL=externalReferenceCompatibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"externalReferenceCompatibility.js","sourceRoot":"","sources":["../../src/domain/externalReferenceCompatibility.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,oCAAoC,EAAE,MAAM,uBAAuB,CAAC;AAU7E,SAAS,aAAa,CAAC,QAA2C;IAChE,OAAO,GAAG,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;AAChD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uCAAuC,CAAC,SAAoC,EAAE,SAA8B;IAC1H,MAAM,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;IAC9C,MAAM,OAAO,GAA0B,EAAE,CAAC;IAE1C,MAAM,sBAAsB,GAAG,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3G,MAAM,sBAAsB,GAAG,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/E,MAAM,cAAc,GAAG,oCAAoC,CACzD,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,EAAE,EACnF,mDAAmD,CACpD,CAAC;IACF,IAAI,cAAc;QA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