@azx-pbc/axiom-runtime 0.0.0-stage → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +714 -2
- package/dist/cache/index.d.ts +191 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +361 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/canonical/jcs.d.ts +78 -0
- package/dist/canonical/jcs.d.ts.map +1 -0
- package/dist/canonical/jcs.js +500 -0
- package/dist/canonical/jcs.js.map +1 -0
- package/dist/canonical/restricted-json.d.ts +7 -0
- package/dist/canonical/restricted-json.d.ts.map +1 -0
- package/dist/canonical/restricted-json.js +318 -0
- package/dist/canonical/restricted-json.js.map +1 -0
- package/dist/canonical/restricted-value.d.ts +59 -0
- package/dist/canonical/restricted-value.d.ts.map +1 -0
- package/dist/canonical/restricted-value.js +156 -0
- package/dist/canonical/restricted-value.js.map +1 -0
- package/dist/canonical/restricted.d.ts +85 -0
- package/dist/canonical/restricted.d.ts.map +1 -0
- package/dist/canonical/restricted.js +163 -0
- package/dist/canonical/restricted.js.map +1 -0
- package/dist/canonical/signature.d.ts +38 -0
- package/dist/canonical/signature.d.ts.map +1 -0
- package/dist/canonical/signature.js +47 -0
- package/dist/canonical/signature.js.map +1 -0
- package/dist/eval/access/delivery.d.ts +63 -0
- package/dist/eval/access/delivery.d.ts.map +1 -0
- package/dist/eval/access/delivery.js +98 -0
- package/dist/eval/access/delivery.js.map +1 -0
- package/dist/eval/access/overlay.d.ts +72 -0
- package/dist/eval/access/overlay.d.ts.map +1 -0
- package/dist/eval/access/overlay.js +402 -0
- package/dist/eval/access/overlay.js.map +1 -0
- package/dist/eval/access/projection.d.ts +159 -0
- package/dist/eval/access/projection.d.ts.map +1 -0
- package/dist/eval/access/projection.js +211 -0
- package/dist/eval/access/projection.js.map +1 -0
- package/dist/eval/access/window.d.ts +128 -0
- package/dist/eval/access/window.d.ts.map +1 -0
- package/dist/eval/access/window.js +254 -0
- package/dist/eval/access/window.js.map +1 -0
- package/dist/eval/access/write.d.ts +113 -0
- package/dist/eval/access/write.d.ts.map +1 -0
- package/dist/eval/access/write.js +119 -0
- package/dist/eval/access/write.js.map +1 -0
- package/dist/eval/addressing.d.ts +131 -0
- package/dist/eval/addressing.d.ts.map +1 -0
- package/dist/eval/addressing.js +270 -0
- package/dist/eval/addressing.js.map +1 -0
- package/dist/eval/budget.d.ts +143 -0
- package/dist/eval/budget.d.ts.map +1 -0
- package/dist/eval/budget.js +387 -0
- package/dist/eval/budget.js.map +1 -0
- package/dist/eval/computed.d.ts +46 -0
- package/dist/eval/computed.d.ts.map +1 -0
- package/dist/eval/computed.js +89 -0
- package/dist/eval/computed.js.map +1 -0
- package/dist/eval/denials.d.ts +64 -0
- package/dist/eval/denials.d.ts.map +1 -0
- package/dist/eval/denials.js +87 -0
- package/dist/eval/denials.js.map +1 -0
- package/dist/eval/engine/cancellation.d.ts +12 -0
- package/dist/eval/engine/cancellation.d.ts.map +1 -0
- package/dist/eval/engine/cancellation.js +56 -0
- package/dist/eval/engine/cancellation.js.map +1 -0
- package/dist/eval/engine/delta.d.ts +104 -0
- package/dist/eval/engine/delta.d.ts.map +1 -0
- package/dist/eval/engine/delta.js +466 -0
- package/dist/eval/engine/delta.js.map +1 -0
- package/dist/eval/engine/deps.d.ts +136 -0
- package/dist/eval/engine/deps.d.ts.map +1 -0
- package/dist/eval/engine/deps.js +345 -0
- package/dist/eval/engine/deps.js.map +1 -0
- package/dist/eval/engine/identity.d.ts +128 -0
- package/dist/eval/engine/identity.d.ts.map +1 -0
- package/dist/eval/engine/identity.js +398 -0
- package/dist/eval/engine/identity.js.map +1 -0
- package/dist/eval/engine/index.d.ts +200 -0
- package/dist/eval/engine/index.d.ts.map +1 -0
- package/dist/eval/engine/index.js +1242 -0
- package/dist/eval/engine/index.js.map +1 -0
- package/dist/eval/engine/measurement.d.ts +23 -0
- package/dist/eval/engine/measurement.d.ts.map +1 -0
- package/dist/eval/engine/measurement.js +42 -0
- package/dist/eval/engine/measurement.js.map +1 -0
- package/dist/eval/engine/naive.d.ts +19 -0
- package/dist/eval/engine/naive.d.ts.map +1 -0
- package/dist/eval/engine/naive.js +59 -0
- package/dist/eval/engine/naive.js.map +1 -0
- package/dist/eval/engine/ops.d.ts +214 -0
- package/dist/eval/engine/ops.d.ts.map +1 -0
- package/dist/eval/engine/ops.js +1422 -0
- package/dist/eval/engine/ops.js.map +1 -0
- package/dist/eval/engine/patches.d.ts +40 -0
- package/dist/eval/engine/patches.d.ts.map +1 -0
- package/dist/eval/engine/patches.js +125 -0
- package/dist/eval/engine/patches.js.map +1 -0
- package/dist/eval/engine/ports.d.ts +71 -0
- package/dist/eval/engine/ports.d.ts.map +1 -0
- package/dist/eval/engine/ports.js +2 -0
- package/dist/eval/engine/ports.js.map +1 -0
- package/dist/eval/engine/session.d.ts +116 -0
- package/dist/eval/engine/session.d.ts.map +1 -0
- package/dist/eval/engine/session.js +653 -0
- package/dist/eval/engine/session.js.map +1 -0
- package/dist/eval/engine/snapshot.d.ts +97 -0
- package/dist/eval/engine/snapshot.d.ts.map +1 -0
- package/dist/eval/engine/snapshot.js +221 -0
- package/dist/eval/engine/snapshot.js.map +1 -0
- package/dist/eval/engine/subscriptions.d.ts +47 -0
- package/dist/eval/engine/subscriptions.d.ts.map +1 -0
- package/dist/eval/engine/subscriptions.js +103 -0
- package/dist/eval/engine/subscriptions.js.map +1 -0
- package/dist/eval/engine/trace.d.ts +77 -0
- package/dist/eval/engine/trace.d.ts.map +1 -0
- package/dist/eval/engine/trace.js +140 -0
- package/dist/eval/engine/trace.js.map +1 -0
- package/dist/eval/error-diagnostic.d.ts +26 -0
- package/dist/eval/error-diagnostic.d.ts.map +1 -0
- package/dist/eval/error-diagnostic.js +63 -0
- package/dist/eval/error-diagnostic.js.map +1 -0
- package/dist/eval/evaluate-expr.d.ts +44 -0
- package/dist/eval/evaluate-expr.d.ts.map +1 -0
- package/dist/eval/evaluate-expr.js +149 -0
- package/dist/eval/evaluate-expr.js.map +1 -0
- package/dist/eval/evaluate.d.ts +282 -0
- package/dist/eval/evaluate.d.ts.map +1 -0
- package/dist/eval/evaluate.js +391 -0
- package/dist/eval/evaluate.js.map +1 -0
- package/dist/eval/evolution/relocate.d.ts +72 -0
- package/dist/eval/evolution/relocate.d.ts.map +1 -0
- package/dist/eval/evolution/relocate.js +427 -0
- package/dist/eval/evolution/relocate.js.map +1 -0
- package/dist/eval/evolution/select.d.ts +11 -0
- package/dist/eval/evolution/select.d.ts.map +1 -0
- package/dist/eval/evolution/select.js +53 -0
- package/dist/eval/evolution/select.js.map +1 -0
- package/dist/eval/evolution/upcast.d.ts +13 -0
- package/dist/eval/evolution/upcast.d.ts.map +1 -0
- package/dist/eval/evolution/upcast.js +88 -0
- package/dist/eval/evolution/upcast.js.map +1 -0
- package/dist/eval/expr/aggregates.d.ts +75 -0
- package/dist/eval/expr/aggregates.d.ts.map +1 -0
- package/dist/eval/expr/aggregates.js +991 -0
- package/dist/eval/expr/aggregates.js.map +1 -0
- package/dist/eval/expr/arithmetic.d.ts +26 -0
- package/dist/eval/expr/arithmetic.d.ts.map +1 -0
- package/dist/eval/expr/arithmetic.js +387 -0
- package/dist/eval/expr/arithmetic.js.map +1 -0
- package/dist/eval/expr/between.d.ts +17 -0
- package/dist/eval/expr/between.d.ts.map +1 -0
- package/dist/eval/expr/between.js +46 -0
- package/dist/eval/expr/between.js.map +1 -0
- package/dist/eval/expr/binder.d.ts +96 -0
- package/dist/eval/expr/binder.d.ts.map +1 -0
- package/dist/eval/expr/binder.js +253 -0
- package/dist/eval/expr/binder.js.map +1 -0
- package/dist/eval/expr/call-dispatch.d.ts +28 -0
- package/dist/eval/expr/call-dispatch.d.ts.map +1 -0
- package/dist/eval/expr/call-dispatch.js +114 -0
- package/dist/eval/expr/call-dispatch.js.map +1 -0
- package/dist/eval/expr/collections.d.ts +20 -0
- package/dist/eval/expr/collections.d.ts.map +1 -0
- package/dist/eval/expr/collections.js +66 -0
- package/dist/eval/expr/collections.js.map +1 -0
- package/dist/eval/expr/compare.d.ts +36 -0
- package/dist/eval/expr/compare.d.ts.map +1 -0
- package/dist/eval/expr/compare.js +115 -0
- package/dist/eval/expr/compare.js.map +1 -0
- package/dist/eval/expr/datasets.d.ts +28 -0
- package/dist/eval/expr/datasets.d.ts.map +1 -0
- package/dist/eval/expr/datasets.js +304 -0
- package/dist/eval/expr/datasets.js.map +1 -0
- package/dist/eval/expr/digest.d.ts +23 -0
- package/dist/eval/expr/digest.d.ts.map +1 -0
- package/dist/eval/expr/digest.js +89 -0
- package/dist/eval/expr/digest.js.map +1 -0
- package/dist/eval/expr/domains.d.ts +19 -0
- package/dist/eval/expr/domains.d.ts.map +1 -0
- package/dist/eval/expr/domains.js +18 -0
- package/dist/eval/expr/domains.js.map +1 -0
- package/dist/eval/expr/host.d.ts +152 -0
- package/dist/eval/expr/host.d.ts.map +1 -0
- package/dist/eval/expr/host.js +36 -0
- package/dist/eval/expr/host.js.map +1 -0
- package/dist/eval/expr/lists.d.ts +24 -0
- package/dist/eval/expr/lists.d.ts.map +1 -0
- package/dist/eval/expr/lists.js +155 -0
- package/dist/eval/expr/lists.js.map +1 -0
- package/dist/eval/expr/member.d.ts +15 -0
- package/dist/eval/expr/member.d.ts.map +1 -0
- package/dist/eval/expr/member.js +32 -0
- package/dist/eval/expr/member.js.map +1 -0
- package/dist/eval/expr/money-ops.d.ts +10 -0
- package/dist/eval/expr/money-ops.d.ts.map +1 -0
- package/dist/eval/expr/money-ops.js +17 -0
- package/dist/eval/expr/money-ops.js.map +1 -0
- package/dist/eval/expr/operands.d.ts +27 -0
- package/dist/eval/expr/operands.d.ts.map +1 -0
- package/dist/eval/expr/operands.js +167 -0
- package/dist/eval/expr/operands.js.map +1 -0
- package/dist/eval/expr/presence.d.ts +27 -0
- package/dist/eval/expr/presence.d.ts.map +1 -0
- package/dist/eval/expr/presence.js +140 -0
- package/dist/eval/expr/presence.js.map +1 -0
- package/dist/eval/expr/records.d.ts +22 -0
- package/dist/eval/expr/records.d.ts.map +1 -0
- package/dist/eval/expr/records.js +101 -0
- package/dist/eval/expr/records.js.map +1 -0
- package/dist/eval/expr/rule-refs.d.ts +25 -0
- package/dist/eval/expr/rule-refs.d.ts.map +1 -0
- package/dist/eval/expr/rule-refs.js +60 -0
- package/dist/eval/expr/rule-refs.js.map +1 -0
- package/dist/eval/expr/sequences.d.ts +26 -0
- package/dist/eval/expr/sequences.d.ts.map +1 -0
- package/dist/eval/expr/sequences.js +151 -0
- package/dist/eval/expr/sequences.js.map +1 -0
- package/dist/eval/expr/value.d.ts +99 -0
- package/dist/eval/expr/value.d.ts.map +1 -0
- package/dist/eval/expr/value.js +14 -0
- package/dist/eval/expr/value.js.map +1 -0
- package/dist/eval/expression.d.ts +142 -0
- package/dist/eval/expression.d.ts.map +1 -0
- package/dist/eval/expression.js +446 -0
- package/dist/eval/expression.js.map +1 -0
- package/dist/eval/firing.d.ts +68 -0
- package/dist/eval/firing.d.ts.map +1 -0
- package/dist/eval/firing.js +222 -0
- package/dist/eval/firing.js.map +1 -0
- package/dist/eval/gate.d.ts +110 -0
- package/dist/eval/gate.d.ts.map +1 -0
- package/dist/eval/gate.js +278 -0
- package/dist/eval/gate.js.map +1 -0
- package/dist/eval/layout-visibility.d.ts +18 -0
- package/dist/eval/layout-visibility.d.ts.map +1 -0
- package/dist/eval/layout-visibility.js +61 -0
- package/dist/eval/layout-visibility.js.map +1 -0
- package/dist/eval/option-availability.d.ts +26 -0
- package/dist/eval/option-availability.d.ts.map +1 -0
- package/dist/eval/option-availability.js +580 -0
- package/dist/eval/option-availability.js.map +1 -0
- package/dist/eval/options-boundary.d.ts +15 -0
- package/dist/eval/options-boundary.d.ts.map +1 -0
- package/dist/eval/options-boundary.js +40 -0
- package/dist/eval/options-boundary.js.map +1 -0
- package/dist/eval/options.d.ts +99 -0
- package/dist/eval/options.d.ts.map +1 -0
- package/dist/eval/options.js +96 -0
- package/dist/eval/options.js.map +1 -0
- package/dist/eval/overrides.d.ts +116 -0
- package/dist/eval/overrides.d.ts.map +1 -0
- package/dist/eval/overrides.js +176 -0
- package/dist/eval/overrides.js.map +1 -0
- package/dist/eval/paths.d.ts +25 -0
- package/dist/eval/paths.d.ts.map +1 -0
- package/dist/eval/paths.js +47 -0
- package/dist/eval/paths.js.map +1 -0
- package/dist/eval/presentation-reads.d.ts +20 -0
- package/dist/eval/presentation-reads.d.ts.map +1 -0
- package/dist/eval/presentation-reads.js +2 -0
- package/dist/eval/presentation-reads.js.map +1 -0
- package/dist/eval/presentation.d.ts +122 -0
- package/dist/eval/presentation.d.ts.map +1 -0
- package/dist/eval/presentation.js +255 -0
- package/dist/eval/presentation.js.map +1 -0
- package/dist/eval/reader/context-value.d.ts +41 -0
- package/dist/eval/reader/context-value.d.ts.map +1 -0
- package/dist/eval/reader/context-value.js +129 -0
- package/dist/eval/reader/context-value.js.map +1 -0
- package/dist/eval/reader/covered.d.ts +53 -0
- package/dist/eval/reader/covered.d.ts.map +1 -0
- package/dist/eval/reader/covered.js +139 -0
- package/dist/eval/reader/covered.js.map +1 -0
- package/dist/eval/reader/declarations.d.ts +182 -0
- package/dist/eval/reader/declarations.d.ts.map +1 -0
- package/dist/eval/reader/declarations.js +153 -0
- package/dist/eval/reader/declarations.js.map +1 -0
- package/dist/eval/reader/member-access.d.ts +87 -0
- package/dist/eval/reader/member-access.d.ts.map +1 -0
- package/dist/eval/reader/member-access.js +212 -0
- package/dist/eval/reader/member-access.js.map +1 -0
- package/dist/eval/reader/memo.d.ts +34 -0
- package/dist/eval/reader/memo.d.ts.map +1 -0
- package/dist/eval/reader/memo.js +67 -0
- package/dist/eval/reader/memo.js.map +1 -0
- package/dist/eval/reader/overlay.d.ts +74 -0
- package/dist/eval/reader/overlay.d.ts.map +1 -0
- package/dist/eval/reader/overlay.js +365 -0
- package/dist/eval/reader/overlay.js.map +1 -0
- package/dist/eval/reader/questions.d.ts +37 -0
- package/dist/eval/reader/questions.d.ts.map +1 -0
- package/dist/eval/reader/questions.js +78 -0
- package/dist/eval/reader/questions.js.map +1 -0
- package/dist/eval/reader/resolve.d.ts +84 -0
- package/dist/eval/reader/resolve.d.ts.map +1 -0
- package/dist/eval/reader/resolve.js +310 -0
- package/dist/eval/reader/resolve.js.map +1 -0
- package/dist/eval/reader/value-read.d.ts +50 -0
- package/dist/eval/reader/value-read.d.ts.map +1 -0
- package/dist/eval/reader/value-read.js +133 -0
- package/dist/eval/reader/value-read.js.map +1 -0
- package/dist/eval/reader/withheld.d.ts +48 -0
- package/dist/eval/reader/withheld.d.ts.map +1 -0
- package/dist/eval/reader/withheld.js +108 -0
- package/dist/eval/reader/withheld.js.map +1 -0
- package/dist/eval/reader-paths.d.ts +24 -0
- package/dist/eval/reader-paths.d.ts.map +1 -0
- package/dist/eval/reader-paths.js +23 -0
- package/dist/eval/reader-paths.js.map +1 -0
- package/dist/eval/reader.d.ts +281 -0
- package/dist/eval/reader.d.ts.map +1 -0
- package/dist/eval/reader.js +560 -0
- package/dist/eval/reader.js.map +1 -0
- package/dist/eval/receipt.d.ts +37 -0
- package/dist/eval/receipt.d.ts.map +1 -0
- package/dist/eval/receipt.js +222 -0
- package/dist/eval/receipt.js.map +1 -0
- package/dist/eval/report/assemble.d.ts +84 -0
- package/dist/eval/report/assemble.d.ts.map +1 -0
- package/dist/eval/report/assemble.js +277 -0
- package/dist/eval/report/assemble.js.map +1 -0
- package/dist/eval/report/fold.d.ts +18 -0
- package/dist/eval/report/fold.d.ts.map +1 -0
- package/dist/eval/report/fold.js +58 -0
- package/dist/eval/report/fold.js.map +1 -0
- package/dist/eval/rule/alternatives.d.ts +23 -0
- package/dist/eval/rule/alternatives.d.ts.map +1 -0
- package/dist/eval/rule/alternatives.js +46 -0
- package/dist/eval/rule/alternatives.js.map +1 -0
- package/dist/eval/rule/behaviour.d.ts +47 -0
- package/dist/eval/rule/behaviour.d.ts.map +1 -0
- package/dist/eval/rule/behaviour.js +249 -0
- package/dist/eval/rule/behaviour.js.map +1 -0
- package/dist/eval/rule/compute.d.ts +46 -0
- package/dist/eval/rule/compute.d.ts.map +1 -0
- package/dist/eval/rule/compute.js +158 -0
- package/dist/eval/rule/compute.js.map +1 -0
- package/dist/eval/rule/create-state.d.ts +42 -0
- package/dist/eval/rule/create-state.d.ts.map +1 -0
- package/dist/eval/rule/create-state.js +134 -0
- package/dist/eval/rule/create-state.js.map +1 -0
- package/dist/eval/rule/diagnostics.d.ts +24 -0
- package/dist/eval/rule/diagnostics.d.ts.map +1 -0
- package/dist/eval/rule/diagnostics.js +45 -0
- package/dist/eval/rule/diagnostics.js.map +1 -0
- package/dist/eval/rule/execution.d.ts +24 -0
- package/dist/eval/rule/execution.d.ts.map +1 -0
- package/dist/eval/rule/execution.js +495 -0
- package/dist/eval/rule/execution.js.map +1 -0
- package/dist/eval/rule/gate.d.ts +12 -0
- package/dist/eval/rule/gate.d.ts.map +1 -0
- package/dist/eval/rule/gate.js +34 -0
- package/dist/eval/rule/gate.js.map +1 -0
- package/dist/eval/rule/item.d.ts +11 -0
- package/dist/eval/rule/item.d.ts.map +1 -0
- package/dist/eval/rule/item.js +265 -0
- package/dist/eval/rule/item.js.map +1 -0
- package/dist/eval/rule/prepare.d.ts +64 -0
- package/dist/eval/rule/prepare.d.ts.map +1 -0
- package/dist/eval/rule/prepare.js +131 -0
- package/dist/eval/rule/prepare.js.map +1 -0
- package/dist/eval/rule/result.d.ts +97 -0
- package/dist/eval/rule/result.d.ts.map +1 -0
- package/dist/eval/rule/result.js +347 -0
- package/dist/eval/rule/result.js.map +1 -0
- package/dist/eval/rule/runner.d.ts +128 -0
- package/dist/eval/rule/runner.d.ts.map +1 -0
- package/dist/eval/rule/runner.js +296 -0
- package/dist/eval/rule/runner.js.map +1 -0
- package/dist/eval/rule/screen.d.ts +32 -0
- package/dist/eval/rule/screen.d.ts.map +1 -0
- package/dist/eval/rule/screen.js +73 -0
- package/dist/eval/rule/screen.js.map +1 -0
- package/dist/eval/rule/state.d.ts +137 -0
- package/dist/eval/rule/state.d.ts.map +1 -0
- package/dist/eval/rule/state.js +2 -0
- package/dist/eval/rule/state.js.map +1 -0
- package/dist/eval/rule/steps.d.ts +44 -0
- package/dist/eval/rule/steps.d.ts.map +1 -0
- package/dist/eval/rule/steps.js +367 -0
- package/dist/eval/rule/steps.js.map +1 -0
- package/dist/eval/rule/visibility.d.ts +18 -0
- package/dist/eval/rule/visibility.d.ts.map +1 -0
- package/dist/eval/rule/visibility.js +79 -0
- package/dist/eval/rule/visibility.js.map +1 -0
- package/dist/eval/seal.d.ts +74 -0
- package/dist/eval/seal.d.ts.map +1 -0
- package/dist/eval/seal.js +154 -0
- package/dist/eval/seal.js.map +1 -0
- package/dist/eval/signature-coverage.d.ts +19 -0
- package/dist/eval/signature-coverage.d.ts.map +1 -0
- package/dist/eval/signature-coverage.js +160 -0
- package/dist/eval/signature-coverage.js.map +1 -0
- package/dist/eval/state/derive.d.ts +72 -0
- package/dist/eval/state/derive.d.ts.map +1 -0
- package/dist/eval/state/derive.js +61 -0
- package/dist/eval/state/derive.js.map +1 -0
- package/dist/eval/state/describe.d.ts +18 -0
- package/dist/eval/state/describe.d.ts.map +1 -0
- package/dist/eval/state/describe.js +19 -0
- package/dist/eval/state/describe.js.map +1 -0
- package/dist/eval/state/field-state.d.ts +471 -0
- package/dist/eval/state/field-state.d.ts.map +1 -0
- package/dist/eval/state/field-state.js +1604 -0
- package/dist/eval/state/field-state.js.map +1 -0
- package/dist/eval/state/measurement.d.ts +136 -0
- package/dist/eval/state/measurement.d.ts.map +1 -0
- package/dist/eval/state/measurement.js +209 -0
- package/dist/eval/state/measurement.js.map +1 -0
- package/dist/eval/state/options.d.ts +21 -0
- package/dist/eval/state/options.d.ts.map +1 -0
- package/dist/eval/state/options.js +3 -0
- package/dist/eval/state/options.js.map +1 -0
- package/dist/eval/state/readiness.d.ts +400 -0
- package/dist/eval/state/readiness.d.ts.map +1 -0
- package/dist/eval/state/readiness.js +1067 -0
- package/dist/eval/state/readiness.js.map +1 -0
- package/dist/eval/state/snapshot.d.ts +130 -0
- package/dist/eval/state/snapshot.d.ts.map +1 -0
- package/dist/eval/state/snapshot.js +35 -0
- package/dist/eval/state/snapshot.js.map +1 -0
- package/dist/eval/state/unavailable-options.d.ts +54 -0
- package/dist/eval/state/unavailable-options.d.ts.map +1 -0
- package/dist/eval/state/unavailable-options.js +82 -0
- package/dist/eval/state/unavailable-options.js.map +1 -0
- package/dist/eval/state/value-state.d.ts +38 -0
- package/dist/eval/state/value-state.d.ts.map +1 -0
- package/dist/eval/state/value-state.js +52 -0
- package/dist/eval/state/value-state.js.map +1 -0
- package/dist/eval/submission/admission.d.ts +50 -0
- package/dist/eval/submission/admission.d.ts.map +1 -0
- package/dist/eval/submission/admission.js +174 -0
- package/dist/eval/submission/admission.js.map +1 -0
- package/dist/eval/submission/authority.d.ts +71 -0
- package/dist/eval/submission/authority.d.ts.map +1 -0
- package/dist/eval/submission/authority.js +118 -0
- package/dist/eval/submission/authority.js.map +1 -0
- package/dist/eval/submission/datasets.d.ts +28 -0
- package/dist/eval/submission/datasets.d.ts.map +1 -0
- package/dist/eval/submission/datasets.js +109 -0
- package/dist/eval/submission/datasets.js.map +1 -0
- package/dist/eval/submission/index.d.ts +15 -0
- package/dist/eval/submission/index.d.ts.map +1 -0
- package/dist/eval/submission/index.js +13 -0
- package/dist/eval/submission/index.js.map +1 -0
- package/dist/eval/submission/refusals.d.ts +103 -0
- package/dist/eval/submission/refusals.d.ts.map +1 -0
- package/dist/eval/submission/refusals.js +15 -0
- package/dist/eval/submission/refusals.js.map +1 -0
- package/dist/eval/submission/signatures.d.ts +7 -0
- package/dist/eval/submission/signatures.d.ts.map +1 -0
- package/dist/eval/submission/signatures.js +215 -0
- package/dist/eval/submission/signatures.js.map +1 -0
- package/dist/eval/submission/writes.d.ts +51 -0
- package/dist/eval/submission/writes.d.ts.map +1 -0
- package/dist/eval/submission/writes.js +203 -0
- package/dist/eval/submission/writes.js.map +1 -0
- package/dist/eval/submission.d.ts +53 -0
- package/dist/eval/submission.d.ts.map +1 -0
- package/dist/eval/submission.js +521 -0
- package/dist/eval/submission.js.map +1 -0
- package/dist/eval/suggestions-to-engine.d.ts +18 -0
- package/dist/eval/suggestions-to-engine.d.ts.map +1 -0
- package/dist/eval/suggestions-to-engine.js +40 -0
- package/dist/eval/suggestions-to-engine.js.map +1 -0
- package/dist/eval/suggestions.d.ts +17 -0
- package/dist/eval/suggestions.d.ts.map +1 -0
- package/dist/eval/suggestions.js +314 -0
- package/dist/eval/suggestions.js.map +1 -0
- package/dist/eval/undecided.d.ts +64 -0
- package/dist/eval/undecided.d.ts.map +1 -0
- package/dist/eval/undecided.js +101 -0
- package/dist/eval/undecided.js.map +1 -0
- package/dist/eval/verdict.d.ts +66 -0
- package/dist/eval/verdict.d.ts.map +1 -0
- package/dist/eval/verdict.js +106 -0
- package/dist/eval/verdict.js.map +1 -0
- package/dist/eval/verify-signature.d.ts +78 -0
- package/dist/eval/verify-signature.d.ts.map +1 -0
- package/dist/eval/verify-signature.js +185 -0
- package/dist/eval/verify-signature.js.map +1 -0
- package/dist/eval/version-dispatch.d.ts +38 -0
- package/dist/eval/version-dispatch.d.ts.map +1 -0
- package/dist/eval/version-dispatch.js +61 -0
- package/dist/eval/version-dispatch.js.map +1 -0
- package/dist/eval/visibility.d.ts +33 -0
- package/dist/eval/visibility.d.ts.map +1 -0
- package/dist/eval/visibility.js +83 -0
- package/dist/eval/visibility.js.map +1 -0
- package/dist/evaluate.d.ts +24 -0
- package/dist/evaluate.d.ts.map +1 -0
- package/dist/evaluate.js +18 -0
- package/dist/evaluate.js.map +1 -0
- package/dist/expr/builtin-docs.d.ts +51 -0
- package/dist/expr/builtin-docs.d.ts.map +1 -0
- package/dist/expr/builtin-docs.js +874 -0
- package/dist/expr/builtin-docs.js.map +1 -0
- package/dist/expr/builtins.d.ts +50 -0
- package/dist/expr/builtins.d.ts.map +1 -0
- package/dist/expr/builtins.js +966 -0
- package/dist/expr/builtins.js.map +1 -0
- package/dist/expr/decimal-precision.d.ts +39 -0
- package/dist/expr/decimal-precision.d.ts.map +1 -0
- package/dist/expr/decimal-precision.js +62 -0
- package/dist/expr/decimal-precision.js.map +1 -0
- package/dist/expr/decimal.d.ts +172 -0
- package/dist/expr/decimal.d.ts.map +1 -0
- package/dist/expr/decimal.js +782 -0
- package/dist/expr/decimal.js.map +1 -0
- package/dist/expr/deprecations.d.ts +34 -0
- package/dist/expr/deprecations.d.ts.map +1 -0
- package/dist/expr/deprecations.js +17 -0
- package/dist/expr/deprecations.js.map +1 -0
- package/dist/expr/diagnostics.d.ts +21 -0
- package/dist/expr/diagnostics.d.ts.map +1 -0
- package/dist/expr/diagnostics.js +231 -0
- package/dist/expr/diagnostics.js.map +1 -0
- package/dist/expr/direction.d.ts +30 -0
- package/dist/expr/direction.d.ts.map +1 -0
- package/dist/expr/direction.js +77 -0
- package/dist/expr/direction.js.map +1 -0
- package/dist/expr/example-expression.d.ts +62 -0
- package/dist/expr/example-expression.d.ts.map +1 -0
- package/dist/expr/example-expression.js +670 -0
- package/dist/expr/example-expression.js.map +1 -0
- package/dist/expr/instant.d.ts +49 -0
- package/dist/expr/instant.d.ts.map +1 -0
- package/dist/expr/instant.js +111 -0
- package/dist/expr/instant.js.map +1 -0
- package/dist/expr/logic.d.ts +17 -0
- package/dist/expr/logic.d.ts.map +1 -0
- package/dist/expr/logic.js +65 -0
- package/dist/expr/logic.js.map +1 -0
- package/dist/expr/messages.d.ts +45 -0
- package/dist/expr/messages.d.ts.map +1 -0
- package/dist/expr/messages.js +280 -0
- package/dist/expr/messages.js.map +1 -0
- package/dist/expr/money.d.ts +38 -0
- package/dist/expr/money.d.ts.map +1 -0
- package/dist/expr/money.js +127 -0
- package/dist/expr/money.js.map +1 -0
- package/dist/expr/ordering.d.ts +56 -0
- package/dist/expr/ordering.d.ts.map +1 -0
- package/dist/expr/ordering.js +167 -0
- package/dist/expr/ordering.js.map +1 -0
- package/dist/expr/pattern.d.ts +44 -0
- package/dist/expr/pattern.d.ts.map +1 -0
- package/dist/expr/pattern.js +458 -0
- package/dist/expr/pattern.js.map +1 -0
- package/dist/expr/plain-date.d.ts +90 -0
- package/dist/expr/plain-date.d.ts.map +1 -0
- package/dist/expr/plain-date.js +230 -0
- package/dist/expr/plain-date.js.map +1 -0
- package/dist/expr/plural-categories.d.ts +8 -0
- package/dist/expr/plural-categories.d.ts.map +1 -0
- package/dist/expr/plural-categories.js +15 -0
- package/dist/expr/plural-categories.js.map +1 -0
- package/dist/expr/plural-keys.d.ts +39 -0
- package/dist/expr/plural-keys.d.ts.map +1 -0
- package/dist/expr/plural-keys.js +46 -0
- package/dist/expr/plural-keys.js.map +1 -0
- package/dist/expr/plural.d.ts +33 -0
- package/dist/expr/plural.d.ts.map +1 -0
- package/dist/expr/plural.js +50 -0
- package/dist/expr/plural.js.map +1 -0
- package/dist/expr/quantity.d.ts +31 -0
- package/dist/expr/quantity.d.ts.map +1 -0
- package/dist/expr/quantity.js +83 -0
- package/dist/expr/quantity.js.map +1 -0
- package/dist/expr/reduce.d.ts +50 -0
- package/dist/expr/reduce.d.ts.map +1 -0
- package/dist/expr/reduce.js +236 -0
- package/dist/expr/reduce.js.map +1 -0
- package/dist/expr/regex.d.ts +108 -0
- package/dist/expr/regex.d.ts.map +1 -0
- package/dist/expr/regex.js +1210 -0
- package/dist/expr/regex.js.map +1 -0
- package/dist/expr/select-locale.d.ts +67 -0
- package/dist/expr/select-locale.d.ts.map +1 -0
- package/dist/expr/select-locale.js +219 -0
- package/dist/expr/select-locale.js.map +1 -0
- package/dist/expr/sequences.d.ts +123 -0
- package/dist/expr/sequences.d.ts.map +1 -0
- package/dist/expr/sequences.js +234 -0
- package/dist/expr/sequences.js.map +1 -0
- package/dist/expr/strings.d.ts +50 -0
- package/dist/expr/strings.d.ts.map +1 -0
- package/dist/expr/strings.js +184 -0
- package/dist/expr/strings.js.map +1 -0
- package/dist/expr/validation.d.ts +32 -0
- package/dist/expr/validation.d.ts.map +1 -0
- package/dist/expr/validation.js +182 -0
- package/dist/expr/validation.js.map +1 -0
- package/dist/graph/freeze.d.ts +4 -0
- package/dist/graph/freeze.d.ts.map +1 -0
- package/dist/graph/freeze.js +52 -0
- package/dist/graph/freeze.js.map +1 -0
- package/dist/graph/index.d.ts +15 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +13 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/inspect.d.ts +76 -0
- package/dist/graph/inspect.d.ts.map +1 -0
- package/dist/graph/inspect.js +263 -0
- package/dist/graph/inspect.js.map +1 -0
- package/dist/graph/read-walk.d.ts +101 -0
- package/dist/graph/read-walk.d.ts.map +1 -0
- package/dist/graph/read-walk.js +358 -0
- package/dist/graph/read-walk.js.map +1 -0
- package/dist/graph/record-index.d.ts +24 -0
- package/dist/graph/record-index.d.ts.map +1 -0
- package/dist/graph/record-index.js +35 -0
- package/dist/graph/record-index.js.map +1 -0
- package/dist/index.d.ts +104 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +139 -0
- package/dist/index.js.map +1 -0
- package/dist/lookup/digest.d.ts +51 -0
- package/dist/lookup/digest.d.ts.map +1 -0
- package/dist/lookup/digest.js +46 -0
- package/dist/lookup/digest.js.map +1 -0
- package/dist/lookup/index.d.ts +28 -0
- package/dist/lookup/index.d.ts.map +1 -0
- package/dist/lookup/index.js +27 -0
- package/dist/lookup/index.js.map +1 -0
- package/dist/lookup/install.d.ts +48 -0
- package/dist/lookup/install.d.ts.map +1 -0
- package/dist/lookup/install.js +315 -0
- package/dist/lookup/install.js.map +1 -0
- package/dist/lookup/pass.d.ts +55 -0
- package/dist/lookup/pass.d.ts.map +1 -0
- package/dist/lookup/pass.js +212 -0
- package/dist/lookup/pass.js.map +1 -0
- package/dist/lookup/pins.d.ts +34 -0
- package/dist/lookup/pins.d.ts.map +1 -0
- package/dist/lookup/pins.js +39 -0
- package/dist/lookup/pins.js.map +1 -0
- package/dist/lookup/provenance.d.ts +23 -0
- package/dist/lookup/provenance.d.ts.map +1 -0
- package/dist/lookup/provenance.js +78 -0
- package/dist/lookup/provenance.js.map +1 -0
- package/dist/lookup/readiness.d.ts +13 -0
- package/dist/lookup/readiness.d.ts.map +1 -0
- package/dist/lookup/readiness.js +57 -0
- package/dist/lookup/readiness.js.map +1 -0
- package/dist/lookup/resolve.d.ts +24 -0
- package/dist/lookup/resolve.d.ts.map +1 -0
- package/dist/lookup/resolve.js +201 -0
- package/dist/lookup/resolve.js.map +1 -0
- package/dist/lookup/store.d.ts +41 -0
- package/dist/lookup/store.d.ts.map +1 -0
- package/dist/lookup/store.js +74 -0
- package/dist/lookup/store.js.map +1 -0
- package/dist/model/access.d.ts +200 -0
- package/dist/model/access.d.ts.map +1 -0
- package/dist/model/access.js +125 -0
- package/dist/model/access.js.map +1 -0
- package/dist/model/artifact-members.d.ts +3 -0
- package/dist/model/artifact-members.d.ts.map +1 -0
- package/dist/model/artifact-members.js +38 -0
- package/dist/model/artifact-members.js.map +1 -0
- package/dist/model/composition.d.ts +47 -0
- package/dist/model/composition.d.ts.map +1 -0
- package/dist/model/composition.js +66 -0
- package/dist/model/composition.js.map +1 -0
- package/dist/model/domain.d.ts +51 -0
- package/dist/model/domain.d.ts.map +1 -0
- package/dist/model/domain.js +75 -0
- package/dist/model/domain.js.map +1 -0
- package/dist/model/duration.d.ts +31 -0
- package/dist/model/duration.d.ts.map +1 -0
- package/dist/model/duration.js +136 -0
- package/dist/model/duration.js.map +1 -0
- package/dist/model/errors.d.ts +58 -0
- package/dist/model/errors.d.ts.map +1 -0
- package/dist/model/errors.js +81 -0
- package/dist/model/errors.js.map +1 -0
- package/dist/model/evolution.d.ts +177 -0
- package/dist/model/evolution.d.ts.map +1 -0
- package/dist/model/evolution.js +5 -0
- package/dist/model/evolution.js.map +1 -0
- package/dist/model/expr-children.d.ts +15 -0
- package/dist/model/expr-children.d.ts.map +1 -0
- package/dist/model/expr-children.js +45 -0
- package/dist/model/expr-children.js.map +1 -0
- package/dist/model/guards.d.ts +9 -0
- package/dist/model/guards.d.ts.map +1 -0
- package/dist/model/guards.js +11 -0
- package/dist/model/guards.js.map +1 -0
- package/dist/model/input.d.ts +42 -0
- package/dist/model/input.d.ts.map +1 -0
- package/dist/model/input.js +26 -0
- package/dist/model/input.js.map +1 -0
- package/dist/model/integer.d.ts +14 -0
- package/dist/model/integer.d.ts.map +1 -0
- package/dist/model/integer.js +16 -0
- package/dist/model/integer.js.map +1 -0
- package/dist/model/intrinsic.d.ts +18 -0
- package/dist/model/intrinsic.d.ts.map +1 -0
- package/dist/model/intrinsic.js +21 -0
- package/dist/model/intrinsic.js.map +1 -0
- package/dist/model/layout.d.ts +129 -0
- package/dist/model/layout.d.ts.map +1 -0
- package/dist/model/layout.js +2 -0
- package/dist/model/layout.js.map +1 -0
- package/dist/model/media.d.ts +33 -0
- package/dist/model/media.d.ts.map +1 -0
- package/dist/model/media.js +86 -0
- package/dist/model/media.js.map +1 -0
- package/dist/model/members.generated.d.ts +11 -0
- package/dist/model/members.generated.d.ts.map +1 -0
- package/dist/model/members.generated.js +71 -0
- package/dist/model/members.generated.js.map +1 -0
- package/dist/model/row-address.d.ts +27 -0
- package/dist/model/row-address.d.ts.map +1 -0
- package/dist/model/row-address.js +146 -0
- package/dist/model/row-address.js.map +1 -0
- package/dist/model/schema.d.ts +108 -0
- package/dist/model/schema.d.ts.map +1 -0
- package/dist/model/schema.js +2 -0
- package/dist/model/schema.js.map +1 -0
- package/dist/model/shape.d.ts +193 -0
- package/dist/model/shape.d.ts.map +1 -0
- package/dist/model/shape.js +2 -0
- package/dist/model/shape.js.map +1 -0
- package/dist/model/time.d.ts +61 -0
- package/dist/model/time.d.ts.map +1 -0
- package/dist/model/time.js +110 -0
- package/dist/model/time.js.map +1 -0
- package/dist/model/types.d.ts +1329 -0
- package/dist/model/types.d.ts.map +1 -0
- package/dist/model/types.js +424 -0
- package/dist/model/types.js.map +1 -0
- package/dist/model/values.d.ts +91 -0
- package/dist/model/values.d.ts.map +1 -0
- package/dist/model/values.js +195 -0
- package/dist/model/values.js.map +1 -0
- package/dist/model/wire.d.ts +356 -0
- package/dist/model/wire.d.ts.map +1 -0
- package/dist/model/wire.js +1504 -0
- package/dist/model/wire.js.map +1 -0
- package/dist/offline/index.d.ts +374 -0
- package/dist/offline/index.d.ts.map +1 -0
- package/dist/offline/index.js +422 -0
- package/dist/offline/index.js.map +1 -0
- package/dist/testing.d.ts +30 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +42 -0
- package/dist/testing.js.map +1 -0
- package/dist/version.d.ts +30 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +116 -0
- package/dist/version.js.map +1 -0
- package/package.json +98 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate.js","sourceRoot":"","sources":["../../../src/eval/rule/gate.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;AACxF,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAyB;IAC7C,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC9E,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IAChC,OAAO,MAAM,EAAE,IAAI,KAAK,SAAS,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACnG,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,QAAQ,CACtB,IAAyB,EACzB,MAAe,EACf,MAAuD,EACvD,MAA2B;IAE3B,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3C,MAAM;QACN,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3C,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;KAC3C,CAAC;AACJ,CAAC","sourcesContent":["import type {\n FieldRef,\n GateItemDeclaration,\n GateItemResult,\n GateReport,\n Outcome,\n RuleGate,\n WireValue,\n} from '../../model/types.js';\n\n/**\n * The gate section a device reports for a gate rule only the server evaluates: every\n * item's identity and message key with the one status the device can\n * honestly give it, and no parameters — a client artifact carries nothing that states what\n * the server checked. Without the section the report would say nothing about the gate the\n * record must still pass, and `evaluateGate` could only report a missing gate.\n */\nexport function deferredGate(gate: RuleGate): GateReport {\n return { items: gate.items.map((item) => gateItem(item, 'DEFERRED', undefined, [])) };\n}\n\n/**\n * The rule a gate item folds, when its expression is exactly `rule_ok(<ruleId>)`. The item\n * result names it so a consumer can map the item to the rule it decided without parsing the\n * expression; an item that composes its own condition folds no single rule and states none.\n */\nfunction foldedRuleOf(item: GateItemDeclaration): string | undefined {\n if (item.expr.kind !== 'call' || item.expr.op !== 'rule_ok') return undefined;\n const [target] = item.expr.args;\n return target?.kind === 'literal' && typeof target.value === 'string' ? target.value : undefined;\n}\n\n/** One gate item's result, built the same way for an evaluated and a deferred gate. */\nexport function gateItem(\n item: GateItemDeclaration,\n status: Outcome,\n params: Readonly<Record<string, WireValue>> | undefined,\n fields: readonly FieldRef[],\n): GateItemResult {\n const ruleId = foldedRuleOf(item);\n return {\n itemId: item.itemId,\n ...(ruleId === undefined ? {} : { ruleId }),\n status,\n messageKey: item.messageKey,\n ...(params === undefined ? {} : { params }),\n ...(fields.length === 0 ? {} : { fields }),\n };\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CompiledRule, RuleResult } from '../../model/types.js';
|
|
2
|
+
import type { EvaluationState } from './state.js';
|
|
3
|
+
/**
|
|
4
|
+
* One `item`-scoped rule evaluated once per row of the array it addresses,
|
|
5
|
+
* Each result and diagnostic names the row by its natural or assigned key, so a
|
|
6
|
+
* host can map it to one row without relying on array position.
|
|
7
|
+
*/
|
|
8
|
+
export declare function evaluateItemRule(state: EvaluationState, rule: CompiledRule, evaluateBody: (rule: CompiledRule) => {
|
|
9
|
+
readonly result: RuleResult;
|
|
10
|
+
}): readonly RuleResult[];
|
|
11
|
+
//# sourceMappingURL=item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../src/eval/rule/item.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,YAAY,EAEZ,UAAU,EAEX,MAAM,sBAAsB,CAAC;AAW9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,GACpE,SAAS,UAAU,EAAE,CAyIvB"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { AxiomError } from '../../model/errors.js';
|
|
2
|
+
import { isUndetermined, UNKNOWN } from '../../model/types.js';
|
|
3
|
+
import { isWireArray } from '../../model/values.js';
|
|
4
|
+
import { rowKeyToken } from '../../model/wire.js';
|
|
5
|
+
import { addressingOfItems, rowKeyOfItem } from '../addressing.js';
|
|
6
|
+
import { BudgetExceededError } from '../budget.js';
|
|
7
|
+
import { valueOf } from '../expr/value.js';
|
|
8
|
+
import { recordDiagnostic, recordEngineError } from './diagnostics.js';
|
|
9
|
+
import { baseResult, failedResult, outcomeResult } from './result.js';
|
|
10
|
+
import { markComputedUndetermined } from './compute.js';
|
|
11
|
+
/**
|
|
12
|
+
* One `item`-scoped rule evaluated once per row of the array it addresses,
|
|
13
|
+
* Each result and diagnostic names the row by its natural or assigned key, so a
|
|
14
|
+
* host can map it to one row without relying on array position.
|
|
15
|
+
*/
|
|
16
|
+
export function evaluateItemRule(state, rule, evaluateBody) {
|
|
17
|
+
if (rule.kind === 'gate' || rule.kind === 'screen') {
|
|
18
|
+
throw new AxiomError('ENGINE_ERROR', `an item-scoped ${rule.kind} rule has no per-row report section`, rule.ruleId);
|
|
19
|
+
}
|
|
20
|
+
const fieldId = rule.fieldId;
|
|
21
|
+
if (fieldId === undefined) {
|
|
22
|
+
throw new AxiomError('ENGINE_ERROR', 'an item-scoped rule declares the array field it addresses', rule.ruleId);
|
|
23
|
+
}
|
|
24
|
+
const arrayPath = state.reader.declarationPathOf(fieldId);
|
|
25
|
+
// An item rule answers one row at a time, so it reads the rows rather than the container value:
|
|
26
|
+
// a row-exact restriction is that row's answer and leaves its siblings decided
|
|
27
|
+
// (`[ACCESS-1.3.1]`). A redacted array, or one whose rows cannot be named, is still refused or
|
|
28
|
+
// deferred whole by that read.
|
|
29
|
+
const array = state.reader.readRows(arrayPath);
|
|
30
|
+
// an absent or `null` list is undetermined, never an empty one, and a
|
|
31
|
+
// redacted one is computed elsewhere. No row exists to carry such a result, so the
|
|
32
|
+
// rule reports once against its array instead of inventing rows.
|
|
33
|
+
if (array.kind === 'absent' || (array.kind === 'value' && array.value === null)) {
|
|
34
|
+
reportRequiredUnknown(state, rule);
|
|
35
|
+
return [outcomeResult(state, rule, 'UNKNOWN')];
|
|
36
|
+
}
|
|
37
|
+
if (array.kind === 'value' && isUndetermined(array.value)) {
|
|
38
|
+
reportRequiredUnknown(state, rule);
|
|
39
|
+
return [outcomeResult(state, rule, array.value.undetermined)];
|
|
40
|
+
}
|
|
41
|
+
if (array.kind !== 'value' || !isWireArray(array.value)) {
|
|
42
|
+
throw new AxiomError('ENGINE_ERROR', `${fieldId} is not a list`, arrayPath);
|
|
43
|
+
}
|
|
44
|
+
// The item scope binds one element per row, so it is held to the same source cap a
|
|
45
|
+
// comprehension is: a hostile record is refused before an unbounded binding list exists.
|
|
46
|
+
state.evaluator.refuseElements(array.value.length);
|
|
47
|
+
const field = state.reader.index.fieldsByPath.get(arrayPath);
|
|
48
|
+
if (field === undefined || field.primitive !== 'array') {
|
|
49
|
+
throw new AxiomError('ENGINE_ERROR', `${fieldId} is not a declared array`, arrayPath);
|
|
50
|
+
}
|
|
51
|
+
const addressing = addressingOfItems(field, array.value, state.reader.index.assignedRowKeys?.(field.fieldId));
|
|
52
|
+
// The one row-identity contract: a duplicate key is data the record carries, so it is
|
|
53
|
+
// answered per row with the key the record states. A duplicate is never collapsed into one
|
|
54
|
+
// undifferentiated engine error, and it is never refused at open (`IDENT-2.1.9`).
|
|
55
|
+
if (addressing.outcome === 'duplicate') {
|
|
56
|
+
return duplicateRowResults(state, rule, field, array.value, addressing.rowKey);
|
|
57
|
+
}
|
|
58
|
+
if (addressing.outcome !== 'addressed') {
|
|
59
|
+
return [identityRefusalResult(state, rule, field, addressing)];
|
|
60
|
+
}
|
|
61
|
+
const rowKeys = addressing.rows.map((row) => row.rowKey);
|
|
62
|
+
// A declared row is a closed record: its members are the array's declared fields, in
|
|
63
|
+
// declaration order, whether or not this row stated each one. Carrying them lets an item
|
|
64
|
+
// rule ask `keys($it)` without inferring a type from the row's current enumerable keys.
|
|
65
|
+
const rowMemberNames = field.fields?.map((member) => member.fieldId) ?? [];
|
|
66
|
+
const elements = array.value.map((item) => {
|
|
67
|
+
const evaluated = valueOf(item);
|
|
68
|
+
return rowMemberNames.length === 0
|
|
69
|
+
? evaluated
|
|
70
|
+
: {
|
|
71
|
+
...evaluated,
|
|
72
|
+
closedMembers: rowMemberNames,
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
// An item rule answers once per row, so its row count is the block of report entries it is
|
|
76
|
+
// about to allocate. The check runs before the first result exists: a hostile record is
|
|
77
|
+
// refused here rather than after a result per row has been built.
|
|
78
|
+
state.evaluator.ensureDecisionRoom(elements.length, 'item rule');
|
|
79
|
+
// The read states the members each row withheld, including sideband a computed writer carried
|
|
80
|
+
// through the overlay. A row no longer carries those members, so the binder must answer
|
|
81
|
+
// `UNKNOWN` rather than the absence their removal would state. The ordered array aligns with
|
|
82
|
+
// `elements`, which is what a scope reading `$prev`/`$next` needs.
|
|
83
|
+
const withheld = array.withheldRows ?? rowKeys.map((rowKey) => state.reader.withheldAt(arrayPath, rowKey));
|
|
84
|
+
// The same read states the members a writer could not produce, with the sentinel each one
|
|
85
|
+
// answers. It is per row like `withheld`, but its answer is the sentinel itself, so a row's
|
|
86
|
+
// `DEFERRED` member never becomes another row's `UNKNOWN` or the array's undecided state.
|
|
87
|
+
const undetermined = array.undeterminedRows;
|
|
88
|
+
const results = [];
|
|
89
|
+
for (let index = 0; index < elements.length; index += 1) {
|
|
90
|
+
const rowKey = rowKeys[index];
|
|
91
|
+
if (rowKey === undefined)
|
|
92
|
+
continue;
|
|
93
|
+
state.currentRowKey = rowKey;
|
|
94
|
+
const ref = { fieldId, rowKey };
|
|
95
|
+
// A scalar element has no member walk to strip it. Answer the row itself before its raw value
|
|
96
|
+
// reaches an expression; a record row's own restriction is already carried by its cell walk.
|
|
97
|
+
if (state.reader.isRedacted(ref)) {
|
|
98
|
+
results.push(outcomeResult(state, rule, 'DEFERRED'));
|
|
99
|
+
state.currentRowKey = undefined;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (!state.reader.isReadable(ref)) {
|
|
103
|
+
state.reader.recordDenied(fieldId, rowKey);
|
|
104
|
+
if (rule.kind === 'required')
|
|
105
|
+
reportRequiredUnknown(state, rule);
|
|
106
|
+
if (rule.kind === 'compute')
|
|
107
|
+
markComputedUndetermined(state, rule, UNKNOWN);
|
|
108
|
+
results.push(outcomeResult(state, rule, 'UNKNOWN'));
|
|
109
|
+
state.currentRowKey = undefined;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
results.push(state.evaluator.withItemScope(arrayPath, elements, index, () => {
|
|
114
|
+
return evaluateBody(rule).result;
|
|
115
|
+
}, withheld, undetermined));
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (!(error instanceof AxiomError))
|
|
119
|
+
throw error;
|
|
120
|
+
// A budget refusal belongs to the rule's evaluation, not to the row that happened to cross
|
|
121
|
+
// it. Continuing would repeat an exhausted allowance on every remaining row and turn one
|
|
122
|
+
// loud refusal into thousands of duplicate results and diagnostics.
|
|
123
|
+
if (error instanceof BudgetExceededError)
|
|
124
|
+
throw error;
|
|
125
|
+
// One row's expression raising decides that row only; the other
|
|
126
|
+
// rows were never the same claim.
|
|
127
|
+
recordEngineError(state, rule.ruleId, error);
|
|
128
|
+
// A computed write that raised has no value for this row: record the row's
|
|
129
|
+
// undetermined entry so a read of its target can never fall through to the submission.
|
|
130
|
+
if (rule.kind === 'compute')
|
|
131
|
+
markComputedUndetermined(state, rule, UNKNOWN);
|
|
132
|
+
results.push(failedResult(state, rule));
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
state.currentRowKey = undefined;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return results;
|
|
139
|
+
}
|
|
140
|
+
/** A `required` rule that could not read its rows is unsatisfied and says why (). */
|
|
141
|
+
function reportRequiredUnknown(state, rule) {
|
|
142
|
+
if (rule.kind !== 'required')
|
|
143
|
+
return;
|
|
144
|
+
const written = rule.scope === 'item' ? rule.targetFieldId : rule.fieldId;
|
|
145
|
+
recordDiagnostic(state, 'REQUIRED_UNKNOWN', {
|
|
146
|
+
ruleId: rule.ruleId,
|
|
147
|
+
...(written === undefined ? {} : { fieldId: written }),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* One result per row whose key another row also states, each naming that key.
|
|
152
|
+
*
|
|
153
|
+
* Two rows sharing one key identify neither (`IDENT-2.1.6`), so neither is matched to the
|
|
154
|
+
* other. The failure is still representable as data — one result per offending row, carrying
|
|
155
|
+
* the key the record itself states — instead of an engine error that names no row. `validate`
|
|
156
|
+
* fails the row it names; a kind whose `FAIL` is a branch (`visible`, `required`, `enabled`)
|
|
157
|
+
* is undecided instead, so a duplicate never reads as "not required".
|
|
158
|
+
*/
|
|
159
|
+
function duplicateRowResults(state, rule, field, items, rowKey) {
|
|
160
|
+
const manifest = state.reader.index.assignedRowKeys?.(field.fieldId);
|
|
161
|
+
const counts = new Map();
|
|
162
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
163
|
+
const key = rowKeyOfItem(field, items, index, manifest);
|
|
164
|
+
if (key === undefined)
|
|
165
|
+
continue;
|
|
166
|
+
const token = rowKeyToken(key);
|
|
167
|
+
counts.set(token, (counts.get(token) ?? 0) + 1);
|
|
168
|
+
}
|
|
169
|
+
// A key the device may not read must not be spelled by the result or its diagnostic
|
|
170
|
+
// (`ACCESS-7.1.6`): a masked or redacted natural key would otherwise leak through the row
|
|
171
|
+
// the rule names. The duplicate is still reported — once against the array, with no key.
|
|
172
|
+
if (!identityKeyReadable(state, field)) {
|
|
173
|
+
recordDiagnostic(state, 'ROW_IDENTITY', {
|
|
174
|
+
ruleId: rule.ruleId,
|
|
175
|
+
fieldId: field.fieldId,
|
|
176
|
+
params: { reason: 'duplicate', fieldId: field.fieldId },
|
|
177
|
+
});
|
|
178
|
+
if (rule.kind === 'required')
|
|
179
|
+
reportRequiredUnknown(state, rule);
|
|
180
|
+
if (rule.kind === 'compute')
|
|
181
|
+
markComputedUndetermined(state, rule, UNKNOWN);
|
|
182
|
+
return [outcomeResult(state, rule, 'UNKNOWN')];
|
|
183
|
+
}
|
|
184
|
+
const status = rule.kind === 'validate' ? 'FAIL' : 'UNKNOWN';
|
|
185
|
+
// The duplicate path still produces one entry per offending row, so it is bounded by the
|
|
186
|
+
// same decision allowance before it allocates them.
|
|
187
|
+
state.evaluator.ensureDecisionRoom(items.length, 'item rule');
|
|
188
|
+
const results = [];
|
|
189
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
190
|
+
const key = rowKeyOfItem(field, items, index, manifest);
|
|
191
|
+
if (key === undefined || (counts.get(rowKeyToken(key)) ?? 0) < 2)
|
|
192
|
+
continue;
|
|
193
|
+
state.currentRowKey = key;
|
|
194
|
+
try {
|
|
195
|
+
recordDiagnostic(state, 'ROW_IDENTITY', {
|
|
196
|
+
ruleId: rule.ruleId,
|
|
197
|
+
fieldId: field.fieldId,
|
|
198
|
+
params: { reason: 'duplicate', fieldId: field.fieldId, rowKey: key },
|
|
199
|
+
});
|
|
200
|
+
if (rule.kind === 'required')
|
|
201
|
+
reportRequiredUnknown(state, rule);
|
|
202
|
+
if (rule.kind === 'compute')
|
|
203
|
+
markComputedUndetermined(state, rule, UNKNOWN);
|
|
204
|
+
results.push(rule.kind === 'compute'
|
|
205
|
+
? { ...baseResult(state, rule, status, rule.severity ?? 'block', undefined), value: null }
|
|
206
|
+
: baseResult(state, rule, status, rule.severity ?? 'block', undefined));
|
|
207
|
+
}
|
|
208
|
+
finally {
|
|
209
|
+
state.currentRowKey = undefined;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// `rowKey` is the first duplicate the addressing authority named; the loop above finds every
|
|
213
|
+
// one from the same items. If they ever disagree the loop is the answer, so this member is
|
|
214
|
+
// only asserted against the authority by the contract test.
|
|
215
|
+
if (results.length === 0 && rowKey !== undefined) {
|
|
216
|
+
state.currentRowKey = rowKey;
|
|
217
|
+
try {
|
|
218
|
+
recordDiagnostic(state, 'ROW_IDENTITY', {
|
|
219
|
+
ruleId: rule.ruleId,
|
|
220
|
+
fieldId: field.fieldId,
|
|
221
|
+
params: { reason: 'duplicate', fieldId: field.fieldId, rowKey },
|
|
222
|
+
});
|
|
223
|
+
results.push(failedResult(state, rule));
|
|
224
|
+
}
|
|
225
|
+
finally {
|
|
226
|
+
state.currentRowKey = undefined;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return results;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Whether the value that names a row may be stated to this device.
|
|
233
|
+
*
|
|
234
|
+
* A natural key is a record value, so a masked, hidden or redacted key — or one under a container
|
|
235
|
+
* delivery withholds — must not be named in a result or a diagnostic (`ACCESS-7.1.6`). The
|
|
236
|
+
* declaration walk covers ancestors, the same way a delivered writer value is weighed.
|
|
237
|
+
*/
|
|
238
|
+
function identityKeyReadable(state, field) {
|
|
239
|
+
const identityFieldId = field.rowKey?.mode === 'natural' ? field.rowKey.fieldId : field.fieldId;
|
|
240
|
+
if (identityFieldId === undefined)
|
|
241
|
+
return false;
|
|
242
|
+
const walked = state.reader.walked(state.reader.declarationPathOf(identityFieldId));
|
|
243
|
+
if (walked === undefined)
|
|
244
|
+
return false;
|
|
245
|
+
return walked.declared.every((id) => !state.reader.redactedFields.has(id) && state.reader.isReadable({ fieldId: id }));
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The one answer an array with no reconciled identity states: undecided, against the array,
|
|
249
|
+
* with the reason and the array named. No row is invented, and the cause is `ROW_IDENTITY`
|
|
250
|
+
* rather than an `ENGINE_ERROR` that says only that evaluation stopped (`IDENT-2.1.9`).
|
|
251
|
+
*/
|
|
252
|
+
function identityRefusalResult(state, rule, field, addressing) {
|
|
253
|
+
const reason = addressing.outcome === 'duplicate' ? 'duplicate' : addressing.reason;
|
|
254
|
+
recordDiagnostic(state, 'ROW_IDENTITY', {
|
|
255
|
+
ruleId: rule.ruleId,
|
|
256
|
+
fieldId: field.fieldId,
|
|
257
|
+
params: { reason, fieldId: field.fieldId },
|
|
258
|
+
});
|
|
259
|
+
if (rule.kind === 'required')
|
|
260
|
+
reportRequiredUnknown(state, rule);
|
|
261
|
+
if (rule.kind === 'compute')
|
|
262
|
+
markComputedUndetermined(state, rule, UNKNOWN);
|
|
263
|
+
return outcomeResult(state, rule, 'UNKNOWN');
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item.js","sourceRoot":"","sources":["../../../src/eval/rule/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAQnD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAGxD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAsB,EACtB,IAAkB,EAClB,YAAqE;IAErE,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACnD,MAAM,IAAI,UAAU,CAClB,cAAc,EACd,kBAAkB,IAAI,CAAC,IAAI,qCAAqC,EAChE,IAAI,CAAC,MAAM,CACZ,CAAC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CACzF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,qBAAqB,CAC5B,KAAsB,EACtB,IAAkB,EAClB,KAAoB,EACpB,UAAuE;IAEvE,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;IACpF,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE;QACtC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;KAC3C,CAAC,CAAC;IACH,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU;QAAE,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACjE,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;QAAE,wBAAwB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5E,OAAO,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import { AxiomError } from '../../model/errors.js';\nimport type {\n CompiledField,\n CompiledRule,\n Outcome,\n RuleResult,\n WireValue,\n} from '../../model/types.js';\nimport { isUndetermined, UNKNOWN } from '../../model/types.js';\nimport { isWireArray } from '../../model/values.js';\nimport { rowKeyToken } from '../../model/wire.js';\nimport { addressingOfItems, rowKeyOfItem } from '../addressing.js';\nimport type { ArrayAddressing } from '../addressing.js';\nimport { BudgetExceededError } from '../budget.js';\nimport { valueOf } from '../expr/value.js';\nimport { recordDiagnostic, recordEngineError } from './diagnostics.js';\nimport { baseResult, failedResult, outcomeResult } from './result.js';\nimport { markComputedUndetermined } from './compute.js';\nimport type { EvaluationState } from './state.js';\n\n/**\n * One `item`-scoped rule evaluated once per row of the array it addresses,\n * Each result and diagnostic names the row by its natural or assigned key, so a\n * host can map it to one row without relying on array position.\n */\nexport function evaluateItemRule(\n state: EvaluationState,\n rule: CompiledRule,\n evaluateBody: (rule: CompiledRule) => { readonly result: RuleResult },\n): readonly RuleResult[] {\n if (rule.kind === 'gate' || rule.kind === 'screen') {\n throw new AxiomError(\n 'ENGINE_ERROR',\n `an item-scoped ${rule.kind} rule has no per-row report section`,\n rule.ruleId,\n );\n }\n const fieldId = rule.fieldId;\n if (fieldId === undefined) {\n throw new AxiomError(\n 'ENGINE_ERROR',\n 'an item-scoped rule declares the array field it addresses',\n rule.ruleId,\n );\n }\n const arrayPath = state.reader.declarationPathOf(fieldId);\n // An item rule answers one row at a time, so it reads the rows rather than the container value:\n // a row-exact restriction is that row's answer and leaves its siblings decided\n // (`[ACCESS-1.3.1]`). A redacted array, or one whose rows cannot be named, is still refused or\n // deferred whole by that read.\n const array = state.reader.readRows(arrayPath);\n // an absent or `null` list is undetermined, never an empty one, and a\n // redacted one is computed elsewhere. No row exists to carry such a result, so the\n // rule reports once against its array instead of inventing rows.\n if (array.kind === 'absent' || (array.kind === 'value' && array.value === null)) {\n reportRequiredUnknown(state, rule);\n return [outcomeResult(state, rule, 'UNKNOWN')];\n }\n if (array.kind === 'value' && isUndetermined(array.value)) {\n reportRequiredUnknown(state, rule);\n return [outcomeResult(state, rule, array.value.undetermined)];\n }\n if (array.kind !== 'value' || !isWireArray(array.value)) {\n throw new AxiomError('ENGINE_ERROR', `${fieldId} is not a list`, arrayPath);\n }\n // The item scope binds one element per row, so it is held to the same source cap a\n // comprehension is: a hostile record is refused before an unbounded binding list exists.\n state.evaluator.refuseElements(array.value.length);\n const field = state.reader.index.fieldsByPath.get(arrayPath);\n if (field === undefined || field.primitive !== 'array') {\n throw new AxiomError('ENGINE_ERROR', `${fieldId} is not a declared array`, arrayPath);\n }\n const addressing = addressingOfItems(\n field,\n array.value,\n state.reader.index.assignedRowKeys?.(field.fieldId),\n );\n // The one row-identity contract: a duplicate key is data the record carries, so it is\n // answered per row with the key the record states. A duplicate is never collapsed into one\n // undifferentiated engine error, and it is never refused at open (`IDENT-2.1.9`).\n if (addressing.outcome === 'duplicate') {\n return duplicateRowResults(state, rule, field, array.value, addressing.rowKey);\n }\n if (addressing.outcome !== 'addressed') {\n return [identityRefusalResult(state, rule, field, addressing)];\n }\n const rowKeys = addressing.rows.map((row) => row.rowKey);\n // A declared row is a closed record: its members are the array's declared fields, in\n // declaration order, whether or not this row stated each one. Carrying them lets an item\n // rule ask `keys($it)` without inferring a type from the row's current enumerable keys.\n const rowMemberNames = field.fields?.map((member) => member.fieldId) ?? [];\n const elements = array.value.map((item) => {\n const evaluated = valueOf(item);\n return rowMemberNames.length === 0\n ? evaluated\n : {\n ...evaluated,\n closedMembers: rowMemberNames,\n };\n });\n // An item rule answers once per row, so its row count is the block of report entries it is\n // about to allocate. The check runs before the first result exists: a hostile record is\n // refused here rather than after a result per row has been built.\n state.evaluator.ensureDecisionRoom(elements.length, 'item rule');\n // The read states the members each row withheld, including sideband a computed writer carried\n // through the overlay. A row no longer carries those members, so the binder must answer\n // `UNKNOWN` rather than the absence their removal would state. The ordered array aligns with\n // `elements`, which is what a scope reading `$prev`/`$next` needs.\n const withheld =\n array.withheldRows ?? rowKeys.map((rowKey) => state.reader.withheldAt(arrayPath, rowKey));\n // The same read states the members a writer could not produce, with the sentinel each one\n // answers. It is per row like `withheld`, but its answer is the sentinel itself, so a row's\n // `DEFERRED` member never becomes another row's `UNKNOWN` or the array's undecided state.\n const undetermined = array.undeterminedRows;\n const results: RuleResult[] = [];\n for (let index = 0; index < elements.length; index += 1) {\n const rowKey = rowKeys[index];\n if (rowKey === undefined) continue;\n state.currentRowKey = rowKey;\n const ref = { fieldId, rowKey };\n // A scalar element has no member walk to strip it. Answer the row itself before its raw value\n // reaches an expression; a record row's own restriction is already carried by its cell walk.\n if (state.reader.isRedacted(ref)) {\n results.push(outcomeResult(state, rule, 'DEFERRED'));\n state.currentRowKey = undefined;\n continue;\n }\n if (!state.reader.isReadable(ref)) {\n state.reader.recordDenied(fieldId, rowKey);\n if (rule.kind === 'required') reportRequiredUnknown(state, rule);\n if (rule.kind === 'compute') markComputedUndetermined(state, rule, UNKNOWN);\n results.push(outcomeResult(state, rule, 'UNKNOWN'));\n state.currentRowKey = undefined;\n continue;\n }\n try {\n results.push(\n state.evaluator.withItemScope(\n arrayPath,\n elements,\n index,\n () => {\n return evaluateBody(rule).result;\n },\n withheld,\n undetermined,\n ),\n );\n } catch (error) {\n if (!(error instanceof AxiomError)) throw error;\n // A budget refusal belongs to the rule's evaluation, not to the row that happened to cross\n // it. Continuing would repeat an exhausted allowance on every remaining row and turn one\n // loud refusal into thousands of duplicate results and diagnostics.\n if (error instanceof BudgetExceededError) throw error;\n // One row's expression raising decides that row only; the other\n // rows were never the same claim.\n recordEngineError(state, rule.ruleId, error);\n // A computed write that raised has no value for this row: record the row's\n // undetermined entry so a read of its target can never fall through to the submission.\n if (rule.kind === 'compute') markComputedUndetermined(state, rule, UNKNOWN);\n results.push(failedResult(state, rule));\n } finally {\n state.currentRowKey = undefined;\n }\n }\n return results;\n}\n\n/** A `required` rule that could not read its rows is unsatisfied and says why (). */\nfunction reportRequiredUnknown(state: EvaluationState, rule: CompiledRule): void {\n if (rule.kind !== 'required') return;\n const written = rule.scope === 'item' ? rule.targetFieldId : rule.fieldId;\n recordDiagnostic(state, 'REQUIRED_UNKNOWN', {\n ruleId: rule.ruleId,\n ...(written === undefined ? {} : { fieldId: written }),\n });\n}\n\n/**\n * One result per row whose key another row also states, each naming that key.\n *\n * Two rows sharing one key identify neither (`IDENT-2.1.6`), so neither is matched to the\n * other. The failure is still representable as data — one result per offending row, carrying\n * the key the record itself states — instead of an engine error that names no row. `validate`\n * fails the row it names; a kind whose `FAIL` is a branch (`visible`, `required`, `enabled`)\n * is undecided instead, so a duplicate never reads as \"not required\".\n */\nfunction duplicateRowResults(\n state: EvaluationState,\n rule: CompiledRule,\n field: CompiledField,\n items: readonly WireValue[],\n rowKey: string | number,\n): readonly RuleResult[] {\n const manifest = state.reader.index.assignedRowKeys?.(field.fieldId);\n const counts = new Map<string, number>();\n for (let index = 0; index < items.length; index += 1) {\n const key = rowKeyOfItem(field, items, index, manifest);\n if (key === undefined) continue;\n const token = rowKeyToken(key);\n counts.set(token, (counts.get(token) ?? 0) + 1);\n }\n // A key the device may not read must not be spelled by the result or its diagnostic\n // (`ACCESS-7.1.6`): a masked or redacted natural key would otherwise leak through the row\n // the rule names. The duplicate is still reported — once against the array, with no key.\n if (!identityKeyReadable(state, field)) {\n recordDiagnostic(state, 'ROW_IDENTITY', {\n ruleId: rule.ruleId,\n fieldId: field.fieldId,\n params: { reason: 'duplicate', fieldId: field.fieldId },\n });\n if (rule.kind === 'required') reportRequiredUnknown(state, rule);\n if (rule.kind === 'compute') markComputedUndetermined(state, rule, UNKNOWN);\n return [outcomeResult(state, rule, 'UNKNOWN')];\n }\n const status: Outcome = rule.kind === 'validate' ? 'FAIL' : 'UNKNOWN';\n // The duplicate path still produces one entry per offending row, so it is bounded by the\n // same decision allowance before it allocates them.\n state.evaluator.ensureDecisionRoom(items.length, 'item rule');\n const results: RuleResult[] = [];\n for (let index = 0; index < items.length; index += 1) {\n const key = rowKeyOfItem(field, items, index, manifest);\n if (key === undefined || (counts.get(rowKeyToken(key)) ?? 0) < 2) continue;\n state.currentRowKey = key;\n try {\n recordDiagnostic(state, 'ROW_IDENTITY', {\n ruleId: rule.ruleId,\n fieldId: field.fieldId,\n params: { reason: 'duplicate', fieldId: field.fieldId, rowKey: key },\n });\n if (rule.kind === 'required') reportRequiredUnknown(state, rule);\n if (rule.kind === 'compute') markComputedUndetermined(state, rule, UNKNOWN);\n results.push(\n rule.kind === 'compute'\n ? { ...baseResult(state, rule, status, rule.severity ?? 'block', undefined), value: null }\n : baseResult(state, rule, status, rule.severity ?? 'block', undefined),\n );\n } finally {\n state.currentRowKey = undefined;\n }\n }\n // `rowKey` is the first duplicate the addressing authority named; the loop above finds every\n // one from the same items. If they ever disagree the loop is the answer, so this member is\n // only asserted against the authority by the contract test.\n if (results.length === 0 && rowKey !== undefined) {\n state.currentRowKey = rowKey;\n try {\n recordDiagnostic(state, 'ROW_IDENTITY', {\n ruleId: rule.ruleId,\n fieldId: field.fieldId,\n params: { reason: 'duplicate', fieldId: field.fieldId, rowKey },\n });\n results.push(failedResult(state, rule));\n } finally {\n state.currentRowKey = undefined;\n }\n }\n return results;\n}\n\n/**\n * Whether the value that names a row may be stated to this device.\n *\n * A natural key is a record value, so a masked, hidden or redacted key — or one under a container\n * delivery withholds — must not be named in a result or a diagnostic (`ACCESS-7.1.6`). The\n * declaration walk covers ancestors, the same way a delivered writer value is weighed.\n */\nfunction identityKeyReadable(state: EvaluationState, field: CompiledField): boolean {\n const identityFieldId = field.rowKey?.mode === 'natural' ? field.rowKey.fieldId : field.fieldId;\n if (identityFieldId === undefined) return false;\n const walked = state.reader.walked(state.reader.declarationPathOf(identityFieldId));\n if (walked === undefined) return false;\n return walked.declared.every(\n (id) => !state.reader.redactedFields.has(id) && state.reader.isReadable({ fieldId: id }),\n );\n}\n\n/**\n * The one answer an array with no reconciled identity states: undecided, against the array,\n * with the reason and the array named. No row is invented, and the cause is `ROW_IDENTITY`\n * rather than an `ENGINE_ERROR` that says only that evaluation stopped (`IDENT-2.1.9`).\n */\nfunction identityRefusalResult(\n state: EvaluationState,\n rule: CompiledRule,\n field: CompiledField,\n addressing: Exclude<ArrayAddressing, { readonly outcome: 'addressed' }>,\n): RuleResult {\n const reason = addressing.outcome === 'duplicate' ? 'duplicate' : addressing.reason;\n recordDiagnostic(state, 'ROW_IDENTITY', {\n ruleId: rule.ruleId,\n fieldId: field.fieldId,\n params: { reason, fieldId: field.fieldId },\n });\n if (rule.kind === 'required') reportRequiredUnknown(state, rule);\n if (rule.kind === 'compute') markComputedUndetermined(state, rule, UNKNOWN);\n return outcomeResult(state, rule, 'UNKNOWN');\n}\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ReadRef } from '../../graph/index.js';
|
|
2
|
+
import type { CompiledField, CompiledRule, GateItemDeclaration, LookupPort } from '../../model/types.js';
|
|
3
|
+
import type { CompiledSchema } from '../../model/schema.js';
|
|
4
|
+
import type { ContextRootDeclaration } from '../reader.js';
|
|
5
|
+
import type { VisibilityIndex } from '../visibility.js';
|
|
6
|
+
/**
|
|
7
|
+
* Everything an evaluation needs that depends only on the compiled artifact: its hashes,
|
|
8
|
+
* the fields each rule reads, the field-path index and the declared context roots.
|
|
9
|
+
*
|
|
10
|
+
* None of it changes between records, and hashing a rule means a defensive walk plus
|
|
11
|
+
* SHA-256, so deriving it per record made the artifact the dominant cost of an
|
|
12
|
+
* evaluation. A compiled artifact is immutable once parsed — the same contract the
|
|
13
|
+
* evaluator already assumes — so the identity of the object is a safe cache key.
|
|
14
|
+
*/
|
|
15
|
+
export interface PreparedSchema {
|
|
16
|
+
readonly behaviorHash: string;
|
|
17
|
+
readonly ruleHashes: ReadonlyMap<CompiledRule, string>;
|
|
18
|
+
readonly ruleFields: ReadonlyMap<CompiledRule, readonly ReadRef[]>;
|
|
19
|
+
readonly gateItemFields: ReadonlyMap<GateItemDeclaration, readonly ReadRef[]>;
|
|
20
|
+
readonly fieldsByPath: ReadonlyMap<string, CompiledField>;
|
|
21
|
+
readonly fieldById: ReadonlyMap<string, CompiledField>;
|
|
22
|
+
readonly contextRoots: ReadonlyMap<string, ContextRootDeclaration>;
|
|
23
|
+
readonly ruleById: ReadonlyMap<string, CompiledRule>;
|
|
24
|
+
/**
|
|
25
|
+
* The `visible` rules that can hide each field, container cascade included,
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
readonly visibility: VisibilityIndex;
|
|
29
|
+
/**
|
|
30
|
+
* The fields whose captured value is withheld from the report when a `visible` rule hides
|
|
31
|
+
* them: the declaration's own `exclude`, or the document's when it states none, and a
|
|
32
|
+
* `visible` rule that can reach it. A read of one of these can put a hidden value into a
|
|
33
|
+
* message parameter or a lookup key, so it is the set the reader taints.
|
|
34
|
+
*/
|
|
35
|
+
readonly withholdable: ReadonlySet<string>;
|
|
36
|
+
/**
|
|
37
|
+
* The rules whose signature verification the runtime refuses, with the cause. The compiler
|
|
38
|
+
* checks the same shape; a hand-built artifact reaches the evaluator without that check.
|
|
39
|
+
*/
|
|
40
|
+
readonly signatureRefusals: ReadonlyMap<CompiledRule, string>;
|
|
41
|
+
/** Every field a `compute` or `defaultCompute` rule owns. */
|
|
42
|
+
readonly writerIds: ReadonlySet<string>;
|
|
43
|
+
/**
|
|
44
|
+
* The writers in the order their values must be produced, or `undefined` when the artifact's
|
|
45
|
+
* graph has no order at all (a cycle or a second writer for one field). A hand-built artifact
|
|
46
|
+
* can reach the evaluator without the compiler's refusal, so its writers fail closed instead
|
|
47
|
+
* of resolving in an arbitrary order.
|
|
48
|
+
*/
|
|
49
|
+
readonly computedOrder: readonly CompiledRule[] | undefined;
|
|
50
|
+
}
|
|
51
|
+
/** The artifact-derived index one evaluation reads, built once per compiled schema. */
|
|
52
|
+
export declare function prepareSchema(compiled: CompiledSchema): PreparedSchema;
|
|
53
|
+
/**
|
|
54
|
+
* The host store with this artifact's version and digest pins applied.
|
|
55
|
+
*
|
|
56
|
+
* A schema declares the table versions it was compiled against; a store serving another
|
|
57
|
+
* version of one is answering from data the artifact was never checked with, so resolution
|
|
58
|
+
* goes `STALE` rather than falling back. When the store can state the digest of the version it
|
|
59
|
+
* holds, the document's canonical digest is compared with the pin as the two are paired, and a
|
|
60
|
+
* same-version republished table is refused there rather than resolved under an honest-looking
|
|
61
|
+
* report.
|
|
62
|
+
*/
|
|
63
|
+
export declare function pinnedLookup(compiled: CompiledSchema, port: LookupPort | undefined): LookupPort | undefined;
|
|
64
|
+
//# sourceMappingURL=prepare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../../src/eval/rule/prepare.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO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a,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAC;CAC7D;AA8CD,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,cAAc,GAAG,cAAc,CAgDtE;AAwBD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,UAAU,GAAG,SAAS,GAC3B,UAAU,GAAG,SAAS,CAIxB"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { gateItemReads, inspectDeps, ruleReads } from '../../graph/index.js';
|
|
2
|
+
import { pinLookup } from '../../lookup/pass.js';
|
|
3
|
+
import { indexContextRoots, indexFields } from '../reader.js';
|
|
4
|
+
import { freezeTree } from '../seal.js';
|
|
5
|
+
import { ruleSignatureRefusals } from '../signature-coverage.js';
|
|
6
|
+
import { artifactVisibility } from '../visibility.js';
|
|
7
|
+
import { behaviourOf, ruleHashesOf } from './behaviour.js';
|
|
8
|
+
/**
|
|
9
|
+
* The declared fields by `fieldId`. An identifier the compiler makes unique can be repeated in
|
|
10
|
+
* a hand-built artifact; the last declaration wins for a policy lookup because the reader
|
|
11
|
+
* already refuses a reference two declarations answer differently.
|
|
12
|
+
*/
|
|
13
|
+
function fieldsById(fields) {
|
|
14
|
+
const byId = new Map();
|
|
15
|
+
const visit = (members) => {
|
|
16
|
+
for (const member of members) {
|
|
17
|
+
byId.set(member.fieldId, member);
|
|
18
|
+
visit(member.fields ?? []);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
visit(fields);
|
|
22
|
+
return byId;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The fields a report must not quote when a `visible` rule hides them: the declaration's own
|
|
26
|
+
* `exclude`, the document's `exclude` when the field states none, and a `visible` rule that can
|
|
27
|
+
* reach the field. A field no rule can hide is never withheld, so a `visible` check is never
|
|
28
|
+
* asked about it.
|
|
29
|
+
*/
|
|
30
|
+
function withholdableFields(fields, document, visibility) {
|
|
31
|
+
const candidates = new Set();
|
|
32
|
+
const visit = (members) => {
|
|
33
|
+
for (const member of members) {
|
|
34
|
+
const policy = member.onHide ?? document;
|
|
35
|
+
if (policy === 'exclude' && visibility.byField.has(member.fieldId)) {
|
|
36
|
+
candidates.add(member.fieldId);
|
|
37
|
+
}
|
|
38
|
+
visit(member.fields ?? []);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
visit(fields);
|
|
42
|
+
return candidates;
|
|
43
|
+
}
|
|
44
|
+
const PREPARED_SCHEMAS = new WeakMap();
|
|
45
|
+
/** The artifact-derived index one evaluation reads, built once per compiled schema. */
|
|
46
|
+
export function prepareSchema(compiled) {
|
|
47
|
+
const cached = PREPARED_SCHEMAS.get(compiled);
|
|
48
|
+
if (cached !== undefined)
|
|
49
|
+
return cached;
|
|
50
|
+
// The caches key on the artifact's identity, so the artifact is frozen before anything is
|
|
51
|
+
// keyed by it: a later write fails instead of leaving a `behaviorHash` that describes a
|
|
52
|
+
// rule set the caller has since changed. The compiler already calls `inspectDeps`, which
|
|
53
|
+
// freezes at the emission boundary; this covers an artifact built by hand.
|
|
54
|
+
freezeTree(compiled);
|
|
55
|
+
const fieldsByPath = indexFields(compiled.fields);
|
|
56
|
+
const contextRoots = indexContextRoots(compiled.context?.roots);
|
|
57
|
+
const visibility = artifactVisibility(compiled);
|
|
58
|
+
const rules = compiled.rules ?? [];
|
|
59
|
+
const ruleHashes = ruleHashesOf(compiled);
|
|
60
|
+
const ruleById = new Map(rules.map((rule) => [rule.ruleId, rule]));
|
|
61
|
+
const ruleFields = new Map();
|
|
62
|
+
const gateItemFields = new Map();
|
|
63
|
+
for (const rule of rules) {
|
|
64
|
+
ruleFields.set(rule, ruleReads(compiled, rule));
|
|
65
|
+
for (const item of rule.gate?.items ?? []) {
|
|
66
|
+
gateItemFields.set(item, gateItemReads(compiled, rule, item));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const prepared = {
|
|
70
|
+
behaviorHash: behaviourOf(compiled, ruleHashes).behaviorHash,
|
|
71
|
+
ruleHashes,
|
|
72
|
+
ruleFields,
|
|
73
|
+
gateItemFields,
|
|
74
|
+
fieldsByPath,
|
|
75
|
+
fieldById: fieldsById(compiled.fields),
|
|
76
|
+
contextRoots,
|
|
77
|
+
ruleById,
|
|
78
|
+
visibility,
|
|
79
|
+
withholdable: withholdableFields(compiled.fields, compiled.onHide ?? 'preserve', visibility),
|
|
80
|
+
signatureRefusals: ruleSignatureRefusals(rules, compiled.fields),
|
|
81
|
+
writerIds: new Set(rules.flatMap((rule) => {
|
|
82
|
+
if (rule.kind !== 'compute' && rule.kind !== 'defaultCompute')
|
|
83
|
+
return [];
|
|
84
|
+
if (rule.fieldId === undefined)
|
|
85
|
+
return [];
|
|
86
|
+
// An item-scope writer owns the row member it writes; `fieldId` names the array it
|
|
87
|
+
// addresses, which no single write replaces.
|
|
88
|
+
return [rule.scope === 'item' ? (rule.targetFieldId ?? rule.fieldId) : rule.fieldId];
|
|
89
|
+
})),
|
|
90
|
+
computedOrder: computedWriterOrder(compiled, ruleById),
|
|
91
|
+
};
|
|
92
|
+
PREPARED_SCHEMAS.set(compiled, prepared);
|
|
93
|
+
return prepared;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The writers in dependency order. The derived graph is the one place that decides the order,
|
|
97
|
+
* so the evaluator and a reactive engine cannot disagree about which value is produced first.
|
|
98
|
+
*
|
|
99
|
+
* An artifact the graph refuses has no order to follow: a cycle or a duplicate writer would
|
|
100
|
+
* make the answer depend on where the walk started, so the evaluator reports those writers
|
|
101
|
+
* undetermined rather than choosing one.
|
|
102
|
+
*/
|
|
103
|
+
function computedWriterOrder(compiled, ruleById) {
|
|
104
|
+
const inspection = inspectDeps(compiled, { selfReads: 'base-value' });
|
|
105
|
+
if (!inspection.ok)
|
|
106
|
+
return undefined;
|
|
107
|
+
const order = [];
|
|
108
|
+
for (const entry of inspection.report.computed) {
|
|
109
|
+
const rule = ruleById.get(entry.ruleId);
|
|
110
|
+
if (rule !== undefined)
|
|
111
|
+
order.push(rule);
|
|
112
|
+
}
|
|
113
|
+
return order;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The host store with this artifact's version and digest pins applied.
|
|
117
|
+
*
|
|
118
|
+
* A schema declares the table versions it was compiled against; a store serving another
|
|
119
|
+
* version of one is answering from data the artifact was never checked with, so resolution
|
|
120
|
+
* goes `STALE` rather than falling back. When the store can state the digest of the version it
|
|
121
|
+
* holds, the document's canonical digest is compared with the pin as the two are paired, and a
|
|
122
|
+
* same-version republished table is refused there rather than resolved under an honest-looking
|
|
123
|
+
* report.
|
|
124
|
+
*/
|
|
125
|
+
export function pinnedLookup(compiled, port) {
|
|
126
|
+
const datasets = compiled.datasets ?? [];
|
|
127
|
+
if (port === undefined || datasets.length === 0)
|
|
128
|
+
return port;
|
|
129
|
+
return pinLookup(port, datasets);
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=prepare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../../src/eval/rule/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AASjD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAgD3D;;;;GAIG;AACH,SAAS,UAAU,CAAC,MAAgC;IAClD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC9C,MAAM,KAAK,GAAG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YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAC1B,QAAwB,EACxB,IAA4B;IAE5B,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC;IACzC,IAAI,IAAI,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7D,OAAO,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import { gateItemReads, inspectDeps, ruleReads } from '../../graph/index.js';\nimport type { ReadRef } from '../../graph/index.js';\nimport { pinLookup } from '../../lookup/pass.js';\nimport type {\n CompiledField,\n CompiledRule,\n GateItemDeclaration,\n LookupPort,\n OnHidePolicy,\n} from '../../model/types.js';\nimport type { CompiledSchema } from '../../model/schema.js';\nimport { indexContextRoots, indexFields } from '../reader.js';\nimport type { ContextRootDeclaration } from '../reader.js';\nimport { freezeTree } from '../seal.js';\nimport { ruleSignatureRefusals } from '../signature-coverage.js';\nimport { artifactVisibility } from '../visibility.js';\nimport type { VisibilityIndex } from '../visibility.js';\nimport { behaviourOf, ruleHashesOf } from './behaviour.js';\n\n/**\n * Everything an evaluation needs that depends only on the compiled artifact: its hashes,\n * the fields each rule reads, the field-path index and the declared context roots.\n *\n * None of it changes between records, and hashing a rule means a defensive walk plus\n * SHA-256, so deriving it per record made the artifact the dominant cost of an\n * evaluation. A compiled artifact is immutable once parsed — the same contract the\n * evaluator already assumes — so the identity of the object is a safe cache key.\n */\nexport interface PreparedSchema {\n readonly behaviorHash: string;\n readonly ruleHashes: ReadonlyMap<CompiledRule, string>;\n readonly ruleFields: ReadonlyMap<CompiledRule, readonly ReadRef[]>;\n readonly gateItemFields: ReadonlyMap<GateItemDeclaration, readonly ReadRef[]>;\n readonly fieldsByPath: ReadonlyMap<string, CompiledField>;\n readonly fieldById: ReadonlyMap<string, CompiledField>;\n readonly contextRoots: ReadonlyMap<string, ContextRootDeclaration>;\n readonly ruleById: ReadonlyMap<string, CompiledRule>;\n /**\n * The `visible` rules that can hide each field, container cascade included,\n *\n */\n readonly visibility: VisibilityIndex;\n /**\n * The fields whose captured value is withheld from the report when a `visible` rule hides\n * them: the declaration's own `exclude`, or the document's when it states none, and a\n * `visible` rule that can reach it. A read of one of these can put a hidden value into a\n * message parameter or a lookup key, so it is the set the reader taints.\n */\n readonly withholdable: ReadonlySet<string>;\n /**\n * The rules whose signature verification the runtime refuses, with the cause. The compiler\n * checks the same shape; a hand-built artifact reaches the evaluator without that check.\n */\n readonly signatureRefusals: ReadonlyMap<CompiledRule, string>;\n /** Every field a `compute` or `defaultCompute` rule owns. */\n readonly writerIds: ReadonlySet<string>;\n /**\n * The writers in the order their values must be produced, or `undefined` when the artifact's\n * graph has no order at all (a cycle or a second writer for one field). A hand-built artifact\n * can reach the evaluator without the compiler's refusal, so its writers fail closed instead\n * of resolving in an arbitrary order.\n */\n readonly computedOrder: readonly CompiledRule[] | undefined;\n}\n\n/**\n * The declared fields by `fieldId`. An identifier the compiler makes unique can be repeated in\n * a hand-built artifact; the last declaration wins for a policy lookup because the reader\n * already refuses a reference two declarations answer differently.\n */\nfunction fieldsById(fields: readonly CompiledField[]): ReadonlyMap<string, CompiledField> {\n const byId = new Map<string, CompiledField>();\n const visit = (members: readonly CompiledField[]): void => {\n for (const member of members) {\n byId.set(member.fieldId, member);\n visit(member.fields ?? []);\n }\n };\n visit(fields);\n return byId;\n}\n\n/**\n * The fields a report must not quote when a `visible` rule hides them: the declaration's own\n * `exclude`, the document's `exclude` when the field states none, and a `visible` rule that can\n * reach the field. A field no rule can hide is never withheld, so a `visible` check is never\n * asked about it.\n */\nfunction withholdableFields(\n fields: readonly CompiledField[],\n document: OnHidePolicy,\n visibility: VisibilityIndex,\n): ReadonlySet<string> {\n const candidates = new Set<string>();\n const visit = (members: readonly CompiledField[]): void => {\n for (const member of members) {\n const policy = member.onHide ?? document;\n if (policy === 'exclude' && visibility.byField.has(member.fieldId)) {\n candidates.add(member.fieldId);\n }\n visit(member.fields ?? []);\n }\n };\n visit(fields);\n return candidates;\n}\n\nconst PREPARED_SCHEMAS: WeakMap<CompiledSchema, PreparedSchema> = new WeakMap();\n\n/** The artifact-derived index one evaluation reads, built once per compiled schema. */\nexport function prepareSchema(compiled: CompiledSchema): PreparedSchema {\n const cached = PREPARED_SCHEMAS.get(compiled);\n if (cached !== undefined) return cached;\n // The caches key on the artifact's identity, so the artifact is frozen before anything is\n // keyed by it: a later write fails instead of leaving a `behaviorHash` that describes a\n // rule set the caller has since changed. The compiler already calls `inspectDeps`, which\n // freezes at the emission boundary; this covers an artifact built by hand.\n freezeTree(compiled);\n const fieldsByPath = indexFields(compiled.fields);\n const contextRoots = indexContextRoots(compiled.context?.roots);\n const visibility = artifactVisibility(compiled);\n\n const rules = compiled.rules ?? [];\n const ruleHashes = ruleHashesOf(compiled);\n const ruleById = new Map(rules.map((rule) => [rule.ruleId, rule]));\n const ruleFields = new Map<CompiledRule, readonly ReadRef[]>();\n const gateItemFields = new Map<GateItemDeclaration, readonly ReadRef[]>();\n for (const rule of rules) {\n ruleFields.set(rule, ruleReads(compiled, rule));\n for (const item of rule.gate?.items ?? []) {\n gateItemFields.set(item, gateItemReads(compiled, rule, item));\n }\n }\n const prepared: PreparedSchema = {\n behaviorHash: behaviourOf(compiled, ruleHashes).behaviorHash,\n ruleHashes,\n ruleFields,\n gateItemFields,\n fieldsByPath,\n fieldById: fieldsById(compiled.fields),\n contextRoots,\n ruleById,\n visibility,\n withholdable: withholdableFields(compiled.fields, compiled.onHide ?? 'preserve', visibility),\n signatureRefusals: ruleSignatureRefusals(rules, compiled.fields),\n writerIds: new Set(\n rules.flatMap((rule) => {\n if (rule.kind !== 'compute' && rule.kind !== 'defaultCompute') return [];\n if (rule.fieldId === undefined) return [];\n // An item-scope writer owns the row member it writes; `fieldId` names the array it\n // addresses, which no single write replaces.\n return [rule.scope === 'item' ? (rule.targetFieldId ?? rule.fieldId) : rule.fieldId];\n }),\n ),\n computedOrder: computedWriterOrder(compiled, ruleById),\n };\n PREPARED_SCHEMAS.set(compiled, prepared);\n return prepared;\n}\n\n/**\n * The writers in dependency order. The derived graph is the one place that decides the order,\n * so the evaluator and a reactive engine cannot disagree about which value is produced first.\n *\n * An artifact the graph refuses has no order to follow: a cycle or a duplicate writer would\n * make the answer depend on where the walk started, so the evaluator reports those writers\n * undetermined rather than choosing one.\n */\nfunction computedWriterOrder(\n compiled: CompiledSchema,\n ruleById: ReadonlyMap<string, CompiledRule>,\n): readonly CompiledRule[] | undefined {\n const inspection = inspectDeps(compiled, { selfReads: 'base-value' });\n if (!inspection.ok) return undefined;\n const order: CompiledRule[] = [];\n for (const entry of inspection.report.computed) {\n const rule = ruleById.get(entry.ruleId);\n if (rule !== undefined) order.push(rule);\n }\n return order;\n}\n\n/**\n * The host store with this artifact's version and digest pins applied.\n *\n * A schema declares the table versions it was compiled against; a store serving another\n * version of one is answering from data the artifact was never checked with, so resolution\n * goes `STALE` rather than falling back. When the store can state the digest of the version it\n * holds, the document's canonical digest is compared with the pin as the two are paired, and a\n * same-version republished table is refused there rather than resolved under an honest-looking\n * report.\n */\nexport function pinnedLookup(\n compiled: CompiledSchema,\n port: LookupPort | undefined,\n): LookupPort | undefined {\n const datasets = compiled.datasets ?? [];\n if (port === undefined || datasets.length === 0) return port;\n return pinLookup(port, datasets);\n}\n"]}
|