@azx-pbc/axiom-compiler 0.0.0-stage → 0.0.6

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 (655) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +415 -2
  3. package/dist/article.d.ts +12 -0
  4. package/dist/article.d.ts.map +1 -0
  5. package/dist/article.js +16 -0
  6. package/dist/article.js.map +1 -0
  7. package/dist/cli/args.d.ts +101 -0
  8. package/dist/cli/args.d.ts.map +1 -0
  9. package/dist/cli/args.js +158 -0
  10. package/dist/cli/args.js.map +1 -0
  11. package/dist/cli/check.d.ts +2 -0
  12. package/dist/cli/check.d.ts.map +1 -0
  13. package/dist/cli/check.js +33 -0
  14. package/dist/cli/check.js.map +1 -0
  15. package/dist/cli/compile.d.ts +2 -0
  16. package/dist/cli/compile.d.ts.map +1 -0
  17. package/dist/cli/compile.js +43 -0
  18. package/dist/cli/compile.js.map +1 -0
  19. package/dist/cli/count.d.ts +15 -0
  20. package/dist/cli/count.d.ts.map +1 -0
  21. package/dist/cli/count.js +21 -0
  22. package/dist/cli/count.js.map +1 -0
  23. package/dist/cli/dataset.d.ts +28 -0
  24. package/dist/cli/dataset.d.ts.map +1 -0
  25. package/dist/cli/dataset.js +115 -0
  26. package/dist/cli/dataset.js.map +1 -0
  27. package/dist/cli/diff.d.ts +2 -0
  28. package/dist/cli/diff.d.ts.map +1 -0
  29. package/dist/cli/diff.js +297 -0
  30. package/dist/cli/diff.js.map +1 -0
  31. package/dist/cli/explain.d.ts +2 -0
  32. package/dist/cli/explain.d.ts.map +1 -0
  33. package/dist/cli/explain.js +95 -0
  34. package/dist/cli/explain.js.map +1 -0
  35. package/dist/cli/fields.d.ts +11 -0
  36. package/dist/cli/fields.d.ts.map +1 -0
  37. package/dist/cli/fields.js +13 -0
  38. package/dist/cli/fields.js.map +1 -0
  39. package/dist/cli/main.d.ts +2 -0
  40. package/dist/cli/main.d.ts.map +1 -0
  41. package/dist/cli/main.js +40 -0
  42. package/dist/cli/main.js.map +1 -0
  43. package/dist/cli/read.d.ts +56 -0
  44. package/dist/cli/read.d.ts.map +1 -0
  45. package/dist/cli/read.js +179 -0
  46. package/dist/cli/read.js.map +1 -0
  47. package/dist/cli/render.d.ts +58 -0
  48. package/dist/cli/render.d.ts.map +1 -0
  49. package/dist/cli/render.js +422 -0
  50. package/dist/cli/render.js.map +1 -0
  51. package/dist/cli/schema.d.ts +28 -0
  52. package/dist/cli/schema.d.ts.map +1 -0
  53. package/dist/cli/schema.js +46 -0
  54. package/dist/cli/schema.js.map +1 -0
  55. package/dist/cli/suite-report.d.ts +18 -0
  56. package/dist/cli/suite-report.d.ts.map +1 -0
  57. package/dist/cli/suite-report.js +58 -0
  58. package/dist/cli/suite-report.js.map +1 -0
  59. package/dist/cli/suites.d.ts +25 -0
  60. package/dist/cli/suites.d.ts.map +1 -0
  61. package/dist/cli/suites.js +67 -0
  62. package/dist/cli/suites.js.map +1 -0
  63. package/dist/cli/terminal.d.ts +45 -0
  64. package/dist/cli/terminal.d.ts.map +1 -0
  65. package/dist/cli/terminal.js +119 -0
  66. package/dist/cli/terminal.js.map +1 -0
  67. package/dist/cli/test.d.ts +12 -0
  68. package/dist/cli/test.d.ts.map +1 -0
  69. package/dist/cli/test.js +199 -0
  70. package/dist/cli/test.js.map +1 -0
  71. package/dist/cli/usage.d.ts +15 -0
  72. package/dist/cli/usage.d.ts.map +1 -0
  73. package/dist/cli/usage.js +95 -0
  74. package/dist/cli/usage.js.map +1 -0
  75. package/dist/cli.d.ts +3 -0
  76. package/dist/cli.d.ts.map +1 -0
  77. package/dist/cli.js +51 -0
  78. package/dist/cli.js.map +1 -0
  79. package/dist/compile/artifact-members.d.ts +57 -0
  80. package/dist/compile/artifact-members.d.ts.map +1 -0
  81. package/dist/compile/artifact-members.js +130 -0
  82. package/dist/compile/artifact-members.js.map +1 -0
  83. package/dist/compile/artifact.d.ts +20 -0
  84. package/dist/compile/artifact.d.ts.map +1 -0
  85. package/dist/compile/artifact.js +87 -0
  86. package/dist/compile/artifact.js.map +1 -0
  87. package/dist/compile/compilation.d.ts +46 -0
  88. package/dist/compile/compilation.d.ts.map +1 -0
  89. package/dist/compile/compilation.js +4 -0
  90. package/dist/compile/compilation.js.map +1 -0
  91. package/dist/compile/computed.d.ts +22 -0
  92. package/dist/compile/computed.d.ts.map +1 -0
  93. package/dist/compile/computed.js +245 -0
  94. package/dist/compile/computed.js.map +1 -0
  95. package/dist/compile/condition-warnings.d.ts +12 -0
  96. package/dist/compile/condition-warnings.d.ts.map +1 -0
  97. package/dist/compile/condition-warnings.js +26 -0
  98. package/dist/compile/condition-warnings.js.map +1 -0
  99. package/dist/compile/conditions.d.ts +18 -0
  100. package/dist/compile/conditions.d.ts.map +1 -0
  101. package/dist/compile/conditions.js +22 -0
  102. package/dist/compile/conditions.js.map +1 -0
  103. package/dist/compile/cross-checks.d.ts +67 -0
  104. package/dist/compile/cross-checks.d.ts.map +1 -0
  105. package/dist/compile/cross-checks.js +238 -0
  106. package/dist/compile/cross-checks.js.map +1 -0
  107. package/dist/compile/datasets.d.ts +52 -0
  108. package/dist/compile/datasets.d.ts.map +1 -0
  109. package/dist/compile/datasets.js +183 -0
  110. package/dist/compile/datasets.js.map +1 -0
  111. package/dist/compile/dead-weight.d.ts +26 -0
  112. package/dist/compile/dead-weight.d.ts.map +1 -0
  113. package/dist/compile/dead-weight.js +244 -0
  114. package/dist/compile/dead-weight.js.map +1 -0
  115. package/dist/compile/declaration-rules.d.ts +54 -0
  116. package/dist/compile/declaration-rules.d.ts.map +1 -0
  117. package/dist/compile/declaration-rules.js +510 -0
  118. package/dist/compile/declaration-rules.js.map +1 -0
  119. package/dist/compile/declarations.d.ts +44 -0
  120. package/dist/compile/declarations.d.ts.map +1 -0
  121. package/dist/compile/declarations.js +160 -0
  122. package/dist/compile/declarations.js.map +1 -0
  123. package/dist/compile/document.d.ts +4 -0
  124. package/dist/compile/document.d.ts.map +1 -0
  125. package/dist/compile/document.js +13 -0
  126. package/dist/compile/document.js.map +1 -0
  127. package/dist/compile/expression.d.ts +38 -0
  128. package/dist/compile/expression.d.ts.map +1 -0
  129. package/dist/compile/expression.js +288 -0
  130. package/dist/compile/expression.js.map +1 -0
  131. package/dist/compile/hashes.d.ts +26 -0
  132. package/dist/compile/hashes.d.ts.map +1 -0
  133. package/dist/compile/hashes.js +96 -0
  134. package/dist/compile/hashes.js.map +1 -0
  135. package/dist/compile/item-targets.d.ts +12 -0
  136. package/dist/compile/item-targets.d.ts.map +1 -0
  137. package/dist/compile/item-targets.js +287 -0
  138. package/dist/compile/item-targets.js.map +1 -0
  139. package/dist/compile/messages.d.ts +8 -0
  140. package/dist/compile/messages.d.ts.map +1 -0
  141. package/dist/compile/messages.js +62 -0
  142. package/dist/compile/messages.js.map +1 -0
  143. package/dist/compile/option-availability.d.ts +51 -0
  144. package/dist/compile/option-availability.d.ts.map +1 -0
  145. package/dist/compile/option-availability.js +171 -0
  146. package/dist/compile/option-availability.js.map +1 -0
  147. package/dist/compile/option-codes.d.ts +27 -0
  148. package/dist/compile/option-codes.d.ts.map +1 -0
  149. package/dist/compile/option-codes.js +212 -0
  150. package/dist/compile/option-codes.js.map +1 -0
  151. package/dist/compile/references.d.ts +14 -0
  152. package/dist/compile/references.d.ts.map +1 -0
  153. package/dist/compile/references.js +126 -0
  154. package/dist/compile/references.js.map +1 -0
  155. package/dist/compile/rows-from.d.ts +27 -0
  156. package/dist/compile/rows-from.d.ts.map +1 -0
  157. package/dist/compile/rows-from.js +164 -0
  158. package/dist/compile/rows-from.js.map +1 -0
  159. package/dist/compile/rules.d.ts +58 -0
  160. package/dist/compile/rules.d.ts.map +1 -0
  161. package/dist/compile/rules.js +327 -0
  162. package/dist/compile/rules.js.map +1 -0
  163. package/dist/compile/suggestions.d.ts +52 -0
  164. package/dist/compile/suggestions.d.ts.map +1 -0
  165. package/dist/compile/suggestions.js +633 -0
  166. package/dist/compile/suggestions.js.map +1 -0
  167. package/dist/compile/targets.d.ts +22 -0
  168. package/dist/compile/targets.d.ts.map +1 -0
  169. package/dist/compile/targets.js +125 -0
  170. package/dist/compile/targets.js.map +1 -0
  171. package/dist/compile/types.d.ts +84 -0
  172. package/dist/compile/types.d.ts.map +1 -0
  173. package/dist/compile/types.js +2 -0
  174. package/dist/compile/types.js.map +1 -0
  175. package/dist/compile/warning.d.ts +45 -0
  176. package/dist/compile/warning.d.ts.map +1 -0
  177. package/dist/compile/warning.js +2 -0
  178. package/dist/compile/warning.js.map +1 -0
  179. package/dist/compile-yaml.d.ts +23 -0
  180. package/dist/compile-yaml.d.ts.map +1 -0
  181. package/dist/compile-yaml.js +30 -0
  182. package/dist/compile-yaml.js.map +1 -0
  183. package/dist/compile.d.ts +78 -0
  184. package/dist/compile.d.ts.map +1 -0
  185. package/dist/compile.js +372 -0
  186. package/dist/compile.js.map +1 -0
  187. package/dist/csv/limits.d.ts +43 -0
  188. package/dist/csv/limits.d.ts.map +1 -0
  189. package/dist/csv/limits.js +51 -0
  190. package/dist/csv/limits.js.map +1 -0
  191. package/dist/csv/scalar.d.ts +33 -0
  192. package/dist/csv/scalar.d.ts.map +1 -0
  193. package/dist/csv/scalar.js +77 -0
  194. package/dist/csv/scalar.js.map +1 -0
  195. package/dist/datasets/csv.d.ts +46 -0
  196. package/dist/datasets/csv.d.ts.map +1 -0
  197. package/dist/datasets/csv.js +293 -0
  198. package/dist/datasets/csv.js.map +1 -0
  199. package/dist/datasets/declaration.d.ts +16 -0
  200. package/dist/datasets/declaration.d.ts.map +1 -0
  201. package/dist/datasets/declaration.js +104 -0
  202. package/dist/datasets/declaration.js.map +1 -0
  203. package/dist/datasets/diagnostics.d.ts +65 -0
  204. package/dist/datasets/diagnostics.d.ts.map +1 -0
  205. package/dist/datasets/diagnostics.js +2 -0
  206. package/dist/datasets/diagnostics.js.map +1 -0
  207. package/dist/datasets/diff.d.ts +46 -0
  208. package/dist/datasets/diff.d.ts.map +1 -0
  209. package/dist/datasets/diff.js +84 -0
  210. package/dist/datasets/diff.js.map +1 -0
  211. package/dist/datasets/document.d.ts +12 -0
  212. package/dist/datasets/document.d.ts.map +1 -0
  213. package/dist/datasets/document.js +382 -0
  214. package/dist/datasets/document.js.map +1 -0
  215. package/dist/datasets/index.d.ts +43 -0
  216. package/dist/datasets/index.d.ts.map +1 -0
  217. package/dist/datasets/index.js +68 -0
  218. package/dist/datasets/index.js.map +1 -0
  219. package/dist/datasets/repair.d.ts +26 -0
  220. package/dist/datasets/repair.d.ts.map +1 -0
  221. package/dist/datasets/repair.js +60 -0
  222. package/dist/datasets/repair.js.map +1 -0
  223. package/dist/document-path.d.ts +62 -0
  224. package/dist/document-path.d.ts.map +1 -0
  225. package/dist/document-path.js +200 -0
  226. package/dist/document-path.js.map +1 -0
  227. package/dist/expr/boundary.d.ts +8 -0
  228. package/dist/expr/boundary.d.ts.map +1 -0
  229. package/dist/expr/boundary.js +243 -0
  230. package/dist/expr/boundary.js.map +1 -0
  231. package/dist/expr/compile-expr.d.ts +35 -0
  232. package/dist/expr/compile-expr.d.ts.map +1 -0
  233. package/dist/expr/compile-expr.js +66 -0
  234. package/dist/expr/compile-expr.js.map +1 -0
  235. package/dist/expr/deprecation.d.ts +23 -0
  236. package/dist/expr/deprecation.d.ts.map +1 -0
  237. package/dist/expr/deprecation.js +28 -0
  238. package/dist/expr/deprecation.js.map +1 -0
  239. package/dist/expr/diagnostics.d.ts +31 -0
  240. package/dist/expr/diagnostics.d.ts.map +1 -0
  241. package/dist/expr/diagnostics.js +34 -0
  242. package/dist/expr/diagnostics.js.map +1 -0
  243. package/dist/expr/lexer.d.ts +49 -0
  244. package/dist/expr/lexer.d.ts.map +1 -0
  245. package/dist/expr/lexer.js +277 -0
  246. package/dist/expr/lexer.js.map +1 -0
  247. package/dist/expr/lint-warnings.d.ts +11 -0
  248. package/dist/expr/lint-warnings.d.ts.map +1 -0
  249. package/dist/expr/lint-warnings.js +20 -0
  250. package/dist/expr/lint-warnings.js.map +1 -0
  251. package/dist/expr/lint.d.ts +41 -0
  252. package/dist/expr/lint.d.ts.map +1 -0
  253. package/dist/expr/lint.js +1034 -0
  254. package/dist/expr/lint.js.map +1 -0
  255. package/dist/expr/parse/aggregates.d.ts +13 -0
  256. package/dist/expr/parse/aggregates.d.ts.map +1 -0
  257. package/dist/expr/parse/aggregates.js +48 -0
  258. package/dist/expr/parse/aggregates.js.map +1 -0
  259. package/dist/expr/parse/budget.d.ts +11 -0
  260. package/dist/expr/parse/budget.d.ts.map +1 -0
  261. package/dist/expr/parse/budget.js +57 -0
  262. package/dist/expr/parse/budget.js.map +1 -0
  263. package/dist/expr/parse/grammar.d.ts +9 -0
  264. package/dist/expr/parse/grammar.d.ts.map +1 -0
  265. package/dist/expr/parse/grammar.js +699 -0
  266. package/dist/expr/parse/grammar.js.map +1 -0
  267. package/dist/expr/parse/literals.d.ts +20 -0
  268. package/dist/expr/parse/literals.d.ts.map +1 -0
  269. package/dist/expr/parse/literals.js +132 -0
  270. package/dist/expr/parse/literals.js.map +1 -0
  271. package/dist/expr/parse/stream.d.ts +60 -0
  272. package/dist/expr/parse/stream.d.ts.map +1 -0
  273. package/dist/expr/parse/stream.js +151 -0
  274. package/dist/expr/parse/stream.js.map +1 -0
  275. package/dist/expr/parser.d.ts +45 -0
  276. package/dist/expr/parser.d.ts.map +1 -0
  277. package/dist/expr/parser.js +110 -0
  278. package/dist/expr/parser.js.map +1 -0
  279. package/dist/expr/print/spell.d.ts +78 -0
  280. package/dist/expr/print/spell.d.ts.map +1 -0
  281. package/dist/expr/print/spell.js +592 -0
  282. package/dist/expr/print/spell.js.map +1 -0
  283. package/dist/expr/print.d.ts +20 -0
  284. package/dist/expr/print.d.ts.map +1 -0
  285. package/dist/expr/print.js +102 -0
  286. package/dist/expr/print.js.map +1 -0
  287. package/dist/expr/suggest.d.ts +26 -0
  288. package/dist/expr/suggest.d.ts.map +1 -0
  289. package/dist/expr/suggest.js +77 -0
  290. package/dist/expr/suggest.js.map +1 -0
  291. package/dist/expr/typecheck/aggregates.d.ts +8 -0
  292. package/dist/expr/typecheck/aggregates.d.ts.map +1 -0
  293. package/dist/expr/typecheck/aggregates.js +334 -0
  294. package/dist/expr/typecheck/aggregates.js.map +1 -0
  295. package/dist/expr/typecheck/arithmetic.d.ts +6 -0
  296. package/dist/expr/typecheck/arithmetic.d.ts.map +1 -0
  297. package/dist/expr/typecheck/arithmetic.js +258 -0
  298. package/dist/expr/typecheck/arithmetic.js.map +1 -0
  299. package/dist/expr/typecheck/arity.d.ts +38 -0
  300. package/dist/expr/typecheck/arity.d.ts.map +1 -0
  301. package/dist/expr/typecheck/arity.js +173 -0
  302. package/dist/expr/typecheck/arity.js.map +1 -0
  303. package/dist/expr/typecheck/calls.d.ts +6 -0
  304. package/dist/expr/typecheck/calls.d.ts.map +1 -0
  305. package/dist/expr/typecheck/calls.js +137 -0
  306. package/dist/expr/typecheck/calls.js.map +1 -0
  307. package/dist/expr/typecheck/comparison.d.ts +13 -0
  308. package/dist/expr/typecheck/comparison.d.ts.map +1 -0
  309. package/dist/expr/typecheck/comparison.js +200 -0
  310. package/dist/expr/typecheck/comparison.js.map +1 -0
  311. package/dist/expr/typecheck/compound.d.ts +24 -0
  312. package/dist/expr/typecheck/compound.d.ts.map +1 -0
  313. package/dist/expr/typecheck/compound.js +175 -0
  314. package/dist/expr/typecheck/compound.js.map +1 -0
  315. package/dist/expr/typecheck/context.d.ts +44 -0
  316. package/dist/expr/typecheck/context.d.ts.map +1 -0
  317. package/dist/expr/typecheck/context.js +2 -0
  318. package/dist/expr/typecheck/context.js.map +1 -0
  319. package/dist/expr/typecheck/datasets.d.ts +17 -0
  320. package/dist/expr/typecheck/datasets.d.ts.map +1 -0
  321. package/dist/expr/typecheck/datasets.js +136 -0
  322. package/dist/expr/typecheck/datasets.js.map +1 -0
  323. package/dist/expr/typecheck/digest.d.ts +7 -0
  324. package/dist/expr/typecheck/digest.d.ts.map +1 -0
  325. package/dist/expr/typecheck/digest.js +44 -0
  326. package/dist/expr/typecheck/digest.js.map +1 -0
  327. package/dist/expr/typecheck/fold.d.ts +41 -0
  328. package/dist/expr/typecheck/fold.d.ts.map +1 -0
  329. package/dist/expr/typecheck/fold.js +71 -0
  330. package/dist/expr/typecheck/fold.js.map +1 -0
  331. package/dist/expr/typecheck/gate-folds.d.ts +22 -0
  332. package/dist/expr/typecheck/gate-folds.d.ts.map +1 -0
  333. package/dist/expr/typecheck/gate-folds.js +40 -0
  334. package/dist/expr/typecheck/gate-folds.js.map +1 -0
  335. package/dist/expr/typecheck/guards.d.ts +6 -0
  336. package/dist/expr/typecheck/guards.d.ts.map +1 -0
  337. package/dist/expr/typecheck/guards.js +38 -0
  338. package/dist/expr/typecheck/guards.js.map +1 -0
  339. package/dist/expr/typecheck/member.d.ts +17 -0
  340. package/dist/expr/typecheck/member.d.ts.map +1 -0
  341. package/dist/expr/typecheck/member.js +46 -0
  342. package/dist/expr/typecheck/member.js.map +1 -0
  343. package/dist/expr/typecheck/money.d.ts +8 -0
  344. package/dist/expr/typecheck/money.d.ts.map +1 -0
  345. package/dist/expr/typecheck/money.js +49 -0
  346. package/dist/expr/typecheck/money.js.map +1 -0
  347. package/dist/expr/typecheck/numeric.d.ts +8 -0
  348. package/dist/expr/typecheck/numeric.d.ts.map +1 -0
  349. package/dist/expr/typecheck/numeric.js +84 -0
  350. package/dist/expr/typecheck/numeric.js.map +1 -0
  351. package/dist/expr/typecheck/operands.d.ts +27 -0
  352. package/dist/expr/typecheck/operands.d.ts.map +1 -0
  353. package/dist/expr/typecheck/operands.js +106 -0
  354. package/dist/expr/typecheck/operands.js.map +1 -0
  355. package/dist/expr/typecheck/paths.d.ts +21 -0
  356. package/dist/expr/typecheck/paths.d.ts.map +1 -0
  357. package/dist/expr/typecheck/paths.js +321 -0
  358. package/dist/expr/typecheck/paths.js.map +1 -0
  359. package/dist/expr/typecheck/records.d.ts +24 -0
  360. package/dist/expr/typecheck/records.d.ts.map +1 -0
  361. package/dist/expr/typecheck/records.js +53 -0
  362. package/dist/expr/typecheck/records.js.map +1 -0
  363. package/dist/expr/typecheck/sequences.d.ts +15 -0
  364. package/dist/expr/typecheck/sequences.d.ts.map +1 -0
  365. package/dist/expr/typecheck/sequences.js +55 -0
  366. package/dist/expr/typecheck/sequences.js.map +1 -0
  367. package/dist/expr/typecheck/strings.d.ts +8 -0
  368. package/dist/expr/typecheck/strings.d.ts.map +1 -0
  369. package/dist/expr/typecheck/strings.js +188 -0
  370. package/dist/expr/typecheck/strings.js.map +1 -0
  371. package/dist/expr/typecheck/temporal.d.ts +7 -0
  372. package/dist/expr/typecheck/temporal.d.ts.map +1 -0
  373. package/dist/expr/typecheck/temporal.js +80 -0
  374. package/dist/expr/typecheck/temporal.js.map +1 -0
  375. package/dist/expr/typecheck/types.d.ts +163 -0
  376. package/dist/expr/typecheck/types.d.ts.map +1 -0
  377. package/dist/expr/typecheck/types.js +404 -0
  378. package/dist/expr/typecheck/types.js.map +1 -0
  379. package/dist/expr/typecheck.d.ts +75 -0
  380. package/dist/expr/typecheck.d.ts.map +1 -0
  381. package/dist/expr/typecheck.js +242 -0
  382. package/dist/expr/typecheck.js.map +1 -0
  383. package/dist/expr/undecided.d.ts +13 -0
  384. package/dist/expr/undecided.d.ts.map +1 -0
  385. package/dist/expr/undecided.js +58 -0
  386. package/dist/expr/undecided.js.map +1 -0
  387. package/dist/expr/values/code-points.d.ts +13 -0
  388. package/dist/expr/values/code-points.d.ts.map +1 -0
  389. package/dist/expr/values/code-points.js +25 -0
  390. package/dist/expr/values/code-points.js.map +1 -0
  391. package/dist/expr/values/inline.d.ts +77 -0
  392. package/dist/expr/values/inline.d.ts.map +1 -0
  393. package/dist/expr/values/inline.js +404 -0
  394. package/dist/expr/values/inline.js.map +1 -0
  395. package/dist/expr/values/interval.d.ts +19 -0
  396. package/dist/expr/values/interval.d.ts.map +1 -0
  397. package/dist/expr/values/interval.js +1180 -0
  398. package/dist/expr/values/interval.js.map +1 -0
  399. package/dist/index.d.ts +163 -0
  400. package/dist/index.d.ts.map +1 -0
  401. package/dist/index.js +128 -0
  402. package/dist/index.js.map +1 -0
  403. package/dist/ingest/document.d.ts +58 -0
  404. package/dist/ingest/document.d.ts.map +1 -0
  405. package/dist/ingest/document.js +83 -0
  406. package/dist/ingest/document.js.map +1 -0
  407. package/dist/ingest/yaml-document.d.ts +15 -0
  408. package/dist/ingest/yaml-document.d.ts.map +1 -0
  409. package/dist/ingest/yaml-document.js +42 -0
  410. package/dist/ingest/yaml-document.js.map +1 -0
  411. package/dist/ingest/yaml.d.ts +51 -0
  412. package/dist/ingest/yaml.d.ts.map +1 -0
  413. package/dist/ingest/yaml.js +340 -0
  414. package/dist/ingest/yaml.js.map +1 -0
  415. package/dist/layout/compile.d.ts +6 -0
  416. package/dist/layout/compile.d.ts.map +1 -0
  417. package/dist/layout/compile.js +224 -0
  418. package/dist/layout/compile.js.map +1 -0
  419. package/dist/layout/context.d.ts +12 -0
  420. package/dist/layout/context.d.ts.map +1 -0
  421. package/dist/layout/context.js +26 -0
  422. package/dist/layout/context.js.map +1 -0
  423. package/dist/layout/grammar.d.ts +34 -0
  424. package/dist/layout/grammar.d.ts.map +1 -0
  425. package/dist/layout/grammar.js +171 -0
  426. package/dist/layout/grammar.js.map +1 -0
  427. package/dist/layout/read.d.ts +54 -0
  428. package/dist/layout/read.d.ts.map +1 -0
  429. package/dist/layout/read.js +101 -0
  430. package/dist/layout/read.js.map +1 -0
  431. package/dist/layout/shape.d.ts +34 -0
  432. package/dist/layout/shape.d.ts.map +1 -0
  433. package/dist/layout/shape.js +149 -0
  434. package/dist/layout/shape.js.map +1 -0
  435. package/dist/messages/compile.d.ts +47 -0
  436. package/dist/messages/compile.d.ts.map +1 -0
  437. package/dist/messages/compile.js +202 -0
  438. package/dist/messages/compile.js.map +1 -0
  439. package/dist/messages/locale.d.ts +18 -0
  440. package/dist/messages/locale.d.ts.map +1 -0
  441. package/dist/messages/locale.js +33 -0
  442. package/dist/messages/locale.js.map +1 -0
  443. package/dist/messages/slots.d.ts +54 -0
  444. package/dist/messages/slots.d.ts.map +1 -0
  445. package/dist/messages/slots.js +137 -0
  446. package/dist/messages/slots.js.map +1 -0
  447. package/dist/overlay/compile-overlay.d.ts +29 -0
  448. package/dist/overlay/compile-overlay.d.ts.map +1 -0
  449. package/dist/overlay/compile-overlay.js +120 -0
  450. package/dist/overlay/compile-overlay.js.map +1 -0
  451. package/dist/overlay/compose.d.ts +26 -0
  452. package/dist/overlay/compose.d.ts.map +1 -0
  453. package/dist/overlay/compose.js +674 -0
  454. package/dist/overlay/compose.js.map +1 -0
  455. package/dist/overlay/types.d.ts +41 -0
  456. package/dist/overlay/types.d.ts.map +1 -0
  457. package/dist/overlay/types.js +2 -0
  458. package/dist/overlay/types.js.map +1 -0
  459. package/dist/publish/classify.d.ts +50 -0
  460. package/dist/publish/classify.d.ts.map +1 -0
  461. package/dist/publish/classify.js +85 -0
  462. package/dist/publish/classify.js.map +1 -0
  463. package/dist/publish/environment.d.ts +15 -0
  464. package/dist/publish/environment.d.ts.map +1 -0
  465. package/dist/publish/environment.js +2 -0
  466. package/dist/publish/environment.js.map +1 -0
  467. package/dist/publish/migrations.d.ts +108 -0
  468. package/dist/publish/migrations.d.ts.map +1 -0
  469. package/dist/publish/migrations.js +166 -0
  470. package/dist/publish/migrations.js.map +1 -0
  471. package/dist/publish/observation.d.ts +29 -0
  472. package/dist/publish/observation.d.ts.map +1 -0
  473. package/dist/publish/observation.js +43 -0
  474. package/dist/publish/observation.js.map +1 -0
  475. package/dist/publish/readiness.d.ts +197 -0
  476. package/dist/publish/readiness.d.ts.map +1 -0
  477. package/dist/publish/readiness.js +239 -0
  478. package/dist/publish/readiness.js.map +1 -0
  479. package/dist/publish/vectors.d.ts +50 -0
  480. package/dist/publish/vectors.d.ts.map +1 -0
  481. package/dist/publish/vectors.js +306 -0
  482. package/dist/publish/vectors.js.map +1 -0
  483. package/dist/publish/verify.d.ts +146 -0
  484. package/dist/publish/verify.d.ts.map +1 -0
  485. package/dist/publish/verify.js +548 -0
  486. package/dist/publish/verify.js.map +1 -0
  487. package/dist/scenarios/branch.d.ts +36 -0
  488. package/dist/scenarios/branch.d.ts.map +1 -0
  489. package/dist/scenarios/branch.js +30 -0
  490. package/dist/scenarios/branch.js.map +1 -0
  491. package/dist/scenarios/capture.d.ts +89 -0
  492. package/dist/scenarios/capture.d.ts.map +1 -0
  493. package/dist/scenarios/capture.js +443 -0
  494. package/dist/scenarios/capture.js.map +1 -0
  495. package/dist/scenarios/classifier.d.ts +20 -0
  496. package/dist/scenarios/classifier.d.ts.map +1 -0
  497. package/dist/scenarios/classifier.js +88 -0
  498. package/dist/scenarios/classifier.js.map +1 -0
  499. package/dist/scenarios/credit.d.ts +33 -0
  500. package/dist/scenarios/credit.d.ts.map +1 -0
  501. package/dist/scenarios/credit.js +330 -0
  502. package/dist/scenarios/credit.js.map +1 -0
  503. package/dist/scenarios/csv.d.ts +34 -0
  504. package/dist/scenarios/csv.d.ts.map +1 -0
  505. package/dist/scenarios/csv.js +1047 -0
  506. package/dist/scenarios/csv.js.map +1 -0
  507. package/dist/scenarios/data-identity.d.ts +39 -0
  508. package/dist/scenarios/data-identity.d.ts.map +1 -0
  509. package/dist/scenarios/data-identity.js +28 -0
  510. package/dist/scenarios/data-identity.js.map +1 -0
  511. package/dist/scenarios/document.d.ts +148 -0
  512. package/dist/scenarios/document.d.ts.map +1 -0
  513. package/dist/scenarios/document.js +513 -0
  514. package/dist/scenarios/document.js.map +1 -0
  515. package/dist/scenarios/environment.d.ts +64 -0
  516. package/dist/scenarios/environment.d.ts.map +1 -0
  517. package/dist/scenarios/environment.js +106 -0
  518. package/dist/scenarios/environment.js.map +1 -0
  519. package/dist/scenarios/evidence.d.ts +128 -0
  520. package/dist/scenarios/evidence.d.ts.map +1 -0
  521. package/dist/scenarios/evidence.js +179 -0
  522. package/dist/scenarios/evidence.js.map +1 -0
  523. package/dist/scenarios/expectations.d.ts +63 -0
  524. package/dist/scenarios/expectations.d.ts.map +1 -0
  525. package/dist/scenarios/expectations.js +490 -0
  526. package/dist/scenarios/expectations.js.map +1 -0
  527. package/dist/scenarios/references.d.ts +15 -0
  528. package/dist/scenarios/references.d.ts.map +1 -0
  529. package/dist/scenarios/references.js +239 -0
  530. package/dist/scenarios/references.js.map +1 -0
  531. package/dist/scenarios/report.d.ts +216 -0
  532. package/dist/scenarios/report.d.ts.map +1 -0
  533. package/dist/scenarios/report.js +54 -0
  534. package/dist/scenarios/report.js.map +1 -0
  535. package/dist/scenarios/runner.d.ts +55 -0
  536. package/dist/scenarios/runner.d.ts.map +1 -0
  537. package/dist/scenarios/runner.js +205 -0
  538. package/dist/scenarios/runner.js.map +1 -0
  539. package/dist/scenarios/vocabulary.d.ts +19 -0
  540. package/dist/scenarios/vocabulary.d.ts.map +1 -0
  541. package/dist/scenarios/vocabulary.js +56 -0
  542. package/dist/scenarios/vocabulary.js.map +1 -0
  543. package/dist/schema/catalogue.d.ts +54 -0
  544. package/dist/schema/catalogue.d.ts.map +1 -0
  545. package/dist/schema/catalogue.js +221 -0
  546. package/dist/schema/catalogue.js.map +1 -0
  547. package/dist/schema/check.d.ts +22 -0
  548. package/dist/schema/check.d.ts.map +1 -0
  549. package/dist/schema/check.js +30 -0
  550. package/dist/schema/check.js.map +1 -0
  551. package/dist/schema/closed.d.ts +19 -0
  552. package/dist/schema/closed.d.ts.map +1 -0
  553. package/dist/schema/closed.js +33 -0
  554. package/dist/schema/closed.js.map +1 -0
  555. package/dist/schema/collapse.d.ts +27 -0
  556. package/dist/schema/collapse.d.ts.map +1 -0
  557. package/dist/schema/collapse.js +143 -0
  558. package/dist/schema/collapse.js.map +1 -0
  559. package/dist/schema/controls.d.ts +46 -0
  560. package/dist/schema/controls.d.ts.map +1 -0
  561. package/dist/schema/controls.js +75 -0
  562. package/dist/schema/controls.js.map +1 -0
  563. package/dist/schema/dataset-declaration.d.ts +11 -0
  564. package/dist/schema/dataset-declaration.d.ts.map +1 -0
  565. package/dist/schema/dataset-declaration.js +11 -0
  566. package/dist/schema/dataset-declaration.js.map +1 -0
  567. package/dist/schema/declaration-warnings.d.ts +14 -0
  568. package/dist/schema/declaration-warnings.d.ts.map +1 -0
  569. package/dist/schema/declaration-warnings.js +77 -0
  570. package/dist/schema/declaration-warnings.js.map +1 -0
  571. package/dist/schema/declarations.d.ts +41 -0
  572. package/dist/schema/declarations.d.ts.map +1 -0
  573. package/dist/schema/declarations.js +1299 -0
  574. package/dist/schema/declarations.js.map +1 -0
  575. package/dist/schema/diagnostic.d.ts +118 -0
  576. package/dist/schema/diagnostic.d.ts.map +1 -0
  577. package/dist/schema/diagnostic.js +39 -0
  578. package/dist/schema/diagnostic.js.map +1 -0
  579. package/dist/schema/document.d.ts +93 -0
  580. package/dist/schema/document.d.ts.map +1 -0
  581. package/dist/schema/document.js +507 -0
  582. package/dist/schema/document.js.map +1 -0
  583. package/dist/schema/fields.d.ts +11 -0
  584. package/dist/schema/fields.d.ts.map +1 -0
  585. package/dist/schema/fields.js +265 -0
  586. package/dist/schema/fields.js.map +1 -0
  587. package/dist/schema/gates.d.ts +4 -0
  588. package/dist/schema/gates.d.ts.map +1 -0
  589. package/dist/schema/gates.js +68 -0
  590. package/dist/schema/gates.js.map +1 -0
  591. package/dist/schema/located.d.ts +27 -0
  592. package/dist/schema/located.d.ts.map +1 -0
  593. package/dist/schema/located.js +56 -0
  594. package/dist/schema/located.js.map +1 -0
  595. package/dist/schema/measurement.d.ts +9 -0
  596. package/dist/schema/measurement.d.ts.map +1 -0
  597. package/dist/schema/measurement.js +38 -0
  598. package/dist/schema/measurement.js.map +1 -0
  599. package/dist/schema/member-wording.d.ts +35 -0
  600. package/dist/schema/member-wording.d.ts.map +1 -0
  601. package/dist/schema/member-wording.js +286 -0
  602. package/dist/schema/member-wording.js.map +1 -0
  603. package/dist/schema/metaschema.d.ts +20 -0
  604. package/dist/schema/metaschema.d.ts.map +1 -0
  605. package/dist/schema/metaschema.js +476 -0
  606. package/dist/schema/metaschema.js.map +1 -0
  607. package/dist/schema/pointer.d.ts +31 -0
  608. package/dist/schema/pointer.d.ts.map +1 -0
  609. package/dist/schema/pointer.js +73 -0
  610. package/dist/schema/pointer.js.map +1 -0
  611. package/dist/schema/primary.d.ts +29 -0
  612. package/dist/schema/primary.d.ts.map +1 -0
  613. package/dist/schema/primary.js +48 -0
  614. package/dist/schema/primary.js.map +1 -0
  615. package/dist/schema/publish-vector.d.ts +17 -0
  616. package/dist/schema/publish-vector.d.ts.map +1 -0
  617. package/dist/schema/publish-vector.js +34 -0
  618. package/dist/schema/publish-vector.js.map +1 -0
  619. package/dist/schema/repair.d.ts +34 -0
  620. package/dist/schema/repair.d.ts.map +1 -0
  621. package/dist/schema/repair.js +163 -0
  622. package/dist/schema/repair.js.map +1 -0
  623. package/dist/schema/schema-v1.generated.d.ts +14 -0
  624. package/dist/schema/schema-v1.generated.d.ts.map +1 -0
  625. package/dist/schema/schema-v1.generated.js +7089 -0
  626. package/dist/schema/schema-v1.generated.js.map +1 -0
  627. package/dist/schema/screens.d.ts +4 -0
  628. package/dist/schema/screens.d.ts.map +1 -0
  629. package/dist/schema/screens.js +28 -0
  630. package/dist/schema/screens.js.map +1 -0
  631. package/dist/schema/test-values.d.ts +12 -0
  632. package/dist/schema/test-values.d.ts.map +1 -0
  633. package/dist/schema/test-values.js +97 -0
  634. package/dist/schema/test-values.js.map +1 -0
  635. package/dist/schema/unions.d.ts +46 -0
  636. package/dist/schema/unions.d.ts.map +1 -0
  637. package/dist/schema/unions.js +131 -0
  638. package/dist/schema/unions.js.map +1 -0
  639. package/dist/schema/validate-yaml.d.ts +14 -0
  640. package/dist/schema/validate-yaml.d.ts.map +1 -0
  641. package/dist/schema/validate-yaml.js +17 -0
  642. package/dist/schema/validate-yaml.js.map +1 -0
  643. package/dist/schema/validate.d.ts +46 -0
  644. package/dist/schema/validate.d.ts.map +1 -0
  645. package/dist/schema/validate.js +186 -0
  646. package/dist/schema/validate.js.map +1 -0
  647. package/dist/testing.d.ts +21 -0
  648. package/dist/testing.d.ts.map +1 -0
  649. package/dist/testing.js +28 -0
  650. package/dist/testing.js.map +1 -0
  651. package/dist/vocabulary.d.ts +6 -0
  652. package/dist/vocabulary.d.ts.map +1 -0
  653. package/dist/vocabulary.js +26 -0
  654. package/dist/vocabulary.js.map +1 -0
  655. package/package.json +66 -3
