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,215 @@
|
|
|
1
|
+
import { Schema as S } from "effect";
|
|
2
|
+
const text = S.String.check(S.isMinLength(1));
|
|
3
|
+
const optional = S.optionalKey;
|
|
4
|
+
export const Actor = S.Struct({
|
|
5
|
+
id: text,
|
|
6
|
+
kind: S.Literals(["human", "agent", "service", "connector"]),
|
|
7
|
+
groups: optional(S.Array(text)),
|
|
8
|
+
});
|
|
9
|
+
export const Scalar = S.Union([S.String, S.Number, S.Boolean]);
|
|
10
|
+
export const Facts = S.Record(S.String, S.Union([Scalar, S.Null]));
|
|
11
|
+
const Values = S.Record(S.String, Scalar);
|
|
12
|
+
export const SignatureInput = S.Struct({
|
|
13
|
+
consent: S.Boolean,
|
|
14
|
+
intent: S.Boolean,
|
|
15
|
+
method: text,
|
|
16
|
+
device: text,
|
|
17
|
+
});
|
|
18
|
+
export const Draft = S.Union([
|
|
19
|
+
S.Struct({ kind: S.Literal("assert"), values: Facts, factKind: optional(text) }),
|
|
20
|
+
S.Struct({
|
|
21
|
+
kind: S.Literal("evidence"),
|
|
22
|
+
operation: text,
|
|
23
|
+
values: Values,
|
|
24
|
+
instance: optional(text),
|
|
25
|
+
}),
|
|
26
|
+
]);
|
|
27
|
+
export const Proposal = S.Struct({
|
|
28
|
+
id: text,
|
|
29
|
+
type: text,
|
|
30
|
+
subject: text,
|
|
31
|
+
by: Actor,
|
|
32
|
+
at: text,
|
|
33
|
+
rationale: text,
|
|
34
|
+
draft: Draft,
|
|
35
|
+
state: S.Literals(["pending", "accepted", "rejected"]),
|
|
36
|
+
resolution: optional(S.Struct({ by: Actor, at: text, command: text, reason: optional(text) })),
|
|
37
|
+
});
|
|
38
|
+
const address = { type: text, subject: text };
|
|
39
|
+
const read = { ...address, at: optional(text) };
|
|
40
|
+
const command = { ...address, id: text };
|
|
41
|
+
export const requests = {
|
|
42
|
+
status: S.Struct(read),
|
|
43
|
+
facts: S.Struct(read),
|
|
44
|
+
work: S.Struct(read),
|
|
45
|
+
operations: S.Struct(read),
|
|
46
|
+
explain: S.Struct({ ...read, requirement: optional(text) }),
|
|
47
|
+
subjects: S.Struct({ type: text }),
|
|
48
|
+
assert: S.Struct({ ...command, values: Facts, kind: optional(text) }),
|
|
49
|
+
perform: S.Struct({
|
|
50
|
+
...command,
|
|
51
|
+
operation: text,
|
|
52
|
+
values: optional(Values),
|
|
53
|
+
instance: optional(text),
|
|
54
|
+
reason: optional(S.Union([Scalar, S.Null])),
|
|
55
|
+
signature: optional(SignatureInput),
|
|
56
|
+
unsigned: optional(S.Boolean),
|
|
57
|
+
amend: optional(S.Struct({ previous: text, reason: text })),
|
|
58
|
+
revoke: optional(text),
|
|
59
|
+
}),
|
|
60
|
+
signal: S.Struct({ ...command, machine: text, state: text, instance: optional(text) }),
|
|
61
|
+
propose: S.Struct({ ...command, draft: Draft, rationale: text }),
|
|
62
|
+
proposals: S.Struct({
|
|
63
|
+
type: optional(text),
|
|
64
|
+
subject: optional(text),
|
|
65
|
+
state: optional(S.Literals(["pending", "accepted", "rejected"])),
|
|
66
|
+
}),
|
|
67
|
+
"accept-proposal": S.Struct({ ...command, proposal: text, signature: optional(SignatureInput) }),
|
|
68
|
+
"reject-proposal": S.Struct({ ...command, proposal: text, reason: text }),
|
|
69
|
+
changes: S.Record(S.String, S.Never),
|
|
70
|
+
};
|
|
71
|
+
export const verbs = Object.keys(requests);
|
|
72
|
+
export const mutations = [
|
|
73
|
+
"assert",
|
|
74
|
+
"perform",
|
|
75
|
+
"signal",
|
|
76
|
+
"propose",
|
|
77
|
+
"accept-proposal",
|
|
78
|
+
"reject-proposal",
|
|
79
|
+
];
|
|
80
|
+
export const errorCodes = [
|
|
81
|
+
"invalid-request",
|
|
82
|
+
"unauthenticated",
|
|
83
|
+
"human-required",
|
|
84
|
+
"forbidden",
|
|
85
|
+
"not-found",
|
|
86
|
+
"command-duplicate",
|
|
87
|
+
"proposal-resolved",
|
|
88
|
+
"write-refused",
|
|
89
|
+
"internal",
|
|
90
|
+
];
|
|
91
|
+
export const ProtocolError = S.Struct({
|
|
92
|
+
code: S.Literals(errorCodes),
|
|
93
|
+
message: S.String,
|
|
94
|
+
details: optional(S.Array(S.String)),
|
|
95
|
+
});
|
|
96
|
+
const Status = S.Literals(["Unknown", "Open", "Satisfied", "NotApplicable", "Overdue", "Waived"]);
|
|
97
|
+
const nullableText = S.Union([S.String, S.Null]);
|
|
98
|
+
export const SubjectStatus = S.Struct({
|
|
99
|
+
subject: S.String,
|
|
100
|
+
at: S.String,
|
|
101
|
+
release: S.String,
|
|
102
|
+
revision: S.Number,
|
|
103
|
+
wakeAt: nullableText,
|
|
104
|
+
wakeReason: S.String,
|
|
105
|
+
machines: S.Array(S.Struct({ instance: S.String, machine: S.String, state: nullableText, since: nullableText })),
|
|
106
|
+
instances: S.Array(S.Struct({
|
|
107
|
+
instance: S.String,
|
|
108
|
+
component: S.String,
|
|
109
|
+
digest: S.String,
|
|
110
|
+
outputs: S.Record(S.String, Status),
|
|
111
|
+
requirements: S.Array(S.Struct({
|
|
112
|
+
name: S.String,
|
|
113
|
+
label: S.String,
|
|
114
|
+
status: Status,
|
|
115
|
+
due: nullableText,
|
|
116
|
+
blocked: nullableText,
|
|
117
|
+
})),
|
|
118
|
+
})),
|
|
119
|
+
});
|
|
120
|
+
export const Missing = S.Struct({
|
|
121
|
+
text: S.String,
|
|
122
|
+
kind: S.Literals(["requirement", "evidence", "fact", "machine", "other"]),
|
|
123
|
+
requirement: optional(S.String),
|
|
124
|
+
instance: optional(S.String),
|
|
125
|
+
evidence: optional(S.String),
|
|
126
|
+
producedBy: optional(S.Array(S.Struct({ requirement: S.String, instance: S.String }))),
|
|
127
|
+
fact: optional(S.String),
|
|
128
|
+
machine: optional(S.String),
|
|
129
|
+
states: optional(S.Array(S.String)),
|
|
130
|
+
});
|
|
131
|
+
export const Fact = S.Struct({
|
|
132
|
+
fact: S.String,
|
|
133
|
+
value: S.Union([Scalar, S.Null]),
|
|
134
|
+
by: S.String,
|
|
135
|
+
at: S.String,
|
|
136
|
+
command: nullableText,
|
|
137
|
+
});
|
|
138
|
+
export const WorkItem = S.Struct({
|
|
139
|
+
id: S.String,
|
|
140
|
+
instance: S.String,
|
|
141
|
+
operation: S.String,
|
|
142
|
+
label: S.String,
|
|
143
|
+
kind: S.Literals(["interaction", "connector", "decision", "proposal"]),
|
|
144
|
+
state: S.Literals(["eligible", "waiting", "dispatched", "held"]),
|
|
145
|
+
advances: S.Array(S.String),
|
|
146
|
+
assignee: S.Struct({ id: nullableText, kind: S.Literals(["entity", "group", "connector"]) }),
|
|
147
|
+
missing: S.Array(Missing),
|
|
148
|
+
fields: S.Array(S.Struct({
|
|
149
|
+
field: S.String,
|
|
150
|
+
mode: S.Literals(["ask", "confirm", "read-only"]),
|
|
151
|
+
value: S.Union([Scalar, S.Null]),
|
|
152
|
+
})),
|
|
153
|
+
proposal: optional(S.String),
|
|
154
|
+
});
|
|
155
|
+
export const Change = S.Struct({
|
|
156
|
+
subject: S.String,
|
|
157
|
+
revision: S.Number,
|
|
158
|
+
at: S.String,
|
|
159
|
+
transitions: S.Array(S.Struct({
|
|
160
|
+
instance: S.String,
|
|
161
|
+
kind: S.Literals(["requirement", "output"]),
|
|
162
|
+
name: S.String,
|
|
163
|
+
from: S.Union([Status, S.Null]),
|
|
164
|
+
to: S.Union([Status, S.Null]),
|
|
165
|
+
})),
|
|
166
|
+
opened: S.Array(WorkItem),
|
|
167
|
+
closed: S.Array(WorkItem),
|
|
168
|
+
});
|
|
169
|
+
export const Outcome = S.Struct({
|
|
170
|
+
accepted: S.Boolean,
|
|
171
|
+
codes: S.Array(S.String),
|
|
172
|
+
status: SubjectStatus,
|
|
173
|
+
change: Change,
|
|
174
|
+
});
|
|
175
|
+
const Json = S.suspend(() => S.Union([S.Null, S.Boolean, S.Number, S.String, S.Array(Json), S.Record(S.String, Json)]));
|
|
176
|
+
export const responses = {
|
|
177
|
+
status: SubjectStatus,
|
|
178
|
+
facts: S.Array(Fact),
|
|
179
|
+
work: S.Array(WorkItem),
|
|
180
|
+
operations: S.Array(S.Struct({
|
|
181
|
+
instance: S.String,
|
|
182
|
+
name: S.String,
|
|
183
|
+
kind: S.Literals(["action", "decision"]),
|
|
184
|
+
state: S.Literals([
|
|
185
|
+
"eligible",
|
|
186
|
+
"waiting",
|
|
187
|
+
"dispatched",
|
|
188
|
+
"held",
|
|
189
|
+
"complete",
|
|
190
|
+
"not-applicable",
|
|
191
|
+
"decision",
|
|
192
|
+
]),
|
|
193
|
+
})),
|
|
194
|
+
explain: S.Array(Json),
|
|
195
|
+
subjects: S.Array(S.String),
|
|
196
|
+
assert: Outcome,
|
|
197
|
+
perform: Outcome,
|
|
198
|
+
signal: Outcome,
|
|
199
|
+
propose: Outcome,
|
|
200
|
+
proposals: S.Array(Proposal),
|
|
201
|
+
"accept-proposal": Outcome,
|
|
202
|
+
"reject-proposal": Outcome,
|
|
203
|
+
changes: S.Struct({ revision: S.Number, nextWake: nullableText }),
|
|
204
|
+
};
|
|
205
|
+
export const requestJsonSchema = (verb) => S.toJsonSchemaDocument(requests[verb]).schema;
|
|
206
|
+
export const responseJsonSchema = (verb) => S.toJsonSchemaDocument(responses[verb]);
|
|
207
|
+
export const decodeRequest = (verb, value) => S.decodeUnknownSync(requests[verb])(value, { onExcessProperty: "error" });
|
|
208
|
+
export const decodeActor = (value) => S.decodeUnknownSync(Actor)(value, { onExcessProperty: "error" });
|
|
209
|
+
export const decodeResponse = (verb, value) => S.decodeUnknownSync(responses[verb])(value, {
|
|
210
|
+
onExcessProperty: "error",
|
|
211
|
+
});
|
|
212
|
+
export const resultJsonSchema = (verb) => S.toJsonSchemaDocument(S.Union([
|
|
213
|
+
S.Struct({ ok: S.Literal(true), value: responses[verb] }),
|
|
214
|
+
S.Struct({ ok: S.Literal(false), error: ProtocolError }),
|
|
215
|
+
]));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as IR from "../world-ir/types.generated.js";
|
|
2
|
+
import type { ActionResult, Cx, Instance, RequirementResult, Value, WorkIntent } from "./model.js";
|
|
3
|
+
export declare const assignment: (cx: Cx, value: Value, requested?: Pick<IR.Action, "dispatch" | "onIneligible">, kind?: ActionResult["assigneeKind"]) => {
|
|
4
|
+
assignee: string;
|
|
5
|
+
assigneeId: string | null;
|
|
6
|
+
assigneeKind: "entity" | "group" | "connector";
|
|
7
|
+
dispatch: "auto" | "claim" | "manual";
|
|
8
|
+
onIneligible: "withdraw" | "keep" | "review";
|
|
9
|
+
};
|
|
10
|
+
export declare const openIntent: (inst: Instance, target: RequirementResult, action: ActionResult) => WorkIntent | null;
|
|
11
|
+
export interface ActionProjection {
|
|
12
|
+
readonly action: ActionResult | null;
|
|
13
|
+
readonly intent: WorkIntent | null;
|
|
14
|
+
}
|
|
15
|
+
export declare const projectAction: (cx: Cx, inst: Instance, a: IR.Action, requirements: readonly RequirementResult[], amending?: boolean) => ActionProjection;
|
|
16
|
+
/** Waiting display details can change harmlessly; dispatched ineligibility is consequential. */
|
|
17
|
+
export declare const projectionSignature: ({ action, intent }: ActionProjection) => string;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { missingCondition } from "./missing.js";
|
|
2
|
+
import { workKey } from "./work.js";
|
|
3
|
+
import { resourceGeneration } from "./resource-generation.js";
|
|
4
|
+
import { advanceTargets } from "../ir-checks/index.js";
|
|
5
|
+
import { policyAssignments } from "./policies.js";
|
|
6
|
+
import { projectInteractionFields } from "./interaction-fields.js";
|
|
7
|
+
import { readRenewal } from "./evidence-validity.js";
|
|
8
|
+
import { and, evaluateIn, isUnknown, keyText, truth } from "./evaluation.js";
|
|
9
|
+
import { semanticJson } from "./result-digest.js";
|
|
10
|
+
export const assignment = (cx, value, requested, kind) => {
|
|
11
|
+
const id = typeof value === "string" && value.length ? value : null;
|
|
12
|
+
const namespace = id ? cx.b.nsOf(id) : undefined;
|
|
13
|
+
const assigneeKind = kind ?? (namespace ? "entity" : "group");
|
|
14
|
+
const entity = namespace ? cx.p.entities.get(namespace) : undefined;
|
|
15
|
+
const shown = id && entity?.display ? cx.b.fact(id, `${entity.ns}/${entity.display}`)?.v : undefined;
|
|
16
|
+
return {
|
|
17
|
+
assignee: isUnknown(value) ? "Unassigned" : value === null ? "" : String(shown ?? value),
|
|
18
|
+
assigneeId: id,
|
|
19
|
+
assigneeKind,
|
|
20
|
+
dispatch: requested?.dispatch ?? (assigneeKind === "group" ? "claim" : "auto"),
|
|
21
|
+
onIneligible: requested?.onIneligible ?? "withdraw",
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export const openIntent = (inst, target, action) => action.state === "eligible" && action.assigneeId
|
|
25
|
+
? {
|
|
26
|
+
instance: inst.id,
|
|
27
|
+
action: action.action,
|
|
28
|
+
occurrence: target.occurrence,
|
|
29
|
+
idempotencyKey: action.idempotencyKey,
|
|
30
|
+
at: action.at,
|
|
31
|
+
kind: "open",
|
|
32
|
+
...(action.advancesAll
|
|
33
|
+
? { occurrences: action.advancesAll.map((name) => `${inst.id}/${name}`) }
|
|
34
|
+
: {}),
|
|
35
|
+
...(action.authorityConstraints
|
|
36
|
+
? { authorityConstraints: action.authorityConstraints }
|
|
37
|
+
: {}),
|
|
38
|
+
dispatch: action.dispatch ?? (action.assigneeKind === "group" ? "claim" : "auto"),
|
|
39
|
+
onIneligible: action.onIneligible ?? "withdraw",
|
|
40
|
+
assignee: { id: action.assigneeId, kind: action.assigneeKind },
|
|
41
|
+
}
|
|
42
|
+
: null;
|
|
43
|
+
export const projectAction = (cx, inst, a, requirements, amending = false) => {
|
|
44
|
+
const names = advanceTargets(a);
|
|
45
|
+
const targets = names.map((name) => {
|
|
46
|
+
const target = requirements.find((r) => r.name === name);
|
|
47
|
+
return { target, status: cx.statusRead?.(inst, name) ?? target.status };
|
|
48
|
+
});
|
|
49
|
+
const chosen = targets.find((t) => t.status === "Open" || t.status === "Overdue") ?? targets[0];
|
|
50
|
+
const { target, status } = chosen;
|
|
51
|
+
const definition = cx.p.components
|
|
52
|
+
.get(inst.component)
|
|
53
|
+
.requirements.find((r) => r.name === target.name);
|
|
54
|
+
const renewal = definition.renewWithin
|
|
55
|
+
? readRenewal({ ...cx, ...(target.recurrence ? { proofPeriod: target.recurrence } : {}) }, definition, target.occurrence)
|
|
56
|
+
: null;
|
|
57
|
+
const baseKey = a.idempotency
|
|
58
|
+
? names.length > 1
|
|
59
|
+
? JSON.stringify([
|
|
60
|
+
"worldvm/action@1",
|
|
61
|
+
inst.component,
|
|
62
|
+
a.name,
|
|
63
|
+
inst.cycle,
|
|
64
|
+
a.idempotency.map((e) => evaluateIn(cx, e)),
|
|
65
|
+
])
|
|
66
|
+
: `${a.name}[${a.idempotency.map((e) => keyText(evaluateIn(cx, e))).join(", ")}]`
|
|
67
|
+
: target.recurrence
|
|
68
|
+
? `${target.occurrence}/${a.name}`
|
|
69
|
+
: `${inst.id}/${a.name}`;
|
|
70
|
+
const resource = cx.p.components
|
|
71
|
+
.get(inst.component)
|
|
72
|
+
.resources?.find((r) => a.via.kind === "connector" &&
|
|
73
|
+
r.acquire.connector === a.via.connector &&
|
|
74
|
+
r.acquire.capability === a.via.capability);
|
|
75
|
+
const generationKey = resource
|
|
76
|
+
? JSON.stringify([
|
|
77
|
+
"worldvm/resource@1",
|
|
78
|
+
baseKey,
|
|
79
|
+
resource.name,
|
|
80
|
+
resourceGeneration(cx.p, cx.b, inst),
|
|
81
|
+
])
|
|
82
|
+
: baseKey;
|
|
83
|
+
const key = !a.idempotency && renewal?.expiresAt
|
|
84
|
+
? JSON.stringify(["worldvm/renewal@1", generationKey, renewal.expiresAt])
|
|
85
|
+
: generationKey;
|
|
86
|
+
if (!amending &&
|
|
87
|
+
names.length > 1 &&
|
|
88
|
+
a.via.kind === "interaction" &&
|
|
89
|
+
cx.b
|
|
90
|
+
.evidenceOf(inst.id)
|
|
91
|
+
.some((e) => e.workKey === workKey(inst.account, key) && e.status === "attested"))
|
|
92
|
+
return { action: null, intent: null };
|
|
93
|
+
const dispatched = cx.b.dispatched(key);
|
|
94
|
+
const ineligible = dispatched
|
|
95
|
+
? {
|
|
96
|
+
instance: inst.id,
|
|
97
|
+
action: a.name,
|
|
98
|
+
occurrence: target.occurrence,
|
|
99
|
+
idempotencyKey: key,
|
|
100
|
+
at: a.at,
|
|
101
|
+
kind: a.onIneligible ?? "withdraw",
|
|
102
|
+
}
|
|
103
|
+
: null;
|
|
104
|
+
if (!amending &&
|
|
105
|
+
status !== "Open" &&
|
|
106
|
+
status !== "Overdue" &&
|
|
107
|
+
!(status === "Satisfied" && renewal?.state === "ready"))
|
|
108
|
+
return { action: null, intent: status === "Satisfied" ? null : ineligible };
|
|
109
|
+
const needs = a.needs.map((n) => ({
|
|
110
|
+
text: n.text,
|
|
111
|
+
expr: n.expr,
|
|
112
|
+
truth: truth(evaluateIn(cx, n.expr)),
|
|
113
|
+
}));
|
|
114
|
+
const connector = a.via.kind === "connector" ? a.via.connector : null;
|
|
115
|
+
const who = assignment(cx, connector ? `connector:${connector}` : a.assignee ? evaluateIn(cx, a.assignee) : null, a, connector ? "connector" : a.assigneeKind);
|
|
116
|
+
const constraints = policyAssignments(cx, a);
|
|
117
|
+
const entities = constraints.filter((c) => c.kind === "entity").map((c) => c.id);
|
|
118
|
+
const allowed = constraints.every((c) => c.id !== null) && new Set(entities).size <= 1;
|
|
119
|
+
const assigned = names.length === 1 || who.assigneeId !== null;
|
|
120
|
+
const eligible = and(needs.map((n) => n.truth)) === true && who.assigneeId !== null && allowed;
|
|
121
|
+
const interaction = a.via.kind === "interaction" ? cx.p.interactions.get(a.via.name) : undefined;
|
|
122
|
+
const action = {
|
|
123
|
+
...(interaction
|
|
124
|
+
? {
|
|
125
|
+
fields: projectInteractionFields(cx.p, interaction, (expr) => evaluateIn(cx, expr), {
|
|
126
|
+
basis: cx.b,
|
|
127
|
+
...(cx.temporal ? { temporal: cx.temporal } : {}),
|
|
128
|
+
}),
|
|
129
|
+
}
|
|
130
|
+
: {}),
|
|
131
|
+
...who,
|
|
132
|
+
...(constraints.length ? { authorityConstraints: constraints } : {}),
|
|
133
|
+
action: a.name,
|
|
134
|
+
label: a.label ?? a.name,
|
|
135
|
+
advances: target.name,
|
|
136
|
+
...(names.length > 1 ? { advancesAll: names } : {}),
|
|
137
|
+
via: a.via.kind === "interaction" ? a.via.name : `${a.via.connector}/${a.via.capability}`,
|
|
138
|
+
kind: a.via.kind,
|
|
139
|
+
interaction: a.via.kind === "interaction" ? a.via.name : null,
|
|
140
|
+
idempotencyKey: key,
|
|
141
|
+
state: dispatched
|
|
142
|
+
? "dispatched"
|
|
143
|
+
: allowed && assigned && and(needs.map((n) => n.truth)) === true
|
|
144
|
+
? "eligible"
|
|
145
|
+
: "waiting",
|
|
146
|
+
missing: [
|
|
147
|
+
...needs.filter((n) => n.truth !== true).map((n) => missingCondition(cx, n.text, n.expr)),
|
|
148
|
+
...(!allowed
|
|
149
|
+
? [{ text: "Policy assignment intersection is unknown or empty", kind: "other" }]
|
|
150
|
+
: []),
|
|
151
|
+
...(!assigned ? [{ text: "Assignee is Unknown", kind: "other" }] : []),
|
|
152
|
+
],
|
|
153
|
+
at: a.at,
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
action,
|
|
157
|
+
intent: dispatched ? (eligible ? null : ineligible) : openIntent(inst, target, action),
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
/** Waiting display details can change harmlessly; dispatched ineligibility is consequential. */
|
|
161
|
+
export const projectionSignature = ({ action, intent }) => semanticJson([action?.state === "eligible" ? action : (action?.state ?? null), intent]);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type EvaluationContext } from "./context.js";
|
|
2
|
+
import type * as IR from "../world-ir/types.generated.js";
|
|
3
|
+
import { type ActionResult, type Cx, type Instance, type HoldResult, type RequirementResult, type WorkIntent } from "./model.js";
|
|
4
|
+
export declare const evaluateActions: (ctx: EvaluationContext, inst: Instance, cx: Cx, component: IR.Component, requirements: readonly RequirementResult[], holds?: readonly HoldResult[]) => {
|
|
5
|
+
readonly actions: ActionResult[];
|
|
6
|
+
readonly workIntents: WorkIntent[];
|
|
7
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { evidenceSuperseded } from "./evidence-history.js";
|
|
2
|
+
import { reusableProof, reuseDecisionName } from "./reuse.js";
|
|
3
|
+
import { advanceTargets, priorCycleOperationName } from "../ir-checks/index.js";
|
|
4
|
+
import {} from "./context.js";
|
|
5
|
+
import { activeHolds } from "./holds.js";
|
|
6
|
+
import { nextTime, isPastDeadline } from "./instants.js";
|
|
7
|
+
import { evaluateIn, isDuration, legacyAcceptance, plus, selectedDecision } from "./evaluation.js";
|
|
8
|
+
import { Unknown, } from "./model.js";
|
|
9
|
+
import { assignment, openIntent, projectAction, projectionSignature } from "./action-intents.js";
|
|
10
|
+
import { timed } from "./scheduling.js";
|
|
11
|
+
export const evaluateActions = (ctx, inst, cx, component, requirements, holds = []) => {
|
|
12
|
+
const p = cx.p;
|
|
13
|
+
const b = cx.b;
|
|
14
|
+
// Eligibility is a pure derivation (P7): the requirement is Open/Overdue and every need holds.
|
|
15
|
+
const actions = [];
|
|
16
|
+
const workIntents = [];
|
|
17
|
+
for (const r of component.requirements) {
|
|
18
|
+
const target = requirements.find((q) => q.name === r.name);
|
|
19
|
+
const open = target.status === "Open" || target.status === "Overdue";
|
|
20
|
+
const accepts = r.accepts;
|
|
21
|
+
if (open && r.reuse?.confirm && selectedDecision(cx, r.name)?.definition.effect !== "reject") {
|
|
22
|
+
const offer = timed(ctx, { ...cx, occurrence: target.occurrence }, ["requirement", r.name, "reuse"], `${r.label ?? r.name}: reuse window changes`, (c) => {
|
|
23
|
+
const candidate = reusableProof(c, r);
|
|
24
|
+
if (!candidate || candidate instanceof Unknown)
|
|
25
|
+
return null;
|
|
26
|
+
const who = assignment(c, evaluateIn(c, r.reuse.confirm), undefined, r.reuse.confirmKind);
|
|
27
|
+
return {
|
|
28
|
+
action: `accept-reuse:${r.name}`,
|
|
29
|
+
label: `Accept existing evidence for ${r.label ?? r.name}`,
|
|
30
|
+
advances: r.name,
|
|
31
|
+
...who,
|
|
32
|
+
via: "decision",
|
|
33
|
+
kind: "decision",
|
|
34
|
+
interaction: null,
|
|
35
|
+
idempotencyKey: JSON.stringify([
|
|
36
|
+
inst.id,
|
|
37
|
+
reuseDecisionName(inst.component, r.name, "accepted"),
|
|
38
|
+
candidate.record.id,
|
|
39
|
+
]),
|
|
40
|
+
state: who.assigneeId ? "eligible" : "waiting",
|
|
41
|
+
missing: who.assigneeId
|
|
42
|
+
? []
|
|
43
|
+
: [{ text: "Confirmation principal is Unknown", kind: "other" }],
|
|
44
|
+
at: r.at,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
if (offer) {
|
|
48
|
+
actions.push(offer);
|
|
49
|
+
const intent = openIntent(inst, target, offer);
|
|
50
|
+
if (intent)
|
|
51
|
+
workIntents.push(intent);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// An acceptance the law leaves to the employer is offered as a decision, never automatic.
|
|
55
|
+
if (open &&
|
|
56
|
+
accepts?.from &&
|
|
57
|
+
inst.prior &&
|
|
58
|
+
!legacyAcceptance(cx, r) &&
|
|
59
|
+
selectedDecision(cx, r.name)?.definition.effect !== "reject") {
|
|
60
|
+
const prior = b
|
|
61
|
+
.evidence(`${inst.prior}/${accepts.from}`)
|
|
62
|
+
.filter((e) => e.status === "attested" && !evidenceSuperseded(b, e))
|
|
63
|
+
.at(-1);
|
|
64
|
+
const offer = timed(ctx, cx, ["requirement", r.name, "reuse"], `${r.label ?? r.name}: prior evidence window changes`, (c) => {
|
|
65
|
+
const within = accepts.within ? evaluateIn(c, accepts.within) : null;
|
|
66
|
+
const expires = prior && within && isDuration(within) ? plus(prior.at, within) : null;
|
|
67
|
+
if (expires) {
|
|
68
|
+
const next = nextTime(expires);
|
|
69
|
+
if (next)
|
|
70
|
+
c.temporal?.add(next);
|
|
71
|
+
}
|
|
72
|
+
if (!prior || (expires && isPastDeadline(c.b.now, expires)))
|
|
73
|
+
return null;
|
|
74
|
+
const contract = p.ir.decisions?.find((d) => d.of === inst.component &&
|
|
75
|
+
d.name ===
|
|
76
|
+
priorCycleOperationName(p.ir.decisions ?? [], inst.component, r.name, "accepted"));
|
|
77
|
+
const principal = contract
|
|
78
|
+
? evaluateIn(c, contract.by)
|
|
79
|
+
: accepts.confirm
|
|
80
|
+
? evaluateIn(c, accepts.confirm)
|
|
81
|
+
: null;
|
|
82
|
+
return {
|
|
83
|
+
action: `accept-prior:${r.name}`,
|
|
84
|
+
label: accepts.label ?? `Accept the prior cycle's ${r.name}`,
|
|
85
|
+
advances: r.name,
|
|
86
|
+
...assignment(c, principal, undefined, contract?.byKind === "individual" ? "entity" : contract?.byKind),
|
|
87
|
+
via: "decision",
|
|
88
|
+
kind: "decision",
|
|
89
|
+
interaction: null,
|
|
90
|
+
idempotencyKey: `${inst.id}/accept-prior:${r.name}`,
|
|
91
|
+
state: "eligible",
|
|
92
|
+
missing: [],
|
|
93
|
+
at: r.at,
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
if (offer) {
|
|
97
|
+
actions.push(offer);
|
|
98
|
+
const intent = openIntent(inst, target, offer);
|
|
99
|
+
if (intent)
|
|
100
|
+
workIntents.push(intent);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
for (const a of component.actions) {
|
|
105
|
+
const target = requirements.find((q) => q.name === advanceTargets(a)[0]);
|
|
106
|
+
if (!target)
|
|
107
|
+
continue;
|
|
108
|
+
const projection = timed(ctx, cx, ["action", a.name], `${a.label ?? a.name}: eligibility changes`, (c) => projectAction(c, inst, a, requirements), projectionSignature);
|
|
109
|
+
if (projection.action)
|
|
110
|
+
actions.push(projection.action);
|
|
111
|
+
if (projection.intent)
|
|
112
|
+
workIntents.push(projection.intent);
|
|
113
|
+
}
|
|
114
|
+
const paused = activeHolds(holds, "dispatch");
|
|
115
|
+
if (!paused.length)
|
|
116
|
+
return { actions, workIntents };
|
|
117
|
+
return {
|
|
118
|
+
actions: actions.map((action) => action.state === "eligible"
|
|
119
|
+
? {
|
|
120
|
+
...action,
|
|
121
|
+
state: "held",
|
|
122
|
+
heldBy: paused.map((h) => h.name),
|
|
123
|
+
missing: [
|
|
124
|
+
...action.missing,
|
|
125
|
+
...paused.map((h) => ({
|
|
126
|
+
text: `Hold: ${h.label}${h.condition === "unknown" ? " (condition Unknown)" : ""}`,
|
|
127
|
+
kind: "other",
|
|
128
|
+
})),
|
|
129
|
+
],
|
|
130
|
+
}
|
|
131
|
+
: action),
|
|
132
|
+
workIntents: workIntents.filter((intent) => intent.kind !== "open"),
|
|
133
|
+
};
|
|
134
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EvidenceRecord } from "./basis.js";
|
|
2
|
+
import type { World } from "./memory.js";
|
|
3
|
+
import type { TimePoint } from "./instants.js";
|
|
4
|
+
import type { WorldReconciliation, ActionResult } from "./model.js";
|
|
5
|
+
export declare const amendmentAction: (recon: WorldReconciliation, world: World, now: TimePoint, instance: string, name: string, previous: string) => {
|
|
6
|
+
readonly action: ActionResult;
|
|
7
|
+
readonly record: EvidenceRecord;
|
|
8
|
+
readonly code?: never;
|
|
9
|
+
} | {
|
|
10
|
+
readonly code: string;
|
|
11
|
+
readonly action?: never;
|
|
12
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { basis } from "./memory.js";
|
|
2
|
+
import { instanceContext } from "./evaluation.js";
|
|
3
|
+
import { programFor } from "./reconcile.js";
|
|
4
|
+
import { projectAction } from "./action-intents.js";
|
|
5
|
+
import { activeHolds } from "./holds.js";
|
|
6
|
+
import { advanceTargets, componentOperationNames } from "../ir-checks/index.js";
|
|
7
|
+
import { signatureValid } from "./signatures.js";
|
|
8
|
+
import { evidenceOccurrences, supersededEvidence } from "./evidence-history.js";
|
|
9
|
+
export const amendmentAction = (recon, world, now, instance, name, previous) => {
|
|
10
|
+
const inst = recon.instances.get(instance), p = programFor(recon, instance), result = recon.results.get(instance);
|
|
11
|
+
const definition = inst && p?.components.get(inst.component)?.actions.find((a) => a.name === name), via = definition?.via;
|
|
12
|
+
const evidence = via?.kind === "interaction" && p?.evidence.get(p.interactions.get(via.name).produces);
|
|
13
|
+
if (!inst ||
|
|
14
|
+
!p ||
|
|
15
|
+
!result ||
|
|
16
|
+
!definition ||
|
|
17
|
+
!evidence ||
|
|
18
|
+
!evidence.amend ||
|
|
19
|
+
evidence.of !== inst.component)
|
|
20
|
+
return { code: "amendment-target" };
|
|
21
|
+
if (!componentOperationNames(p.ir, p.components.get(inst.component)).includes(name))
|
|
22
|
+
return { code: "amendment-target" };
|
|
23
|
+
const targets = advanceTargets(definition).map((n) => result.requirements.find((r) => r.name === n));
|
|
24
|
+
if (targets.some((r) => !r || !["Open", "Overdue", "Satisfied"].includes(r.status)))
|
|
25
|
+
return { code: "amendment-target" };
|
|
26
|
+
const scopes = targets.map((r) => r.occurrence).sort(), snapshot = basis(world, now), records = snapshot.evidence(scopes[0]), superseded = supersededEvidence(records);
|
|
27
|
+
const originals = records.filter((r) => r.id === previous);
|
|
28
|
+
if (originals.length !== 1 ||
|
|
29
|
+
originals[0].type !== evidence.name ||
|
|
30
|
+
originals[0].status !== "attested" ||
|
|
31
|
+
!signatureValid(originals[0]) ||
|
|
32
|
+
JSON.stringify(evidenceOccurrences(originals[0])) !== JSON.stringify(scopes))
|
|
33
|
+
return { code: "amendment-target" };
|
|
34
|
+
if (superseded.has(previous) ||
|
|
35
|
+
scopes.some((scope) => snapshot
|
|
36
|
+
.evidence(scope)
|
|
37
|
+
.filter((r) => r.type === evidence.name &&
|
|
38
|
+
r.status === "attested" &&
|
|
39
|
+
signatureValid(r) &&
|
|
40
|
+
!superseded.has(r.id))
|
|
41
|
+
.at(-1)?.id !== previous))
|
|
42
|
+
return { code: "amendment-stale" };
|
|
43
|
+
const action = projectAction(instanceContext(recon, snapshot, inst), inst, definition, result.requirements, true).action;
|
|
44
|
+
if (!action)
|
|
45
|
+
return { code: "operation-not-eligible" };
|
|
46
|
+
return {
|
|
47
|
+
record: originals[0],
|
|
48
|
+
action: activeHolds(result.holds ?? [], "dispatch").length
|
|
49
|
+
? { ...action, state: "held" }
|
|
50
|
+
: action,
|
|
51
|
+
};
|
|
52
|
+
};
|