@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,74 @@
|
|
|
1
|
+
import type { Diagnostic, EvaluationReport, Outcome, RuleResult } from '../model/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sealing a report: the hash that binds its content, the status fold it carries, and the
|
|
4
|
+
* immutability a caller relies on.
|
|
5
|
+
*
|
|
6
|
+
* A report is the engine's record of a decision, so a consumer that mutates it holds a value
|
|
7
|
+
* whose `reportHash` no longer describes it. Freezing the tree makes the two one thing: what
|
|
8
|
+
* was hashed is what the caller can read, and a later write fails instead of quietly
|
|
9
|
+
* invalidating the evidence.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Freezes a value tree. Every object reachable from a report is the engine's own at this
|
|
13
|
+
* point — record values crossed the wire reader, which copies them, and an accepted override
|
|
14
|
+
* is built by the override reader — so freezing costs the caller nothing it owns.
|
|
15
|
+
*
|
|
16
|
+
* `seen` keeps the walk total on a tree that could not be canonicalised anyway: a cycle is
|
|
17
|
+
* refused by the hash, and this function must not turn a refusal into a stack overflow.
|
|
18
|
+
*/
|
|
19
|
+
export declare function freezeTree<T>(value: T, seen?: WeakSet<object>): T;
|
|
20
|
+
/** The number of report seals since the process started. */
|
|
21
|
+
export declare function sealsPerformed(): number;
|
|
22
|
+
/**
|
|
23
|
+
* A report body with the hash that binds it, frozen so the binding cannot be undone.
|
|
24
|
+
*
|
|
25
|
+
* The hash is taken through the trusted entry. Every leaf of a body has already crossed a
|
|
26
|
+
* boundary that validated it — a record value through the wire reader, a writer's result
|
|
27
|
+
* against its target declaration, an identifier or a version through the compiler — so the
|
|
28
|
+
* restricted profile's checks have been discharged and `canonicalizeOwned` does not repeat
|
|
29
|
+
* them. It does not skip the copy: the serialiser is still handed a shielded, prototype-less
|
|
30
|
+
* tree, because an ambient `Object.prototype.toJSON` would otherwise be reachable from an
|
|
31
|
+
* uncopied body and decide a report's bytes. The hash itself is
|
|
32
|
+
* unchanged, so a report's bytes are what they always were.
|
|
33
|
+
*/
|
|
34
|
+
export declare function sealReport(body: Omit<EvaluationReport, 'reportHash'>): EvaluationReport;
|
|
35
|
+
/** The members of a rule result the fold reads. */
|
|
36
|
+
export type FoldableResult = Pick<RuleResult, 'kind' | 'severity' | 'status'>;
|
|
37
|
+
/**
|
|
38
|
+
* One rule result's admission outcome, `RULES-1.1.5`.
|
|
39
|
+
*
|
|
40
|
+
* A `visible`, `required` or `enabled` `FAIL` states a branch — the field is hidden, the
|
|
41
|
+
* condition does not hold, or the control is not writable — so it folds as `PASS` into an
|
|
42
|
+
* admission question. Every other result is its own outcome. `rule_ok_in` folds this, and
|
|
43
|
+
* `isBlocking` is the same classification read as a predicate, so a step fold and the report
|
|
44
|
+
* status cannot disagree about one rule.
|
|
45
|
+
*/
|
|
46
|
+
export declare function admissionOutcome(result: FoldableResult): Outcome;
|
|
47
|
+
/**
|
|
48
|
+
* Whether one rule result counts against the record, `RULES-1.1.5`.
|
|
49
|
+
*
|
|
50
|
+
* Only a `block`-severity result participates, and a `FAIL` of a kind whose failure is a branch
|
|
51
|
+
* (`RULES-1.1.5`) is not a blocking fact. `UNKNOWN` and `DEFERRED` always count, because nothing
|
|
52
|
+
* was decided — and that is the classification `no_blocking(kind)` folds too (`RULES-1.1.9`), so
|
|
53
|
+
* the two queries cannot disagree about one result.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isBlocking(result: FoldableResult): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The report's status: the fold of every `block`-severity rule's status and every
|
|
58
|
+
* `block`-severity diagnostic.
|
|
59
|
+
*
|
|
60
|
+
* A diagnostic is evidence the evaluation could not resolve a fact the report rests on — a
|
|
61
|
+
* stale table, an engine error — so a `warn` rule that leaves such a diagnostic must not let
|
|
62
|
+
* the report say `PASS` over it. Every diagnostic folds as `UNKNOWN`: the engine did not
|
|
63
|
+
* decide the thing it reports, whatever the cause. Its own severity decides whether it
|
|
64
|
+
* reaches this fold, which is why a gate's `UNDETERMINED` cause is recorded at the gate's
|
|
65
|
+
* effective severity (`RULES-1.1.5`, `RULES-2.1.2`): a `warn` or `info` gate states the cause
|
|
66
|
+
* without blocking, exactly as `no_blocking` answers for it. An accepted override waives the
|
|
67
|
+
* gate-decision diagnostics it approved and passes the rest to this fold unchanged.
|
|
68
|
+
*
|
|
69
|
+
* A `FAIL` is not always a blocking fact: a `visible`, `required` or `enabled` rule states a
|
|
70
|
+
* branch, so its `FAIL` contributes nothing (`RULES-1.1.5`). An `UNKNOWN` or `DEFERRED` result of
|
|
71
|
+
* those kinds still folds, because nothing was decided.
|
|
72
|
+
*/
|
|
73
|
+
export declare function reportStatus(rules: readonly FoldableResult[], diagnostics: readonly Pick<Diagnostic, 'severity'>[]): Outcome;
|
|
74
|
+
//# sourceMappingURL=seal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../src/eval/seal.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,OAAO,EAEP,UAAU,EACX,MAAM,mBAAmB,CAAC;AAG3B;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,GAAE,OAAO,CAAC,MAAM,CAAiB,GAAG,CAAC,CAiBhF;AAaD,4DAA4D;AAC5D,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,GAAG,gBAAgB,CAGvF;AAeD,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC,CAAC;AAE9E;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAGhE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAc1D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,WAAW,EAAE,SAAS,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,GACnD,OAAO,CAST"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { canonicalHashOwned } from '../canonical/jcs.js';
|
|
2
|
+
import { andAll } from '../expr/logic.js';
|
|
3
|
+
import { assertNever } from '../model/errors.js';
|
|
4
|
+
import { isRecord } from '../model/values.js';
|
|
5
|
+
/**
|
|
6
|
+
* Sealing a report: the hash that binds its content, the status fold it carries, and the
|
|
7
|
+
* immutability a caller relies on.
|
|
8
|
+
*
|
|
9
|
+
* A report is the engine's record of a decision, so a consumer that mutates it holds a value
|
|
10
|
+
* whose `reportHash` no longer describes it. Freezing the tree makes the two one thing: what
|
|
11
|
+
* was hashed is what the caller can read, and a later write fails instead of quietly
|
|
12
|
+
* invalidating the evidence.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Freezes a value tree. Every object reachable from a report is the engine's own at this
|
|
16
|
+
* point — record values crossed the wire reader, which copies them, and an accepted override
|
|
17
|
+
* is built by the override reader — so freezing costs the caller nothing it owns.
|
|
18
|
+
*
|
|
19
|
+
* `seen` keeps the walk total on a tree that could not be canonicalised anyway: a cycle is
|
|
20
|
+
* refused by the hash, and this function must not turn a refusal into a stack overflow.
|
|
21
|
+
*/
|
|
22
|
+
export function freezeTree(value, seen = new WeakSet()) {
|
|
23
|
+
// A tree this function froze has frozen children before its parent, so a frozen node is
|
|
24
|
+
// already whole: re-walking it costs a pass over the form and the report on every keystroke.
|
|
25
|
+
if (Object.isFrozen(value))
|
|
26
|
+
return value;
|
|
27
|
+
if (Array.isArray(value)) {
|
|
28
|
+
if (seen.has(value))
|
|
29
|
+
return value;
|
|
30
|
+
seen.add(value);
|
|
31
|
+
for (const item of value)
|
|
32
|
+
freezeTree(item, seen);
|
|
33
|
+
return Object.freeze(value);
|
|
34
|
+
}
|
|
35
|
+
if (isRecord(value)) {
|
|
36
|
+
if (seen.has(value))
|
|
37
|
+
return value;
|
|
38
|
+
seen.add(value);
|
|
39
|
+
for (const member of Object.values(value))
|
|
40
|
+
freezeTree(member, seen);
|
|
41
|
+
return Object.freeze(value);
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The report seals this process has performed.
|
|
47
|
+
*
|
|
48
|
+
* The companion to `restrictedCanonicalizations`, which counts only the untrusted entry. A seal
|
|
49
|
+
* hashes through `canonicalHashOwned`, so a counted pass of zero says nothing about whether the
|
|
50
|
+
* pass sealed: this counter is how a test or a benchmark states that separately. It is a
|
|
51
|
+
* measurement hook, never an input; no decision reads it, and its reader is published on
|
|
52
|
+
* `@azx-pbc/axiom-runtime/testing` rather than a host door.
|
|
53
|
+
*/
|
|
54
|
+
let sealCount = 0;
|
|
55
|
+
/** The number of report seals since the process started. */
|
|
56
|
+
export function sealsPerformed() {
|
|
57
|
+
return sealCount;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A report body with the hash that binds it, frozen so the binding cannot be undone.
|
|
61
|
+
*
|
|
62
|
+
* The hash is taken through the trusted entry. Every leaf of a body has already crossed a
|
|
63
|
+
* boundary that validated it — a record value through the wire reader, a writer's result
|
|
64
|
+
* against its target declaration, an identifier or a version through the compiler — so the
|
|
65
|
+
* restricted profile's checks have been discharged and `canonicalizeOwned` does not repeat
|
|
66
|
+
* them. It does not skip the copy: the serialiser is still handed a shielded, prototype-less
|
|
67
|
+
* tree, because an ambient `Object.prototype.toJSON` would otherwise be reachable from an
|
|
68
|
+
* uncopied body and decide a report's bytes. The hash itself is
|
|
69
|
+
* unchanged, so a report's bytes are what they always were.
|
|
70
|
+
*/
|
|
71
|
+
export function sealReport(body) {
|
|
72
|
+
sealCount += 1;
|
|
73
|
+
return freezeTree({ ...body, reportHash: canonicalHashOwned(body) });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The rule kinds whose `FAIL` states a normal branch rather than a record failure,
|
|
77
|
+
* `RULES-1.1.5`.
|
|
78
|
+
*
|
|
79
|
+
* A `required` rule fires on `PASS` (`RULES-2.1.5`) and an `enabled` rule reports the control it
|
|
80
|
+
* leaves writable (`RULES-2.1.6`), so their `FAIL` is the branch in which the requirement or the
|
|
81
|
+
* control does not apply. A `visible` rule's `FAIL` states that the field is hidden
|
|
82
|
+
* (`RULES-2.1.4`), which is the branch the author declared the field for. All three are whole
|
|
83
|
+
* and valid records: the report states the rule's own result, and nothing stands between the
|
|
84
|
+
* record and submission.
|
|
85
|
+
*/
|
|
86
|
+
const BRANCH_FAIL_KINDS = new Set(['visible', 'required', 'enabled']);
|
|
87
|
+
/**
|
|
88
|
+
* One rule result's admission outcome, `RULES-1.1.5`.
|
|
89
|
+
*
|
|
90
|
+
* A `visible`, `required` or `enabled` `FAIL` states a branch — the field is hidden, the
|
|
91
|
+
* condition does not hold, or the control is not writable — so it folds as `PASS` into an
|
|
92
|
+
* admission question. Every other result is its own outcome. `rule_ok_in` folds this, and
|
|
93
|
+
* `isBlocking` is the same classification read as a predicate, so a step fold and the report
|
|
94
|
+
* status cannot disagree about one rule.
|
|
95
|
+
*/
|
|
96
|
+
export function admissionOutcome(result) {
|
|
97
|
+
if (result.status === 'FAIL' && BRANCH_FAIL_KINDS.has(result.kind))
|
|
98
|
+
return 'PASS';
|
|
99
|
+
return result.status;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Whether one rule result counts against the record, `RULES-1.1.5`.
|
|
103
|
+
*
|
|
104
|
+
* Only a `block`-severity result participates, and a `FAIL` of a kind whose failure is a branch
|
|
105
|
+
* (`RULES-1.1.5`) is not a blocking fact. `UNKNOWN` and `DEFERRED` always count, because nothing
|
|
106
|
+
* was decided — and that is the classification `no_blocking(kind)` folds too (`RULES-1.1.9`), so
|
|
107
|
+
* the two queries cannot disagree about one result.
|
|
108
|
+
*/
|
|
109
|
+
export function isBlocking(result) {
|
|
110
|
+
if (result.severity !== 'block')
|
|
111
|
+
return false;
|
|
112
|
+
const outcome = admissionOutcome(result);
|
|
113
|
+
switch (outcome) {
|
|
114
|
+
case 'PASS':
|
|
115
|
+
return false;
|
|
116
|
+
case 'FAIL':
|
|
117
|
+
return true;
|
|
118
|
+
case 'UNKNOWN':
|
|
119
|
+
case 'DEFERRED':
|
|
120
|
+
return true;
|
|
121
|
+
default:
|
|
122
|
+
return assertNever(outcome);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The report's status: the fold of every `block`-severity rule's status and every
|
|
127
|
+
* `block`-severity diagnostic.
|
|
128
|
+
*
|
|
129
|
+
* A diagnostic is evidence the evaluation could not resolve a fact the report rests on — a
|
|
130
|
+
* stale table, an engine error — so a `warn` rule that leaves such a diagnostic must not let
|
|
131
|
+
* the report say `PASS` over it. Every diagnostic folds as `UNKNOWN`: the engine did not
|
|
132
|
+
* decide the thing it reports, whatever the cause. Its own severity decides whether it
|
|
133
|
+
* reaches this fold, which is why a gate's `UNDETERMINED` cause is recorded at the gate's
|
|
134
|
+
* effective severity (`RULES-1.1.5`, `RULES-2.1.2`): a `warn` or `info` gate states the cause
|
|
135
|
+
* without blocking, exactly as `no_blocking` answers for it. An accepted override waives the
|
|
136
|
+
* gate-decision diagnostics it approved and passes the rest to this fold unchanged.
|
|
137
|
+
*
|
|
138
|
+
* A `FAIL` is not always a blocking fact: a `visible`, `required` or `enabled` rule states a
|
|
139
|
+
* branch, so its `FAIL` contributes nothing (`RULES-1.1.5`). An `UNKNOWN` or `DEFERRED` result of
|
|
140
|
+
* those kinds still folds, because nothing was decided.
|
|
141
|
+
*/
|
|
142
|
+
export function reportStatus(rules, diagnostics) {
|
|
143
|
+
const blocked = [];
|
|
144
|
+
for (const rule of rules) {
|
|
145
|
+
if (isBlocking(rule))
|
|
146
|
+
blocked.push(rule.status);
|
|
147
|
+
}
|
|
148
|
+
for (const diagnostic of diagnostics) {
|
|
149
|
+
if (diagnostic.severity === 'block')
|
|
150
|
+
blocked.push('UNKNOWN');
|
|
151
|
+
}
|
|
152
|
+
return andAll(blocked);
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=seal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal.js","sourceRoot":"","sources":["../../src/eval/seal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAQjD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAI,KAAQ,EAAE,IAAI,GAAoB,IAAI,OAAO,EAAE;IAC3E,wFAAwF;IACxF,6FAA6F;IAC7F,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAA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AAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC;IAClF,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,MAAsB;IAC/C,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC9C,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzC,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,MAAM;YACT,OAAO,KAAK,CAAC;QACf,KAAK,MAAM;YACT,OAAO,IAAI,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,UAAU;YACb,OAAO,IAAI,CAAC;QACd;YACE,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAgC,EAChC,WAAoD;IAEpD,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,UAAU,CAAC,IAAI,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC;IACD,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,IAAI,UAAU,CAAC,QAAQ,KAAK,OAAO;YAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC","sourcesContent":["import { canonicalHashOwned } from '../canonical/jcs.js';\nimport { andAll } from '../expr/logic.js';\nimport { assertNever } from '../model/errors.js';\nimport type {\n Diagnostic,\n EvaluationReport,\n Outcome,\n RuleKind,\n RuleResult,\n} from '../model/types.js';\nimport { isRecord } from '../model/values.js';\n\n/**\n * Sealing a report: the hash that binds its content, the status fold it carries, and the\n * immutability a caller relies on.\n *\n * A report is the engine's record of a decision, so a consumer that mutates it holds a value\n * whose `reportHash` no longer describes it. Freezing the tree makes the two one thing: what\n * was hashed is what the caller can read, and a later write fails instead of quietly\n * invalidating the evidence.\n */\n\n/**\n * Freezes a value tree. Every object reachable from a report is the engine's own at this\n * point — record values crossed the wire reader, which copies them, and an accepted override\n * is built by the override reader — so freezing costs the caller nothing it owns.\n *\n * `seen` keeps the walk total on a tree that could not be canonicalised anyway: a cycle is\n * refused by the hash, and this function must not turn a refusal into a stack overflow.\n */\nexport function freezeTree<T>(value: T, seen: WeakSet<object> = new WeakSet()): T {\n // A tree this function froze has frozen children before its parent, so a frozen node is\n // already whole: re-walking it costs a pass over the form and the report on every keystroke.\n if (Object.isFrozen(value)) return value;\n if (Array.isArray(value)) {\n if (seen.has(value)) return value;\n seen.add(value);\n for (const item of value) freezeTree(item, seen);\n return Object.freeze(value);\n }\n if (isRecord(value)) {\n if (seen.has(value)) return value;\n seen.add(value);\n for (const member of Object.values(value)) freezeTree(member, seen);\n return Object.freeze(value);\n }\n return value;\n}\n\n/**\n * The report seals this process has performed.\n *\n * The companion to `restrictedCanonicalizations`, which counts only the untrusted entry. A seal\n * hashes through `canonicalHashOwned`, so a counted pass of zero says nothing about whether the\n * pass sealed: this counter is how a test or a benchmark states that separately. It is a\n * measurement hook, never an input; no decision reads it, and its reader is published on\n * `@azx-pbc/axiom-runtime/testing` rather than a host door.\n */\nlet sealCount = 0;\n\n/** The number of report seals since the process started. */\nexport function sealsPerformed(): number {\n return sealCount;\n}\n\n/**\n * A report body with the hash that binds it, frozen so the binding cannot be undone.\n *\n * The hash is taken through the trusted entry. Every leaf of a body has already crossed a\n * boundary that validated it — a record value through the wire reader, a writer's result\n * against its target declaration, an identifier or a version through the compiler — so the\n * restricted profile's checks have been discharged and `canonicalizeOwned` does not repeat\n * them. It does not skip the copy: the serialiser is still handed a shielded, prototype-less\n * tree, because an ambient `Object.prototype.toJSON` would otherwise be reachable from an\n * uncopied body and decide a report's bytes. The hash itself is\n * unchanged, so a report's bytes are what they always were.\n */\nexport function sealReport(body: Omit<EvaluationReport, 'reportHash'>): EvaluationReport {\n sealCount += 1;\n return freezeTree({ ...body, reportHash: canonicalHashOwned(body) });\n}\n\n/**\n * The rule kinds whose `FAIL` states a normal branch rather than a record failure,\n * `RULES-1.1.5`.\n *\n * A `required` rule fires on `PASS` (`RULES-2.1.5`) and an `enabled` rule reports the control it\n * leaves writable (`RULES-2.1.6`), so their `FAIL` is the branch in which the requirement or the\n * control does not apply. A `visible` rule's `FAIL` states that the field is hidden\n * (`RULES-2.1.4`), which is the branch the author declared the field for. All three are whole\n * and valid records: the report states the rule's own result, and nothing stands between the\n * record and submission.\n */\nconst BRANCH_FAIL_KINDS: ReadonlySet<RuleKind> = new Set(['visible', 'required', 'enabled']);\n\n/** The members of a rule result the fold reads. */\nexport type FoldableResult = Pick<RuleResult, 'kind' | 'severity' | 'status'>;\n\n/**\n * One rule result's admission outcome, `RULES-1.1.5`.\n *\n * A `visible`, `required` or `enabled` `FAIL` states a branch — the field is hidden, the\n * condition does not hold, or the control is not writable — so it folds as `PASS` into an\n * admission question. Every other result is its own outcome. `rule_ok_in` folds this, and\n * `isBlocking` is the same classification read as a predicate, so a step fold and the report\n * status cannot disagree about one rule.\n */\nexport function admissionOutcome(result: FoldableResult): Outcome {\n if (result.status === 'FAIL' && BRANCH_FAIL_KINDS.has(result.kind)) return 'PASS';\n return result.status;\n}\n\n/**\n * Whether one rule result counts against the record, `RULES-1.1.5`.\n *\n * Only a `block`-severity result participates, and a `FAIL` of a kind whose failure is a branch\n * (`RULES-1.1.5`) is not a blocking fact. `UNKNOWN` and `DEFERRED` always count, because nothing\n * was decided — and that is the classification `no_blocking(kind)` folds too (`RULES-1.1.9`), so\n * the two queries cannot disagree about one result.\n */\nexport function isBlocking(result: FoldableResult): boolean {\n if (result.severity !== 'block') return false;\n const outcome = admissionOutcome(result);\n switch (outcome) {\n case 'PASS':\n return false;\n case 'FAIL':\n return true;\n case 'UNKNOWN':\n case 'DEFERRED':\n return true;\n default:\n return assertNever(outcome);\n }\n}\n\n/**\n * The report's status: the fold of every `block`-severity rule's status and every\n * `block`-severity diagnostic.\n *\n * A diagnostic is evidence the evaluation could not resolve a fact the report rests on — a\n * stale table, an engine error — so a `warn` rule that leaves such a diagnostic must not let\n * the report say `PASS` over it. Every diagnostic folds as `UNKNOWN`: the engine did not\n * decide the thing it reports, whatever the cause. Its own severity decides whether it\n * reaches this fold, which is why a gate's `UNDETERMINED` cause is recorded at the gate's\n * effective severity (`RULES-1.1.5`, `RULES-2.1.2`): a `warn` or `info` gate states the cause\n * without blocking, exactly as `no_blocking` answers for it. An accepted override waives the\n * gate-decision diagnostics it approved and passes the rest to this fold unchanged.\n *\n * A `FAIL` is not always a blocking fact: a `visible`, `required` or `enabled` rule states a\n * branch, so its `FAIL` contributes nothing (`RULES-1.1.5`). An `UNKNOWN` or `DEFERRED` result of\n * those kinds still folds, because nothing was decided.\n */\nexport function reportStatus(\n rules: readonly FoldableResult[],\n diagnostics: readonly Pick<Diagnostic, 'severity'>[],\n): Outcome {\n const blocked: Outcome[] = [];\n for (const rule of rules) {\n if (isBlocking(rule)) blocked.push(rule.status);\n }\n for (const diagnostic of diagnostics) {\n if (diagnostic.severity === 'block') blocked.push('UNKNOWN');\n }\n return andAll(blocked);\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CompiledField, CompiledRule, FieldRef } from '../model/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The rules whose signature verification the runtime refuses, with the cause it reports.
|
|
4
|
+
*
|
|
5
|
+
* Built once per artifact: the check is a walk of every rule, and an evaluation of thirty
|
|
6
|
+
* thousand records must not repeat it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ruleSignatureRefusals(rules: readonly CompiledRule[], fields: readonly CompiledField[]): ReadonlyMap<CompiledRule, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Whether a stored signature binds exactly the coverage the artifact declares, in the declared
|
|
11
|
+
* order, with no row narrowing.
|
|
12
|
+
*
|
|
13
|
+
* Order takes part in the binding, so a reordered list is a different digest, and a list with an
|
|
14
|
+
* added or missing target is not the coverage the artifact declares. A declaration names a
|
|
15
|
+
* field, never one row of it: a stored target that adds a row is a subset of what the field
|
|
16
|
+
* declares, so it would verify while leaving the other rows free to change.
|
|
17
|
+
*/
|
|
18
|
+
export declare function matchesCoverage(declared: readonly string[], covered: readonly FieldRef[]): boolean;
|
|
19
|
+
//# sourceMappingURL=signature-coverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature-coverage.d.ts","sourceRoot":"","sources":["../../src/eval/signature-coverage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EAEZ,QAAQ,EAET,MAAM,mBAAmB,CAAC;AA+I3B;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,MAAM,EAAE,SAAS,aAAa,EAAE,GAC/B,WAAW,CAAC,YAAY,EAAE,MAAM,CAAC,CAQnC;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,OAAO,EAAE,SAAS,QAAQ,EAAE,GAC3B,OAAO,CAQT"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { childNodes } from '../model/expr-children.js';
|
|
2
|
+
/**
|
|
3
|
+
* Signature coverage: what an artifact declares a signature binds, and whether a stored
|
|
4
|
+
* signature binds exactly that.
|
|
5
|
+
*
|
|
6
|
+
* Two callers ask the same question of it. The evaluator refuses a `digest(...)` that verifies a
|
|
7
|
+
* stored signature without binding the coverage that signature declares — the compiler refuses
|
|
8
|
+
* the same shape, but a hand-built `CompiledSchema` (a host's own artifact, a fixture, a stored
|
|
9
|
+
* document never compiled here) passed no such check, so the runtime refuses it instead of
|
|
10
|
+
* comparing two stored digests and calling the result verification. That refusal is a
|
|
11
|
+
* diagnostic on the rule, never a thrown error: the rule fails closed and the rest of the
|
|
12
|
+
* report still stands. Verification itself asks whether the stored targets are the declared
|
|
13
|
+
* coverage, so the answer cannot be spelled one way by a rule and another by the verifier.
|
|
14
|
+
*/
|
|
15
|
+
/** The read path that answers the artifact's own schema version. */
|
|
16
|
+
const ARTIFACT_VERSION = 'context.schema_version';
|
|
17
|
+
/** The coverage each `signature_capture` field declares, keyed by its `fieldId`. */
|
|
18
|
+
function declaredCovers(fields) {
|
|
19
|
+
const covers = new Map();
|
|
20
|
+
const visit = (members) => {
|
|
21
|
+
for (const member of members) {
|
|
22
|
+
if (member.covers !== undefined)
|
|
23
|
+
covers.set(member.fieldId, member.covers);
|
|
24
|
+
visit(member.fields ?? []);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
visit(fields);
|
|
28
|
+
return covers;
|
|
29
|
+
}
|
|
30
|
+
/** The signature whose stored `dataHash` `node` reads, or `undefined` when it reads none. */
|
|
31
|
+
function signatureOf(node) {
|
|
32
|
+
if (node.kind !== 'path')
|
|
33
|
+
return undefined;
|
|
34
|
+
const segments = node.path.split('.');
|
|
35
|
+
const member = segments[segments.length - 1];
|
|
36
|
+
const owner = segments[segments.length - 2];
|
|
37
|
+
return member === 'dataHash' ? owner : undefined;
|
|
38
|
+
}
|
|
39
|
+
/** The `fieldId` each target of a `digest(...)` call binds, in declared order. */
|
|
40
|
+
function digestTargets(node) {
|
|
41
|
+
if (node.kind !== 'call' || node.op !== 'digest')
|
|
42
|
+
return undefined;
|
|
43
|
+
const [targets] = node.args;
|
|
44
|
+
if (targets === undefined || targets.kind !== 'list')
|
|
45
|
+
return undefined;
|
|
46
|
+
const fieldIds = [];
|
|
47
|
+
for (const target of targets.items) {
|
|
48
|
+
if (target.kind !== 'path')
|
|
49
|
+
return undefined;
|
|
50
|
+
const segments = target.path.split('.');
|
|
51
|
+
const fieldId = segments[segments.length - 1];
|
|
52
|
+
if (fieldId === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
fieldIds.push(fieldId);
|
|
55
|
+
}
|
|
56
|
+
return fieldIds;
|
|
57
|
+
}
|
|
58
|
+
/** Whether a `digest` binds the artifact's dynamic schema version. */
|
|
59
|
+
function bindsArtifactVersion(node) {
|
|
60
|
+
if (node.kind !== 'call')
|
|
61
|
+
return false;
|
|
62
|
+
const version = node.args[1];
|
|
63
|
+
return version !== undefined && version.kind === 'path' && version.path === ARTIFACT_VERSION;
|
|
64
|
+
}
|
|
65
|
+
/** Whether two coverage lists name the same targets in the same order. */
|
|
66
|
+
function sameTargets(left, right) {
|
|
67
|
+
return left.length === right.length && left.every((id, index) => id === right[index]);
|
|
68
|
+
}
|
|
69
|
+
/** The refusal one comparison states, or `undefined` when it states none. */
|
|
70
|
+
function comparisonRefusal(left, right, covers) {
|
|
71
|
+
const leftSigner = signatureOf(left);
|
|
72
|
+
const rightSigner = signatureOf(right);
|
|
73
|
+
const signer = leftSigner ?? rightSigner;
|
|
74
|
+
if (signer === undefined)
|
|
75
|
+
return undefined;
|
|
76
|
+
const digest = leftSigner === undefined ? left : right;
|
|
77
|
+
const targets = digestTargets(digest);
|
|
78
|
+
if (targets === undefined) {
|
|
79
|
+
return `the comparison reads a stored \`${signer}.dataHash\`, but its other operand is not a \`digest(...)\` call; a verifier recomputes the binding instead of comparing a value some other rule computed`;
|
|
80
|
+
}
|
|
81
|
+
const declared = covers.get(signer);
|
|
82
|
+
if (declared === undefined)
|
|
83
|
+
return undefined;
|
|
84
|
+
if (!sameTargets(targets, declared)) {
|
|
85
|
+
return `signature field \`${signer}\` declares [${declared
|
|
86
|
+
.map((id) => `\`${id}\``)
|
|
87
|
+
.join(', ')}], but this \`digest\` binds [${targets
|
|
88
|
+
.map((id) => `\`${id}\``)
|
|
89
|
+
.join(', ')}]; the digest that verifies the signature must bind the declared targets in the same order`;
|
|
90
|
+
}
|
|
91
|
+
if (bindsArtifactVersion(digest))
|
|
92
|
+
return undefined;
|
|
93
|
+
return `the \`digest\` that verifies signature field \`${signer}\` does not bind \`context.schema_version\`; a rule recomputes at the artifact's own version`;
|
|
94
|
+
}
|
|
95
|
+
/** The first refusal the nodes state, in walk order. */
|
|
96
|
+
function firstRefusal(nodes, covers) {
|
|
97
|
+
for (const node of nodes) {
|
|
98
|
+
const refusal = expressionRefusal(node, covers);
|
|
99
|
+
if (refusal !== undefined)
|
|
100
|
+
return refusal;
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
/** The first refusal one expression states, in walk order. */
|
|
105
|
+
function expressionRefusal(node, covers) {
|
|
106
|
+
// `==` compares a declared target against a column, so its own refusal is asked first; every
|
|
107
|
+
// node — that one included — then descends through the one child list, which a leaf answers
|
|
108
|
+
// empty. A kind added to the union is walked here without an edit.
|
|
109
|
+
if (node.kind === 'compare' && node.op === '==') {
|
|
110
|
+
const [left, right] = node.args;
|
|
111
|
+
const refusal = comparisonRefusal(left, right, covers);
|
|
112
|
+
if (refusal !== undefined)
|
|
113
|
+
return refusal;
|
|
114
|
+
}
|
|
115
|
+
return firstRefusal(childNodes(node), covers);
|
|
116
|
+
}
|
|
117
|
+
/** Every expression slot one rule carries, so a gate item is held to the same check. */
|
|
118
|
+
function ruleExpressions(rule) {
|
|
119
|
+
const params = (record) => Object.values(record ?? {});
|
|
120
|
+
const itemExpressions = (item) => [
|
|
121
|
+
item.expr,
|
|
122
|
+
...params(item.params),
|
|
123
|
+
];
|
|
124
|
+
return [
|
|
125
|
+
rule.expr,
|
|
126
|
+
...params(rule.params),
|
|
127
|
+
...(rule.referWhen === undefined ? [] : [rule.referWhen]),
|
|
128
|
+
...(rule.gate?.items ?? []).flatMap(itemExpressions),
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The rules whose signature verification the runtime refuses, with the cause it reports.
|
|
133
|
+
*
|
|
134
|
+
* Built once per artifact: the check is a walk of every rule, and an evaluation of thirty
|
|
135
|
+
* thousand records must not repeat it.
|
|
136
|
+
*/
|
|
137
|
+
export function ruleSignatureRefusals(rules, fields) {
|
|
138
|
+
const covers = declaredCovers(fields);
|
|
139
|
+
const refusals = new Map();
|
|
140
|
+
for (const rule of rules) {
|
|
141
|
+
const refusal = firstRefusal(ruleExpressions(rule), covers);
|
|
142
|
+
if (refusal !== undefined)
|
|
143
|
+
refusals.set(rule, refusal);
|
|
144
|
+
}
|
|
145
|
+
return refusals;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Whether a stored signature binds exactly the coverage the artifact declares, in the declared
|
|
149
|
+
* order, with no row narrowing.
|
|
150
|
+
*
|
|
151
|
+
* Order takes part in the binding, so a reordered list is a different digest, and a list with an
|
|
152
|
+
* added or missing target is not the coverage the artifact declares. A declaration names a
|
|
153
|
+
* field, never one row of it: a stored target that adds a row is a subset of what the field
|
|
154
|
+
* declares, so it would verify while leaving the other rows free to change.
|
|
155
|
+
*/
|
|
156
|
+
export function matchesCoverage(declared, covered) {
|
|
157
|
+
return (declared.length === covered.length &&
|
|
158
|
+
declared.every((fieldId, index) => fieldId === covered[index]?.fieldId && covered[index]?.rowKey === undefined));
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=signature-coverage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature-coverage.js","sourceRoot":"","sources":["../../src/eval/signature-coverage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AASvD;;;;;;;;;;;;GAYG;AAEH,oEAAoE;AACpE,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAElD,oFAAoF;AACpF,SAAS,cAAc,CAAC,MAAgC;IACtD,MAAM,MAAM,GAAG,IAAI,GAAG,EAA6B,CAAC;IACpD,MAAM,KAAK,GAAG,CAAC,OAAiC,EAAQ,EAAE;QACxD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,CAAC,M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G,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,QAA2B,EAC3B,OAA4B;IAE5B,OAAO,CACL,QAAQ,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;QAClC,QAAQ,CAAC,KAAK,CACZ,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CACjB,OAAO,KAAK,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,SAAS,CAC9E,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { childNodes } from '../model/expr-children.js';\nimport type {\n CompiledField,\n CompiledRule,\n ExprNode,\n FieldRef,\n GateItemDeclaration,\n} from '../model/types.js';\n\n/**\n * Signature coverage: what an artifact declares a signature binds, and whether a stored\n * signature binds exactly that.\n *\n * Two callers ask the same question of it. The evaluator refuses a `digest(...)` that verifies a\n * stored signature without binding the coverage that signature declares — the compiler refuses\n * the same shape, but a hand-built `CompiledSchema` (a host's own artifact, a fixture, a stored\n * document never compiled here) passed no such check, so the runtime refuses it instead of\n * comparing two stored digests and calling the result verification. That refusal is a\n * diagnostic on the rule, never a thrown error: the rule fails closed and the rest of the\n * report still stands. Verification itself asks whether the stored targets are the declared\n * coverage, so the answer cannot be spelled one way by a rule and another by the verifier.\n */\n\n/** The read path that answers the artifact's own schema version. */\nconst ARTIFACT_VERSION = 'context.schema_version';\n\n/** The coverage each `signature_capture` field declares, keyed by its `fieldId`. */\nfunction declaredCovers(fields: readonly CompiledField[]): ReadonlyMap<string, readonly string[]> {\n const covers = new Map<string, readonly string[]>();\n const visit = (members: readonly CompiledField[]): void => {\n for (const member of members) {\n if (member.covers !== undefined) covers.set(member.fieldId, member.covers);\n visit(member.fields ?? []);\n }\n };\n visit(fields);\n return covers;\n}\n\n/** The signature whose stored `dataHash` `node` reads, or `undefined` when it reads none. */\nfunction signatureOf(node: ExprNode): string | undefined {\n if (node.kind !== 'path') return undefined;\n const segments = node.path.split('.');\n const member = segments[segments.length - 1];\n const owner = segments[segments.length - 2];\n return member === 'dataHash' ? owner : undefined;\n}\n\n/** The `fieldId` each target of a `digest(...)` call binds, in declared order. */\nfunction digestTargets(node: ExprNode): readonly string[] | undefined {\n if (node.kind !== 'call' || node.op !== 'digest') return undefined;\n const [targets] = node.args;\n if (targets === undefined || targets.kind !== 'list') return undefined;\n const fieldIds: string[] = [];\n for (const target of targets.items) {\n if (target.kind !== 'path') return undefined;\n const segments = target.path.split('.');\n const fieldId = segments[segments.length - 1];\n if (fieldId === undefined) return undefined;\n fieldIds.push(fieldId);\n }\n return fieldIds;\n}\n\n/** Whether a `digest` binds the artifact's dynamic schema version. */\nfunction bindsArtifactVersion(node: ExprNode): boolean {\n if (node.kind !== 'call') return false;\n const version = node.args[1];\n return version !== undefined && version.kind === 'path' && version.path === ARTIFACT_VERSION;\n}\n\n/** Whether two coverage lists name the same targets in the same order. */\nfunction sameTargets(left: readonly string[], right: readonly string[]): boolean {\n return left.length === right.length && left.every((id, index) => id === right[index]);\n}\n\n/** The refusal one comparison states, or `undefined` when it states none. */\nfunction comparisonRefusal(\n left: ExprNode,\n right: ExprNode,\n covers: ReadonlyMap<string, readonly string[]>,\n): string | undefined {\n const leftSigner = signatureOf(left);\n const rightSigner = signatureOf(right);\n const signer = leftSigner ?? rightSigner;\n if (signer === undefined) return undefined;\n const digest = leftSigner === undefined ? left : right;\n const targets = digestTargets(digest);\n if (targets === undefined) {\n return `the comparison reads a stored \\`${signer}.dataHash\\`, but its other operand is not a \\`digest(...)\\` call; a verifier recomputes the binding instead of comparing a value some other rule computed`;\n }\n const declared = covers.get(signer);\n if (declared === undefined) return undefined;\n if (!sameTargets(targets, declared)) {\n return `signature field \\`${signer}\\` declares [${declared\n .map((id) => `\\`${id}\\``)\n .join(', ')}], but this \\`digest\\` binds [${targets\n .map((id) => `\\`${id}\\``)\n .join(\n ', ',\n )}]; the digest that verifies the signature must bind the declared targets in the same order`;\n }\n if (bindsArtifactVersion(digest)) return undefined;\n return `the \\`digest\\` that verifies signature field \\`${signer}\\` does not bind \\`context.schema_version\\`; a rule recomputes at the artifact's own version`;\n}\n\n/** The first refusal the nodes state, in walk order. */\nfunction firstRefusal(\n nodes: readonly ExprNode[],\n covers: ReadonlyMap<string, readonly string[]>,\n): string | undefined {\n for (const node of nodes) {\n const refusal = expressionRefusal(node, covers);\n if (refusal !== undefined) return refusal;\n }\n return undefined;\n}\n\n/** The first refusal one expression states, in walk order. */\nfunction expressionRefusal(\n node: ExprNode,\n covers: ReadonlyMap<string, readonly string[]>,\n): string | undefined {\n // `==` compares a declared target against a column, so its own refusal is asked first; every\n // node — that one included — then descends through the one child list, which a leaf answers\n // empty. A kind added to the union is walked here without an edit.\n if (node.kind === 'compare' && node.op === '==') {\n const [left, right] = node.args;\n const refusal = comparisonRefusal(left, right, covers);\n if (refusal !== undefined) return refusal;\n }\n return firstRefusal(childNodes(node), covers);\n}\n\n/** Every expression slot one rule carries, so a gate item is held to the same check. */\nfunction ruleExpressions(rule: CompiledRule): readonly ExprNode[] {\n const params = (record: Readonly<Record<string, ExprNode>> | undefined): readonly ExprNode[] =>\n Object.values(record ?? {});\n const itemExpressions = (item: GateItemDeclaration): readonly ExprNode[] => [\n item.expr,\n ...params(item.params),\n ];\n return [\n rule.expr,\n ...params(rule.params),\n ...(rule.referWhen === undefined ? [] : [rule.referWhen]),\n ...(rule.gate?.items ?? []).flatMap(itemExpressions),\n ];\n}\n\n/**\n * The rules whose signature verification the runtime refuses, with the cause it reports.\n *\n * Built once per artifact: the check is a walk of every rule, and an evaluation of thirty\n * thousand records must not repeat it.\n */\nexport function ruleSignatureRefusals(\n rules: readonly CompiledRule[],\n fields: readonly CompiledField[],\n): ReadonlyMap<CompiledRule, string> {\n const covers = declaredCovers(fields);\n const refusals = new Map<CompiledRule, string>();\n for (const rule of rules) {\n const refusal = firstRefusal(ruleExpressions(rule), covers);\n if (refusal !== undefined) refusals.set(rule, refusal);\n }\n return refusals;\n}\n\n/**\n * Whether a stored signature binds exactly the coverage the artifact declares, in the declared\n * order, with no row narrowing.\n *\n * Order takes part in the binding, so a reordered list is a different digest, and a list with an\n * added or missing target is not the coverage the artifact declares. A declaration names a\n * field, never one row of it: a stored target that adds a row is a subset of what the field\n * declares, so it would verify while leaving the other rows free to change.\n */\nexport function matchesCoverage(\n declared: readonly string[],\n covered: readonly FieldRef[],\n): boolean {\n return (\n declared.length === covered.length &&\n declared.every(\n (fieldId, index) =>\n fieldId === covered[index]?.fieldId && covered[index]?.rowKey === undefined,\n )\n );\n}\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ReportFacts } from '../../model/types.js';
|
|
2
|
+
import type { CompiledSchema } from '../../model/schema.js';
|
|
3
|
+
import type { FormFieldState } from './field-state.js';
|
|
4
|
+
import type { FormStateOptions } from './options.js';
|
|
5
|
+
import type { FormBlocker, FormGateState, FormScreenState, FormSkippedCheck, FormUndeterminedCheck, FormUndeterminedComputation, Readiness, SubmissionVerdict } from './readiness.js';
|
|
6
|
+
import type { FormSnapshot } from './snapshot.js';
|
|
7
|
+
/**
|
|
8
|
+
* The derived form state every consumer reads, `[ENGINE-7.1.5]`.
|
|
9
|
+
*
|
|
10
|
+
* It is a pure function of one evaluation: the report it states, the fields it decided, the
|
|
11
|
+
* gates and screens it folded, and a readiness answer that is deliberately not the report's
|
|
12
|
+
* own status. `describeFormState` and `deriveFormState` both produce it; the first evaluates
|
|
13
|
+
* the record, the second reads a snapshot a caller already holds.
|
|
14
|
+
*/
|
|
15
|
+
export interface FormState {
|
|
16
|
+
/** The report body the fields were derived from; its digest is the report entry point's. */
|
|
17
|
+
readonly report: ReportFacts;
|
|
18
|
+
readonly fields: readonly FormFieldState[];
|
|
19
|
+
readonly gates: readonly FormGateState[];
|
|
20
|
+
readonly screens: readonly FormScreenState[];
|
|
21
|
+
readonly blockers: readonly FormBlocker[];
|
|
22
|
+
/** Local readiness. A fact behind `verdict`, never permission on its own. */
|
|
23
|
+
readonly ready: boolean;
|
|
24
|
+
readonly hasDeferredChecks: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Every block-severity check this device could not decide, in declaration order.
|
|
27
|
+
*
|
|
28
|
+
* `hasUndeterminedChecks` is the predicate, stated beside the list because a form can be
|
|
29
|
+
* `BLOCKED` and undecided at once; it is not a second flag for the list's emptiness.
|
|
30
|
+
*/
|
|
31
|
+
readonly undeterminedChecks: readonly FormUndeterminedCheck[];
|
|
32
|
+
readonly hasUndeterminedChecks: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Every check the access answer skipped, `RULES-2.1.1`.
|
|
35
|
+
*
|
|
36
|
+
* A host that paints a rule result list leaves these out: the report still states `UNKNOWN`
|
|
37
|
+
* because the sealed contract does not move, and counting one as unanswered would show a
|
|
38
|
+
* question no respondent can answer.
|
|
39
|
+
*/
|
|
40
|
+
readonly skippedChecks: readonly FormSkippedCheck[];
|
|
41
|
+
/** Every computed value the engine could not decide. Informational, never a refusal. */
|
|
42
|
+
readonly undeterminedComputations: readonly FormUndeterminedComputation[];
|
|
43
|
+
/** The one verdict a host gates a submission on, `[ENGINE-7.1.5]`. */
|
|
44
|
+
readonly verdict: SubmissionVerdict;
|
|
45
|
+
}
|
|
46
|
+
/** What a caller may supply that the artifact cannot derive. */
|
|
47
|
+
export type { FormStateOptions } from './options.js';
|
|
48
|
+
/**
|
|
49
|
+
* The entries one pass may carry over, and the fields whose facts the commit may have moved.
|
|
50
|
+
*
|
|
51
|
+
* `previous` is the field list the caller last derived for the same compiled artifact, and
|
|
52
|
+
* `affected` is every field whose entry the change could have moved: the written fields, their
|
|
53
|
+
* ancestors and descendants, the targets of every rule the closure re-evaluated, and every
|
|
54
|
+
* field when the access answer or the environment changed. A field outside the set is reused
|
|
55
|
+
* whole; a pass that supplied an incomplete set would state a stale entry.
|
|
56
|
+
*/
|
|
57
|
+
export interface DerivedFieldReuse {
|
|
58
|
+
readonly previous: readonly FormFieldState[];
|
|
59
|
+
readonly affected: ReadonlySet<string> | 'all';
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Derives one form's state from a snapshot an evaluation already produced.
|
|
63
|
+
*
|
|
64
|
+
* This is the stateless half of `describeFormState`, for a host that already holds the
|
|
65
|
+
* snapshot — an engine turn, a scenario runner, a review pass — so it neither re-evaluates
|
|
66
|
+
* the record nor resolves a second access answer. A parity test pins that the two entry
|
|
67
|
+
* points agree.
|
|
68
|
+
*/
|
|
69
|
+
export declare function deriveFormState(compiled: CompiledSchema, evaluated: FormSnapshot, options?: FormStateOptions, reuse?: DerivedFieldReuse): FormState;
|
|
70
|
+
/** The admission subset of one derived state: what a host reads to decide whether to submit. */
|
|
71
|
+
export declare function readinessOf(form: FormState): Readiness;
|
|
72
|
+
//# sourceMappingURL=derive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../../src/eval/state/derive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,2BAA2B,EAC3B,SAAS,EACT,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,4FAA4F;IAC5F,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,c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OPTIONS } from './options.js';
|
|
3
|
+
import { deriveReadiness } from './readiness.js';
|
|
4
|
+
/**
|
|
5
|
+
* Derives one form's state from a snapshot an evaluation already produced.
|
|
6
|
+
*
|
|
7
|
+
* This is the stateless half of `describeFormState`, for a host that already holds the
|
|
8
|
+
* snapshot — an engine turn, a scenario runner, a review pass — so it neither re-evaluates
|
|
9
|
+
* the record nor resolves a second access answer. A parity test pins that the two entry
|
|
10
|
+
* points agree.
|
|
11
|
+
*/
|
|
12
|
+
export function deriveFormState(compiled, evaluated, options = NO_FORM_STATE_OPTIONS, reuse) {
|
|
13
|
+
const redacted = evaluated.access.redactedFields();
|
|
14
|
+
const rules = indexDerivedRules(compiled, evaluated.report, evaluated.undecided);
|
|
15
|
+
const context = {
|
|
16
|
+
compiled,
|
|
17
|
+
snapshot: evaluated,
|
|
18
|
+
rules,
|
|
19
|
+
options,
|
|
20
|
+
redacted,
|
|
21
|
+
// The writer targets are per artifact, not per record: one pass over its rules serves every
|
|
22
|
+
// field that asks whether a writer owns it.
|
|
23
|
+
writers: writerTargetsOf(compiled),
|
|
24
|
+
// A field inside a hidden section is off-screen for the same reason a hidden field is:
|
|
25
|
+
// readiness must not accuse a respondent of a control the page does not paint.
|
|
26
|
+
layoutHidden: evaluated.layoutHidden,
|
|
27
|
+
};
|
|
28
|
+
const fields = deriveFields(context, reuse === undefined
|
|
29
|
+
? undefined
|
|
30
|
+
: {
|
|
31
|
+
previous: new Map(reuse.previous.map((field) => [field.fieldId, field])),
|
|
32
|
+
affected: reuse.affected,
|
|
33
|
+
});
|
|
34
|
+
const readiness = deriveReadiness(compiled, evaluated, fields, rules, options);
|
|
35
|
+
return {
|
|
36
|
+
report: evaluated.report,
|
|
37
|
+
fields,
|
|
38
|
+
gates: readiness.gates,
|
|
39
|
+
screens: readiness.screens,
|
|
40
|
+
blockers: readiness.blockers,
|
|
41
|
+
ready: readiness.ready,
|
|
42
|
+
hasDeferredChecks: readiness.hasDeferredChecks,
|
|
43
|
+
undeterminedChecks: readiness.undeterminedChecks,
|
|
44
|
+
hasUndeterminedChecks: readiness.hasUndeterminedChecks,
|
|
45
|
+
skippedChecks: readiness.skippedChecks,
|
|
46
|
+
undeterminedComputations: readiness.undeterminedComputations,
|
|
47
|
+
verdict: readiness.verdict,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** The admission subset of one derived state: what a host reads to decide whether to submit. */
|
|
51
|
+
export function readinessOf(form) {
|
|
52
|
+
return {
|
|
53
|
+
verdict: form.verdict,
|
|
54
|
+
ready: form.ready,
|
|
55
|
+
blockers: form.blockers,
|
|
56
|
+
undeterminedChecks: form.undeterminedChecks,
|
|
57
|
+
skippedChecks: form.skippedChecks,
|
|
58
|
+
hasDeferredChecks: form.hasDeferredChecks,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=derive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive.js","sourceRoot":"","sources":["../../../src/eval/state/derive.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAsEjD;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAwB,EACxB,SAAuB,EACvB,OAAO,GAAqB,qBAAqB,EACjD,KAAyB;IAEzB,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;IACnD,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjF,MAAM,OAAO,GAAG;QACd,QAAQ;QACR,QAAQ,EAAE,SAAS;QACnB,KAAK;QACL,OAAO;QACP,QAAQ;QACR,4FAA4F;QAC5F,4CAA4C;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,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;KAC1C,CAAC;AACJ,CAAC","sourcesContent":["import type { ReportFacts } from '../../model/types.js';\nimport type { CompiledSchema } from '../../model/schema.js';\nimport { deriveFields, indexDerivedRules, writerTargetsOf } from './field-state.js';\nimport type { FormFieldState } from './field-state.js';\nimport { NO_FORM_STATE_OPTIONS } from './options.js';\nimport type { FormStateOptions } from './options.js';\nimport { deriveReadiness } from './readiness.js';\nimport type {\n FormBlocker,\n FormGateState,\n FormScreenState,\n FormSkippedCheck,\n FormUndeterminedCheck,\n FormUndeterminedComputation,\n Readiness,\n SubmissionVerdict,\n} from './readiness.js';\nimport type { FormSnapshot } from './snapshot.js';\n\n/**\n * The derived form state every consumer reads, `[ENGINE-7.1.5]`.\n *\n * It is a pure function of one evaluation: the report it states, the fields it decided, the\n * gates and screens it folded, and a readiness answer that is deliberately not the report's\n * own status. `describeFormState` and `deriveFormState` both produce it; the first evaluates\n * the record, the second reads a snapshot a caller already holds.\n */\nexport interface FormState {\n /** The report body the fields were derived from; its digest is the report entry point's. */\n readonly report: ReportFacts;\n readonly fields: readonly FormFieldState[];\n readonly gates: readonly FormGateState[];\n readonly screens: readonly FormScreenState[];\n readonly blockers: readonly FormBlocker[];\n /** Local readiness. A fact behind `verdict`, never permission on its own. */\n readonly ready: boolean;\n readonly hasDeferredChecks: boolean;\n /**\n * Every block-severity check this device could not decide, in declaration order.\n *\n * `hasUndeterminedChecks` is the predicate, stated beside the list because a form can be\n * `BLOCKED` and undecided at once; it is not a second flag for the list's emptiness.\n */\n readonly undeterminedChecks: readonly FormUndeterminedCheck[];\n readonly hasUndeterminedChecks: boolean;\n /**\n * Every check the access answer skipped, `RULES-2.1.1`.\n *\n * A host that paints a rule result list leaves these out: the report still states `UNKNOWN`\n * because the sealed contract does not move, and counting one as unanswered would show a\n * question no respondent can answer.\n */\n readonly skippedChecks: readonly FormSkippedCheck[];\n /** Every computed value the engine could not decide. Informational, never a refusal. */\n readonly undeterminedComputations: readonly FormUndeterminedComputation[];\n /** The one verdict a host gates a submission on, `[ENGINE-7.1.5]`. */\n readonly verdict: SubmissionVerdict;\n}\n\n/** What a caller may supply that the artifact cannot derive. */\nexport type { FormStateOptions } from './options.js';\n\n/**\n * The entries one pass may carry over, and the fields whose facts the commit may have moved.\n *\n * `previous` is the field list the caller last derived for the same compiled artifact, and\n * `affected` is every field whose entry the change could have moved: the written fields, their\n * ancestors and descendants, the targets of every rule the closure re-evaluated, and every\n * field when the access answer or the environment changed. A field outside the set is reused\n * whole; a pass that supplied an incomplete set would state a stale entry.\n */\nexport interface DerivedFieldReuse {\n readonly previous: readonly FormFieldState[];\n readonly affected: ReadonlySet<string> | 'all';\n}\n\n/**\n * Derives one form's state from a snapshot an evaluation already produced.\n *\n * This is the stateless half of `describeFormState`, for a host that already holds the\n * snapshot — an engine turn, a scenario runner, a review pass — so it neither re-evaluates\n * the record nor resolves a second access answer. A parity test pins that the two entry\n * points agree.\n */\nexport function deriveFormState(\n compiled: CompiledSchema,\n evaluated: FormSnapshot,\n options: FormStateOptions = NO_FORM_STATE_OPTIONS,\n reuse?: DerivedFieldReuse,\n): FormState {\n const redacted = evaluated.access.redactedFields();\n const rules = indexDerivedRules(compiled, evaluated.report, evaluated.undecided);\n const context = {\n compiled,\n snapshot: evaluated,\n rules,\n options,\n redacted,\n // The writer targets are per artifact, not per record: one pass over its rules serves every\n // field that asks whether a writer owns it.\n writers: writerTargetsOf(compiled),\n // A field inside a hidden section is off-screen for the same reason a hidden field is:\n // readiness must not accuse a respondent of a control the page does not paint.\n layoutHidden: evaluated.layoutHidden,\n };\n const fields = deriveFields(\n context,\n reuse === undefined\n ? undefined\n : {\n previous: new Map(reuse.previous.map((field) => [field.fieldId, field] as const)),\n affected: reuse.affected,\n },\n );\n const readiness = deriveReadiness(compiled, evaluated, fields, rules, options);\n return {\n report: evaluated.report,\n fields,\n gates: readiness.gates,\n screens: readiness.screens,\n blockers: readiness.blockers,\n ready: readiness.ready,\n hasDeferredChecks: readiness.hasDeferredChecks,\n undeterminedChecks: readiness.undeterminedChecks,\n hasUndeterminedChecks: readiness.hasUndeterminedChecks,\n skippedChecks: readiness.skippedChecks,\n undeterminedComputations: readiness.undeterminedComputations,\n verdict: readiness.verdict,\n };\n}\n\n/** The admission subset of one derived state: what a host reads to decide whether to submit. */\nexport function readinessOf(form: FormState): Readiness {\n return {\n verdict: form.verdict,\n ready: form.ready,\n blockers: form.blockers,\n undeterminedChecks: form.undeterminedChecks,\n skippedChecks: form.skippedChecks,\n hasDeferredChecks: form.hasDeferredChecks,\n };\n}\n"]}
|