@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.
- 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,238 @@
|
|
|
1
|
+
import { isRuleKind, RULE_KINDS } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import { closestNames } from '../expr/suggest.js';
|
|
3
|
+
import { gateFoldDetail } from '../expr/typecheck/gate-folds.js';
|
|
4
|
+
import { argumentsOf, selectBranches } from '../messages/compile.js';
|
|
5
|
+
import { messageKeyUses } from '../messages/slots.js';
|
|
6
|
+
import { refuse } from './compilation.js';
|
|
7
|
+
import { bindsArtifactVersion, describeTargets, digestTargets, hashComparisons, sameTargets, } from './hashes.js';
|
|
8
|
+
import { crossCheckOptionCodes } from './option-codes.js';
|
|
9
|
+
import { noBlockingKinds, ruleReferences, ruleReferenceUses, stepFoldCalls } from './references.js';
|
|
10
|
+
/** The rule kinds `rule_ok` and `no_blocking` may appear in. */
|
|
11
|
+
const GATE_KIND = 'gate';
|
|
12
|
+
/** The message entries one message key declares, in every locale. */
|
|
13
|
+
function compiledMessages(compilation, key) {
|
|
14
|
+
const entry = Object.hasOwn(compilation.messages, key) ? compilation.messages[key] : undefined;
|
|
15
|
+
if (entry === undefined)
|
|
16
|
+
return [];
|
|
17
|
+
return Object.values(entry).flatMap((value) => (typeof value === 'string' ? [] : [value]));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A `digest(...)` that verifies a stored signature must bind the targets that signature
|
|
21
|
+
* declares.
|
|
22
|
+
*
|
|
23
|
+
* The artifact states a signature's coverage once, on the mandatory `covers` list of the
|
|
24
|
+
* `signature_capture` field, and the expression that checks a stored signature recomputes the
|
|
25
|
+
* same binding. A list that names other targets would let a signature verify over values the
|
|
26
|
+
* artifact does not say it covers, so a `digest` and a read of a signature's `dataHash` in
|
|
27
|
+
* one slot are compared here. A signature field carries no coverage only in an artifact this
|
|
28
|
+
* compiler did not produce, and that too is refused rather than skipped. A `digest` in a slot
|
|
29
|
+
* that reads no signature is not a signature's coverage, and is left to its own rule.
|
|
30
|
+
*/
|
|
31
|
+
function crossCheckSignatureCoverage(compilation, path, node) {
|
|
32
|
+
const comparisons = hashComparisons(node);
|
|
33
|
+
if (comparisons.length === 0)
|
|
34
|
+
return;
|
|
35
|
+
// One refusal per signature, not per comparison: two bad comparisons for one signer state
|
|
36
|
+
// one defect.
|
|
37
|
+
const reported = new Set();
|
|
38
|
+
for (const { digest, signer } of comparisons) {
|
|
39
|
+
if (reported.has(signer))
|
|
40
|
+
continue;
|
|
41
|
+
const covers = compilation.signatureCovers.get(signer);
|
|
42
|
+
if (covers === undefined) {
|
|
43
|
+
// Unreachable for a document this compiler admitted: `covers` is mandatory on every
|
|
44
|
+
// `signature_capture`, and a `dataHash` is only an intrinsic member of one. It is still
|
|
45
|
+
// refused rather than skipped, because "no declared coverage" is exactly the state a
|
|
46
|
+
// verification must not accept — a comparison against an absent declaration would pass
|
|
47
|
+
// while nothing stated which targets it covered.
|
|
48
|
+
reported.add(signer);
|
|
49
|
+
refuse(compilation, 'SIGNATURE_COVERAGE', path, `this expression compares the stored \`dataHash\` of \`${signer}\`, but no \`signature_capture\` field declares the coverage it binds; state the fields and context roots this signature binds in a \`covers\` list`);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (digest === undefined) {
|
|
53
|
+
reported.add(signer);
|
|
54
|
+
refuse(compilation, 'SIGNATURE_COVERAGE', path, `this expression compares the stored \`dataHash\` of signature field \`${signer}\` but recomputes no \`digest\` beside it; the binding has to be recomputed where it is compared, or nothing states which targets the compared value covers`);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const targets = digestTargets(digest);
|
|
58
|
+
if (targets === undefined || !sameTargets(targets, covers)) {
|
|
59
|
+
reported.add(signer);
|
|
60
|
+
refuse(compilation, 'SIGNATURE_COVERAGE', path, `signature field \`${signer}\` declares [${covers.map((id) => `\`${id}\``).join(', ')}], but this expression's \`digest\` binds ${targets === undefined ? 'no computable target list' : describeTargets([targets])}; coverage is declared once on the field, so the digest that verifies the signature must bind the same targets in the same order`);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
// A rule reads the values the artifact evaluates, so it can only re-derive a binding at the
|
|
64
|
+
// artifact's own version. A digest bound to the signature's recorded version would compare a
|
|
65
|
+
// value binding computed from current values against a version other values were recorded
|
|
66
|
+
// at; a stored record is verified from the values it was recorded with instead, through the
|
|
67
|
+
// catalogue (`verifySignature`), not by a rule in the current artifact.
|
|
68
|
+
if (bindsArtifactVersion(digest))
|
|
69
|
+
continue;
|
|
70
|
+
reported.add(signer);
|
|
71
|
+
refuse(compilation, 'SIGNATURE_COVERAGE', path, `the \`digest\` that verifies signature field \`${signer}\` does not bind \`context.schema_version\`; a rule recomputes at the artifact's own version, and a binding to the signature's recorded version would accept a signature signed against another artifact version`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The expression-wide checks one slot earns wherever it appears: signature coverage, plus the
|
|
76
|
+
* gate-only placement and referential integrity of `rule_ok` and `no_blocking`, and the step
|
|
77
|
+
* ids the three step folds name. Layout passes no rule kind, so those built-ins are refused
|
|
78
|
+
* there just as they are outside a gate rule.
|
|
79
|
+
*/
|
|
80
|
+
export function crossCheckExpression(compilation, path, node, ruleKind, targetIds) {
|
|
81
|
+
crossCheckSignatureCoverage(compilation, path, node);
|
|
82
|
+
const uses = ruleReferenceUses(node);
|
|
83
|
+
if (uses.length > 0 && ruleKind !== GATE_KIND) {
|
|
84
|
+
refuse(compilation, 'RULE_REFERENCE', path, gateFoldDetail(uses.map((use) => use.op)));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
for (const call of noBlockingKinds(node)) {
|
|
88
|
+
const [kindNode] = call.kind === 'call' ? call.args : [];
|
|
89
|
+
const kind = kindNode?.kind === 'literal' && typeof kindNode.value === 'string'
|
|
90
|
+
? kindNode.value
|
|
91
|
+
: undefined;
|
|
92
|
+
if (kind !== undefined && isRuleKind(kind))
|
|
93
|
+
continue;
|
|
94
|
+
refuse(compilation, 'UNKNOWN_IDENTIFIER', path, `\`no_blocking\` names \`${kind ?? 'a value'}\`, which is not a rule kind; write one of ${RULE_KINDS.join(', ')}`);
|
|
95
|
+
}
|
|
96
|
+
for (const target of ruleReferences(node)) {
|
|
97
|
+
if (compilation.ruleIds.has(target))
|
|
98
|
+
continue;
|
|
99
|
+
refuse(compilation, 'UNKNOWN_IDENTIFIER', path, `\`rule_ok\` names rule \`${target}\`, which this schema does not declare; name a declared \`ruleId\`, or add the rule this gate should read`, { suggestions: closestNames(target, [...compilation.ruleIds]) });
|
|
100
|
+
}
|
|
101
|
+
// The step folds name a layout step, and the engine refuses an undeclared id by turning the
|
|
102
|
+
// gate item `UNKNOWN` at run time. The layout is known here, so the same answer is a compile
|
|
103
|
+
// diagnostic at the expression that asked.
|
|
104
|
+
for (const call of stepFoldCalls(node)) {
|
|
105
|
+
if (call.kind !== 'call')
|
|
106
|
+
continue;
|
|
107
|
+
const [stepNode] = call.args;
|
|
108
|
+
const stepId = stepNode?.kind === 'literal' && typeof stepNode.value === 'string'
|
|
109
|
+
? stepNode.value
|
|
110
|
+
: undefined;
|
|
111
|
+
if (stepId === undefined || targetIds.has(stepId))
|
|
112
|
+
continue;
|
|
113
|
+
refuse(compilation, 'UNKNOWN_IDENTIFIER', path, `\`${call.op}\` names \`${stepId}\`, which this layout does not declare; name a declared \`stepId\` or layout \`sectionId\`, or add the step the fold should read`, { suggestions: closestNames(stepId, [...targetIds]) });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The cross-checks between a compiled rule, the message it raises and the fields it binds:
|
|
118
|
+
* `rule_ok`/`no_blocking` are admitted only inside a gate rule, every rule
|
|
119
|
+
* they name exists, every message argument is bound by the rule
|
|
120
|
+
* and every `select` branch of a bound option field is one of its codes.
|
|
121
|
+
* A `digest(...)` that verifies a signature is also checked against the coverage that
|
|
122
|
+
* signature declares.
|
|
123
|
+
*/
|
|
124
|
+
export function crossCheckRule(compilation, entry, messageKeys, targetIds) {
|
|
125
|
+
const itemFieldId = entry.rule.scope === 'item' ? entry.rule.fieldId : undefined;
|
|
126
|
+
for (const slot of entry.slots) {
|
|
127
|
+
crossCheckExpression(compilation, slot.path, slot.node, entry.rule.kind, targetIds);
|
|
128
|
+
crossCheckOptionCodes(compilation, slot.path, slot.node, itemFieldId);
|
|
129
|
+
}
|
|
130
|
+
for (const use of messageKeys)
|
|
131
|
+
crossCheckMessageBinding(compilation, use);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* One message use against the arguments its owner binds: every interpolation is bound, and every
|
|
135
|
+
* `select` branch a bound option field can take is one of its declared codes.
|
|
136
|
+
*
|
|
137
|
+
* Exported because a layout chrome message (`titleKey`, `textKey`) is bound by the layout node's
|
|
138
|
+
* own `params` block rather than by a rule, and one authority for the check keeps the two
|
|
139
|
+
* declarations reporting the same cause the same way.
|
|
140
|
+
*/
|
|
141
|
+
export function crossCheckMessageBinding(compilation, use) {
|
|
142
|
+
const messages = compiledMessages(compilation, use.key);
|
|
143
|
+
if (messages.length === 0)
|
|
144
|
+
return;
|
|
145
|
+
// One refusal per cause, not per locale entry: a message key carries one entry per locale and
|
|
146
|
+
// every entry has to bind the same arguments, so reporting the same unbound name once per
|
|
147
|
+
// locale would bury the cause in repetition.
|
|
148
|
+
const unbound = new Set();
|
|
149
|
+
const selects = new Map();
|
|
150
|
+
for (const message of messages) {
|
|
151
|
+
for (const name of argumentsOf(message.nodes)) {
|
|
152
|
+
// A parameter whose own expression was refused is already reported at its slot. Calling
|
|
153
|
+
// it unbound too would state a second defect the author does not have.
|
|
154
|
+
if (use.binding.unparsedParams?.has(name) === true)
|
|
155
|
+
continue;
|
|
156
|
+
if (!Object.hasOwn(use.binding.nodes, name))
|
|
157
|
+
unbound.add(name);
|
|
158
|
+
}
|
|
159
|
+
for (const [name, branches] of selectBranches(message.nodes)) {
|
|
160
|
+
const declared = selects.get(name) ?? new Set();
|
|
161
|
+
for (const branch of branches)
|
|
162
|
+
declared.add(branch);
|
|
163
|
+
selects.set(name, declared);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const member = use.member ?? 'params';
|
|
167
|
+
for (const name of unbound) {
|
|
168
|
+
// The name alone leaves the shape of the block to guesswork, and a plural's argument is the
|
|
169
|
+
// one an author most often assumes the runtime supplies. The block is an object whose every
|
|
170
|
+
// member is one interpolated name bound to an expression, so the example spells that pair
|
|
171
|
+
// with the name this message actually interpolates.
|
|
172
|
+
refuse(compilation, 'MESSAGE_BINDING', use.path, `message \`${use.key}\` interpolates \`${name}\`, which ${use.owner} does not bind; \`${member}\` holds one member per interpolated name, valued by the field path or expression that supplies it — bind the interpolated name there, for example \`"${name}": "f_${name}"\`, or remove \`{${name}}\` from the message`);
|
|
173
|
+
}
|
|
174
|
+
for (const [name, branches] of selects) {
|
|
175
|
+
// An unbound argument is already refused above; refusing it again for being a `select`
|
|
176
|
+
// would state the same defect twice.
|
|
177
|
+
if (!Object.hasOwn(use.binding.nodes, name))
|
|
178
|
+
continue;
|
|
179
|
+
const fieldId = use.binding.paramFields.get(name);
|
|
180
|
+
if (fieldId === undefined) {
|
|
181
|
+
// Bound to an expression or a context root: the domain is not a field's declared
|
|
182
|
+
// options, and refusing it would narrow a capability the language already admits. The
|
|
183
|
+
// `other` branch keeps a value outside the written branches renderable.
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const codes = compilation.options.get(fieldId);
|
|
187
|
+
if (codes === undefined) {
|
|
188
|
+
// A dynamic domain is real but not enumerable at compile time; a field with neither
|
|
189
|
+
// static options nor a source declares no domain at all, which is the defect.
|
|
190
|
+
if (compilation.dynamicOptions.has(fieldId))
|
|
191
|
+
continue;
|
|
192
|
+
refuse(compilation, 'MESSAGE_BINDING', use.path, `message \`${use.key}\` selects on \`${name}\`, which ${use.owner} binds to \`${fieldId}\`, and that field declares neither \`options\` nor \`optionSource\`; a \`select\` needs a closed or declared option domain`);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const unknown = [...branches].filter((branch) => !codes.includes(branch));
|
|
196
|
+
if (unknown.length === 0)
|
|
197
|
+
continue;
|
|
198
|
+
refuse(compilation, 'MESSAGE_BINDING', use.path, `message \`${use.key}\` selects on \`${name}\`, which ${use.owner} binds to \`${fieldId}\`; \`${unknown.join('`, `')}\` ${unknown.length === 1 ? 'is not a declared option' : 'are not declared options'} of that field`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The messages a params-less slot names, refused when they interpolate anything.
|
|
203
|
+
*
|
|
204
|
+
* A label, a help text, a placeholder, a title or a layout text is stated presentation: its
|
|
205
|
+
* slot declares no `params`, so nothing binds an argument and a `{param}` (or a `plural`'s
|
|
206
|
+
* count) would be a missing argument on every record — a runtime `ENGINE_ERROR` instead of a
|
|
207
|
+
* publish-time answer. The slot table is the one list of which members those are.
|
|
208
|
+
*
|
|
209
|
+
* A slot whose owner binds arguments is not checked here: the rule or gate-item compile
|
|
210
|
+
* already refuses an argument that declaration does not bind, and it can name the declaration.
|
|
211
|
+
*/
|
|
212
|
+
export function crossCheckParamslessMessages(compilation, document) {
|
|
213
|
+
for (const use of messageKeyUses(document)) {
|
|
214
|
+
if (use.params !== 'none')
|
|
215
|
+
continue;
|
|
216
|
+
crossCheckParamslessMessage(compilation, use);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* One params-less message use: every interpolation is refused because the slot has no binding.
|
|
221
|
+
*
|
|
222
|
+
* Exported beside the binding check because a layout `titleKey` or `textKey` is params-bearing
|
|
223
|
+
* only when its node carries a `params` block; the layout compile decides which of the two
|
|
224
|
+
* checks a node earns, and both must state the cause the same way.
|
|
225
|
+
*/
|
|
226
|
+
export function crossCheckParamslessMessage(compilation, use) {
|
|
227
|
+
// One refusal per argument, not per locale entry: the slot has no binding whichever
|
|
228
|
+
// locale states the text, and the same cause reported once per locale is noise.
|
|
229
|
+
const unbound = new Set();
|
|
230
|
+
for (const message of compiledMessages(compilation, use.key)) {
|
|
231
|
+
for (const name of argumentsOf(message.nodes))
|
|
232
|
+
unbound.add(name);
|
|
233
|
+
}
|
|
234
|
+
for (const name of unbound) {
|
|
235
|
+
refuse(compilation, 'MESSAGE_BINDING', use.path, `message \`${use.key}\` interpolates \`${name}\`, and this slot declares no \`params\` to bind it; a params-less message is rendered as authored, so declare it without arguments`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=cross-checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross-checks.js","sourceRoot":"","sources":["../../src/compile/cross-checks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGpG,gEAAgE;AAChE,MAAM,SAAS,GAAa,MAAM,CAAC;AAiBnC,qEAAqE;AACrE,SAAS,gBAAgB,CAAC,WAAwB,EAAE,GAAW;IAC7D,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/F,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACnC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAA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AAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,0BACtD,gBAAgB,CACjB,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,4BAA4B,CAC1C,WAAwB,EACxB,QAAiC;IAEjC,KAAK,MAAM,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3C,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM;YAAE,SAAS;QACpC,2BAA2B,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACzC,WAAwB,EACxB,GAAoD;IAEpD,oFAAoF;IACpF,gFAAgF;IAChF,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAK,MAAM,OAAO,IAAI,gBAAgB,CAAC,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7D,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnE,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,MAAM,CACJ,WAAW,EACX,iBAAiB,EACjB,GAAG,CAAC,IAAI,EACR,aAAa,GAAG,CAAC,GAAG,qBAAqB,IAAI,qIAAqI,CACnL,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { isRuleKind, RULE_KINDS } from '@azx-pbc/axiom-runtime';\nimport type { CompiledMessage, ExprNode, RuleKind } from '@azx-pbc/axiom-runtime';\nimport { closestNames } from '../expr/suggest.js';\nimport { gateFoldDetail } from '../expr/typecheck/gate-folds.js';\nimport { argumentsOf, selectBranches } from '../messages/compile.js';\nimport { messageKeyUses } from '../messages/slots.js';\nimport type { Compilation } from './compilation.js';\nimport { refuse } from './compilation.js';\nimport type { CompiledMessageBinding } from './expression.js';\nimport {\n bindsArtifactVersion,\n describeTargets,\n digestTargets,\n hashComparisons,\n sameTargets,\n} from './hashes.js';\nimport { crossCheckOptionCodes } from './option-codes.js';\nimport { noBlockingKinds, ruleReferences, ruleReferenceUses, stepFoldCalls } from './references.js';\nimport type { CompiledRuleEntry } from './rules.js';\n\n/** The rule kinds `rule_ok` and `no_blocking` may appear in. */\nconst GATE_KIND: RuleKind = 'gate';\n\n/** One message a rule or a gate item raises, with the arguments that declaration binds. */\nexport interface MessageUse {\n readonly key: string;\n readonly path: string;\n /** The rule, gate item or option that binds the arguments, named in a refusal. */\n readonly owner: string;\n readonly binding: CompiledMessageBinding;\n /**\n * The member the owner binds the arguments in, as the repair spells it. Defaults to `params`,\n * which is the block a rule, gate item, screen reason and layout node carry; an option's reason\n * message is bound by `unavailableParams` instead.\n */\n readonly member?: string;\n}\n\n/** The message entries one message key declares, in every locale. */\nfunction compiledMessages(compilation: Compilation, key: string): readonly CompiledMessage[] {\n const entry = Object.hasOwn(compilation.messages, key) ? compilation.messages[key] : undefined;\n if (entry === undefined) return [];\n return Object.values(entry).flatMap((value) => (typeof value === 'string' ? [] : [value]));\n}\n\n/**\n * A `digest(...)` that verifies a stored signature must bind the targets that signature\n * declares.\n *\n * The artifact states a signature's coverage once, on the mandatory `covers` list of the\n * `signature_capture` field, and the expression that checks a stored signature recomputes the\n * same binding. A list that names other targets would let a signature verify over values the\n * artifact does not say it covers, so a `digest` and a read of a signature's `dataHash` in\n * one slot are compared here. A signature field carries no coverage only in an artifact this\n * compiler did not produce, and that too is refused rather than skipped. A `digest` in a slot\n * that reads no signature is not a signature's coverage, and is left to its own rule.\n */\nfunction crossCheckSignatureCoverage(compilation: Compilation, path: string, node: ExprNode): void {\n const comparisons = hashComparisons(node);\n if (comparisons.length === 0) return;\n // One refusal per signature, not per comparison: two bad comparisons for one signer state\n // one defect.\n const reported = new Set<string>();\n for (const { digest, signer } of comparisons) {\n if (reported.has(signer)) continue;\n const covers = compilation.signatureCovers.get(signer);\n if (covers === undefined) {\n // Unreachable for a document this compiler admitted: `covers` is mandatory on every\n // `signature_capture`, and a `dataHash` is only an intrinsic member of one. It is still\n // refused rather than skipped, because \"no declared coverage\" is exactly the state a\n // verification must not accept — a comparison against an absent declaration would pass\n // while nothing stated which targets it covered.\n reported.add(signer);\n refuse(\n compilation,\n 'SIGNATURE_COVERAGE',\n path,\n `this expression compares the stored \\`dataHash\\` of \\`${signer}\\`, but no \\`signature_capture\\` field declares the coverage it binds; state the fields and context roots this signature binds in a \\`covers\\` list`,\n );\n continue;\n }\n if (digest === undefined) {\n reported.add(signer);\n refuse(\n compilation,\n 'SIGNATURE_COVERAGE',\n path,\n `this expression compares the stored \\`dataHash\\` of signature field \\`${signer}\\` but recomputes no \\`digest\\` beside it; the binding has to be recomputed where it is compared, or nothing states which targets the compared value covers`,\n );\n continue;\n }\n const targets = digestTargets(digest);\n if (targets === undefined || !sameTargets(targets, covers)) {\n reported.add(signer);\n refuse(\n compilation,\n 'SIGNATURE_COVERAGE',\n path,\n `signature field \\`${signer}\\` declares [${covers.map((id) => `\\`${id}\\``).join(', ')}], but this expression's \\`digest\\` binds ${\n targets === undefined ? 'no computable target list' : describeTargets([targets])\n }; coverage is declared once on the field, so the digest that verifies the signature must bind the same targets in the same order`,\n );\n continue;\n }\n // A rule reads the values the artifact evaluates, so it can only re-derive a binding at the\n // artifact's own version. A digest bound to the signature's recorded version would compare a\n // value binding computed from current values against a version other values were recorded\n // at; a stored record is verified from the values it was recorded with instead, through the\n // catalogue (`verifySignature`), not by a rule in the current artifact.\n if (bindsArtifactVersion(digest)) continue;\n reported.add(signer);\n refuse(\n compilation,\n 'SIGNATURE_COVERAGE',\n path,\n `the \\`digest\\` that verifies signature field \\`${signer}\\` does not bind \\`context.schema_version\\`; a rule recomputes at the artifact's own version, and a binding to the signature's recorded version would accept a signature signed against another artifact version`,\n );\n }\n}\n\n/**\n * The expression-wide checks one slot earns wherever it appears: signature coverage, plus the\n * gate-only placement and referential integrity of `rule_ok` and `no_blocking`, and the step\n * ids the three step folds name. Layout passes no rule kind, so those built-ins are refused\n * there just as they are outside a gate rule.\n */\nexport function crossCheckExpression(\n compilation: Compilation,\n path: string,\n node: ExprNode,\n ruleKind: RuleKind | undefined,\n targetIds: ReadonlySet<string>,\n): void {\n crossCheckSignatureCoverage(compilation, path, node);\n const uses = ruleReferenceUses(node);\n if (uses.length > 0 && ruleKind !== GATE_KIND) {\n refuse(compilation, 'RULE_REFERENCE', path, gateFoldDetail(uses.map((use) => use.op)));\n return;\n }\n for (const call of noBlockingKinds(node)) {\n const [kindNode] = call.kind === 'call' ? call.args : [];\n const kind =\n kindNode?.kind === 'literal' && typeof kindNode.value === 'string'\n ? kindNode.value\n : undefined;\n if (kind !== undefined && isRuleKind(kind)) continue;\n refuse(\n compilation,\n 'UNKNOWN_IDENTIFIER',\n path,\n `\\`no_blocking\\` names \\`${kind ?? 'a value'}\\`, which is not a rule kind; write one of ${RULE_KINDS.join(', ')}`,\n );\n }\n for (const target of ruleReferences(node)) {\n if (compilation.ruleIds.has(target)) continue;\n refuse(\n compilation,\n 'UNKNOWN_IDENTIFIER',\n path,\n `\\`rule_ok\\` names rule \\`${target}\\`, which this schema does not declare; name a declared \\`ruleId\\`, or add the rule this gate should read`,\n { suggestions: closestNames(target, [...compilation.ruleIds]) },\n );\n }\n // The step folds name a layout step, and the engine refuses an undeclared id by turning the\n // gate item `UNKNOWN` at run time. The layout is known here, so the same answer is a compile\n // diagnostic at the expression that asked.\n for (const call of stepFoldCalls(node)) {\n if (call.kind !== 'call') continue;\n const [stepNode] = call.args;\n const stepId =\n stepNode?.kind === 'literal' && typeof stepNode.value === 'string'\n ? stepNode.value\n : undefined;\n if (stepId === undefined || targetIds.has(stepId)) continue;\n refuse(\n compilation,\n 'UNKNOWN_IDENTIFIER',\n path,\n `\\`${call.op}\\` names \\`${stepId}\\`, which this layout does not declare; name a declared \\`stepId\\` or layout \\`sectionId\\`, or add the step the fold should read`,\n { suggestions: closestNames(stepId, [...targetIds]) },\n );\n }\n}\n\n/**\n * The cross-checks between a compiled rule, the message it raises and the fields it binds:\n * `rule_ok`/`no_blocking` are admitted only inside a gate rule, every rule\n * they name exists, every message argument is bound by the rule\n * and every `select` branch of a bound option field is one of its codes.\n * A `digest(...)` that verifies a signature is also checked against the coverage that\n * signature declares.\n */\nexport function crossCheckRule(\n compilation: Compilation,\n entry: CompiledRuleEntry,\n messageKeys: readonly MessageUse[],\n targetIds: ReadonlySet<string>,\n): void {\n const itemFieldId = entry.rule.scope === 'item' ? entry.rule.fieldId : undefined;\n for (const slot of entry.slots) {\n crossCheckExpression(compilation, slot.path, slot.node, entry.rule.kind, targetIds);\n crossCheckOptionCodes(compilation, slot.path, slot.node, itemFieldId);\n }\n\n for (const use of messageKeys) crossCheckMessageBinding(compilation, use);\n}\n\n/**\n * One message use against the arguments its owner binds: every interpolation is bound, and every\n * `select` branch a bound option field can take is one of its declared codes.\n *\n * Exported because a layout chrome message (`titleKey`, `textKey`) is bound by the layout node's\n * own `params` block rather than by a rule, and one authority for the check keeps the two\n * declarations reporting the same cause the same way.\n */\nexport function crossCheckMessageBinding(compilation: Compilation, use: MessageUse): void {\n const messages = compiledMessages(compilation, use.key);\n if (messages.length === 0) return;\n // One refusal per cause, not per locale entry: a message key carries one entry per locale and\n // every entry has to bind the same arguments, so reporting the same unbound name once per\n // locale would bury the cause in repetition.\n const unbound = new Set<string>();\n const selects = new Map<string, Set<string>>();\n for (const message of messages) {\n for (const name of argumentsOf(message.nodes)) {\n // A parameter whose own expression was refused is already reported at its slot. Calling\n // it unbound too would state a second defect the author does not have.\n if (use.binding.unparsedParams?.has(name) === true) continue;\n if (!Object.hasOwn(use.binding.nodes, name)) unbound.add(name);\n }\n for (const [name, branches] of selectBranches(message.nodes)) {\n const declared = selects.get(name) ?? new Set<string>();\n for (const branch of branches) declared.add(branch);\n selects.set(name, declared);\n }\n }\n const member = use.member ?? 'params';\n for (const name of unbound) {\n // The name alone leaves the shape of the block to guesswork, and a plural's argument is the\n // one an author most often assumes the runtime supplies. The block is an object whose every\n // member is one interpolated name bound to an expression, so the example spells that pair\n // with the name this message actually interpolates.\n refuse(\n compilation,\n 'MESSAGE_BINDING',\n use.path,\n `message \\`${use.key}\\` interpolates \\`${name}\\`, which ${use.owner} does not bind; \\`${member}\\` holds one member per interpolated name, valued by the field path or expression that supplies it — bind the interpolated name there, for example \\`\"${name}\": \"f_${name}\"\\`, or remove \\`{${name}}\\` from the message`,\n );\n }\n for (const [name, branches] of selects) {\n // An unbound argument is already refused above; refusing it again for being a `select`\n // would state the same defect twice.\n if (!Object.hasOwn(use.binding.nodes, name)) continue;\n const fieldId = use.binding.paramFields.get(name);\n if (fieldId === undefined) {\n // Bound to an expression or a context root: the domain is not a field's declared\n // options, and refusing it would narrow a capability the language already admits. The\n // `other` branch keeps a value outside the written branches renderable.\n continue;\n }\n const codes = compilation.options.get(fieldId);\n if (codes === undefined) {\n // A dynamic domain is real but not enumerable at compile time; a field with neither\n // static options nor a source declares no domain at all, which is the defect.\n if (compilation.dynamicOptions.has(fieldId)) continue;\n refuse(\n compilation,\n 'MESSAGE_BINDING',\n use.path,\n `message \\`${use.key}\\` selects on \\`${name}\\`, which ${use.owner} binds to \\`${fieldId}\\`, and that field declares neither \\`options\\` nor \\`optionSource\\`; a \\`select\\` needs a closed or declared option domain`,\n );\n continue;\n }\n const unknown = [...branches].filter((branch) => !codes.includes(branch));\n if (unknown.length === 0) continue;\n refuse(\n compilation,\n 'MESSAGE_BINDING',\n use.path,\n `message \\`${use.key}\\` selects on \\`${name}\\`, which ${use.owner} binds to \\`${fieldId}\\`; \\`${unknown.join('`, `')}\\` ${\n unknown.length === 1 ? 'is not a declared option' : 'are not declared options'\n } of that field`,\n );\n }\n}\n\n/**\n * The messages a params-less slot names, refused when they interpolate anything.\n *\n * A label, a help text, a placeholder, a title or a layout text is stated presentation: its\n * slot declares no `params`, so nothing binds an argument and a `{param}` (or a `plural`'s\n * count) would be a missing argument on every record — a runtime `ENGINE_ERROR` instead of a\n * publish-time answer. The slot table is the one list of which members those are.\n *\n * A slot whose owner binds arguments is not checked here: the rule or gate-item compile\n * already refuses an argument that declaration does not bind, and it can name the declaration.\n */\nexport function crossCheckParamslessMessages(\n compilation: Compilation,\n document: Record<string, unknown>,\n): void {\n for (const use of messageKeyUses(document)) {\n if (use.params !== 'none') continue;\n crossCheckParamslessMessage(compilation, use);\n }\n}\n\n/**\n * One params-less message use: every interpolation is refused because the slot has no binding.\n *\n * Exported beside the binding check because a layout `titleKey` or `textKey` is params-bearing\n * only when its node carries a `params` block; the layout compile decides which of the two\n * checks a node earns, and both must state the cause the same way.\n */\nexport function crossCheckParamslessMessage(\n compilation: Compilation,\n use: { readonly key: string; readonly path: string },\n): void {\n // One refusal per argument, not per locale entry: the slot has no binding whichever\n // locale states the text, and the same cause reported once per locale is noise.\n const unbound = new Set<string>();\n for (const message of compiledMessages(compilation, use.key)) {\n for (const name of argumentsOf(message.nodes)) unbound.add(name);\n }\n for (const name of unbound) {\n refuse(\n compilation,\n 'MESSAGE_BINDING',\n use.path,\n `message \\`${use.key}\\` interpolates \\`${name}\\`, and this slot declares no \\`params\\` to bind it; a params-less message is rendered as authored, so declare it without arguments`,\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { CompiledField, CompiledRule, DatasetDeclaration, DatasetRef, ExprNode, Tier } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import type { CompiledDatasetDeclaration } from '../datasets/index.js';
|
|
3
|
+
/** The table ids the document itself declares, `schema.v1.json` `datasetRef`. */
|
|
4
|
+
export declare function declaredTablesOf(document: Record<string, unknown>): ReadonlySet<string>;
|
|
5
|
+
/**
|
|
6
|
+
* The version the document pins each declared table to.
|
|
7
|
+
*
|
|
8
|
+
* The closed metaschema requires a `tableVersion` and the declaration walk refuses a table named
|
|
9
|
+
* twice, so every declared table answers exactly one version here. A pin is what a caller's
|
|
10
|
+
* compiled declaration has to match: the artifact carries the pin, and a rule typed against
|
|
11
|
+
* another version would compile an artifact its own runtime refuses as `STALE_DATA`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function pinnedVersionsOf(document: Record<string, unknown>): ReadonlyMap<string, number>;
|
|
14
|
+
/** The table ids the caller supplied a compiled declaration for. */
|
|
15
|
+
export declare function suppliedTablesOf(datasets: readonly DatasetDeclaration[]): ReadonlySet<string>;
|
|
16
|
+
/**
|
|
17
|
+
* The versions the caller supplied for each table.
|
|
18
|
+
*
|
|
19
|
+
* A schema ships a *set* of versions of one table, so a table id can appear more than once and
|
|
20
|
+
* the pin check asks whether the document's version is among them, not whether every supplied
|
|
21
|
+
* declaration states it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function suppliedVersionsOf(datasets: readonly CompiledDatasetDeclaration[]): ReadonlyMap<string, ReadonlySet<number>>;
|
|
24
|
+
/** The table name each dataset built-in a compiled expression uses names. */
|
|
25
|
+
export declare function datasetTableNames(node: ExprNode, into?: Set<string>): ReadonlySet<string>;
|
|
26
|
+
/** The digest each supplied declaration binds, keyed by the table and version it describes. */
|
|
27
|
+
export declare function suppliedDigestsOf(datasets: readonly CompiledDatasetDeclaration[]): ReadonlyMap<string, string>;
|
|
28
|
+
/** A pin the artifact wanted to state but had no digest to bind it with. */
|
|
29
|
+
export interface DatasetPinGap {
|
|
30
|
+
/** The authored position, so the diagnostic points at the entry an author can fix. */
|
|
31
|
+
readonly index: number;
|
|
32
|
+
readonly tableId: string;
|
|
33
|
+
readonly tableVersion: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The dataset pins a compiled artifact carries: only the tables some expression in that artifact
|
|
37
|
+
* can read.
|
|
38
|
+
*
|
|
39
|
+
* A pin is a promise that the host must hold that table, so a pin nothing can reach asks every
|
|
40
|
+
* device to carry bytes no evaluation can use. A server artifact keeps every table one of its
|
|
41
|
+
* rules reads; a client artifact narrows that further to the tables a client-tier rule reads,
|
|
42
|
+
* because every server-tier rule became a deferred stub. A declared field's own expressions are
|
|
43
|
+
* device-side in both tiers, so their tables are kept either way. The digest comes from the
|
|
44
|
+
* supplied compiled declaration: the artifact binds the table's canonical bytes, not only its
|
|
45
|
+
* version (`DATA-4.1.6`). A kept pin with no supplied declaration is returned as a gap rather
|
|
46
|
+
* than silently dropped, so the author is told which table to pass.
|
|
47
|
+
*/
|
|
48
|
+
export declare function artifactDatasetPins(document: Record<string, unknown>, rules: readonly CompiledRule[], fields: readonly CompiledField[], target: Tier, suppliedDigests: ReadonlyMap<string, string>): {
|
|
49
|
+
readonly pins: readonly DatasetRef[];
|
|
50
|
+
readonly gaps: readonly DatasetPinGap[];
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=datasets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasets.d.ts","sourceRoot":"","sources":["../../src/compile/datasets.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,QAAQ,EACR,IAAI,EACL,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGvE,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAOvF;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAiB/F;AAED,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,CAE7F;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,SAAS,0BAA0B,EAAE,GAC9C,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAS1C;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,QAAQ,EACd,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,GAC5B,WAAW,CAAC,MAAM,CAAC,CAyBrB;AA4CD,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,SAAS,0BAA0B,EAAE,GAC9C,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAS7B;AAED,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,sFAAsF;IACtF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,MAAM,EAAE,IAAI,EACZ,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3C;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,CAyBnF"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { DATASET_BUILTINS, declaredFieldExpressions, isRecord, ruleExpressions, } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import { listAt, textAt } from './document.js';
|
|
3
|
+
/** The table ids the document itself declares, `schema.v1.json` `datasetRef`. */
|
|
4
|
+
export function declaredTablesOf(document) {
|
|
5
|
+
return new Set(listAt(document, 'datasets').flatMap((ref) => {
|
|
6
|
+
const tableId = isRecord(ref) ? textAt(ref, 'tableId') : undefined;
|
|
7
|
+
return tableId === undefined ? [] : [tableId];
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The version the document pins each declared table to.
|
|
12
|
+
*
|
|
13
|
+
* The closed metaschema requires a `tableVersion` and the declaration walk refuses a table named
|
|
14
|
+
* twice, so every declared table answers exactly one version here. A pin is what a caller's
|
|
15
|
+
* compiled declaration has to match: the artifact carries the pin, and a rule typed against
|
|
16
|
+
* another version would compile an artifact its own runtime refuses as `STALE_DATA`.
|
|
17
|
+
*/
|
|
18
|
+
export function pinnedVersionsOf(document) {
|
|
19
|
+
const pinned = new Map();
|
|
20
|
+
for (const ref of listAt(document, 'datasets')) {
|
|
21
|
+
if (!isRecord(ref))
|
|
22
|
+
continue;
|
|
23
|
+
const tableId = textAt(ref, 'tableId');
|
|
24
|
+
const tableVersion = ref['tableVersion'];
|
|
25
|
+
if (tableId === undefined ||
|
|
26
|
+
typeof tableVersion !== 'number' ||
|
|
27
|
+
!Number.isSafeInteger(tableVersion) ||
|
|
28
|
+
pinned.has(tableId)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
pinned.set(tableId, tableVersion);
|
|
32
|
+
}
|
|
33
|
+
return pinned;
|
|
34
|
+
}
|
|
35
|
+
/** The table ids the caller supplied a compiled declaration for. */
|
|
36
|
+
export function suppliedTablesOf(datasets) {
|
|
37
|
+
return new Set(datasets.map((dataset) => dataset.tableId));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The versions the caller supplied for each table.
|
|
41
|
+
*
|
|
42
|
+
* A schema ships a *set* of versions of one table, so a table id can appear more than once and
|
|
43
|
+
* the pin check asks whether the document's version is among them, not whether every supplied
|
|
44
|
+
* declaration states it.
|
|
45
|
+
*/
|
|
46
|
+
export function suppliedVersionsOf(datasets) {
|
|
47
|
+
const versions = new Map();
|
|
48
|
+
for (const dataset of datasets) {
|
|
49
|
+
if (!Number.isSafeInteger(dataset.tableVersion))
|
|
50
|
+
continue;
|
|
51
|
+
const held = versions.get(dataset.tableId);
|
|
52
|
+
if (held === undefined)
|
|
53
|
+
versions.set(dataset.tableId, new Set([dataset.tableVersion]));
|
|
54
|
+
else
|
|
55
|
+
held.add(dataset.tableVersion);
|
|
56
|
+
}
|
|
57
|
+
return versions;
|
|
58
|
+
}
|
|
59
|
+
/** The table name each dataset built-in a compiled expression uses names. */
|
|
60
|
+
export function datasetTableNames(node, into = new Set()) {
|
|
61
|
+
switch (node.kind) {
|
|
62
|
+
case 'literal':
|
|
63
|
+
case 'path':
|
|
64
|
+
return into;
|
|
65
|
+
case 'list':
|
|
66
|
+
for (const item of node.items)
|
|
67
|
+
datasetTableNames(item, into);
|
|
68
|
+
return into;
|
|
69
|
+
case 'comprehension':
|
|
70
|
+
datasetTableNames(node.source, into);
|
|
71
|
+
if (node.valueExpr !== undefined)
|
|
72
|
+
datasetTableNames(node.valueExpr, into);
|
|
73
|
+
if (node.predicate !== undefined)
|
|
74
|
+
datasetTableNames(node.predicate, into);
|
|
75
|
+
return into;
|
|
76
|
+
case 'call': {
|
|
77
|
+
if (DATASET_BUILTINS.has(node.op)) {
|
|
78
|
+
const [table] = node.args;
|
|
79
|
+
if (table?.kind === 'path')
|
|
80
|
+
into.add(table.path);
|
|
81
|
+
}
|
|
82
|
+
for (const arg of node.args)
|
|
83
|
+
datasetTableNames(arg, into);
|
|
84
|
+
return into;
|
|
85
|
+
}
|
|
86
|
+
default:
|
|
87
|
+
for (const arg of node.args)
|
|
88
|
+
datasetTableNames(arg, into);
|
|
89
|
+
return into;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The tables any rule in a set can read, through every expression slot each rule carries.
|
|
94
|
+
*
|
|
95
|
+
* A server artifact runs every rule it carries, so this is its reachability.
|
|
96
|
+
*/
|
|
97
|
+
function rulesReadTables(rules) {
|
|
98
|
+
const tables = new Set();
|
|
99
|
+
for (const rule of rules) {
|
|
100
|
+
for (const node of ruleExpressions(rule))
|
|
101
|
+
datasetTableNames(node, tables);
|
|
102
|
+
}
|
|
103
|
+
return tables;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The tables a declared field's own expressions can read.
|
|
107
|
+
*
|
|
108
|
+
* An array's `rowsFrom` count and a declared option's availability, reason arguments and
|
|
109
|
+
* alternatives are evaluated on the device whichever tier the artifact is packaged for, so they
|
|
110
|
+
* are reachable in both tiers rather than narrowed with the client rules.
|
|
111
|
+
*/
|
|
112
|
+
function fieldTables(fields) {
|
|
113
|
+
const tables = new Set();
|
|
114
|
+
for (const slot of declaredFieldExpressions(fields))
|
|
115
|
+
datasetTableNames(slot.node, tables);
|
|
116
|
+
return tables;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The tables the client-tier rules can read.
|
|
120
|
+
*
|
|
121
|
+
* This is a client artifact's reachability: a server-tier rule is deferred on the device and
|
|
122
|
+
* never resolves a table there, so it contributes nothing even if the artifact carried its
|
|
123
|
+
* authored expression rather than the compiler's stub.
|
|
124
|
+
*/
|
|
125
|
+
function clientRulesReadTables(rules) {
|
|
126
|
+
return rulesReadTables(rules.filter((rule) => rule.evaluateOn === 'client'));
|
|
127
|
+
}
|
|
128
|
+
/** The identity a supplied declaration is filed under: a pin names a table and a version. */
|
|
129
|
+
function pinKey(tableId, tableVersion) {
|
|
130
|
+
return `${tableId}\u0000${String(tableVersion)}`;
|
|
131
|
+
}
|
|
132
|
+
/** The digest each supplied declaration binds, keyed by the table and version it describes. */
|
|
133
|
+
export function suppliedDigestsOf(datasets) {
|
|
134
|
+
const digests = new Map();
|
|
135
|
+
for (const dataset of datasets) {
|
|
136
|
+
const key = pinKey(dataset.tableId, dataset.tableVersion);
|
|
137
|
+
// The first declaration wins, as the version set does: one supplied declaration per version
|
|
138
|
+
// is the installation contract, and a duplicate is reported there rather than here.
|
|
139
|
+
if (!digests.has(key))
|
|
140
|
+
digests.set(key, dataset.sha256);
|
|
141
|
+
}
|
|
142
|
+
return digests;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The dataset pins a compiled artifact carries: only the tables some expression in that artifact
|
|
146
|
+
* can read.
|
|
147
|
+
*
|
|
148
|
+
* A pin is a promise that the host must hold that table, so a pin nothing can reach asks every
|
|
149
|
+
* device to carry bytes no evaluation can use. A server artifact keeps every table one of its
|
|
150
|
+
* rules reads; a client artifact narrows that further to the tables a client-tier rule reads,
|
|
151
|
+
* because every server-tier rule became a deferred stub. A declared field's own expressions are
|
|
152
|
+
* device-side in both tiers, so their tables are kept either way. The digest comes from the
|
|
153
|
+
* supplied compiled declaration: the artifact binds the table's canonical bytes, not only its
|
|
154
|
+
* version (`DATA-4.1.6`). A kept pin with no supplied declaration is returned as a gap rather
|
|
155
|
+
* than silently dropped, so the author is told which table to pass.
|
|
156
|
+
*/
|
|
157
|
+
export function artifactDatasetPins(document, rules, fields, target, suppliedDigests) {
|
|
158
|
+
const ruleTables = target === 'client' ? clientRulesReadTables(rules) : rulesReadTables(rules);
|
|
159
|
+
const readable = new Set([...ruleTables, ...fieldTables(fields)]);
|
|
160
|
+
const pins = [];
|
|
161
|
+
const gaps = [];
|
|
162
|
+
listAt(document, 'datasets').forEach((ref, index) => {
|
|
163
|
+
if (!isRecord(ref))
|
|
164
|
+
return;
|
|
165
|
+
const tableId = textAt(ref, 'tableId');
|
|
166
|
+
const tableVersion = ref['tableVersion'];
|
|
167
|
+
if (tableId === undefined ||
|
|
168
|
+
typeof tableVersion !== 'number' ||
|
|
169
|
+
!Number.isSafeInteger(tableVersion)) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (!readable.has(tableId))
|
|
173
|
+
return;
|
|
174
|
+
const sha256 = suppliedDigests.get(pinKey(tableId, tableVersion));
|
|
175
|
+
if (sha256 === undefined) {
|
|
176
|
+
gaps.push({ index, tableId, tableVersion });
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
pins.push({ tableId, tableVersion, sha256 });
|
|
180
|
+
});
|
|
181
|
+
return { pins, gaps };
|
|
182
|
+
}
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AAC,KAAK,CAAC,CAAC;IAC/F,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAS,CAAC,GAAG,UAAU,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1E,MAAM,IAAI,GAAiB,EAAE,CAAC;IAC9B,MAAM,IAAI,GAAoB,EAAE,CAAC;IACjC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAClD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,OAAO;QAC3B,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACvC,MAAM,YAAY,GAAG,GAAG,CAAC,cAAc,CAAC,CAAC;QACzC,IACE,OAAO,KAAK,SAAS;YACrB,OAAO,YAAY,KAAK,QAAQ;YAChC,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,EACnC,CAAC;YACD,OAAO;QACT,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,OAAO;QACnC,MAAM,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;QAClE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;YAC5C,OAAO;QACT,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC","sourcesContent":["import {\n DATASET_BUILTINS,\n declaredFieldExpressions,\n isRecord,\n ruleExpressions,\n} from '@azx-pbc/axiom-runtime';\nimport type {\n CompiledField,\n CompiledRule,\n DatasetDeclaration,\n DatasetRef,\n ExprNode,\n Tier,\n} from '@azx-pbc/axiom-runtime';\nimport type { CompiledDatasetDeclaration } from '../datasets/index.js';\nimport { listAt, textAt } from './document.js';\n\n/** The table ids the document itself declares, `schema.v1.json` `datasetRef`. */\nexport function declaredTablesOf(document: Record<string, unknown>): ReadonlySet<string> {\n return new Set(\n listAt(document, 'datasets').flatMap((ref) => {\n const tableId = isRecord(ref) ? textAt(ref, 'tableId') : undefined;\n return tableId === undefined ? [] : [tableId];\n }),\n );\n}\n\n/**\n * The version the document pins each declared table to.\n *\n * The closed metaschema requires a `tableVersion` and the declaration walk refuses a table named\n * twice, so every declared table answers exactly one version here. A pin is what a caller's\n * compiled declaration has to match: the artifact carries the pin, and a rule typed against\n * another version would compile an artifact its own runtime refuses as `STALE_DATA`.\n */\nexport function pinnedVersionsOf(document: Record<string, unknown>): ReadonlyMap<string, number> {\n const pinned = new Map<string, number>();\n for (const ref of listAt(document, 'datasets')) {\n if (!isRecord(ref)) continue;\n const tableId = textAt(ref, 'tableId');\n const tableVersion = ref['tableVersion'];\n if (\n tableId === undefined ||\n typeof tableVersion !== 'number' ||\n !Number.isSafeInteger(tableVersion) ||\n pinned.has(tableId)\n ) {\n continue;\n }\n pinned.set(tableId, tableVersion);\n }\n return pinned;\n}\n\n/** The table ids the caller supplied a compiled declaration for. */\nexport function suppliedTablesOf(datasets: readonly DatasetDeclaration[]): ReadonlySet<string> {\n return new Set(datasets.map((dataset) => dataset.tableId));\n}\n\n/**\n * The versions the caller supplied for each table.\n *\n * A schema ships a *set* of versions of one table, so a table id can appear more than once and\n * the pin check asks whether the document's version is among them, not whether every supplied\n * declaration states it.\n */\nexport function suppliedVersionsOf(\n datasets: readonly CompiledDatasetDeclaration[],\n): ReadonlyMap<string, ReadonlySet<number>> {\n const versions = new Map<string, Set<number>>();\n for (const dataset of datasets) {\n if (!Number.isSafeInteger(dataset.tableVersion)) continue;\n const held = versions.get(dataset.tableId);\n if (held === undefined) versions.set(dataset.tableId, new Set([dataset.tableVersion]));\n else held.add(dataset.tableVersion);\n }\n return versions;\n}\n\n/** The table name each dataset built-in a compiled expression uses names. */\nexport function datasetTableNames(\n node: ExprNode,\n into: Set<string> = new Set(),\n): ReadonlySet<string> {\n switch (node.kind) {\n case 'literal':\n case 'path':\n return into;\n case 'list':\n for (const item of node.items) datasetTableNames(item, into);\n return into;\n case 'comprehension':\n datasetTableNames(node.source, into);\n if (node.valueExpr !== undefined) datasetTableNames(node.valueExpr, into);\n if (node.predicate !== undefined) datasetTableNames(node.predicate, into);\n return into;\n case 'call': {\n if (DATASET_BUILTINS.has(node.op)) {\n const [table] = node.args;\n if (table?.kind === 'path') into.add(table.path);\n }\n for (const arg of node.args) datasetTableNames(arg, into);\n return into;\n }\n default:\n for (const arg of node.args) datasetTableNames(arg, into);\n return into;\n }\n}\n\n/**\n * The tables any rule in a set can read, through every expression slot each rule carries.\n *\n * A server artifact runs every rule it carries, so this is its reachability.\n */\nfunction rulesReadTables(rules: readonly CompiledRule[]): ReadonlySet<string> {\n const tables = new Set<string>();\n for (const rule of rules) {\n for (const node of ruleExpressions(rule)) datasetTableNames(node, tables);\n }\n return tables;\n}\n\n/**\n * The tables a declared field's own expressions can read.\n *\n * An array's `rowsFrom` count and a declared option's availability, reason arguments and\n * alternatives are evaluated on the device whichever tier the artifact is packaged for, so they\n * are reachable in both tiers rather than narrowed with the client rules.\n */\nfunction fieldTables(fields: readonly CompiledField[]): ReadonlySet<string> {\n const tables = new Set<string>();\n for (const slot of declaredFieldExpressions(fields)) datasetTableNames(slot.node, tables);\n return tables;\n}\n\n/**\n * The tables the client-tier rules can read.\n *\n * This is a client artifact's reachability: a server-tier rule is deferred on the device and\n * never resolves a table there, so it contributes nothing even if the artifact carried its\n * authored expression rather than the compiler's stub.\n */\nfunction clientRulesReadTables(rules: readonly CompiledRule[]): ReadonlySet<string> {\n return rulesReadTables(rules.filter((rule) => rule.evaluateOn === 'client'));\n}\n\n/** The identity a supplied declaration is filed under: a pin names a table and a version. */\nfunction pinKey(tableId: string, tableVersion: number): string {\n return `${tableId}\\u0000${String(tableVersion)}`;\n}\n\n/** The digest each supplied declaration binds, keyed by the table and version it describes. */\nexport function suppliedDigestsOf(\n datasets: readonly CompiledDatasetDeclaration[],\n): ReadonlyMap<string, string> {\n const digests = new Map<string, string>();\n for (const dataset of datasets) {\n const key = pinKey(dataset.tableId, dataset.tableVersion);\n // The first declaration wins, as the version set does: one supplied declaration per version\n // is the installation contract, and a duplicate is reported there rather than here.\n if (!digests.has(key)) digests.set(key, dataset.sha256);\n }\n return digests;\n}\n\n/** A pin the artifact wanted to state but had no digest to bind it with. */\nexport interface DatasetPinGap {\n /** The authored position, so the diagnostic points at the entry an author can fix. */\n readonly index: number;\n readonly tableId: string;\n readonly tableVersion: number;\n}\n\n/**\n * The dataset pins a compiled artifact carries: only the tables some expression in that artifact\n * can read.\n *\n * A pin is a promise that the host must hold that table, so a pin nothing can reach asks every\n * device to carry bytes no evaluation can use. A server artifact keeps every table one of its\n * rules reads; a client artifact narrows that further to the tables a client-tier rule reads,\n * because every server-tier rule became a deferred stub. A declared field's own expressions are\n * device-side in both tiers, so their tables are kept either way. The digest comes from the\n * supplied compiled declaration: the artifact binds the table's canonical bytes, not only its\n * version (`DATA-4.1.6`). A kept pin with no supplied declaration is returned as a gap rather\n * than silently dropped, so the author is told which table to pass.\n */\nexport function artifactDatasetPins(\n document: Record<string, unknown>,\n rules: readonly CompiledRule[],\n fields: readonly CompiledField[],\n target: Tier,\n suppliedDigests: ReadonlyMap<string, string>,\n): { readonly pins: readonly DatasetRef[]; readonly gaps: readonly DatasetPinGap[] } {\n const ruleTables = target === 'client' ? clientRulesReadTables(rules) : rulesReadTables(rules);\n const readable = new Set<string>([...ruleTables, ...fieldTables(fields)]);\n const pins: DatasetRef[] = [];\n const gaps: DatasetPinGap[] = [];\n listAt(document, 'datasets').forEach((ref, index) => {\n if (!isRecord(ref)) return;\n const tableId = textAt(ref, 'tableId');\n const tableVersion = ref['tableVersion'];\n if (\n tableId === undefined ||\n typeof tableVersion !== 'number' ||\n !Number.isSafeInteger(tableVersion)\n ) {\n return;\n }\n if (!readable.has(tableId)) return;\n const sha256 = suppliedDigests.get(pinKey(tableId, tableVersion));\n if (sha256 === undefined) {\n gaps.push({ index, tableId, tableVersion });\n return;\n }\n pins.push({ tableId, tableVersion, sha256 });\n });\n return { pins, gaps };\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CompiledField, CompiledRule, LayoutNode } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
import type { CompileWarning } from './warning.js';
|
|
3
|
+
import type { CompiledRuleEntry } from './rules.js';
|
|
4
|
+
import type { RawLayoutNode } from '../layout/read.js';
|
|
5
|
+
/**
|
|
6
|
+
* The constructs that can only be inert, reported as advice rather than as a refusal.
|
|
7
|
+
*
|
|
8
|
+
* The principle: a diagnostic refuses a document only when the document alone proves the
|
|
9
|
+
* construct cannot mean what it appears to. An inert construct is not that proof. A constant
|
|
10
|
+
* `visible: false` hides a field on purpose and a `compute: false` writes a constant; an
|
|
11
|
+
* unplaced field may be rendered by a host or read by a rule; an instruction-only step is a
|
|
12
|
+
* legitimate page. What remains after those are set aside is dead weight: a step that places
|
|
13
|
+
* nothing at all (`EMPTY_STEP`) and a field a declared layout never places and nothing reads
|
|
14
|
+
* (`UNUSED_FIELD`). A rule whose condition is literally `false` is the same kind of finding and
|
|
15
|
+
* states `UNSATISFIABLE_CONDITION` through `condition-warnings`, because the expression lint
|
|
16
|
+
* already proves it and one path earns one warning. The compiler names each with a warning code,
|
|
17
|
+
* so a host shows it beside the artifact without refusing the author's edit.
|
|
18
|
+
*
|
|
19
|
+
* A message key declared and never named is deliberately **not** warned about. The catalogue is
|
|
20
|
+
* part of the artifact a host may address directly, and an author may declare a key ahead of the
|
|
21
|
+
* slot that names it; a warning would penalise staged authoring for a construct the document
|
|
22
|
+
* cannot prove is a mistake.
|
|
23
|
+
*/
|
|
24
|
+
/** A warning that names a dead construct rather than a defect. */
|
|
25
|
+
export declare function deadWeightWarnings(document: Record<string, unknown>, entries: readonly CompiledRuleEntry[], declared: readonly CompiledRule[], layout: readonly LayoutNode[], rawLayout: readonly RawLayoutNode[], fields: readonly CompiledField[]): readonly CompileWarning[];
|
|
26
|
+
//# sourceMappingURL=dead-weight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dead-weight.d.ts","sourceRoot":"","sources":["../../src/compile/dead-weight.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EAGZ,UAAU,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AAEH,kEAAkE;AAClE,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,EAAE,SAAS,iBAAiB,EAAE,EACrC,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,SAAS,EAAE,SAAS,aAAa,EAAE,EACnC,MAAM,EAAE,SAAS,aAAa,EAAE,GAC/B,SAAS,cAAc,EAAE,CAK3B"}
|