@@ -0,0 +1,205 @@
1
+ import { artifactBehaviour, AxiomError, compareCodePoints, DEFAULT_EVIDENCE_TIER, deriveFormState, evaluateForm, explain, isArtifactBehaviourOf, isTier, sealReport, } from '@azx-pbc/axiom-runtime';
2
+ import { MemoryLookupStore } from '@azx-pbc/axiom-runtime/lookup';
3
+ import { classifyScenario } from './classifier.js';
4
+ import { readDataIdentity } from './data-identity.js';
5
+ import { normalizeEnvironment, resolveRunEnvironment } from './environment.js';
6
+ import { projectScenarioSubmission } from './evidence.js';
7
+ import { validateReferences } from './references.js';
8
+ /**
9
+ * Runs every scenario in a suite.
10
+ *
11
+ * A suite that names a rule, field, gate item or table the artifact does not declare — or whose
12
+ * values the artifact's declarations refuse — is refused before anything runs: an `invalid`
13
+ * report carries every reason and no results, because a run against a reference that does not
14
+ * exist would compare a claim with nothing. A table set the artifact pins and no installation
15
+ * can represent is refused the same way: a report that cannot name the data it judged has no
16
+ * identity to bind its evidence to.
17
+ */
18
+ export function runScenarioSuite(compiled, suite, options = {}) {
19
+ const documents = options.datasets ?? [];
20
+ if (options.behaviour !== undefined && !isArtifactBehaviourOf(compiled, options.behaviour)) {
21
+ throw new AxiomError('ENGINE_ERROR', 'the supplied behaviour identity was not derived for this artifact', compiled.schemaId);
22
+ }
23
+ // One environment authority: the run's declaration and the suite's defaults must agree on every
24
+ // member they both name, and an unknown tier is refused rather than rewritten. A scenario's
25
+ // own `given` may still override a member, and each result commits the environment it used.
26
+ const resolvedRun = resolveRunEnvironment(options.environment, [suite]);
27
+ if (!resolvedRun.ok) {
28
+ return {
29
+ status: 'invalid',
30
+ diagnostics: [
31
+ {
32
+ code: 'SCENARIOS_INVALID',
33
+ // The resolver reports a suite at its publish path; this door runs one suite, so the
34
+ // author-facing location is the document they hold.
35
+ path: resolvedRun.path?.replace(/^\$\.suites\[0\]/u, '$') ?? '$',
36
+ detail: resolvedRun.detail,
37
+ },
38
+ ],
39
+ };
40
+ }
41
+ const environment = resolvedRun.environment;
42
+ const baseline = environment;
43
+ const storeFor = storeCache(documents);
44
+ const prepared = suite.scenarios.map((scenario, index) => prepare(scenario, index, storeFor, environment));
45
+ const diagnostics = [
46
+ ...validateReferences(compiled, suite),
47
+ ...prepared.flatMap((entry) => entry.diagnostics),
48
+ ];
49
+ if (diagnostics.length > 0)
50
+ return { status: 'invalid', diagnostics };
51
+ // A catalogue the artifact pins and no installation can represent leaves the run unable to
52
+ // state what it judged, so it is refused before a record is evaluated: a throw here would
53
+ // escape a call whose contract is a report, and results would be judged against data the
54
+ // report cannot name.
55
+ const pins = datasetPins(compiled, documents);
56
+ if (!pins.ok)
57
+ return { status: 'invalid', diagnostics: [pins.diagnostic] };
58
+ const scenarios = prepared.map((entry) => runOne(compiled, entry));
59
+ return {
60
+ status: scenarios.every((scenario) => scenario.status === 'passed') ? 'passed' : 'failed',
61
+ behaviorHash: (options.behaviour ?? artifactBehaviour(compiled)).behaviorHash,
62
+ datasetHashes: pins.pins,
63
+ environment: normalizeEnvironment(baseline),
64
+ scenarios,
65
+ };
66
+ }
67
+ /**
68
+ * The artifact's data identity for one run, or the reason the supplied documents cannot state it.
69
+ *
70
+ * An uninstallable catalogue is refused rather than thrown: the run has no data identity to bind
71
+ * its evidence to. A pinned table no document answers is not refused here — a suite may assert the
72
+ * stale data its record was judged under (`references.ts`) — while a publisher states it as a gap,
73
+ * because it cannot bind evidence to data it does not hold. The read itself is `data-identity.ts`,
74
+ * so both callers state the same refusal in the same words.
75
+ */
76
+ function datasetPins(compiled, documents) {
77
+ const read = readDataIdentity(compiled, documents);
78
+ if (!read.ok) {
79
+ return {
80
+ ok: false,
81
+ diagnostic: { code: 'SCENARIOS_INVALID', path: '$', detail: read.detail },
82
+ };
83
+ }
84
+ return { ok: true, pins: read.identity.pins };
85
+ }
86
+ /**
87
+ * The lookup store for each distinct table exposure, installed once.
88
+ *
89
+ * Installing a catalogue prepares every row of every table, so two scenarios over one table
90
+ * share one store. The cache lives for the call: no store outlives the run it was built for. A
91
+ * catalogue that cannot be installed is cached as its refusal, so the reason is stated once and
92
+ * reported per scenario.
93
+ */
94
+ function storeCache(documents) {
95
+ const stores = new Map();
96
+ return (exposure) => {
97
+ const exposed = new Set(exposure);
98
+ if (exposed.size === 0)
99
+ return undefined;
100
+ const key = [...exposed].sort(compareCodePoints).join('\u0000');
101
+ const cached = stores.get(key);
102
+ if (cached !== undefined)
103
+ return cached;
104
+ const tables = documents.filter((document) => exposed.has(document.tableId));
105
+ let store;
106
+ try {
107
+ store = new MemoryLookupStore(tables);
108
+ }
109
+ catch (cause) {
110
+ if (!(cause instanceof AxiomError))
111
+ throw cause;
112
+ store = cause;
113
+ }
114
+ stores.set(key, store);
115
+ return store;
116
+ };
117
+ }
118
+ /** One scenario bound to its lookup store, or the reasons it could not be. */
119
+ function prepare(scenario, index, storeFor, environment) {
120
+ // The scenario's own declarations win member by member: a suite that names its record date
121
+ // judges under that date, and a baseline only fills a member the document leaves absent.
122
+ // This is the evidence door, so an omitted tier is the evidence default rather than the
123
+ // local evaluation default.
124
+ const inherited = { ...environment, ...scenario.env };
125
+ const tier = inherited.tier ?? DEFAULT_EVIDENCE_TIER;
126
+ if (!isTier(tier)) {
127
+ // `resolveRunEnvironment` validates the run's and the suite's declarations, but a scenario's
128
+ // own `given` is a member the resolver never sees. A JavaScript caller can hand this door a
129
+ // tier outside the pair, and the contract here is a report rather than a throw: the run is
130
+ // refused with the reason, and the committed environment is the baseline it would have used.
131
+ return {
132
+ scenario,
133
+ env: { ...inherited, tier: DEFAULT_EVIDENCE_TIER },
134
+ environment: normalizeEnvironment(environment),
135
+ diagnostics: [
136
+ {
137
+ code: 'SCENARIOS_INVALID',
138
+ path: `$.scenarios[${String(index)}].given.tier`,
139
+ detail: `\`${String(tier)}\` is not a tier: a run judges at \`server\` or \`client\``,
140
+ },
141
+ ],
142
+ };
143
+ }
144
+ const resolved = { ...inherited, tier };
145
+ const environmentOf = normalizeEnvironment(resolved);
146
+ const store = storeFor(scenario.datasets);
147
+ if (store === undefined) {
148
+ return { scenario, env: resolved, environment: environmentOf, diagnostics: [] };
149
+ }
150
+ if (store instanceof AxiomError) {
151
+ return {
152
+ scenario,
153
+ env: resolved,
154
+ environment: environmentOf,
155
+ diagnostics: [
156
+ {
157
+ code: 'SCENARIOS_INVALID',
158
+ path: `$.scenarios[${String(index)}].given.datasets`,
159
+ detail: `the tables this scenario exposes cannot be installed: ${store.message}`,
160
+ },
161
+ ],
162
+ };
163
+ }
164
+ return {
165
+ scenario,
166
+ env: { ...resolved, lookup: store },
167
+ environment: environmentOf,
168
+ diagnostics: [],
169
+ };
170
+ }
171
+ /** One scenario judged against one evaluation, with a separate explanation pass on failure. */
172
+ function runOne(compiled, prepared) {
173
+ const { scenario, env } = prepared;
174
+ const snapshot = evaluateForm(compiled, scenario.input, env);
175
+ const state = deriveFormState(compiled, snapshot);
176
+ const evidence = { compiled, input: scenario.input, snapshot, state };
177
+ // The projection runs once per scenario because the submission is part of what the record
178
+ // decided. A refusal it reports is only examined by `exportSubmission`/`exportRefused`
179
+ // assertions: a suite that says nothing about the submission claims nothing about it.
180
+ const projection = projectScenarioSubmission(evidence);
181
+ const classification = classifyScenario(evidence, scenario.assertions, projection);
182
+ const status = classification.assertions.every((assertion) => assertion.passed)
183
+ ? 'passed'
184
+ : 'failed';
185
+ const stale = staleLookupsOf(snapshot.report.lookups);
186
+ return {
187
+ scenarioId: scenario.scenarioId,
188
+ status,
189
+ environment: prepared.environment,
190
+ reportHash: sealReport(snapshot.report).reportHash,
191
+ assertions: classification.assertions,
192
+ unasserted: classification.unasserted,
193
+ ...(stale.length === 0 ? {} : { stale }),
194
+ ...(status === 'failed' ? { explanation: explain(compiled, scenario.input, env) } : {}),
195
+ };
196
+ }
197
+ /** The report's lookups that state a table which could not answer, in canonical order. */
198
+ function staleLookupsOf(lookups) {
199
+ return lookups.filter(isStaleLookup);
200
+ }
201
+ /** Whether a report's lookup entry states a table that could not answer. */
202
+ function isStaleLookup(entry) {
203
+ return 'reason' in entry;
204
+ }
205
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/scenarios/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,OAAO,EACP,qBAAqB,EACrB,MAAM,EACN,UAAU,GACX,MAAM,wBAAwB,CAAC;AAQhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAyDrD;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAwB,EACxB,KAA4B,EAC5B,OAAO,GAAyB,EAAE;IAElC,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;IACzC,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3F,MAAM,IAAI,UAAU,CAClB,cAAc,EACd,mEAAmE,EACnE,QAAQ,CAAC,QAAQ,CAClB,CAAC;IACJ,CAAC;IACD,gGAAgG;IAChG,4FAA4F;IAC5F,4FAA4F;IAC5F,MAAM,WAAW,G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AC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxF,CAAC;AACJ,CAAC;AAED,0FAA0F;AAC1F,SAAS,cAAc,CAAC,OAA+B;IACrD,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;AACvC,CAAC;AAED,4EAA4E;AAC5E,SAAS,aAAa,CAAC,KAAqC;IAC1D,OAAO,QAAQ,IAAI,KAAK,CAAC;AAC3B,CAAC","sourcesContent":["import {\n artifactBehaviour,\n AxiomError,\n compareCodePoints,\n DEFAULT_EVIDENCE_TIER,\n deriveFormState,\n evaluateForm,\n explain,\n isArtifactBehaviourOf,\n isTier,\n sealReport,\n} from '@azx-pbc/axiom-runtime';\nimport type {\n ArtifactBehaviour,\n CompiledSchema,\n EvaluationEnv,\n ReportFacts,\n StaleLookupProvenance,\n} from '@azx-pbc/axiom-runtime';\nimport { MemoryLookupStore } from '@azx-pbc/axiom-runtime/lookup';\nimport type { ResolvedDatasetPin } from '@azx-pbc/axiom-runtime/lookup';\nimport type { LookupPort, LookupTableDocument } from '@azx-pbc/axiom-runtime';\nimport { classifyScenario } from './classifier.js';\nimport { readDataIdentity } from './data-identity.js';\nimport type { DeclaredEnvironment, Scenario, ScenarioSuiteDocument } from './document.js';\nimport { normalizeEnvironment, resolveRunEnvironment } from './environment.js';\nimport type { CommittedEnvironment } from './environment.js';\nimport { projectScenarioSubmission } from './evidence.js';\nimport { validateReferences } from './references.js';\nimport type { ScenarioDiagnostic, ScenarioResult, ScenarioSuiteReport } from './report.js';\n\n/**\n * Running a scenario suite over a compiled artifact.\n *\n * A scenario's assertions read one `evaluateForm` answer: the report, the access answer and the\n * writer overlay; the derived form state and the submission projection read that same answer, so\n * no two answers can disagree. A failed scenario's `explain()` trace is a separate, explicit pass.\n * The report binds each assertion to the artifact's behaviour hash and the table versions the run\n * resolved, and it carries no second copy of the report it judged.\n *\n * Nothing here touches a clock, a locale database or a Node built-in, so a browser preview and a\n * CI build run the same suite to the same bytes.\n */\n\n/** What a run needs that a suite cannot carry: the table documents its exposures name. */\nexport interface ScenarioSuiteOptions {\n /**\n * The table documents a run may install, usually every document the host holds for the\n * artifact. A document for a table the artifact does not pin cannot change the run's data\n * identity, so it is not installed; a catalogue for a pinned table that no installation can\n * represent refuses the run rather than throwing.\n */\n readonly datasets?: readonly LookupTableDocument[];\n /**\n * The environment a scenario starts from where its own document states nothing.\n *\n * The suite's own `given`/defaults win member by member: a scenario that names its record date\n * judges under that date. The baseline exists so a publisher that declares the environment it\n * is publishing against executes the suite under it rather than under an accidental absence.\n */\n readonly environment?: DeclaredEnvironment;\n /**\n * The artifact's behaviour identity, when the caller already derived it.\n *\n * A publisher that verifies several suites over one artifact derives it once and states it\n * here; a caller that runs a suite on its own lets this module derive it, which re-hashes every\n * rule and the artifact around them. It must be the exact immutable value derived for `compiled`;\n * an identity from another artifact, or an edited copy, throws before anything runs.\n */\n readonly behaviour?: ArtifactBehaviour;\n}\n\n/** The artifact's data identity for one run, or the reason it cannot be stated. */\ntype DatasetPins =\n | { readonly ok: true; readonly pins: readonly ResolvedDatasetPin[] }\n | { readonly ok: false; readonly diagnostic: ScenarioDiagnostic };\n\n/** One scenario bound to the environment and lookup store its claims run under. */\ninterface PreparedScenario {\n readonly scenario: Scenario;\n readonly env: EvaluationEnv;\n /** The environment the evaluation actually used, after the scenario's own override. */\n readonly environment: CommittedEnvironment;\n}\n\n/**\n * Runs every scenario in a suite.\n *\n * A suite that names a rule, field, gate item or table the artifact does not declare — or whose\n * values the artifact's declarations refuse — is refused before anything runs: an `invalid`\n * report carries every reason and no results, because a run against a reference that does not\n * exist would compare a claim with nothing. A table set the artifact pins and no installation\n * can represent is refused the same way: a report that cannot name the data it judged has no\n * identity to bind its evidence to.\n */\nexport function runScenarioSuite(\n compiled: CompiledSchema,\n suite: ScenarioSuiteDocument,\n options: ScenarioSuiteOptions = {},\n): ScenarioSuiteReport {\n const documents = options.datasets ?? [];\n if (options.behaviour !== undefined && !isArtifactBehaviourOf(compiled, options.behaviour)) {\n throw new AxiomError(\n 'ENGINE_ERROR',\n 'the supplied behaviour identity was not derived for this artifact',\n compiled.schemaId,\n );\n }\n // One environment authority: the run's declaration and the suite's defaults must agree on every\n // member they both name, and an unknown tier is refused rather than rewritten. A scenario's\n // own `given` may still override a member, and each result commits the environment it used.\n const resolvedRun = resolveRunEnvironment(options.environment, [suite]);\n if (!resolvedRun.ok) {\n return {\n status: 'invalid',\n diagnostics: [\n {\n code: 'SCENARIOS_INVALID',\n // The resolver reports a suite at its publish path; this door runs one suite, so the\n // author-facing location is the document they hold.\n path: resolvedRun.path?.replace(/^\\$\\.suites\\[0\\]/u, '$') ?? '$',\n detail: resolvedRun.detail,\n },\n ],\n };\n }\n const environment: DeclaredEnvironment = resolvedRun.environment;\n const baseline: DeclaredEnvironment = environment;\n const storeFor = storeCache(documents);\n const prepared = suite.scenarios.map((scenario, index) =>\n prepare(scenario, index, storeFor, environment),\n );\n const diagnostics = [\n ...validateReferences(compiled, suite),\n ...prepared.flatMap((entry) => entry.diagnostics),\n ];\n if (diagnostics.length > 0) return { status: 'invalid', diagnostics };\n // A catalogue the artifact pins and no installation can represent leaves the run unable to\n // state what it judged, so it is refused before a record is evaluated: a throw here would\n // escape a call whose contract is a report, and results would be judged against data the\n // report cannot name.\n const pins = datasetPins(compiled, documents);\n if (!pins.ok) return { status: 'invalid', diagnostics: [pins.diagnostic] };\n const scenarios = prepared.map((entry) => runOne(compiled, entry));\n return {\n status: scenarios.every((scenario) => scenario.status === 'passed') ? 'passed' : 'failed',\n behaviorHash: (options.behaviour ?? artifactBehaviour(compiled)).behaviorHash,\n datasetHashes: pins.pins,\n environment: normalizeEnvironment(baseline),\n scenarios,\n };\n}\n\n/**\n * The artifact's data identity for one run, or the reason the supplied documents cannot state it.\n *\n * An uninstallable catalogue is refused rather than thrown: the run has no data identity to bind\n * its evidence to. A pinned table no document answers is not refused here — a suite may assert the\n * stale data its record was judged under (`references.ts`) — while a publisher states it as a gap,\n * because it cannot bind evidence to data it does not hold. The read itself is `data-identity.ts`,\n * so both callers state the same refusal in the same words.\n */\nfunction datasetPins(\n compiled: CompiledSchema,\n documents: readonly LookupTableDocument[],\n): DatasetPins {\n const read = readDataIdentity(compiled, documents);\n if (!read.ok) {\n return {\n ok: false,\n diagnostic: { code: 'SCENARIOS_INVALID', path: '$', detail: read.detail },\n };\n }\n return { ok: true, pins: read.identity.pins };\n}\n\n/**\n * The lookup store for each distinct table exposure, installed once.\n *\n * Installing a catalogue prepares every row of every table, so two scenarios over one table\n * share one store. The cache lives for the call: no store outlives the run it was built for. A\n * catalogue that cannot be installed is cached as its refusal, so the reason is stated once and\n * reported per scenario.\n */\nfunction storeCache(\n documents: readonly LookupTableDocument[],\n): (exposure: readonly string[]) => LookupPort | AxiomError | undefined {\n const stores = new Map<string, LookupPort | AxiomError>();\n return (exposure) => {\n const exposed = new Set(exposure);\n if (exposed.size === 0) return undefined;\n const key = [...exposed].sort(compareCodePoints).join('\\u0000');\n const cached = stores.get(key);\n if (cached !== undefined) return cached;\n const tables = documents.filter((document) => exposed.has(document.tableId));\n let store: LookupPort | AxiomError;\n try {\n store = new MemoryLookupStore(tables);\n } catch (cause) {\n if (!(cause instanceof AxiomError)) throw cause;\n store = cause;\n }\n stores.set(key, store);\n return store;\n };\n}\n\n/** One scenario bound to its lookup store, or the reasons it could not be. */\nfunction prepare(\n scenario: Scenario,\n index: number,\n storeFor: (exposure: readonly string[]) => LookupPort | AxiomError | undefined,\n environment: DeclaredEnvironment,\n): PreparedScenario & { readonly diagnostics: readonly ScenarioDiagnostic[] } {\n // The scenario's own declarations win member by member: a suite that names its record date\n // judges under that date, and a baseline only fills a member the document leaves absent.\n // This is the evidence door, so an omitted tier is the evidence default rather than the\n // local evaluation default.\n const inherited: EvaluationEnv = { ...environment, ...scenario.env };\n const tier = inherited.tier ?? DEFAULT_EVIDENCE_TIER;\n if (!isTier(tier)) {\n // `resolveRunEnvironment` validates the run's and the suite's declarations, but a scenario's\n // own `given` is a member the resolver never sees. A JavaScript caller can hand this door a\n // tier outside the pair, and the contract here is a report rather than a throw: the run is\n // refused with the reason, and the committed environment is the baseline it would have used.\n return {\n scenario,\n env: { ...inherited, tier: DEFAULT_EVIDENCE_TIER },\n environment: normalizeEnvironment(environment),\n diagnostics: [\n {\n code: 'SCENARIOS_INVALID',\n path: `$.scenarios[${String(index)}].given.tier`,\n detail: `\\`${String(tier)}\\` is not a tier: a run judges at \\`server\\` or \\`client\\``,\n },\n ],\n };\n }\n const resolved: EvaluationEnv = { ...inherited, tier };\n const environmentOf = normalizeEnvironment(resolved);\n const store = storeFor(scenario.datasets);\n if (store === undefined) {\n return { scenario, env: resolved, environment: environmentOf, diagnostics: [] };\n }\n if (store instanceof AxiomError) {\n return {\n scenario,\n env: resolved,\n environment: environmentOf,\n diagnostics: [\n {\n code: 'SCENARIOS_INVALID',\n path: `$.scenarios[${String(index)}].given.datasets`,\n detail: `the tables this scenario exposes cannot be installed: ${store.message}`,\n },\n ],\n };\n }\n return {\n scenario,\n env: { ...resolved, lookup: store },\n environment: environmentOf,\n diagnostics: [],\n };\n}\n\n/** One scenario judged against one evaluation, with a separate explanation pass on failure. */\nfunction runOne(compiled: CompiledSchema, prepared: PreparedScenario): ScenarioResult {\n const { scenario, env } = prepared;\n const snapshot = evaluateForm(compiled, scenario.input, env);\n const state = deriveFormState(compiled, snapshot);\n const evidence = { compiled, input: scenario.input, snapshot, state };\n // The projection runs once per scenario because the submission is part of what the record\n // decided. A refusal it reports is only examined by `exportSubmission`/`exportRefused`\n // assertions: a suite that says nothing about the submission claims nothing about it.\n const projection = projectScenarioSubmission(evidence);\n const classification = classifyScenario(evidence, scenario.assertions, projection);\n const status = classification.assertions.every((assertion) => assertion.passed)\n ? 'passed'\n : 'failed';\n const stale = staleLookupsOf(snapshot.report.lookups);\n return {\n scenarioId: scenario.scenarioId,\n status,\n environment: prepared.environment,\n reportHash: sealReport(snapshot.report).reportHash,\n assertions: classification.assertions,\n unasserted: classification.unasserted,\n ...(stale.length === 0 ? {} : { stale }),\n ...(status === 'failed' ? { explanation: explain(compiled, scenario.input, env) } : {}),\n };\n}\n\n/** The report's lookups that state a table which could not answer, in canonical order. */\nfunction staleLookupsOf(lookups: ReportFacts['lookups']): readonly StaleLookupProvenance[] {\n return lookups.filter(isStaleLookup);\n}\n\n/** Whether a report's lookup entry states a table that could not answer. */\nfunction isStaleLookup(entry: ReportFacts['lookups'][number]): entry is StaleLookupProvenance {\n return 'reason' in entry;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import type { GateOutcome, RequiredStatus, ScreenOutcome } from '@azx-pbc/axiom-runtime';
2
+ export { isOutcome } from '../vocabulary.js';
3
+ /**
4
+ * The screen outcomes an `expected`/`screen` tag admits.
5
+ *
6
+ * A vector's `expected` states a screen's *decision*, and a suite's explicit `screen` tag states
7
+ * the same three; `UNKNOWN` and `DEFERRED` are not decisions, so a vector reads them as an
8
+ * outcome and a suite states them through `screens.outcome` instead.
9
+ */
10
+ export type VectorScreenOutcome = Exclude<ScreenOutcome, 'UNKNOWN' | 'DEFERRED'>;
11
+ /** Whether a text names one of the five outcomes a screen reports. */
12
+ export declare function isScreenOutcome(text: string): text is ScreenOutcome;
13
+ /** Whether a text names the three screen outcomes an assertion's `screen` tag admits. */
14
+ export declare function isVectorScreenOutcome(text: string): text is VectorScreenOutcome;
15
+ /** Whether a text names one of the five outcomes a gate presents. */
16
+ export declare function isGateOutcome(text: string): text is GateOutcome;
17
+ /** Whether a text names one of the four states `missingRequired` reports. */
18
+ export declare function isRequiredStatus(text: string): text is RequiredStatus;
19
+ //# sourceMappingURL=vocabulary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocabulary.d.ts","sourceRoot":"","sources":["../../src/scenarios/vocabulary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEzF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAuC7C;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,aAAa,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC;AAQjF,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,aAAa,CAEnE;AAED,yFAAyF;AACzF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,mBAAmB,CAE/E;AAED,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,WAAW,CAE/D;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,cAAc,CAErE"}
@@ -0,0 +1,56 @@
1
+ export { isOutcome } from '../vocabulary.js';
2
+ /**
3
+ * The one reading of each closed wire vocabulary a document states as text.
4
+ *
5
+ * A document is untrusted, so a vocabulary member is a `string` until a predicate narrows it.
6
+ * Each table below is the totality gate: `satisfies Record<Union, Union>` stops compiling when the
7
+ * runtime union gains a variant this file does not name, which is the guarantee an `assertNever`
8
+ * arm gives a switch. There is no silent fallback — a text outside the set is `undefined` and the
9
+ * caller refuses it at its own path, where it knows which member was being read.
10
+ *
11
+ * The rule-outcome table is not here: the dataset compiler reads it too, so it lives in
12
+ * `../vocabulary.ts` and this module re-exports the predicate for its existing callers.
13
+ */
14
+ const SCREEN_TEXT = {
15
+ SCREEN_PASS: 'SCREEN_PASS',
16
+ SCREEN_FAIL: 'SCREEN_FAIL',
17
+ SCREEN_REFER: 'SCREEN_REFER',
18
+ UNKNOWN: 'UNKNOWN',
19
+ DEFERRED: 'DEFERRED',
20
+ };
21
+ const GATE_TEXT = {
22
+ OPEN: 'OPEN',
23
+ BLOCKED: 'BLOCKED',
24
+ DEFERRED: 'DEFERRED',
25
+ OVERRIDDEN: 'OVERRIDDEN',
26
+ INACTIVE: 'INACTIVE',
27
+ };
28
+ const REQUIRED_TEXT = {
29
+ missing: 'missing',
30
+ satisfied: 'satisfied',
31
+ undetermined: 'undetermined',
32
+ // A server-redacted required value is a handoff, not an open question (`ACCESS-3.1.2`).
33
+ deferred: 'deferred',
34
+ };
35
+ const VECTOR_SCREEN_TEXT = {
36
+ SCREEN_PASS: 'SCREEN_PASS',
37
+ SCREEN_FAIL: 'SCREEN_FAIL',
38
+ SCREEN_REFER: 'SCREEN_REFER',
39
+ };
40
+ /** Whether a text names one of the five outcomes a screen reports. */
41
+ export function isScreenOutcome(text) {
42
+ return Object.hasOwn(SCREEN_TEXT, text);
43
+ }
44
+ /** Whether a text names the three screen outcomes an assertion's `screen` tag admits. */
45
+ export function isVectorScreenOutcome(text) {
46
+ return Object.hasOwn(VECTOR_SCREEN_TEXT, text);
47
+ }
48
+ /** Whether a text names one of the five outcomes a gate presents. */
49
+ export function isGateOutcome(text) {
50
+ return Object.hasOwn(GATE_TEXT, text);
51
+ }
52
+ /** Whether a text names one of the four states `missingRequired` reports. */
53
+ export function isRequiredStatus(text) {
54
+ return Object.hasOwn(REQUIRED_TEXT, text);
55
+ }
56
+ //# sourceMappingURL=vocabulary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocabulary.js","sourceRoot":"","sources":["../../src/scenarios/vocabulary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,GAAG;IAClB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;CACmC,CAAC;AAE1D,MAAM,SAAS,GAAG;IAChB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;CAC+B,CAAC;AAEtD,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;IAC5B,wFAAwF;IACxF,QAAQ,EAAE,UAAU;CACqC,CAAC;AAW5D,MAAM,kBAAkB,GAAG;IACzB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;CACuC,CAAC;AAEtE,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,OAAO,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import type { GateOutcome, RequiredStatus, ScreenOutcome } from '@azx-pbc/axiom-runtime';\n\nexport { isOutcome } from '../vocabulary.js';\n\n/**\n * The one reading of each closed wire vocabulary a document states as text.\n *\n * A document is untrusted, so a vocabulary member is a `string` until a predicate narrows it.\n * Each table below is the totality gate: `satisfies Record<Union, Union>` stops compiling when the\n * runtime union gains a variant this file does not name, which is the guarantee an `assertNever`\n * arm gives a switch. There is no silent fallback — a text outside the set is `undefined` and the\n * caller refuses it at its own path, where it knows which member was being read.\n *\n * The rule-outcome table is not here: the dataset compiler reads it too, so it lives in\n * `../vocabulary.ts` and this module re-exports the predicate for its existing callers.\n */\n\nconst SCREEN_TEXT = {\n SCREEN_PASS: 'SCREEN_PASS',\n SCREEN_FAIL: 'SCREEN_FAIL',\n SCREEN_REFER: 'SCREEN_REFER',\n UNKNOWN: 'UNKNOWN',\n DEFERRED: 'DEFERRED',\n} as const satisfies Record<ScreenOutcome, ScreenOutcome>;\n\nconst GATE_TEXT = {\n OPEN: 'OPEN',\n BLOCKED: 'BLOCKED',\n DEFERRED: 'DEFERRED',\n OVERRIDDEN: 'OVERRIDDEN',\n INACTIVE: 'INACTIVE',\n} as const satisfies Record<GateOutcome, GateOutcome>;\n\nconst REQUIRED_TEXT = {\n missing: 'missing',\n satisfied: 'satisfied',\n undetermined: 'undetermined',\n // A server-redacted required value is a handoff, not an open question (`ACCESS-3.1.2`).\n deferred: 'deferred',\n} as const satisfies Record<RequiredStatus, RequiredStatus>;\n\n/**\n * The screen outcomes an `expected`/`screen` tag admits.\n *\n * A vector's `expected` states a screen's *decision*, and a suite's explicit `screen` tag states\n * the same three; `UNKNOWN` and `DEFERRED` are not decisions, so a vector reads them as an\n * outcome and a suite states them through `screens.outcome` instead.\n */\nexport type VectorScreenOutcome = Exclude<ScreenOutcome, 'UNKNOWN' | 'DEFERRED'>;\n\nconst VECTOR_SCREEN_TEXT = {\n SCREEN_PASS: 'SCREEN_PASS',\n SCREEN_FAIL: 'SCREEN_FAIL',\n SCREEN_REFER: 'SCREEN_REFER',\n} as const satisfies Record<VectorScreenOutcome, VectorScreenOutcome>;\n\n/** Whether a text names one of the five outcomes a screen reports. */\nexport function isScreenOutcome(text: string): text is ScreenOutcome {\n return Object.hasOwn(SCREEN_TEXT, text);\n}\n\n/** Whether a text names the three screen outcomes an assertion's `screen` tag admits. */\nexport function isVectorScreenOutcome(text: string): text is VectorScreenOutcome {\n return Object.hasOwn(VECTOR_SCREEN_TEXT, text);\n}\n\n/** Whether a text names one of the five outcomes a gate presents. */\nexport function isGateOutcome(text: string): text is GateOutcome {\n return Object.hasOwn(GATE_TEXT, text);\n}\n\n/** Whether a text names one of the four states `missingRequired` reports. */\nexport function isRequiredStatus(text: string): text is RequiredStatus {\n return Object.hasOwn(REQUIRED_TEXT, text);\n}\n"]}
@@ -0,0 +1,54 @@
1
+ import type { SchemaDiagnostic } from './diagnostic.js';
2
+ /**
3
+ * One declared locale a catalogue entry does not state: the unit an authoring store hands a
4
+ * translator and the unit the completeness check is built from.
5
+ */
6
+ export interface TranslationGap {
7
+ /** The catalogue key the entry is filed under, exactly as the document spells it. */
8
+ readonly messageKey: string;
9
+ /** The declared locale the entry has no text in. */
10
+ readonly locale: string;
11
+ /** The catalogue entry's document path, so a caller can report where the text is missing. */
12
+ readonly path: string;
13
+ }
14
+ /**
15
+ * Every declared locale a message entry does not state, derived from the document's `locales`
16
+ * and its catalogue and nothing else.
17
+ *
18
+ * A document that declares no `locales` states its locale set one entry at a time, so there is
19
+ * no locale to be missing from it and the answer is empty. The completeness check below is this
20
+ * derivation rendered as diagnostics, which is what keeps an authoring store's gap list and a
21
+ * compile's refusal from ever disagreeing about which text is missing.
22
+ */
23
+ export declare function missingTranslations(document: Record<string, unknown>): readonly TranslationGap[];
24
+ /**
25
+ * The locale contract: `locales` is the author's commitment to a set of locales, so every
26
+ * catalogue entry states exactly those locales and nothing else, and `defaultLocale` is one of
27
+ * them. Both members are optional as a pair, because a single-locale document is the simplest
28
+ * document there is and states its one locale in every entry; the metaschema requires
29
+ * `defaultLocale` once `locales` is declared.
30
+ *
31
+ * Without the pair the author is still stating a set, one entry at a time: the **union** of the
32
+ * catalogue's locale keys. That union, not each entry on its own, is what must be one locale —
33
+ * `{A: en}` beside `{B: fr}` is a two-locale catalogue however evenly each entry is spelled,
34
+ * and nothing names its default. A union of one is the documented single-locale state.
35
+ *
36
+ * JSON Schema can hold a member to an enum but not one entry's members to another member's
37
+ * list, so this is the compiler's check rather than the metaschema's. Paths are document paths
38
+ * built from segments, never dotted key text: a message key may contain a dot (`option.a`), so
39
+ * `$.messages["option.a"]` is the only spelling of that location that cannot be read as
40
+ * `messages.option.a`. Each diagnostic also names its `messageKey` and `locale` structurally,
41
+ * so a caller need not parse the path at all.
42
+ */
43
+ export declare function localeDiagnostics(document: Record<string, unknown>): readonly SchemaDiagnostic[];
44
+ /**
45
+ * The location of one catalogue entry, or of one locale key inside it, as a document path.
46
+ *
47
+ * The segments are joined as an RFC 6901 pointer and rendered by `documentPath`, which quotes a
48
+ * member name that is not an identifier — so a key such as `option.a` renders `["option.a"]`
49
+ * rather than a dotted path a reader could mistake for two members. The message compiler reports
50
+ * its refusals at the same location, so both halves of the catalogue name a member one way.
51
+ */
52
+ export declare function catalogueLocation(document: Record<string, unknown>, key: string, locale?: string): string;
53
+ export declare function unresolvedMessageKeys(document: Record<string, unknown>): readonly SchemaDiagnostic[];
54
+ //# sourceMappingURL=catalogue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogue.d.ts","sourceRoot":"","sources":["../../src/schema/catalogue.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,qFAAqF;IACrF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6FAA6F;IAC7F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,cAAc,EAAE,CAiBhG;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,gBAAgB,EAAE,CAwFhG;AAQD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAMR;AAgED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,SAAS,gBAAgB,EAAE,CAU7B"}
@@ -0,0 +1,221 @@
1
+ import { compareCodePoints, isRecord } from '@azx-pbc/axiom-runtime';
2
+ import { documentPath } from '../document-path.js';
3
+ import { canonicalLocale, isLocaleTag } from '../messages/locale.js';
4
+ import { messageKeyUses } from '../messages/slots.js';
5
+ import { listAt, textAt } from './document.js';
6
+ /**
7
+ * Every declared locale a message entry does not state, derived from the document's `locales`
8
+ * and its catalogue and nothing else.
9
+ *
10
+ * A document that declares no `locales` states its locale set one entry at a time, so there is
11
+ * no locale to be missing from it and the answer is empty. The completeness check below is this
12
+ * derivation rendered as diagnostics, which is what keeps an authoring store's gap list and a
13
+ * compile's refusal from ever disagreeing about which text is missing.
14
+ */
15
+ export function missingTranslations(document) {
16
+ const declared = listAt(document, 'locales').filter((locale) => typeof locale === 'string');
17
+ if (declared.length === 0)
18
+ return [];
19
+ const catalogue = document['messages'];
20
+ if (!isRecord(catalogue))
21
+ return [];
22
+ const gaps = [];
23
+ for (const [key, entry] of Object.entries(catalogue)) {
24
+ if (!isRecord(entry))
25
+ continue;
26
+ const path = catalogueLocation(document, key);
27
+ for (const locale of declared) {
28
+ if (Object.hasOwn(entry, locale))
29
+ continue;
30
+ gaps.push({ messageKey: key, locale, path });
31
+ }
32
+ }
33
+ return gaps;
34
+ }
35
+ /**
36
+ * The locale contract: `locales` is the author's commitment to a set of locales, so every
37
+ * catalogue entry states exactly those locales and nothing else, and `defaultLocale` is one of
38
+ * them. Both members are optional as a pair, because a single-locale document is the simplest
39
+ * document there is and states its one locale in every entry; the metaschema requires
40
+ * `defaultLocale` once `locales` is declared.
41
+ *
42
+ * Without the pair the author is still stating a set, one entry at a time: the **union** of the
43
+ * catalogue's locale keys. That union, not each entry on its own, is what must be one locale —
44
+ * `{A: en}` beside `{B: fr}` is a two-locale catalogue however evenly each entry is spelled,
45
+ * and nothing names its default. A union of one is the documented single-locale state.
46
+ *
47
+ * JSON Schema can hold a member to an enum but not one entry's members to another member's
48
+ * list, so this is the compiler's check rather than the metaschema's. Paths are document paths
49
+ * built from segments, never dotted key text: a message key may contain a dot (`option.a`), so
50
+ * `$.messages["option.a"]` is the only spelling of that location that cannot be read as
51
+ * `messages.option.a`. Each diagnostic also names its `messageKey` and `locale` structurally,
52
+ * so a caller need not parse the path at all.
53
+ */
54
+ export function localeDiagnostics(document) {
55
+ const catalogue = document['messages'];
56
+ const entries = isRecord(catalogue) ? Object.entries(catalogue) : [];
57
+ const declared = listAt(document, 'locales').filter((locale) => typeof locale === 'string');
58
+ const defaultLocale = textAt(document, 'defaultLocale');
59
+ const diagnostics = [];
60
+ if (declared.length === 0) {
61
+ const union = new Set();
62
+ for (const [, entry] of entries) {
63
+ if (!isRecord(entry))
64
+ continue;
65
+ for (const locale of Object.keys(entry))
66
+ union.add(locale);
67
+ }
68
+ const stated = [...union].sort(compareCodePoints);
69
+ if (stated.length > 1) {
70
+ diagnostics.push({
71
+ code: 'MESSAGE_LOCALE',
72
+ path: '$.locales',
73
+ detail: `the catalogue states ${quotedList(stated)}, but the document declares no \`locales\` and no \`defaultLocale\`; declare both: \`locales\` is the set every entry is complete in, and \`defaultLocale\` is the one a renderer shows`,
74
+ });
75
+ }
76
+ for (const [key, entry] of entries) {
77
+ if (!isRecord(entry))
78
+ continue;
79
+ diagnostics.push(...catalogueKeyDiagnostics(document, key, entry, undefined));
80
+ }
81
+ return diagnostics;
82
+ }
83
+ const locales = new Set(declared);
84
+ const list = [...locales].join(', ');
85
+ const gapsByKey = new Map();
86
+ for (const gap of missingTranslations(document)) {
87
+ const locales = gapsByKey.get(gap.messageKey);
88
+ if (locales === undefined)
89
+ gapsByKey.set(gap.messageKey, [gap.locale]);
90
+ else
91
+ locales.push(gap.locale);
92
+ }
93
+ declared.forEach((locale, index) => {
94
+ const at = documentPath(`#/locales/${String(index)}`, document);
95
+ if (!isLocaleTag(locale)) {
96
+ diagnostics.push({
97
+ code: 'MESSAGE_LOCALE',
98
+ path: at,
99
+ locale,
100
+ detail: `\`${locale}\` is not a locale tag; write a language, an optional script and an optional region, as \`pt-BR\` or \`es-419\``,
101
+ });
102
+ return;
103
+ }
104
+ const canonical = canonicalLocale(locale);
105
+ if (canonical === locale)
106
+ return;
107
+ diagnostics.push({
108
+ code: 'MESSAGE_LOCALE',
109
+ path: at,
110
+ locale,
111
+ expected: canonical,
112
+ detail: `locale \`${locale}\` is not in canonical form; write \`${canonical}\` so the catalogue keys and the declared set compare as exact strings`,
113
+ });
114
+ });
115
+ if (defaultLocale !== undefined && !locales.has(defaultLocale)) {
116
+ diagnostics.push({
117
+ code: 'MESSAGE_LOCALE',
118
+ path: '$.defaultLocale',
119
+ locale: defaultLocale,
120
+ detail: `default locale \`${defaultLocale}\` is not one of the declared locales (${list}); write \`defaultLocale\` as one of them`,
121
+ });
122
+ }
123
+ for (const [key, entry] of entries) {
124
+ if (!isRecord(entry))
125
+ continue;
126
+ const missing = gapsByKey.get(key) ?? [];
127
+ if (missing.length > 0) {
128
+ // One refusal per message, naming every missing locale: a diagnostic per locale would
129
+ // repeat the same location and code, leaving a repair loop with four identical findings.
130
+ diagnostics.push({
131
+ code: 'MESSAGE_LOCALE',
132
+ path: catalogueLocation(document, key),
133
+ messageKey: key,
134
+ detail: `message \`${key}\` has no ${quotedList(missing)} ${missing.length === 1 ? 'entry' : 'entries'}, and the document declares \`locales\` [${list}]; write the missing entry under each declared locale`,
135
+ });
136
+ }
137
+ diagnostics.push(...catalogueKeyDiagnostics(document, key, entry, { locales, list }));
138
+ }
139
+ return diagnostics;
140
+ }
141
+ /**
142
+ * The location of one catalogue entry, or of one locale key inside it, as a document path.
143
+ *
144
+ * The segments are joined as an RFC 6901 pointer and rendered by `documentPath`, which quotes a
145
+ * member name that is not an identifier — so a key such as `option.a` renders `["option.a"]`
146
+ * rather than a dotted path a reader could mistake for two members. The message compiler reports
147
+ * its refusals at the same location, so both halves of the catalogue name a member one way.
148
+ */
149
+ export function catalogueLocation(document, key, locale) {
150
+ const segments = locale === undefined ? ['messages', key] : ['messages', key, locale];
151
+ const pointer = segments
152
+ .map((segment) => encodeURIComponent(segment.replaceAll('~', '~0').replaceAll('/', '~1')))
153
+ .join('/');
154
+ return documentPath(`#/${pointer}`, document);
155
+ }
156
+ /**
157
+ * One diagnostic per locale-key or carried-locale defect of one catalogue entry.
158
+ *
159
+ * A declared set is optional here because a document without one still states a locale in each
160
+ * key; the spelling is a defect in either state, so both report it at the key's own location. A
161
+ * compiled AST's carried locale must agree with that key for the same reason: it selects the
162
+ * plural rules for the text filed there.
163
+ */
164
+ function catalogueKeyDiagnostics(document, key, entry, declared) {
165
+ const diagnostics = [];
166
+ for (const locale of Object.keys(entry)) {
167
+ const at = catalogueLocation(document, key, locale);
168
+ const compiled = entry[locale];
169
+ if (isRecord(compiled)) {
170
+ const carried = compiled['locale'];
171
+ if (typeof carried === 'string' && carried !== locale) {
172
+ diagnostics.push({
173
+ code: 'MESSAGE_LOCALE',
174
+ path: at,
175
+ messageKey: key,
176
+ locale: carried,
177
+ expected: locale,
178
+ detail: `message \`${key}\` is filed under \`${locale}\` but its compiled entry carries \`${carried}\`; the entry's locale must be its catalogue key so its text and plural rules cannot disagree`,
179
+ });
180
+ }
181
+ }
182
+ const canonical = canonicalLocale(locale);
183
+ if (locale !== canonical) {
184
+ diagnostics.push({
185
+ code: 'MESSAGE_LOCALE',
186
+ path: at,
187
+ messageKey: key,
188
+ locale,
189
+ expected: canonical,
190
+ detail: `locale key \`${locale}\` is not in canonical form; write \`${canonical}\`${declared === undefined ? '' : ' so it matches the declared locale'}`,
191
+ });
192
+ continue;
193
+ }
194
+ if (declared === undefined || declared.locales.has(locale))
195
+ continue;
196
+ diagnostics.push({
197
+ code: 'MESSAGE_LOCALE',
198
+ path: at,
199
+ messageKey: key,
200
+ locale,
201
+ detail: `message \`${key}\` declares locale \`${locale}\`, which \`locales\` does not list ([${declared.list}]); remove the locale from this entry, or add it to \`locales\``,
202
+ });
203
+ }
204
+ return diagnostics;
205
+ }
206
+ /** `a`, `b`, `c` — the spelling every locale list in a diagnostic uses. */
207
+ function quotedList(values) {
208
+ return values.map((value) => `\`${value}\``).join(', ');
209
+ }
210
+ export function unresolvedMessageKeys(document) {
211
+ const catalogue = document['messages'];
212
+ const declared = new Set(isRecord(catalogue) ? Object.keys(catalogue) : []);
213
+ return messageKeyUses(document)
214
+ .filter((use) => !declared.has(use.key))
215
+ .map((use) => ({
216
+ code: 'UNRESOLVED_MESSAGE_KEY',
217
+ path: use.path,
218
+ detail: `message key \`${use.key}\` is not declared in \`messages\`; declare the key in \`messages\`, or point \`messageKey\` at a declared key`,
219
+ }));
220
+ }
221
+ //# sourceMappingURL=catalogue.js.map