gdp-wired 0.47.0 → 0.49.0
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/README.md +17 -6
- package/dist/core/bmc.js +10 -7
- package/dist/core/carry.d.ts +15 -0
- package/dist/core/carry.js +651 -0
- package/dist/core/check.js +7 -2
- package/dist/core/cli.d.ts +3 -1
- package/dist/core/cli.js +28 -8
- package/dist/core/count-attempt-work.d.ts +29 -0
- package/dist/core/count-attempt-work.js +96 -0
- package/dist/core/count-boolean-partition.d.ts +5 -0
- package/dist/core/count-boolean-partition.js +47 -0
- package/dist/core/count-bounded-quotient.d.ts +2 -0
- package/dist/core/count-bounded-quotient.js +13 -0
- package/dist/core/count-case-compose.d.ts +20 -0
- package/dist/core/count-case-compose.js +289 -0
- package/dist/core/count-cases.d.ts +24 -0
- package/dist/core/count-cases.js +321 -0
- package/dist/core/count-cert-grow.d.ts +4 -0
- package/dist/core/count-cert-grow.js +37 -0
- package/dist/core/count-cert-rename.d.ts +10 -0
- package/dist/core/count-cert-rename.js +69 -0
- package/dist/core/count-cert-transport.d.ts +11 -0
- package/dist/core/count-cert-transport.js +109 -0
- package/dist/core/count-certificate-minimize.d.ts +57 -0
- package/dist/core/count-certificate-minimize.js +263 -0
- package/dist/core/count-closed-family.d.ts +32 -0
- package/dist/core/count-closed-family.js +143 -0
- package/dist/core/count-closing-budget.d.ts +10 -0
- package/dist/core/count-closing-budget.js +49 -0
- package/dist/core/count-closing-needs.d.ts +5 -0
- package/dist/core/count-closing-needs.js +9 -0
- package/dist/core/count-completion.d.ts +9 -0
- package/dist/core/count-completion.js +27 -0
- package/dist/core/count-component-budget.d.ts +5 -0
- package/dist/core/count-component-budget.js +9 -0
- package/dist/core/count-copy-shape.d.ts +11 -0
- package/dist/core/count-copy-shape.js +40 -0
- package/dist/core/count-cubes.d.ts +8 -0
- package/dist/core/count-cubes.js +69 -0
- package/dist/core/count-demand.d.ts +37 -0
- package/dist/core/count-demand.js +361 -0
- package/dist/core/count-disjoint-funding.d.ts +75 -0
- package/dist/core/count-disjoint-funding.js +284 -0
- package/dist/core/count-emitter-frame-pool.d.ts +23 -0
- package/dist/core/count-emitter-frame-pool.js +87 -0
- package/dist/core/count-facts.d.ts +52 -0
- package/dist/core/count-facts.js +247 -0
- package/dist/core/count-final-step.d.ts +5 -0
- package/dist/core/count-final-step.js +20 -0
- package/dist/core/count-fixed-frame.d.ts +4 -0
- package/dist/core/count-fixed-frame.js +30 -0
- package/dist/core/count-focus-proof.d.ts +8 -0
- package/dist/core/count-focus-proof.js +140 -0
- package/dist/core/count-focused.d.ts +22 -0
- package/dist/core/count-focused.js +676 -0
- package/dist/core/count-frames.d.ts +25 -0
- package/dist/core/count-frames.js +118 -0
- package/dist/core/count-frozen-guard.d.ts +2 -0
- package/dist/core/count-frozen-guard.js +31 -0
- package/dist/core/count-generation-phase.d.ts +7 -0
- package/dist/core/count-generation-phase.js +33 -0
- package/dist/core/count-guard-composition.d.ts +12 -0
- package/dist/core/count-guard-composition.js +48 -0
- package/dist/core/count-guard-context.d.ts +11 -0
- package/dist/core/count-guard-context.js +50 -0
- package/dist/core/count-guard-facts.d.ts +50 -0
- package/dist/core/count-guard-facts.js +97 -0
- package/dist/core/count-guard-proposals.d.ts +7 -0
- package/dist/core/count-guard-proposals.js +106 -0
- package/dist/core/count-guard-shape.d.ts +18 -0
- package/dist/core/count-guard-shape.js +100 -0
- package/dist/core/count-guard-tree.d.ts +17 -0
- package/dist/core/count-guard-tree.js +125 -0
- package/dist/core/count-leader-facts.d.ts +10 -0
- package/dist/core/count-leader-facts.js +52 -0
- package/dist/core/count-leader.d.ts +10 -0
- package/dist/core/count-leader.js +331 -0
- package/dist/core/count-lemma-transport.d.ts +8 -0
- package/dist/core/count-lemma-transport.js +47 -0
- package/dist/core/count-lifted-budget.d.ts +54 -0
- package/dist/core/count-lifted-budget.js +97 -0
- package/dist/core/count-lifted-copy.d.ts +3 -0
- package/dist/core/count-lifted-copy.js +166 -0
- package/dist/core/count-lifted-increment.d.ts +3 -0
- package/dist/core/count-lifted-increment.js +146 -0
- package/dist/core/count-lifted-load.d.ts +5 -0
- package/dist/core/count-lifted-load.js +179 -0
- package/dist/core/count-lifted-prerequisite.d.ts +14 -0
- package/dist/core/count-lifted-prerequisite.js +53 -0
- package/dist/core/count-lifted-replacement.d.ts +3 -0
- package/dist/core/count-lifted-replacement.js +540 -0
- package/dist/core/count-lifted-shape.d.ts +63 -0
- package/dist/core/count-lifted-shape.js +115 -0
- package/dist/core/count-lifted-strategy.d.ts +7 -0
- package/dist/core/count-lifted-strategy.js +226 -0
- package/dist/core/count-lifted-transports.d.ts +32 -0
- package/dist/core/count-lifted-transports.js +293 -0
- package/dist/core/count-load-shape.d.ts +17 -0
- package/dist/core/count-load-shape.js +67 -0
- package/dist/core/count-minimal-view.d.ts +26 -0
- package/dist/core/count-minimal-view.js +46 -0
- package/dist/core/count-operation-observation.d.ts +9 -0
- package/dist/core/count-operation-observation.js +22 -0
- package/dist/core/count-operation-order.d.ts +5 -0
- package/dist/core/count-operation-order.js +4 -0
- package/dist/core/count-phase.d.ts +9 -0
- package/dist/core/count-phase.js +127 -0
- package/dist/core/count-premise-search.d.ts +9 -0
- package/dist/core/count-premise-search.js +41 -0
- package/dist/core/count-premise-view.d.ts +19 -0
- package/dist/core/count-premise-view.js +220 -0
- package/dist/core/count-prerequisite-components.d.ts +67 -0
- package/dist/core/count-prerequisite-components.js +239 -0
- package/dist/core/count-prerequisite-memory.d.ts +24 -0
- package/dist/core/count-prerequisite-memory.js +37 -0
- package/dist/core/count-prerequisite-plan.d.ts +12 -0
- package/dist/core/count-prerequisite-plan.js +88 -0
- package/dist/core/count-primitive-budget.d.ts +1 -0
- package/dist/core/count-primitive-budget.js +8 -0
- package/dist/core/count-project-free.d.ts +3 -0
- package/dist/core/count-project-free.js +24 -0
- package/dist/core/count-project-witness.d.ts +4 -0
- package/dist/core/count-project-witness.js +48 -0
- package/dist/core/count-proof-rescope.d.ts +14 -0
- package/dist/core/count-proof-rescope.js +71 -0
- package/dist/core/count-proof-scope.d.ts +68 -0
- package/dist/core/count-proof-scope.js +333 -0
- package/dist/core/count-prune-owned-root.d.ts +5 -0
- package/dist/core/count-prune-owned-root.js +27 -0
- package/dist/core/count-query-context.d.ts +3 -0
- package/dist/core/count-query-context.js +7 -0
- package/dist/core/count-query.d.ts +15 -0
- package/dist/core/count-query.js +59 -0
- package/dist/core/count-quorum-leaf.d.ts +9 -0
- package/dist/core/count-quorum-leaf.js +38 -0
- package/dist/core/count-ranges.d.ts +5 -0
- package/dist/core/count-ranges.js +65 -0
- package/dist/core/count-reachability-budget.d.ts +1 -0
- package/dist/core/count-reachability-budget.js +7 -0
- package/dist/core/count-reachability-reconcile.d.ts +11 -0
- package/dist/core/count-reachability-reconcile.js +19 -0
- package/dist/core/count-reachability.d.ts +50 -0
- package/dist/core/count-reachability.js +351 -0
- package/dist/core/count-rebase-path.d.ts +9 -0
- package/dist/core/count-rebase-path.js +68 -0
- package/dist/core/count-recipe-context.d.ts +45 -0
- package/dist/core/count-recipe-context.js +71 -0
- package/dist/core/count-recipe-controller.d.ts +115 -0
- package/dist/core/count-recipe-controller.js +417 -0
- package/dist/core/count-recipe-graph.d.ts +36 -0
- package/dist/core/count-recipe-graph.js +211 -0
- package/dist/core/count-recovery/action-guard.d.ts +5 -0
- package/dist/core/count-recovery/action-guard.js +51 -0
- package/dist/core/count-recovery/boolean-core.d.ts +16 -0
- package/dist/core/count-recovery/boolean-core.js +258 -0
- package/dist/core/count-recovery/carried-case.d.ts +2 -0
- package/dist/core/count-recovery/carried-case.js +24 -0
- package/dist/core/count-recovery/conditional-check-cache.d.ts +23 -0
- package/dist/core/count-recovery/conditional-check-cache.js +131 -0
- package/dist/core/count-recovery/conditional-cuts.d.ts +6 -0
- package/dist/core/count-recovery/conditional-cuts.js +319 -0
- package/dist/core/count-recovery/conditional-proof.d.ts +53 -0
- package/dist/core/count-recovery/conditional-proof.js +348 -0
- package/dist/core/count-recovery/derivability-closure.d.ts +14 -0
- package/dist/core/count-recovery/derivability-closure.js +534 -0
- package/dist/core/count-recovery/empty-count-source.d.ts +2 -0
- package/dist/core/count-recovery/empty-count-source.js +40 -0
- package/dist/core/count-recovery/field-bound-lemmas.d.ts +23 -0
- package/dist/core/count-recovery/field-bound-lemmas.js +640 -0
- package/dist/core/count-recovery/field-case.d.ts +5 -0
- package/dist/core/count-recovery/field-case.js +89 -0
- package/dist/core/count-recovery/field-demand.d.ts +46 -0
- package/dist/core/count-recovery/field-demand.js +47 -0
- package/dist/core/count-recovery/field-only.d.ts +3 -0
- package/dist/core/count-recovery/field-only.js +18 -0
- package/dist/core/count-recovery/fold-path.d.ts +6 -0
- package/dist/core/count-recovery/fold-path.js +35 -0
- package/dist/core/count-recovery/frame-lemmas.d.ts +9 -0
- package/dist/core/count-recovery/frame-lemmas.js +120 -0
- package/dist/core/count-recovery/guard-cases.d.ts +12 -0
- package/dist/core/count-recovery/guard-cases.js +139 -0
- package/dist/core/count-recovery/key-closure.d.ts +14 -0
- package/dist/core/count-recovery/key-closure.js +62 -0
- package/dist/core/count-recovery/leaf-allowance.d.ts +4 -0
- package/dist/core/count-recovery/leaf-allowance.js +7 -0
- package/dist/core/count-recovery/lift-count-proxies.d.ts +6 -0
- package/dist/core/count-recovery/lift-count-proxies.js +175 -0
- package/dist/core/count-recovery/live-dependencies.d.ts +6 -0
- package/dist/core/count-recovery/live-dependencies.js +76 -0
- package/dist/core/count-recovery/member-inclusions.d.ts +11 -0
- package/dist/core/count-recovery/member-inclusions.js +168 -0
- package/dist/core/count-recovery/member-premises.d.ts +29 -0
- package/dist/core/count-recovery/member-premises.js +114 -0
- package/dist/core/count-recovery/natural-cases.d.ts +6 -0
- package/dist/core/count-recovery/natural-cases.js +59 -0
- package/dist/core/count-recovery/ops.d.ts +6 -0
- package/dist/core/count-recovery/ops.js +8 -0
- package/dist/core/count-recovery/pre-state-source.d.ts +8 -0
- package/dist/core/count-recovery/pre-state-source.js +18 -0
- package/dist/core/count-recovery/rebase-path.d.ts +9 -0
- package/dist/core/count-recovery/rebase-path.js +70 -0
- package/dist/core/count-recovery/reframe-tree.d.ts +2 -0
- package/dist/core/count-recovery/reframe-tree.js +24 -0
- package/dist/core/count-recovery/rename-proof.d.ts +2 -0
- package/dist/core/count-recovery/rename-proof.js +102 -0
- package/dist/core/count-recovery/replay-linear-skeleton.d.ts +2 -0
- package/dist/core/count-recovery/replay-linear-skeleton.js +28 -0
- package/dist/core/count-recovery/row-cases.d.ts +16 -0
- package/dist/core/count-recovery/row-cases.js +292 -0
- package/dist/core/count-recovery/scalar-guards.d.ts +7 -0
- package/dist/core/count-recovery/scalar-guards.js +291 -0
- package/dist/core/count-recovery/source-memo.d.ts +12 -0
- package/dist/core/count-recovery/source-memo.js +67 -0
- package/dist/core/count-rejection-budget.d.ts +8 -0
- package/dist/core/count-rejection-budget.js +15 -0
- package/dist/core/count-replacement.d.ts +5 -0
- package/dist/core/count-replacement.js +129 -0
- package/dist/core/count-replay-diagnostic.d.ts +21 -0
- package/dist/core/count-replay-diagnostic.js +49 -0
- package/dist/core/count-replay-skeleton.d.ts +4 -0
- package/dist/core/count-replay-skeleton.js +28 -0
- package/dist/core/count-rescope-funding.d.ts +3 -0
- package/dist/core/count-rescope-funding.js +17 -0
- package/dist/core/count-restrictions.d.ts +11 -0
- package/dist/core/count-restrictions.js +31 -0
- package/dist/core/count-retry-budget.d.ts +67 -0
- package/dist/core/count-retry-budget.js +114 -0
- package/dist/core/count-retry-round.d.ts +24 -0
- package/dist/core/count-retry-round.js +44 -0
- package/dist/core/count-row-agreement.d.ts +35 -0
- package/dist/core/count-row-agreement.js +270 -0
- package/dist/core/count-row-aliases.d.ts +3 -0
- package/dist/core/count-row-aliases.js +59 -0
- package/dist/core/count-row-composition.d.ts +6 -0
- package/dist/core/count-row-composition.js +55 -0
- package/dist/core/count-row-copy-linear.d.ts +4 -0
- package/dist/core/count-row-copy-linear.js +83 -0
- package/dist/core/count-row-copy.d.ts +4 -0
- package/dist/core/count-row-copy.js +94 -0
- package/dist/core/count-row-policy.d.ts +3 -0
- package/dist/core/count-row-policy.js +56 -0
- package/dist/core/count-row-reindex.d.ts +11 -0
- package/dist/core/count-row-reindex.js +126 -0
- package/dist/core/count-row-support.d.ts +9 -0
- package/dist/core/count-row-support.js +42 -0
- package/dist/core/count-row-symmetry.d.ts +7 -0
- package/dist/core/count-row-symmetry.js +100 -0
- package/dist/core/count-scope-hyps.d.ts +2 -0
- package/dist/core/count-scope-hyps.js +163 -0
- package/dist/core/count-scope-row-reuse.d.ts +3 -0
- package/dist/core/count-scope-row-reuse.js +92 -0
- package/dist/core/count-search-allowance.d.ts +1 -0
- package/dist/core/count-search-allowance.js +17 -0
- package/dist/core/count-select.d.ts +16 -0
- package/dist/core/count-select.js +24 -0
- package/dist/core/count-stabilize-tree.d.ts +9 -0
- package/dist/core/count-stabilize-tree.js +35 -0
- package/dist/core/count-stage-trace.d.ts +8 -0
- package/dist/core/count-stage-trace.js +45 -0
- package/dist/core/count-strategies.d.ts +16 -0
- package/dist/core/count-strategies.js +155 -0
- package/dist/core/count-strategy-premises.d.ts +5 -0
- package/dist/core/count-strategy-premises.js +14 -0
- package/dist/core/count-strategy.d.ts +41 -0
- package/dist/core/count-strategy.js +76 -0
- package/dist/core/count-support.d.ts +598 -0
- package/dist/core/count-support.js +2081 -0
- package/dist/core/count-tier-budget.d.ts +14 -0
- package/dist/core/count-tier-budget.js +64 -0
- package/dist/core/count-unions.d.ts +2 -0
- package/dist/core/count-unions.js +139 -0
- package/dist/core/count-unwritten-prefix.d.ts +24 -0
- package/dist/core/count-unwritten-prefix.js +97 -0
- package/dist/core/count-witness-flags.d.ts +9 -0
- package/dist/core/count-witness-flags.js +37 -0
- package/dist/core/count-write-frames.d.ts +12 -0
- package/dist/core/count-write-frames.js +206 -0
- package/dist/core/count-write-shape.d.ts +15 -0
- package/dist/core/count-write-shape.js +73 -0
- package/dist/core/counts.d.ts +49 -7
- package/dist/core/counts.js +1679 -165
- package/dist/core/cycles.js +5 -4
- package/dist/core/cyclic.js +11 -10
- package/dist/core/data.js +16 -15
- package/dist/core/dsl-deadline.d.ts +3 -0
- package/dist/core/dsl-deadline.js +27 -0
- package/dist/core/dsl.d.ts +59 -6
- package/dist/core/dsl.js +459 -112
- package/dist/core/effect.js +8 -1
- package/dist/core/evaluation-admission.d.ts +1 -0
- package/dist/core/evaluation-admission.js +3 -0
- package/dist/core/exists.d.ts +7 -2
- package/dist/core/exists.js +131 -24
- package/dist/core/extract-check.d.ts +7 -1
- package/dist/core/extract-check.js +130 -13
- package/dist/core/extract-read.d.ts +22 -8
- package/dist/core/extract-read.js +29 -11
- package/dist/core/extract-shapes.js +122 -41
- package/dist/core/extract-standalone.js +53 -9
- package/dist/core/extract.js +9 -3
- package/dist/core/field-laws.d.ts +4 -0
- package/dist/core/field-laws.js +238 -0
- package/dist/core/finite-frontiers.d.ts +5 -0
- package/dist/core/finite-frontiers.js +116 -0
- package/dist/core/finite-houdini.d.ts +58 -0
- package/dist/core/finite-houdini.js +502 -0
- package/dist/core/finite-model.d.ts +13 -0
- package/dist/core/finite-model.js +68 -0
- package/dist/core/finite-tiny.d.ts +72 -0
- package/dist/core/finite-tiny.js +1080 -0
- package/dist/core/fixtures/count-completion/paxos-decision.json +1 -0
- package/dist/core/fresh.js +5 -1
- package/dist/core/infer.d.ts +1 -1
- package/dist/core/infer.js +76 -38
- package/dist/core/kind.js +2 -1
- package/dist/core/laws.d.ts +2 -1
- package/dist/core/laws.js +47 -14
- package/dist/core/lemma-cuts.d.ts +38 -0
- package/dist/core/lemma-cuts.js +366 -0
- package/dist/core/linear-admission.d.ts +14 -0
- package/dist/core/linear-admission.js +151 -0
- package/dist/core/machine.d.ts +44 -4
- package/dist/core/machine.js +342 -63
- package/dist/core/meter.d.ts +22 -0
- package/dist/core/meter.js +34 -0
- package/dist/core/mutate.d.ts +55 -0
- package/dist/core/mutate.js +210 -0
- package/dist/core/native-domain.d.ts +6 -0
- package/dist/core/native-domain.js +114 -0
- package/dist/core/native-law.d.ts +3 -0
- package/dist/core/native-law.js +174 -0
- package/dist/core/nonterm.js +4 -3
- package/dist/core/prover-row-budget.d.ts +3 -0
- package/dist/core/prover-row-budget.js +106 -0
- package/dist/core/quorum-laws.d.ts +25 -0
- package/dist/core/quorum-laws.js +263 -0
- package/dist/core/rationals.js +3 -2
- package/dist/core/rejection-discovery.d.ts +34 -0
- package/dist/core/rejection-discovery.js +36 -0
- package/dist/core/rejection-stage.d.ts +39 -0
- package/dist/core/rejection-stage.js +205 -0
- package/dist/core/relational.js +10 -2
- package/dist/core/relevance.d.ts +4 -0
- package/dist/core/relevance.js +79 -0
- package/dist/core/request-quotient.d.ts +8 -0
- package/dist/core/request-quotient.js +299 -0
- package/dist/core/row-agreement-shape.d.ts +15 -0
- package/dist/core/row-agreement-shape.js +68 -0
- package/dist/core/runtime-wall.d.ts +5 -0
- package/dist/core/runtime-wall.js +4 -0
- package/dist/core/sample-step.d.ts +16 -0
- package/dist/core/sample-step.js +28 -0
- package/dist/core/search-policy.d.ts +15 -0
- package/dist/core/search-policy.js +68 -0
- package/dist/core/solver.d.ts +1 -1
- package/dist/core/solver.js +40 -6
- package/dist/core/source-check.d.ts +44 -0
- package/dist/core/source-check.js +126 -0
- package/dist/core/source-diagnostic.d.ts +1 -0
- package/dist/core/source-diagnostic.js +34 -0
- package/dist/core/step-work.d.ts +12 -0
- package/dist/core/step-work.js +14 -0
- package/dist/core/strategy-premises.d.ts +8 -0
- package/dist/core/strategy-premises.js +64 -0
- package/dist/core/support-budget.d.ts +2 -0
- package/dist/core/support-budget.js +6 -0
- package/dist/core/system.js +6 -3
- package/dist/core/table-admission.d.ts +1 -0
- package/dist/core/table-admission.js +3 -0
- package/dist/core/trace-clock.d.ts +3 -0
- package/dist/core/trace-clock.js +16 -0
- package/dist/core/transfer.js +3 -2
- package/dist/core/translate.js +16 -3
- package/dist/core/wall.d.ts +11 -0
- package/dist/core/wall.js +37 -0
- package/dist/core/watch.d.ts +1 -1
- package/dist/core/watch.js +15 -2
- package/dist/core/work-admission.d.ts +164 -0
- package/dist/core/work-admission.js +418 -0
- package/dist/core/work-amount.d.ts +21 -0
- package/dist/core/work-amount.js +80 -0
- package/dist/core/work-collections.d.ts +11 -0
- package/dist/core/work-collections.js +198 -0
- package/dist/core/work-kinds.d.ts +11 -0
- package/dist/core/work-kinds.js +9 -0
- package/dist/core/work-meter.d.ts +8 -0
- package/dist/core/work-meter.js +83 -0
- package/dist/core/work-observe.d.ts +12 -0
- package/dist/core/work-observe.js +39 -0
- package/dist/core/work-profile.d.ts +10 -0
- package/dist/core/work-profile.js +21 -0
- package/dist/core/work-refusal.d.ts +1 -0
- package/dist/core/work-refusal.js +6 -0
- package/dist/interchange/format.js +2 -0
- package/dist/kernel/cdcl.d.ts +4 -0
- package/dist/kernel/cdcl.js +109 -41
- package/dist/kernel/epr.js +23 -8
- package/dist/kernel/kernel.d.ts +56 -0
- package/dist/kernel/kernel.js +466 -64
- package/dist/kernel/model-sequence.d.ts +2 -2
- package/dist/kernel/model-sequence.js +4 -3
- package/dist/kernel/model-values.d.ts +2 -0
- package/dist/kernel/model-values.js +60 -0
- package/dist/kernel/prove.d.ts +59 -3
- package/dist/kernel/prove.js +524 -130
- package/dist/kernel/prover-rows.d.ts +30 -0
- package/dist/kernel/prover-rows.js +125 -0
- package/dist/kernel/reader.d.ts +1 -1
- package/dist/kernel/reader.js +57 -12
- package/dist/kernel/simplex.js +9 -2
- package/dist/lean-kernel/emit.d.ts +47 -2
- package/dist/lean-kernel/emit.js +270 -36
- package/dist/lean-kernel/lean-terms.d.ts +1 -0
- package/dist/lean-kernel/lean-terms.js +13 -5
- package/dist/lean-kernel/legacy-family-library.d.ts +1 -0
- package/dist/lean-kernel/legacy-family-library.js +5 -0
- package/dist/lean-kernel/library.js +4 -0
- package/dist/lean-kernel/qalpha.d.ts +7 -0
- package/dist/lean-kernel/qalpha.js +40 -0
- package/package.json +5 -1
|
@@ -20,8 +20,10 @@ const vmOf = () => { const m = proc?.getBuiltinModule?.('node:vm'); if (!m)
|
|
|
20
20
|
import { Int, Term, bool, int, intern, interned, nat, no, oneOf, str, proveSteps } from "./dsl.js";
|
|
21
21
|
import { seeded, walk } from "./machine.js";
|
|
22
22
|
import { allowed } from "./watch.js";
|
|
23
|
-
import { normalize, resolveIn, scriptKind } from "./extract-read.js";
|
|
23
|
+
import { normalize, resolveIn, sameLazyRoot, scriptKind } from "./extract-read.js";
|
|
24
24
|
import * as I from "./extract-ir.js";
|
|
25
|
+
import { nativeSnapshot, rememberNative } from "./source-check.js";
|
|
26
|
+
import { nativeCaptureEdits, nativeInputs } from "./native-domain.js";
|
|
25
27
|
// The check's own failure, not the code's: a request past its time, the harness's transport (anvil's JSON-RPC) failing,
|
|
26
28
|
// the harness gone. Never a difference and never a pass: the whole check runs once more, from a fresh harness, and a
|
|
27
29
|
// second failure is the check's outcome (Evidence.harness).
|
|
@@ -89,9 +91,12 @@ export function instrument(code, file, tail = '', extra = []) {
|
|
|
89
91
|
const js = ts.transpileModule(out, { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022, esModuleInterop: true, jsx: ts.JsxEmit.React }, fileName: file.replace(/\.js$/, '.ts').replace(/\.jsx$/, '.tsx') }).outputText;
|
|
90
92
|
return { js, arms };
|
|
91
93
|
}
|
|
92
|
-
export function sandbox(code, file, expose, modules = {}, init, files = {}, extra = []) {
|
|
94
|
+
export function sandbox(code, file, expose, modules = {}, init, files = {}, extra = [], nativeMethods = []) {
|
|
93
95
|
const vm = vmOf();
|
|
94
|
-
|
|
96
|
+
// A final arrow can end exactly where a factory appends fields. Its capture
|
|
97
|
+
// must close first; instrument preserves the order of equal-position edits.
|
|
98
|
+
const { js, arms } = instrument(code, file, init ? `\n;(globalThis as any).__gdpInit = () => (${init});\n` : '', [...nativeCaptureEdits(code, file, nativeMethods), ...extra]);
|
|
99
|
+
const captured = new Map(), captureErrors = new Map();
|
|
95
100
|
const counts = arms.map(() => 0);
|
|
96
101
|
let now = 0;
|
|
97
102
|
const stub = (name) => new Proxy({}, {
|
|
@@ -102,6 +107,16 @@ export function sandbox(code, file, expose, modules = {}, init, files = {}, extr
|
|
|
102
107
|
const module = { exports: {} };
|
|
103
108
|
const ctx = vm.createContext({
|
|
104
109
|
__cov: (i) => { counts[i]++; }, __now: () => now, module, exports: module.exports,
|
|
110
|
+
__gdp_native_capture: (name, value) => {
|
|
111
|
+
if (captured.has(name) || captureErrors.has(name))
|
|
112
|
+
return;
|
|
113
|
+
try {
|
|
114
|
+
captured.set(name, nativeSnapshot(value));
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
captureErrors.set(name, String(e));
|
|
118
|
+
}
|
|
119
|
+
},
|
|
105
120
|
// A relative import among the files given: loaded in this VM (not counted: the branches are the entry's). A module
|
|
106
121
|
// the step doesn't name (React, for the component beside a reducer): a stub that throws when read, so a step that
|
|
107
122
|
// reads it fails the check rather than running without it.
|
|
@@ -118,7 +133,10 @@ export function sandbox(code, file, expose, modules = {}, init, files = {}, extr
|
|
|
118
133
|
return loaded.get(at);
|
|
119
134
|
const m = { exports: {} };
|
|
120
135
|
loaded.set(at, m.exports);
|
|
121
|
-
|
|
136
|
+
let input = abs[at];
|
|
137
|
+
for (const [pos, text] of nativeCaptureEdits(input, at, nativeMethods).sort((a, b) => b[0] - a[0]))
|
|
138
|
+
input = input.slice(0, pos) + text + input.slice(pos);
|
|
139
|
+
const js = ts.transpileModule(input, { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022, esModuleInterop: true, jsx: ts.JsxEmit.React }, fileName: at.replace(/\.js$/, '.ts').replace(/\.jsx$/, '.tsx') }).outputText;
|
|
122
140
|
// A file that doesn't load here (it reads import.meta, a browser's globals): a stub that throws when read, so a step
|
|
123
141
|
// that reads it fails the check rather than running without it.
|
|
124
142
|
try {
|
|
@@ -139,6 +157,11 @@ export function sandbox(code, file, expose, modules = {}, init, files = {}, extr
|
|
|
139
157
|
return 'default: module.exports.default'; const [h, ...rest] = n.split('.'); return `${JSON.stringify(n)}: (typeof ${h} !== 'undefined' ? ${h} : module.exports.${h})${rest.map(x => `.${x}`).join('')}`; }).join(', ')}};`, ctx, { timeout: 2000, filename: file });
|
|
140
158
|
const script = new vm.Script('globalThis.__r = (() => { try { return {ok: true, value: __gdp[__f].apply(__self, __args)} } catch (e) { return {ok: false, error: String(e && e.message || e)} } })()');
|
|
141
159
|
const call = (f, self, args) => {
|
|
160
|
+
// Reading/restoring a factory's closure is harness work, not a new request.
|
|
161
|
+
if (f !== '$get' && f !== '$at') {
|
|
162
|
+
captured.clear();
|
|
163
|
+
captureErrors.clear();
|
|
164
|
+
}
|
|
142
165
|
Object.assign(ctx, { __f: f, __self: self, __args: args });
|
|
143
166
|
try {
|
|
144
167
|
script.runInContext(ctx, { timeout: 1000 });
|
|
@@ -150,7 +173,9 @@ export function sandbox(code, file, expose, modules = {}, init, files = {}, extr
|
|
|
150
173
|
}
|
|
151
174
|
return ctx.__r;
|
|
152
175
|
};
|
|
153
|
-
return { ctx, counts, arms, call, setNow: n => { now = n; }, get: name => vm.runInContext(`__gdp[${JSON.stringify(name)}]`, ctx)
|
|
176
|
+
return { ctx, counts, arms, call, setNow: n => { now = n; }, get: name => vm.runInContext(`__gdp[${JSON.stringify(name)}]`, ctx),
|
|
177
|
+
bindings: method => { if (captureErrors.has(method))
|
|
178
|
+
throw new Error(captureErrors.get(method)); return captured.get(method); } };
|
|
154
179
|
}
|
|
155
180
|
const isMap = (x) => Object.prototype.toString.call(x) === '[object Map]';
|
|
156
181
|
export class Outside extends Error {
|
|
@@ -409,7 +434,7 @@ function checkOnce(code, file, m, r, sorts, opts) {
|
|
|
409
434
|
// declared twice: no request runs, and the check says why)
|
|
410
435
|
let box;
|
|
411
436
|
try {
|
|
412
|
-
box = sandbox(code, file, fns, mods, m.initSource, opts.files, m.factory ? [[m.factory.at, m.factory.text], ...(m.factory.extra ?? [])] : []);
|
|
437
|
+
box = sandbox(code, file, fns, mods, m.initSource, opts.files, m.factory ? [[m.factory.at, m.factory.text], ...(m.factory.extra ?? [])] : [], m.events.map(e => e.call));
|
|
413
438
|
}
|
|
414
439
|
catch (e) {
|
|
415
440
|
return { runs: 0, requests: 0, fromStates: 0, probes: { conditions: 0, witnesses: 0, steps: 0 }, refusedBoth: 0, outside: 0, edge: 0, compiledAgreed: 0, coverage: { arms: 0, hit: 0, missed: [] }, ms: 0,
|
|
@@ -434,6 +459,9 @@ function checkOnce(code, file, m, r, sorts, opts) {
|
|
|
434
459
|
const ctorValue = (n, params) => (n === '$fn' ? fnArg() : n.startsWith('$map:') ? vmOf().runInContext(n === '$map:Map' ? 'new Map()' : '({})', box.ctx) : params[n]);
|
|
435
460
|
const ctorValues = (params) => (m.ctorArgs ?? []).filter(n => !m.params.find(v => v.name === n)?.note?.startsWith('Date.now()')).map(n => ctorValue(n, params));
|
|
436
461
|
const side = {
|
|
462
|
+
nativeState: (self, snap, params) => standalone ? {} : isClass ? stateOf(self) : valueOf(snap, m.layout, m, evalAt(params), box.ctx),
|
|
463
|
+
nativeBindings: e => box.bindings(e.call),
|
|
464
|
+
...(standalone ? { nativeInputs: nativeInputs(code, file, m.entry, opts.files) } : {}),
|
|
437
465
|
make: params => {
|
|
438
466
|
const now0 = m.params.find(v => v.note?.startsWith('Date.now()'));
|
|
439
467
|
if (now0)
|
|
@@ -462,7 +490,7 @@ function checkOnce(code, file, m, r, sorts, opts) {
|
|
|
462
490
|
answers = inputs;
|
|
463
491
|
const dateIn = (n) => { const x = m.inputs.find(v => v.name === n); return x?.sort.k === 'num' && x.sort.date ? vmOf().runInContext(`new Date(${Number(inputs[n])})`, box.ctx) : inputs[n]; };
|
|
464
492
|
const build = (a) => (a.k === 'input' ? dateIn(a.name) : a.k === 'maybe-bool' ? (inputs[a.missing] ? undefined : inputs[a.name]) : a.k === 'lit' ? a.value : a.k === 'rec' ? Object.fromEntries(a.fields.map(([f, x]) => [f, build(x)])) : a.k === 'lazy'
|
|
465
|
-
? Object.fromEntries([...m.inputs].filter(v => m.lazy?.get(v.name)
|
|
493
|
+
? Object.fromEntries([...m.inputs].filter(v => sameLazyRoot(m.lazy?.get(v.name), a)).map(v => [m.lazy.get(v.name).field, inputs[v.name]]))
|
|
466
494
|
: undefined);
|
|
467
495
|
return e.args.map(build);
|
|
468
496
|
},
|
|
@@ -496,11 +524,38 @@ export function drive(m, r, sorts, code, opts = {}) {
|
|
|
496
524
|
const interp = r.interpreter(), gen = r.compiled(), machine = r.machine;
|
|
497
525
|
const ev = { runs: 0, requests: 0, fromStates: 0, probes: { conditions: 0, witnesses: 0, steps: 0 }, refusedBoth: 0, outside: 0, edge: 0, compiledAgreed: 0, coverage: { arms: 0, hit: 0, missed: [] }, ms: 0 };
|
|
498
526
|
const consts = constantsOf(m), strs = stringsOf(m);
|
|
527
|
+
const disabled = opts.lawCrossCheck === false || (opts.runs === 0 && opts.states === 0 && opts.probes === false);
|
|
528
|
+
const finite = code.nativeInputs?.domains;
|
|
529
|
+
const exhaustive = finite !== undefined;
|
|
530
|
+
const journal = { enabled: !disabled, complete: false, scope: exhaustive ? 'exhaustive' : 'sampled', observations: [],
|
|
531
|
+
...(disabled ? { reason: 'source replay or native-law cross-check was disabled' } : {}) };
|
|
532
|
+
if (code.nativeInputs?.reason)
|
|
533
|
+
journal.reason = code.nativeInputs.reason;
|
|
534
|
+
rememberNative(ev, journal);
|
|
535
|
+
const nativeContext = vmOf().createContext({});
|
|
536
|
+
const nativeState = (side, params) => nativeSnapshot(code.nativeState ? code.nativeState(side.self, side.snap, params) : valueOf(side.snap, m.layout, m, t => evalTerm(t, params), nativeContext));
|
|
537
|
+
const capture = (read) => {
|
|
538
|
+
if (!journal.enabled || journal.reason)
|
|
539
|
+
return undefined;
|
|
540
|
+
try {
|
|
541
|
+
return read();
|
|
542
|
+
}
|
|
543
|
+
catch (e) {
|
|
544
|
+
journal.reason = `native observation unavailable: ${e instanceof Error ? e.message : String(e)}`;
|
|
545
|
+
return undefined;
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
const recordInitial = (side, params) => {
|
|
549
|
+
const state = capture(() => nativeState(side, params));
|
|
550
|
+
if (journal.enabled && !journal.reason)
|
|
551
|
+
journal.observations.push({ where: 'initial native state', before: state, after: state, params: { ...params }, inputs: {}, bindings: {}, args: [], result: undefined, failed: false });
|
|
552
|
+
};
|
|
499
553
|
const paramKinds = m.params.map(v => [v, kindOfVar(v, sorts)]), inputKinds = m.inputs.map(v => [v, kindOfVar(v, sorts)]);
|
|
500
554
|
const fail = (what) => { ev.mismatch = what; return finish(); };
|
|
501
555
|
const finish = () => {
|
|
502
556
|
ev.coverage = code.coverage();
|
|
503
557
|
ev.ms = Math.round(performance.now() - t0);
|
|
558
|
+
journal.complete = journal.enabled && !journal.reason && journal.observations.length > 0;
|
|
504
559
|
return ev;
|
|
505
560
|
};
|
|
506
561
|
const draws = (st, params) => [...consts, ...Object.values(st.leaves).filter((x) => typeof x === 'number'), ...Object.values(params).filter((x) => typeof x === 'number')];
|
|
@@ -541,7 +596,7 @@ export function drive(m, r, sorts, code, opts = {}) {
|
|
|
541
596
|
a.fields.forEach(([, x]) => walk(x));
|
|
542
597
|
else if (a.k === 'lazy')
|
|
543
598
|
for (const v of m.inputs)
|
|
544
|
-
if (m.lazy?.get(v.name)
|
|
599
|
+
if (sameLazyRoot(m.lazy?.get(v.name), a))
|
|
545
600
|
used.add(v.name); };
|
|
546
601
|
e.args.forEach(walk);
|
|
547
602
|
for (const v of m.inputs)
|
|
@@ -552,7 +607,7 @@ export function drive(m, r, sorts, code, opts = {}) {
|
|
|
552
607
|
};
|
|
553
608
|
// Steps the code and the rule from one state; undefined when they agree (the next state on both sides is returned
|
|
554
609
|
// through `next`), else the difference.
|
|
555
|
-
const step = (params, ps, side, st, inputs, e, next, where) => {
|
|
610
|
+
const step = (params, ps, side, st, inputs, e, next, where, reachable) => {
|
|
556
611
|
// A source type's finite numeric domain is part of the standalone claim, not
|
|
557
612
|
// behavior the source is alleged to reject. Never execute an out-of-domain probe.
|
|
558
613
|
if (m.standalone && Object.entries(m.standaloneDomains ?? {}).some(([name, values]) => !values.includes(inputs[name]))) {
|
|
@@ -561,6 +616,8 @@ export function drive(m, r, sorts, code, opts = {}) {
|
|
|
561
616
|
return undefined;
|
|
562
617
|
}
|
|
563
618
|
const args = code.args(inputs, e), raw = ruleInputs(inputs, e);
|
|
619
|
+
const before = reachable ? capture(() => nativeState(side, params)) : undefined;
|
|
620
|
+
const nativeArgs = reachable ? capture(() => nativeSnapshot(args)) : undefined;
|
|
564
621
|
if (m.folds)
|
|
565
622
|
carry(m, raw, inputs, side.snap, params, r.decode(st));
|
|
566
623
|
const nowVar = m.inputs.find(v => v.note?.startsWith('Date.now()'));
|
|
@@ -703,7 +760,25 @@ export function drive(m, r, sorts, code, opts = {}) {
|
|
|
703
760
|
return bad(`the rule's ${rk.name} is ${JSON.stringify(d[rk.name])}`);
|
|
704
761
|
}
|
|
705
762
|
}
|
|
706
|
-
|
|
763
|
+
const afterSide = { snap: res.snap, ...(res.self ? { self: res.self } : {}) };
|
|
764
|
+
if (reachable && journal.enabled && !journal.reason) {
|
|
765
|
+
const after = capture(() => nativeState(afterSide, params)), result = capture(() => nativeSnapshot(res.out));
|
|
766
|
+
const bindings = capture(() => code.nativeBindings?.(e));
|
|
767
|
+
if (code.nativeBindings && !bindings)
|
|
768
|
+
journal.reason ??= `native parameter capture unavailable for ${e.call}`;
|
|
769
|
+
const fallback = Object.create(null);
|
|
770
|
+
e.names?.forEach((n, i) => {
|
|
771
|
+
const value = nativeArgs?.[i];
|
|
772
|
+
if (n === '__gdp_destructured' && value && typeof value === 'object')
|
|
773
|
+
Object.assign(fallback, value);
|
|
774
|
+
else
|
|
775
|
+
fallback[n] = value;
|
|
776
|
+
});
|
|
777
|
+
const rk = m.results?.[e.call];
|
|
778
|
+
journal.observations.push({ where, method: e.call, before, after, params: { ...params }, inputs: { ...inputs }, bindings: bindings ?? fallback,
|
|
779
|
+
args: nativeArgs ?? [], result, failed: false, legacyResult: !standalone && rk?.k === 'rec' && rk.fields.some(([field]) => field === 'value') });
|
|
780
|
+
}
|
|
781
|
+
next.side = afterSide;
|
|
707
782
|
next.st = rule.st;
|
|
708
783
|
return undefined;
|
|
709
784
|
};
|
|
@@ -754,7 +829,9 @@ export function drive(m, r, sorts, code, opts = {}) {
|
|
|
754
829
|
const diff = sameSnap(snap, ruleSnap(r, m, st, sorts));
|
|
755
830
|
if (diff)
|
|
756
831
|
return { problem: `new ${m.entry}(${JSON.stringify(params)}): ${diff}` };
|
|
757
|
-
|
|
832
|
+
const side = { snap, self: made.value };
|
|
833
|
+
recordInitial(side, params);
|
|
834
|
+
return { side, st, ps: ps };
|
|
758
835
|
}
|
|
759
836
|
catch (x) {
|
|
760
837
|
if (x instanceof HarnessFailure)
|
|
@@ -777,6 +854,7 @@ export function drive(m, r, sorts, code, opts = {}) {
|
|
|
777
854
|
const problem = code.init?.(snap, params);
|
|
778
855
|
if (problem)
|
|
779
856
|
return { problem };
|
|
857
|
+
recordInitial({ snap }, params);
|
|
780
858
|
return { side: { snap }, st, ps: ps ?? {} };
|
|
781
859
|
};
|
|
782
860
|
const runs = opts.runs ?? 200, depth = opts.depth ?? 12;
|
|
@@ -790,7 +868,7 @@ export function drive(m, r, sorts, code, opts = {}) {
|
|
|
790
868
|
let side = s0.side, st = s0.st;
|
|
791
869
|
for (let d = 0; d < depth; d++) {
|
|
792
870
|
const { e, inputs } = drawRequest(side.snap, params), next = {};
|
|
793
|
-
const diff = step(params, s0.ps, side, st, inputs, e, next, `run ${run + 1}, request ${d + 1}
|
|
871
|
+
const diff = step(params, s0.ps, side, st, inputs, e, next, `run ${run + 1}, request ${d + 1}`, true);
|
|
794
872
|
ev.requests++;
|
|
795
873
|
if (diff)
|
|
796
874
|
return fail(diff);
|
|
@@ -871,7 +949,8 @@ export function drive(m, r, sorts, code, opts = {}) {
|
|
|
871
949
|
if (isClass && self === undefined)
|
|
872
950
|
return undefined;
|
|
873
951
|
const side = { snap, ...(isClass ? { self: self } : {}) };
|
|
874
|
-
|
|
952
|
+
// Drawn/prover states test translation conformance, not reachable source laws.
|
|
953
|
+
return step(params, ps, side, st, inputs, e, {}, where, false);
|
|
875
954
|
};
|
|
876
955
|
for (let i = 0; i < (opts.states ?? 400); i++) {
|
|
877
956
|
const params = drawParams(), snap = drawSnap(params), { e, inputs } = drawRequest(snap, params);
|
|
@@ -929,6 +1008,44 @@ export function drive(m, r, sorts, code, opts = {}) {
|
|
|
929
1008
|
return fail(diff);
|
|
930
1009
|
}
|
|
931
1010
|
}
|
|
1011
|
+
// Finite standalone inputs are not replaced by random sampling, even when a
|
|
1012
|
+
// particular request was already replayed above. The same native step supplies
|
|
1013
|
+
// both rule conformance and the independent source-law observation.
|
|
1014
|
+
if (exhaustive && journal.enabled && !journal.reason) {
|
|
1015
|
+
const params = {}, first = start(params);
|
|
1016
|
+
if (first.problem)
|
|
1017
|
+
return fail(`exhaustive native start: ${first.problem}`);
|
|
1018
|
+
if (!first.side || !first.st || !first.ps)
|
|
1019
|
+
journal.reason = 'finite native entry could not start';
|
|
1020
|
+
else {
|
|
1021
|
+
let ordinal = 0;
|
|
1022
|
+
const event = m.events[0];
|
|
1023
|
+
const visit = (at, args) => {
|
|
1024
|
+
if (journal.reason)
|
|
1025
|
+
return;
|
|
1026
|
+
if (at === finite.length) {
|
|
1027
|
+
const returned = code.call(undefined, event, args);
|
|
1028
|
+
if (!returned.ok) {
|
|
1029
|
+
journal.reason = `native finite input ${++ordinal} throws: ${returned.error}`;
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
const bindings = capture(() => code.nativeBindings?.(event));
|
|
1033
|
+
if (!bindings) {
|
|
1034
|
+
journal.reason ??= 'independent native parameter capture unavailable';
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
const result = capture(() => nativeSnapshot(returned.value)), savedArgs = capture(() => nativeSnapshot(args));
|
|
1038
|
+
if (!journal.reason)
|
|
1039
|
+
journal.observations.push({ where: `exhaustive native input ${++ordinal}`, method: event.call,
|
|
1040
|
+
before: {}, after: {}, params: {}, inputs: {}, bindings, args: savedArgs, result, failed: false });
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
for (const value of finite[at])
|
|
1044
|
+
visit(at + 1, [...args, value]);
|
|
1045
|
+
};
|
|
1046
|
+
visit(0, []);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
932
1049
|
return finish();
|
|
933
1050
|
}
|
|
934
1051
|
const mapReplacer = (_, v) => (isMap(v) ? { $map: [...v.entries()] } : v);
|
|
@@ -90,6 +90,23 @@ export type Term = {
|
|
|
90
90
|
s: 'str';
|
|
91
91
|
e: K;
|
|
92
92
|
};
|
|
93
|
+
export type LazyRoot = readonly [scope: string, argument: number];
|
|
94
|
+
export type LazyField = {
|
|
95
|
+
prefix: string;
|
|
96
|
+
root?: LazyRoot;
|
|
97
|
+
field: string;
|
|
98
|
+
};
|
|
99
|
+
export declare const lazyKey: (record: {
|
|
100
|
+
prefix: string;
|
|
101
|
+
root?: LazyRoot;
|
|
102
|
+
}, field: string) => string;
|
|
103
|
+
export declare const sameLazyRoot: (a: {
|
|
104
|
+
prefix: string;
|
|
105
|
+
root?: LazyRoot;
|
|
106
|
+
} | undefined, b: {
|
|
107
|
+
prefix: string;
|
|
108
|
+
root?: LazyRoot;
|
|
109
|
+
}) => boolean;
|
|
93
110
|
export type Arg = {
|
|
94
111
|
k: 'input';
|
|
95
112
|
name: string;
|
|
@@ -108,6 +125,7 @@ export type Arg = {
|
|
|
108
125
|
} | {
|
|
109
126
|
k: 'lazy';
|
|
110
127
|
prefix: string;
|
|
128
|
+
root?: LazyRoot;
|
|
111
129
|
};
|
|
112
130
|
export type Event = {
|
|
113
131
|
select: Record<string, string>;
|
|
@@ -175,10 +193,7 @@ export type Model = {
|
|
|
175
193
|
notes: string[];
|
|
176
194
|
hints: WeakMap<object, string>;
|
|
177
195
|
ctorArgs?: string[];
|
|
178
|
-
lazy?: Map<string,
|
|
179
|
-
prefix: string;
|
|
180
|
-
field: string;
|
|
181
|
-
}>;
|
|
196
|
+
lazy?: Map<string, LazyField>;
|
|
182
197
|
initSource?: string;
|
|
183
198
|
spans?: [number, number][];
|
|
184
199
|
factory?: {
|
|
@@ -286,6 +301,7 @@ type Rec = {
|
|
|
286
301
|
origin: 'fresh' | 'input' | 'this' | 'shared';
|
|
287
302
|
lazy?: {
|
|
288
303
|
prefix: string;
|
|
304
|
+
root?: LazyRoot;
|
|
289
305
|
};
|
|
290
306
|
};
|
|
291
307
|
type MapObj = {
|
|
@@ -379,10 +395,8 @@ export type Setup = {
|
|
|
379
395
|
nowRole: 'input' | 'param';
|
|
380
396
|
hints: WeakMap<object, string>;
|
|
381
397
|
notes: Set<string>;
|
|
382
|
-
lazy: Map<string,
|
|
383
|
-
|
|
384
|
-
field: string;
|
|
385
|
-
}>;
|
|
398
|
+
lazy: Map<string, LazyField>;
|
|
399
|
+
lazySelections?: Set<string>;
|
|
386
400
|
ctor?: boolean;
|
|
387
401
|
ours: (sf: ts.SourceFile) => boolean;
|
|
388
402
|
spans?: [number, number][];
|
|
@@ -26,6 +26,13 @@ export class Retype extends Error {
|
|
|
26
26
|
this.sort = sort;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
export const lazyKey = (record, field) => JSON.stringify([record.root ?? [record.prefix, 0], [field]]);
|
|
30
|
+
export const sameLazyRoot = (a, b) => {
|
|
31
|
+
if (!a)
|
|
32
|
+
return false;
|
|
33
|
+
const x = a.root ?? [a.prefix, 0], y = b.root ?? [b.prefix, 0];
|
|
34
|
+
return x[0] === y[0] && x[1] === y[1];
|
|
35
|
+
};
|
|
29
36
|
export const unparen = (x) => (ts.isParenthesizedExpression(x) ? unparen(x.expression) : x);
|
|
30
37
|
// An expression without its parentheses, casts and `!` (what it is, as the front ends read it).
|
|
31
38
|
export const bare = (x) => (ts.isParenthesizedExpression(x) || ts.isAsExpression(x) || ts.isSatisfiesExpression(x) || ts.isNonNullExpression(x) ? bare(x.expression) : x);
|
|
@@ -392,8 +399,11 @@ export class Exec {
|
|
|
392
399
|
return { has: { op: 'cell', map: m.name, key, field: 'has' }, vals: new Map(m.fields.map(f => [f.name, Exec.cellOf(m, key, f)])) };
|
|
393
400
|
}
|
|
394
401
|
asChoice(v, values, at) {
|
|
395
|
-
if (v.t === 'choice')
|
|
402
|
+
if (v.t === 'choice') {
|
|
403
|
+
if (v.values.length !== values.length || v.values.some((value, i) => value !== values[i]))
|
|
404
|
+
return refuse(at, 'a join or assignment between different ordered choice domains');
|
|
396
405
|
return v.e;
|
|
406
|
+
}
|
|
397
407
|
if (v.t === 'str' && v.e.op === 'slit') {
|
|
398
408
|
if (!values.includes(v.e.value))
|
|
399
409
|
return refuse(at, `'${v.e.value}' is not one of ${values.map(x => `'${x}'`).join(', ')}`);
|
|
@@ -528,7 +538,7 @@ export class Exec {
|
|
|
528
538
|
// where it is there.
|
|
529
539
|
narrow(e, pt, pe) {
|
|
530
540
|
const strip = (x) => (ts.isParenthesizedExpression(x) ? strip(x.expression) : x);
|
|
531
|
-
let x = strip(e), present = true, absenceTest = false;
|
|
541
|
+
let x = strip(e), present = true, absenceTest = false, comparedNull = false, loose = false;
|
|
532
542
|
if (ts.isPrefixUnaryExpression(x) && x.operator === ts.SyntaxKind.ExclamationToken) {
|
|
533
543
|
x = strip(x.operand);
|
|
534
544
|
present = false;
|
|
@@ -536,6 +546,8 @@ export class Exec {
|
|
|
536
546
|
else if (ts.isBinaryExpression(x) && (x.right.kind === ts.SyntaxKind.UndefinedKeyword || (ts.isIdentifier(x.right) && x.right.text === 'undefined') || x.right.kind === ts.SyntaxKind.NullKeyword)) {
|
|
537
547
|
const op = x.operatorToken.kind;
|
|
538
548
|
absenceTest = true;
|
|
549
|
+
comparedNull = x.right.kind === ts.SyntaxKind.NullKeyword;
|
|
550
|
+
loose = op === ts.SyntaxKind.EqualsEqualsToken || op === ts.SyntaxKind.ExclamationEqualsToken;
|
|
539
551
|
if (op === ts.SyntaxKind.EqualsEqualsEqualsToken || op === ts.SyntaxKind.EqualsEqualsToken)
|
|
540
552
|
present = false;
|
|
541
553
|
else if (op !== ts.SyntaxKind.ExclamationEqualsEqualsToken && op !== ts.SyntaxKind.ExclamationEqualsToken)
|
|
@@ -547,10 +559,14 @@ export class Exec {
|
|
|
547
559
|
const v = pt.locals.get(x.text);
|
|
548
560
|
if (v?.t !== 'opt')
|
|
549
561
|
return [pt, pe];
|
|
550
|
-
|
|
562
|
+
// A strict comparison to the other absence kind is constant, not a presence test.
|
|
563
|
+
if (absenceTest && !loose && !!v.null !== comparedNull)
|
|
564
|
+
return [pt, pe];
|
|
565
|
+
const absent = { t: 'undef', ...(v.null ? { null: true } : {}) };
|
|
566
|
+
const set = (p, there) => ({ ...p, locals: new Map(p.locals).set(x.text, there ? v.v : absent) });
|
|
551
567
|
// A falsy optional scalar can be present (false or 0), not just absent.
|
|
552
568
|
// Preserve the opt value on that arm; only an explicit absence comparison narrows both arms.
|
|
553
|
-
if (
|
|
569
|
+
if (!absenceTest)
|
|
554
570
|
return present ? [set(pt, true), pe] : [pt, set(pe, true)];
|
|
555
571
|
return present ? [set(pt, true), set(pe, false)] : [set(pt, false), set(pe, true)];
|
|
556
572
|
}
|
|
@@ -626,6 +642,10 @@ export class Exec {
|
|
|
626
642
|
return I.cmp('=', a.e, b.e);
|
|
627
643
|
if (a.t === 'bool' && b.t === 'bool')
|
|
628
644
|
return I.or(I.and(a.e, b.e), I.and(I.not(a.e), I.not(b.e)));
|
|
645
|
+
// Choices are encoded by position. Standalone arguments may have different
|
|
646
|
+
// domains or orders, so comparing their indices would equate different strings.
|
|
647
|
+
if (this.standalone && a.t === 'choice' && b.t === 'choice')
|
|
648
|
+
return I.or(...a.values.filter(x => b.values.includes(x)).map(x => I.and(I.is(a.e, x), I.is(b.e, x))));
|
|
629
649
|
if (a.t === 'choice' && (b.t === 'choice' || b.t === 'str'))
|
|
630
650
|
return I.leq(a.e, b.t === 'str' && b.e.op === 'slit' && !a.values.includes(b.e.value) ? I.llit(b.e.value, [...a.values, b.e.value]) : this.asChoice(b, a.values, at));
|
|
631
651
|
if (b.t === 'choice' && a.t === 'str')
|
|
@@ -993,8 +1013,6 @@ export class Exec {
|
|
|
993
1013
|
return { t: 'num', e: I.nite(c, x.e, y.e) };
|
|
994
1014
|
if (x.t === 'bool' && y.t === 'bool')
|
|
995
1015
|
return { t: 'bool', e: I.bite(c, x.e, y.e) };
|
|
996
|
-
if (x.t === 'choice' && y.t === 'choice')
|
|
997
|
-
return { t: 'choice', e: I.lite(c, x.e, y.e), values: x.values };
|
|
998
1016
|
if ((x.t === 'choice' || x.t === 'str') && (y.t === 'choice' || y.t === 'str')) {
|
|
999
1017
|
if (x.t === 'str' && y.t === 'str')
|
|
1000
1018
|
return { t: 'str', e: I.kite(c, x.e, y.e) };
|
|
@@ -1080,11 +1098,11 @@ export class Exec {
|
|
|
1080
1098
|
})();
|
|
1081
1099
|
if (opaque)
|
|
1082
1100
|
return [{ t: 'opaque', what: opaque }, p];
|
|
1083
|
-
const
|
|
1084
|
-
//
|
|
1085
|
-
const seen = [...this.s.lazy].find(([, l]) => l
|
|
1086
|
-
const nvar = seen ? this.s.vars.get(seen) : this.newVar(
|
|
1087
|
-
this.s.lazy.set(nvar.name, {
|
|
1101
|
+
const key = lazyKey(o.lazy, f), sort = this.s.lazySorts.get(key) ?? typed ?? { k: 'num' };
|
|
1102
|
+
// Repeated reads share one input, independently of its readable scalar name.
|
|
1103
|
+
const seen = [...this.s.lazy].find(([, l]) => lazyKey(l, l.field) === key)?.[0];
|
|
1104
|
+
const nvar = seen ? this.s.vars.get(seen) : this.newVar(`${o.lazy.prefix}${f}`, sort, 'input'), nv = Exec.valueOf(nvar);
|
|
1105
|
+
this.s.lazy.set(nvar.name, { ...o.lazy, field: f });
|
|
1088
1106
|
const fields = new Map(o.fields).set(f, nv);
|
|
1089
1107
|
return [nv, { ...p, heap: new Map(p.heap).set(v.id, { ...o, fields }) }];
|
|
1090
1108
|
}
|