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,468 @@
|
|
|
1
|
+
import { sha256 } from "./sha256.js";
|
|
2
|
+
import { canonicalJson } from "./result-digest.js";
|
|
3
|
+
import { amendmentAction } from "./amendments.js";
|
|
4
|
+
import { resourceMachineScope } from "./resource-generation.js";
|
|
5
|
+
import { signEvidence, signatureInputValid } from "./signatures.js";
|
|
6
|
+
import { evidenceFilesAllowed, factFileAllowed } from "./files.js";
|
|
7
|
+
import { occurrenceHome } from "./homes.js";
|
|
8
|
+
import { instanceContext } from "./evaluation.js";
|
|
9
|
+
import { canAttestEvidence } from "./evidence-authority.js";
|
|
10
|
+
import { reuseKey, reuseDecisionName } from "./reuse.js";
|
|
11
|
+
import { actionTargets, canPerformWork, workItems, workKey } from "./work.js";
|
|
12
|
+
import { permitsConstraints } from "./policies.js";
|
|
13
|
+
import { confirmFacts, refreshDrafts } from "./collection-state.js";
|
|
14
|
+
import { collectionRule, factKey } from "./collection-rules.js";
|
|
15
|
+
import { projectInteractionFields } from "./interaction-fields.js";
|
|
16
|
+
import { priorCycleOperationName, sensitivePayload } from "../ir-checks/index.js";
|
|
17
|
+
import { decide } from "./decide.js";
|
|
18
|
+
import { log } from "./journal.js";
|
|
19
|
+
export { log } from "./journal.js";
|
|
20
|
+
import { admit, canTransition, evaluateFor, evaluateValues, machineState, programFor, Unknown, } from "./reconcile.js";
|
|
21
|
+
import { basis } from "./memory.js";
|
|
22
|
+
/** Shared field and rule checks for signed submissions. */
|
|
23
|
+
export const validEvidence = (p, type, values, now) => {
|
|
24
|
+
const evidence = p.evidence.get(type);
|
|
25
|
+
if (!evidence)
|
|
26
|
+
return false;
|
|
27
|
+
const optional = (t, seen = new Set()) => {
|
|
28
|
+
if (Array.isArray(t)) {
|
|
29
|
+
const payload = sensitivePayload(t);
|
|
30
|
+
return payload
|
|
31
|
+
? optional(payload, seen)
|
|
32
|
+
: t[0] === "Option" || (t[0] === "Brand" && optional(t[1], seen));
|
|
33
|
+
}
|
|
34
|
+
if (typeof t !== "string" || seen.has(t))
|
|
35
|
+
return false;
|
|
36
|
+
const alias = p.ir.types.find((a) => a.name === t);
|
|
37
|
+
if (!alias)
|
|
38
|
+
return false;
|
|
39
|
+
seen.add(t);
|
|
40
|
+
return optional(alias.type, seen);
|
|
41
|
+
};
|
|
42
|
+
const filled = (name) => values[name] !== undefined && (typeof values[name] !== "string" || values[name].trim() !== "");
|
|
43
|
+
if (evidence.fields.some((f) => !optional(f.type) && !filled(f.name)))
|
|
44
|
+
return false;
|
|
45
|
+
const env = Object.fromEntries(evidence.fields.map((f) => [
|
|
46
|
+
f.name,
|
|
47
|
+
filled(f.name) ? values[f.name] : new Unknown(`${f.name} is empty`),
|
|
48
|
+
]));
|
|
49
|
+
return evidence.rules.every((r) => {
|
|
50
|
+
const when = r.when ? evaluateValues(p, env, now, r.when) : true;
|
|
51
|
+
if (when === false)
|
|
52
|
+
return true;
|
|
53
|
+
return (when === true &&
|
|
54
|
+
(r.requires.mode === "all" ? r.requires.fields.every(filled) : r.requires.fields.some(filled)));
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
/** Perform an eligible action. Ineligible or repeated work leaves the world unchanged. */
|
|
58
|
+
export const perform = (recon, world, at, request) => performInMode(recon, world, at, request);
|
|
59
|
+
const performInMode = (recon, world, at, request, amendment) => {
|
|
60
|
+
if (request.signature && (request.unsigned || request.actor?.kind !== "human"))
|
|
61
|
+
return world;
|
|
62
|
+
if (request.actor?.kind === "agent" && !request.unsigned)
|
|
63
|
+
return world;
|
|
64
|
+
const inst = recon.instances.get(request.instance);
|
|
65
|
+
const p = programFor(recon, request.instance);
|
|
66
|
+
const action = recon.results
|
|
67
|
+
.get(request.instance)
|
|
68
|
+
?.actions.find((a) => a.action === request.action);
|
|
69
|
+
if (!inst || !p || !action || (action.state !== "eligible" && action.state !== "dispatched"))
|
|
70
|
+
return world;
|
|
71
|
+
if ((request.actor?.kind === "service" || request.actor?.kind === "connector") &&
|
|
72
|
+
(action.kind !== "connector" ||
|
|
73
|
+
request.actor.id !== action.assigneeId ||
|
|
74
|
+
request.actor.id !== request.by))
|
|
75
|
+
return world;
|
|
76
|
+
if (request.signature && action.kind !== "interaction")
|
|
77
|
+
return world;
|
|
78
|
+
const decisionActor = request.actor?.kind === "human" || request.actor?.kind === "agent" ? request.actor : undefined;
|
|
79
|
+
const actor = decisionActor ?? { id: request.by, kind: "human", groups: [] };
|
|
80
|
+
if (action.kind === "interaction" && !canPerformWork(action, actor, request.by))
|
|
81
|
+
return world;
|
|
82
|
+
if (action.authorityConstraints &&
|
|
83
|
+
((request.actor?.id !== undefined && request.actor.id !== request.by) ||
|
|
84
|
+
!permitsConstraints(action.authorityConstraints, {
|
|
85
|
+
id: request.by,
|
|
86
|
+
groups: request.actor?.groups ?? [],
|
|
87
|
+
})))
|
|
88
|
+
return world;
|
|
89
|
+
const target = recon.results
|
|
90
|
+
.get(request.instance)
|
|
91
|
+
.requirements.find((r) => r.name === action.advances);
|
|
92
|
+
const names = actionTargets(action), multi = names.length > 1;
|
|
93
|
+
const identity = workKey(p.account.name, action.idempotencyKey);
|
|
94
|
+
if (multi) {
|
|
95
|
+
if (workItems(recon).find((w) => w.key === identity)?.state === "conflict")
|
|
96
|
+
return world;
|
|
97
|
+
if (action.kind === "interaction") {
|
|
98
|
+
if (!amendment &&
|
|
99
|
+
world.evidence.some((e) => e.workKey === identity && e.status === "attested"))
|
|
100
|
+
return world;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (action.kind === "decision") {
|
|
104
|
+
const choice = request.decision ?? "accepted";
|
|
105
|
+
const reuse = p.components
|
|
106
|
+
.get(inst.component)
|
|
107
|
+
.requirements.find((r) => r.name === action.advances)?.reuse;
|
|
108
|
+
if (reuse)
|
|
109
|
+
return decide(recon, world, at, {
|
|
110
|
+
id: request.id ??
|
|
111
|
+
`reuse:${inst.id}:${action.advances}:${choice}:${world.decisions?.length ?? 0}`,
|
|
112
|
+
instance: inst.id,
|
|
113
|
+
decision: reuseDecisionName(inst.component, action.advances, choice),
|
|
114
|
+
actor: decisionActor ?? { id: request.by, kind: "human", groups: [] },
|
|
115
|
+
...(request.reason === undefined ? {} : { reason: request.reason }),
|
|
116
|
+
...(request.revoke ? { revoke: request.revoke } : {}),
|
|
117
|
+
}).world;
|
|
118
|
+
const result = decide(recon, world, at, {
|
|
119
|
+
id: request.id ??
|
|
120
|
+
`prior:${inst.id}:${action.advances}:${choice}:${world.decisions?.length ?? 0}`,
|
|
121
|
+
instance: inst.id,
|
|
122
|
+
decision: priorCycleOperationName(p.ir.decisions ?? [], inst.component, action.advances, choice),
|
|
123
|
+
actor: decisionActor ?? { id: request.by, kind: "human", groups: [] },
|
|
124
|
+
...(request.reason === undefined ? {} : { reason: request.reason }),
|
|
125
|
+
...(request.revoke ? { revoke: request.revoke } : {}),
|
|
126
|
+
});
|
|
127
|
+
if (!result.accepted || result.world === world)
|
|
128
|
+
return result.world;
|
|
129
|
+
const title = `${request.revoke ? "Revoked" : choice === "accepted" ? "Accepted" : "Declined"} the prior cycle's ${target.label}`;
|
|
130
|
+
return {
|
|
131
|
+
...result.world,
|
|
132
|
+
acceptances: result.record?.kind === "grant"
|
|
133
|
+
? [
|
|
134
|
+
...result.world.acceptances,
|
|
135
|
+
{
|
|
136
|
+
instance: inst.id,
|
|
137
|
+
requirement: action.advances,
|
|
138
|
+
from: inst.prior ?? "",
|
|
139
|
+
decision: choice,
|
|
140
|
+
by: result.record.by,
|
|
141
|
+
at,
|
|
142
|
+
},
|
|
143
|
+
]
|
|
144
|
+
: result.world.acceptances,
|
|
145
|
+
journal: result.world.journal.map((entry, i) => i === result.world.journal.length - 1 ? { ...entry, title } : entry),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (action.kind === "connector") {
|
|
149
|
+
// Idempotent: a retried reconcile never dispatches the same work twice.
|
|
150
|
+
if (world.dispatches.some((d) => d.key === action.idempotencyKey))
|
|
151
|
+
return world;
|
|
152
|
+
let next = log({
|
|
153
|
+
...world,
|
|
154
|
+
dispatches: [
|
|
155
|
+
...world.dispatches,
|
|
156
|
+
{
|
|
157
|
+
key: action.idempotencyKey,
|
|
158
|
+
action: action.action,
|
|
159
|
+
occurrence: target.occurrence,
|
|
160
|
+
assignee: action.assignee,
|
|
161
|
+
at,
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
}, {
|
|
165
|
+
at,
|
|
166
|
+
actor: "worldvm:runtime",
|
|
167
|
+
title: `Dispatched ${action.via}`,
|
|
168
|
+
context: `idempotency key ${action.idempotencyKey}`,
|
|
169
|
+
changes: [],
|
|
170
|
+
});
|
|
171
|
+
if (request.connectorAcknowledgement === "deferred")
|
|
172
|
+
return next;
|
|
173
|
+
// Simulated acknowledgement: the connector opens the machines it owns at their initial state.
|
|
174
|
+
const connector = p.connectors.get(action.via.split("/")[0]);
|
|
175
|
+
for (const use of p.components.get(inst.component).machines) {
|
|
176
|
+
const protocol = p.machines.get(use.protocol);
|
|
177
|
+
if (protocol && connector?.owns.includes(protocol.name))
|
|
178
|
+
next = signal(recon, next, at, {
|
|
179
|
+
instance: inst.id,
|
|
180
|
+
machine: use.name,
|
|
181
|
+
state: protocol.initial,
|
|
182
|
+
by: `connector:${connector.name}`,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return next;
|
|
186
|
+
}
|
|
187
|
+
const interaction = p.interactions.get(action.interaction ?? "");
|
|
188
|
+
if (!interaction)
|
|
189
|
+
return world;
|
|
190
|
+
const supplied = request.values ?? {};
|
|
191
|
+
const inputBasis = basis(world, at);
|
|
192
|
+
const fields = projectInteractionFields(p, interaction, (expr) => evaluateFor(recon, inputBasis, at, inst.id, expr, target.occurrence));
|
|
193
|
+
const values = { ...supplied };
|
|
194
|
+
for (const fixed of interaction.fixes ?? []) {
|
|
195
|
+
if (supplied[fixed.field] !== undefined && supplied[fixed.field] !== fixed.value)
|
|
196
|
+
return world;
|
|
197
|
+
values[fixed.field] = fixed.value;
|
|
198
|
+
}
|
|
199
|
+
for (const field of fields) {
|
|
200
|
+
const proposed = supplied[field.field];
|
|
201
|
+
if (field.mode === "read-only" &&
|
|
202
|
+
proposed !== undefined &&
|
|
203
|
+
(field.value === null || String(proposed) !== String(field.value)))
|
|
204
|
+
return world;
|
|
205
|
+
if (field.value !== null &&
|
|
206
|
+
(proposed === undefined ||
|
|
207
|
+
field.mode === "read-only" ||
|
|
208
|
+
String(proposed) === String(field.value)))
|
|
209
|
+
values[field.field] = field.value;
|
|
210
|
+
}
|
|
211
|
+
const type = interaction.produces;
|
|
212
|
+
if (!request.unsigned &&
|
|
213
|
+
!canAttestEvidence(instanceContext(recon, inputBasis, inst), type, actor))
|
|
214
|
+
return world;
|
|
215
|
+
const audit = p.evidence.get(type)?.attest?.audit;
|
|
216
|
+
const method = p.evidence.get(type)?.attest?.method;
|
|
217
|
+
if (request.signature && !audit)
|
|
218
|
+
return world;
|
|
219
|
+
if (!request.unsigned &&
|
|
220
|
+
audit &&
|
|
221
|
+
(request.actor?.kind !== "human" ||
|
|
222
|
+
request.actor.id !== request.by ||
|
|
223
|
+
action.assigneeId == null ||
|
|
224
|
+
(action.assigneeKind === "group"
|
|
225
|
+
? !request.actor.groups.includes(action.assigneeId)
|
|
226
|
+
: request.actor.id !== action.assigneeId) ||
|
|
227
|
+
!canPerformWork(action, request.actor, request.by) ||
|
|
228
|
+
!signatureInputValid(request.signature, method)))
|
|
229
|
+
return world;
|
|
230
|
+
const requirement = p.components
|
|
231
|
+
.get(inst.component)
|
|
232
|
+
.requirements.find((r) => r.name === action.advances);
|
|
233
|
+
const scope = !request.unsigned && requirement.reuse
|
|
234
|
+
? reuseKey(instanceContext(recon, inputBasis, inst), requirement)
|
|
235
|
+
: null;
|
|
236
|
+
if (!request.unsigned &&
|
|
237
|
+
(!validEvidence(p, type, values, at) ||
|
|
238
|
+
!evidenceFilesAllowed(p, inputBasis, occurrenceHome(p, inst, recon.instances)?.id, type, values)))
|
|
239
|
+
return world;
|
|
240
|
+
if (!request.unsigned)
|
|
241
|
+
for (const binding of interaction.binds) {
|
|
242
|
+
if (binding.target?.k !== "attr" || values[binding.field] === undefined)
|
|
243
|
+
continue;
|
|
244
|
+
const entity = evaluateFor(recon, inputBasis, at, inst.id, binding.target.of);
|
|
245
|
+
if (typeof entity === "string" &&
|
|
246
|
+
!factFileAllowed(p, inputBasis, entity, binding.target.attr, values[binding.field]))
|
|
247
|
+
return world;
|
|
248
|
+
}
|
|
249
|
+
const record = {
|
|
250
|
+
...(amendment ? { amendment } : {}),
|
|
251
|
+
id: `ev-${world.evidence.length + 1}`,
|
|
252
|
+
type,
|
|
253
|
+
...(request.unsigned && interaction.binds.length ? { interaction: interaction.name } : {}),
|
|
254
|
+
occurrence: target.occurrence,
|
|
255
|
+
...(scope ? { reuseScopes: [scope] } : {}),
|
|
256
|
+
...(multi
|
|
257
|
+
? {
|
|
258
|
+
occurrences: names.map((name) => recon.results.get(inst.id).requirements.find((r) => r.name === name).occurrence),
|
|
259
|
+
workKey: identity,
|
|
260
|
+
}
|
|
261
|
+
: {}),
|
|
262
|
+
status: request.unsigned ? "submitted" : "attested",
|
|
263
|
+
at,
|
|
264
|
+
by: request.by,
|
|
265
|
+
values: Object.fromEntries(Object.entries(values).map(([key, v]) => [key, String(v)])),
|
|
266
|
+
};
|
|
267
|
+
const signedRecord = audit && request.signature ? signEvidence(record, audit, request.signature) : record;
|
|
268
|
+
let next = log({
|
|
269
|
+
...world,
|
|
270
|
+
evidence: [...world.evidence, signedRecord],
|
|
271
|
+
}, {
|
|
272
|
+
at,
|
|
273
|
+
actor: request.by,
|
|
274
|
+
title: `${amendment ? "Amended and re-attested" : request.unsigned ? "Submitted (unsigned)" : "Attested"} ${type}`,
|
|
275
|
+
context: target.occurrence,
|
|
276
|
+
changes: [
|
|
277
|
+
{
|
|
278
|
+
label: `${type}.status`,
|
|
279
|
+
before: "—",
|
|
280
|
+
after: request.unsigned ? "submitted" : "attested",
|
|
281
|
+
},
|
|
282
|
+
...(amendment
|
|
283
|
+
? [{ label: `${type}.correction`, before: amendment.previous, after: amendment.reason }]
|
|
284
|
+
: []),
|
|
285
|
+
...Object.entries(values).map(([label, after]) => ({
|
|
286
|
+
label: `${type}.${label}`,
|
|
287
|
+
before: "—",
|
|
288
|
+
after: String(after),
|
|
289
|
+
})),
|
|
290
|
+
],
|
|
291
|
+
});
|
|
292
|
+
if (request.unsigned)
|
|
293
|
+
return next;
|
|
294
|
+
// Accepted evidence writes through direct role fields; reference-path bindings are read-only.
|
|
295
|
+
const changes = [];
|
|
296
|
+
const changedFacts = new Set();
|
|
297
|
+
for (const proposal of interaction.binds) {
|
|
298
|
+
if (!proposal.target)
|
|
299
|
+
continue;
|
|
300
|
+
const value = values[proposal.field];
|
|
301
|
+
if (value === undefined || value === "" || proposal.target.k !== "attr")
|
|
302
|
+
continue;
|
|
303
|
+
const via = proposal.target.meta.via;
|
|
304
|
+
if (via && (p.bindings.get(via)?.attrs.length ?? 0) > 1)
|
|
305
|
+
continue;
|
|
306
|
+
const entity = evaluateFor(recon, basis(next, at), at, inst.id, proposal.target.of);
|
|
307
|
+
if (typeof entity !== "string")
|
|
308
|
+
continue;
|
|
309
|
+
const before = basis(next, at).fact(entity, proposal.target.attr)?.v;
|
|
310
|
+
if (before === value)
|
|
311
|
+
continue;
|
|
312
|
+
next = {
|
|
313
|
+
...next,
|
|
314
|
+
facts: [...next.facts, { e: entity, a: proposal.target.attr, v: value, at, by: request.by }],
|
|
315
|
+
};
|
|
316
|
+
changedFacts.add(factKey(entity, proposal.target.attr));
|
|
317
|
+
changes.push({
|
|
318
|
+
label: `${proposal.target.attr} (${proposal.target.meta.via ?? proposal.target.meta.path})`,
|
|
319
|
+
before: before === undefined ? "—" : String(before),
|
|
320
|
+
after: String(value),
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
next = refreshDrafts(recon, next, at, changedFacts);
|
|
324
|
+
const confirmed = interaction.binds.flatMap((binding) => {
|
|
325
|
+
const expr = binding.from ?? binding.target;
|
|
326
|
+
if (expr?.k !== "attr" || !collectionRule(p, expr.attr))
|
|
327
|
+
return [];
|
|
328
|
+
const entity = evaluateFor(recon, basis(next, at), at, inst.id, expr.of), value = values[binding.field];
|
|
329
|
+
return typeof entity === "string" &&
|
|
330
|
+
value !== undefined &&
|
|
331
|
+
basis(next, at).fact(entity, expr.attr)?.v === value
|
|
332
|
+
? [{ entity, attribute: expr.attr, value }]
|
|
333
|
+
: [];
|
|
334
|
+
});
|
|
335
|
+
next = confirmFacts(next, at, request.by, confirmed);
|
|
336
|
+
return changes.length
|
|
337
|
+
? log(next, {
|
|
338
|
+
at,
|
|
339
|
+
actor: request.by,
|
|
340
|
+
title: "Proposed facts accepted",
|
|
341
|
+
context: `${interaction.name} :binds`,
|
|
342
|
+
changes,
|
|
343
|
+
})
|
|
344
|
+
: next;
|
|
345
|
+
};
|
|
346
|
+
/** An inbound signal moves a machine only along a declared transition. */
|
|
347
|
+
export const signal = (recon, world, at, request) => {
|
|
348
|
+
const inst = recon.instances.get(request.instance);
|
|
349
|
+
const p = programFor(recon, request.instance);
|
|
350
|
+
if (!inst || !p)
|
|
351
|
+
return world;
|
|
352
|
+
const b = basis(world, at);
|
|
353
|
+
const scope = resourceMachineScope(p, b, inst, request.machine);
|
|
354
|
+
const before = machineState(b, inst.id, request.machine, scope);
|
|
355
|
+
if (!canTransition(p, b, inst, request.machine, request.state))
|
|
356
|
+
return log(world, {
|
|
357
|
+
at,
|
|
358
|
+
actor: request.by,
|
|
359
|
+
title: `Rejected signal: ${request.machine} cannot move from ${before ?? "nothing"} to ${request.state}`,
|
|
360
|
+
context: inst.id,
|
|
361
|
+
changes: [],
|
|
362
|
+
});
|
|
363
|
+
const protocol = p.machines.get(p.components.get(inst.component).machines.find((m) => m.name === request.machine).protocol);
|
|
364
|
+
const label = (state) => state === null ? "—" : (protocol.states.find((s) => s.name === state)?.label ?? state);
|
|
365
|
+
return log({
|
|
366
|
+
...world,
|
|
367
|
+
signals: [
|
|
368
|
+
...world.signals,
|
|
369
|
+
{
|
|
370
|
+
instance: inst.id,
|
|
371
|
+
machine: request.machine,
|
|
372
|
+
state: request.state,
|
|
373
|
+
at,
|
|
374
|
+
by: request.by,
|
|
375
|
+
...(scope ?? {}),
|
|
376
|
+
},
|
|
377
|
+
],
|
|
378
|
+
}, {
|
|
379
|
+
at,
|
|
380
|
+
actor: request.by,
|
|
381
|
+
title: `Signal ${protocol.signal}: ${label(request.state)}`,
|
|
382
|
+
context: inst.id,
|
|
383
|
+
changes: [
|
|
384
|
+
{ label: `${request.machine}.state`, before: label(before), after: label(request.state) },
|
|
385
|
+
],
|
|
386
|
+
});
|
|
387
|
+
};
|
|
388
|
+
/** A command is admitted only if no declared invariant forbids it now. */
|
|
389
|
+
export const command = (recon, world, at, request) => {
|
|
390
|
+
const snapshot = basis(world, at);
|
|
391
|
+
const violations = [...admit(recon, snapshot, at, request)];
|
|
392
|
+
for (const fact of request.facts)
|
|
393
|
+
for (const p of recon.programs) {
|
|
394
|
+
if (fact.v !== null && !factFileAllowed(p, snapshot, fact.e, fact.a, fact.v))
|
|
395
|
+
violations.push({
|
|
396
|
+
instance: fact.e,
|
|
397
|
+
invariant: "E_FILE_REFERENCE",
|
|
398
|
+
reason: "File fact requires clean, non-redacted metadata within every declared field policy.",
|
|
399
|
+
at: p.account.at,
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
if (violations.length)
|
|
403
|
+
return {
|
|
404
|
+
violations,
|
|
405
|
+
world: log(world, {
|
|
406
|
+
at,
|
|
407
|
+
actor: request.by,
|
|
408
|
+
title: `Rejected: ${request.title}`,
|
|
409
|
+
context: violations.map((v) => `invariant ${v.reason}`).join("; "),
|
|
410
|
+
changes: [],
|
|
411
|
+
}),
|
|
412
|
+
};
|
|
413
|
+
const b = basis(world, at);
|
|
414
|
+
return {
|
|
415
|
+
violations,
|
|
416
|
+
world: log(refreshDrafts(recon, {
|
|
417
|
+
...world,
|
|
418
|
+
facts: [...world.facts, ...request.facts.map((f) => ({ ...f, at, by: request.by }))],
|
|
419
|
+
}, at, new Set(request.facts.map((f) => factKey(f.e, f.a)))), {
|
|
420
|
+
at,
|
|
421
|
+
actor: request.by,
|
|
422
|
+
title: request.title,
|
|
423
|
+
context: "admitted: no invariant forbids it",
|
|
424
|
+
changes: request.facts.map((f) => ({
|
|
425
|
+
label: f.a,
|
|
426
|
+
before: String(b.fact(f.e, f.a)?.v ?? "—"),
|
|
427
|
+
after: f.v === null ? "—" : String(f.v),
|
|
428
|
+
})),
|
|
429
|
+
}),
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
/** Only this checked path can pass correction metadata into the shared writer. */
|
|
433
|
+
export const amendEvidence = (recon, world, at, request) => {
|
|
434
|
+
const who = request.actor, input = request.amend;
|
|
435
|
+
if (!who ||
|
|
436
|
+
who.kind !== "human" ||
|
|
437
|
+
who.id !== request.by ||
|
|
438
|
+
request.unsigned ||
|
|
439
|
+
!input.previous.trim() ||
|
|
440
|
+
!input.reason.trim() ||
|
|
441
|
+
input.reason.length > 2000)
|
|
442
|
+
return world;
|
|
443
|
+
const prepared = amendmentAction(recon, world, at, request.instance, request.action, input.previous);
|
|
444
|
+
if (!prepared.action)
|
|
445
|
+
return world;
|
|
446
|
+
const action = prepared.action;
|
|
447
|
+
if (!action.assigneeId ||
|
|
448
|
+
(action.assigneeKind === "group"
|
|
449
|
+
? !who.groups.includes(action.assigneeId)
|
|
450
|
+
: who.id !== action.assigneeId))
|
|
451
|
+
return world;
|
|
452
|
+
const inst = recon.instances.get(request.instance), p = programFor(recon, inst.id), home = occurrenceHome(p, inst, recon.instances);
|
|
453
|
+
if (!home ||
|
|
454
|
+
[request.action, "perform"].some((kind) => admit(recon, basis(world, at), at, { kind, subject: home.id }).length))
|
|
455
|
+
return world;
|
|
456
|
+
const current = recon.results.get(inst.id);
|
|
457
|
+
const amended = {
|
|
458
|
+
...recon,
|
|
459
|
+
results: new Map(recon.results).set(inst.id, {
|
|
460
|
+
...current,
|
|
461
|
+
actions: [...current.actions.filter((a) => a.action !== request.action), action],
|
|
462
|
+
}),
|
|
463
|
+
};
|
|
464
|
+
return performInMode(amended, world, at, request, {
|
|
465
|
+
...input,
|
|
466
|
+
previousDigest: sha256(canonicalJson(prepared.record)),
|
|
467
|
+
});
|
|
468
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type * as IR from "../world-ir/types.generated.js";
|
|
2
|
+
import type { Scalar } from "./basis.js";
|
|
3
|
+
import type { TimePoint } from "./instants.js";
|
|
4
|
+
import { type WorkActor } from "./commands.js";
|
|
5
|
+
import { type World } from "./memory.js";
|
|
6
|
+
import type { WorldReconciliation, ActionResult } from "./model.js";
|
|
7
|
+
export type OperationTarget = {
|
|
8
|
+
readonly instance: string;
|
|
9
|
+
} | {
|
|
10
|
+
readonly parent: string;
|
|
11
|
+
readonly slot: string;
|
|
12
|
+
readonly instance?: string;
|
|
13
|
+
};
|
|
14
|
+
export interface OperationRequest {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly account: string;
|
|
17
|
+
readonly target: OperationTarget;
|
|
18
|
+
readonly operation: string;
|
|
19
|
+
readonly actor: WorkActor;
|
|
20
|
+
readonly values?: Readonly<Record<string, Scalar>>;
|
|
21
|
+
readonly unsigned?: boolean;
|
|
22
|
+
readonly signature?: IR.SignatureInput;
|
|
23
|
+
readonly amend?: IR.AmendmentInput;
|
|
24
|
+
readonly reason?: Scalar | null;
|
|
25
|
+
readonly revoke?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface OperationResult {
|
|
28
|
+
readonly accepted: boolean;
|
|
29
|
+
readonly codes: readonly string[];
|
|
30
|
+
readonly world: World;
|
|
31
|
+
readonly instance?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface PublicOperation {
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly kind: "action" | "decision";
|
|
36
|
+
readonly state: ActionResult["state"] | "complete" | "not-applicable" | "decision";
|
|
37
|
+
readonly workKey?: string;
|
|
38
|
+
readonly amendable?: boolean;
|
|
39
|
+
readonly at: IR.Span;
|
|
40
|
+
}
|
|
41
|
+
/** Structural projection only; command admission still checks the trusted actor and current work. */
|
|
42
|
+
export declare const operationsFor: (recon: WorldReconciliation, account: string, target: OperationTarget) => {
|
|
43
|
+
readonly instance: string | null;
|
|
44
|
+
readonly operations: readonly PublicOperation[];
|
|
45
|
+
readonly codes: readonly string[];
|
|
46
|
+
};
|
|
47
|
+
/** The host supplies a current reconciliation/basis pair and verified identity; M16 serializes it. */
|
|
48
|
+
export declare const invokeOperation: (recon: WorldReconciliation, world: World, now: TimePoint, request: OperationRequest) => OperationResult;
|