@azx-pbc/axiom-runtime 0.0.0-stage → 0.0.5
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 +714 -2
- package/dist/cache/index.d.ts +191 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +361 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/canonical/jcs.d.ts +78 -0
- package/dist/canonical/jcs.d.ts.map +1 -0
- package/dist/canonical/jcs.js +500 -0
- package/dist/canonical/jcs.js.map +1 -0
- package/dist/canonical/restricted-json.d.ts +7 -0
- package/dist/canonical/restricted-json.d.ts.map +1 -0
- package/dist/canonical/restricted-json.js +318 -0
- package/dist/canonical/restricted-json.js.map +1 -0
- package/dist/canonical/restricted-value.d.ts +59 -0
- package/dist/canonical/restricted-value.d.ts.map +1 -0
- package/dist/canonical/restricted-value.js +156 -0
- package/dist/canonical/restricted-value.js.map +1 -0
- package/dist/canonical/restricted.d.ts +85 -0
- package/dist/canonical/restricted.d.ts.map +1 -0
- package/dist/canonical/restricted.js +163 -0
- package/dist/canonical/restricted.js.map +1 -0
- package/dist/canonical/signature.d.ts +38 -0
- package/dist/canonical/signature.d.ts.map +1 -0
- package/dist/canonical/signature.js +47 -0
- package/dist/canonical/signature.js.map +1 -0
- package/dist/eval/access/delivery.d.ts +63 -0
- package/dist/eval/access/delivery.d.ts.map +1 -0
- package/dist/eval/access/delivery.js +98 -0
- package/dist/eval/access/delivery.js.map +1 -0
- package/dist/eval/access/overlay.d.ts +72 -0
- package/dist/eval/access/overlay.d.ts.map +1 -0
- package/dist/eval/access/overlay.js +402 -0
- package/dist/eval/access/overlay.js.map +1 -0
- package/dist/eval/access/projection.d.ts +159 -0
- package/dist/eval/access/projection.d.ts.map +1 -0
- package/dist/eval/access/projection.js +211 -0
- package/dist/eval/access/projection.js.map +1 -0
- package/dist/eval/access/window.d.ts +128 -0
- package/dist/eval/access/window.d.ts.map +1 -0
- package/dist/eval/access/window.js +254 -0
- package/dist/eval/access/window.js.map +1 -0
- package/dist/eval/access/write.d.ts +113 -0
- package/dist/eval/access/write.d.ts.map +1 -0
- package/dist/eval/access/write.js +119 -0
- package/dist/eval/access/write.js.map +1 -0
- package/dist/eval/addressing.d.ts +131 -0
- package/dist/eval/addressing.d.ts.map +1 -0
- package/dist/eval/addressing.js +270 -0
- package/dist/eval/addressing.js.map +1 -0
- package/dist/eval/budget.d.ts +143 -0
- package/dist/eval/budget.d.ts.map +1 -0
- package/dist/eval/budget.js +387 -0
- package/dist/eval/budget.js.map +1 -0
- package/dist/eval/computed.d.ts +46 -0
- package/dist/eval/computed.d.ts.map +1 -0
- package/dist/eval/computed.js +89 -0
- package/dist/eval/computed.js.map +1 -0
- package/dist/eval/denials.d.ts +64 -0
- package/dist/eval/denials.d.ts.map +1 -0
- package/dist/eval/denials.js +87 -0
- package/dist/eval/denials.js.map +1 -0
- package/dist/eval/engine/cancellation.d.ts +12 -0
- package/dist/eval/engine/cancellation.d.ts.map +1 -0
- package/dist/eval/engine/cancellation.js +56 -0
- package/dist/eval/engine/cancellation.js.map +1 -0
- package/dist/eval/engine/delta.d.ts +104 -0
- package/dist/eval/engine/delta.d.ts.map +1 -0
- package/dist/eval/engine/delta.js +466 -0
- package/dist/eval/engine/delta.js.map +1 -0
- package/dist/eval/engine/deps.d.ts +136 -0
- package/dist/eval/engine/deps.d.ts.map +1 -0
- package/dist/eval/engine/deps.js +345 -0
- package/dist/eval/engine/deps.js.map +1 -0
- package/dist/eval/engine/identity.d.ts +128 -0
- package/dist/eval/engine/identity.d.ts.map +1 -0
- package/dist/eval/engine/identity.js +398 -0
- package/dist/eval/engine/identity.js.map +1 -0
- package/dist/eval/engine/index.d.ts +200 -0
- package/dist/eval/engine/index.d.ts.map +1 -0
- package/dist/eval/engine/index.js +1242 -0
- package/dist/eval/engine/index.js.map +1 -0
- package/dist/eval/engine/measurement.d.ts +23 -0
- package/dist/eval/engine/measurement.d.ts.map +1 -0
- package/dist/eval/engine/measurement.js +42 -0
- package/dist/eval/engine/measurement.js.map +1 -0
- package/dist/eval/engine/naive.d.ts +19 -0
- package/dist/eval/engine/naive.d.ts.map +1 -0
- package/dist/eval/engine/naive.js +59 -0
- package/dist/eval/engine/naive.js.map +1 -0
- package/dist/eval/engine/ops.d.ts +214 -0
- package/dist/eval/engine/ops.d.ts.map +1 -0
- package/dist/eval/engine/ops.js +1422 -0
- package/dist/eval/engine/ops.js.map +1 -0
- package/dist/eval/engine/patches.d.ts +40 -0
- package/dist/eval/engine/patches.d.ts.map +1 -0
- package/dist/eval/engine/patches.js +125 -0
- package/dist/eval/engine/patches.js.map +1 -0
- package/dist/eval/engine/ports.d.ts +71 -0
- package/dist/eval/engine/ports.d.ts.map +1 -0
- package/dist/eval/engine/ports.js +2 -0
- package/dist/eval/engine/ports.js.map +1 -0
- package/dist/eval/engine/session.d.ts +116 -0
- package/dist/eval/engine/session.d.ts.map +1 -0
- package/dist/eval/engine/session.js +653 -0
- package/dist/eval/engine/session.js.map +1 -0
- package/dist/eval/engine/snapshot.d.ts +97 -0
- package/dist/eval/engine/snapshot.d.ts.map +1 -0
- package/dist/eval/engine/snapshot.js +221 -0
- package/dist/eval/engine/snapshot.js.map +1 -0
- package/dist/eval/engine/subscriptions.d.ts +47 -0
- package/dist/eval/engine/subscriptions.d.ts.map +1 -0
- package/dist/eval/engine/subscriptions.js +103 -0
- package/dist/eval/engine/subscriptions.js.map +1 -0
- package/dist/eval/engine/trace.d.ts +77 -0
- package/dist/eval/engine/trace.d.ts.map +1 -0
- package/dist/eval/engine/trace.js +140 -0
- package/dist/eval/engine/trace.js.map +1 -0
- package/dist/eval/error-diagnostic.d.ts +26 -0
- package/dist/eval/error-diagnostic.d.ts.map +1 -0
- package/dist/eval/error-diagnostic.js +63 -0
- package/dist/eval/error-diagnostic.js.map +1 -0
- package/dist/eval/evaluate-expr.d.ts +44 -0
- package/dist/eval/evaluate-expr.d.ts.map +1 -0
- package/dist/eval/evaluate-expr.js +149 -0
- package/dist/eval/evaluate-expr.js.map +1 -0
- package/dist/eval/evaluate.d.ts +282 -0
- package/dist/eval/evaluate.d.ts.map +1 -0
- package/dist/eval/evaluate.js +391 -0
- package/dist/eval/evaluate.js.map +1 -0
- package/dist/eval/evolution/relocate.d.ts +72 -0
- package/dist/eval/evolution/relocate.d.ts.map +1 -0
- package/dist/eval/evolution/relocate.js +427 -0
- package/dist/eval/evolution/relocate.js.map +1 -0
- package/dist/eval/evolution/select.d.ts +11 -0
- package/dist/eval/evolution/select.d.ts.map +1 -0
- package/dist/eval/evolution/select.js +53 -0
- package/dist/eval/evolution/select.js.map +1 -0
- package/dist/eval/evolution/upcast.d.ts +13 -0
- package/dist/eval/evolution/upcast.d.ts.map +1 -0
- package/dist/eval/evolution/upcast.js +88 -0
- package/dist/eval/evolution/upcast.js.map +1 -0
- package/dist/eval/expr/aggregates.d.ts +75 -0
- package/dist/eval/expr/aggregates.d.ts.map +1 -0
- package/dist/eval/expr/aggregates.js +991 -0
- package/dist/eval/expr/aggregates.js.map +1 -0
- package/dist/eval/expr/arithmetic.d.ts +26 -0
- package/dist/eval/expr/arithmetic.d.ts.map +1 -0
- package/dist/eval/expr/arithmetic.js +387 -0
- package/dist/eval/expr/arithmetic.js.map +1 -0
- package/dist/eval/expr/between.d.ts +17 -0
- package/dist/eval/expr/between.d.ts.map +1 -0
- package/dist/eval/expr/between.js +46 -0
- package/dist/eval/expr/between.js.map +1 -0
- package/dist/eval/expr/binder.d.ts +96 -0
- package/dist/eval/expr/binder.d.ts.map +1 -0
- package/dist/eval/expr/binder.js +253 -0
- package/dist/eval/expr/binder.js.map +1 -0
- package/dist/eval/expr/call-dispatch.d.ts +28 -0
- package/dist/eval/expr/call-dispatch.d.ts.map +1 -0
- package/dist/eval/expr/call-dispatch.js +114 -0
- package/dist/eval/expr/call-dispatch.js.map +1 -0
- package/dist/eval/expr/collections.d.ts +20 -0
- package/dist/eval/expr/collections.d.ts.map +1 -0
- package/dist/eval/expr/collections.js +66 -0
- package/dist/eval/expr/collections.js.map +1 -0
- package/dist/eval/expr/compare.d.ts +36 -0
- package/dist/eval/expr/compare.d.ts.map +1 -0
- package/dist/eval/expr/compare.js +115 -0
- package/dist/eval/expr/compare.js.map +1 -0
- package/dist/eval/expr/datasets.d.ts +28 -0
- package/dist/eval/expr/datasets.d.ts.map +1 -0
- package/dist/eval/expr/datasets.js +304 -0
- package/dist/eval/expr/datasets.js.map +1 -0
- package/dist/eval/expr/digest.d.ts +23 -0
- package/dist/eval/expr/digest.d.ts.map +1 -0
- package/dist/eval/expr/digest.js +89 -0
- package/dist/eval/expr/digest.js.map +1 -0
- package/dist/eval/expr/domains.d.ts +19 -0
- package/dist/eval/expr/domains.d.ts.map +1 -0
- package/dist/eval/expr/domains.js +18 -0
- package/dist/eval/expr/domains.js.map +1 -0
- package/dist/eval/expr/host.d.ts +152 -0
- package/dist/eval/expr/host.d.ts.map +1 -0
- package/dist/eval/expr/host.js +36 -0
- package/dist/eval/expr/host.js.map +1 -0
- package/dist/eval/expr/lists.d.ts +24 -0
- package/dist/eval/expr/lists.d.ts.map +1 -0
- package/dist/eval/expr/lists.js +155 -0
- package/dist/eval/expr/lists.js.map +1 -0
- package/dist/eval/expr/member.d.ts +15 -0
- package/dist/eval/expr/member.d.ts.map +1 -0
- package/dist/eval/expr/member.js +32 -0
- package/dist/eval/expr/member.js.map +1 -0
- package/dist/eval/expr/money-ops.d.ts +10 -0
- package/dist/eval/expr/money-ops.d.ts.map +1 -0
- package/dist/eval/expr/money-ops.js +17 -0
- package/dist/eval/expr/money-ops.js.map +1 -0
- package/dist/eval/expr/operands.d.ts +27 -0
- package/dist/eval/expr/operands.d.ts.map +1 -0
- package/dist/eval/expr/operands.js +167 -0
- package/dist/eval/expr/operands.js.map +1 -0
- package/dist/eval/expr/presence.d.ts +27 -0
- package/dist/eval/expr/presence.d.ts.map +1 -0
- package/dist/eval/expr/presence.js +140 -0
- package/dist/eval/expr/presence.js.map +1 -0
- package/dist/eval/expr/records.d.ts +22 -0
- package/dist/eval/expr/records.d.ts.map +1 -0
- package/dist/eval/expr/records.js +101 -0
- package/dist/eval/expr/records.js.map +1 -0
- package/dist/eval/expr/rule-refs.d.ts +25 -0
- package/dist/eval/expr/rule-refs.d.ts.map +1 -0
- package/dist/eval/expr/rule-refs.js +60 -0
- package/dist/eval/expr/rule-refs.js.map +1 -0
- package/dist/eval/expr/sequences.d.ts +26 -0
- package/dist/eval/expr/sequences.d.ts.map +1 -0
- package/dist/eval/expr/sequences.js +151 -0
- package/dist/eval/expr/sequences.js.map +1 -0
- package/dist/eval/expr/value.d.ts +99 -0
- package/dist/eval/expr/value.d.ts.map +1 -0
- package/dist/eval/expr/value.js +14 -0
- package/dist/eval/expr/value.js.map +1 -0
- package/dist/eval/expression.d.ts +142 -0
- package/dist/eval/expression.d.ts.map +1 -0
- package/dist/eval/expression.js +446 -0
- package/dist/eval/expression.js.map +1 -0
- package/dist/eval/firing.d.ts +68 -0
- package/dist/eval/firing.d.ts.map +1 -0
- package/dist/eval/firing.js +222 -0
- package/dist/eval/firing.js.map +1 -0
- package/dist/eval/gate.d.ts +110 -0
- package/dist/eval/gate.d.ts.map +1 -0
- package/dist/eval/gate.js +278 -0
- package/dist/eval/gate.js.map +1 -0
- package/dist/eval/layout-visibility.d.ts +18 -0
- package/dist/eval/layout-visibility.d.ts.map +1 -0
- package/dist/eval/layout-visibility.js +61 -0
- package/dist/eval/layout-visibility.js.map +1 -0
- package/dist/eval/option-availability.d.ts +26 -0
- package/dist/eval/option-availability.d.ts.map +1 -0
- package/dist/eval/option-availability.js +580 -0
- package/dist/eval/option-availability.js.map +1 -0
- package/dist/eval/options-boundary.d.ts +15 -0
- package/dist/eval/options-boundary.d.ts.map +1 -0
- package/dist/eval/options-boundary.js +40 -0
- package/dist/eval/options-boundary.js.map +1 -0
- package/dist/eval/options.d.ts +99 -0
- package/dist/eval/options.d.ts.map +1 -0
- package/dist/eval/options.js +96 -0
- package/dist/eval/options.js.map +1 -0
- package/dist/eval/overrides.d.ts +116 -0
- package/dist/eval/overrides.d.ts.map +1 -0
- package/dist/eval/overrides.js +176 -0
- package/dist/eval/overrides.js.map +1 -0
- package/dist/eval/paths.d.ts +25 -0
- package/dist/eval/paths.d.ts.map +1 -0
- package/dist/eval/paths.js +47 -0
- package/dist/eval/paths.js.map +1 -0
- package/dist/eval/presentation-reads.d.ts +20 -0
- package/dist/eval/presentation-reads.d.ts.map +1 -0
- package/dist/eval/presentation-reads.js +2 -0
- package/dist/eval/presentation-reads.js.map +1 -0
- package/dist/eval/presentation.d.ts +122 -0
- package/dist/eval/presentation.d.ts.map +1 -0
- package/dist/eval/presentation.js +255 -0
- package/dist/eval/presentation.js.map +1 -0
- package/dist/eval/reader/context-value.d.ts +41 -0
- package/dist/eval/reader/context-value.d.ts.map +1 -0
- package/dist/eval/reader/context-value.js +129 -0
- package/dist/eval/reader/context-value.js.map +1 -0
- package/dist/eval/reader/covered.d.ts +53 -0
- package/dist/eval/reader/covered.d.ts.map +1 -0
- package/dist/eval/reader/covered.js +139 -0
- package/dist/eval/reader/covered.js.map +1 -0
- package/dist/eval/reader/declarations.d.ts +182 -0
- package/dist/eval/reader/declarations.d.ts.map +1 -0
- package/dist/eval/reader/declarations.js +153 -0
- package/dist/eval/reader/declarations.js.map +1 -0
- package/dist/eval/reader/member-access.d.ts +87 -0
- package/dist/eval/reader/member-access.d.ts.map +1 -0
- package/dist/eval/reader/member-access.js +212 -0
- package/dist/eval/reader/member-access.js.map +1 -0
- package/dist/eval/reader/memo.d.ts +34 -0
- package/dist/eval/reader/memo.d.ts.map +1 -0
- package/dist/eval/reader/memo.js +67 -0
- package/dist/eval/reader/memo.js.map +1 -0
- package/dist/eval/reader/overlay.d.ts +74 -0
- package/dist/eval/reader/overlay.d.ts.map +1 -0
- package/dist/eval/reader/overlay.js +365 -0
- package/dist/eval/reader/overlay.js.map +1 -0
- package/dist/eval/reader/questions.d.ts +37 -0
- package/dist/eval/reader/questions.d.ts.map +1 -0
- package/dist/eval/reader/questions.js +78 -0
- package/dist/eval/reader/questions.js.map +1 -0
- package/dist/eval/reader/resolve.d.ts +84 -0
- package/dist/eval/reader/resolve.d.ts.map +1 -0
- package/dist/eval/reader/resolve.js +310 -0
- package/dist/eval/reader/resolve.js.map +1 -0
- package/dist/eval/reader/value-read.d.ts +50 -0
- package/dist/eval/reader/value-read.d.ts.map +1 -0
- package/dist/eval/reader/value-read.js +133 -0
- package/dist/eval/reader/value-read.js.map +1 -0
- package/dist/eval/reader/withheld.d.ts +48 -0
- package/dist/eval/reader/withheld.d.ts.map +1 -0
- package/dist/eval/reader/withheld.js +108 -0
- package/dist/eval/reader/withheld.js.map +1 -0
- package/dist/eval/reader-paths.d.ts +24 -0
- package/dist/eval/reader-paths.d.ts.map +1 -0
- package/dist/eval/reader-paths.js +23 -0
- package/dist/eval/reader-paths.js.map +1 -0
- package/dist/eval/reader.d.ts +281 -0
- package/dist/eval/reader.d.ts.map +1 -0
- package/dist/eval/reader.js +560 -0
- package/dist/eval/reader.js.map +1 -0
- package/dist/eval/receipt.d.ts +37 -0
- package/dist/eval/receipt.d.ts.map +1 -0
- package/dist/eval/receipt.js +222 -0
- package/dist/eval/receipt.js.map +1 -0
- package/dist/eval/report/assemble.d.ts +84 -0
- package/dist/eval/report/assemble.d.ts.map +1 -0
- package/dist/eval/report/assemble.js +277 -0
- package/dist/eval/report/assemble.js.map +1 -0
- package/dist/eval/report/fold.d.ts +18 -0
- package/dist/eval/report/fold.d.ts.map +1 -0
- package/dist/eval/report/fold.js +58 -0
- package/dist/eval/report/fold.js.map +1 -0
- package/dist/eval/rule/alternatives.d.ts +23 -0
- package/dist/eval/rule/alternatives.d.ts.map +1 -0
- package/dist/eval/rule/alternatives.js +46 -0
- package/dist/eval/rule/alternatives.js.map +1 -0
- package/dist/eval/rule/behaviour.d.ts +47 -0
- package/dist/eval/rule/behaviour.d.ts.map +1 -0
- package/dist/eval/rule/behaviour.js +249 -0
- package/dist/eval/rule/behaviour.js.map +1 -0
- package/dist/eval/rule/compute.d.ts +46 -0
- package/dist/eval/rule/compute.d.ts.map +1 -0
- package/dist/eval/rule/compute.js +158 -0
- package/dist/eval/rule/compute.js.map +1 -0
- package/dist/eval/rule/create-state.d.ts +42 -0
- package/dist/eval/rule/create-state.d.ts.map +1 -0
- package/dist/eval/rule/create-state.js +134 -0
- package/dist/eval/rule/create-state.js.map +1 -0
- package/dist/eval/rule/diagnostics.d.ts +24 -0
- package/dist/eval/rule/diagnostics.d.ts.map +1 -0
- package/dist/eval/rule/diagnostics.js +45 -0
- package/dist/eval/rule/diagnostics.js.map +1 -0
- package/dist/eval/rule/execution.d.ts +24 -0
- package/dist/eval/rule/execution.d.ts.map +1 -0
- package/dist/eval/rule/execution.js +495 -0
- package/dist/eval/rule/execution.js.map +1 -0
- package/dist/eval/rule/gate.d.ts +12 -0
- package/dist/eval/rule/gate.d.ts.map +1 -0
- package/dist/eval/rule/gate.js +34 -0
- package/dist/eval/rule/gate.js.map +1 -0
- package/dist/eval/rule/item.d.ts +11 -0
- package/dist/eval/rule/item.d.ts.map +1 -0
- package/dist/eval/rule/item.js +265 -0
- package/dist/eval/rule/item.js.map +1 -0
- package/dist/eval/rule/prepare.d.ts +64 -0
- package/dist/eval/rule/prepare.d.ts.map +1 -0
- package/dist/eval/rule/prepare.js +131 -0
- package/dist/eval/rule/prepare.js.map +1 -0
- package/dist/eval/rule/result.d.ts +97 -0
- package/dist/eval/rule/result.d.ts.map +1 -0
- package/dist/eval/rule/result.js +347 -0
- package/dist/eval/rule/result.js.map +1 -0
- package/dist/eval/rule/runner.d.ts +128 -0
- package/dist/eval/rule/runner.d.ts.map +1 -0
- package/dist/eval/rule/runner.js +296 -0
- package/dist/eval/rule/runner.js.map +1 -0
- package/dist/eval/rule/screen.d.ts +32 -0
- package/dist/eval/rule/screen.d.ts.map +1 -0
- package/dist/eval/rule/screen.js +73 -0
- package/dist/eval/rule/screen.js.map +1 -0
- package/dist/eval/rule/state.d.ts +137 -0
- package/dist/eval/rule/state.d.ts.map +1 -0
- package/dist/eval/rule/state.js +2 -0
- package/dist/eval/rule/state.js.map +1 -0
- package/dist/eval/rule/steps.d.ts +44 -0
- package/dist/eval/rule/steps.d.ts.map +1 -0
- package/dist/eval/rule/steps.js +367 -0
- package/dist/eval/rule/steps.js.map +1 -0
- package/dist/eval/rule/visibility.d.ts +18 -0
- package/dist/eval/rule/visibility.d.ts.map +1 -0
- package/dist/eval/rule/visibility.js +79 -0
- package/dist/eval/rule/visibility.js.map +1 -0
- package/dist/eval/seal.d.ts +74 -0
- package/dist/eval/seal.d.ts.map +1 -0
- package/dist/eval/seal.js +154 -0
- package/dist/eval/seal.js.map +1 -0
- package/dist/eval/signature-coverage.d.ts +19 -0
- package/dist/eval/signature-coverage.d.ts.map +1 -0
- package/dist/eval/signature-coverage.js +160 -0
- package/dist/eval/signature-coverage.js.map +1 -0
- package/dist/eval/state/derive.d.ts +72 -0
- package/dist/eval/state/derive.d.ts.map +1 -0
- package/dist/eval/state/derive.js +61 -0
- package/dist/eval/state/derive.js.map +1 -0
- package/dist/eval/state/describe.d.ts +18 -0
- package/dist/eval/state/describe.d.ts.map +1 -0
- package/dist/eval/state/describe.js +19 -0
- package/dist/eval/state/describe.js.map +1 -0
- package/dist/eval/state/field-state.d.ts +471 -0
- package/dist/eval/state/field-state.d.ts.map +1 -0
- package/dist/eval/state/field-state.js +1604 -0
- package/dist/eval/state/field-state.js.map +1 -0
- package/dist/eval/state/measurement.d.ts +136 -0
- package/dist/eval/state/measurement.d.ts.map +1 -0
- package/dist/eval/state/measurement.js +209 -0
- package/dist/eval/state/measurement.js.map +1 -0
- package/dist/eval/state/options.d.ts +21 -0
- package/dist/eval/state/options.d.ts.map +1 -0
- package/dist/eval/state/options.js +3 -0
- package/dist/eval/state/options.js.map +1 -0
- package/dist/eval/state/readiness.d.ts +400 -0
- package/dist/eval/state/readiness.d.ts.map +1 -0
- package/dist/eval/state/readiness.js +1067 -0
- package/dist/eval/state/readiness.js.map +1 -0
- package/dist/eval/state/snapshot.d.ts +130 -0
- package/dist/eval/state/snapshot.d.ts.map +1 -0
- package/dist/eval/state/snapshot.js +35 -0
- package/dist/eval/state/snapshot.js.map +1 -0
- package/dist/eval/state/unavailable-options.d.ts +54 -0
- package/dist/eval/state/unavailable-options.d.ts.map +1 -0
- package/dist/eval/state/unavailable-options.js +82 -0
- package/dist/eval/state/unavailable-options.js.map +1 -0
- package/dist/eval/state/value-state.d.ts +38 -0
- package/dist/eval/state/value-state.d.ts.map +1 -0
- package/dist/eval/state/value-state.js +52 -0
- package/dist/eval/state/value-state.js.map +1 -0
- package/dist/eval/submission/admission.d.ts +50 -0
- package/dist/eval/submission/admission.d.ts.map +1 -0
- package/dist/eval/submission/admission.js +174 -0
- package/dist/eval/submission/admission.js.map +1 -0
- package/dist/eval/submission/authority.d.ts +71 -0
- package/dist/eval/submission/authority.d.ts.map +1 -0
- package/dist/eval/submission/authority.js +118 -0
- package/dist/eval/submission/authority.js.map +1 -0
- package/dist/eval/submission/datasets.d.ts +28 -0
- package/dist/eval/submission/datasets.d.ts.map +1 -0
- package/dist/eval/submission/datasets.js +109 -0
- package/dist/eval/submission/datasets.js.map +1 -0
- package/dist/eval/submission/index.d.ts +15 -0
- package/dist/eval/submission/index.d.ts.map +1 -0
- package/dist/eval/submission/index.js +13 -0
- package/dist/eval/submission/index.js.map +1 -0
- package/dist/eval/submission/refusals.d.ts +103 -0
- package/dist/eval/submission/refusals.d.ts.map +1 -0
- package/dist/eval/submission/refusals.js +15 -0
- package/dist/eval/submission/refusals.js.map +1 -0
- package/dist/eval/submission/signatures.d.ts +7 -0
- package/dist/eval/submission/signatures.d.ts.map +1 -0
- package/dist/eval/submission/signatures.js +215 -0
- package/dist/eval/submission/signatures.js.map +1 -0
- package/dist/eval/submission/writes.d.ts +51 -0
- package/dist/eval/submission/writes.d.ts.map +1 -0
- package/dist/eval/submission/writes.js +203 -0
- package/dist/eval/submission/writes.js.map +1 -0
- package/dist/eval/submission.d.ts +53 -0
- package/dist/eval/submission.d.ts.map +1 -0
- package/dist/eval/submission.js +521 -0
- package/dist/eval/submission.js.map +1 -0
- package/dist/eval/suggestions-to-engine.d.ts +18 -0
- package/dist/eval/suggestions-to-engine.d.ts.map +1 -0
- package/dist/eval/suggestions-to-engine.js +40 -0
- package/dist/eval/suggestions-to-engine.js.map +1 -0
- package/dist/eval/suggestions.d.ts +17 -0
- package/dist/eval/suggestions.d.ts.map +1 -0
- package/dist/eval/suggestions.js +314 -0
- package/dist/eval/suggestions.js.map +1 -0
- package/dist/eval/undecided.d.ts +64 -0
- package/dist/eval/undecided.d.ts.map +1 -0
- package/dist/eval/undecided.js +101 -0
- package/dist/eval/undecided.js.map +1 -0
- package/dist/eval/verdict.d.ts +66 -0
- package/dist/eval/verdict.d.ts.map +1 -0
- package/dist/eval/verdict.js +106 -0
- package/dist/eval/verdict.js.map +1 -0
- package/dist/eval/verify-signature.d.ts +78 -0
- package/dist/eval/verify-signature.d.ts.map +1 -0
- package/dist/eval/verify-signature.js +185 -0
- package/dist/eval/verify-signature.js.map +1 -0
- package/dist/eval/version-dispatch.d.ts +38 -0
- package/dist/eval/version-dispatch.d.ts.map +1 -0
- package/dist/eval/version-dispatch.js +61 -0
- package/dist/eval/version-dispatch.js.map +1 -0
- package/dist/eval/visibility.d.ts +33 -0
- package/dist/eval/visibility.d.ts.map +1 -0
- package/dist/eval/visibility.js +83 -0
- package/dist/eval/visibility.js.map +1 -0
- package/dist/evaluate.d.ts +24 -0
- package/dist/evaluate.d.ts.map +1 -0
- package/dist/evaluate.js +18 -0
- package/dist/evaluate.js.map +1 -0
- package/dist/expr/builtin-docs.d.ts +51 -0
- package/dist/expr/builtin-docs.d.ts.map +1 -0
- package/dist/expr/builtin-docs.js +874 -0
- package/dist/expr/builtin-docs.js.map +1 -0
- package/dist/expr/builtins.d.ts +50 -0
- package/dist/expr/builtins.d.ts.map +1 -0
- package/dist/expr/builtins.js +966 -0
- package/dist/expr/builtins.js.map +1 -0
- package/dist/expr/decimal-precision.d.ts +39 -0
- package/dist/expr/decimal-precision.d.ts.map +1 -0
- package/dist/expr/decimal-precision.js +62 -0
- package/dist/expr/decimal-precision.js.map +1 -0
- package/dist/expr/decimal.d.ts +172 -0
- package/dist/expr/decimal.d.ts.map +1 -0
- package/dist/expr/decimal.js +782 -0
- package/dist/expr/decimal.js.map +1 -0
- package/dist/expr/deprecations.d.ts +34 -0
- package/dist/expr/deprecations.d.ts.map +1 -0
- package/dist/expr/deprecations.js +17 -0
- package/dist/expr/deprecations.js.map +1 -0
- package/dist/expr/diagnostics.d.ts +21 -0
- package/dist/expr/diagnostics.d.ts.map +1 -0
- package/dist/expr/diagnostics.js +231 -0
- package/dist/expr/diagnostics.js.map +1 -0
- package/dist/expr/direction.d.ts +30 -0
- package/dist/expr/direction.d.ts.map +1 -0
- package/dist/expr/direction.js +77 -0
- package/dist/expr/direction.js.map +1 -0
- package/dist/expr/example-expression.d.ts +62 -0
- package/dist/expr/example-expression.d.ts.map +1 -0
- package/dist/expr/example-expression.js +670 -0
- package/dist/expr/example-expression.js.map +1 -0
- package/dist/expr/instant.d.ts +49 -0
- package/dist/expr/instant.d.ts.map +1 -0
- package/dist/expr/instant.js +111 -0
- package/dist/expr/instant.js.map +1 -0
- package/dist/expr/logic.d.ts +17 -0
- package/dist/expr/logic.d.ts.map +1 -0
- package/dist/expr/logic.js +65 -0
- package/dist/expr/logic.js.map +1 -0
- package/dist/expr/messages.d.ts +45 -0
- package/dist/expr/messages.d.ts.map +1 -0
- package/dist/expr/messages.js +280 -0
- package/dist/expr/messages.js.map +1 -0
- package/dist/expr/money.d.ts +38 -0
- package/dist/expr/money.d.ts.map +1 -0
- package/dist/expr/money.js +127 -0
- package/dist/expr/money.js.map +1 -0
- package/dist/expr/ordering.d.ts +56 -0
- package/dist/expr/ordering.d.ts.map +1 -0
- package/dist/expr/ordering.js +167 -0
- package/dist/expr/ordering.js.map +1 -0
- package/dist/expr/pattern.d.ts +44 -0
- package/dist/expr/pattern.d.ts.map +1 -0
- package/dist/expr/pattern.js +458 -0
- package/dist/expr/pattern.js.map +1 -0
- package/dist/expr/plain-date.d.ts +90 -0
- package/dist/expr/plain-date.d.ts.map +1 -0
- package/dist/expr/plain-date.js +230 -0
- package/dist/expr/plain-date.js.map +1 -0
- package/dist/expr/plural-categories.d.ts +8 -0
- package/dist/expr/plural-categories.d.ts.map +1 -0
- package/dist/expr/plural-categories.js +15 -0
- package/dist/expr/plural-categories.js.map +1 -0
- package/dist/expr/plural-keys.d.ts +39 -0
- package/dist/expr/plural-keys.d.ts.map +1 -0
- package/dist/expr/plural-keys.js +46 -0
- package/dist/expr/plural-keys.js.map +1 -0
- package/dist/expr/plural.d.ts +33 -0
- package/dist/expr/plural.d.ts.map +1 -0
- package/dist/expr/plural.js +50 -0
- package/dist/expr/plural.js.map +1 -0
- package/dist/expr/quantity.d.ts +31 -0
- package/dist/expr/quantity.d.ts.map +1 -0
- package/dist/expr/quantity.js +83 -0
- package/dist/expr/quantity.js.map +1 -0
- package/dist/expr/reduce.d.ts +50 -0
- package/dist/expr/reduce.d.ts.map +1 -0
- package/dist/expr/reduce.js +236 -0
- package/dist/expr/reduce.js.map +1 -0
- package/dist/expr/regex.d.ts +108 -0
- package/dist/expr/regex.d.ts.map +1 -0
- package/dist/expr/regex.js +1210 -0
- package/dist/expr/regex.js.map +1 -0
- package/dist/expr/select-locale.d.ts +67 -0
- package/dist/expr/select-locale.d.ts.map +1 -0
- package/dist/expr/select-locale.js +219 -0
- package/dist/expr/select-locale.js.map +1 -0
- package/dist/expr/sequences.d.ts +123 -0
- package/dist/expr/sequences.d.ts.map +1 -0
- package/dist/expr/sequences.js +234 -0
- package/dist/expr/sequences.js.map +1 -0
- package/dist/expr/strings.d.ts +50 -0
- package/dist/expr/strings.d.ts.map +1 -0
- package/dist/expr/strings.js +184 -0
- package/dist/expr/strings.js.map +1 -0
- package/dist/expr/validation.d.ts +32 -0
- package/dist/expr/validation.d.ts.map +1 -0
- package/dist/expr/validation.js +182 -0
- package/dist/expr/validation.js.map +1 -0
- package/dist/graph/freeze.d.ts +4 -0
- package/dist/graph/freeze.d.ts.map +1 -0
- package/dist/graph/freeze.js +52 -0
- package/dist/graph/freeze.js.map +1 -0
- package/dist/graph/index.d.ts +15 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +13 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/inspect.d.ts +76 -0
- package/dist/graph/inspect.d.ts.map +1 -0
- package/dist/graph/inspect.js +263 -0
- package/dist/graph/inspect.js.map +1 -0
- package/dist/graph/read-walk.d.ts +101 -0
- package/dist/graph/read-walk.d.ts.map +1 -0
- package/dist/graph/read-walk.js +358 -0
- package/dist/graph/read-walk.js.map +1 -0
- package/dist/graph/record-index.d.ts +24 -0
- package/dist/graph/record-index.d.ts.map +1 -0
- package/dist/graph/record-index.js +35 -0
- package/dist/graph/record-index.js.map +1 -0
- package/dist/index.d.ts +104 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +139 -0
- package/dist/index.js.map +1 -0
- package/dist/lookup/digest.d.ts +51 -0
- package/dist/lookup/digest.d.ts.map +1 -0
- package/dist/lookup/digest.js +46 -0
- package/dist/lookup/digest.js.map +1 -0
- package/dist/lookup/index.d.ts +28 -0
- package/dist/lookup/index.d.ts.map +1 -0
- package/dist/lookup/index.js +27 -0
- package/dist/lookup/index.js.map +1 -0
- package/dist/lookup/install.d.ts +48 -0
- package/dist/lookup/install.d.ts.map +1 -0
- package/dist/lookup/install.js +315 -0
- package/dist/lookup/install.js.map +1 -0
- package/dist/lookup/pass.d.ts +55 -0
- package/dist/lookup/pass.d.ts.map +1 -0
- package/dist/lookup/pass.js +212 -0
- package/dist/lookup/pass.js.map +1 -0
- package/dist/lookup/pins.d.ts +34 -0
- package/dist/lookup/pins.d.ts.map +1 -0
- package/dist/lookup/pins.js +39 -0
- package/dist/lookup/pins.js.map +1 -0
- package/dist/lookup/provenance.d.ts +23 -0
- package/dist/lookup/provenance.d.ts.map +1 -0
- package/dist/lookup/provenance.js +78 -0
- package/dist/lookup/provenance.js.map +1 -0
- package/dist/lookup/readiness.d.ts +13 -0
- package/dist/lookup/readiness.d.ts.map +1 -0
- package/dist/lookup/readiness.js +57 -0
- package/dist/lookup/readiness.js.map +1 -0
- package/dist/lookup/resolve.d.ts +24 -0
- package/dist/lookup/resolve.d.ts.map +1 -0
- package/dist/lookup/resolve.js +201 -0
- package/dist/lookup/resolve.js.map +1 -0
- package/dist/lookup/store.d.ts +41 -0
- package/dist/lookup/store.d.ts.map +1 -0
- package/dist/lookup/store.js +74 -0
- package/dist/lookup/store.js.map +1 -0
- package/dist/model/access.d.ts +200 -0
- package/dist/model/access.d.ts.map +1 -0
- package/dist/model/access.js +125 -0
- package/dist/model/access.js.map +1 -0
- package/dist/model/artifact-members.d.ts +3 -0
- package/dist/model/artifact-members.d.ts.map +1 -0
- package/dist/model/artifact-members.js +38 -0
- package/dist/model/artifact-members.js.map +1 -0
- package/dist/model/composition.d.ts +47 -0
- package/dist/model/composition.d.ts.map +1 -0
- package/dist/model/composition.js +66 -0
- package/dist/model/composition.js.map +1 -0
- package/dist/model/domain.d.ts +51 -0
- package/dist/model/domain.d.ts.map +1 -0
- package/dist/model/domain.js +75 -0
- package/dist/model/domain.js.map +1 -0
- package/dist/model/duration.d.ts +31 -0
- package/dist/model/duration.d.ts.map +1 -0
- package/dist/model/duration.js +136 -0
- package/dist/model/duration.js.map +1 -0
- package/dist/model/errors.d.ts +58 -0
- package/dist/model/errors.d.ts.map +1 -0
- package/dist/model/errors.js +81 -0
- package/dist/model/errors.js.map +1 -0
- package/dist/model/evolution.d.ts +177 -0
- package/dist/model/evolution.d.ts.map +1 -0
- package/dist/model/evolution.js +5 -0
- package/dist/model/evolution.js.map +1 -0
- package/dist/model/expr-children.d.ts +15 -0
- package/dist/model/expr-children.d.ts.map +1 -0
- package/dist/model/expr-children.js +45 -0
- package/dist/model/expr-children.js.map +1 -0
- package/dist/model/guards.d.ts +9 -0
- package/dist/model/guards.d.ts.map +1 -0
- package/dist/model/guards.js +11 -0
- package/dist/model/guards.js.map +1 -0
- package/dist/model/input.d.ts +42 -0
- package/dist/model/input.d.ts.map +1 -0
- package/dist/model/input.js +26 -0
- package/dist/model/input.js.map +1 -0
- package/dist/model/integer.d.ts +14 -0
- package/dist/model/integer.d.ts.map +1 -0
- package/dist/model/integer.js +16 -0
- package/dist/model/integer.js.map +1 -0
- package/dist/model/intrinsic.d.ts +18 -0
- package/dist/model/intrinsic.d.ts.map +1 -0
- package/dist/model/intrinsic.js +21 -0
- package/dist/model/intrinsic.js.map +1 -0
- package/dist/model/layout.d.ts +129 -0
- package/dist/model/layout.d.ts.map +1 -0
- package/dist/model/layout.js +2 -0
- package/dist/model/layout.js.map +1 -0
- package/dist/model/media.d.ts +33 -0
- package/dist/model/media.d.ts.map +1 -0
- package/dist/model/media.js +86 -0
- package/dist/model/media.js.map +1 -0
- package/dist/model/members.generated.d.ts +11 -0
- package/dist/model/members.generated.d.ts.map +1 -0
- package/dist/model/members.generated.js +71 -0
- package/dist/model/members.generated.js.map +1 -0
- package/dist/model/row-address.d.ts +27 -0
- package/dist/model/row-address.d.ts.map +1 -0
- package/dist/model/row-address.js +146 -0
- package/dist/model/row-address.js.map +1 -0
- package/dist/model/schema.d.ts +108 -0
- package/dist/model/schema.d.ts.map +1 -0
- package/dist/model/schema.js +2 -0
- package/dist/model/schema.js.map +1 -0
- package/dist/model/shape.d.ts +193 -0
- package/dist/model/shape.d.ts.map +1 -0
- package/dist/model/shape.js +2 -0
- package/dist/model/shape.js.map +1 -0
- package/dist/model/time.d.ts +61 -0
- package/dist/model/time.d.ts.map +1 -0
- package/dist/model/time.js +110 -0
- package/dist/model/time.js.map +1 -0
- package/dist/model/types.d.ts +1329 -0
- package/dist/model/types.d.ts.map +1 -0
- package/dist/model/types.js +424 -0
- package/dist/model/types.js.map +1 -0
- package/dist/model/values.d.ts +91 -0
- package/dist/model/values.d.ts.map +1 -0
- package/dist/model/values.js +195 -0
- package/dist/model/values.js.map +1 -0
- package/dist/model/wire.d.ts +356 -0
- package/dist/model/wire.d.ts.map +1 -0
- package/dist/model/wire.js +1504 -0
- package/dist/model/wire.js.map +1 -0
- package/dist/offline/index.d.ts +374 -0
- package/dist/offline/index.d.ts.map +1 -0
- package/dist/offline/index.js +422 -0
- package/dist/offline/index.js.map +1 -0
- package/dist/testing.d.ts +30 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +42 -0
- package/dist/testing.js.map +1 -0
- package/dist/version.d.ts +30 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +116 -0
- package/dist/version.js.map +1 -0
- package/package.json +98 -3
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { assertNever } from '../model/errors.js';
|
|
2
|
+
import { RULE_KINDS } from '../model/types.js';
|
|
3
|
+
/** Every rule kind as a membership test, built once from the vocabulary tuple. */
|
|
4
|
+
const RULE_KIND_SET = new Set(RULE_KINDS);
|
|
5
|
+
/** Whether a text names one of the rule kinds the contract declares. */
|
|
6
|
+
export function isRuleKind(value) {
|
|
7
|
+
return RULE_KIND_SET.has(value);
|
|
8
|
+
}
|
|
9
|
+
/** `visible`, `required` and `enabled` fire on `PASS`; `UNKNOWN` decided neither branch. */
|
|
10
|
+
const PASS_BRANCH = {
|
|
11
|
+
PASS: true,
|
|
12
|
+
FAIL: false,
|
|
13
|
+
UNKNOWN: undefined,
|
|
14
|
+
DEFERRED: undefined,
|
|
15
|
+
};
|
|
16
|
+
/** `validate` and `gate` fire on `FAIL`; `UNKNOWN` decided neither branch. */
|
|
17
|
+
const FAIL_BRANCH = {
|
|
18
|
+
PASS: false,
|
|
19
|
+
FAIL: true,
|
|
20
|
+
UNKNOWN: undefined,
|
|
21
|
+
DEFERRED: undefined,
|
|
22
|
+
};
|
|
23
|
+
/** A screen fires on a refusal and on a referral, and an undecided screen is not a pass. */
|
|
24
|
+
const SCREEN_BRANCH = {
|
|
25
|
+
SCREEN_PASS: false,
|
|
26
|
+
SCREEN_FAIL: true,
|
|
27
|
+
SCREEN_REFER: true,
|
|
28
|
+
UNKNOWN: undefined,
|
|
29
|
+
DEFERRED: undefined,
|
|
30
|
+
};
|
|
31
|
+
/** A writer fires by producing a value; `UNKNOWN` is its one non-firing case. */
|
|
32
|
+
const WRITER_BRANCH = {
|
|
33
|
+
PASS: true,
|
|
34
|
+
FAIL: undefined,
|
|
35
|
+
UNKNOWN: false,
|
|
36
|
+
DEFERRED: undefined,
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Which branch of its firing table one observation proves, `spec/semantics/rules-v1.md`.
|
|
40
|
+
*
|
|
41
|
+
* `true` is the firing branch, `false` the non-firing branch, and `undefined` an observation
|
|
42
|
+
* that proves neither: a rule that deferred did not run, and an `UNKNOWN` result decided
|
|
43
|
+
* nothing. The table is one answer shared by the compiler's publish-readiness check, the CLI's
|
|
44
|
+
* vector verdict and every downstream scenario runner: a `visible`/`required`/`enabled` rule
|
|
45
|
+
* is doing its work when it passes, a writer is doing its work when it produces a value, and a
|
|
46
|
+
* `validate`, `gate` or `screen` rule is doing its work when it refuses. A second copy of this
|
|
47
|
+
* table is how a rule's vectors could be counted as firing for publishing while the same case
|
|
48
|
+
* counted as non-firing in a runner.
|
|
49
|
+
*
|
|
50
|
+
* The non-firing branch is the kind's own answer rather than "any observation that is not
|
|
51
|
+
* firing": `UNKNOWN` beside a `validate` rule is a case that decided nothing, while `UNKNOWN`
|
|
52
|
+
* is exactly a writer's non-firing branch (`RULES-3.1.2`), and a `screen` states its branch
|
|
53
|
+
* through its own outcome.
|
|
54
|
+
*
|
|
55
|
+
* A screen fires on a referral as well as a refusal, and a writer's `PASS` is the same fact as
|
|
56
|
+
* a produced value, so both spellings of one observation answer alike.
|
|
57
|
+
*/
|
|
58
|
+
export function firingBranch(kind, observation) {
|
|
59
|
+
switch (kind) {
|
|
60
|
+
case 'visible':
|
|
61
|
+
case 'required':
|
|
62
|
+
case 'enabled':
|
|
63
|
+
return passFires(observation);
|
|
64
|
+
case 'validate':
|
|
65
|
+
case 'gate':
|
|
66
|
+
return failFires(observation);
|
|
67
|
+
case 'screen':
|
|
68
|
+
return screenBranch(observation);
|
|
69
|
+
case 'compute':
|
|
70
|
+
case 'defaultCompute':
|
|
71
|
+
return writerBranch(observation);
|
|
72
|
+
default:
|
|
73
|
+
return assertNever(kind);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Whether a rule kind fires at one observation; an observation that decides neither is not firing. */
|
|
77
|
+
export function isFiring(kind, observation) {
|
|
78
|
+
return firingBranch(kind, observation) === true;
|
|
79
|
+
}
|
|
80
|
+
/** A kind whose firing branch is `PASS` (`visible`, `required`, `enabled`). */
|
|
81
|
+
function passFires(observation) {
|
|
82
|
+
switch (observation.kind) {
|
|
83
|
+
case 'outcome':
|
|
84
|
+
return PASS_BRANCH[observation.outcome];
|
|
85
|
+
case 'screen':
|
|
86
|
+
case 'value':
|
|
87
|
+
return undefined;
|
|
88
|
+
default:
|
|
89
|
+
return assertNever(observation);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** A kind whose firing branch is `FAIL` (`validate`, `gate`). */
|
|
93
|
+
function failFires(observation) {
|
|
94
|
+
switch (observation.kind) {
|
|
95
|
+
case 'outcome':
|
|
96
|
+
return FAIL_BRANCH[observation.outcome];
|
|
97
|
+
case 'screen':
|
|
98
|
+
case 'value':
|
|
99
|
+
return undefined;
|
|
100
|
+
default:
|
|
101
|
+
return assertNever(observation);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** A screen's own five-state outcome, with the four-state spelling read the same way. */
|
|
105
|
+
function screenBranch(observation) {
|
|
106
|
+
switch (observation.kind) {
|
|
107
|
+
case 'screen':
|
|
108
|
+
return SCREEN_BRANCH[observation.outcome];
|
|
109
|
+
case 'outcome':
|
|
110
|
+
return failFires(observation);
|
|
111
|
+
case 'value':
|
|
112
|
+
return undefined;
|
|
113
|
+
default:
|
|
114
|
+
return assertNever(observation);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* A writer's branch: a produced value fires, and `UNKNOWN` is the non-firing case
|
|
119
|
+
* (`RULES-3.1.2`). `FAIL` is no writer branch — a writer whose expression raised reports
|
|
120
|
+
* `UNKNOWN` (`RULES-2.1.9`) — and a deferral means the writer never ran.
|
|
121
|
+
*/
|
|
122
|
+
function writerBranch(observation) {
|
|
123
|
+
switch (observation.kind) {
|
|
124
|
+
case 'value':
|
|
125
|
+
return true;
|
|
126
|
+
case 'outcome':
|
|
127
|
+
return WRITER_BRANCH[observation.outcome];
|
|
128
|
+
case 'screen':
|
|
129
|
+
return undefined;
|
|
130
|
+
default:
|
|
131
|
+
return assertNever(observation);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The branch of its firing table a rule's expression can never take, when it fixes that answer.
|
|
136
|
+
*
|
|
137
|
+
* A `validate`, `visible`, `required` or `enabled` rule's outcome is its expression's answer, so
|
|
138
|
+
* an expression that folds to a constant boolean fixes that answer for every record: `true`
|
|
139
|
+
* passes and can never fail, and `false` fails and can never pass. A writer's result is a value
|
|
140
|
+
* or `UNKNOWN`, so an expression that folds to a constant produces a value on every record and
|
|
141
|
+
* can never report the non-firing case. Publishing asks for a case on each branch a rule can
|
|
142
|
+
* take (`spec/semantics/rules-v1.md` `RULES-3.1.2`), and no record can state the branch this
|
|
143
|
+
* rule can never reach — so stating one is the requirement being unmet rather than a case
|
|
144
|
+
* being missing.
|
|
145
|
+
*
|
|
146
|
+
* The fold is the tree's own answer, not a search for a literal: `not(false)` and
|
|
147
|
+
* `true and true` state one branch as plainly as the literal does. A `gate` or `screen` decides
|
|
148
|
+
* through composition as well — a gate's items, a screen's `referWhen` — so neither states a
|
|
149
|
+
* fixed branch from its expression alone.
|
|
150
|
+
*
|
|
151
|
+
* Kind and expression together decide it, so this is the one answer a publisher and a diff read
|
|
152
|
+
* rather than each re-reading the rule's tree.
|
|
153
|
+
*/
|
|
154
|
+
export function unreachableBranchOf(rule) {
|
|
155
|
+
switch (rule.kind) {
|
|
156
|
+
case 'validate':
|
|
157
|
+
case 'visible':
|
|
158
|
+
case 'required':
|
|
159
|
+
case 'enabled': {
|
|
160
|
+
const decided = constantBooleanOf(rule.expr);
|
|
161
|
+
if (decided === undefined)
|
|
162
|
+
return undefined;
|
|
163
|
+
const outcome = decided ? 'PASS' : 'FAIL';
|
|
164
|
+
return firingBranch(rule.kind, { kind: 'outcome', outcome }) === true
|
|
165
|
+
? 'non_firing'
|
|
166
|
+
: 'firing';
|
|
167
|
+
}
|
|
168
|
+
case 'compute':
|
|
169
|
+
case 'defaultCompute':
|
|
170
|
+
// A constant expression always produces a value, so only the firing branch is reachable.
|
|
171
|
+
return producesConstant(rule.expr) ? 'non_firing' : undefined;
|
|
172
|
+
case 'gate':
|
|
173
|
+
case 'screen':
|
|
174
|
+
return undefined;
|
|
175
|
+
default:
|
|
176
|
+
return assertNever(rule);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The boolean an expression folds to with no record at all, or `undefined`.
|
|
181
|
+
*
|
|
182
|
+
* Only the connectives over constants fold. An operand the walk cannot fold leaves the whole
|
|
183
|
+
* connective undecided: evaluation may still have to run it, and a value whose producing rule
|
|
184
|
+
* is undecided is not the literal answer. A comparison, a call, an `if` and a comprehension all
|
|
185
|
+
* read something, so none of them is constant.
|
|
186
|
+
*/
|
|
187
|
+
function constantBooleanOf(expr) {
|
|
188
|
+
switch (expr.kind) {
|
|
189
|
+
case 'literal':
|
|
190
|
+
return expr.domain === 'boolean' && typeof expr.value === 'boolean' ? expr.value : undefined;
|
|
191
|
+
case 'not': {
|
|
192
|
+
const inner = constantBooleanOf(expr.args[0]);
|
|
193
|
+
return inner === undefined ? undefined : !inner;
|
|
194
|
+
}
|
|
195
|
+
case 'and':
|
|
196
|
+
case 'or': {
|
|
197
|
+
const values = [];
|
|
198
|
+
for (const arg of expr.args) {
|
|
199
|
+
const value = constantBooleanOf(arg);
|
|
200
|
+
if (value === undefined)
|
|
201
|
+
return undefined;
|
|
202
|
+
values.push(value);
|
|
203
|
+
}
|
|
204
|
+
return expr.kind === 'and' ? values.every((value) => value) : values.some((value) => value);
|
|
205
|
+
}
|
|
206
|
+
case 'path':
|
|
207
|
+
case 'list':
|
|
208
|
+
case 'compare':
|
|
209
|
+
case 'if':
|
|
210
|
+
case 'coalesce':
|
|
211
|
+
case 'call':
|
|
212
|
+
case 'comprehension':
|
|
213
|
+
return undefined;
|
|
214
|
+
default:
|
|
215
|
+
return assertNever(expr);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/** Whether an expression produces the same value on every record, `null` included. */
|
|
219
|
+
function producesConstant(expr) {
|
|
220
|
+
return expr.kind === 'literal' || constantBooleanOf(expr) !== undefined;
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=firing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firing.js","sourceRoot":"","sources":["../../src/eval/firing.ts"],"names":[],"mappings":"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","sourcesContent":["import { assertNever } from '../model/errors.js';\nimport { RULE_KINDS } from '../model/types.js';\nimport type {\n CompiledRule,\n ExprNode,\n Outcome,\n RuleKind,\n ScreenOutcome,\n WireValue,\n} from '../model/types.js';\n\n/** Every rule kind as a membership test, built once from the vocabulary tuple. */\nconst RULE_KIND_SET: ReadonlySet<string> = new Set(RULE_KINDS);\n\n/** Whether a text names one of the rule kinds the contract declares. */\nexport function isRuleKind(value: string): value is RuleKind {\n return RULE_KIND_SET.has(value);\n}\n\n/**\n * What an evaluation observed about one rule.\n *\n * The union is tagged because the three observations are not one scale: an outcome is the\n * four-state fold a rule result carries, a screen states its own `SCREEN_PASS`/`SCREEN_FAIL`/\n * `SCREEN_REFER` so a referral is distinguishable from a refusal, and a writer states the\n * value it produced — `null` included, which is a produced value rather than an absence.\n */\nexport type Observation =\n | { readonly kind: 'outcome'; readonly outcome: Outcome }\n | { readonly kind: 'screen'; readonly outcome: ScreenOutcome }\n | { readonly kind: 'value'; readonly value: WireValue | null };\n\n/**\n * The branch one four-state outcome proves, indexed by the closed outcome union so a new\n * variant is a type error rather than a case the table silently answers `false` for.\n */\ntype BranchOf<T extends string> = Readonly<Record<T, boolean | undefined>>;\n\n/** `visible`, `required` and `enabled` fire on `PASS`; `UNKNOWN` decided neither branch. */\nconst PASS_BRANCH: BranchOf<Outcome> = {\n PASS: true,\n FAIL: false,\n UNKNOWN: undefined,\n DEFERRED: undefined,\n};\n\n/** `validate` and `gate` fire on `FAIL`; `UNKNOWN` decided neither branch. */\nconst FAIL_BRANCH: BranchOf<Outcome> = {\n PASS: false,\n FAIL: true,\n UNKNOWN: undefined,\n DEFERRED: undefined,\n};\n\n/** A screen fires on a refusal and on a referral, and an undecided screen is not a pass. */\nconst SCREEN_BRANCH: BranchOf<ScreenOutcome> = {\n SCREEN_PASS: false,\n SCREEN_FAIL: true,\n SCREEN_REFER: true,\n UNKNOWN: undefined,\n DEFERRED: undefined,\n};\n\n/** A writer fires by producing a value; `UNKNOWN` is its one non-firing case. */\nconst WRITER_BRANCH: BranchOf<Outcome> = {\n PASS: true,\n FAIL: undefined,\n UNKNOWN: false,\n DEFERRED: undefined,\n};\n\n/**\n * Which branch of its firing table one observation proves, `spec/semantics/rules-v1.md`.\n *\n * `true` is the firing branch, `false` the non-firing branch, and `undefined` an observation\n * that proves neither: a rule that deferred did not run, and an `UNKNOWN` result decided\n * nothing. The table is one answer shared by the compiler's publish-readiness check, the CLI's\n * vector verdict and every downstream scenario runner: a `visible`/`required`/`enabled` rule\n * is doing its work when it passes, a writer is doing its work when it produces a value, and a\n * `validate`, `gate` or `screen` rule is doing its work when it refuses. A second copy of this\n * table is how a rule's vectors could be counted as firing for publishing while the same case\n * counted as non-firing in a runner.\n *\n * The non-firing branch is the kind's own answer rather than \"any observation that is not\n * firing\": `UNKNOWN` beside a `validate` rule is a case that decided nothing, while `UNKNOWN`\n * is exactly a writer's non-firing branch (`RULES-3.1.2`), and a `screen` states its branch\n * through its own outcome.\n *\n * A screen fires on a referral as well as a refusal, and a writer's `PASS` is the same fact as\n * a produced value, so both spellings of one observation answer alike.\n */\nexport function firingBranch(kind: RuleKind, observation: Observation): boolean | undefined {\n switch (kind) {\n case 'visible':\n case 'required':\n case 'enabled':\n return passFires(observation);\n case 'validate':\n case 'gate':\n return failFires(observation);\n case 'screen':\n return screenBranch(observation);\n case 'compute':\n case 'defaultCompute':\n return writerBranch(observation);\n default:\n return assertNever(kind);\n }\n}\n\n/** Whether a rule kind fires at one observation; an observation that decides neither is not firing. */\nexport function isFiring(kind: RuleKind, observation: Observation): boolean {\n return firingBranch(kind, observation) === true;\n}\n\n/** A kind whose firing branch is `PASS` (`visible`, `required`, `enabled`). */\nfunction passFires(observation: Observation): boolean | undefined {\n switch (observation.kind) {\n case 'outcome':\n return PASS_BRANCH[observation.outcome];\n case 'screen':\n case 'value':\n return undefined;\n default:\n return assertNever(observation);\n }\n}\n\n/** A kind whose firing branch is `FAIL` (`validate`, `gate`). */\nfunction failFires(observation: Observation): boolean | undefined {\n switch (observation.kind) {\n case 'outcome':\n return FAIL_BRANCH[observation.outcome];\n case 'screen':\n case 'value':\n return undefined;\n default:\n return assertNever(observation);\n }\n}\n\n/** A screen's own five-state outcome, with the four-state spelling read the same way. */\nfunction screenBranch(observation: Observation): boolean | undefined {\n switch (observation.kind) {\n case 'screen':\n return SCREEN_BRANCH[observation.outcome];\n case 'outcome':\n return failFires(observation);\n case 'value':\n return undefined;\n default:\n return assertNever(observation);\n }\n}\n\n/**\n * A writer's branch: a produced value fires, and `UNKNOWN` is the non-firing case\n * (`RULES-3.1.2`). `FAIL` is no writer branch — a writer whose expression raised reports\n * `UNKNOWN` (`RULES-2.1.9`) — and a deferral means the writer never ran.\n */\nfunction writerBranch(observation: Observation): boolean | undefined {\n switch (observation.kind) {\n case 'value':\n return true;\n case 'outcome':\n return WRITER_BRANCH[observation.outcome];\n case 'screen':\n return undefined;\n default:\n return assertNever(observation);\n }\n}\n\n/** The branch of its firing table a rule's expression can never take. */\nexport type UnreachableBranch = 'firing' | 'non_firing';\n\n/**\n * The branch of its firing table a rule's expression can never take, when it fixes that answer.\n *\n * A `validate`, `visible`, `required` or `enabled` rule's outcome is its expression's answer, so\n * an expression that folds to a constant boolean fixes that answer for every record: `true`\n * passes and can never fail, and `false` fails and can never pass. A writer's result is a value\n * or `UNKNOWN`, so an expression that folds to a constant produces a value on every record and\n * can never report the non-firing case. Publishing asks for a case on each branch a rule can\n * take (`spec/semantics/rules-v1.md` `RULES-3.1.2`), and no record can state the branch this\n * rule can never reach — so stating one is the requirement being unmet rather than a case\n * being missing.\n *\n * The fold is the tree's own answer, not a search for a literal: `not(false)` and\n * `true and true` state one branch as plainly as the literal does. A `gate` or `screen` decides\n * through composition as well — a gate's items, a screen's `referWhen` — so neither states a\n * fixed branch from its expression alone.\n *\n * Kind and expression together decide it, so this is the one answer a publisher and a diff read\n * rather than each re-reading the rule's tree.\n */\nexport function unreachableBranchOf(rule: CompiledRule): UnreachableBranch | undefined {\n switch (rule.kind) {\n case 'validate':\n case 'visible':\n case 'required':\n case 'enabled': {\n const decided = constantBooleanOf(rule.expr);\n if (decided === undefined) return undefined;\n const outcome: Outcome = decided ? 'PASS' : 'FAIL';\n return firingBranch(rule.kind, { kind: 'outcome', outcome }) === true\n ? 'non_firing'\n : 'firing';\n }\n case 'compute':\n case 'defaultCompute':\n // A constant expression always produces a value, so only the firing branch is reachable.\n return producesConstant(rule.expr) ? 'non_firing' : undefined;\n case 'gate':\n case 'screen':\n return undefined;\n default:\n return assertNever(rule);\n }\n}\n\n/**\n * The boolean an expression folds to with no record at all, or `undefined`.\n *\n * Only the connectives over constants fold. An operand the walk cannot fold leaves the whole\n * connective undecided: evaluation may still have to run it, and a value whose producing rule\n * is undecided is not the literal answer. A comparison, a call, an `if` and a comprehension all\n * read something, so none of them is constant.\n */\nfunction constantBooleanOf(expr: ExprNode): boolean | undefined {\n switch (expr.kind) {\n case 'literal':\n return expr.domain === 'boolean' && typeof expr.value === 'boolean' ? expr.value : undefined;\n case 'not': {\n const inner = constantBooleanOf(expr.args[0]);\n return inner === undefined ? undefined : !inner;\n }\n case 'and':\n case 'or': {\n const values: boolean[] = [];\n for (const arg of expr.args) {\n const value = constantBooleanOf(arg);\n if (value === undefined) return undefined;\n values.push(value);\n }\n return expr.kind === 'and' ? values.every((value) => value) : values.some((value) => value);\n }\n case 'path':\n case 'list':\n case 'compare':\n case 'if':\n case 'coalesce':\n case 'call':\n case 'comprehension':\n return undefined;\n default:\n return assertNever(expr);\n }\n}\n\n/** Whether an expression produces the same value on every record, `null` included. */\nfunction producesConstant(expr: ExprNode): boolean {\n return expr.kind === 'literal' || constantBooleanOf(expr) !== undefined;\n}\n"]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { CompiledRule, EvaluationReport, GateItemResult, GatePolicy, GateReport, Outcome } from '../model/types.js';
|
|
2
|
+
import type { EvaluationEnv, EvaluationInput } from '../model/access.js';
|
|
3
|
+
import type { CompiledSchema } from '../model/schema.js';
|
|
4
|
+
import type { GateOverrideOutcome, ReadOverrides } from './overrides.js';
|
|
5
|
+
/**
|
|
6
|
+
* The gate's stateless semantics: what a gate status means as a verdict, what a record's
|
|
7
|
+
* input hash binds, and how an approved override is weighed.
|
|
8
|
+
*
|
|
9
|
+
* Everything here is a function of a report and the declarations it was decided under, so
|
|
10
|
+
* the gate surface can be read — and tested — without an evaluation in progress.
|
|
11
|
+
*/
|
|
12
|
+
/** The four verdicts `evaluateGate()` reports. */
|
|
13
|
+
export type GateVerdict = 'OPEN' | 'BLOCKED' | 'DEFERRED' | 'OVERRIDDEN';
|
|
14
|
+
/** The stateless verdict one gate rule status stands for. */
|
|
15
|
+
export declare function gateOutcome(status: Outcome): Exclude<GateVerdict, 'OVERRIDDEN'>;
|
|
16
|
+
/**
|
|
17
|
+
* A gate's status when a read-only refusal reached it.
|
|
18
|
+
*
|
|
19
|
+
* `policy` is `undefined` for a hard gate, which has no permissive setting. A genuine `FAIL`
|
|
20
|
+
* stays a failure under every policy: the policy governs what an *undecided* gate does, not
|
|
21
|
+
* whether a decided one is overruled.
|
|
22
|
+
*/
|
|
23
|
+
export declare function gateStatusUnderPolicy(policy: GatePolicy | undefined, status: Outcome): Outcome;
|
|
24
|
+
/**
|
|
25
|
+
* The status the report decided for one gate, before any override is applied: an approval
|
|
26
|
+
* binds the verdict it replaced, so a `DEFERRED` gate's approval cannot also describe a `FAIL`.
|
|
27
|
+
* `undefined` when the report carries no result for that gate.
|
|
28
|
+
*/
|
|
29
|
+
export declare function decidedGateStatus(report: EvaluationReport, gateId: string): Outcome | undefined;
|
|
30
|
+
/** Every item result an active gate reported. An inactive gate decided no item, so it has none. */
|
|
31
|
+
export declare function gateItemsOf(gate: GateReport | undefined): readonly GateItemResult[];
|
|
32
|
+
/**
|
|
33
|
+
* Every gate item's status, sorted by `itemId` and deduplicated, so the order the artifact
|
|
34
|
+
* declares its items in cannot move an approval and a swapped verdict cannot hide behind an
|
|
35
|
+
* unchanged fold. The compiler refuses two items of one gate sharing an id, so an item's id is
|
|
36
|
+
* its identity and this binds every item the artifact declares. An inactive gate reported no
|
|
37
|
+
* item, so it commits to none.
|
|
38
|
+
*/
|
|
39
|
+
export declare function gateItemCommitments(gate: GateReport | undefined): readonly {
|
|
40
|
+
readonly itemId: string;
|
|
41
|
+
readonly status: Outcome;
|
|
42
|
+
}[];
|
|
43
|
+
/**
|
|
44
|
+
* The SHA-256 a gate override is approved against: everything the gate actually judged plus
|
|
45
|
+
* everything the submission would carry.
|
|
46
|
+
*
|
|
47
|
+
* `values` is the value tree the gate read, because a `visible` rule never stops an
|
|
48
|
+
* expression reading a hidden field, so a hash of the projection alone would leave a value
|
|
49
|
+
* the gate depended on unbound. `projected` is the submission the same record and snapshot
|
|
50
|
+
* would export, so hiding a value under an `exclude` policy changes the hash without
|
|
51
|
+
* changing any value. `context`, the sorted `redacted` set and `recordDate` are the record's
|
|
52
|
+
* own facts, and `tables` is every version the evaluation resolved — hit or miss, including
|
|
53
|
+
* a set-membership test.
|
|
54
|
+
*
|
|
55
|
+
* `tier`, `capabilities` and the gate's own decision are bound because a gate's verdict is a
|
|
56
|
+
* function of them, not of the record: a client-tier `DEFERRED` approval must not be
|
|
57
|
+
* replayable against the server-tier `FAIL` it deferred to. `gateStatus` is the named gate's
|
|
58
|
+
* pre-override status and `gateItems` every item's, so an approval belongs to the verdict it
|
|
59
|
+
* replaced rather than to a fold that happens to be unchanged. Both are the named gate's own,
|
|
60
|
+
* so re-designating which gate is primary — a presentation choice the artifact states at the
|
|
61
|
+
* document root — leaves every recorded approval valid.
|
|
62
|
+
*
|
|
63
|
+
* Access is not bound as a member of its own, but the submission it shapes is: a value an
|
|
64
|
+
* overlay withholds stops travelling, so the hash moves with it. A record the wire contract
|
|
65
|
+
* cannot read has no hash: the caller refuses the override rather than binding an approval
|
|
66
|
+
* to a record it could not reduce to canonical form.
|
|
67
|
+
*/
|
|
68
|
+
export declare function gateInputHash(compiled: CompiledSchema, input: EvaluationInput, env: EvaluationEnv, report: EvaluationReport, gateId: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* The input hash an override is matched against, or `undefined` when the record has none.
|
|
71
|
+
*
|
|
72
|
+
* A record outside the canonical wire contract has no hash, so no approval can be shown to
|
|
73
|
+
* belong to it; the evaluation already reported the offending value. A document whose
|
|
74
|
+
* signature would travel without a value it binds is a different failure — an authoring
|
|
75
|
+
* defect that stops the export altogether — so its named refusal reaches the caller instead
|
|
76
|
+
* of being reported as an unreadable record.
|
|
77
|
+
*/
|
|
78
|
+
export declare function gateInputHashOrNone(compiled: CompiledSchema, input: EvaluationInput, env: EvaluationEnv, report: EvaluationReport, gateId: string): string | undefined;
|
|
79
|
+
/** Everything one gate call decided, before it is shaped into `GateEvaluation`. */
|
|
80
|
+
export interface GateDecision {
|
|
81
|
+
/** The verdict of the gate this call decides — the artifact's primary gate. */
|
|
82
|
+
readonly outcome: GateVerdict;
|
|
83
|
+
readonly report: EvaluationReport;
|
|
84
|
+
readonly gate: GateReport;
|
|
85
|
+
readonly overrides: GateOverrideOutcome;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Weighs every well-formed override against the gate it names, and reports the primary gate's
|
|
89
|
+
* verdict.
|
|
90
|
+
*
|
|
91
|
+
* An override belongs to one gate's verdict: `inputHashOf` binds that gate's own decision
|
|
92
|
+
* inputs, so re-designating which gate is primary leaves an approval for either gate valid. An
|
|
93
|
+
* override is accepted only when it names a declared gate, that gate is in force and not
|
|
94
|
+
* `hard`, and the record, the gate's own `ruleHash` and the schema's `behaviorHash` all still
|
|
95
|
+
* match the evaluation it would satisfy. An accepted override satisfies its gate and is
|
|
96
|
+
* recorded in the report so the report hash binds it; a refused one is reported with its reason
|
|
97
|
+
* and changes nothing.
|
|
98
|
+
*/
|
|
99
|
+
export declare function decideGate(request: {
|
|
100
|
+
/** Every declared gate rule, keyed by its `ruleId`. */
|
|
101
|
+
readonly gateRules: ReadonlyMap<string, CompiledRule>;
|
|
102
|
+
/** The gate this call reports a verdict for. */
|
|
103
|
+
readonly primaryGateId: string;
|
|
104
|
+
readonly report: EvaluationReport;
|
|
105
|
+
/** The record's input hash for one gate, or `undefined` when the record has none. */
|
|
106
|
+
readonly inputHashOf: (gateId: string) => string | undefined;
|
|
107
|
+
readonly candidates: ReadOverrides;
|
|
108
|
+
readonly deniedFieldsOf: (gateId: string) => readonly string[];
|
|
109
|
+
}): GateDecision;
|
|
110
|
+
//# sourceMappingURL=gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../../src/eval/gate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAEhB,cAAc,EAEd,UAAU,EACV,UAAU,EAGV,OAAO,EACR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAKzE;;;;;;GAMG;AAEH,kDAAkD;AAClD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CAAC;AAEzE,6DAA6D;AAC7D,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,CAU/E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAU9F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAE/F;AAED,mGAAmG;AACnG,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,cAAc,EAAE,CAEnF;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,SAAS;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CAAE,EAAE,CAMlE;AAoDD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,GACb,MAAM,CAqBR;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,SAAS,CAQpB;AAED,mFAAmF;AACnF,MAAM,WAAW,YAAY;IAC3B,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;CACzC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAClC,uDAAuD;IACvD,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtD,gDAAgD;IAChD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,qFAAqF;IACrF,QAAQ,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC7D,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS,MAAM,EAAE,CAAC;CAChE,GAAG,YAAY,CA+Gf"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { canonicalHash, canonicalizeRestricted } from '../canonical/jcs.js';
|
|
2
|
+
import { parsePlainDate } from '../expr/plain-date.js';
|
|
3
|
+
import { compareCodePoints } from '../expr/strings.js';
|
|
4
|
+
import { AxiomError } from '../model/errors.js';
|
|
5
|
+
import { effectiveTier } from '../model/access.js';
|
|
6
|
+
import { toFieldRef } from '../model/wire.js';
|
|
7
|
+
import { fieldKey } from './access/projection.js';
|
|
8
|
+
import { createAccessWindow } from './access/window.js';
|
|
9
|
+
import { applyApprovedOverrideBatch, approvalMatchesReport } from './overrides.js';
|
|
10
|
+
import { projectSubmission } from './submission.js';
|
|
11
|
+
/** The stateless verdict one gate rule status stands for. */
|
|
12
|
+
export function gateOutcome(status) {
|
|
13
|
+
switch (status) {
|
|
14
|
+
case 'PASS':
|
|
15
|
+
return 'OPEN';
|
|
16
|
+
case 'DEFERRED':
|
|
17
|
+
return 'DEFERRED';
|
|
18
|
+
case 'FAIL':
|
|
19
|
+
case 'UNKNOWN':
|
|
20
|
+
return 'BLOCKED';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A gate's status when a read-only refusal reached it.
|
|
25
|
+
*
|
|
26
|
+
* `policy` is `undefined` for a hard gate, which has no permissive setting. A genuine `FAIL`
|
|
27
|
+
* stays a failure under every policy: the policy governs what an *undecided* gate does, not
|
|
28
|
+
* whether a decided one is overruled.
|
|
29
|
+
*/
|
|
30
|
+
export function gateStatusUnderPolicy(policy, status) {
|
|
31
|
+
switch (policy) {
|
|
32
|
+
case undefined:
|
|
33
|
+
case 'block':
|
|
34
|
+
return 'FAIL';
|
|
35
|
+
case 'warn':
|
|
36
|
+
return status === 'FAIL' ? 'FAIL' : 'PASS';
|
|
37
|
+
case 'defer':
|
|
38
|
+
return status === 'FAIL' ? 'FAIL' : 'DEFERRED';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The status the report decided for one gate, before any override is applied: an approval
|
|
43
|
+
* binds the verdict it replaced, so a `DEFERRED` gate's approval cannot also describe a `FAIL`.
|
|
44
|
+
* `undefined` when the report carries no result for that gate.
|
|
45
|
+
*/
|
|
46
|
+
export function decidedGateStatus(report, gateId) {
|
|
47
|
+
return report.rules.find((rule) => rule.ruleId === gateId)?.status;
|
|
48
|
+
}
|
|
49
|
+
/** Every item result an active gate reported. An inactive gate decided no item, so it has none. */
|
|
50
|
+
export function gateItemsOf(gate) {
|
|
51
|
+
return gate !== undefined && 'items' in gate ? gate.items : [];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Every gate item's status, sorted by `itemId` and deduplicated, so the order the artifact
|
|
55
|
+
* declares its items in cannot move an approval and a swapped verdict cannot hide behind an
|
|
56
|
+
* unchanged fold. The compiler refuses two items of one gate sharing an id, so an item's id is
|
|
57
|
+
* its identity and this binds every item the artifact declares. An inactive gate reported no
|
|
58
|
+
* item, so it commits to none.
|
|
59
|
+
*/
|
|
60
|
+
export function gateItemCommitments(gate) {
|
|
61
|
+
const byId = new Map();
|
|
62
|
+
for (const item of gateItemsOf(gate))
|
|
63
|
+
byId.set(item.itemId, item.status);
|
|
64
|
+
return [...byId.entries()]
|
|
65
|
+
.sort(([left], [right]) => compareCodePoints(left, right))
|
|
66
|
+
.map(([itemId, status]) => ({ itemId, status }));
|
|
67
|
+
}
|
|
68
|
+
/** A capability set in the one order and multiplicity a hash may depend on. */
|
|
69
|
+
function sortedCapabilities(capabilities) {
|
|
70
|
+
return [...new Set(capabilities ?? [])].sort(compareCodePoints);
|
|
71
|
+
}
|
|
72
|
+
/** The tables a report resolved against, deduplicated and in canonical order. */
|
|
73
|
+
function tableCommitments(lookups) {
|
|
74
|
+
const byText = new Map();
|
|
75
|
+
for (const entry of lookups) {
|
|
76
|
+
const commitment = 'tableSha256' in entry
|
|
77
|
+
? {
|
|
78
|
+
tableId: entry.tableId,
|
|
79
|
+
tableVersion: entry.tableVersion,
|
|
80
|
+
tableSha256: entry.tableSha256,
|
|
81
|
+
}
|
|
82
|
+
: { tableId: entry.tableId, reason: entry.reason };
|
|
83
|
+
byText.set(canonicalizeRestricted(commitment), commitment);
|
|
84
|
+
}
|
|
85
|
+
return [...byText.entries()]
|
|
86
|
+
.sort(([left], [right]) => compareCodePoints(left, right))
|
|
87
|
+
.map(([, commitment]) => commitment);
|
|
88
|
+
}
|
|
89
|
+
/** References validated, normalized and ordered canonically without repeats, so host order cannot move a hash. */
|
|
90
|
+
function sortedRefs(refs, path) {
|
|
91
|
+
const byKey = new Map();
|
|
92
|
+
refs.forEach((raw, index) => {
|
|
93
|
+
const ref = toFieldRef(raw, `${path}[${String(index)}]`);
|
|
94
|
+
byKey.set(fieldKey(ref), ref);
|
|
95
|
+
});
|
|
96
|
+
return [...byKey.entries()]
|
|
97
|
+
.sort(([left], [right]) => compareCodePoints(left, right))
|
|
98
|
+
.map(([, ref]) => ref);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The SHA-256 a gate override is approved against: everything the gate actually judged plus
|
|
102
|
+
* everything the submission would carry.
|
|
103
|
+
*
|
|
104
|
+
* `values` is the value tree the gate read, because a `visible` rule never stops an
|
|
105
|
+
* expression reading a hidden field, so a hash of the projection alone would leave a value
|
|
106
|
+
* the gate depended on unbound. `projected` is the submission the same record and snapshot
|
|
107
|
+
* would export, so hiding a value under an `exclude` policy changes the hash without
|
|
108
|
+
* changing any value. `context`, the sorted `redacted` set and `recordDate` are the record's
|
|
109
|
+
* own facts, and `tables` is every version the evaluation resolved — hit or miss, including
|
|
110
|
+
* a set-membership test.
|
|
111
|
+
*
|
|
112
|
+
* `tier`, `capabilities` and the gate's own decision are bound because a gate's verdict is a
|
|
113
|
+
* function of them, not of the record: a client-tier `DEFERRED` approval must not be
|
|
114
|
+
* replayable against the server-tier `FAIL` it deferred to. `gateStatus` is the named gate's
|
|
115
|
+
* pre-override status and `gateItems` every item's, so an approval belongs to the verdict it
|
|
116
|
+
* replaced rather than to a fold that happens to be unchanged. Both are the named gate's own,
|
|
117
|
+
* so re-designating which gate is primary — a presentation choice the artifact states at the
|
|
118
|
+
* document root — leaves every recorded approval valid.
|
|
119
|
+
*
|
|
120
|
+
* Access is not bound as a member of its own, but the submission it shapes is: a value an
|
|
121
|
+
* overlay withholds stops travelling, so the hash moves with it. A record the wire contract
|
|
122
|
+
* cannot read has no hash: the caller refuses the override rather than binding an approval
|
|
123
|
+
* to a record it could not reduce to canonical form.
|
|
124
|
+
*/
|
|
125
|
+
export function gateInputHash(compiled, input, env, report, gateId) {
|
|
126
|
+
// The projection reads the access answer the evaluation resolved; resolving the same
|
|
127
|
+
// window keeps one answer rather than a second overlay.
|
|
128
|
+
const snapshot = {
|
|
129
|
+
report,
|
|
130
|
+
access: createAccessWindow(compiled.fields, input, env).snapshotAccess(),
|
|
131
|
+
};
|
|
132
|
+
if (env.recordDate !== undefined)
|
|
133
|
+
parsePlainDate(env.recordDate, '$.recordDate');
|
|
134
|
+
const gateStatus = decidedGateStatus(report, gateId);
|
|
135
|
+
return canonicalHash({
|
|
136
|
+
values: input.values,
|
|
137
|
+
projected: projectSubmission(compiled, input, snapshot),
|
|
138
|
+
...(input.context === undefined ? {} : { context: input.context }),
|
|
139
|
+
...(input.redacted === undefined ? {} : { redacted: sortedRefs(input.redacted, '$.redacted') }),
|
|
140
|
+
...(env.recordDate === undefined ? {} : { recordDate: env.recordDate }),
|
|
141
|
+
tier: effectiveTier(env),
|
|
142
|
+
capabilities: sortedCapabilities(env.capabilities),
|
|
143
|
+
...(gateStatus === undefined ? {} : { gateStatus }),
|
|
144
|
+
gateItems: gateItemCommitments(report.gates?.[gateId]),
|
|
145
|
+
tables: tableCommitments(report.lookups),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The input hash an override is matched against, or `undefined` when the record has none.
|
|
150
|
+
*
|
|
151
|
+
* A record outside the canonical wire contract has no hash, so no approval can be shown to
|
|
152
|
+
* belong to it; the evaluation already reported the offending value. A document whose
|
|
153
|
+
* signature would travel without a value it binds is a different failure — an authoring
|
|
154
|
+
* defect that stops the export altogether — so its named refusal reaches the caller instead
|
|
155
|
+
* of being reported as an unreadable record.
|
|
156
|
+
*/
|
|
157
|
+
export function gateInputHashOrNone(compiled, input, env, report, gateId) {
|
|
158
|
+
try {
|
|
159
|
+
return gateInputHash(compiled, input, env, report, gateId);
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
if (!(error instanceof AxiomError))
|
|
163
|
+
throw error;
|
|
164
|
+
if (error.code === 'SIGNATURE_COVER_EXCLUDED')
|
|
165
|
+
throw error;
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Weighs every well-formed override against the gate it names, and reports the primary gate's
|
|
171
|
+
* verdict.
|
|
172
|
+
*
|
|
173
|
+
* An override belongs to one gate's verdict: `inputHashOf` binds that gate's own decision
|
|
174
|
+
* inputs, so re-designating which gate is primary leaves an approval for either gate valid. An
|
|
175
|
+
* override is accepted only when it names a declared gate, that gate is in force and not
|
|
176
|
+
* `hard`, and the record, the gate's own `ruleHash` and the schema's `behaviorHash` all still
|
|
177
|
+
* match the evaluation it would satisfy. An accepted override satisfies its gate and is
|
|
178
|
+
* recorded in the report so the report hash binds it; a refused one is reported with its reason
|
|
179
|
+
* and changes nothing.
|
|
180
|
+
*/
|
|
181
|
+
export function decideGate(request) {
|
|
182
|
+
const refused = [...request.candidates.refused];
|
|
183
|
+
// One index of the report's decisions and one grouped candidate list, built before the gate
|
|
184
|
+
// loop: a scan per gate and a re-copied array per approved record made this quadratic in a
|
|
185
|
+
// report with many gates and overrides.
|
|
186
|
+
const resultByRuleId = new Map(request.report.rules.map((result) => [result.ruleId, result]));
|
|
187
|
+
// Grouped by the rule itself, so a gate the artifact does not declare is refused here and
|
|
188
|
+
// every gate weighed below is one this artifact reported.
|
|
189
|
+
const candidatesByGate = new Map();
|
|
190
|
+
for (const override of request.candidates.wellFormed) {
|
|
191
|
+
const gateRule = request.gateRules.get(override.gateId);
|
|
192
|
+
if (gateRule === undefined) {
|
|
193
|
+
refused.push({ override, reason: 'unknown_gate' });
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const forGate = candidatesByGate.get(gateRule);
|
|
197
|
+
if (forGate === undefined)
|
|
198
|
+
candidatesByGate.set(gateRule, [override]);
|
|
199
|
+
else
|
|
200
|
+
forGate.push(override);
|
|
201
|
+
}
|
|
202
|
+
const accepted = [];
|
|
203
|
+
const acceptedByGate = new Set();
|
|
204
|
+
const approvals = [];
|
|
205
|
+
// Gates are visited in code-point order so the host's list order cannot decide the accepted
|
|
206
|
+
// list. Every candidate is weighed against the original, pre-override report; the report is
|
|
207
|
+
// rewritten once below so one gate's waiver cannot be lost when the next gate is applied.
|
|
208
|
+
for (const gateRule of [...candidatesByGate.keys()].sort((left, right) => compareCodePoints(left.ruleId, right.ruleId))) {
|
|
209
|
+
const gateResult = resultByRuleId.get(gateRule.ruleId);
|
|
210
|
+
const inputHash = request.inputHashOf(gateRule.ruleId);
|
|
211
|
+
const gateReport = request.report.gates?.[gateRule.ruleId];
|
|
212
|
+
if (gateResult === undefined || gateReport === undefined) {
|
|
213
|
+
throw new AxiomError('ENGINE_ERROR', `gate ${gateRule.ruleId} reported no gate section`, gateRule.ruleId);
|
|
214
|
+
}
|
|
215
|
+
// An inactive gate's section states `active: false` and no items; an active one has no
|
|
216
|
+
// `active` member at all, so the union is narrowed rather than tested for a falsy value.
|
|
217
|
+
const inactive = 'active' in gateReport && gateReport.active === false;
|
|
218
|
+
const approved = [];
|
|
219
|
+
for (const override of candidatesByGate.get(gateRule) ?? []) {
|
|
220
|
+
// An inactive gate decided nothing — its `activeWhen` switched it off — so there is no
|
|
221
|
+
// verdict an approval could satisfy or be stale against. The check precedes the hash
|
|
222
|
+
// because an inactive gate reports `PASS`, which is the same status its own approval would
|
|
223
|
+
// bind: accepting here recorded a human approving a gate that never ran.
|
|
224
|
+
if (inactive) {
|
|
225
|
+
refused.push({ override, reason: 'inactive_gate' });
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (gateRule.gate?.hard === true) {
|
|
229
|
+
refused.push({ override, reason: 'hard_gate' });
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
if (inputHash === undefined || override.inputHash !== inputHash) {
|
|
233
|
+
refused.push({ override, reason: inputHash === undefined ? 'unreadable_input' : 'stale' });
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
// The same report-stated facts `applyApprovedOverrides` weighs, so the door and the replay
|
|
237
|
+
// helper cannot disagree about whether a record belongs to this gate.
|
|
238
|
+
if (!approvalMatchesReport(request.report, gateResult, override)) {
|
|
239
|
+
refused.push({ override, reason: 'stale' });
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
approved.push(override);
|
|
243
|
+
}
|
|
244
|
+
if (approved.length === 0)
|
|
245
|
+
continue;
|
|
246
|
+
// A host may replay a long approval log; appending one at a time keeps a large list a
|
|
247
|
+
// large list rather than an argument-count overflow.
|
|
248
|
+
for (const override of approved)
|
|
249
|
+
accepted.push(override);
|
|
250
|
+
acceptedByGate.add(gateRule.ruleId);
|
|
251
|
+
approvals.push({
|
|
252
|
+
gateRuleId: gateRule.ruleId,
|
|
253
|
+
accepted: approved,
|
|
254
|
+
deniedFields: request.deniedFieldsOf(gateRule.ruleId),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
const satisfied = approvals.length === 0 ? request.report : applyApprovedOverrideBatch(request.report, approvals);
|
|
258
|
+
// The records are frozen by the boundary reader; the list a caller receives is frozen here
|
|
259
|
+
// so an accepted approval cannot be dropped from the view of what the call accepted.
|
|
260
|
+
const overrides = Object.freeze({
|
|
261
|
+
accepted: Object.freeze(accepted),
|
|
262
|
+
refused: Object.freeze(refused),
|
|
263
|
+
});
|
|
264
|
+
const primary = satisfied.gates?.[request.primaryGateId];
|
|
265
|
+
const primaryResult = satisfied.rules.find((result) => result.ruleId === request.primaryGateId);
|
|
266
|
+
if (primary === undefined || primaryResult === undefined) {
|
|
267
|
+
throw new AxiomError('ENGINE_ERROR', `gate ${request.primaryGateId} reported no gate section`, request.primaryGateId);
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
outcome: acceptedByGate.has(request.primaryGateId)
|
|
271
|
+
? 'OVERRIDDEN'
|
|
272
|
+
: gateOutcome(primaryResult.status),
|
|
273
|
+
report: satisfied,
|
|
274
|
+
gate: primary,
|
|
275
|
+
overrides,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=gate.js.map
|