@azx-pbc/axiom-runtime 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +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 +1207 -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 @@
|
|
|
1
|
+
{"version":3,"file":"pass.js","sourceRoot":"","sources":["../../src/lookup/pass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAWhD,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAEjG;;;;;;;;GAQG;AAEH,+FAA+F;AAC/F,SAAS,KAAK,CAAC,GAAG,KAAyB;IACzC,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC;AAkBD,SAAS,QAAQ,CACf,MAAiB,EACjB,OAAe,EACf,KAAsB,EACtB,UAA8B;IAE9B,MAAM,IAAI,GAAG,UAAU,IAAI,IAAI,CAAC;IAChC,IAAI,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACpB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAA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CAAC;AACzC,CAAC","sourcesContent":["import { canonicalizeRestricted } from '../canonical/jcs.js';\nimport { compareCodePoints } from '../expr/strings.js';\nimport { AxiomError } from '../model/errors.js';\nimport type { DatasetRef } from '../model/schema.js';\nimport type {\n LookupPort,\n LookupProvenance,\n LookupResolution,\n ResolvedTable,\n ScalarWireValue,\n SetResolution,\n WireRecord,\n} from '../model/types.js';\nimport { datasetDigestMismatch, digestReaderOf, refuseDatasetDigestMismatch } from './digest.js';\n\n/**\n * The two wrappers every evaluation pass puts around the host's lookup port, so neither the\n * expression language nor the host store has to carry them.\n *\n * `pinLookup` binds resolution to the versions an artifact was compiled against\n * `memoizeLookup` answers an identical call once per pass\n * a decision table read by three rules is one store round trip, and the\n * memo dies with the pass, so no result outlives the input it was resolved from.\n */\n\n/** The canonical text one call is keyed by: the operation, its table, its operand and date. */\nfunction token(...parts: readonly unknown[]): string {\n return canonicalizeRestricted(parts);\n}\n\n/**\n * The canonical token of each scalar set query already seen this pass, by table, value and\n * date. The token is still the memo's key universe; this index only means a call the pass\n * has already resolved does not canonicalise its arguments a second time. Scalars are safe\n * as map keys because `1` and `\"1\"` are different keys, exactly as the canonical text keeps\n * them different.\n */\ntype SetTokens = Map<string, Map<ScalarWireValue, Map<string | null, string>>>;\n\n/**\n * The canonical token of each decision input already seen this pass. A decision is queried\n * by the record it names, and the reader hands the same record object back for the rest of\n * the pass, so object identity is the cheap index in front of the canonical key.\n */\ntype DecideTokens = WeakMap<object, Map<string, Map<string | null, string>>>;\n\nfunction setToken(\n tokens: SetTokens,\n tableId: string,\n value: ScalarWireValue,\n recordDate: string | undefined,\n): string {\n const date = recordDate ?? null;\n let byValue = tokens.get(tableId);\n if (byValue === undefined) {\n byValue = new Map();\n tokens.set(tableId, byValue);\n }\n let byDate = byValue.get(value);\n if (byDate === undefined) {\n byDate = new Map();\n byValue.set(value, byDate);\n }\n const known = byDate.get(date);\n if (known !== undefined) return known;\n const text = token('in_set', tableId, value, date);\n byDate.set(date, text);\n return text;\n}\n\nfunction decideToken(\n tokens: DecideTokens,\n tableId: string,\n inputs: WireRecord,\n asOf: string | undefined,\n): string {\n let byTable = tokens.get(inputs);\n if (byTable === undefined) {\n byTable = new Map();\n tokens.set(inputs, byTable);\n }\n let byDate = byTable.get(tableId);\n if (byDate === undefined) {\n byDate = new Map();\n byTable.set(tableId, byDate);\n }\n const date = asOf ?? null;\n const known = byDate.get(date);\n if (known !== undefined) return known;\n const text = token('decide', tableId, inputs, date);\n byDate.set(date, text);\n return text;\n}\n\n/**\n * A port that answers an identical call from the store once and repeats the answer for the\n * rest of the pass.\n *\n * The memo is deliberately not a cache: it is built per evaluation pass and is released\n * with it, so it cannot serve a resolution from another record, another record date or\n * another set of table versions. A miss, an undetermined answer and a stale refusal are\n * recorded too — the store's answer is the fact being reused, not only its hits.\n */\nexport function memoizeLookup(port: LookupPort): LookupPort {\n const sets = new Map<string, SetResolution>();\n const resolutions = new Map<string, LookupResolution>();\n // The token indexes die with the pass, like the memos they front, so a value resolved from\n // one record can never name the resolution of another.\n const setTokens: SetTokens = new Map();\n const decideTokens: DecideTokens = new WeakMap();\n const rememberSet = (key: string, resolve: () => SetResolution): SetResolution => {\n const known = sets.get(key);\n if (known !== undefined) return known;\n const resolution = resolve();\n sets.set(key, resolution);\n return resolution;\n };\n const remember = (key: string, resolve: () => LookupResolution): LookupResolution => {\n const known = resolutions.get(key);\n if (known !== undefined) return known;\n const resolution = resolve();\n resolutions.set(key, resolution);\n return resolution;\n };\n return {\n contains(tableId: string, value: ScalarWireValue, recordDate?: string): SetResolution {\n return rememberSet(setToken(setTokens, tableId, value, recordDate), () =>\n port.contains(tableId, value, recordDate),\n );\n },\n resolve(tableId: string, keys: readonly ScalarWireValue[], asOf?: string): LookupResolution {\n return remember(token('lookup', tableId, keys, asOf ?? null), () =>\n port.resolve(tableId, keys, asOf),\n );\n },\n decide(tableId: string, inputs: WireRecord, asOf?: string): LookupResolution {\n // A `decide` is queried by the input record it names, so that record is its identity\n // for the pass: two rules reading the same inputs resolve one answer.\n return remember(decideToken(decideTokens, tableId, inputs, asOf), () =>\n port.decide(tableId, inputs, asOf),\n );\n },\n decideKeys(tableId: string, keys: readonly ScalarWireValue[], asOf?: string): LookupResolution {\n return remember(token('decide_keys', tableId, keys, asOf ?? null), () =>\n port.decideKeys(tableId, keys, asOf),\n );\n },\n };\n}\n\n/**\n * A port that refuses a table version other than the one the artifact pins, and a pairing whose\n * held document is not the document the pin names.\n *\n * The pin is the version the schema was published against, so a store serving any other\n * version — older or newer — is answering from data the artifact was never checked with: the\n * call goes `STALE` with `version_mismatch` rather than falling back to what the store holds.\n * That is what \"must not fall back to the newest available version\" means,\n * and it is what makes a replay seven years later resolve the rows the decision was made on.\n *\n * A version is not bytes: a table republished under the pinned version keeps its name while its\n * document changes. When the store can state the canonical digest of the version it holds\n * (`DigestBearingPort`, which `MemoryLookupStore` implements), every pin the store can answer is\n * compared before any rule reads a value, and a difference is refused with the `tableId`,\n * `tableVersion`, `expected` and `actual` offline admission also states. A pin that names no\n * digest cannot be verified at all and is refused too, rather than silently answering from\n * version alone; an artifact that declares no pins is not paired through here at all.\n */\nexport function pinLookup(port: LookupPort, pins: readonly DatasetRef[]): LookupPort {\n const byTable = new Map<string, DatasetRef>();\n const digestOf = digestReaderOf(port);\n for (const pin of pins) {\n if (typeof pin.sha256 !== 'string') {\n throw new AxiomError(\n 'ENGINE_ERROR',\n `table ${pin.tableId} version ${String(pin.tableVersion)} pins no canonical digest, so its bytes cannot be verified`,\n pin.tableId,\n );\n }\n byTable.set(pin.tableId, pin);\n // A port that cannot state its digests has its documents outside what this package can see;\n // offline admission is then the only door that verified them.\n if (digestOf === undefined) continue;\n const actual = digestOf(pin.tableId, pin.tableVersion);\n if (actual === undefined) continue;\n const mismatch = datasetDigestMismatch(pin, actual);\n if (mismatch !== undefined) refuseDatasetDigestMismatch(mismatch);\n }\n const wrongVersion = (table: ResolvedTable): boolean => {\n const pin = byTable.get(table.tableId);\n return pin !== undefined && table.tableVersion !== pin.tableVersion;\n };\n const pinnedSet = (resolution: SetResolution): SetResolution => {\n if (resolution.outcome === 'STALE' || !wrongVersion(resolution.table)) return resolution;\n return { outcome: 'STALE', tableId: resolution.table.tableId, reason: 'version_mismatch' };\n };\n const pinnedResolution = (resolution: LookupResolution): LookupResolution => {\n if (resolution.outcome === 'STALE') return resolution;\n const table = resolution.table;\n if (table === undefined || !wrongVersion(table)) return resolution;\n return { outcome: 'STALE', tableId: table.tableId, reason: 'version_mismatch' };\n };\n return {\n contains: (tableId, value, recordDate) => pinnedSet(port.contains(tableId, value, recordDate)),\n resolve: (tableId, keys, asOf) => pinnedResolution(port.resolve(tableId, keys, asOf)),\n decide: (tableId, inputs, asOf) => pinnedResolution(port.decide(tableId, inputs, asOf)),\n decideKeys: (tableId, keys, asOf) => pinnedResolution(port.decideKeys(tableId, keys, asOf)),\n };\n}\n\n/**\n * The lookups one evaluation resolved, deduplicated and ordered.\n *\n * The list is provenance rather than a call log: two rules resolving the same row of the same\n * table version produced one fact about what the report was resolved against, so an identical\n * entry is recorded once. Entries are canonically sorted, so the order does not depend on\n * which rule happened to run first and the report hash is reproducible.\n *\n * The canonical token is derived once per distinct provenance object. The port memo hands back\n * the same resolution object for a repeated call, so a query asked once per row is\n * canonicalised once rather than once per call.\n */\nexport class ProvenanceLedger {\n private readonly entries = new Map<string, LookupProvenance>();\n private readonly attributed = new Map<string, Map<string, LookupProvenance>>();\n private readonly tokens = new WeakMap<LookupProvenance, string>();\n\n /** Records one resolution, attributed to the rule that made it when there is one. */\n record(provenance: LookupProvenance, ruleId: string | undefined): void {\n let token = this.tokens.get(provenance);\n if (token === undefined) {\n token = canonicalizeRestricted(provenance);\n this.tokens.set(provenance, token);\n }\n this.entries.set(token, provenance);\n if (ruleId === undefined) return;\n const attributed = this.attributed.get(ruleId) ?? new Map<string, LookupProvenance>();\n attributed.set(token, provenance);\n this.attributed.set(ruleId, attributed);\n }\n\n /** Every entry, canonically ordered. */\n all(): readonly LookupProvenance[] {\n return sortedProvenance(this.entries);\n }\n\n /** One rule's own entries, canonically ordered. */\n forRule(ruleId: string | undefined): readonly LookupProvenance[] {\n return ruleId === undefined ? [] : sortedProvenance(this.attributed.get(ruleId));\n }\n}\n\nfunction sortedProvenance(\n entries: ReadonlyMap<string, LookupProvenance> | undefined,\n): readonly LookupProvenance[] {\n if (entries === undefined) return [];\n return [...entries.entries()]\n .sort(([left], [right]) => compareCodePoints(left, right))\n .map(([, provenance]) => provenance);\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { LookupMissReason, LookupTableDocument } from '../model/types.js';
|
|
2
|
+
import type { CompiledSchema } from '../model/schema.js';
|
|
3
|
+
/**
|
|
4
|
+
* Why a declared dataset has no version hash to commit to: the two reasons a lookup can miss
|
|
5
|
+
* without a document to name. The members are selected from `LookupMissReason`, so a pin and a
|
|
6
|
+
* resolution cannot spell one reason two ways.
|
|
7
|
+
*/
|
|
8
|
+
export type DatasetPinMissReason = Extract<LookupMissReason, 'missing_table' | 'version_mismatch'>;
|
|
9
|
+
/**
|
|
10
|
+
* One table the artifact pins, as an identity a caller can reproduce without evaluating.
|
|
11
|
+
*
|
|
12
|
+
* A resolved pin names the version the artifact was compiled against and the SHA-256 of the
|
|
13
|
+
* document that answered, which is the same digest `install.ts` builds every resolution's
|
|
14
|
+
* provenance from. A table the supplied documents cannot answer with the pinned version has
|
|
15
|
+
* no digest to state, so the reason it could not is bound instead.
|
|
16
|
+
*/
|
|
17
|
+
export type ResolvedDatasetPin = {
|
|
18
|
+
readonly tableId: string;
|
|
19
|
+
readonly tableVersion: number;
|
|
20
|
+
readonly tableSha256: string;
|
|
21
|
+
} | {
|
|
22
|
+
readonly tableId: string;
|
|
23
|
+
readonly reason: DatasetPinMissReason;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Every table a compiled artifact pins, resolved against the documents a caller supplies.
|
|
27
|
+
*
|
|
28
|
+
* This is the artifact's data identity rather than an evaluation's: a caller that must bind a
|
|
29
|
+
* decision to the tables it was resolved against asks here, so the answer does not depend on
|
|
30
|
+
* which rules happened to read which table. `prepareInstallation` runs first, so a catalogue
|
|
31
|
+
* that could not be installed at all is refused rather than half-hashed.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveDatasetPins(compiled: CompiledSchema, documents: readonly LookupTableDocument[]): readonly ResolvedDatasetPin[];
|
|
34
|
+
//# sourceMappingURL=pins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pins.d.ts","sourceRoot":"","sources":["../../src/lookup/pins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,oBAAoB,CAAC;AAKrE;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,EAAE,eAAe,GAAG,kBAAkB,CAAC,CAAC;AAEnG;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IACE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,GACD;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAExE;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,SAAS,mBAAmB,EAAE,GACxC,SAAS,kBAAkB,EAAE,CAW/B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { compareCodePoints } from '../expr/strings.js';
|
|
2
|
+
import { prepareInstallation } from './install.js';
|
|
3
|
+
/**
|
|
4
|
+
* Every table a compiled artifact pins, resolved against the documents a caller supplies.
|
|
5
|
+
*
|
|
6
|
+
* This is the artifact's data identity rather than an evaluation's: a caller that must bind a
|
|
7
|
+
* decision to the tables it was resolved against asks here, so the answer does not depend on
|
|
8
|
+
* which rules happened to read which table. `prepareInstallation` runs first, so a catalogue
|
|
9
|
+
* that could not be installed at all is refused rather than half-hashed.
|
|
10
|
+
*/
|
|
11
|
+
export function resolveDatasetPins(compiled, documents) {
|
|
12
|
+
const declared = compiled.datasets ?? [];
|
|
13
|
+
if (declared.length === 0)
|
|
14
|
+
return [];
|
|
15
|
+
// A document for a table the artifact does not pin cannot change the identity this states,
|
|
16
|
+
// so it is not installed: an uninstallable catalogue it alone belongs to would otherwise
|
|
17
|
+
// refuse a run whose data never mentioned it.
|
|
18
|
+
const pinned = new Set(declared.map((ref) => ref.tableId));
|
|
19
|
+
const tables = prepareInstallation(documents.filter((document) => pinned.has(document.tableId)));
|
|
20
|
+
return [...declared]
|
|
21
|
+
.sort((left, right) => compareCodePoints(left.tableId, right.tableId))
|
|
22
|
+
.map((ref) => pinOf(ref, tables));
|
|
23
|
+
}
|
|
24
|
+
function pinOf(ref, tables) {
|
|
25
|
+
const table = tables.get(ref.tableId);
|
|
26
|
+
const version = table?.versions.find((candidate) => candidate.document.tableVersion === ref.tableVersion);
|
|
27
|
+
if (version === undefined) {
|
|
28
|
+
return {
|
|
29
|
+
tableId: ref.tableId,
|
|
30
|
+
reason: table === undefined ? 'missing_table' : 'version_mismatch',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
tableId: ref.tableId,
|
|
35
|
+
tableVersion: ref.tableVersion,
|
|
36
|
+
tableSha256: version.digest,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=pins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pins.js","sourceRoot":"","sources":["../../src/lookup/pins.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EA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MAAM,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,kBAAkB;SACnE,CAAC;IACJ,CAAC;IACD,OAAO;QACL,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,WAAW,EAAE,OAAO,CAAC,MAAM;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["import type { LookupMissReason, LookupTableDocument } from '../model/types.js';\nimport type { CompiledSchema, DatasetRef } from '../model/schema.js';\nimport { compareCodePoints } from '../expr/strings.js';\nimport { prepareInstallation } from './install.js';\nimport type { PreparedTable } from './install.js';\n\n/**\n * Why a declared dataset has no version hash to commit to: the two reasons a lookup can miss\n * without a document to name. The members are selected from `LookupMissReason`, so a pin and a\n * resolution cannot spell one reason two ways.\n */\nexport type DatasetPinMissReason = Extract<LookupMissReason, 'missing_table' | 'version_mismatch'>;\n\n/**\n * One table the artifact pins, as an identity a caller can reproduce without evaluating.\n *\n * A resolved pin names the version the artifact was compiled against and the SHA-256 of the\n * document that answered, which is the same digest `install.ts` builds every resolution's\n * provenance from. A table the supplied documents cannot answer with the pinned version has\n * no digest to state, so the reason it could not is bound instead.\n */\nexport type ResolvedDatasetPin =\n | {\n readonly tableId: string;\n readonly tableVersion: number;\n readonly tableSha256: string;\n }\n | { readonly tableId: string; readonly reason: DatasetPinMissReason };\n\n/**\n * Every table a compiled artifact pins, resolved against the documents a caller supplies.\n *\n * This is the artifact's data identity rather than an evaluation's: a caller that must bind a\n * decision to the tables it was resolved against asks here, so the answer does not depend on\n * which rules happened to read which table. `prepareInstallation` runs first, so a catalogue\n * that could not be installed at all is refused rather than half-hashed.\n */\nexport function resolveDatasetPins(\n compiled: CompiledSchema,\n documents: readonly LookupTableDocument[],\n): readonly ResolvedDatasetPin[] {\n const declared = compiled.datasets ?? [];\n if (declared.length === 0) return [];\n // A document for a table the artifact does not pin cannot change the identity this states,\n // so it is not installed: an uninstallable catalogue it alone belongs to would otherwise\n // refuse a run whose data never mentioned it.\n const pinned = new Set(declared.map((ref) => ref.tableId));\n const tables = prepareInstallation(documents.filter((document) => pinned.has(document.tableId)));\n return [...declared]\n .sort((left, right) => compareCodePoints(left.tableId, right.tableId))\n .map((ref) => pinOf(ref, tables));\n}\n\nfunction pinOf(ref: DatasetRef, tables: ReadonlyMap<string, PreparedTable>): ResolvedDatasetPin {\n const table = tables.get(ref.tableId);\n const version = table?.versions.find(\n (candidate) => candidate.document.tableVersion === ref.tableVersion,\n );\n if (version === undefined) {\n return {\n tableId: ref.tableId,\n reason: table === undefined ? 'missing_table' : 'version_mismatch',\n };\n }\n return {\n tableId: ref.tableId,\n tableVersion: ref.tableVersion,\n tableSha256: version.digest,\n };\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { LookupProvenance, LookupResolution, ResolvedTable, SetResolution } from '../model/types.js';
|
|
2
|
+
import type { PreparedVersion } from './install.js';
|
|
3
|
+
/** The identity of the version that answered. */
|
|
4
|
+
export declare function resolvedTable(version: PreparedVersion, asOf: string | undefined): ResolvedTable;
|
|
5
|
+
/**
|
|
6
|
+
* The report entry one resolution produces.
|
|
7
|
+
*
|
|
8
|
+
* Every resolution between them states what a seven-year-old report needs to reproduce the
|
|
9
|
+
* answer: a resolved entry carries the table identity, the canonical query key and whether the
|
|
10
|
+
* query matched; a `STALE` entry carries the table that could not resolve and why, because no
|
|
11
|
+
* document resolved and therefore no version or digest exists to record. `hit`,
|
|
12
|
+
* `matchedRowId` and single-versus-collection are derived from `rows` here, so the resolution
|
|
13
|
+
* and the report cannot disagree about them.
|
|
14
|
+
*
|
|
15
|
+
* A resolution whose verdict is undetermined states the rows whose key matched. Reporting it as
|
|
16
|
+
* a query that matched nothing would be a claim the opposite of what the engine observed, and a
|
|
17
|
+
* replay seven years later could not tell it from a genuine miss (`DATA-4.1.1`, `DATA-4.1.3`).
|
|
18
|
+
*
|
|
19
|
+
* `undefined` when no query was formed at all: a `decide` whose input record omits a key column
|
|
20
|
+
* asked the store nothing, and an entry would describe a lookup nobody made.
|
|
21
|
+
*/
|
|
22
|
+
export declare function toProvenance(resolution: SetResolution | LookupResolution): LookupProvenance | undefined;
|
|
23
|
+
//# sourceMappingURL=provenance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provenance.d.ts","sourceRoot":"","sources":["../../src/lookup/provenance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAChB,gBAAgB,EAEhB,aAAa,EACb,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,iDAAiD;AACjD,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa,CAQ/F;AAkBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,aAAa,GAAG,gBAAgB,GAC3C,gBAAgB,GAAG,SAAS,CAmC9B"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** The identity of the version that answered. */
|
|
2
|
+
export function resolvedTable(version, asOf) {
|
|
3
|
+
const document = version.document;
|
|
4
|
+
return {
|
|
5
|
+
tableId: document.tableId,
|
|
6
|
+
tableVersion: document.tableVersion,
|
|
7
|
+
tableSha256: version.digest,
|
|
8
|
+
...(version.document.binding === 'data' && asOf !== undefined ? { asOfDate: asOf } : {}),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The row ids one resolution's matched rows state, in the shape its hit policy fixes.
|
|
13
|
+
*
|
|
14
|
+
* One id for `UNIQUE` and `FIRST`, the ordered ids for `COLLECT`, and `null` only when no row
|
|
15
|
+
* matched. A collection is always a list, decided or not, so the report's shape does not depend
|
|
16
|
+
* on how many rows a resolution happened to reach.
|
|
17
|
+
*/
|
|
18
|
+
function matchedRowId(rows, hitPolicy) {
|
|
19
|
+
const [first] = rows;
|
|
20
|
+
if (first === undefined)
|
|
21
|
+
return null;
|
|
22
|
+
return hitPolicy === 'COLLECT' ? rows.map((row) => row.rowId) : first.rowId;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The report entry one resolution produces.
|
|
26
|
+
*
|
|
27
|
+
* Every resolution between them states what a seven-year-old report needs to reproduce the
|
|
28
|
+
* answer: a resolved entry carries the table identity, the canonical query key and whether the
|
|
29
|
+
* query matched; a `STALE` entry carries the table that could not resolve and why, because no
|
|
30
|
+
* document resolved and therefore no version or digest exists to record. `hit`,
|
|
31
|
+
* `matchedRowId` and single-versus-collection are derived from `rows` here, so the resolution
|
|
32
|
+
* and the report cannot disagree about them.
|
|
33
|
+
*
|
|
34
|
+
* A resolution whose verdict is undetermined states the rows whose key matched. Reporting it as
|
|
35
|
+
* a query that matched nothing would be a claim the opposite of what the engine observed, and a
|
|
36
|
+
* replay seven years later could not tell it from a genuine miss (`DATA-4.1.1`, `DATA-4.1.3`).
|
|
37
|
+
*
|
|
38
|
+
* `undefined` when no query was formed at all: a `decide` whose input record omits a key column
|
|
39
|
+
* asked the store nothing, and an entry would describe a lookup nobody made.
|
|
40
|
+
*/
|
|
41
|
+
export function toProvenance(resolution) {
|
|
42
|
+
switch (resolution.outcome) {
|
|
43
|
+
case 'STALE':
|
|
44
|
+
return { tableId: resolution.tableId, reason: resolution.reason };
|
|
45
|
+
case 'MEMBER':
|
|
46
|
+
case 'ABSENT':
|
|
47
|
+
return {
|
|
48
|
+
...resolution.table,
|
|
49
|
+
key: resolution.key,
|
|
50
|
+
hit: resolution.outcome === 'MEMBER',
|
|
51
|
+
matchedRowId: null,
|
|
52
|
+
};
|
|
53
|
+
case 'HIT': {
|
|
54
|
+
const [first] = resolution.rows;
|
|
55
|
+
if (first === undefined)
|
|
56
|
+
return undefined;
|
|
57
|
+
return {
|
|
58
|
+
...resolution.table,
|
|
59
|
+
key: resolution.key,
|
|
60
|
+
hit: true,
|
|
61
|
+
matchedRowId: matchedRowId(resolution.rows, resolution.hitPolicy),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
case 'MISS':
|
|
65
|
+
return { ...resolution.table, key: resolution.key, hit: false, matchedRowId: null };
|
|
66
|
+
case 'UNDETERMINED': {
|
|
67
|
+
const { table, key, hitPolicy, rows } = resolution;
|
|
68
|
+
// The four members are stated together by a resolution that formed a query. Without them
|
|
69
|
+
// there is no table, key or row to reproduce, so the call records no entry rather than
|
|
70
|
+
// one that claims the query matched nothing.
|
|
71
|
+
if (table === undefined || key === undefined || hitPolicy === undefined || rows === undefined)
|
|
72
|
+
return undefined;
|
|
73
|
+
const matched = matchedRowId(rows, hitPolicy);
|
|
74
|
+
return { ...table, key, hit: matched !== null, matchedRowId: matched };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=provenance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provenance.js","sourceRoot":"","sources":["../../src/lookup/provenance.ts"],"names":[],"mappings":"AAUA,iDAAiD;AACjD,MAAM,UAAU,aAAa,CAAC,OAAwB,EAAE,IAAwB;IAC9E,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,OAAO;QACL,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,WAAW,EAAE,OAAO,CAAC,MAAM;QAC3B,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,KAAK,MAAM,IAAI,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAS,YAAY,CACnB,IAA0B,EAC1B,SAAoB;IAEpB,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACrB,IAAI,KAAK,K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AAS,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC;YACnD,yFAAyF;YACzF,uFAAuF;YACvF,6CAA6C;YAC7C,IAAI,KAAK,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS;gBAC3F,OAAO,SAAS,CAAC;YACnB,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YAC9C,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;QACzE,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type {\n HitPolicy,\n LookupProvenance,\n LookupResolution,\n LookupRow,\n ResolvedTable,\n SetResolution,\n} from '../model/types.js';\nimport type { PreparedVersion } from './install.js';\n\n/** The identity of the version that answered. */\nexport function resolvedTable(version: PreparedVersion, asOf: string | undefined): ResolvedTable {\n const document = version.document;\n return {\n tableId: document.tableId,\n tableVersion: document.tableVersion,\n tableSha256: version.digest,\n ...(version.document.binding === 'data' && asOf !== undefined ? { asOfDate: asOf } : {}),\n };\n}\n\n/**\n * The row ids one resolution's matched rows state, in the shape its hit policy fixes.\n *\n * One id for `UNIQUE` and `FIRST`, the ordered ids for `COLLECT`, and `null` only when no row\n * matched. A collection is always a list, decided or not, so the report's shape does not depend\n * on how many rows a resolution happened to reach.\n */\nfunction matchedRowId(\n rows: readonly LookupRow[],\n hitPolicy: HitPolicy,\n): string | readonly string[] | null {\n const [first] = rows;\n if (first === undefined) return null;\n return hitPolicy === 'COLLECT' ? rows.map((row) => row.rowId) : first.rowId;\n}\n\n/**\n * The report entry one resolution produces.\n *\n * Every resolution between them states what a seven-year-old report needs to reproduce the\n * answer: a resolved entry carries the table identity, the canonical query key and whether the\n * query matched; a `STALE` entry carries the table that could not resolve and why, because no\n * document resolved and therefore no version or digest exists to record. `hit`,\n * `matchedRowId` and single-versus-collection are derived from `rows` here, so the resolution\n * and the report cannot disagree about them.\n *\n * A resolution whose verdict is undetermined states the rows whose key matched. Reporting it as\n * a query that matched nothing would be a claim the opposite of what the engine observed, and a\n * replay seven years later could not tell it from a genuine miss (`DATA-4.1.1`, `DATA-4.1.3`).\n *\n * `undefined` when no query was formed at all: a `decide` whose input record omits a key column\n * asked the store nothing, and an entry would describe a lookup nobody made.\n */\nexport function toProvenance(\n resolution: SetResolution | LookupResolution,\n): LookupProvenance | undefined {\n switch (resolution.outcome) {\n case 'STALE':\n return { tableId: resolution.tableId, reason: resolution.reason };\n case 'MEMBER':\n case 'ABSENT':\n return {\n ...resolution.table,\n key: resolution.key,\n hit: resolution.outcome === 'MEMBER',\n matchedRowId: null,\n };\n case 'HIT': {\n const [first] = resolution.rows;\n if (first === undefined) return undefined;\n return {\n ...resolution.table,\n key: resolution.key,\n hit: true,\n matchedRowId: matchedRowId(resolution.rows, resolution.hitPolicy),\n };\n }\n case 'MISS':\n return { ...resolution.table, key: resolution.key, hit: false, matchedRowId: null };\n case 'UNDETERMINED': {\n const { table, key, hitPolicy, rows } = resolution;\n // The four members are stated together by a resolution that formed a query. Without them\n // there is no table, key or row to reproduce, so the call records no entry rather than\n // one that claims the query matched nothing.\n if (table === undefined || key === undefined || hitPolicy === undefined || rows === undefined)\n return undefined;\n const matched = matchedRowId(rows, hitPolicy);\n return { ...table, key, hit: matched !== null, matchedRowId: matched };\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { LookupResolution } from '../model/types.js';
|
|
2
|
+
import type { PreparedTable, PreparedVersion } from './install.js';
|
|
3
|
+
/**
|
|
4
|
+
* The one version a call resolves against: the behavior table itself, or the data-bound
|
|
5
|
+
* version whose half-open window covers the supplied record date. A table that no version
|
|
6
|
+
* can answer from is `STALE` with the reason, never a neighbour's answer.
|
|
7
|
+
*/
|
|
8
|
+
export declare function selectVersion(tables: ReadonlyMap<string, PreparedTable>, tableId: string, expectedKind: 'lookup' | 'decision_table', asOf: string | undefined): PreparedVersion | Extract<LookupResolution, {
|
|
9
|
+
outcome: 'STALE';
|
|
10
|
+
}>;
|
|
11
|
+
/** The version whose window covers `day`, by binary search over disjoint windows. */
|
|
12
|
+
export declare function selectWindow(versions: readonly PreparedVersion[], day: number): PreparedVersion | undefined;
|
|
13
|
+
//# sourceMappingURL=readiness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../../src/lookup/readiness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGnE;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,QAAQ,GAAG,gBAAgB,EACzC,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,eAAe,GAAG,OAAO,CAAC,gBAAgB,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAyBnE;AAED,qFAAqF;AACrF,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,SAAS,eAAe,EAAE,EACpC,GAAG,EAAE,MAAM,GACV,eAAe,GAAG,SAAS,CAiB7B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { dateToDay, refuseTable } from './install.js';
|
|
2
|
+
/**
|
|
3
|
+
* The one version a call resolves against: the behavior table itself, or the data-bound
|
|
4
|
+
* version whose half-open window covers the supplied record date. A table that no version
|
|
5
|
+
* can answer from is `STALE` with the reason, never a neighbour's answer.
|
|
6
|
+
*/
|
|
7
|
+
export function selectVersion(tables, tableId, expectedKind, asOf) {
|
|
8
|
+
const table = tables.get(tableId);
|
|
9
|
+
const version = table?.versions[0];
|
|
10
|
+
if (table === undefined || version === undefined) {
|
|
11
|
+
return { outcome: 'STALE', reason: 'missing_table', tableId };
|
|
12
|
+
}
|
|
13
|
+
if (version.document.kind !== expectedKind) {
|
|
14
|
+
// Every version of one table shares its kind, which `datasetInstallationProblems`
|
|
15
|
+
// enforces, so the first version states the table's kind.
|
|
16
|
+
refuseTable(tableId, `table ${tableId} is a ${version.document.kind}, not a ${expectedKind}`);
|
|
17
|
+
}
|
|
18
|
+
if (version.document.binding === 'behavior') {
|
|
19
|
+
// A behavior table pins to the case and takes no date.
|
|
20
|
+
if (asOf !== undefined) {
|
|
21
|
+
refuseTable(tableId, `table ${tableId} is behavior-bound and does not take an as-of date`);
|
|
22
|
+
}
|
|
23
|
+
return version;
|
|
24
|
+
}
|
|
25
|
+
// A data-bound table resolves against the host's record date and never a clock
|
|
26
|
+
//
|
|
27
|
+
if (asOf === undefined)
|
|
28
|
+
return { outcome: 'STALE', reason: 'missing_as_of', tableId };
|
|
29
|
+
const day = dateToDay(asOf, tableId);
|
|
30
|
+
const selected = selectWindow(table.versions, day);
|
|
31
|
+
if (selected === undefined)
|
|
32
|
+
return { outcome: 'STALE', reason: 'out_of_range', tableId };
|
|
33
|
+
return selected;
|
|
34
|
+
}
|
|
35
|
+
/** The version whose window covers `day`, by binary search over disjoint windows. */
|
|
36
|
+
export function selectWindow(versions, day) {
|
|
37
|
+
let low = 0;
|
|
38
|
+
let high = versions.length - 1;
|
|
39
|
+
let candidate;
|
|
40
|
+
while (low <= high) {
|
|
41
|
+
const middle = (low + high) >> 1;
|
|
42
|
+
const version = versions[middle];
|
|
43
|
+
if (version === undefined)
|
|
44
|
+
return undefined;
|
|
45
|
+
if ((version.effectiveFrom ?? 0) <= day) {
|
|
46
|
+
candidate = version;
|
|
47
|
+
low = middle + 1;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
high = middle - 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (candidate === undefined)
|
|
54
|
+
return undefined;
|
|
55
|
+
return day < (candidate.effectiveTo ?? 0) ? candidate : undefined;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=readiness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readiness.js","sourceRoot":"","sources":["../../src/lookup/readiness.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,MAA0C,EAC1C,OAAe,EACf,YAAyC,EACzC,IAAwB;IAExB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACjD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;IAChE,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC3C,kFAAkF;QAClF,0DAA0D;QAC1D,WAAW,CAAC,OAAO,EAAE,SAAS,OAAO,SAAS,OAAO,CAAC,QAAQ,CAAC,IAAI,WAAW,YAAY,EAAE,CAAC,CAAC;IAChG,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QAC5C,uDAAuD;QACvD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,WAAW,CAAC,OAAO,EAAE,SAAS,OAAO,oDAAoD,CAAC,CAAC;QAC7F,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,+EAA+E;IAC/E,EAAE;IACF,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;IACtF,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACnD,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;IACzF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,YAAY,CAC1B,QAAoC,EACpC,GAAW;IAEX,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/B,IAAI,SAAsC,CAAC;IAC3C,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC5C,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;YACxC,SAAS,GAAG,OAAO,CAAC;YACpB,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IACD,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC9C,OAAO,GAAG,GAAG,CAAC,SAAS,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC","sourcesContent":["import type { LookupResolution } from '../model/types.js';\nimport type { PreparedTable, PreparedVersion } from './install.js';\nimport { dateToDay, refuseTable } from './install.js';\n\n/**\n * The one version a call resolves against: the behavior table itself, or the data-bound\n * version whose half-open window covers the supplied record date. A table that no version\n * can answer from is `STALE` with the reason, never a neighbour's answer.\n */\nexport function selectVersion(\n tables: ReadonlyMap<string, PreparedTable>,\n tableId: string,\n expectedKind: 'lookup' | 'decision_table',\n asOf: string | undefined,\n): PreparedVersion | Extract<LookupResolution, { outcome: 'STALE' }> {\n const table = tables.get(tableId);\n const version = table?.versions[0];\n if (table === undefined || version === undefined) {\n return { outcome: 'STALE', reason: 'missing_table', tableId };\n }\n if (version.document.kind !== expectedKind) {\n // Every version of one table shares its kind, which `datasetInstallationProblems`\n // enforces, so the first version states the table's kind.\n refuseTable(tableId, `table ${tableId} is a ${version.document.kind}, not a ${expectedKind}`);\n }\n if (version.document.binding === 'behavior') {\n // A behavior table pins to the case and takes no date.\n if (asOf !== undefined) {\n refuseTable(tableId, `table ${tableId} is behavior-bound and does not take an as-of date`);\n }\n return version;\n }\n // A data-bound table resolves against the host's record date and never a clock\n //\n if (asOf === undefined) return { outcome: 'STALE', reason: 'missing_as_of', tableId };\n const day = dateToDay(asOf, tableId);\n const selected = selectWindow(table.versions, day);\n if (selected === undefined) return { outcome: 'STALE', reason: 'out_of_range', tableId };\n return selected;\n}\n\n/** The version whose window covers `day`, by binary search over disjoint windows. */\nexport function selectWindow(\n versions: readonly PreparedVersion[],\n day: number,\n): PreparedVersion | undefined {\n let low = 0;\n let high = versions.length - 1;\n let candidate: PreparedVersion | undefined;\n while (low <= high) {\n const middle = (low + high) >> 1;\n const version = versions[middle];\n if (version === undefined) return undefined;\n if ((version.effectiveFrom ?? 0) <= day) {\n candidate = version;\n low = middle + 1;\n } else {\n high = middle - 1;\n }\n }\n if (candidate === undefined) return undefined;\n return day < (candidate.effectiveTo ?? 0) ? candidate : undefined;\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LookupResolution, ScalarWireValue, SetResolution, WireRecord } from '../model/types.js';
|
|
2
|
+
import type { PreparedTable } from './install.js';
|
|
3
|
+
/**
|
|
4
|
+
* The resolution algorithms behind `MemoryLookupStore`: set membership for every kind of
|
|
5
|
+
* set, composite-key lookup, and decision-row selection. They read a prepared catalog and
|
|
6
|
+
* never hold one, so the store owns the only copy of the installed versions.
|
|
7
|
+
*/
|
|
8
|
+
export declare function containsMember(tables: ReadonlyMap<string, PreparedTable>, tableId: string, value: ScalarWireValue, recordDate?: string): SetResolution;
|
|
9
|
+
/** `lookup(table, keys, asOf?)`: one keyed call against a lookup table. */
|
|
10
|
+
export declare function resolveKeyed(tables: ReadonlyMap<string, PreparedTable>, tableId: string, keys: readonly ScalarWireValue[], asOf?: string): LookupResolution;
|
|
11
|
+
/**
|
|
12
|
+
* `decide(table, inputs, asOf?)`: a decision row matches when every key
|
|
13
|
+
* column's input equals the row's key entry in the same domain. The key is assembled in
|
|
14
|
+
* column order and resolved through the same index a lookup uses, so a decision table is
|
|
15
|
+
* one map hit whatever its row count — the policy is applied to the rows sharing the key.
|
|
16
|
+
*/
|
|
17
|
+
export declare function decideInputs(tables: ReadonlyMap<string, PreparedTable>, tableId: string, inputs: WireRecord, asOf?: string): LookupResolution;
|
|
18
|
+
/**
|
|
19
|
+
* `decide_keys(table, keys, asOf?)`: the key vector a decision table is
|
|
20
|
+
* probed with, in declaration order. The language has no record literal, so a caller that
|
|
21
|
+
* holds the key values can name them directly instead of fabricating an input record.
|
|
22
|
+
*/
|
|
23
|
+
export declare function decideKeyVector(tables: ReadonlyMap<string, PreparedTable>, tableId: string, keys: readonly ScalarWireValue[], asOf?: string): LookupResolution;
|
|
24
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/lookup/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,aAAa,EACb,UAAU,EACX,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,cAAc,CAAC;AAKnE;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,eAAe,EACtB,UAAU,CAAC,EAAE,MAAM,GAClB,aAAa,CAuCf;AAED,2EAA2E;AAC3E,wBAAgB,YAAY,CAC1B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,eAAe,EAAE,EAChC,IAAI,CAAC,EAAE,MAAM,GACZ,gBAAgB,CAElB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,EAClB,IAAI,CAAC,EAAE,MAAM,GACZ,gBAAgB,CAmBlB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,eAAe,EAAE,EAChC,IAAI,CAAC,EAAE,MAAM,GACZ,gBAAgB,CAElB"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { assertNever } from '../model/errors.js';
|
|
2
|
+
import { isScalarWireValue } from '../model/values.js';
|
|
3
|
+
import { canonicalKey, dateToDay, refuseTable } from './install.js';
|
|
4
|
+
import { resolvedTable } from './provenance.js';
|
|
5
|
+
import { selectVersion, selectWindow } from './readiness.js';
|
|
6
|
+
/**
|
|
7
|
+
* The resolution algorithms behind `MemoryLookupStore`: set membership for every kind of
|
|
8
|
+
* set, composite-key lookup, and decision-row selection. They read a prepared catalog and
|
|
9
|
+
* never hold one, so the store owns the only copy of the installed versions.
|
|
10
|
+
*/
|
|
11
|
+
export function containsMember(tables, tableId, value, recordDate) {
|
|
12
|
+
const table = tables.get(tableId);
|
|
13
|
+
if (table === undefined)
|
|
14
|
+
return { outcome: 'STALE', reason: 'missing_table', tableId };
|
|
15
|
+
const version = table.versions[0];
|
|
16
|
+
if (version === undefined)
|
|
17
|
+
return { outcome: 'STALE', reason: 'missing_table', tableId };
|
|
18
|
+
const members = version.members;
|
|
19
|
+
if (members === undefined) {
|
|
20
|
+
refuseTable(tableId, `table ${tableId} is a ${version.document.kind}, not a set`);
|
|
21
|
+
}
|
|
22
|
+
const key = [value];
|
|
23
|
+
// The membership index is keyed by the value's canonical text; the provenance key is
|
|
24
|
+
// the same value as the one-entry key vector a keyed table would record.
|
|
25
|
+
const query = canonicalKey(value, `in_set(${tableId})`);
|
|
26
|
+
// A behavior table takes no date from anyone: membership is the same
|
|
27
|
+
// for every day, so a supplied record date is ignored rather than made a refusal.
|
|
28
|
+
if (version.document.binding === 'behavior') {
|
|
29
|
+
return {
|
|
30
|
+
outcome: members.has(query) ? 'MEMBER' : 'ABSENT',
|
|
31
|
+
table: resolvedTable(version, undefined),
|
|
32
|
+
key,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// A data-bound set resolves against a supplied date and nothing else.
|
|
36
|
+
// The evaluation decides which date that is — an `asOf` the call names, or the host's
|
|
37
|
+
// record date — so an as-of-less call answers only when the host supplied its own.
|
|
38
|
+
if (recordDate === undefined) {
|
|
39
|
+
return { outcome: 'STALE', reason: 'missing_as_of', tableId };
|
|
40
|
+
}
|
|
41
|
+
const selected = selectWindow(table.versions, dateToDay(recordDate, tableId));
|
|
42
|
+
if (selected === undefined)
|
|
43
|
+
return { outcome: 'STALE', reason: 'out_of_range', tableId };
|
|
44
|
+
const selectedMembers = selected.members;
|
|
45
|
+
if (selectedMembers === undefined) {
|
|
46
|
+
refuseTable(tableId, `table ${tableId} is a ${selected.document.kind}, not a set`);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
outcome: selectedMembers.has(query) ? 'MEMBER' : 'ABSENT',
|
|
50
|
+
table: resolvedTable(selected, recordDate),
|
|
51
|
+
key,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** `lookup(table, keys, asOf?)`: one keyed call against a lookup table. */
|
|
55
|
+
export function resolveKeyed(tables, tableId, keys, asOf) {
|
|
56
|
+
return byKey(tables, tableId, 'lookup', keys, asOf);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* `decide(table, inputs, asOf?)`: a decision row matches when every key
|
|
60
|
+
* column's input equals the row's key entry in the same domain. The key is assembled in
|
|
61
|
+
* column order and resolved through the same index a lookup uses, so a decision table is
|
|
62
|
+
* one map hit whatever its row count — the policy is applied to the rows sharing the key.
|
|
63
|
+
*/
|
|
64
|
+
export function decideInputs(tables, tableId, inputs, asOf) {
|
|
65
|
+
const version = selectVersion(tables, tableId, 'decision_table', asOf);
|
|
66
|
+
if ('outcome' in version)
|
|
67
|
+
return version;
|
|
68
|
+
const key = [];
|
|
69
|
+
for (const column of version.keyColumns) {
|
|
70
|
+
// An own member, never an inherited one: a column id is a name the caller may have chosen,
|
|
71
|
+
// and `constructor` is one an artifact may declare. Reading it through the prototype chain
|
|
72
|
+
// would answer `Object.prototype.constructor` for a record that carries nothing.
|
|
73
|
+
const supplied = Object.hasOwn(inputs, column.columnId) ? inputs[column.columnId] : undefined;
|
|
74
|
+
// An input the record does not carry — or carries as an empty or non-scalar value —
|
|
75
|
+
// cannot rule any row out, so nothing can be decided, and never a match found by
|
|
76
|
+
// skipping it. No query was formed, so the
|
|
77
|
+
// resolution names no key: a partial key would describe a lookup nobody made.
|
|
78
|
+
if (supplied === undefined || !isScalarWireValue(supplied)) {
|
|
79
|
+
return { outcome: 'UNDETERMINED', value: 'UNKNOWN' };
|
|
80
|
+
}
|
|
81
|
+
key.push(supplied);
|
|
82
|
+
}
|
|
83
|
+
return match(version, key, asOf);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* `decide_keys(table, keys, asOf?)`: the key vector a decision table is
|
|
87
|
+
* probed with, in declaration order. The language has no record literal, so a caller that
|
|
88
|
+
* holds the key values can name them directly instead of fabricating an input record.
|
|
89
|
+
*/
|
|
90
|
+
export function decideKeyVector(tables, tableId, keys, asOf) {
|
|
91
|
+
return byKey(tables, tableId, 'decision_table', keys, asOf);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The rows sharing one canonical key, and the policy applied to them.
|
|
95
|
+
* The key is indexed by canonical text, so a resolution is one map hit whatever the
|
|
96
|
+
* table's size.
|
|
97
|
+
*/
|
|
98
|
+
function match(version, keys, asOf) {
|
|
99
|
+
const rows = version.rowsByKey.get(canonicalKey(keys, version.document.tableId)) ?? [];
|
|
100
|
+
return applyPolicy(version, rows, asOf, keys);
|
|
101
|
+
}
|
|
102
|
+
/** One keyed call against a table of the expected kind. */
|
|
103
|
+
function byKey(tables, tableId, expectedKind, keys, asOf) {
|
|
104
|
+
const version = selectVersion(tables, tableId, expectedKind, asOf);
|
|
105
|
+
if ('outcome' in version)
|
|
106
|
+
return version;
|
|
107
|
+
if (keys.length !== version.keyColumns.length) {
|
|
108
|
+
refuseTable(tableId, `table ${tableId} takes ${String(version.keyColumns.length)} key values but received ${String(keys.length)}`);
|
|
109
|
+
}
|
|
110
|
+
return match(version, keys, asOf);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The hit policy applied to the rows that share one key.
|
|
114
|
+
*
|
|
115
|
+
* A row's declared outcome decides what it contributes: `PASS` is a hit, `FAIL` is a
|
|
116
|
+
* non-matching row a `FIRST` scan passes over, and an undetermined row makes the answer
|
|
117
|
+
* undetermined rather than skipped. A `UNIQUE` key matches at most one row — the installer
|
|
118
|
+
* refuses a second (`DATA-1.2.5`) — so its answer is that row's own outcome. The order-independent
|
|
119
|
+
* fold is `COLLECT`'s: `UNKNOWN` beats `DEFERRED` whichever order the rows are declared in, and a
|
|
120
|
+
* collection is never returned partially (`DATA-3.1.2`, `DATA-3.1.4`). A resolution that could not
|
|
121
|
+
* decide still states the rows whose key matched, so the report records the match it observed
|
|
122
|
+
* (`DATA-4.1.1`).
|
|
123
|
+
*/
|
|
124
|
+
function applyPolicy(version, rows, asOf, key) {
|
|
125
|
+
const table = resolvedTable(version, asOf);
|
|
126
|
+
const policy = version.hitPolicy;
|
|
127
|
+
switch (policy) {
|
|
128
|
+
case 'COLLECT': {
|
|
129
|
+
const hits = [];
|
|
130
|
+
const matched = [];
|
|
131
|
+
let undetermined;
|
|
132
|
+
for (const row of rows) {
|
|
133
|
+
const outcome = row.outcome ?? 'PASS';
|
|
134
|
+
if (outcome === 'FAIL')
|
|
135
|
+
continue;
|
|
136
|
+
matched.push(row);
|
|
137
|
+
if (outcome === 'PASS') {
|
|
138
|
+
hits.push(row);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (outcome === 'UNKNOWN')
|
|
142
|
+
undetermined = 'UNKNOWN';
|
|
143
|
+
else
|
|
144
|
+
undetermined ??= 'DEFERRED';
|
|
145
|
+
}
|
|
146
|
+
if (undetermined !== undefined) {
|
|
147
|
+
return {
|
|
148
|
+
outcome: 'UNDETERMINED',
|
|
149
|
+
table,
|
|
150
|
+
key,
|
|
151
|
+
hitPolicy: policy,
|
|
152
|
+
rows: matched,
|
|
153
|
+
value: undetermined,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const limit = version.document.collectLimit;
|
|
157
|
+
if (limit !== undefined && hits.length > limit) {
|
|
158
|
+
refuseTable(version.document.tableId, `table ${version.document.tableId} matched ${String(hits.length)} rows, beyond its collectLimit of ${String(limit)}`);
|
|
159
|
+
}
|
|
160
|
+
return hits.length === 0
|
|
161
|
+
? { outcome: 'MISS', table, key, hitPolicy: policy }
|
|
162
|
+
: { outcome: 'HIT', table, key, hitPolicy: policy, rows: hits };
|
|
163
|
+
}
|
|
164
|
+
case 'UNIQUE':
|
|
165
|
+
case 'FIRST': {
|
|
166
|
+
// `FIRST` is the first row that matches, not the first row present: a `FAIL` row is a
|
|
167
|
+
// non-match and the scan passes over it. An
|
|
168
|
+
// undetermined row stops the scan rather than being skipped, because promoting a later,
|
|
169
|
+
// weaker row would silently turn "cannot decide" into a decision.
|
|
170
|
+
//
|
|
171
|
+
// A `UNIQUE` table has at most one row per key — the installer refuses a second
|
|
172
|
+
// (`DATA-1.2.5`) — so this same scan can never see a second match under it. A resolution
|
|
173
|
+
// a caller hands in with two matches is refused where it is applied, not here: the
|
|
174
|
+
// resolver applies the rows a store gives it, and only the consumer can see a store's
|
|
175
|
+
// malformed answer as one.
|
|
176
|
+
for (const row of rows) {
|
|
177
|
+
const outcome = row.outcome ?? 'PASS';
|
|
178
|
+
switch (outcome) {
|
|
179
|
+
case 'PASS':
|
|
180
|
+
return { outcome: 'HIT', table, key, hitPolicy: policy, rows: [row] };
|
|
181
|
+
case 'FAIL':
|
|
182
|
+
break;
|
|
183
|
+
case 'UNKNOWN':
|
|
184
|
+
case 'DEFERRED':
|
|
185
|
+
return {
|
|
186
|
+
outcome: 'UNDETERMINED',
|
|
187
|
+
table,
|
|
188
|
+
key,
|
|
189
|
+
hitPolicy: policy,
|
|
190
|
+
rows: [row],
|
|
191
|
+
value: outcome,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return { outcome: 'MISS', table, key, hitPolicy: policy };
|
|
196
|
+
}
|
|
197
|
+
default:
|
|
198
|
+
return assertNever(policy);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/lookup/resolve.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,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AC;oBAChB,KAAK,MAAM;wBACT,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;oBACxE,KAAK,MAAM;wBACT,MAAM;oBACR,KAAK,SAAS,CAAC;oBACf,KAAK,UAAU;wBACb,OAAO;4BACL,OAAO,EAAE,cAAc;4BACvB,KAAK;4BACL,GAAG;4BACH,SAAS,EAAE,MAAM;4BACjB,IAAI,EAAE,CAAC,GAAG,CAAC;4BACX,KAAK,EAAE,OAAO;yBACf,CAAC;gBACN,CAAC;YACH,CAAC;YACD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;QAC5D,CAAC;QACD;YACE,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC","sourcesContent":["import type {\n LookupResolution,\n LookupRow,\n ScalarWireValue,\n SetResolution,\n WireRecord,\n} from '../model/types.js';\nimport { assertNever } from '../model/errors.js';\nimport { isScalarWireValue } from '../model/values.js';\nimport type { PreparedTable, PreparedVersion } from './install.js';\nimport { canonicalKey, dateToDay, refuseTable } from './install.js';\nimport { resolvedTable } from './provenance.js';\nimport { selectVersion, selectWindow } from './readiness.js';\n\n/**\n * The resolution algorithms behind `MemoryLookupStore`: set membership for every kind of\n * set, composite-key lookup, and decision-row selection. They read a prepared catalog and\n * never hold one, so the store owns the only copy of the installed versions.\n */\nexport function containsMember(\n tables: ReadonlyMap<string, PreparedTable>,\n tableId: string,\n value: ScalarWireValue,\n recordDate?: string,\n): SetResolution {\n const table = tables.get(tableId);\n if (table === undefined) return { outcome: 'STALE', reason: 'missing_table', tableId };\n const version = table.versions[0];\n if (version === undefined) return { outcome: 'STALE', reason: 'missing_table', tableId };\n const members = version.members;\n if (members === undefined) {\n refuseTable(tableId, `table ${tableId} is a ${version.document.kind}, not a set`);\n }\n const key: readonly ScalarWireValue[] = [value];\n // The membership index is keyed by the value's canonical text; the provenance key is\n // the same value as the one-entry key vector a keyed table would record.\n const query = canonicalKey(value, `in_set(${tableId})`);\n // A behavior table takes no date from anyone: membership is the same\n // for every day, so a supplied record date is ignored rather than made a refusal.\n if (version.document.binding === 'behavior') {\n return {\n outcome: members.has(query) ? 'MEMBER' : 'ABSENT',\n table: resolvedTable(version, undefined),\n key,\n };\n }\n // A data-bound set resolves against a supplied date and nothing else.\n // The evaluation decides which date that is — an `asOf` the call names, or the host's\n // record date — so an as-of-less call answers only when the host supplied its own.\n if (recordDate === undefined) {\n return { outcome: 'STALE', reason: 'missing_as_of', tableId };\n }\n const selected = selectWindow(table.versions, dateToDay(recordDate, tableId));\n if (selected === undefined) return { outcome: 'STALE', reason: 'out_of_range', tableId };\n const selectedMembers = selected.members;\n if (selectedMembers === undefined) {\n refuseTable(tableId, `table ${tableId} is a ${selected.document.kind}, not a set`);\n }\n return {\n outcome: selectedMembers.has(query) ? 'MEMBER' : 'ABSENT',\n table: resolvedTable(selected, recordDate),\n key,\n };\n}\n\n/** `lookup(table, keys, asOf?)`: one keyed call against a lookup table. */\nexport function resolveKeyed(\n tables: ReadonlyMap<string, PreparedTable>,\n tableId: string,\n keys: readonly ScalarWireValue[],\n asOf?: string,\n): LookupResolution {\n return byKey(tables, tableId, 'lookup', keys, asOf);\n}\n\n/**\n * `decide(table, inputs, asOf?)`: a decision row matches when every key\n * column's input equals the row's key entry in the same domain. The key is assembled in\n * column order and resolved through the same index a lookup uses, so a decision table is\n * one map hit whatever its row count — the policy is applied to the rows sharing the key.\n */\nexport function decideInputs(\n tables: ReadonlyMap<string, PreparedTable>,\n tableId: string,\n inputs: WireRecord,\n asOf?: string,\n): LookupResolution {\n const version = selectVersion(tables, tableId, 'decision_table', asOf);\n if ('outcome' in version) return version;\n const key: ScalarWireValue[] = [];\n for (const column of version.keyColumns) {\n // An own member, never an inherited one: a column id is a name the caller may have chosen,\n // and `constructor` is one an artifact may declare. Reading it through the prototype chain\n // would answer `Object.prototype.constructor` for a record that carries nothing.\n const supplied = Object.hasOwn(inputs, column.columnId) ? inputs[column.columnId] : undefined;\n // An input the record does not carry — or carries as an empty or non-scalar value —\n // cannot rule any row out, so nothing can be decided, and never a match found by\n // skipping it. No query was formed, so the\n // resolution names no key: a partial key would describe a lookup nobody made.\n if (supplied === undefined || !isScalarWireValue(supplied)) {\n return { outcome: 'UNDETERMINED', value: 'UNKNOWN' };\n }\n key.push(supplied);\n }\n return match(version, key, asOf);\n}\n\n/**\n * `decide_keys(table, keys, asOf?)`: the key vector a decision table is\n * probed with, in declaration order. The language has no record literal, so a caller that\n * holds the key values can name them directly instead of fabricating an input record.\n */\nexport function decideKeyVector(\n tables: ReadonlyMap<string, PreparedTable>,\n tableId: string,\n keys: readonly ScalarWireValue[],\n asOf?: string,\n): LookupResolution {\n return byKey(tables, tableId, 'decision_table', keys, asOf);\n}\n\n/**\n * The rows sharing one canonical key, and the policy applied to them.\n * The key is indexed by canonical text, so a resolution is one map hit whatever the\n * table's size.\n */\nfunction match(\n version: PreparedVersion,\n keys: readonly ScalarWireValue[],\n asOf: string | undefined,\n): LookupResolution {\n const rows = version.rowsByKey.get(canonicalKey(keys, version.document.tableId)) ?? [];\n return applyPolicy(version, rows, asOf, keys);\n}\n\n/** One keyed call against a table of the expected kind. */\nfunction byKey(\n tables: ReadonlyMap<string, PreparedTable>,\n tableId: string,\n expectedKind: 'lookup' | 'decision_table',\n keys: readonly ScalarWireValue[],\n asOf: string | undefined,\n): LookupResolution {\n const version = selectVersion(tables, tableId, expectedKind, asOf);\n if ('outcome' in version) return version;\n if (keys.length !== version.keyColumns.length) {\n refuseTable(\n tableId,\n `table ${tableId} takes ${String(version.keyColumns.length)} key values but received ${String(keys.length)}`,\n );\n }\n return match(version, keys, asOf);\n}\n\n/**\n * The hit policy applied to the rows that share one key.\n *\n * A row's declared outcome decides what it contributes: `PASS` is a hit, `FAIL` is a\n * non-matching row a `FIRST` scan passes over, and an undetermined row makes the answer\n * undetermined rather than skipped. A `UNIQUE` key matches at most one row — the installer\n * refuses a second (`DATA-1.2.5`) — so its answer is that row's own outcome. The order-independent\n * fold is `COLLECT`'s: `UNKNOWN` beats `DEFERRED` whichever order the rows are declared in, and a\n * collection is never returned partially (`DATA-3.1.2`, `DATA-3.1.4`). A resolution that could not\n * decide still states the rows whose key matched, so the report records the match it observed\n * (`DATA-4.1.1`).\n */\nfunction applyPolicy(\n version: PreparedVersion,\n rows: readonly LookupRow[],\n asOf: string | undefined,\n key: readonly ScalarWireValue[],\n): LookupResolution {\n const table = resolvedTable(version, asOf);\n const policy = version.hitPolicy;\n switch (policy) {\n case 'COLLECT': {\n const hits: LookupRow[] = [];\n const matched: LookupRow[] = [];\n let undetermined: 'UNKNOWN' | 'DEFERRED' | undefined;\n for (const row of rows) {\n const outcome = row.outcome ?? 'PASS';\n if (outcome === 'FAIL') continue;\n matched.push(row);\n if (outcome === 'PASS') {\n hits.push(row);\n continue;\n }\n if (outcome === 'UNKNOWN') undetermined = 'UNKNOWN';\n else undetermined ??= 'DEFERRED';\n }\n if (undetermined !== undefined) {\n return {\n outcome: 'UNDETERMINED',\n table,\n key,\n hitPolicy: policy,\n rows: matched,\n value: undetermined,\n };\n }\n const limit = version.document.collectLimit;\n if (limit !== undefined && hits.length > limit) {\n refuseTable(\n version.document.tableId,\n `table ${version.document.tableId} matched ${String(hits.length)} rows, beyond its collectLimit of ${String(limit)}`,\n );\n }\n return hits.length === 0\n ? { outcome: 'MISS', table, key, hitPolicy: policy }\n : { outcome: 'HIT', table, key, hitPolicy: policy, rows: hits };\n }\n case 'UNIQUE':\n case 'FIRST': {\n // `FIRST` is the first row that matches, not the first row present: a `FAIL` row is a\n // non-match and the scan passes over it. An\n // undetermined row stops the scan rather than being skipped, because promoting a later,\n // weaker row would silently turn \"cannot decide\" into a decision.\n //\n // A `UNIQUE` table has at most one row per key — the installer refuses a second\n // (`DATA-1.2.5`) — so this same scan can never see a second match under it. A resolution\n // a caller hands in with two matches is refused where it is applied, not here: the\n // resolver applies the rows a store gives it, and only the consumer can see a store's\n // malformed answer as one.\n for (const row of rows) {\n const outcome = row.outcome ?? 'PASS';\n switch (outcome) {\n case 'PASS':\n return { outcome: 'HIT', table, key, hitPolicy: policy, rows: [row] };\n case 'FAIL':\n break;\n case 'UNKNOWN':\n case 'DEFERRED':\n return {\n outcome: 'UNDETERMINED',\n table,\n key,\n hitPolicy: policy,\n rows: [row],\n value: outcome,\n };\n }\n }\n return { outcome: 'MISS', table, key, hitPolicy: policy };\n }\n default:\n return assertNever(policy);\n }\n}\n"]}
|