@azx-pbc/axiom-compiler 0.0.0-stage → 0.0.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.
- package/LICENSE +21 -0
- package/README.md +415 -2
- package/dist/article.d.ts +12 -0
- package/dist/article.d.ts.map +1 -0
- package/dist/article.js +16 -0
- package/dist/article.js.map +1 -0
- package/dist/cli/args.d.ts +101 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +158 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/check.d.ts +2 -0
- package/dist/cli/check.d.ts.map +1 -0
- package/dist/cli/check.js +33 -0
- package/dist/cli/check.js.map +1 -0
- package/dist/cli/compile.d.ts +2 -0
- package/dist/cli/compile.d.ts.map +1 -0
- package/dist/cli/compile.js +43 -0
- package/dist/cli/compile.js.map +1 -0
- package/dist/cli/count.d.ts +15 -0
- package/dist/cli/count.d.ts.map +1 -0
- package/dist/cli/count.js +21 -0
- package/dist/cli/count.js.map +1 -0
- package/dist/cli/dataset.d.ts +28 -0
- package/dist/cli/dataset.d.ts.map +1 -0
- package/dist/cli/dataset.js +115 -0
- package/dist/cli/dataset.js.map +1 -0
- package/dist/cli/diff.d.ts +2 -0
- package/dist/cli/diff.d.ts.map +1 -0
- package/dist/cli/diff.js +297 -0
- package/dist/cli/diff.js.map +1 -0
- package/dist/cli/explain.d.ts +2 -0
- package/dist/cli/explain.d.ts.map +1 -0
- package/dist/cli/explain.js +95 -0
- package/dist/cli/explain.js.map +1 -0
- package/dist/cli/fields.d.ts +11 -0
- package/dist/cli/fields.d.ts.map +1 -0
- package/dist/cli/fields.js +13 -0
- package/dist/cli/fields.js.map +1 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +40 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/read.d.ts +56 -0
- package/dist/cli/read.d.ts.map +1 -0
- package/dist/cli/read.js +179 -0
- package/dist/cli/read.js.map +1 -0
- package/dist/cli/render.d.ts +58 -0
- package/dist/cli/render.d.ts.map +1 -0
- package/dist/cli/render.js +422 -0
- package/dist/cli/render.js.map +1 -0
- package/dist/cli/schema.d.ts +28 -0
- package/dist/cli/schema.d.ts.map +1 -0
- package/dist/cli/schema.js +46 -0
- package/dist/cli/schema.js.map +1 -0
- package/dist/cli/suite-report.d.ts +18 -0
- package/dist/cli/suite-report.d.ts.map +1 -0
- package/dist/cli/suite-report.js +58 -0
- package/dist/cli/suite-report.js.map +1 -0
- package/dist/cli/suites.d.ts +25 -0
- package/dist/cli/suites.d.ts.map +1 -0
- package/dist/cli/suites.js +67 -0
- package/dist/cli/suites.js.map +1 -0
- package/dist/cli/terminal.d.ts +45 -0
- package/dist/cli/terminal.d.ts.map +1 -0
- package/dist/cli/terminal.js +119 -0
- package/dist/cli/terminal.js.map +1 -0
- package/dist/cli/test.d.ts +12 -0
- package/dist/cli/test.d.ts.map +1 -0
- package/dist/cli/test.js +199 -0
- package/dist/cli/test.js.map +1 -0
- package/dist/cli/usage.d.ts +15 -0
- package/dist/cli/usage.d.ts.map +1 -0
- package/dist/cli/usage.js +95 -0
- package/dist/cli/usage.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +51 -0
- package/dist/cli.js.map +1 -0
- package/dist/compile/artifact-members.d.ts +57 -0
- package/dist/compile/artifact-members.d.ts.map +1 -0
- package/dist/compile/artifact-members.js +130 -0
- package/dist/compile/artifact-members.js.map +1 -0
- package/dist/compile/artifact.d.ts +20 -0
- package/dist/compile/artifact.d.ts.map +1 -0
- package/dist/compile/artifact.js +87 -0
- package/dist/compile/artifact.js.map +1 -0
- package/dist/compile/compilation.d.ts +46 -0
- package/dist/compile/compilation.d.ts.map +1 -0
- package/dist/compile/compilation.js +4 -0
- package/dist/compile/compilation.js.map +1 -0
- package/dist/compile/computed.d.ts +22 -0
- package/dist/compile/computed.d.ts.map +1 -0
- package/dist/compile/computed.js +245 -0
- package/dist/compile/computed.js.map +1 -0
- package/dist/compile/condition-warnings.d.ts +12 -0
- package/dist/compile/condition-warnings.d.ts.map +1 -0
- package/dist/compile/condition-warnings.js +26 -0
- package/dist/compile/condition-warnings.js.map +1 -0
- package/dist/compile/conditions.d.ts +18 -0
- package/dist/compile/conditions.d.ts.map +1 -0
- package/dist/compile/conditions.js +22 -0
- package/dist/compile/conditions.js.map +1 -0
- package/dist/compile/cross-checks.d.ts +67 -0
- package/dist/compile/cross-checks.d.ts.map +1 -0
- package/dist/compile/cross-checks.js +238 -0
- package/dist/compile/cross-checks.js.map +1 -0
- package/dist/compile/datasets.d.ts +52 -0
- package/dist/compile/datasets.d.ts.map +1 -0
- package/dist/compile/datasets.js +183 -0
- package/dist/compile/datasets.js.map +1 -0
- package/dist/compile/dead-weight.d.ts +26 -0
- package/dist/compile/dead-weight.d.ts.map +1 -0
- package/dist/compile/dead-weight.js +244 -0
- package/dist/compile/dead-weight.js.map +1 -0
- package/dist/compile/declaration-rules.d.ts +54 -0
- package/dist/compile/declaration-rules.d.ts.map +1 -0
- package/dist/compile/declaration-rules.js +510 -0
- package/dist/compile/declaration-rules.js.map +1 -0
- package/dist/compile/declarations.d.ts +44 -0
- package/dist/compile/declarations.d.ts.map +1 -0
- package/dist/compile/declarations.js +160 -0
- package/dist/compile/declarations.js.map +1 -0
- package/dist/compile/document.d.ts +4 -0
- package/dist/compile/document.d.ts.map +1 -0
- package/dist/compile/document.js +13 -0
- package/dist/compile/document.js.map +1 -0
- package/dist/compile/expression.d.ts +38 -0
- package/dist/compile/expression.d.ts.map +1 -0
- package/dist/compile/expression.js +288 -0
- package/dist/compile/expression.js.map +1 -0
- package/dist/compile/hashes.d.ts +26 -0
- package/dist/compile/hashes.d.ts.map +1 -0
- package/dist/compile/hashes.js +96 -0
- package/dist/compile/hashes.js.map +1 -0
- package/dist/compile/item-targets.d.ts +12 -0
- package/dist/compile/item-targets.d.ts.map +1 -0
- package/dist/compile/item-targets.js +287 -0
- package/dist/compile/item-targets.js.map +1 -0
- package/dist/compile/messages.d.ts +8 -0
- package/dist/compile/messages.d.ts.map +1 -0
- package/dist/compile/messages.js +62 -0
- package/dist/compile/messages.js.map +1 -0
- package/dist/compile/option-availability.d.ts +51 -0
- package/dist/compile/option-availability.d.ts.map +1 -0
- package/dist/compile/option-availability.js +171 -0
- package/dist/compile/option-availability.js.map +1 -0
- package/dist/compile/option-codes.d.ts +27 -0
- package/dist/compile/option-codes.d.ts.map +1 -0
- package/dist/compile/option-codes.js +212 -0
- package/dist/compile/option-codes.js.map +1 -0
- package/dist/compile/references.d.ts +14 -0
- package/dist/compile/references.d.ts.map +1 -0
- package/dist/compile/references.js +126 -0
- package/dist/compile/references.js.map +1 -0
- package/dist/compile/rows-from.d.ts +27 -0
- package/dist/compile/rows-from.d.ts.map +1 -0
- package/dist/compile/rows-from.js +164 -0
- package/dist/compile/rows-from.js.map +1 -0
- package/dist/compile/rules.d.ts +58 -0
- package/dist/compile/rules.d.ts.map +1 -0
- package/dist/compile/rules.js +327 -0
- package/dist/compile/rules.js.map +1 -0
- package/dist/compile/suggestions.d.ts +52 -0
- package/dist/compile/suggestions.d.ts.map +1 -0
- package/dist/compile/suggestions.js +633 -0
- package/dist/compile/suggestions.js.map +1 -0
- package/dist/compile/targets.d.ts +22 -0
- package/dist/compile/targets.d.ts.map +1 -0
- package/dist/compile/targets.js +125 -0
- package/dist/compile/targets.js.map +1 -0
- package/dist/compile/types.d.ts +84 -0
- package/dist/compile/types.d.ts.map +1 -0
- package/dist/compile/types.js +2 -0
- package/dist/compile/types.js.map +1 -0
- package/dist/compile/warning.d.ts +45 -0
- package/dist/compile/warning.d.ts.map +1 -0
- package/dist/compile/warning.js +2 -0
- package/dist/compile/warning.js.map +1 -0
- package/dist/compile-yaml.d.ts +23 -0
- package/dist/compile-yaml.d.ts.map +1 -0
- package/dist/compile-yaml.js +30 -0
- package/dist/compile-yaml.js.map +1 -0
- package/dist/compile.d.ts +78 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +372 -0
- package/dist/compile.js.map +1 -0
- package/dist/csv/limits.d.ts +43 -0
- package/dist/csv/limits.d.ts.map +1 -0
- package/dist/csv/limits.js +51 -0
- package/dist/csv/limits.js.map +1 -0
- package/dist/csv/scalar.d.ts +33 -0
- package/dist/csv/scalar.d.ts.map +1 -0
- package/dist/csv/scalar.js +77 -0
- package/dist/csv/scalar.js.map +1 -0
- package/dist/datasets/csv.d.ts +46 -0
- package/dist/datasets/csv.d.ts.map +1 -0
- package/dist/datasets/csv.js +293 -0
- package/dist/datasets/csv.js.map +1 -0
- package/dist/datasets/declaration.d.ts +16 -0
- package/dist/datasets/declaration.d.ts.map +1 -0
- package/dist/datasets/declaration.js +104 -0
- package/dist/datasets/declaration.js.map +1 -0
- package/dist/datasets/diagnostics.d.ts +65 -0
- package/dist/datasets/diagnostics.d.ts.map +1 -0
- package/dist/datasets/diagnostics.js +2 -0
- package/dist/datasets/diagnostics.js.map +1 -0
- package/dist/datasets/diff.d.ts +46 -0
- package/dist/datasets/diff.d.ts.map +1 -0
- package/dist/datasets/diff.js +84 -0
- package/dist/datasets/diff.js.map +1 -0
- package/dist/datasets/document.d.ts +12 -0
- package/dist/datasets/document.d.ts.map +1 -0
- package/dist/datasets/document.js +382 -0
- package/dist/datasets/document.js.map +1 -0
- package/dist/datasets/index.d.ts +43 -0
- package/dist/datasets/index.d.ts.map +1 -0
- package/dist/datasets/index.js +68 -0
- package/dist/datasets/index.js.map +1 -0
- package/dist/datasets/repair.d.ts +26 -0
- package/dist/datasets/repair.d.ts.map +1 -0
- package/dist/datasets/repair.js +60 -0
- package/dist/datasets/repair.js.map +1 -0
- package/dist/document-path.d.ts +62 -0
- package/dist/document-path.d.ts.map +1 -0
- package/dist/document-path.js +200 -0
- package/dist/document-path.js.map +1 -0
- package/dist/expr/boundary.d.ts +8 -0
- package/dist/expr/boundary.d.ts.map +1 -0
- package/dist/expr/boundary.js +243 -0
- package/dist/expr/boundary.js.map +1 -0
- package/dist/expr/compile-expr.d.ts +35 -0
- package/dist/expr/compile-expr.d.ts.map +1 -0
- package/dist/expr/compile-expr.js +66 -0
- package/dist/expr/compile-expr.js.map +1 -0
- package/dist/expr/deprecation.d.ts +23 -0
- package/dist/expr/deprecation.d.ts.map +1 -0
- package/dist/expr/deprecation.js +28 -0
- package/dist/expr/deprecation.js.map +1 -0
- package/dist/expr/diagnostics.d.ts +31 -0
- package/dist/expr/diagnostics.d.ts.map +1 -0
- package/dist/expr/diagnostics.js +34 -0
- package/dist/expr/diagnostics.js.map +1 -0
- package/dist/expr/lexer.d.ts +49 -0
- package/dist/expr/lexer.d.ts.map +1 -0
- package/dist/expr/lexer.js +277 -0
- package/dist/expr/lexer.js.map +1 -0
- package/dist/expr/lint-warnings.d.ts +11 -0
- package/dist/expr/lint-warnings.d.ts.map +1 -0
- package/dist/expr/lint-warnings.js +20 -0
- package/dist/expr/lint-warnings.js.map +1 -0
- package/dist/expr/lint.d.ts +41 -0
- package/dist/expr/lint.d.ts.map +1 -0
- package/dist/expr/lint.js +1034 -0
- package/dist/expr/lint.js.map +1 -0
- package/dist/expr/parse/aggregates.d.ts +13 -0
- package/dist/expr/parse/aggregates.d.ts.map +1 -0
- package/dist/expr/parse/aggregates.js +48 -0
- package/dist/expr/parse/aggregates.js.map +1 -0
- package/dist/expr/parse/budget.d.ts +11 -0
- package/dist/expr/parse/budget.d.ts.map +1 -0
- package/dist/expr/parse/budget.js +57 -0
- package/dist/expr/parse/budget.js.map +1 -0
- package/dist/expr/parse/grammar.d.ts +9 -0
- package/dist/expr/parse/grammar.d.ts.map +1 -0
- package/dist/expr/parse/grammar.js +699 -0
- package/dist/expr/parse/grammar.js.map +1 -0
- package/dist/expr/parse/literals.d.ts +20 -0
- package/dist/expr/parse/literals.d.ts.map +1 -0
- package/dist/expr/parse/literals.js +132 -0
- package/dist/expr/parse/literals.js.map +1 -0
- package/dist/expr/parse/stream.d.ts +60 -0
- package/dist/expr/parse/stream.d.ts.map +1 -0
- package/dist/expr/parse/stream.js +151 -0
- package/dist/expr/parse/stream.js.map +1 -0
- package/dist/expr/parser.d.ts +45 -0
- package/dist/expr/parser.d.ts.map +1 -0
- package/dist/expr/parser.js +110 -0
- package/dist/expr/parser.js.map +1 -0
- package/dist/expr/print/spell.d.ts +78 -0
- package/dist/expr/print/spell.d.ts.map +1 -0
- package/dist/expr/print/spell.js +592 -0
- package/dist/expr/print/spell.js.map +1 -0
- package/dist/expr/print.d.ts +20 -0
- package/dist/expr/print.d.ts.map +1 -0
- package/dist/expr/print.js +102 -0
- package/dist/expr/print.js.map +1 -0
- package/dist/expr/suggest.d.ts +26 -0
- package/dist/expr/suggest.d.ts.map +1 -0
- package/dist/expr/suggest.js +77 -0
- package/dist/expr/suggest.js.map +1 -0
- package/dist/expr/typecheck/aggregates.d.ts +8 -0
- package/dist/expr/typecheck/aggregates.d.ts.map +1 -0
- package/dist/expr/typecheck/aggregates.js +334 -0
- package/dist/expr/typecheck/aggregates.js.map +1 -0
- package/dist/expr/typecheck/arithmetic.d.ts +6 -0
- package/dist/expr/typecheck/arithmetic.d.ts.map +1 -0
- package/dist/expr/typecheck/arithmetic.js +258 -0
- package/dist/expr/typecheck/arithmetic.js.map +1 -0
- package/dist/expr/typecheck/arity.d.ts +38 -0
- package/dist/expr/typecheck/arity.d.ts.map +1 -0
- package/dist/expr/typecheck/arity.js +173 -0
- package/dist/expr/typecheck/arity.js.map +1 -0
- package/dist/expr/typecheck/calls.d.ts +6 -0
- package/dist/expr/typecheck/calls.d.ts.map +1 -0
- package/dist/expr/typecheck/calls.js +137 -0
- package/dist/expr/typecheck/calls.js.map +1 -0
- package/dist/expr/typecheck/comparison.d.ts +13 -0
- package/dist/expr/typecheck/comparison.d.ts.map +1 -0
- package/dist/expr/typecheck/comparison.js +200 -0
- package/dist/expr/typecheck/comparison.js.map +1 -0
- package/dist/expr/typecheck/compound.d.ts +24 -0
- package/dist/expr/typecheck/compound.d.ts.map +1 -0
- package/dist/expr/typecheck/compound.js +175 -0
- package/dist/expr/typecheck/compound.js.map +1 -0
- package/dist/expr/typecheck/context.d.ts +44 -0
- package/dist/expr/typecheck/context.d.ts.map +1 -0
- package/dist/expr/typecheck/context.js +2 -0
- package/dist/expr/typecheck/context.js.map +1 -0
- package/dist/expr/typecheck/datasets.d.ts +17 -0
- package/dist/expr/typecheck/datasets.d.ts.map +1 -0
- package/dist/expr/typecheck/datasets.js +136 -0
- package/dist/expr/typecheck/datasets.js.map +1 -0
- package/dist/expr/typecheck/digest.d.ts +7 -0
- package/dist/expr/typecheck/digest.d.ts.map +1 -0
- package/dist/expr/typecheck/digest.js +44 -0
- package/dist/expr/typecheck/digest.js.map +1 -0
- package/dist/expr/typecheck/fold.d.ts +41 -0
- package/dist/expr/typecheck/fold.d.ts.map +1 -0
- package/dist/expr/typecheck/fold.js +71 -0
- package/dist/expr/typecheck/fold.js.map +1 -0
- package/dist/expr/typecheck/gate-folds.d.ts +22 -0
- package/dist/expr/typecheck/gate-folds.d.ts.map +1 -0
- package/dist/expr/typecheck/gate-folds.js +40 -0
- package/dist/expr/typecheck/gate-folds.js.map +1 -0
- package/dist/expr/typecheck/guards.d.ts +6 -0
- package/dist/expr/typecheck/guards.d.ts.map +1 -0
- package/dist/expr/typecheck/guards.js +38 -0
- package/dist/expr/typecheck/guards.js.map +1 -0
- package/dist/expr/typecheck/member.d.ts +17 -0
- package/dist/expr/typecheck/member.d.ts.map +1 -0
- package/dist/expr/typecheck/member.js +46 -0
- package/dist/expr/typecheck/member.js.map +1 -0
- package/dist/expr/typecheck/money.d.ts +8 -0
- package/dist/expr/typecheck/money.d.ts.map +1 -0
- package/dist/expr/typecheck/money.js +49 -0
- package/dist/expr/typecheck/money.js.map +1 -0
- package/dist/expr/typecheck/numeric.d.ts +8 -0
- package/dist/expr/typecheck/numeric.d.ts.map +1 -0
- package/dist/expr/typecheck/numeric.js +84 -0
- package/dist/expr/typecheck/numeric.js.map +1 -0
- package/dist/expr/typecheck/operands.d.ts +27 -0
- package/dist/expr/typecheck/operands.d.ts.map +1 -0
- package/dist/expr/typecheck/operands.js +106 -0
- package/dist/expr/typecheck/operands.js.map +1 -0
- package/dist/expr/typecheck/paths.d.ts +21 -0
- package/dist/expr/typecheck/paths.d.ts.map +1 -0
- package/dist/expr/typecheck/paths.js +321 -0
- package/dist/expr/typecheck/paths.js.map +1 -0
- package/dist/expr/typecheck/records.d.ts +24 -0
- package/dist/expr/typecheck/records.d.ts.map +1 -0
- package/dist/expr/typecheck/records.js +53 -0
- package/dist/expr/typecheck/records.js.map +1 -0
- package/dist/expr/typecheck/sequences.d.ts +15 -0
- package/dist/expr/typecheck/sequences.d.ts.map +1 -0
- package/dist/expr/typecheck/sequences.js +55 -0
- package/dist/expr/typecheck/sequences.js.map +1 -0
- package/dist/expr/typecheck/strings.d.ts +8 -0
- package/dist/expr/typecheck/strings.d.ts.map +1 -0
- package/dist/expr/typecheck/strings.js +188 -0
- package/dist/expr/typecheck/strings.js.map +1 -0
- package/dist/expr/typecheck/temporal.d.ts +7 -0
- package/dist/expr/typecheck/temporal.d.ts.map +1 -0
- package/dist/expr/typecheck/temporal.js +80 -0
- package/dist/expr/typecheck/temporal.js.map +1 -0
- package/dist/expr/typecheck/types.d.ts +163 -0
- package/dist/expr/typecheck/types.d.ts.map +1 -0
- package/dist/expr/typecheck/types.js +404 -0
- package/dist/expr/typecheck/types.js.map +1 -0
- package/dist/expr/typecheck.d.ts +75 -0
- package/dist/expr/typecheck.d.ts.map +1 -0
- package/dist/expr/typecheck.js +242 -0
- package/dist/expr/typecheck.js.map +1 -0
- package/dist/expr/undecided.d.ts +13 -0
- package/dist/expr/undecided.d.ts.map +1 -0
- package/dist/expr/undecided.js +58 -0
- package/dist/expr/undecided.js.map +1 -0
- package/dist/expr/values/code-points.d.ts +13 -0
- package/dist/expr/values/code-points.d.ts.map +1 -0
- package/dist/expr/values/code-points.js +25 -0
- package/dist/expr/values/code-points.js.map +1 -0
- package/dist/expr/values/inline.d.ts +77 -0
- package/dist/expr/values/inline.d.ts.map +1 -0
- package/dist/expr/values/inline.js +404 -0
- package/dist/expr/values/inline.js.map +1 -0
- package/dist/expr/values/interval.d.ts +19 -0
- package/dist/expr/values/interval.d.ts.map +1 -0
- package/dist/expr/values/interval.js +1180 -0
- package/dist/expr/values/interval.js.map +1 -0
- package/dist/index.d.ts +163 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -0
- package/dist/ingest/document.d.ts +58 -0
- package/dist/ingest/document.d.ts.map +1 -0
- package/dist/ingest/document.js +83 -0
- package/dist/ingest/document.js.map +1 -0
- package/dist/ingest/yaml-document.d.ts +15 -0
- package/dist/ingest/yaml-document.d.ts.map +1 -0
- package/dist/ingest/yaml-document.js +42 -0
- package/dist/ingest/yaml-document.js.map +1 -0
- package/dist/ingest/yaml.d.ts +51 -0
- package/dist/ingest/yaml.d.ts.map +1 -0
- package/dist/ingest/yaml.js +340 -0
- package/dist/ingest/yaml.js.map +1 -0
- package/dist/layout/compile.d.ts +6 -0
- package/dist/layout/compile.d.ts.map +1 -0
- package/dist/layout/compile.js +224 -0
- package/dist/layout/compile.js.map +1 -0
- package/dist/layout/context.d.ts +12 -0
- package/dist/layout/context.d.ts.map +1 -0
- package/dist/layout/context.js +26 -0
- package/dist/layout/context.js.map +1 -0
- package/dist/layout/grammar.d.ts +34 -0
- package/dist/layout/grammar.d.ts.map +1 -0
- package/dist/layout/grammar.js +171 -0
- package/dist/layout/grammar.js.map +1 -0
- package/dist/layout/read.d.ts +54 -0
- package/dist/layout/read.d.ts.map +1 -0
- package/dist/layout/read.js +101 -0
- package/dist/layout/read.js.map +1 -0
- package/dist/layout/shape.d.ts +34 -0
- package/dist/layout/shape.d.ts.map +1 -0
- package/dist/layout/shape.js +149 -0
- package/dist/layout/shape.js.map +1 -0
- package/dist/messages/compile.d.ts +47 -0
- package/dist/messages/compile.d.ts.map +1 -0
- package/dist/messages/compile.js +202 -0
- package/dist/messages/compile.js.map +1 -0
- package/dist/messages/locale.d.ts +18 -0
- package/dist/messages/locale.d.ts.map +1 -0
- package/dist/messages/locale.js +33 -0
- package/dist/messages/locale.js.map +1 -0
- package/dist/messages/slots.d.ts +54 -0
- package/dist/messages/slots.d.ts.map +1 -0
- package/dist/messages/slots.js +137 -0
- package/dist/messages/slots.js.map +1 -0
- package/dist/overlay/compile-overlay.d.ts +29 -0
- package/dist/overlay/compile-overlay.d.ts.map +1 -0
- package/dist/overlay/compile-overlay.js +120 -0
- package/dist/overlay/compile-overlay.js.map +1 -0
- package/dist/overlay/compose.d.ts +26 -0
- package/dist/overlay/compose.d.ts.map +1 -0
- package/dist/overlay/compose.js +674 -0
- package/dist/overlay/compose.js.map +1 -0
- package/dist/overlay/types.d.ts +41 -0
- package/dist/overlay/types.d.ts.map +1 -0
- package/dist/overlay/types.js +2 -0
- package/dist/overlay/types.js.map +1 -0
- package/dist/publish/classify.d.ts +50 -0
- package/dist/publish/classify.d.ts.map +1 -0
- package/dist/publish/classify.js +85 -0
- package/dist/publish/classify.js.map +1 -0
- package/dist/publish/environment.d.ts +15 -0
- package/dist/publish/environment.d.ts.map +1 -0
- package/dist/publish/environment.js +2 -0
- package/dist/publish/environment.js.map +1 -0
- package/dist/publish/migrations.d.ts +108 -0
- package/dist/publish/migrations.d.ts.map +1 -0
- package/dist/publish/migrations.js +166 -0
- package/dist/publish/migrations.js.map +1 -0
- package/dist/publish/observation.d.ts +29 -0
- package/dist/publish/observation.d.ts.map +1 -0
- package/dist/publish/observation.js +43 -0
- package/dist/publish/observation.js.map +1 -0
- package/dist/publish/readiness.d.ts +197 -0
- package/dist/publish/readiness.d.ts.map +1 -0
- package/dist/publish/readiness.js +239 -0
- package/dist/publish/readiness.js.map +1 -0
- package/dist/publish/vectors.d.ts +50 -0
- package/dist/publish/vectors.d.ts.map +1 -0
- package/dist/publish/vectors.js +306 -0
- package/dist/publish/vectors.js.map +1 -0
- package/dist/publish/verify.d.ts +146 -0
- package/dist/publish/verify.d.ts.map +1 -0
- package/dist/publish/verify.js +548 -0
- package/dist/publish/verify.js.map +1 -0
- package/dist/scenarios/branch.d.ts +36 -0
- package/dist/scenarios/branch.d.ts.map +1 -0
- package/dist/scenarios/branch.js +30 -0
- package/dist/scenarios/branch.js.map +1 -0
- package/dist/scenarios/capture.d.ts +89 -0
- package/dist/scenarios/capture.d.ts.map +1 -0
- package/dist/scenarios/capture.js +443 -0
- package/dist/scenarios/capture.js.map +1 -0
- package/dist/scenarios/classifier.d.ts +20 -0
- package/dist/scenarios/classifier.d.ts.map +1 -0
- package/dist/scenarios/classifier.js +88 -0
- package/dist/scenarios/classifier.js.map +1 -0
- package/dist/scenarios/credit.d.ts +33 -0
- package/dist/scenarios/credit.d.ts.map +1 -0
- package/dist/scenarios/credit.js +330 -0
- package/dist/scenarios/credit.js.map +1 -0
- package/dist/scenarios/csv.d.ts +34 -0
- package/dist/scenarios/csv.d.ts.map +1 -0
- package/dist/scenarios/csv.js +1047 -0
- package/dist/scenarios/csv.js.map +1 -0
- package/dist/scenarios/data-identity.d.ts +39 -0
- package/dist/scenarios/data-identity.d.ts.map +1 -0
- package/dist/scenarios/data-identity.js +28 -0
- package/dist/scenarios/data-identity.js.map +1 -0
- package/dist/scenarios/document.d.ts +148 -0
- package/dist/scenarios/document.d.ts.map +1 -0
- package/dist/scenarios/document.js +513 -0
- package/dist/scenarios/document.js.map +1 -0
- package/dist/scenarios/environment.d.ts +64 -0
- package/dist/scenarios/environment.d.ts.map +1 -0
- package/dist/scenarios/environment.js +106 -0
- package/dist/scenarios/environment.js.map +1 -0
- package/dist/scenarios/evidence.d.ts +128 -0
- package/dist/scenarios/evidence.d.ts.map +1 -0
- package/dist/scenarios/evidence.js +179 -0
- package/dist/scenarios/evidence.js.map +1 -0
- package/dist/scenarios/expectations.d.ts +63 -0
- package/dist/scenarios/expectations.d.ts.map +1 -0
- package/dist/scenarios/expectations.js +490 -0
- package/dist/scenarios/expectations.js.map +1 -0
- package/dist/scenarios/references.d.ts +15 -0
- package/dist/scenarios/references.d.ts.map +1 -0
- package/dist/scenarios/references.js +239 -0
- package/dist/scenarios/references.js.map +1 -0
- package/dist/scenarios/report.d.ts +216 -0
- package/dist/scenarios/report.d.ts.map +1 -0
- package/dist/scenarios/report.js +54 -0
- package/dist/scenarios/report.js.map +1 -0
- package/dist/scenarios/runner.d.ts +55 -0
- package/dist/scenarios/runner.d.ts.map +1 -0
- package/dist/scenarios/runner.js +205 -0
- package/dist/scenarios/runner.js.map +1 -0
- package/dist/scenarios/vocabulary.d.ts +19 -0
- package/dist/scenarios/vocabulary.d.ts.map +1 -0
- package/dist/scenarios/vocabulary.js +56 -0
- package/dist/scenarios/vocabulary.js.map +1 -0
- package/dist/schema/catalogue.d.ts +54 -0
- package/dist/schema/catalogue.d.ts.map +1 -0
- package/dist/schema/catalogue.js +221 -0
- package/dist/schema/catalogue.js.map +1 -0
- package/dist/schema/check.d.ts +22 -0
- package/dist/schema/check.d.ts.map +1 -0
- package/dist/schema/check.js +30 -0
- package/dist/schema/check.js.map +1 -0
- package/dist/schema/closed.d.ts +19 -0
- package/dist/schema/closed.d.ts.map +1 -0
- package/dist/schema/closed.js +33 -0
- package/dist/schema/closed.js.map +1 -0
- package/dist/schema/collapse.d.ts +27 -0
- package/dist/schema/collapse.d.ts.map +1 -0
- package/dist/schema/collapse.js +143 -0
- package/dist/schema/collapse.js.map +1 -0
- package/dist/schema/controls.d.ts +46 -0
- package/dist/schema/controls.d.ts.map +1 -0
- package/dist/schema/controls.js +75 -0
- package/dist/schema/controls.js.map +1 -0
- package/dist/schema/dataset-declaration.d.ts +11 -0
- package/dist/schema/dataset-declaration.d.ts.map +1 -0
- package/dist/schema/dataset-declaration.js +11 -0
- package/dist/schema/dataset-declaration.js.map +1 -0
- package/dist/schema/declaration-warnings.d.ts +14 -0
- package/dist/schema/declaration-warnings.d.ts.map +1 -0
- package/dist/schema/declaration-warnings.js +77 -0
- package/dist/schema/declaration-warnings.js.map +1 -0
- package/dist/schema/declarations.d.ts +41 -0
- package/dist/schema/declarations.d.ts.map +1 -0
- package/dist/schema/declarations.js +1299 -0
- package/dist/schema/declarations.js.map +1 -0
- package/dist/schema/diagnostic.d.ts +118 -0
- package/dist/schema/diagnostic.d.ts.map +1 -0
- package/dist/schema/diagnostic.js +39 -0
- package/dist/schema/diagnostic.js.map +1 -0
- package/dist/schema/document.d.ts +93 -0
- package/dist/schema/document.d.ts.map +1 -0
- package/dist/schema/document.js +507 -0
- package/dist/schema/document.js.map +1 -0
- package/dist/schema/fields.d.ts +11 -0
- package/dist/schema/fields.d.ts.map +1 -0
- package/dist/schema/fields.js +265 -0
- package/dist/schema/fields.js.map +1 -0
- package/dist/schema/gates.d.ts +4 -0
- package/dist/schema/gates.d.ts.map +1 -0
- package/dist/schema/gates.js +68 -0
- package/dist/schema/gates.js.map +1 -0
- package/dist/schema/located.d.ts +27 -0
- package/dist/schema/located.d.ts.map +1 -0
- package/dist/schema/located.js +56 -0
- package/dist/schema/located.js.map +1 -0
- package/dist/schema/measurement.d.ts +9 -0
- package/dist/schema/measurement.d.ts.map +1 -0
- package/dist/schema/measurement.js +38 -0
- package/dist/schema/measurement.js.map +1 -0
- package/dist/schema/member-wording.d.ts +35 -0
- package/dist/schema/member-wording.d.ts.map +1 -0
- package/dist/schema/member-wording.js +286 -0
- package/dist/schema/member-wording.js.map +1 -0
- package/dist/schema/metaschema.d.ts +20 -0
- package/dist/schema/metaschema.d.ts.map +1 -0
- package/dist/schema/metaschema.js +476 -0
- package/dist/schema/metaschema.js.map +1 -0
- package/dist/schema/pointer.d.ts +31 -0
- package/dist/schema/pointer.d.ts.map +1 -0
- package/dist/schema/pointer.js +73 -0
- package/dist/schema/pointer.js.map +1 -0
- package/dist/schema/primary.d.ts +29 -0
- package/dist/schema/primary.d.ts.map +1 -0
- package/dist/schema/primary.js +48 -0
- package/dist/schema/primary.js.map +1 -0
- package/dist/schema/publish-vector.d.ts +17 -0
- package/dist/schema/publish-vector.d.ts.map +1 -0
- package/dist/schema/publish-vector.js +34 -0
- package/dist/schema/publish-vector.js.map +1 -0
- package/dist/schema/repair.d.ts +34 -0
- package/dist/schema/repair.d.ts.map +1 -0
- package/dist/schema/repair.js +163 -0
- package/dist/schema/repair.js.map +1 -0
- package/dist/schema/schema-v1.generated.d.ts +14 -0
- package/dist/schema/schema-v1.generated.d.ts.map +1 -0
- package/dist/schema/schema-v1.generated.js +7089 -0
- package/dist/schema/schema-v1.generated.js.map +1 -0
- package/dist/schema/screens.d.ts +4 -0
- package/dist/schema/screens.d.ts.map +1 -0
- package/dist/schema/screens.js +28 -0
- package/dist/schema/screens.js.map +1 -0
- package/dist/schema/test-values.d.ts +12 -0
- package/dist/schema/test-values.d.ts.map +1 -0
- package/dist/schema/test-values.js +97 -0
- package/dist/schema/test-values.js.map +1 -0
- package/dist/schema/unions.d.ts +46 -0
- package/dist/schema/unions.d.ts.map +1 -0
- package/dist/schema/unions.js +131 -0
- package/dist/schema/unions.js.map +1 -0
- package/dist/schema/validate-yaml.d.ts +14 -0
- package/dist/schema/validate-yaml.d.ts.map +1 -0
- package/dist/schema/validate-yaml.js +17 -0
- package/dist/schema/validate-yaml.js.map +1 -0
- package/dist/schema/validate.d.ts +46 -0
- package/dist/schema/validate.d.ts.map +1 -0
- package/dist/schema/validate.js +186 -0
- package/dist/schema/validate.js.map +1 -0
- package/dist/testing.d.ts +21 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +28 -0
- package/dist/testing.js.map +1 -0
- package/dist/vocabulary.d.ts +6 -0
- package/dist/vocabulary.d.ts.map +1 -0
- package/dist/vocabulary.js +26 -0
- package/dist/vocabulary.js.map +1 -0
- package/package.json +66 -3
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { assertNever, isRecord, unreachableBranchOf } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import { branchCredit } from '../scenarios/branch.js';
|
|
3
|
+
import { observationOfExpected } from './observation.js';
|
|
4
|
+
/**
|
|
5
|
+
* The member that carries one rule's evidence: the declaration's sibling when a declaration
|
|
6
|
+
* produced the rule, else the caller's own fallback.
|
|
7
|
+
*
|
|
8
|
+
* A gap about a generated rule must send the author to the member they can edit
|
|
9
|
+
* (`$.fields[1].minLengthTestCases`), never to an artifact slot the compiler filled.
|
|
10
|
+
*/
|
|
11
|
+
export function evidencePathOf(origins, ruleId, fallback) {
|
|
12
|
+
const origin = declaredOriginOf(origins, ruleId);
|
|
13
|
+
return origin === undefined ? fallback : `${origin.path}.${origin.evidenceMember}`;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The declaration one compiler-synthesised rule came from.
|
|
17
|
+
*
|
|
18
|
+
* One rule is produced by one declaration. A later entry wins over an earlier one for the same id,
|
|
19
|
+
* so a caller that restates a rule states the origin it means.
|
|
20
|
+
*/
|
|
21
|
+
function declaredOriginOf(origins, ruleId) {
|
|
22
|
+
for (let index = origins.length - 1; index >= 0; index -= 1) {
|
|
23
|
+
const origin = origins[index];
|
|
24
|
+
if (origin !== undefined && origin.ruleId === ruleId)
|
|
25
|
+
return origin;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
/** The branches one rule's expression admits, in the order a gap names them. */
|
|
30
|
+
function requiredBranchesOf(rule) {
|
|
31
|
+
const unreachable = unreachableBranchOf(rule);
|
|
32
|
+
return { firing: unreachable !== 'firing', nonFiring: unreachable !== 'non_firing' };
|
|
33
|
+
}
|
|
34
|
+
/** The outcome that counts as one rule kind firing, in the words a gap can quote. */
|
|
35
|
+
function firingOutcomeText(kind) {
|
|
36
|
+
switch (kind) {
|
|
37
|
+
case 'validate':
|
|
38
|
+
case 'gate':
|
|
39
|
+
return `a ${kind} rule fires FAIL`;
|
|
40
|
+
case 'visible':
|
|
41
|
+
case 'required':
|
|
42
|
+
case 'enabled':
|
|
43
|
+
return `${kind === 'enabled' ? 'an' : 'a'} ${kind} rule fires PASS`;
|
|
44
|
+
case 'screen':
|
|
45
|
+
return 'a screen rule fires SCREEN_FAIL or SCREEN_REFER';
|
|
46
|
+
case 'compute':
|
|
47
|
+
case 'defaultCompute':
|
|
48
|
+
return `a ${kind} rule fires on the value it produces`;
|
|
49
|
+
default:
|
|
50
|
+
return assertNever(kind);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** The evidence a rule needs, in the words a gap uses to ask for it. */
|
|
54
|
+
function requirementText(required, kind) {
|
|
55
|
+
const firing = `(${firingOutcomeText(kind)})`;
|
|
56
|
+
if (required.firing && required.nonFiring) {
|
|
57
|
+
return `requires one firing and one non-firing case to publish ${firing}`;
|
|
58
|
+
}
|
|
59
|
+
return required.firing
|
|
60
|
+
? `requires one firing case to publish ${firing}`
|
|
61
|
+
: `requires one non-firing case to publish ${firing}`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Derives the verdict from evidence, or names every reason it is not ready.
|
|
65
|
+
*
|
|
66
|
+
* The causes are stated before the consequences: evidence bound to another artifact first, then
|
|
67
|
+
* the claims that failed outright, then the coverage each rule still lacks. Evidence from another
|
|
68
|
+
* artifact grants nothing — every claim in it was judged against rules this artifact may no longer
|
|
69
|
+
* have, so its failures are discarded with its coverage and the mismatch is stated once. A rule
|
|
70
|
+
* with no evidence entry at all is a gap in its own right: the evidence producer failed to state
|
|
71
|
+
* a rule the artifact carries, which a publisher must not read as coverage.
|
|
72
|
+
*
|
|
73
|
+
* `behaviour` is the artifact's identity the caller already derived, because the evidence was
|
|
74
|
+
* produced against the same artifact: deriving it here again would re-hash every rule for a
|
|
75
|
+
* caller that had to state it to produce the evidence in the first place.
|
|
76
|
+
*/
|
|
77
|
+
export function readinessGaps(schema, evidence, behaviour, origins = []) {
|
|
78
|
+
const gaps = [];
|
|
79
|
+
const behaviorHash = behaviour.behaviorHash;
|
|
80
|
+
const stale = evidence.behaviorHash !== behaviorHash;
|
|
81
|
+
if (stale) {
|
|
82
|
+
gaps.push({
|
|
83
|
+
kind: 'stale_behavior',
|
|
84
|
+
path: '$',
|
|
85
|
+
detail: `the evidence was executed against behaviour ${evidence.behaviorHash}, not this artifact's ${behaviorHash}`,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
gaps.push(...evidence.failures);
|
|
90
|
+
}
|
|
91
|
+
const coverage = new Map(stale ? [] : evidence.coverage.map((entry) => [entry.ruleId, entry]));
|
|
92
|
+
(schema.rules ?? []).forEach((rule, index) => {
|
|
93
|
+
const origin = declaredOriginOf(origins, rule.ruleId);
|
|
94
|
+
const path = evidencePathOf(origins, rule.ruleId, `$.rules[${String(index)}].testCases`);
|
|
95
|
+
const required = requiredBranchesOf(rule);
|
|
96
|
+
const entry = coverage.get(rule.ruleId);
|
|
97
|
+
if (entry === undefined || entry.attempts === 0) {
|
|
98
|
+
gaps.push({
|
|
99
|
+
kind: 'no_evidence',
|
|
100
|
+
ruleId: rule.ruleId,
|
|
101
|
+
path,
|
|
102
|
+
detail: `${declarationSubject(rule, origin)} has no embedded vector and no scenario assertion; ${requirementText(required, rule.kind)}${declarationRepair(origin)}`,
|
|
103
|
+
});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (required.firing && !entry.firing) {
|
|
107
|
+
gaps.push({
|
|
108
|
+
kind: 'no_firing',
|
|
109
|
+
ruleId: rule.ruleId,
|
|
110
|
+
path,
|
|
111
|
+
detail: `${declarationSubject(rule, origin)} has no case where a \`${rule.kind}\` rule fires; requires at least one${declarationRepair(origin)}`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (required.nonFiring && !entry.nonFiring) {
|
|
115
|
+
gaps.push({
|
|
116
|
+
kind: 'no_non_firing',
|
|
117
|
+
ruleId: rule.ruleId,
|
|
118
|
+
path,
|
|
119
|
+
detail: `${declarationSubject(rule, origin)} has no case where a \`${rule.kind}\` rule does not fire; requires at least one${declarationRepair(origin)}`,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return gaps.length === 0 ? { ready: true } : { ready: false, gaps };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The subject of a gap: the rule id, or the declaration that produced it.
|
|
127
|
+
*
|
|
128
|
+
* A generated rule's id is not something the author wrote, so a gap that named only the id would
|
|
129
|
+
* send them looking for a rule that is not in their document. Naming the field and the member is
|
|
130
|
+
* the difference between "go add a test case" and "go find `r_f_note_min_length`".
|
|
131
|
+
*/
|
|
132
|
+
function declarationSubject(rule, origin) {
|
|
133
|
+
if (origin === undefined)
|
|
134
|
+
return `\`${rule.ruleId}\``;
|
|
135
|
+
return `field \`${origin.fieldId}\` declares \`${origin.member}\`, which compiles to rule \`${rule.ruleId}\`, and that rule`;
|
|
136
|
+
}
|
|
137
|
+
/** The member to write, appended to a declaration gap so the repair is one sentence. */
|
|
138
|
+
function declarationRepair(origin) {
|
|
139
|
+
return origin === undefined
|
|
140
|
+
? ''
|
|
141
|
+
: ` — write it in \`${origin.evidenceMember}\` beside \`${origin.member}\``;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The artifact's own vectors, read as declared evidence.
|
|
145
|
+
*
|
|
146
|
+
* This is the evidence `declaredEvidenceOf` folds for a compile: which branches each rule's
|
|
147
|
+
* embedded vectors declare, and which vectors state nothing about the rule that carries them or
|
|
148
|
+
* only that it deferred. Nothing is executed — the vectors are read as claims, which is exactly
|
|
149
|
+
* what a compile that never runs a rule can honestly report.
|
|
150
|
+
*/
|
|
151
|
+
export function embeddedEvidence(schema, behaviour, origins = []) {
|
|
152
|
+
const coverage = [];
|
|
153
|
+
const failures = [];
|
|
154
|
+
(schema.rules ?? []).forEach((rule, index) => {
|
|
155
|
+
const path = evidencePathOf(origins, rule.ruleId, `$.rules[${String(index)}].testCases`);
|
|
156
|
+
const testCases = rule.testCases ?? [];
|
|
157
|
+
let firing = false;
|
|
158
|
+
let nonFiring = false;
|
|
159
|
+
let unreadable = 0;
|
|
160
|
+
let firstUnreadable;
|
|
161
|
+
for (const testCase of testCases) {
|
|
162
|
+
const decoded = observationOfExpected(rule.kind, isRecord(testCase) ? testCase['expected'] : undefined);
|
|
163
|
+
if (!decoded.ok) {
|
|
164
|
+
// A vector that states nothing about its rule is named rather than counted as a case
|
|
165
|
+
// where the rule does not fire: the author wrote evidence that proves nothing. One rule
|
|
166
|
+
// states one reason however many of its vectors are unreadable, as the executed run does.
|
|
167
|
+
unreadable += 1;
|
|
168
|
+
firstUnreadable ??= decoded.detail;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const branch = branchCredit(rule.kind, decoded.observation);
|
|
172
|
+
if (branch.coverageEligible) {
|
|
173
|
+
if (branch.fired)
|
|
174
|
+
firing = true;
|
|
175
|
+
else
|
|
176
|
+
nonFiring = true;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (firstUnreadable !== undefined) {
|
|
180
|
+
failures.push({
|
|
181
|
+
kind: 'unreadable_expectation',
|
|
182
|
+
ruleId: rule.ruleId,
|
|
183
|
+
path,
|
|
184
|
+
detail: unreadable === 1
|
|
185
|
+
? firstUnreadable
|
|
186
|
+
: `${String(unreadable)} cases did not hold; the first is ${firstUnreadable}`,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
coverage.push({
|
|
190
|
+
ruleId: rule.ruleId,
|
|
191
|
+
kind: rule.kind,
|
|
192
|
+
attempts: testCases.length,
|
|
193
|
+
firing,
|
|
194
|
+
nonFiring,
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
return { behaviorHash: behaviour.behaviorHash, coverage, failures };
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* What a compiled artifact's own vectors leave unproven, which is not a publish verdict.
|
|
201
|
+
*
|
|
202
|
+
* The same fold that derives readiness over executed evidence runs here over declarations alone,
|
|
203
|
+
* and only its gaps are reported: the `ready` branch is a statement about evidence that ran, and
|
|
204
|
+
* a compile has none to state. `behaviour` is derived once by the compile and read by both folds.
|
|
205
|
+
*/
|
|
206
|
+
export function declaredEvidenceOf(schema, behaviour, origins = []) {
|
|
207
|
+
const verdict = readinessGaps(schema, embeddedEvidence(schema, behaviour, origins), behaviour, origins);
|
|
208
|
+
return {
|
|
209
|
+
kind: 'declared',
|
|
210
|
+
gaps: verdict.ready ? [] : verdict.gaps.map(declaredGapOf),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* One gap a compile's declared fold can state.
|
|
215
|
+
*
|
|
216
|
+
* The fold returns the verification vocabulary, but a compile executes nothing, so the executed
|
|
217
|
+
* members are unreachable here. Naming them explicitly fails the build if that ever stops being
|
|
218
|
+
* true rather than letting a compile report evidence it never ran.
|
|
219
|
+
*/
|
|
220
|
+
function declaredGapOf(gap) {
|
|
221
|
+
switch (gap.kind) {
|
|
222
|
+
case 'no_evidence':
|
|
223
|
+
case 'no_firing':
|
|
224
|
+
case 'no_non_firing':
|
|
225
|
+
case 'unreadable_expectation':
|
|
226
|
+
return { ...gap, kind: gap.kind };
|
|
227
|
+
case 'failed_vector':
|
|
228
|
+
case 'failed_scenario':
|
|
229
|
+
case 'invalid_suite':
|
|
230
|
+
case 'stale_behavior':
|
|
231
|
+
case 'stale_dataset':
|
|
232
|
+
case 'client_artifact':
|
|
233
|
+
case 'conflicting_environment':
|
|
234
|
+
throw new Error(`declared evidence cannot state the ${gap.kind} gap an executed run reports`);
|
|
235
|
+
default:
|
|
236
|
+
return assertNever(gap.kind);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=readiness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readiness.js","sourceRoot":"","sources":["../../src/publish/readiness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAOpF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAqGzD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AAK,iBAAiB,CAAC;QACvB,KAAK,yBAAyB;YAC5B,MAAM,IAAI,KAAK,CAAC,sCAAsC,GAAG,CAAC,IAAI,8BAA8B,CAAC,CAAC;QAChG;YACE,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;AACH,CAAC","sourcesContent":["import { assertNever, isRecord, unreachableBranchOf } from '@azx-pbc/axiom-runtime';\nimport type {\n ArtifactBehaviour,\n CompiledRule,\n CompiledSchema,\n RuleKind,\n} from '@azx-pbc/axiom-runtime';\nimport { branchCredit } from '../scenarios/branch.js';\nimport { observationOfExpected } from './observation.js';\n\n/**\n * The publisher's one rule, and the evidence it is read against.\n *\n * A rule is ready to publish when evidence proves each branch of its firing table that a record can\n * reach: one case in which the rule fires and one in which it does not\n * (`spec/semantics/rules-v1.md` `RULES-3.1.2`). For the kinds whose outcome is their expression's\n * answer, an expression that folds to a constant boolean makes one branch unreachable, so that\n * branch is not required. This module owns that rule\n * once: `verifyPublishReadiness()` states it over evidence executed against the artifact, and\n * `declaredEvidenceOf()` states what the artifact's own unexecuted vectors declare, because a\n * compile that runs nothing can only report the evidence it was handed.\n *\n * Evidence arrives already judged: which rule each claim was about, whether it proved a firing\n * or a non-firing, and which claims failed outright. Nothing here evaluates a rule or reads a\n * document, so the same fold serves a compile that never runs anything and a verification that\n * ran everything.\n */\n\n/** Why a rule, or the evidence behind it, does not support publishing. */\nexport type PublishGapKind =\n /** Nothing at all was read about the rule: no embedded vector and no scenario assertion. */\n | 'no_evidence'\n /** Evidence exists, but none of it proves the rule fires. */\n | 'no_firing'\n /** Evidence exists, but none of it proves the rule does not fire. */\n | 'no_non_firing'\n /** A vector's `expected` states nothing about the rule that carries it. */\n | 'unreadable_expectation'\n /** An embedded vector was executed and did not hold. */\n | 'failed_vector'\n /** A scenario assertion was executed and did not hold. */\n | 'failed_scenario'\n /** A supplied suite was refused before it could run. */\n | 'invalid_suite'\n /** The evidence was executed against a different artifact. */\n | 'stale_behavior'\n /** A table a vector or suite read could not answer at the version this artifact pins. */\n | 'stale_dataset'\n /**\n * The artifact was compiled for a device. Its server-tier rules are deferred stubs and its\n * embedded cases do not travel, so no evidence can be executed against it.\n */\n | 'client_artifact'\n /**\n * The run and its suites declare environment members that contradict each other, so one\n * report cannot state the environment it judged. Nothing executed.\n */\n | 'conflicting_environment';\n\n/**\n * The gap kinds a compile can state from declarations alone.\n *\n * A compile executes nothing, so it cannot observe a failed case, a refused suite or a lookup\n * that did not resolve. Keeping the declared vocabulary narrower is what stops a compile from\n * reporting executed evidence it never ran.\n */\nexport type DeclaredGapKind =\n | 'no_evidence'\n | 'no_firing'\n | 'no_non_firing'\n | 'unreadable_expectation';\n\n/**\n * The declaration member that carries the evidence for a rule a declaration compiles to.\n *\n * One such rule always has exactly one evidence member — the sibling of the declaration that\n * produced it — so a gap, a builder command and the artifact's `testCases` all name the same\n * place. `minItems`/`maxItems` state a decided fact rather than a rule and carry none.\n */\nexport type DeclarationEvidenceMember =\n | 'requiredTestCases'\n | 'visibleWhenTestCases'\n | 'minimumTestCases'\n | 'maximumTestCases'\n | 'minLengthTestCases'\n | 'maxLengthTestCases';\n\n/**\n * The declaration a compiler-synthesised rule came from.\n *\n * A field declaration compiles to a rule that is part of the artifact and part of this gate\n * (`RULES-3.1.1`), but its id is the compiler's: the author wrote `minLength`, not\n * `r_f_note_min_length`. This origin is what lets a gap name the member the author can repair\n * instead of an id they cannot see. It is authoring metadata and never artifact data, so the\n * artifact a declaration with evidence compiles to stays byte-identical to the hand-written\n * rule's.\n */\nexport interface DeclaredRuleOrigin {\n readonly ruleId: string;\n /** The declaration's document path, `$.fields[1]`. */\n readonly path: string;\n /** The field the declaration belongs to, `f_note`. */\n readonly fieldId: string;\n /** The declaration member that compiles to the rule, `required`, `requiredWhen`, `minLength`. */\n readonly member: string;\n /** The sibling member that carries the rule's evidence, `requiredTestCases`, `minLengthTestCases`. */\n readonly evidenceMember: DeclarationEvidenceMember;\n}\n\n/**\n * The member that carries one rule's evidence: the declaration's sibling when a declaration\n * produced the rule, else the caller's own fallback.\n *\n * A gap about a generated rule must send the author to the member they can edit\n * (`$.fields[1].minLengthTestCases`), never to an artifact slot the compiler filled.\n */\nexport function evidencePathOf(\n origins: readonly DeclaredRuleOrigin[],\n ruleId: string,\n fallback: string,\n): string {\n const origin = declaredOriginOf(origins, ruleId);\n return origin === undefined ? fallback : `${origin.path}.${origin.evidenceMember}`;\n}\n\n/**\n * The declaration one compiler-synthesised rule came from.\n *\n * One rule is produced by one declaration. A later entry wins over an earlier one for the same id,\n * so a caller that restates a rule states the origin it means.\n */\nfunction declaredOriginOf(\n origins: readonly DeclaredRuleOrigin[],\n ruleId: string,\n): DeclaredRuleOrigin | undefined {\n for (let index = origins.length - 1; index >= 0; index -= 1) {\n const origin = origins[index];\n if (origin !== undefined && origin.ruleId === ruleId) return origin;\n }\n return undefined;\n}\n\n/** One reason a schema is not ready to publish. */\nexport interface PublishGap {\n readonly kind: PublishGapKind;\n /** The rule the gap is about; absent from a gap about the evidence's identity. */\n readonly ruleId?: string;\n /**\n * Where to look. A gap about a hand-written rule names its vector member,\n * `$.rules[n].testCases`; a gap about a rule a declaration compiled names the declaration's\n * evidence member, `$.fields[n].minLengthTestCases`, because that is the member the author\n * wrote. A gap a verification reports about an executed suite names its place in that run,\n * `$.suites[n].scenarios[m]`, because the suite is the caller's document rather than this one.\n */\n readonly path: string;\n readonly detail: string;\n}\n\n/** One reason a compile's declared vectors do not prove every reachable branch. */\nexport type DeclaredGap = PublishGap & { readonly kind: DeclaredGapKind };\n\n/**\n * Whether the artifact carries the evidence publishing requires.\n *\n * Readiness is a verdict about the artifact, not a reason to refuse one: a schema may be\n * compiled and evaluated in a preview while it is still missing a case, and the operator who\n * publishes it is the one who must be told. Only `verifyPublishReadiness()` derives it, from\n * evidence a run executed; `axiom-cli test` reports it.\n */\nexport type PublishReadiness =\n | { readonly ready: true }\n | { readonly ready: false; readonly gaps: readonly PublishGap[] };\n\n/**\n * What one artifact's declared vectors leave unproven, which is never a publish verdict.\n *\n * A compile executes nothing, so it cannot report that a rule is ready: a vector that passes on\n * paper has not run, and a suite that would cover the rule was never supplied. This names the\n * branches the embedded vectors leave, so an author reads the same `kind`/`path`/`detail` a\n * verification would report — and there is no `ready` member to mistake for one. The `kind`\n * discriminant says what this is, so the value cannot be handed to a consumer that states a\n * verdict; its gap vocabulary is the declared one, so it cannot name a case nobody ran.\n */\nexport interface DeclaredEvidence {\n readonly kind: 'declared';\n /** The branches the declared vectors leave unproven, one reason per rule at most per branch. */\n readonly gaps: readonly DeclaredGap[];\n}\n\n/**\n * The branches of a rule's firing table a record can reach, and so the branches publishing needs.\n *\n * Where an expression folds to one constant answer, the branch it cannot take is not something a\n * case can state (`unreachableBranchOf`).\n */\ninterface RequiredBranches {\n readonly firing: boolean;\n readonly nonFiring: boolean;\n}\n\n/** The branches one rule's expression admits, in the order a gap names them. */\nfunction requiredBranchesOf(rule: CompiledRule): RequiredBranches {\n const unreachable = unreachableBranchOf(rule);\n return { firing: unreachable !== 'firing', nonFiring: unreachable !== 'non_firing' };\n}\n\n/** The outcome that counts as one rule kind firing, in the words a gap can quote. */\nfunction firingOutcomeText(kind: RuleKind): string {\n switch (kind) {\n case 'validate':\n case 'gate':\n return `a ${kind} rule fires FAIL`;\n case 'visible':\n case 'required':\n case 'enabled':\n return `${kind === 'enabled' ? 'an' : 'a'} ${kind} rule fires PASS`;\n case 'screen':\n return 'a screen rule fires SCREEN_FAIL or SCREEN_REFER';\n case 'compute':\n case 'defaultCompute':\n return `a ${kind} rule fires on the value it produces`;\n default:\n return assertNever(kind);\n }\n}\n\n/** The evidence a rule needs, in the words a gap uses to ask for it. */\nfunction requirementText(required: RequiredBranches, kind: RuleKind): string {\n const firing = `(${firingOutcomeText(kind)})`;\n if (required.firing && required.nonFiring) {\n return `requires one firing and one non-firing case to publish ${firing}`;\n }\n return required.firing\n ? `requires one firing case to publish ${firing}`\n : `requires one non-firing case to publish ${firing}`;\n}\n\n/**\n * What one rule's evidence proved.\n *\n * `attempts` counts the claims that were read about the rule, so a rule nobody asserted is told\n * apart from one whose claims all proved nothing: the first needs a case written, the second has\n * cases that are not evidence.\n */\nexport interface RuleCoverage {\n readonly ruleId: string;\n readonly kind: RuleKind;\n readonly attempts: number;\n readonly firing: boolean;\n readonly nonFiring: boolean;\n}\n\n/** The judged evidence one verdict is derived from. */\nexport interface PublishEvidence {\n /** The artifact the evidence was executed against, `artifactBehaviour(compiled)`. */\n readonly behaviorHash: string;\n /** One entry per rule of the artifact the evidence was about. */\n readonly coverage: readonly RuleCoverage[];\n /** Claims that failed outright, each already carrying its own location and kind. */\n readonly failures: readonly PublishGap[];\n}\n\n/**\n * Derives the verdict from evidence, or names every reason it is not ready.\n *\n * The causes are stated before the consequences: evidence bound to another artifact first, then\n * the claims that failed outright, then the coverage each rule still lacks. Evidence from another\n * artifact grants nothing — every claim in it was judged against rules this artifact may no longer\n * have, so its failures are discarded with its coverage and the mismatch is stated once. A rule\n * with no evidence entry at all is a gap in its own right: the evidence producer failed to state\n * a rule the artifact carries, which a publisher must not read as coverage.\n *\n * `behaviour` is the artifact's identity the caller already derived, because the evidence was\n * produced against the same artifact: deriving it here again would re-hash every rule for a\n * caller that had to state it to produce the evidence in the first place.\n */\nexport function readinessGaps(\n schema: CompiledSchema,\n evidence: PublishEvidence,\n behaviour: ArtifactBehaviour,\n origins: readonly DeclaredRuleOrigin[] = [],\n): PublishReadiness {\n const gaps: PublishGap[] = [];\n const behaviorHash = behaviour.behaviorHash;\n const stale = evidence.behaviorHash !== behaviorHash;\n if (stale) {\n gaps.push({\n kind: 'stale_behavior',\n path: '$',\n detail: `the evidence was executed against behaviour ${evidence.behaviorHash}, not this artifact's ${behaviorHash}`,\n });\n } else {\n gaps.push(...evidence.failures);\n }\n const coverage = new Map(stale ? [] : evidence.coverage.map((entry) => [entry.ruleId, entry]));\n (schema.rules ?? []).forEach((rule, index) => {\n const origin = declaredOriginOf(origins, rule.ruleId);\n const path = evidencePathOf(origins, rule.ruleId, `$.rules[${String(index)}].testCases`);\n const required = requiredBranchesOf(rule);\n const entry = coverage.get(rule.ruleId);\n if (entry === undefined || entry.attempts === 0) {\n gaps.push({\n kind: 'no_evidence',\n ruleId: rule.ruleId,\n path,\n detail: `${declarationSubject(rule, origin)} has no embedded vector and no scenario assertion; ${requirementText(required, rule.kind)}${declarationRepair(origin)}`,\n });\n return;\n }\n if (required.firing && !entry.firing) {\n gaps.push({\n kind: 'no_firing',\n ruleId: rule.ruleId,\n path,\n detail: `${declarationSubject(rule, origin)} has no case where a \\`${rule.kind}\\` rule fires; requires at least one${declarationRepair(origin)}`,\n });\n }\n if (required.nonFiring && !entry.nonFiring) {\n gaps.push({\n kind: 'no_non_firing',\n ruleId: rule.ruleId,\n path,\n detail: `${declarationSubject(rule, origin)} has no case where a \\`${rule.kind}\\` rule does not fire; requires at least one${declarationRepair(origin)}`,\n });\n }\n });\n return gaps.length === 0 ? { ready: true } : { ready: false, gaps };\n}\n\n/**\n * The subject of a gap: the rule id, or the declaration that produced it.\n *\n * A generated rule's id is not something the author wrote, so a gap that named only the id would\n * send them looking for a rule that is not in their document. Naming the field and the member is\n * the difference between \"go add a test case\" and \"go find `r_f_note_min_length`\".\n */\nfunction declarationSubject(rule: CompiledRule, origin: DeclaredRuleOrigin | undefined): string {\n if (origin === undefined) return `\\`${rule.ruleId}\\``;\n return `field \\`${origin.fieldId}\\` declares \\`${origin.member}\\`, which compiles to rule \\`${rule.ruleId}\\`, and that rule`;\n}\n\n/** The member to write, appended to a declaration gap so the repair is one sentence. */\nfunction declarationRepair(origin: DeclaredRuleOrigin | undefined): string {\n return origin === undefined\n ? ''\n : ` — write it in \\`${origin.evidenceMember}\\` beside \\`${origin.member}\\``;\n}\n\n/**\n * The artifact's own vectors, read as declared evidence.\n *\n * This is the evidence `declaredEvidenceOf` folds for a compile: which branches each rule's\n * embedded vectors declare, and which vectors state nothing about the rule that carries them or\n * only that it deferred. Nothing is executed — the vectors are read as claims, which is exactly\n * what a compile that never runs a rule can honestly report.\n */\nexport function embeddedEvidence(\n schema: CompiledSchema,\n behaviour: ArtifactBehaviour,\n origins: readonly DeclaredRuleOrigin[] = [],\n): PublishEvidence {\n const coverage: RuleCoverage[] = [];\n const failures: PublishGap[] = [];\n (schema.rules ?? []).forEach((rule, index) => {\n const path = evidencePathOf(origins, rule.ruleId, `$.rules[${String(index)}].testCases`);\n const testCases = rule.testCases ?? [];\n let firing = false;\n let nonFiring = false;\n let unreadable = 0;\n let firstUnreadable: string | undefined;\n for (const testCase of testCases) {\n const decoded = observationOfExpected(\n rule.kind,\n isRecord(testCase) ? testCase['expected'] : undefined,\n );\n if (!decoded.ok) {\n // A vector that states nothing about its rule is named rather than counted as a case\n // where the rule does not fire: the author wrote evidence that proves nothing. One rule\n // states one reason however many of its vectors are unreadable, as the executed run does.\n unreadable += 1;\n firstUnreadable ??= decoded.detail;\n continue;\n }\n const branch = branchCredit(rule.kind, decoded.observation);\n if (branch.coverageEligible) {\n if (branch.fired) firing = true;\n else nonFiring = true;\n }\n }\n if (firstUnreadable !== undefined) {\n failures.push({\n kind: 'unreadable_expectation',\n ruleId: rule.ruleId,\n path,\n detail:\n unreadable === 1\n ? firstUnreadable\n : `${String(unreadable)} cases did not hold; the first is ${firstUnreadable}`,\n });\n }\n coverage.push({\n ruleId: rule.ruleId,\n kind: rule.kind,\n attempts: testCases.length,\n firing,\n nonFiring,\n });\n });\n return { behaviorHash: behaviour.behaviorHash, coverage, failures };\n}\n\n/**\n * What a compiled artifact's own vectors leave unproven, which is not a publish verdict.\n *\n * The same fold that derives readiness over executed evidence runs here over declarations alone,\n * and only its gaps are reported: the `ready` branch is a statement about evidence that ran, and\n * a compile has none to state. `behaviour` is derived once by the compile and read by both folds.\n */\nexport function declaredEvidenceOf(\n schema: CompiledSchema,\n behaviour: ArtifactBehaviour,\n origins: readonly DeclaredRuleOrigin[] = [],\n): DeclaredEvidence {\n const verdict = readinessGaps(\n schema,\n embeddedEvidence(schema, behaviour, origins),\n behaviour,\n origins,\n );\n return {\n kind: 'declared',\n gaps: verdict.ready ? [] : verdict.gaps.map(declaredGapOf),\n };\n}\n\n/**\n * One gap a compile's declared fold can state.\n *\n * The fold returns the verification vocabulary, but a compile executes nothing, so the executed\n * members are unreachable here. Naming them explicitly fails the build if that ever stops being\n * true rather than letting a compile report evidence it never ran.\n */\nfunction declaredGapOf(gap: PublishGap): DeclaredGap {\n switch (gap.kind) {\n case 'no_evidence':\n case 'no_firing':\n case 'no_non_firing':\n case 'unreadable_expectation':\n return { ...gap, kind: gap.kind };\n case 'failed_vector':\n case 'failed_scenario':\n case 'invalid_suite':\n case 'stale_behavior':\n case 'stale_dataset':\n case 'client_artifact':\n case 'conflicting_environment':\n throw new Error(`declared evidence cannot state the ${gap.kind} gap an executed run reports`);\n default:\n return assertNever(gap.kind);\n }\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { CompiledSchema, EvaluationEnv } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import type { BranchCredit } from '../scenarios/branch.js';
|
|
3
|
+
import type { CommittedEnvironment } from '../scenarios/environment.js';
|
|
4
|
+
/** Whether one case's claim held, and what the run observed when it did not. */
|
|
5
|
+
export type VectorVerdict = {
|
|
6
|
+
readonly ok: true;
|
|
7
|
+
/** What the observation is worth as evidence, decided by the one credit predicate. */
|
|
8
|
+
readonly credit: BranchCredit;
|
|
9
|
+
} | {
|
|
10
|
+
readonly ok: false;
|
|
11
|
+
/**
|
|
12
|
+
* The one gap kind a failed case states: a case that ran and did not hold, a case whose
|
|
13
|
+
* expectation states nothing about the rule that carries it, or a case that was judged
|
|
14
|
+
* against a table version this artifact pins and the table could not answer.
|
|
15
|
+
*/
|
|
16
|
+
readonly kind: 'failed_vector' | 'unreadable_expectation' | 'stale_dataset';
|
|
17
|
+
readonly detail: string;
|
|
18
|
+
/** The lines an author reads to repair the case: absent operands, then the rule's diagnostics. */
|
|
19
|
+
readonly explanation: readonly string[];
|
|
20
|
+
};
|
|
21
|
+
/** One embedded vector, judged against one evaluation of the artifact. */
|
|
22
|
+
export interface EmbeddedVector {
|
|
23
|
+
readonly ruleId: string;
|
|
24
|
+
/** The member the vector was read from, so a failure names its location in the artifact. */
|
|
25
|
+
readonly path: string;
|
|
26
|
+
/** The vector's one-based position in its rule's `testCases`. */
|
|
27
|
+
readonly position: number;
|
|
28
|
+
/** The case id the vector declares; absent only when the vector was not readable at all. */
|
|
29
|
+
readonly caseId?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The environment this case actually evaluated under, after its own `tier`, `recordDate` and
|
|
32
|
+
* `capabilities` overrode the run baseline. Absent only when the vector was not readable.
|
|
33
|
+
*/
|
|
34
|
+
readonly environment?: CommittedEnvironment;
|
|
35
|
+
readonly verdict: VectorVerdict;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Runs every vector the artifact embeds, in artifact order.
|
|
39
|
+
*
|
|
40
|
+
* A vector that cannot run and a vector that ran and did not hold are the same fact for the
|
|
41
|
+
* publisher — the rule has no evidence — so both are reported as a failed verdict carrying the
|
|
42
|
+
* reason. A vector whose rule read a table that could not answer is reported as the stale case it
|
|
43
|
+
* is: the comparison may pass, but the evidence was judged against data the artifact does not
|
|
44
|
+
* hold, so it grants no credit and names the case rather than folding it into "not firing".
|
|
45
|
+
*
|
|
46
|
+
* `env` is the caller's baseline; a case's own `tier`, `capabilities` and `recordDate` override it
|
|
47
|
+
* member by member.
|
|
48
|
+
*/
|
|
49
|
+
export declare function runEmbeddedVectors(schema: CompiledSchema, env: EvaluationEnv): readonly EmbeddedVector[];
|
|
50
|
+
//# sourceMappingURL=vectors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vectors.d.ts","sourceRoot":"","sources":["../../src/publish/vectors.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAGV,cAAc,EACd,aAAa,EAOd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AA8BxE,gFAAgF;AAChF,MAAM,MAAM,aAAa,GACrB;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,sFAAsF;IACtF,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,wBAAwB,GAAG,eAAe,CAAC;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,kGAAkG;IAClG,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAEN,0EAA0E;AAC1E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,4FAA4F;IAC5F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,4FAA4F;IAC5F,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,oBAAoB,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;CACjC;AAqND;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,aAAa,GACjB,SAAS,cAAc,EAAE,CA0F3B"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { AxiomError, assertNever, DATASET_BUILTINS, DEFAULT_EVIDENCE_TIER, evaluateForm, isRecord, toEvaluationEnv, toEvaluationInput, } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import { branchCredit } from '../scenarios/branch.js';
|
|
3
|
+
import { overrideKeptValue } from '../scenarios/credit.js';
|
|
4
|
+
import { normalizeEnvironment } from '../scenarios/environment.js';
|
|
5
|
+
import { compareObservation } from '../scenarios/expectations.js';
|
|
6
|
+
import { observationOfExpected } from './observation.js';
|
|
7
|
+
/**
|
|
8
|
+
* Reads one embedded vector.
|
|
9
|
+
*
|
|
10
|
+
* The artifact's closed metaschema already proved the vector's shape, so the request readers
|
|
11
|
+
* that own the input and environment contracts are the whole boundary parse: a case is the
|
|
12
|
+
* input and the environment `toEvaluationInput`/`toEvaluationEnv` admit, and nothing here
|
|
13
|
+
* re-asserts a member those readers validate. A vector either reader refuses is reported
|
|
14
|
+
* with the cause it gave, so a malformed date or reference is named rather than skipped.
|
|
15
|
+
*/
|
|
16
|
+
function readTestCase(value) {
|
|
17
|
+
if (!isRecord(value))
|
|
18
|
+
return { ok: false, detail: 'a test case must be an object' };
|
|
19
|
+
const caseId = value['caseId'];
|
|
20
|
+
if (typeof caseId !== 'string')
|
|
21
|
+
return { ok: false, detail: 'a test case declares a caseId' };
|
|
22
|
+
try {
|
|
23
|
+
// A case may declare the environment it runs under. Absent members leave the caller's
|
|
24
|
+
// baseline untouched, so a vector written before the member existed runs unchanged.
|
|
25
|
+
const input = toEvaluationInput({
|
|
26
|
+
values: value['values'],
|
|
27
|
+
...(value['context'] === undefined ? {} : { context: value['context'] }),
|
|
28
|
+
...(value['redacted'] === undefined ? {} : { redacted: value['redacted'] }),
|
|
29
|
+
...(value['sessionWrites'] === undefined ? {} : { sessionWrites: value['sessionWrites'] }),
|
|
30
|
+
...(value['accessOverlay'] === undefined ? {} : { overlay: value['accessOverlay'] }),
|
|
31
|
+
});
|
|
32
|
+
const env = toEvaluationEnv({
|
|
33
|
+
...(value['capabilities'] === undefined ? {} : { capabilities: value['capabilities'] }),
|
|
34
|
+
...(value['recordDate'] === undefined ? {} : { recordDate: value['recordDate'] }),
|
|
35
|
+
...(value['tier'] === undefined ? {} : { tier: value['tier'] }),
|
|
36
|
+
});
|
|
37
|
+
return { ok: true, testCase: { caseId, expected: value['expected'], input, env } };
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (!(error instanceof AxiomError))
|
|
41
|
+
throw error;
|
|
42
|
+
return { ok: false, detail: `${error.path ?? '$'}: ${error.message}` };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Whether one case's expectation held, and what its observation is worth as evidence.
|
|
47
|
+
*
|
|
48
|
+
* The comparison is the one `compareObservation` a scenario assertion also uses, so a screen
|
|
49
|
+
* section, a row fold and a produced value are read identically down both paths. Credit is the
|
|
50
|
+
* one `branchCredit` the suite classifier also reads, so a deferral that proves nothing is
|
|
51
|
+
* reported the same way here as it is there — and a `defaultCompute` whose stored value an
|
|
52
|
+
* override kept earns nothing, exactly as the suite path refuses it.
|
|
53
|
+
*/
|
|
54
|
+
function verdictOf(compiledRule, rule, results, report, expected, computed) {
|
|
55
|
+
const decoded = observationOfExpected(rule.kind, expected);
|
|
56
|
+
if (!decoded.ok) {
|
|
57
|
+
return { ok: false, kind: 'unreadable_expectation', detail: decoded.detail, explanation: [] };
|
|
58
|
+
}
|
|
59
|
+
const observation = decoded.observation;
|
|
60
|
+
const compared = compareObservation(rule.ruleId, { kind: rule.kind, results, screen: report.screens?.[rule.ruleId]?.outcome }, observation);
|
|
61
|
+
if (compared !== undefined) {
|
|
62
|
+
return { ok: false, kind: 'failed_vector', detail: compared, explanation: [] };
|
|
63
|
+
}
|
|
64
|
+
// A retained stored value is the record's, not the writer's: the case agrees with the record
|
|
65
|
+
// rather than proving the rule produced what it states. The suite path states the same refusal.
|
|
66
|
+
if (overrideKeptValue(compiledRule, results, computed)) {
|
|
67
|
+
return { ok: true, credit: { coverageEligible: false, refusal: 'override' } };
|
|
68
|
+
}
|
|
69
|
+
return { ok: true, credit: branchCredit(rule.kind, observation) };
|
|
70
|
+
}
|
|
71
|
+
/** The field ids a case supplies at the top level; a record member travels inside its container. */
|
|
72
|
+
function suppliedFieldIds(testCase) {
|
|
73
|
+
return new Set(Object.keys(testCase.input.values));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Each declared field's top-level ancestor, so a nested or row member counts as supplied when
|
|
77
|
+
* the case supplies the container it travels inside.
|
|
78
|
+
*/
|
|
79
|
+
function topLevelAncestors(fields) {
|
|
80
|
+
const ancestors = new Map();
|
|
81
|
+
const visit = (declarations, root) => {
|
|
82
|
+
for (const field of declarations) {
|
|
83
|
+
const container = root ?? field.fieldId;
|
|
84
|
+
ancestors.set(field.fieldId, container);
|
|
85
|
+
if (field.fields !== undefined)
|
|
86
|
+
visit(field.fields, container);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
visit(fields, undefined);
|
|
90
|
+
return ancestors;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Why a case could not decide: the operands it never supplied, then the rule's own diagnostics.
|
|
94
|
+
*
|
|
95
|
+
* The verdict alone says "expected PASS, observed UNKNOWN", which could be any undecided operand.
|
|
96
|
+
* The result already names the fields the rule read, so the one line an author needs is the field
|
|
97
|
+
* the case left out; a diagnostic the rule raised says the rest. A nested field counts as supplied
|
|
98
|
+
* when its container is, because the case carries record and row members inside the container
|
|
99
|
+
* rather than as flat keys.
|
|
100
|
+
*/
|
|
101
|
+
function explanationLines(result, testCase, report, ruleId, ancestors) {
|
|
102
|
+
const lines = [];
|
|
103
|
+
const supplied = suppliedFieldIds(testCase);
|
|
104
|
+
const absent = new Set();
|
|
105
|
+
for (const field of result.fields ?? []) {
|
|
106
|
+
const container = ancestors.get(field.fieldId) ?? field.fieldId;
|
|
107
|
+
if (!supplied.has(container))
|
|
108
|
+
absent.add(field.fieldId);
|
|
109
|
+
}
|
|
110
|
+
if (absent.size > 0) {
|
|
111
|
+
lines.push(` the case supplies no value for ${[...absent].map((fieldId) => `\`${fieldId}\``).join(', ')}, which the rule reads`);
|
|
112
|
+
}
|
|
113
|
+
for (const diagnostic of report.diagnostics) {
|
|
114
|
+
if (diagnostic.ruleId !== ruleId)
|
|
115
|
+
continue;
|
|
116
|
+
const field = diagnostic.fieldId === undefined ? '' : ` on \`${diagnostic.fieldId}\``;
|
|
117
|
+
lines.push(` diagnostic ${diagnostic.code}${field}`);
|
|
118
|
+
}
|
|
119
|
+
return lines;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* A table this rule's own expression names and a lookup that could not answer, or `undefined`.
|
|
123
|
+
*
|
|
124
|
+
* A report's `lookups` are the whole evaluation's, not one rule's, and a form evaluates every
|
|
125
|
+
* rule for every vector. Crediting a rule with another rule's stale table would name a case that
|
|
126
|
+
* never read it, so the table has to be one this rule's own expressions name. A rule that reads a
|
|
127
|
+
* stale table through a computed member decides `UNKNOWN` from it, which the branch table already
|
|
128
|
+
* refuses; this answers the direct operand, which is the one a report can name.
|
|
129
|
+
*/
|
|
130
|
+
function staleLookupOf(rule, report) {
|
|
131
|
+
const stale = report.lookups.filter(isStaleLookup);
|
|
132
|
+
if (stale.length === 0)
|
|
133
|
+
return undefined;
|
|
134
|
+
const named = datasetTablesOf(rule);
|
|
135
|
+
return stale.find((entry) => named.has(entry.tableId));
|
|
136
|
+
}
|
|
137
|
+
/** Whether a report's lookup entry states a table that could not answer. */
|
|
138
|
+
function isStaleLookup(entry) {
|
|
139
|
+
return 'reason' in entry;
|
|
140
|
+
}
|
|
141
|
+
/** Every expression slot of one rule, including the items and reasons a composing kind carries. */
|
|
142
|
+
function ruleExpressionsOf(rule) {
|
|
143
|
+
return [
|
|
144
|
+
rule.expr,
|
|
145
|
+
...(rule.referWhen === undefined ? [] : [rule.referWhen]),
|
|
146
|
+
...Object.values(rule.params ?? {}),
|
|
147
|
+
...(rule.kind === 'screen' ? (rule.reasons ?? []).map((reason) => reason.when) : []),
|
|
148
|
+
...(rule.gate?.activeWhen === undefined ? [] : [rule.gate.activeWhen]),
|
|
149
|
+
...(rule.gate?.items ?? []).flatMap((item) => [item.expr, ...Object.values(item.params ?? {})]),
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
/** Every table id the dataset built-ins of one rule's expressions name. */
|
|
153
|
+
function datasetTablesOf(rule) {
|
|
154
|
+
const tables = new Set();
|
|
155
|
+
const visit = (node) => {
|
|
156
|
+
switch (node.kind) {
|
|
157
|
+
case 'literal':
|
|
158
|
+
case 'path':
|
|
159
|
+
return;
|
|
160
|
+
case 'list':
|
|
161
|
+
for (const item of node.items)
|
|
162
|
+
visit(item);
|
|
163
|
+
return;
|
|
164
|
+
case 'and':
|
|
165
|
+
case 'or':
|
|
166
|
+
case 'coalesce':
|
|
167
|
+
for (const arg of node.args)
|
|
168
|
+
visit(arg);
|
|
169
|
+
return;
|
|
170
|
+
case 'not':
|
|
171
|
+
visit(node.args[0]);
|
|
172
|
+
return;
|
|
173
|
+
case 'compare':
|
|
174
|
+
visit(node.args[0]);
|
|
175
|
+
visit(node.args[1]);
|
|
176
|
+
return;
|
|
177
|
+
case 'if':
|
|
178
|
+
for (const arg of node.args)
|
|
179
|
+
visit(arg);
|
|
180
|
+
return;
|
|
181
|
+
case 'call': {
|
|
182
|
+
const table = node.args[0];
|
|
183
|
+
if (DATASET_BUILTINS.has(node.op) && table !== undefined && table.kind === 'path') {
|
|
184
|
+
tables.add(table.path);
|
|
185
|
+
}
|
|
186
|
+
for (const arg of node.args)
|
|
187
|
+
visit(arg);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
case 'comprehension':
|
|
191
|
+
visit(node.source);
|
|
192
|
+
if (node.valueExpr !== undefined)
|
|
193
|
+
visit(node.valueExpr);
|
|
194
|
+
if (node.predicate !== undefined)
|
|
195
|
+
visit(node.predicate);
|
|
196
|
+
return;
|
|
197
|
+
default:
|
|
198
|
+
return assertNever(node);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
for (const expression of ruleExpressionsOf(rule))
|
|
202
|
+
visit(expression);
|
|
203
|
+
return tables;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Runs every vector the artifact embeds, in artifact order.
|
|
207
|
+
*
|
|
208
|
+
* A vector that cannot run and a vector that ran and did not hold are the same fact for the
|
|
209
|
+
* publisher — the rule has no evidence — so both are reported as a failed verdict carrying the
|
|
210
|
+
* reason. A vector whose rule read a table that could not answer is reported as the stale case it
|
|
211
|
+
* is: the comparison may pass, but the evidence was judged against data the artifact does not
|
|
212
|
+
* hold, so it grants no credit and names the case rather than folding it into "not firing".
|
|
213
|
+
*
|
|
214
|
+
* `env` is the caller's baseline; a case's own `tier`, `capabilities` and `recordDate` override it
|
|
215
|
+
* member by member.
|
|
216
|
+
*/
|
|
217
|
+
export function runEmbeddedVectors(schema, env) {
|
|
218
|
+
const ancestors = topLevelAncestors(schema.fields ?? []);
|
|
219
|
+
const vectors = [];
|
|
220
|
+
for (const [index, rule] of (schema.rules ?? []).entries()) {
|
|
221
|
+
const path = `$.rules[${String(index)}].testCases`;
|
|
222
|
+
for (const [position, entry] of (rule.testCases ?? []).entries()) {
|
|
223
|
+
const location = { ruleId: rule.ruleId, path, position: position + 1 };
|
|
224
|
+
const read = readTestCase(entry);
|
|
225
|
+
if (!read.ok) {
|
|
226
|
+
vectors.push({
|
|
227
|
+
...location,
|
|
228
|
+
verdict: {
|
|
229
|
+
ok: false,
|
|
230
|
+
kind: 'failed_vector',
|
|
231
|
+
detail: `the vector is not a readable test case: ${read.detail}`,
|
|
232
|
+
explanation: [],
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
const testCase = read.testCase;
|
|
238
|
+
// The case's own members win over the baseline; this is the evidence door, so an omitted
|
|
239
|
+
// tier is the evidence default rather than the local evaluation default.
|
|
240
|
+
const inherited = { ...env, ...testCase.env };
|
|
241
|
+
const evaluated = {
|
|
242
|
+
...inherited,
|
|
243
|
+
tier: inherited.tier ?? DEFAULT_EVIDENCE_TIER,
|
|
244
|
+
};
|
|
245
|
+
const environment = normalizeEnvironment(evaluated);
|
|
246
|
+
const where = { ...location, caseId: testCase.caseId, environment };
|
|
247
|
+
const snapshot = evaluateForm(schema, testCase.input, evaluated);
|
|
248
|
+
const report = snapshot.report;
|
|
249
|
+
const results = report.rules.filter((result) => result.ruleId === rule.ruleId);
|
|
250
|
+
// An expression that raised reports `UNKNOWN`, which is also what a designed undetermined
|
|
251
|
+
// input reports. A case that matched on `UNKNOWN` alone would record a broken rule as
|
|
252
|
+
// working behaviour, so the raised diagnostic decides it.
|
|
253
|
+
const raised = report.diagnostics.some((diagnostic) => diagnostic.code === 'ENGINE_ERROR' && diagnostic.ruleId === rule.ruleId);
|
|
254
|
+
if (raised) {
|
|
255
|
+
vectors.push({
|
|
256
|
+
...where,
|
|
257
|
+
verdict: {
|
|
258
|
+
ok: false,
|
|
259
|
+
kind: 'failed_vector',
|
|
260
|
+
detail: 'the rule raised ENGINE_ERROR, so the case proves nothing',
|
|
261
|
+
explanation: [],
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
const stale = staleLookupOf(rule, report);
|
|
267
|
+
if (stale !== undefined) {
|
|
268
|
+
vectors.push({
|
|
269
|
+
...where,
|
|
270
|
+
verdict: {
|
|
271
|
+
ok: false,
|
|
272
|
+
kind: 'stale_dataset',
|
|
273
|
+
detail: `table \`${stale.tableId}\` could not answer at the pinned version (${stale.reason})`,
|
|
274
|
+
explanation: [],
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
const [first] = results;
|
|
280
|
+
if (first === undefined) {
|
|
281
|
+
vectors.push({
|
|
282
|
+
...where,
|
|
283
|
+
verdict: {
|
|
284
|
+
ok: false,
|
|
285
|
+
kind: 'failed_vector',
|
|
286
|
+
detail: 'the record produced no result for this rule',
|
|
287
|
+
explanation: [],
|
|
288
|
+
},
|
|
289
|
+
});
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
const verdict = verdictOf(rule, first, results, report, testCase.expected, snapshot.computed);
|
|
293
|
+
vectors.push({
|
|
294
|
+
...where,
|
|
295
|
+
verdict: verdict.ok
|
|
296
|
+
? verdict
|
|
297
|
+
: {
|
|
298
|
+
...verdict,
|
|
299
|
+
explanation: explanationLines(first, testCase, report, rule.ruleId, ancestors),
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return vectors;
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=vectors.js.map
|