worldvm 0.0.0-stage → 0.1.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/AUTHORING.md +833 -0
- package/README.md +154 -2
- package/bin/worldvm.mjs +3 -0
- package/dist/_internal/forma/index.d.ts +1 -0
- package/dist/_internal/forma/index.js +1 -0
- package/dist/_internal/forma/world/authoring-help.d.ts +25 -0
- package/dist/_internal/forma/world/authoring-help.js +130 -0
- package/dist/_internal/forma/world/citations.d.ts +3 -0
- package/dist/_internal/forma/world/citations.js +26 -0
- package/dist/_internal/forma/world/clock-bindings.d.ts +4 -0
- package/dist/_internal/forma/world/clock-bindings.js +45 -0
- package/dist/_internal/forma/world/compile.d.ts +13 -0
- package/dist/_internal/forma/world/compile.js +190 -0
- package/dist/_internal/forma/world/coverage.d.ts +10 -0
- package/dist/_internal/forma/world/coverage.js +242 -0
- package/dist/_internal/forma/world/digest.d.ts +1 -0
- package/dist/_internal/forma/world/digest.js +1 -0
- package/dist/_internal/forma/world/documentation.d.ts +3 -0
- package/dist/_internal/forma/world/documentation.js +38 -0
- package/dist/_internal/forma/world/homes.d.ts +4 -0
- package/dist/_internal/forma/world/homes.js +202 -0
- package/dist/_internal/forma/world/index.d.ts +6 -0
- package/dist/_internal/forma/world/index.js +5 -0
- package/dist/_internal/forma/world/lowering/accounts.d.ts +4 -0
- package/dist/_internal/forma/world/lowering/accounts.js +36 -0
- package/dist/_internal/forma/world/lowering/action-policy.d.ts +5 -0
- package/dist/_internal/forma/world/lowering/action-policy.js +16 -0
- package/dist/_internal/forma/world/lowering/agents.d.ts +6 -0
- package/dist/_internal/forma/world/lowering/agents.js +116 -0
- package/dist/_internal/forma/world/lowering/bundles.d.ts +3 -0
- package/dist/_internal/forma/world/lowering/bundles.js +13 -0
- package/dist/_internal/forma/world/lowering/child-parameters.d.ts +14 -0
- package/dist/_internal/forma/world/lowering/child-parameters.js +36 -0
- package/dist/_internal/forma/world/lowering/collects.d.ts +3 -0
- package/dist/_internal/forma/world/lowering/collects.js +51 -0
- package/dist/_internal/forma/world/lowering/component-operations.d.ts +6 -0
- package/dist/_internal/forma/world/lowering/component-operations.js +26 -0
- package/dist/_internal/forma/world/lowering/components.d.ts +7 -0
- package/dist/_internal/forma/world/lowering/components.js +236 -0
- package/dist/_internal/forma/world/lowering/connectors.d.ts +4 -0
- package/dist/_internal/forma/world/lowering/connectors.js +31 -0
- package/dist/_internal/forma/world/lowering/context.d.ts +80 -0
- package/dist/_internal/forma/world/lowering/context.js +316 -0
- package/dist/_internal/forma/world/lowering/contracts.d.ts +7 -0
- package/dist/_internal/forma/world/lowering/contracts.js +73 -0
- package/dist/_internal/forma/world/lowering/decisions.d.ts +3 -0
- package/dist/_internal/forma/world/lowering/decisions.js +164 -0
- package/dist/_internal/forma/world/lowering/derives.d.ts +3 -0
- package/dist/_internal/forma/world/lowering/derives.js +22 -0
- package/dist/_internal/forma/world/lowering/discretionary.d.ts +7 -0
- package/dist/_internal/forma/world/lowering/discretionary.js +15 -0
- package/dist/_internal/forma/world/lowering/documents.d.ts +3 -0
- package/dist/_internal/forma/world/lowering/documents.js +68 -0
- package/dist/_internal/forma/world/lowering/effective.d.ts +5 -0
- package/dist/_internal/forma/world/lowering/effective.js +26 -0
- package/dist/_internal/forma/world/lowering/entities.d.ts +3 -0
- package/dist/_internal/forma/world/lowering/entities.js +43 -0
- package/dist/_internal/forma/world/lowering/escalations.d.ts +6 -0
- package/dist/_internal/forma/world/lowering/escalations.js +31 -0
- package/dist/_internal/forma/world/lowering/evidence.d.ts +3 -0
- package/dist/_internal/forma/world/lowering/evidence.js +75 -0
- package/dist/_internal/forma/world/lowering/files.d.ts +4 -0
- package/dist/_internal/forma/world/lowering/files.js +56 -0
- package/dist/_internal/forma/world/lowering/holds.d.ts +6 -0
- package/dist/_internal/forma/world/lowering/holds.js +35 -0
- package/dist/_internal/forma/world/lowering/index.d.ts +89 -0
- package/dist/_internal/forma/world/lowering/index.js +115 -0
- package/dist/_internal/forma/world/lowering/interactions.d.ts +7 -0
- package/dist/_internal/forma/world/lowering/interactions.js +190 -0
- package/dist/_internal/forma/world/lowering/library.d.ts +5 -0
- package/dist/_internal/forma/world/lowering/library.js +41 -0
- package/dist/_internal/forma/world/lowering/milestones.d.ts +6 -0
- package/dist/_internal/forma/world/lowering/milestones.js +17 -0
- package/dist/_internal/forma/world/lowering/notices.d.ts +3 -0
- package/dist/_internal/forma/world/lowering/notices.js +33 -0
- package/dist/_internal/forma/world/lowering/param-bounds.d.ts +15 -0
- package/dist/_internal/forma/world/lowering/param-bounds.js +71 -0
- package/dist/_internal/forma/world/lowering/policies.d.ts +6 -0
- package/dist/_internal/forma/world/lowering/policies.js +95 -0
- package/dist/_internal/forma/world/lowering/principals.d.ts +62 -0
- package/dist/_internal/forma/world/lowering/principals.js +32 -0
- package/dist/_internal/forma/world/lowering/recurrences.d.ts +9 -0
- package/dist/_internal/forma/world/lowering/recurrences.js +56 -0
- package/dist/_internal/forma/world/lowering/renewal.d.ts +5 -0
- package/dist/_internal/forma/world/lowering/renewal.js +21 -0
- package/dist/_internal/forma/world/lowering/resources.d.ts +6 -0
- package/dist/_internal/forma/world/lowering/resources.js +19 -0
- package/dist/_internal/forma/world/lowering/reuse.d.ts +5 -0
- package/dist/_internal/forma/world/lowering/reuse.js +75 -0
- package/dist/_internal/forma/world/lowering/sources.d.ts +10 -0
- package/dist/_internal/forma/world/lowering/sources.js +47 -0
- package/dist/_internal/forma/world/lowering/syntax.d.ts +84 -0
- package/dist/_internal/forma/world/lowering/syntax.js +94 -0
- package/dist/_internal/forma/world/lowering/vaults.d.ts +11 -0
- package/dist/_internal/forma/world/lowering/vaults.js +148 -0
- package/dist/_internal/forma/world/prelude.generated.d.ts +1 -0
- package/dist/_internal/forma/world/prelude.generated.js +2 -0
- package/dist/_internal/forma/world/properties.d.ts +9 -0
- package/dist/_internal/forma/world/properties.js +387 -0
- package/dist/_internal/forma/world/scenarios.d.ts +10 -0
- package/dist/_internal/forma/world/scenarios.js +757 -0
- package/dist/_internal/forma/world/sensitivity.d.ts +3 -0
- package/dist/_internal/forma/world/sensitivity.js +118 -0
- package/dist/_internal/forma/world/source-syntax.d.ts +6 -0
- package/dist/_internal/forma/world/source-syntax.js +27 -0
- package/dist/_internal/forma/world/status-handling.d.ts +3 -0
- package/dist/_internal/forma/world/status-handling.js +143 -0
- package/dist/_internal/forma/world/surface.d.ts +30 -0
- package/dist/_internal/forma/world/surface.js +213 -0
- package/dist/_internal/forma/world/table-expressions.d.ts +3 -0
- package/dist/_internal/forma/world/table-expressions.js +41 -0
- package/dist/_internal/forma-tools/index.d.ts +17 -0
- package/dist/_internal/forma-tools/index.js +124 -0
- package/dist/_internal/ir-checks/advances.d.ts +7 -0
- package/dist/_internal/ir-checks/advances.js +6 -0
- package/dist/_internal/ir-checks/agent-reads.d.ts +14 -0
- package/dist/_internal/ir-checks/agent-reads.js +118 -0
- package/dist/_internal/ir-checks/amendments.d.ts +3 -0
- package/dist/_internal/ir-checks/amendments.js +21 -0
- package/dist/_internal/ir-checks/canonical-json.d.ts +3 -0
- package/dist/_internal/ir-checks/canonical-json.js +85 -0
- package/dist/_internal/ir-checks/child-parameters.d.ts +2 -0
- package/dist/_internal/ir-checks/child-parameters.js +43 -0
- package/dist/_internal/ir-checks/clock-bindings.d.ts +3 -0
- package/dist/_internal/ir-checks/clock-bindings.js +43 -0
- package/dist/_internal/ir-checks/collect-types.d.ts +14 -0
- package/dist/_internal/ir-checks/collect-types.js +34 -0
- package/dist/_internal/ir-checks/component-operations.d.ts +4 -0
- package/dist/_internal/ir-checks/component-operations.js +23 -0
- package/dist/_internal/ir-checks/content-digest.d.ts +4 -0
- package/dist/_internal/ir-checks/content-digest.js +78 -0
- package/dist/_internal/ir-checks/contract-validation.d.ts +3 -0
- package/dist/_internal/ir-checks/contract-validation.js +307 -0
- package/dist/_internal/ir-checks/contracts.d.ts +25 -0
- package/dist/_internal/ir-checks/contracts.js +80 -0
- package/dist/_internal/ir-checks/dates.d.ts +2 -0
- package/dist/_internal/ir-checks/dates.js +7 -0
- package/dist/_internal/ir-checks/documents.d.ts +3 -0
- package/dist/_internal/ir-checks/documents.js +45 -0
- package/dist/_internal/ir-checks/evidence.d.ts +20 -0
- package/dist/_internal/ir-checks/evidence.js +56 -0
- package/dist/_internal/ir-checks/files.d.ts +7 -0
- package/dist/_internal/ir-checks/files.js +47 -0
- package/dist/_internal/ir-checks/index.d.ts +59 -0
- package/dist/_internal/ir-checks/index.js +166 -0
- package/dist/_internal/ir-checks/instants.d.ts +7 -0
- package/dist/_internal/ir-checks/instants.js +61 -0
- package/dist/_internal/ir-checks/notices.d.ts +4 -0
- package/dist/_internal/ir-checks/notices.js +58 -0
- package/dist/_internal/ir-checks/policy-bounds.d.ts +5 -0
- package/dist/_internal/ir-checks/policy-bounds.js +28 -0
- package/dist/_internal/ir-checks/principals.d.ts +26 -0
- package/dist/_internal/ir-checks/principals.js +162 -0
- package/dist/_internal/ir-checks/prior-cycle.d.ts +41 -0
- package/dist/_internal/ir-checks/prior-cycle.js +21 -0
- package/dist/_internal/ir-checks/read-classification.d.ts +12 -0
- package/dist/_internal/ir-checks/read-classification.js +67 -0
- package/dist/_internal/ir-checks/read-types.d.ts +2 -0
- package/dist/_internal/ir-checks/read-types.js +40 -0
- package/dist/_internal/ir-checks/resource-proofs.d.ts +4 -0
- package/dist/_internal/ir-checks/resource-proofs.js +98 -0
- package/dist/_internal/ir-checks/resources.d.ts +3 -0
- package/dist/_internal/ir-checks/resources.js +30 -0
- package/dist/_internal/ir-checks/reuse.d.ts +10 -0
- package/dist/_internal/ir-checks/reuse.js +99 -0
- package/dist/_internal/ir-checks/sealing.d.ts +14 -0
- package/dist/_internal/ir-checks/sealing.js +123 -0
- package/dist/_internal/ir-checks/sensitive-flow.d.ts +4 -0
- package/dist/_internal/ir-checks/sensitive-flow.js +240 -0
- package/dist/_internal/ir-checks/sensitivity.d.ts +19 -0
- package/dist/_internal/ir-checks/sensitivity.js +133 -0
- package/dist/_internal/ir-checks/signatures.d.ts +4 -0
- package/dist/_internal/ir-checks/signatures.js +22 -0
- package/dist/_internal/ir-checks/vaults.d.ts +10 -0
- package/dist/_internal/ir-checks/vaults.js +140 -0
- package/dist/_internal/protocol/index.d.ts +1234 -0
- package/dist/_internal/protocol/index.js +215 -0
- package/dist/_internal/reconciler/action-intents.d.ts +17 -0
- package/dist/_internal/reconciler/action-intents.js +161 -0
- package/dist/_internal/reconciler/actions.d.ts +7 -0
- package/dist/_internal/reconciler/actions.js +134 -0
- package/dist/_internal/reconciler/amendments.d.ts +12 -0
- package/dist/_internal/reconciler/amendments.js +52 -0
- package/dist/_internal/reconciler/basis.d.ts +253 -0
- package/dist/_internal/reconciler/basis.js +16 -0
- package/dist/_internal/reconciler/bundles.d.ts +22 -0
- package/dist/_internal/reconciler/bundles.js +110 -0
- package/dist/_internal/reconciler/change-detection.d.ts +5 -0
- package/dist/_internal/reconciler/change-detection.js +82 -0
- package/dist/_internal/reconciler/collection-rules.d.ts +7 -0
- package/dist/_internal/reconciler/collection-rules.js +46 -0
- package/dist/_internal/reconciler/collection-state.d.ts +11 -0
- package/dist/_internal/reconciler/collection-state.js +62 -0
- package/dist/_internal/reconciler/collection-values.d.ts +5 -0
- package/dist/_internal/reconciler/collection-values.js +60 -0
- package/dist/_internal/reconciler/collections.d.ts +35 -0
- package/dist/_internal/reconciler/collections.js +141 -0
- package/dist/_internal/reconciler/commands.d.ts +60 -0
- package/dist/_internal/reconciler/commands.js +468 -0
- package/dist/_internal/reconciler/component-operations.d.ts +48 -0
- package/dist/_internal/reconciler/component-operations.js +256 -0
- package/dist/_internal/reconciler/context.d.ts +38 -0
- package/dist/_internal/reconciler/context.js +44 -0
- package/dist/_internal/reconciler/coverage.d.ts +31 -0
- package/dist/_internal/reconciler/coverage.js +124 -0
- package/dist/_internal/reconciler/dates.d.ts +38 -0
- package/dist/_internal/reconciler/dates.js +121 -0
- package/dist/_internal/reconciler/decide.d.ts +25 -0
- package/dist/_internal/reconciler/decide.js +263 -0
- package/dist/_internal/reconciler/decision-evaluation.d.ts +9 -0
- package/dist/_internal/reconciler/decision-evaluation.js +67 -0
- package/dist/_internal/reconciler/decision-records.d.ts +14 -0
- package/dist/_internal/reconciler/decision-records.js +77 -0
- package/dist/_internal/reconciler/decision-release.d.ts +3 -0
- package/dist/_internal/reconciler/decision-release.js +12 -0
- package/dist/_internal/reconciler/dependencies.d.ts +179 -0
- package/dist/_internal/reconciler/dependencies.js +372 -0
- package/dist/_internal/reconciler/discovery.d.ts +9 -0
- package/dist/_internal/reconciler/discovery.js +65 -0
- package/dist/_internal/reconciler/document-corrections.d.ts +18 -0
- package/dist/_internal/reconciler/document-corrections.js +59 -0
- package/dist/_internal/reconciler/documents.d.ts +26 -0
- package/dist/_internal/reconciler/documents.js +88 -0
- package/dist/_internal/reconciler/effective.d.ts +6 -0
- package/dist/_internal/reconciler/effective.js +17 -0
- package/dist/_internal/reconciler/escalations.d.ts +4 -0
- package/dist/_internal/reconciler/escalations.js +76 -0
- package/dist/_internal/reconciler/evaluation.d.ts +56 -0
- package/dist/_internal/reconciler/evaluation.js +704 -0
- package/dist/_internal/reconciler/evidence-authority.d.ts +6 -0
- package/dist/_internal/reconciler/evidence-authority.js +70 -0
- package/dist/_internal/reconciler/evidence-history.d.ts +5 -0
- package/dist/_internal/reconciler/evidence-history.js +22 -0
- package/dist/_internal/reconciler/evidence-validity.d.ts +17 -0
- package/dist/_internal/reconciler/evidence-validity.js +135 -0
- package/dist/_internal/reconciler/fact-validation.d.ts +5 -0
- package/dist/_internal/reconciler/fact-validation.js +49 -0
- package/dist/_internal/reconciler/files.d.ts +9 -0
- package/dist/_internal/reconciler/files.js +56 -0
- package/dist/_internal/reconciler/graph.d.ts +40 -0
- package/dist/_internal/reconciler/graph.js +298 -0
- package/dist/_internal/reconciler/holds.d.ts +6 -0
- package/dist/_internal/reconciler/holds.js +18 -0
- package/dist/_internal/reconciler/home-definitions.d.ts +11 -0
- package/dist/_internal/reconciler/home-definitions.js +25 -0
- package/dist/_internal/reconciler/homes.d.ts +6 -0
- package/dist/_internal/reconciler/homes.js +32 -0
- package/dist/_internal/reconciler/index.d.ts +42 -0
- package/dist/_internal/reconciler/index.js +58 -0
- package/dist/_internal/reconciler/instants.d.ts +17 -0
- package/dist/_internal/reconciler/instants.js +56 -0
- package/dist/_internal/reconciler/interaction-fields.d.ts +10 -0
- package/dist/_internal/reconciler/interaction-fields.js +30 -0
- package/dist/_internal/reconciler/invariants.d.ts +8 -0
- package/dist/_internal/reconciler/invariants.js +34 -0
- package/dist/_internal/reconciler/journal.d.ts +3 -0
- package/dist/_internal/reconciler/journal.js +4 -0
- package/dist/_internal/reconciler/linking.d.ts +10 -0
- package/dist/_internal/reconciler/linking.js +259 -0
- package/dist/_internal/reconciler/memory.d.ts +32 -0
- package/dist/_internal/reconciler/memory.js +190 -0
- package/dist/_internal/reconciler/milestones.d.ts +7 -0
- package/dist/_internal/reconciler/milestones.js +58 -0
- package/dist/_internal/reconciler/missing.d.ts +18 -0
- package/dist/_internal/reconciler/missing.js +79 -0
- package/dist/_internal/reconciler/model.d.ts +350 -0
- package/dist/_internal/reconciler/model.js +9 -0
- package/dist/_internal/reconciler/notices.d.ts +14 -0
- package/dist/_internal/reconciler/notices.js +80 -0
- package/dist/_internal/reconciler/occurrences.d.ts +3 -0
- package/dist/_internal/reconciler/occurrences.js +30 -0
- package/dist/_internal/reconciler/outputs.d.ts +12 -0
- package/dist/_internal/reconciler/outputs.js +132 -0
- package/dist/_internal/reconciler/parameters.d.ts +4 -0
- package/dist/_internal/reconciler/parameters.js +27 -0
- package/dist/_internal/reconciler/policies.d.ts +22 -0
- package/dist/_internal/reconciler/policies.js +94 -0
- package/dist/_internal/reconciler/policy-edits.d.ts +11 -0
- package/dist/_internal/reconciler/policy-edits.js +42 -0
- package/dist/_internal/reconciler/policy-linking.d.ts +4 -0
- package/dist/_internal/reconciler/policy-linking.js +104 -0
- package/dist/_internal/reconciler/principal-types.d.ts +2 -0
- package/dist/_internal/reconciler/principal-types.js +38 -0
- package/dist/_internal/reconciler/prior-decisions.d.ts +3 -0
- package/dist/_internal/reconciler/prior-decisions.js +34 -0
- package/dist/_internal/reconciler/projections.d.ts +4 -0
- package/dist/_internal/reconciler/projections.js +85 -0
- package/dist/_internal/reconciler/proofs.d.ts +9 -0
- package/dist/_internal/reconciler/proofs.js +24 -0
- package/dist/_internal/reconciler/properties.d.ts +25 -0
- package/dist/_internal/reconciler/properties.js +67 -0
- package/dist/_internal/reconciler/property-eval.d.ts +5 -0
- package/dist/_internal/reconciler/property-eval.js +101 -0
- package/dist/_internal/reconciler/property-generator.d.ts +9 -0
- package/dist/_internal/reconciler/property-generator.js +288 -0
- package/dist/_internal/reconciler/property-shrink.d.ts +14 -0
- package/dist/_internal/reconciler/property-shrink.js +183 -0
- package/dist/_internal/reconciler/provenance.d.ts +8 -0
- package/dist/_internal/reconciler/provenance.js +61 -0
- package/dist/_internal/reconciler/reconcile.d.ts +32 -0
- package/dist/_internal/reconciler/reconcile.js +164 -0
- package/dist/_internal/reconciler/recurrence.d.ts +9 -0
- package/dist/_internal/reconciler/recurrence.js +44 -0
- package/dist/_internal/reconciler/requirements.d.ts +5 -0
- package/dist/_internal/reconciler/requirements.js +331 -0
- package/dist/_internal/reconciler/resource-generation.d.ts +9 -0
- package/dist/_internal/reconciler/resource-generation.js +17 -0
- package/dist/_internal/reconciler/resource-scenarios.d.ts +26 -0
- package/dist/_internal/reconciler/resource-scenarios.js +78 -0
- package/dist/_internal/reconciler/resources.d.ts +24 -0
- package/dist/_internal/reconciler/resources.js +178 -0
- package/dist/_internal/reconciler/result-digest.d.ts +13 -0
- package/dist/_internal/reconciler/result-digest.js +66 -0
- package/dist/_internal/reconciler/reuse.d.ts +16 -0
- package/dist/_internal/reconciler/reuse.js +119 -0
- package/dist/_internal/reconciler/scenarios.d.ts +32 -0
- package/dist/_internal/reconciler/scenarios.js +442 -0
- package/dist/_internal/reconciler/scheduling.d.ts +9 -0
- package/dist/_internal/reconciler/scheduling.js +203 -0
- package/dist/_internal/reconciler/sha256.d.ts +1 -0
- package/dist/_internal/reconciler/sha256.js +1 -0
- package/dist/_internal/reconciler/signatures.d.ts +13 -0
- package/dist/_internal/reconciler/signatures.js +37 -0
- package/dist/_internal/reconciler/temporal.d.ts +10 -0
- package/dist/_internal/reconciler/temporal.js +46 -0
- package/dist/_internal/reconciler/upgrades.d.ts +6 -0
- package/dist/_internal/reconciler/upgrades.js +65 -0
- package/dist/_internal/reconciler/wire.d.ts +2 -0
- package/dist/_internal/reconciler/wire.js +5 -0
- package/dist/_internal/reconciler/work.d.ts +32 -0
- package/dist/_internal/reconciler/work.js +101 -0
- package/dist/_internal/world-ir/schema.generated.d.ts +180 -0
- package/dist/_internal/world-ir/schema.generated.js +1127 -0
- package/dist/_internal/world-ir/types.generated.d.ts +1011 -0
- package/dist/_internal/world-ir/types.generated.js +1 -0
- package/dist/authoring.d.ts +9 -0
- package/dist/authoring.js +10 -0
- package/dist/catalogue.d.ts +20 -0
- package/dist/catalogue.js +531 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +553 -0
- package/dist/codegen.d.ts +6 -0
- package/dist/codegen.js +89 -0
- package/dist/coverage.d.ts +60 -0
- package/dist/coverage.js +128 -0
- package/dist/deploy.d.ts +21 -0
- package/dist/deploy.js +72 -0
- package/dist/diagnostics.d.ts +9 -0
- package/dist/diagnostics.js +37 -0
- package/dist/diff.d.ts +17 -0
- package/dist/diff.js +19 -0
- package/dist/durable-object.d.ts +14 -0
- package/dist/durable-object.js +30 -0
- package/dist/explain.d.ts +113 -0
- package/dist/explain.js +225 -0
- package/dist/fixes.d.ts +4 -0
- package/dist/fixes.js +70 -0
- package/dist/fmt.d.ts +12 -0
- package/dist/fmt.js +39 -0
- package/dist/handle/open.d.ts +18 -0
- package/dist/handle/open.js +28 -0
- package/dist/handle/protocol.d.ts +12 -0
- package/dist/handle/protocol.js +96 -0
- package/dist/handle/store.d.ts +31 -0
- package/dist/handle/store.js +11 -0
- package/dist/handle/types.d.ts +37 -0
- package/dist/handle/types.js +1 -0
- package/dist/handle/world.d.ts +190 -0
- package/dist/handle/world.js +533 -0
- package/dist/http.d.ts +3 -0
- package/dist/http.js +72 -0
- package/dist/impact.d.ts +21 -0
- package/dist/impact.js +57 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +43 -0
- package/dist/init.d.ts +13 -0
- package/dist/init.js +99 -0
- package/dist/ir-schema.json +4213 -0
- package/dist/lints.d.ts +8 -0
- package/dist/lints.js +154 -0
- package/dist/lsp.d.ts +14 -0
- package/dist/lsp.js +380 -0
- package/dist/manual/catalog.d.ts +12 -0
- package/dist/manual/catalog.js +23 -0
- package/dist/manual/examples.d.ts +15 -0
- package/dist/manual/examples.js +39 -0
- package/dist/manual/projections.d.ts +77 -0
- package/dist/manual/projections.js +344 -0
- package/dist/manual/prose.d.ts +19 -0
- package/dist/manual/prose.js +215 -0
- package/dist/manual/render.d.ts +76 -0
- package/dist/manual/render.js +250 -0
- package/dist/manual/text.d.ts +7 -0
- package/dist/manual/text.js +15 -0
- package/dist/mcp.d.ts +32 -0
- package/dist/mcp.js +269 -0
- package/dist/mutate.d.ts +36 -0
- package/dist/mutate.js +123 -0
- package/dist/project.d.ts +26 -0
- package/dist/project.js +80 -0
- package/dist/refine.d.ts +18 -0
- package/dist/refine.js +197 -0
- package/dist/release/diff.d.ts +45 -0
- package/dist/release/diff.js +103 -0
- package/dist/release/impact.d.ts +83 -0
- package/dist/release/impact.js +214 -0
- package/dist/release/nodes.d.ts +20 -0
- package/dist/release/nodes.js +118 -0
- package/dist/render.d.ts +19 -0
- package/dist/render.js +43 -0
- package/dist/serve.d.ts +18 -0
- package/dist/serve.js +140 -0
- package/dist/snapshot.d.ts +19 -0
- package/dist/snapshot.js +45 -0
- package/dist/sqlite.d.ts +16 -0
- package/dist/sqlite.js +151 -0
- package/dist/test.d.ts +54 -0
- package/dist/test.js +131 -0
- package/dist/world.d.ts +7 -0
- package/dist/world.js +5 -0
- package/docs/authoring/vendor-risk/example.forma +11 -0
- package/docs/authoring/vendor-risk/library/vendor.forma +76 -0
- package/docs/authoring/vendor-risk/scenarios/reviews.forma +107 -0
- package/docs/protocol.md +195 -0
- package/docs/reference.md +258 -0
- package/package.json +81 -3
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import { scenarioResources, observeScenarioLifecycles, scenarioResourceObservation, } from "./resource-scenarios.js";
|
|
2
|
+
import { instanceId, instanceContext } from "./evaluation.js";
|
|
3
|
+
import { canAttestEvidence } from "./evidence-authority.js";
|
|
4
|
+
import { invokeOperation } from "./component-operations.js";
|
|
5
|
+
import { evidenceFilesAllowed } from "./files.js";
|
|
6
|
+
import { occurrenceHome } from "./homes.js";
|
|
7
|
+
import { canPerformWork, actionTargets } from "./work.js";
|
|
8
|
+
import { recordMilestones } from "./milestones.js";
|
|
9
|
+
import { decide } from "./decide.js";
|
|
10
|
+
import { priorCycleOperationName } from "../ir-checks/index.js";
|
|
11
|
+
import { evaluateProperty } from "./property-eval.js";
|
|
12
|
+
import { command, perform, signal, validEvidence } from "./commands.js";
|
|
13
|
+
import { basis, emptyWorld } from "./memory.js";
|
|
14
|
+
import { findOccurrence } from "./occurrences.js";
|
|
15
|
+
import { link, canTransition, programFor, reconcile, } from "./reconcile.js";
|
|
16
|
+
class ScenarioError extends Error {
|
|
17
|
+
at;
|
|
18
|
+
constructor(message, at) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.at = at;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const scalar = (value) => {
|
|
24
|
+
if (value.k === "entity")
|
|
25
|
+
return value.name;
|
|
26
|
+
if (value.k === "literal")
|
|
27
|
+
return value.value;
|
|
28
|
+
throw new ScenarioError("A stored field must be a scalar or an entity alias.", value.at);
|
|
29
|
+
};
|
|
30
|
+
const select = (recon, account, target) => {
|
|
31
|
+
const key = target.key.map((v) => v.k === "instance" ? { inst: select(recon, account, v).id } : scalar(v));
|
|
32
|
+
const found = findOccurrence(recon, account, target.component, key, target.cycle);
|
|
33
|
+
if (!found)
|
|
34
|
+
throw new ScenarioError(`No matching occurrence of ${target.component}${target.cycle ? ` cycle ${target.cycle}` : ""}.`, target.at);
|
|
35
|
+
return found;
|
|
36
|
+
};
|
|
37
|
+
const resourceTarget = (recon, account, target) => {
|
|
38
|
+
try {
|
|
39
|
+
return select(recon, account, target).id;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (!(error instanceof ScenarioError))
|
|
43
|
+
throw error;
|
|
44
|
+
return instanceId(target.component, target.key.map((v) => v.k === "instance" ? { inst: resourceTarget(recon, account, v) } : scalar(v)), target.cycle ?? 1);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const values = (fields) => Object.fromEntries(fields.flatMap((f) => {
|
|
48
|
+
const v = scalar(f.value);
|
|
49
|
+
return v === null ? [] : [[f.name, String(v)]];
|
|
50
|
+
}));
|
|
51
|
+
const inputs = (fields) => Object.fromEntries(fields.flatMap((f) => {
|
|
52
|
+
const v = scalar(f.value);
|
|
53
|
+
return v === null ? [] : [[f.name, v]];
|
|
54
|
+
}));
|
|
55
|
+
const execute = (ir, scenario, world, recon, date, request, commandId) => {
|
|
56
|
+
const accepted = (next) => ({ world: next, outcome: { accepted: true, codes: [] } });
|
|
57
|
+
const rejected = (code, next = world, extra = []) => ({
|
|
58
|
+
world: next,
|
|
59
|
+
outcome: { accepted: false, codes: [code, ...extra] },
|
|
60
|
+
});
|
|
61
|
+
if (request.kind === "resource")
|
|
62
|
+
return scenarioResourceObservation(recon, world, date, scenario.world, resourceTarget(recon, scenario.world, request.target), request, commandId);
|
|
63
|
+
const by = String(scalar(request.by));
|
|
64
|
+
const profile = scenario.actors?.find((a) => a.name === by);
|
|
65
|
+
const authority = {
|
|
66
|
+
id: by,
|
|
67
|
+
kind: profile?.kind ?? "human",
|
|
68
|
+
groups: profile?.groups ?? [],
|
|
69
|
+
};
|
|
70
|
+
if (request.kind === "set") {
|
|
71
|
+
const given = scenario.given.find((e) => e.name === request.entity), entity = ir.entities.find((e) => e.name === given.entity);
|
|
72
|
+
const next = command(recon, world, date, {
|
|
73
|
+
kind: request.commandKind ?? "set",
|
|
74
|
+
subject: request.subject ?? request.entity,
|
|
75
|
+
by,
|
|
76
|
+
title: `Set ${request.entity}.${request.field}`,
|
|
77
|
+
facts: [{ e: request.entity, a: `${entity.ns}/${request.field}`, v: scalar(request.value) }],
|
|
78
|
+
});
|
|
79
|
+
return next.violations.length
|
|
80
|
+
? rejected("invariant", next.world, next.violations.map((v) => v.invariant))
|
|
81
|
+
: accepted(next.world);
|
|
82
|
+
}
|
|
83
|
+
if ((request.kind === "evidence" || request.kind === "signal") &&
|
|
84
|
+
request.date &&
|
|
85
|
+
request.date !== date)
|
|
86
|
+
return rejected("command-date");
|
|
87
|
+
let inst;
|
|
88
|
+
try {
|
|
89
|
+
inst = select(recon, scenario.world, request.target);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (!(error instanceof ScenarioError))
|
|
93
|
+
throw error;
|
|
94
|
+
return rejected("no-occurrence");
|
|
95
|
+
}
|
|
96
|
+
const program = programFor(recon, inst.id);
|
|
97
|
+
if (request.kind === "perform" && request.amend) {
|
|
98
|
+
const result = invokeOperation(recon, world, date, {
|
|
99
|
+
id: commandId,
|
|
100
|
+
account: scenario.world,
|
|
101
|
+
target: { instance: inst.id },
|
|
102
|
+
operation: request.action,
|
|
103
|
+
actor: authority,
|
|
104
|
+
values: inputs(request.values),
|
|
105
|
+
unsigned: request.unsigned,
|
|
106
|
+
amend: request.amend,
|
|
107
|
+
...(request.signature ? { signature: request.signature } : {}),
|
|
108
|
+
});
|
|
109
|
+
return { world: result.world, outcome: { accepted: result.accepted, codes: result.codes } };
|
|
110
|
+
}
|
|
111
|
+
if (request.kind === "decide") {
|
|
112
|
+
const result = decide(recon, world, date, {
|
|
113
|
+
id: request.id ?? commandId,
|
|
114
|
+
instance: inst.id,
|
|
115
|
+
decision: request.decision,
|
|
116
|
+
actor: authority,
|
|
117
|
+
...(request.reason === undefined ? {} : { reason: request.reason }),
|
|
118
|
+
...(request.revoke ? { revoke: request.revoke } : {}),
|
|
119
|
+
});
|
|
120
|
+
return { world: result.world, outcome: { accepted: result.accepted, codes: result.codes } };
|
|
121
|
+
}
|
|
122
|
+
if (request.kind === "signal") {
|
|
123
|
+
const next = signal(recon, world, date, {
|
|
124
|
+
instance: inst.id,
|
|
125
|
+
machine: request.machine,
|
|
126
|
+
state: request.state,
|
|
127
|
+
by,
|
|
128
|
+
});
|
|
129
|
+
return canTransition(program, basis(world, date), inst, request.machine, request.state)
|
|
130
|
+
? accepted(next)
|
|
131
|
+
: rejected("transition", next);
|
|
132
|
+
}
|
|
133
|
+
if (request.kind === "evidence") {
|
|
134
|
+
if (request.status === "attested" && authority.kind === "agent")
|
|
135
|
+
return rejected("human-required");
|
|
136
|
+
const result = recon.results.get(inst.id);
|
|
137
|
+
const occurrence = `${inst.id}/${request.requirement}${request.requirementCycle === undefined ? "" : `@${request.requirementCycle}`}`;
|
|
138
|
+
const authorized = result.actions.some((action) => action.kind === "interaction" &&
|
|
139
|
+
(action.state === "eligible" || action.state === "dispatched") &&
|
|
140
|
+
actionTargets(action).includes(request.requirement) &&
|
|
141
|
+
result.requirements.some((r) => r.name === request.requirement && r.occurrence === occurrence) &&
|
|
142
|
+
program.interactions.get(action.interaction ?? "")?.produces === request.evidence &&
|
|
143
|
+
canPerformWork(action, authority, by));
|
|
144
|
+
if (!authorized ||
|
|
145
|
+
(request.status === "attested" &&
|
|
146
|
+
!canAttestEvidence(instanceContext(recon, basis(world, date), inst), request.evidence, authority)))
|
|
147
|
+
return rejected("not-assignee");
|
|
148
|
+
if (request.status === "attested" && program.evidence.get(request.evidence)?.attest?.audit)
|
|
149
|
+
return rejected("signature-required");
|
|
150
|
+
if (request.status === "attested" &&
|
|
151
|
+
(!validEvidence(program, request.evidence, inputs(request.values), date) ||
|
|
152
|
+
!evidenceFilesAllowed(program, basis(world, date), occurrenceHome(program, inst, recon.instances)?.id, request.evidence, inputs(request.values))))
|
|
153
|
+
return rejected("evidence-invalid");
|
|
154
|
+
return accepted({
|
|
155
|
+
...world,
|
|
156
|
+
evidence: [
|
|
157
|
+
...world.evidence,
|
|
158
|
+
{
|
|
159
|
+
id: `ev-${world.evidence.length + 1}`,
|
|
160
|
+
type: request.evidence,
|
|
161
|
+
occurrence,
|
|
162
|
+
status: request.status,
|
|
163
|
+
at: date,
|
|
164
|
+
by,
|
|
165
|
+
values: values(request.values),
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const name = request.kind === "accept" ? `accept-prior:${request.requirement}` : request.action;
|
|
171
|
+
if (request.kind === "accept" && request.revoke) {
|
|
172
|
+
const result = decide(recon, world, date, {
|
|
173
|
+
id: request.id ?? commandId,
|
|
174
|
+
instance: inst.id,
|
|
175
|
+
decision: priorCycleOperationName(programFor(recon, inst.id).ir.decisions ?? [], inst.component, request.requirement, request.decision),
|
|
176
|
+
actor: authority,
|
|
177
|
+
revoke: request.revoke,
|
|
178
|
+
...(request.reason === undefined ? {} : { reason: request.reason }),
|
|
179
|
+
});
|
|
180
|
+
return { world: result.world, outcome: { accepted: result.accepted, codes: result.codes } };
|
|
181
|
+
}
|
|
182
|
+
const action = recon.results.get(inst.id).actions.find((a) => a.action === name);
|
|
183
|
+
if (!action || (action.state !== "eligible" && action.state !== "dispatched"))
|
|
184
|
+
return rejected("not-eligible");
|
|
185
|
+
if (request.kind === "accept") {
|
|
186
|
+
const result = decide(recon, world, date, {
|
|
187
|
+
id: request.id ?? commandId,
|
|
188
|
+
instance: inst.id,
|
|
189
|
+
decision: priorCycleOperationName(programFor(recon, inst.id).ir.decisions ?? [], inst.component, request.requirement, request.decision),
|
|
190
|
+
actor: authority,
|
|
191
|
+
...(request.reason === undefined ? {} : { reason: request.reason }),
|
|
192
|
+
});
|
|
193
|
+
if (!result.accepted)
|
|
194
|
+
return { world: result.world, outcome: { accepted: false, codes: result.codes } };
|
|
195
|
+
return accepted({
|
|
196
|
+
...result.world,
|
|
197
|
+
acceptances: result.world === world
|
|
198
|
+
? world.acceptances
|
|
199
|
+
: [
|
|
200
|
+
...result.world.acceptances,
|
|
201
|
+
{
|
|
202
|
+
instance: inst.id,
|
|
203
|
+
requirement: request.requirement,
|
|
204
|
+
from: inst.prior ?? "",
|
|
205
|
+
decision: request.decision,
|
|
206
|
+
by,
|
|
207
|
+
at: date,
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
if (authority.kind === "agent" && !request.unsigned)
|
|
213
|
+
return rejected("human-required");
|
|
214
|
+
if (!canPerformWork(action, authority, by) ||
|
|
215
|
+
(action.kind === "interaction" &&
|
|
216
|
+
!request.unsigned &&
|
|
217
|
+
!canAttestEvidence(instanceContext(recon, basis(world, date), inst), program.interactions.get(action.interaction).produces, authority)))
|
|
218
|
+
return rejected("not-assignee");
|
|
219
|
+
const next = perform(recon, world, date, {
|
|
220
|
+
instance: inst.id,
|
|
221
|
+
action: name,
|
|
222
|
+
by,
|
|
223
|
+
unsigned: request.unsigned,
|
|
224
|
+
...(request.signature ? { signature: request.signature } : {}),
|
|
225
|
+
actor: authority,
|
|
226
|
+
values: inputs(request.values),
|
|
227
|
+
});
|
|
228
|
+
// The shared command snapshots bound facts before validating the signed record.
|
|
229
|
+
return action.interaction && next === world ? rejected("evidence-invalid") : accepted(next);
|
|
230
|
+
};
|
|
231
|
+
const observed = (recon, account, expectation, commands, world) => {
|
|
232
|
+
if (expectation.kind === "property") {
|
|
233
|
+
const property = recon.programs
|
|
234
|
+
.find((p) => p.account.name === account)
|
|
235
|
+
?.ir.properties?.find((p) => p.name === expectation.name && p.world === account);
|
|
236
|
+
if (!property)
|
|
237
|
+
throw new ScenarioError("Unknown property in this observation.", expectation.at);
|
|
238
|
+
return evaluateProperty(property, world, recon, expectation.binding);
|
|
239
|
+
}
|
|
240
|
+
if (expectation.kind === "rejected") {
|
|
241
|
+
const outcome = commands[expectation.command - 1];
|
|
242
|
+
if (!outcome)
|
|
243
|
+
throw new ScenarioError("No command outcome in this observation.", expectation.at);
|
|
244
|
+
if (typeof expectation.expected === "boolean")
|
|
245
|
+
return !outcome.accepted;
|
|
246
|
+
return outcome.codes.includes(expectation.expected)
|
|
247
|
+
? expectation.expected
|
|
248
|
+
: outcome.accepted
|
|
249
|
+
? "accepted"
|
|
250
|
+
: outcome.codes.join(", ");
|
|
251
|
+
}
|
|
252
|
+
if (expectation.kind === "resource") {
|
|
253
|
+
const id = resourceTarget(recon, account, expectation.target), projections = scenarioResources(recon, world, recon.now)
|
|
254
|
+
.filter((s) => s.program.account.name === account)
|
|
255
|
+
.map((s) => s.projection), intent = projections
|
|
256
|
+
.flatMap((p) => p.intents)
|
|
257
|
+
.find((i) => i.instance === id && i.resource === expectation.name), view = projections
|
|
258
|
+
.flatMap((p) => p.views)
|
|
259
|
+
.filter((v) => v.instance === id && v.resource === expectation.name)
|
|
260
|
+
.sort((a, b) => b.generation - a.generation)[0];
|
|
261
|
+
return intent?.phase ?? view?.state ?? "absent";
|
|
262
|
+
}
|
|
263
|
+
const inst = select(recon, account, expectation.target), result = recon.results.get(inst.id);
|
|
264
|
+
const requirement = result.requirements.find((r) => r.name === expectation.name);
|
|
265
|
+
switch (expectation.kind) {
|
|
266
|
+
case "retention":
|
|
267
|
+
return result.retention?.[expectation.field];
|
|
268
|
+
case "status":
|
|
269
|
+
return requirement?.status ?? result.outputs.find((o) => o.name === expectation.name)?.status;
|
|
270
|
+
case "due":
|
|
271
|
+
return requirement?.due;
|
|
272
|
+
case "work":
|
|
273
|
+
return result.actions.find((a) => a.action === expectation.name)?.state ?? "absent";
|
|
274
|
+
case "blocked":
|
|
275
|
+
return result.blocked.some((r) => r.requirement === expectation.name);
|
|
276
|
+
case "why":
|
|
277
|
+
return requirement?.reasons.map((r) => `${r.label}: ${r.detail}`).join("\n");
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
const runWithProgram = (ir, scenario, resolveProgram) => {
|
|
281
|
+
let world = emptyWorld, assertions = 0;
|
|
282
|
+
const failures = [], steps = [];
|
|
283
|
+
const report = () => ({
|
|
284
|
+
name: scenario.name,
|
|
285
|
+
passed: failures.length === 0,
|
|
286
|
+
assertions,
|
|
287
|
+
failures,
|
|
288
|
+
steps,
|
|
289
|
+
world,
|
|
290
|
+
});
|
|
291
|
+
try {
|
|
292
|
+
const first = scenario.steps[0];
|
|
293
|
+
if (!first)
|
|
294
|
+
throw new ScenarioError("A scenario needs a dated observation.", scenario.at);
|
|
295
|
+
const program = resolveProgram(scenario.world), programs = [program];
|
|
296
|
+
world = {
|
|
297
|
+
...emptyWorld,
|
|
298
|
+
...(scenario.files?.length
|
|
299
|
+
? {
|
|
300
|
+
files: scenario.files.map((f) => ({
|
|
301
|
+
account: scenario.world,
|
|
302
|
+
home: f.home,
|
|
303
|
+
digest: f.digest,
|
|
304
|
+
mediaType: f.mediaType,
|
|
305
|
+
size: f.size,
|
|
306
|
+
scan: f.scan,
|
|
307
|
+
redacted: f.redacted,
|
|
308
|
+
at: f.date ?? first.date,
|
|
309
|
+
by: "scenario:scanner",
|
|
310
|
+
})),
|
|
311
|
+
}
|
|
312
|
+
: {}),
|
|
313
|
+
facts: scenario.given.flatMap((e) => {
|
|
314
|
+
const entity = ir.entities.find((t) => t.name === e.entity);
|
|
315
|
+
if (!entity)
|
|
316
|
+
throw new ScenarioError(`Unknown entity ${e.entity}.`, e.at);
|
|
317
|
+
const fields = e.fields.length
|
|
318
|
+
? e.fields.map((f) => ({ name: f.name, value: scalar(f.value) }))
|
|
319
|
+
: // A null attribute establishes namespace membership without asserting a missing fact.
|
|
320
|
+
[{ name: entity.fields[0]?.name ?? "__exists", value: null }];
|
|
321
|
+
return fields.map((f) => ({
|
|
322
|
+
e: e.name,
|
|
323
|
+
a: `${entity.ns}/${f.name}`,
|
|
324
|
+
v: f.value,
|
|
325
|
+
at: first.date,
|
|
326
|
+
by: "scenario",
|
|
327
|
+
}));
|
|
328
|
+
}),
|
|
329
|
+
};
|
|
330
|
+
let recon = reconcile(programs, basis(world, first.date), first.date);
|
|
331
|
+
for (const [i, record] of (scenario.records ?? []).entries()) {
|
|
332
|
+
if (record.kind === "evidence" &&
|
|
333
|
+
record.status === "attested" &&
|
|
334
|
+
scenario.actors?.some((a) => a.name === String(scalar(record.by)) && a.kind === "agent"))
|
|
335
|
+
throw new ScenarioError("Agents cannot attest evidence.", record.at);
|
|
336
|
+
const inst = select(recon, scenario.world, record.target), at = record.date ?? first.date, by = String(scalar(record.by));
|
|
337
|
+
world =
|
|
338
|
+
record.kind === "signal"
|
|
339
|
+
? {
|
|
340
|
+
...world,
|
|
341
|
+
signals: [
|
|
342
|
+
...world.signals,
|
|
343
|
+
{ instance: inst.id, machine: record.machine, state: record.state, at, by },
|
|
344
|
+
],
|
|
345
|
+
}
|
|
346
|
+
: {
|
|
347
|
+
...world,
|
|
348
|
+
evidence: [
|
|
349
|
+
...world.evidence,
|
|
350
|
+
{
|
|
351
|
+
id: `scenario:${scenario.name}:${i + 1}`,
|
|
352
|
+
type: record.evidence,
|
|
353
|
+
occurrence: `${inst.id}/${record.requirement}${record.requirementCycle === undefined ? "" : `@${record.requirementCycle}`}`,
|
|
354
|
+
status: record.status,
|
|
355
|
+
values: values(record.values),
|
|
356
|
+
at,
|
|
357
|
+
by,
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
};
|
|
361
|
+
recon = reconcile(programs, basis(world, first.date), first.date);
|
|
362
|
+
}
|
|
363
|
+
// Given records are one setup snapshot; observe each dated step and admitted command.
|
|
364
|
+
const observe = (date) => {
|
|
365
|
+
let current = reconcile(programs, basis(world, date), date);
|
|
366
|
+
const resources = observeScenarioLifecycles(current, world, date);
|
|
367
|
+
if (resources !== world) {
|
|
368
|
+
world = resources;
|
|
369
|
+
current = reconcile(programs, basis(world, date), date);
|
|
370
|
+
}
|
|
371
|
+
const recorded = recordMilestones(current, world);
|
|
372
|
+
if (recorded === world)
|
|
373
|
+
return current;
|
|
374
|
+
world = recorded;
|
|
375
|
+
return reconcile(programs, basis(world, date), date);
|
|
376
|
+
};
|
|
377
|
+
for (const [stepIndex, step] of scenario.steps.entries()) {
|
|
378
|
+
let current = observe(step.date);
|
|
379
|
+
const commands = [];
|
|
380
|
+
for (const [i, request] of (step.commands ?? []).entries()) {
|
|
381
|
+
const next = execute(ir, scenario, world, current, step.date, request, `scenario:${scenario.name}:${stepIndex}:${i + 1}`);
|
|
382
|
+
world = next.world;
|
|
383
|
+
commands.push(next.outcome);
|
|
384
|
+
if (!next.outcome.accepted &&
|
|
385
|
+
!step.expects.some((e) => e.kind === "rejected" && e.command === i + 1))
|
|
386
|
+
failures.push({
|
|
387
|
+
code: "E_SCENARIO_RUN",
|
|
388
|
+
message: `Unasserted command rejection: ${next.outcome.codes.join(", ")}.`,
|
|
389
|
+
at: request.at,
|
|
390
|
+
});
|
|
391
|
+
current = observe(step.date);
|
|
392
|
+
}
|
|
393
|
+
steps.push({ date: step.date, reconciliation: current, commands });
|
|
394
|
+
for (const expectation of step.expects) {
|
|
395
|
+
assertions++;
|
|
396
|
+
try {
|
|
397
|
+
const actual = observed(current, scenario.world, expectation, commands, world), expected = expectation.expected;
|
|
398
|
+
const passed = expectation.kind === "why"
|
|
399
|
+
? typeof actual === "string" && actual.includes(expected)
|
|
400
|
+
: actual === expected;
|
|
401
|
+
if (!passed)
|
|
402
|
+
failures.push({
|
|
403
|
+
code: "E_SCENARIO_ASSERT",
|
|
404
|
+
message: `${expectation.kind} expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}.`,
|
|
405
|
+
at: expectation.at,
|
|
406
|
+
expected,
|
|
407
|
+
actual,
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
catch (error) {
|
|
411
|
+
if (!(error instanceof ScenarioError))
|
|
412
|
+
throw error;
|
|
413
|
+
failures.push({
|
|
414
|
+
code: "E_SCENARIO_ASSERT",
|
|
415
|
+
message: error.message,
|
|
416
|
+
at: expectation.at,
|
|
417
|
+
expected: expectation.expected,
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
if (!(error instanceof ScenarioError))
|
|
425
|
+
throw error;
|
|
426
|
+
failures.push({ code: "E_SCENARIO_RUN", message: error.message, at: error.at });
|
|
427
|
+
}
|
|
428
|
+
return report();
|
|
429
|
+
};
|
|
430
|
+
/** A session reuses immutable linked programs, never scenario facts or evaluation state. */
|
|
431
|
+
export const createScenarioRunner = (ir) => {
|
|
432
|
+
const programs = new Map();
|
|
433
|
+
return (scenario) => runWithProgram(ir, scenario, (account) => {
|
|
434
|
+
let program = programs.get(account);
|
|
435
|
+
if (!program)
|
|
436
|
+
programs.set(account, (program = link(ir, account)));
|
|
437
|
+
return program;
|
|
438
|
+
});
|
|
439
|
+
};
|
|
440
|
+
/** Runs authored finite test data through pure reconciliation. */
|
|
441
|
+
export const runScenario = (ir, scenario) => createScenarioRunner(ir)(scenario);
|
|
442
|
+
export const runScenarios = (ir) => (ir.scenarios ?? []).map(createScenarioRunner(ir));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type EvaluationContext, type PredictedStatus } from "./context.js";
|
|
2
|
+
import { type LocalDate } from "./dates.js";
|
|
3
|
+
import { type Cx, type Instance } from "./model.js";
|
|
4
|
+
export declare const timed: <T>(ctx: EvaluationContext, cx: Cx, path: readonly string[], why: string, read: (active: Cx) => T, signature?: (value: T) => string, options?: {
|
|
5
|
+
readonly enabled?: () => boolean;
|
|
6
|
+
readonly discovery?: boolean;
|
|
7
|
+
readonly instance?: string;
|
|
8
|
+
}) => T;
|
|
9
|
+
export declare function predictStatus(ctx: EvaluationContext, inst: Instance, name: string, at: LocalDate): PredictedStatus;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { policyRequirements } from "./policies.js";
|
|
2
|
+
import { timeOrder, isPastDeadline, nextTime, deadlineOrder } from "./instants.js";
|
|
3
|
+
import {} from "./context.js";
|
|
4
|
+
import {} from "./dates.js";
|
|
5
|
+
import { forecastBasis, observeBasis, ReadSet } from "./dependencies.js";
|
|
6
|
+
import { evaluateIn, timeOf, instanceEnv, isUnknown, legacyAcceptance, selectedDecision, selectedAddition, truth, } from "./evaluation.js";
|
|
7
|
+
import {} from "./model.js";
|
|
8
|
+
import { allOf, anyOf } from "./outputs.js";
|
|
9
|
+
import { semanticJson } from "./result-digest.js";
|
|
10
|
+
import { readEffective } from "./effective.js";
|
|
11
|
+
import { readRecurrence } from "./recurrence.js";
|
|
12
|
+
import { and } from "./evaluation.js";
|
|
13
|
+
import { firstChange } from "./temporal.js";
|
|
14
|
+
const recurringPrograms = new WeakMap();
|
|
15
|
+
const hasRecurrence = (program) => {
|
|
16
|
+
let value = recurringPrograms.get(program);
|
|
17
|
+
if (value === undefined) {
|
|
18
|
+
value = [...program.components.values()].some((c) => c.requirements.some((r) => r.recur));
|
|
19
|
+
recurringPrograms.set(program, value);
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
export const timed = (ctx, cx, path, why, read, signature = semanticJson, options = {}) => {
|
|
24
|
+
const cutoffs = new Set();
|
|
25
|
+
const statuses = new Map();
|
|
26
|
+
const currentStatus = (inst, name) => {
|
|
27
|
+
const value = ctx.state.status(inst, name);
|
|
28
|
+
cx.reads.add({ kind: "status", instance: inst.id, name, value });
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
const value = read({
|
|
32
|
+
...cx,
|
|
33
|
+
temporal: cutoffs,
|
|
34
|
+
statusRead: (inst, name) => {
|
|
35
|
+
statuses.set(JSON.stringify([inst.id, name]), { inst, name });
|
|
36
|
+
return currentStatus(inst, name);
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
if (cutoffs.size || statuses.size)
|
|
40
|
+
(options.discovery ? ctx.discoveryJobs : ctx.temporalJobs).push(() => {
|
|
41
|
+
if (options.enabled && !options.enabled())
|
|
42
|
+
return;
|
|
43
|
+
const consume = (inst, name, at, found) => {
|
|
44
|
+
currentStatus(inst, name);
|
|
45
|
+
const projected = predictStatus(ctx, inst, name, at);
|
|
46
|
+
for (const date of projected.cutoffs)
|
|
47
|
+
found.add(date);
|
|
48
|
+
cx.reads.merge(projected.reads);
|
|
49
|
+
return projected.value;
|
|
50
|
+
};
|
|
51
|
+
for (const { inst, name } of statuses.values())
|
|
52
|
+
consume(inst, name, ctx.now, cutoffs);
|
|
53
|
+
const { trace: _trace, ...base } = cx;
|
|
54
|
+
// Repeated calendar boundaries are unbounded; the earliest cutoff is conservative.
|
|
55
|
+
const at = hasRecurrence(cx.p)
|
|
56
|
+
? ([...cutoffs].filter((at) => timeOrder(at, ctx.now) > 0).sort()[0] ?? null)
|
|
57
|
+
: firstChange(ctx.now, value, cutoffs, (at, found) => read({
|
|
58
|
+
...base,
|
|
59
|
+
b: forecastBasis(cx.b, at),
|
|
60
|
+
temporal: found,
|
|
61
|
+
statusRead: (inst, name) => consume(inst, name, at, found),
|
|
62
|
+
}), signature);
|
|
63
|
+
cx.reads.add({
|
|
64
|
+
kind: "time",
|
|
65
|
+
instance: options.instance ?? cx.inst.id,
|
|
66
|
+
path,
|
|
67
|
+
value: at ? { at, why } : null,
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
return value;
|
|
71
|
+
};
|
|
72
|
+
export function predictStatus(ctx, inst, name, at) {
|
|
73
|
+
const key = JSON.stringify([inst.id, name, at]);
|
|
74
|
+
const cached = ctx.predictions.get(key);
|
|
75
|
+
if (cached)
|
|
76
|
+
return cached;
|
|
77
|
+
if (ctx.predicting.has(key))
|
|
78
|
+
return { value: "Unknown", cutoffs: new Set(), reads: new Map(), cyclic: true };
|
|
79
|
+
ctx.predicting.add(key);
|
|
80
|
+
const p = ctx.programOf.get(inst.id);
|
|
81
|
+
const component = p.components.get(inst.component);
|
|
82
|
+
const cutoffs = new Set();
|
|
83
|
+
const reads = new ReadSet();
|
|
84
|
+
let cyclic = false;
|
|
85
|
+
const statusRead = (target, field) => {
|
|
86
|
+
const next = predictStatus(ctx, target, field, at);
|
|
87
|
+
if (next.cyclic)
|
|
88
|
+
cyclic = true;
|
|
89
|
+
next.cutoffs.forEach((date) => cutoffs.add(date));
|
|
90
|
+
reads.merge(next.reads);
|
|
91
|
+
return next.value;
|
|
92
|
+
};
|
|
93
|
+
let cx = {
|
|
94
|
+
p,
|
|
95
|
+
inst,
|
|
96
|
+
b: forecastBasis(observeBasis(ctx.b, reads), at),
|
|
97
|
+
env: instanceEnv(p, inst, (field) => statusRead(inst, field)),
|
|
98
|
+
k: ctx.state,
|
|
99
|
+
statusRead,
|
|
100
|
+
temporal: cutoffs,
|
|
101
|
+
};
|
|
102
|
+
const pathStatus = (owner, segments, focus) => {
|
|
103
|
+
const [head, ...rest] = segments;
|
|
104
|
+
const c = ctx.programOf.get(owner.id).components.get(owner.component);
|
|
105
|
+
if (!rest.length && [...c.requirements, ...c.outputs].some((item) => item.name === head))
|
|
106
|
+
return statusRead(owner, head);
|
|
107
|
+
const slot = owner.children.find((slot) => slot.name === head);
|
|
108
|
+
if (!slot || slot.applies === "unknown")
|
|
109
|
+
return "Unknown";
|
|
110
|
+
if (!slot.applies)
|
|
111
|
+
return "NotApplicable";
|
|
112
|
+
const candidates = slot.instances.map((id) => ctx.instances.get(id));
|
|
113
|
+
const target = candidates.find((child) => focus !== undefined && child.attached.includes(focus)) ??
|
|
114
|
+
candidates.at(-1);
|
|
115
|
+
if (!target)
|
|
116
|
+
return "Unknown";
|
|
117
|
+
return rest.length
|
|
118
|
+
? pathStatus(target, rest, focus)
|
|
119
|
+
: allOf(ctx.programOf
|
|
120
|
+
.get(target.id)
|
|
121
|
+
.components.get(target.component)
|
|
122
|
+
.outputs.map((output) => statusRead(target, output.name)));
|
|
123
|
+
};
|
|
124
|
+
const requirement = component.requirements.find((item) => item.name === name);
|
|
125
|
+
let value = "Unknown";
|
|
126
|
+
if (requirement) {
|
|
127
|
+
const recurrence = requirement.recur ? readRecurrence(cx, requirement.recur) : null;
|
|
128
|
+
if (recurrence?.period)
|
|
129
|
+
cx = {
|
|
130
|
+
...cx,
|
|
131
|
+
proofPeriod: recurrence.period,
|
|
132
|
+
occurrence: `${inst.id}/${name}@${recurrence.period.start}`,
|
|
133
|
+
};
|
|
134
|
+
const ordinaryApplies = requirement.discretionary && !selectedAddition(cx, name, (date) => cutoffs.add(date))
|
|
135
|
+
? false
|
|
136
|
+
: requirement.appliesWhen
|
|
137
|
+
? truth(evaluateIn(cx, requirement.appliesWhen))
|
|
138
|
+
: true;
|
|
139
|
+
const applies = and([
|
|
140
|
+
ordinaryApplies,
|
|
141
|
+
recurrence?.truth ?? true,
|
|
142
|
+
requirement.effective ? readEffective(cx, requirement.effective).truth : true,
|
|
143
|
+
]);
|
|
144
|
+
if (applies === false)
|
|
145
|
+
value = "NotApplicable";
|
|
146
|
+
else if (applies === true) {
|
|
147
|
+
const cycle = requirement.recur
|
|
148
|
+
? (recurrence?.period?.start ?? null)
|
|
149
|
+
: requirement.cycle
|
|
150
|
+
? evaluateIn(cx, requirement.cycle)
|
|
151
|
+
: null;
|
|
152
|
+
const occurrence = `${inst.id}/${name}${cycle !== null && !isUnknown(cycle) ? `@${String(cycle)}` : ""}`;
|
|
153
|
+
const accepted = legacyAcceptance(cx, requirement);
|
|
154
|
+
const decision = selectedDecision(cx, name, (date) => cutoffs.add(date));
|
|
155
|
+
const lawSat = decision?.definition.effect === "reject"
|
|
156
|
+
? false
|
|
157
|
+
: decision?.definition.effect === "accept"
|
|
158
|
+
? true
|
|
159
|
+
: accepted?.decision === "accepted"
|
|
160
|
+
? true
|
|
161
|
+
: truth(evaluateIn({ ...cx, occurrence }, requirement.satisfiedBy));
|
|
162
|
+
const sat = and([lawSat, ...policyRequirements(cx).map((p) => p.truth)]);
|
|
163
|
+
if (decision?.definition.effect === "waive")
|
|
164
|
+
value = "Waived";
|
|
165
|
+
else if (sat === true)
|
|
166
|
+
value = "Satisfied";
|
|
167
|
+
else if (sat === false) {
|
|
168
|
+
const due = requirement.due ? evaluateIn(cx, requirement.due) : null;
|
|
169
|
+
const point = due !== null ? timeOf(due) : null;
|
|
170
|
+
let date = point !== null && !isUnknown(point) ? point : null;
|
|
171
|
+
if (date &&
|
|
172
|
+
decision?.definition.effect === "defer" &&
|
|
173
|
+
decision.record.deferredUntil &&
|
|
174
|
+
deadlineOrder(decision.record.deferredUntil, date) > 0)
|
|
175
|
+
date = decision.record.deferredUntil;
|
|
176
|
+
if (date) {
|
|
177
|
+
const next = nextTime(date);
|
|
178
|
+
if (next)
|
|
179
|
+
cutoffs.add(next);
|
|
180
|
+
}
|
|
181
|
+
value = date !== null && isPastDeadline(at, date) ? "Overdue" : "Open";
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
const output = component.outputs.find((item) => item.name === name);
|
|
187
|
+
if (output) {
|
|
188
|
+
const statuses = output.paths.map((path) => pathStatus(inst, path.segments, ctx.rootFocus.get(inst.id)));
|
|
189
|
+
value =
|
|
190
|
+
output.op === "all-of"
|
|
191
|
+
? allOf(statuses)
|
|
192
|
+
: output.op === "any-of"
|
|
193
|
+
? anyOf(statuses)
|
|
194
|
+
: statuses[0];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const result = { value, cutoffs, reads: reads.snapshot(), cyclic };
|
|
198
|
+
ctx.predicting.delete(key);
|
|
199
|
+
// A back edge's Unknown depends on the active call stack, so it cannot be reused elsewhere.
|
|
200
|
+
if (!cyclic)
|
|
201
|
+
ctx.predictions.set(key, result);
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sha256 } from "../ir-checks/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sha256 } from "../ir-checks/index.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as IR from "../world-ir/types.generated.js";
|
|
2
|
+
import type { EvidenceRecord } from "./basis.js";
|
|
3
|
+
export interface SignatureTrail extends IR.SignaturePolicy {
|
|
4
|
+
readonly method: string;
|
|
5
|
+
readonly device: string;
|
|
6
|
+
readonly by: string;
|
|
7
|
+
readonly at: string;
|
|
8
|
+
readonly digest: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const signatureInputValid: (input: IR.SignatureInput | undefined, method: string) => boolean;
|
|
11
|
+
export declare const signEvidence: (record: EvidenceRecord, policy: IR.SignaturePolicy, input: IR.SignatureInput) => EvidenceRecord;
|
|
12
|
+
/** Historical basic records carry no inferred consent. A present trail must bind its source. */
|
|
13
|
+
export declare const signatureValid: (record: EvidenceRecord) => boolean;
|