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,59 @@
|
|
|
1
|
+
export { sensitiveClasses, sensitivityOfType, sensitivePayload, factSensitivity, sensitivityDiagnostics, sensitiveTypeHelp, sensitiveSealHelp, type SensitiveClass, type Sensitivity, } from "./sensitivity.js";
|
|
2
|
+
export { resourceProofDiagnostics, resourceProofRequirement } from "./resource-proofs.js";
|
|
3
|
+
export { childParameterDiagnostics } from "./child-parameters.js";
|
|
4
|
+
export { componentOperationNames, operationDeclarationProblem } from "./component-operations.js";
|
|
5
|
+
export { componentContractDiagnostics } from "./contract-validation.js";
|
|
6
|
+
export { componentContractSurface, componentContractDigest } from "./contracts.js";
|
|
7
|
+
export { sha256, canonicalJson, contentDigest } from "./content-digest.js";
|
|
8
|
+
export { clockBindingDiagnostics } from "./clock-bindings.js";
|
|
9
|
+
export { isInstant, normalizeInstant, timePointKey, instantLiteralDiagnostics, } from "./instants.js";
|
|
10
|
+
export { evidenceScopeDiagnostics, type EvidenceScopeDiagnostic } from "./evidence.js";
|
|
11
|
+
export { isLocalDate } from "./dates.js";
|
|
12
|
+
/** Structural IR checks shared by the publisher and pure runtime. This package has no services. */
|
|
13
|
+
export interface Span {
|
|
14
|
+
readonly src: string;
|
|
15
|
+
readonly from: number;
|
|
16
|
+
readonly to: number;
|
|
17
|
+
readonly line: number;
|
|
18
|
+
readonly col: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ClockDiagnostic {
|
|
21
|
+
readonly code: "E_UNBOUNDED_TIME" | "E_INSTANT_LITERAL" | "E_CLOCK_BINDING";
|
|
22
|
+
readonly severity: "error";
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly help: string;
|
|
25
|
+
readonly at?: Span;
|
|
26
|
+
}
|
|
27
|
+
interface ClockIR {
|
|
28
|
+
readonly evidence?: readonly {
|
|
29
|
+
readonly expires?: unknown;
|
|
30
|
+
}[];
|
|
31
|
+
readonly vaults?: readonly {
|
|
32
|
+
readonly retain: unknown;
|
|
33
|
+
}[];
|
|
34
|
+
readonly components: readonly unknown[];
|
|
35
|
+
readonly derives: readonly {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly body: unknown;
|
|
38
|
+
}[];
|
|
39
|
+
readonly accounts: readonly unknown[];
|
|
40
|
+
}
|
|
41
|
+
/** A clock is a predicate input, never rolling date data. Finite cutoffs are then enumerable
|
|
42
|
+
* from expressions, without probing each day or enumerating an entity namespace. */
|
|
43
|
+
export declare const finiteTimeDiagnostics: (ir: ClockIR) => readonly ClockDiagnostic[];
|
|
44
|
+
export { priorCycleDecisionName, priorCycleOperationName, priorCycleDecisions, } from "./prior-cycle.js";
|
|
45
|
+
export { principalKinds, principalActionKey, principalEscalationKey, type PrincipalIR, type PrincipalKind, type PrincipalDiagnostic, } from "./principals.js";
|
|
46
|
+
export { collectionType, type CollectionType } from "./collect-types.js";
|
|
47
|
+
export { policyNumberValid, policyBoundValid, policyValueWithin, policyParameterType, } from "./policy-bounds.js";
|
|
48
|
+
export { advanceTargets, stableWorkIdentity } from "./advances.js";
|
|
49
|
+
export { reuseDecisionName, reuseDecisions, reuseProblem } from "./reuse.js";
|
|
50
|
+
export { fileDigest, fileShape, fileMediaType, filePolicyValid, filePolicyHelp, fileFieldDiagnostics, } from "./files.js";
|
|
51
|
+
export { documentDiagnostics, documentHelp } from "./documents.js";
|
|
52
|
+
export { noticeDiagnostics, noticeHelp } from "./notices.js";
|
|
53
|
+
export { auditPolicyValid, signatureDiagnostics, signatureHelp } from "./signatures.js";
|
|
54
|
+
export { amendmentDiagnostics, amendmentHelp } from "./amendments.js";
|
|
55
|
+
export { resourceDiagnostics, resourceHelp } from "./resources.js";
|
|
56
|
+
export { vaultAuthority, vaultDiagnostics, vaultHelp } from "./vaults.js";
|
|
57
|
+
export { agentReadDiagnostics, agentReadInfo, agentReadHelp, type AgentReadPermission, type AgentReadInfo, } from "./agent-reads.js";
|
|
58
|
+
export { dataReadInfo, type DataReadSelector } from "./read-classification.js";
|
|
59
|
+
export { semanticJson } from "./canonical-json.js";
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
export { sensitiveClasses, sensitivityOfType, sensitivePayload, factSensitivity, sensitivityDiagnostics, sensitiveTypeHelp, sensitiveSealHelp, } from "./sensitivity.js";
|
|
2
|
+
export { resourceProofDiagnostics, resourceProofRequirement } from "./resource-proofs.js";
|
|
3
|
+
export { childParameterDiagnostics } from "./child-parameters.js";
|
|
4
|
+
export { componentOperationNames, operationDeclarationProblem } from "./component-operations.js";
|
|
5
|
+
export { componentContractDiagnostics } from "./contract-validation.js";
|
|
6
|
+
export { componentContractSurface, componentContractDigest } from "./contracts.js";
|
|
7
|
+
export { sha256, canonicalJson, contentDigest } from "./content-digest.js";
|
|
8
|
+
export { clockBindingDiagnostics } from "./clock-bindings.js";
|
|
9
|
+
export { isInstant, normalizeInstant, timePointKey, instantLiteralDiagnostics, } from "./instants.js";
|
|
10
|
+
export { evidenceScopeDiagnostics } from "./evidence.js";
|
|
11
|
+
export { isLocalDate } from "./dates.js";
|
|
12
|
+
const record = (x) => x && typeof x === "object" && !Array.isArray(x) ? x : {};
|
|
13
|
+
const array = (x) => (Array.isArray(x) ? x : []);
|
|
14
|
+
const expressions = (value, parent) => {
|
|
15
|
+
if (Array.isArray(value))
|
|
16
|
+
return value.flatMap((v) => expressions(v, parent));
|
|
17
|
+
const node = record(value);
|
|
18
|
+
const isExpr = typeof node.k === "string";
|
|
19
|
+
return [
|
|
20
|
+
...(isExpr ? [{ node, parent }] : []),
|
|
21
|
+
...Object.entries(node)
|
|
22
|
+
.filter(([key]) => key !== "at")
|
|
23
|
+
.flatMap(([, v]) => expressions(v, isExpr ? node : parent)),
|
|
24
|
+
];
|
|
25
|
+
};
|
|
26
|
+
const scheduled = (component) => {
|
|
27
|
+
const c = record(component);
|
|
28
|
+
return [
|
|
29
|
+
c.cycle,
|
|
30
|
+
record(c.retention).until,
|
|
31
|
+
...array(c.milestones).map((milestone) => record(milestone).when),
|
|
32
|
+
...array(c.holds).map((hold) => record(hold).while),
|
|
33
|
+
...array(c.resources).map((resource) => record(resource).releaseWhen),
|
|
34
|
+
...array(c.requirements).flatMap((r) => {
|
|
35
|
+
const q = record(r), accepts = record(q.accepts);
|
|
36
|
+
return [
|
|
37
|
+
q.appliesWhen,
|
|
38
|
+
q.satisfiedBy,
|
|
39
|
+
q.due,
|
|
40
|
+
q.remind,
|
|
41
|
+
...array(q.escalate).map((step) => record(step).who),
|
|
42
|
+
q.cycle,
|
|
43
|
+
record(q.recur).from,
|
|
44
|
+
accepts.within,
|
|
45
|
+
accepts.confirm,
|
|
46
|
+
];
|
|
47
|
+
}),
|
|
48
|
+
...array(c.slots).flatMap((s) => [
|
|
49
|
+
record(s).appliesWhen,
|
|
50
|
+
...array(record(s).bind).map((b) => record(b).expr),
|
|
51
|
+
]),
|
|
52
|
+
...array(c.actions).flatMap((a) => [
|
|
53
|
+
record(a).assignee,
|
|
54
|
+
...array(record(a).idempotency),
|
|
55
|
+
...array(record(a).needs).map((n) => record(n).expr),
|
|
56
|
+
]),
|
|
57
|
+
].filter((v) => v !== undefined);
|
|
58
|
+
};
|
|
59
|
+
/** A clock is a predicate input, never rolling date data. Finite cutoffs are then enumerable
|
|
60
|
+
* from expressions, without probing each day or enumerating an entity namespace. */
|
|
61
|
+
export const finiteTimeDiagnostics = (ir) => {
|
|
62
|
+
const definitions = new Map(ir.derives.map((d) => [d.name, expressions(d.body)]));
|
|
63
|
+
const diagnostics = [];
|
|
64
|
+
const reported = new Set();
|
|
65
|
+
const report = (node, message, help) => {
|
|
66
|
+
if (reported.has(node))
|
|
67
|
+
return;
|
|
68
|
+
reported.add(node);
|
|
69
|
+
const at = node.at;
|
|
70
|
+
diagnostics.push({
|
|
71
|
+
code: "E_UNBOUNDED_TIME",
|
|
72
|
+
severity: "error",
|
|
73
|
+
message,
|
|
74
|
+
help,
|
|
75
|
+
...(at ? { at } : {}),
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const clock = (node) => node.k === "var" && ["today", "now"].includes(String(node.name));
|
|
79
|
+
const calls = (nodes) => nodes
|
|
80
|
+
.map(({ node }) => node)
|
|
81
|
+
.filter((n) => n.k === "call" && n.derive === true && typeof n.fn === "string");
|
|
82
|
+
const check = (root, isStatic = false) => {
|
|
83
|
+
const own = expressions(root);
|
|
84
|
+
const reachable = new Set(calls(own).map((n) => String(n.fn)));
|
|
85
|
+
for (const name of reachable)
|
|
86
|
+
for (const call of calls(definitions.get(name) ?? []))
|
|
87
|
+
reachable.add(String(call.fn));
|
|
88
|
+
const nodes = [...own, ...[...reachable].flatMap((n) => definitions.get(n) ?? [])];
|
|
89
|
+
const clocks = nodes.filter(({ node }) => clock(node));
|
|
90
|
+
if (clocks.length === 0)
|
|
91
|
+
return;
|
|
92
|
+
if (isStatic) {
|
|
93
|
+
report(record(root), "Account params are static and cannot read today or now.", "Use constant account params; put date predicates on requirements or actions instead.");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
for (const { node, parent } of clocks)
|
|
97
|
+
if (!(parent?.k === "call" &&
|
|
98
|
+
parent.derive !== true &&
|
|
99
|
+
array(parent.args).length === 2 &&
|
|
100
|
+
["before?", "on-or-after?", "=", "not="].includes(String(parent.fn)) &&
|
|
101
|
+
array(parent.args).slice(0, 2).includes(node) &&
|
|
102
|
+
new Set(array(parent.args)
|
|
103
|
+
.map(record)
|
|
104
|
+
.filter(clock)
|
|
105
|
+
.map((arg) => arg.name)).size <= 1))
|
|
106
|
+
report(node, "Scheduled clock reads must be finite date predicates.", "Use today or now directly in the builtin before?, on-or-after?, = or not= predicates; shift a fact-based cutoff date instead of the clock.");
|
|
107
|
+
const active = new Set(), done = new Set();
|
|
108
|
+
const cycle = (name) => {
|
|
109
|
+
if (done.has(name))
|
|
110
|
+
return;
|
|
111
|
+
active.add(name);
|
|
112
|
+
for (const call of calls(definitions.get(name) ?? [])) {
|
|
113
|
+
const target = String(call.fn);
|
|
114
|
+
if (active.has(target))
|
|
115
|
+
return call;
|
|
116
|
+
const found = cycle(target);
|
|
117
|
+
if (found)
|
|
118
|
+
return found;
|
|
119
|
+
}
|
|
120
|
+
active.delete(name);
|
|
121
|
+
done.add(name);
|
|
122
|
+
};
|
|
123
|
+
for (const name of reachable) {
|
|
124
|
+
const found = cycle(name);
|
|
125
|
+
if (found) {
|
|
126
|
+
report(found, "Clock-dependent scheduled expressions cannot call recursive derives.", "Keep scheduled clock logic non-recursive; use fixed cutoff facts and bounded date predicates.");
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
for (const component of ir.components)
|
|
132
|
+
for (const expr of scheduled(component))
|
|
133
|
+
check(expr);
|
|
134
|
+
for (const evidence of ir.evidence ?? [])
|
|
135
|
+
if (evidence.expires)
|
|
136
|
+
check(evidence.expires);
|
|
137
|
+
for (const vault of ir.vaults ?? [])
|
|
138
|
+
check(vault.retain);
|
|
139
|
+
for (const account of ir.accounts) {
|
|
140
|
+
for (const param of array(record(account).params))
|
|
141
|
+
check(record(param).value, true);
|
|
142
|
+
for (const policy of array(record(account).policies)) {
|
|
143
|
+
check(record(policy).when);
|
|
144
|
+
check(record(policy).require);
|
|
145
|
+
for (const assignment of array(record(policy).assign))
|
|
146
|
+
check(record(assignment).assignee);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return diagnostics;
|
|
150
|
+
};
|
|
151
|
+
export { priorCycleDecisionName, priorCycleOperationName, priorCycleDecisions, } from "./prior-cycle.js";
|
|
152
|
+
export { principalKinds, principalActionKey, principalEscalationKey, } from "./principals.js";
|
|
153
|
+
export { collectionType } from "./collect-types.js";
|
|
154
|
+
export { policyNumberValid, policyBoundValid, policyValueWithin, policyParameterType, } from "./policy-bounds.js";
|
|
155
|
+
export { advanceTargets, stableWorkIdentity } from "./advances.js";
|
|
156
|
+
export { reuseDecisionName, reuseDecisions, reuseProblem } from "./reuse.js";
|
|
157
|
+
export { fileDigest, fileShape, fileMediaType, filePolicyValid, filePolicyHelp, fileFieldDiagnostics, } from "./files.js";
|
|
158
|
+
export { documentDiagnostics, documentHelp } from "./documents.js";
|
|
159
|
+
export { noticeDiagnostics, noticeHelp } from "./notices.js";
|
|
160
|
+
export { auditPolicyValid, signatureDiagnostics, signatureHelp } from "./signatures.js";
|
|
161
|
+
export { amendmentDiagnostics, amendmentHelp } from "./amendments.js";
|
|
162
|
+
export { resourceDiagnostics, resourceHelp } from "./resources.js";
|
|
163
|
+
export { vaultAuthority, vaultDiagnostics, vaultHelp } from "./vaults.js";
|
|
164
|
+
export { agentReadDiagnostics, agentReadInfo, agentReadHelp, } from "./agent-reads.js";
|
|
165
|
+
export { dataReadInfo } from "./read-classification.js";
|
|
166
|
+
export { semanticJson } from "./canonical-json.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Require an explicit known offset; never guess a host zone or silently drop precision. */
|
|
2
|
+
export declare const normalizeInstant: (value: unknown) => string | null;
|
|
3
|
+
/** Stored instants have one representation, suitable for deterministic ordering/digests. */
|
|
4
|
+
export declare const isInstant: (value: unknown) => value is string;
|
|
5
|
+
/** A comparison key shared by publication-time scenario ordering and runtime snapshots. */
|
|
6
|
+
export declare const timePointKey: (value: string) => string;
|
|
7
|
+
export declare const instantLiteralDiagnostics: (ir: unknown) => import("./index.js").ClockDiagnostic[];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { isLocalDate } from "./dates.js";
|
|
2
|
+
const canonical = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
3
|
+
/** Require an explicit known offset; never guess a host zone or silently drop precision. */
|
|
4
|
+
export const normalizeInstant = (value) => {
|
|
5
|
+
if (typeof value !== "string")
|
|
6
|
+
return null;
|
|
7
|
+
const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?(Z|[+-]\d{2}:\d{2})$/.exec(value);
|
|
8
|
+
if (!match ||
|
|
9
|
+
!isLocalDate(match[1]) ||
|
|
10
|
+
Number(match[2]) > 23 ||
|
|
11
|
+
Number(match[3]) > 59 ||
|
|
12
|
+
Number(match[4]) > 59)
|
|
13
|
+
return null;
|
|
14
|
+
const zone = match[6];
|
|
15
|
+
if (zone === "-00:00" ||
|
|
16
|
+
(zone !== "Z" && (Number(zone.slice(1, 3)) > 23 || Number(zone.slice(4)) > 59)))
|
|
17
|
+
return null;
|
|
18
|
+
const ms = Date.parse(value);
|
|
19
|
+
if (!Number.isFinite(ms))
|
|
20
|
+
return null;
|
|
21
|
+
const normalized = new Date(ms).toISOString();
|
|
22
|
+
return canonical.test(normalized) ? normalized : null;
|
|
23
|
+
};
|
|
24
|
+
/** Stored instants have one representation, suitable for deterministic ordering/digests. */
|
|
25
|
+
export const isInstant = (value) => typeof value === "string" && canonical.test(value) && normalizeInstant(value) === value;
|
|
26
|
+
/** A comparison key shared by publication-time scenario ordering and runtime snapshots. */
|
|
27
|
+
export const timePointKey = (value) => {
|
|
28
|
+
if (isLocalDate(value))
|
|
29
|
+
return `${value}T00:00:00.000Z`;
|
|
30
|
+
if (isInstant(value))
|
|
31
|
+
return value;
|
|
32
|
+
throw new RangeError("Expected a local date or canonical UTC millisecond instant");
|
|
33
|
+
};
|
|
34
|
+
export const instantLiteralDiagnostics = (ir) => {
|
|
35
|
+
const diagnostics = [];
|
|
36
|
+
const scan = (value) => {
|
|
37
|
+
if (Array.isArray(value)) {
|
|
38
|
+
value.forEach(scan);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (!value || typeof value !== "object")
|
|
42
|
+
return;
|
|
43
|
+
const node = value;
|
|
44
|
+
if (node.k === "call" && node.fn === "instant" && node.derive !== true) {
|
|
45
|
+
const arg = node.args?.[0];
|
|
46
|
+
if (arg?.k === "lit" && normalizeInstant(arg.v) === null)
|
|
47
|
+
diagnostics.push({
|
|
48
|
+
code: "E_INSTANT_LITERAL",
|
|
49
|
+
severity: "error",
|
|
50
|
+
message: "Invalid explicitly zoned millisecond instant.",
|
|
51
|
+
help: "Use a real RFC3339 timestamp with Z or a known numeric offset and at most three fractional digits.",
|
|
52
|
+
...(arg.at ? { at: arg.at } : {}),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
for (const [key, child] of Object.entries(node))
|
|
56
|
+
if (key !== "at")
|
|
57
|
+
scan(child);
|
|
58
|
+
};
|
|
59
|
+
scan(ir);
|
|
60
|
+
return diagnostics;
|
|
61
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type * as IR from "../world-ir/types.generated.js";
|
|
2
|
+
export declare const noticeHelp = "Use :of Component :document OwnDocument :to person, where person is one entity reference reached from the component's key inputs. Component paths may follow only key inputs; groups, scalar values, calls and attached subjects cannot choose a recipient.";
|
|
3
|
+
/** Conservative reference paths keep identity within the owning occurrence's key closure. */
|
|
4
|
+
export declare const noticeDiagnostics: (ir: Pick<IR.WorldIR, "notices" | "documents" | "components" | "types" | "roles" | "entities">) => IR.Diagnostic[];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export const noticeHelp = "Use :of Component :document OwnDocument :to person, where person is one entity reference reached from the component's key inputs. Component paths may follow only key inputs; groups, scalar values, calls and attached subjects cannot choose a recipient.";
|
|
2
|
+
/** Conservative reference paths keep identity within the owning occurrence's key closure. */
|
|
3
|
+
export const noticeDiagnostics = (ir) => {
|
|
4
|
+
const errors = [], names = new Set();
|
|
5
|
+
const target = (type, seen = new Set()) => {
|
|
6
|
+
if (Array.isArray(type)) {
|
|
7
|
+
if (type[0] === "Option" || type[0] === "Brand")
|
|
8
|
+
return target(type[1], seen);
|
|
9
|
+
return type[0] === "Id" && typeof type[1] === "string" ? type[1] : undefined;
|
|
10
|
+
}
|
|
11
|
+
if (typeof type !== "string" || seen.has(type))
|
|
12
|
+
return undefined;
|
|
13
|
+
const alias = ir.types.find((a) => a.name === type);
|
|
14
|
+
return alias && target(alias.type, new Set([...seen, type]));
|
|
15
|
+
};
|
|
16
|
+
for (const n of ir.notices ?? []) {
|
|
17
|
+
const error = (code, message, at = n.at) => errors.push({ code, severity: "error", message, at, help: noticeHelp }), owner = ir.components.find((c) => c.name === n.of);
|
|
18
|
+
if (names.has(n.name))
|
|
19
|
+
error("E_NOTICE_DOCUMENT", "Notice names must be unique.");
|
|
20
|
+
names.add(n.name);
|
|
21
|
+
if (!owner || !ir.documents?.some((d) => d.name === n.document && d.of === n.of))
|
|
22
|
+
error("E_NOTICE_DOCUMENT", "A notice must select a document owned by its component.");
|
|
23
|
+
const reference = (e) => {
|
|
24
|
+
if (!owner)
|
|
25
|
+
return undefined;
|
|
26
|
+
if (e.k === "var") {
|
|
27
|
+
if (e.name === "self")
|
|
28
|
+
return owner.name;
|
|
29
|
+
return owner.key.includes(e.name)
|
|
30
|
+
? target(owner.inputs.find((f) => f.name === e.name)?.type)
|
|
31
|
+
: undefined;
|
|
32
|
+
}
|
|
33
|
+
if (e.k === "inst") {
|
|
34
|
+
const c = ir.components.find((c) => c.name === reference(e.of));
|
|
35
|
+
return c?.key.includes(e.field)
|
|
36
|
+
? target(c.inputs.find((f) => f.name === e.field)?.type)
|
|
37
|
+
: undefined;
|
|
38
|
+
}
|
|
39
|
+
if (e.k === "read") {
|
|
40
|
+
const role = ir.roles.find((r) => r.name === reference(e.of) && r.name === e.role);
|
|
41
|
+
return target(role?.fields.find((f) => f.name === e.field)?.type);
|
|
42
|
+
}
|
|
43
|
+
if (e.k === "attr") {
|
|
44
|
+
const entity = ir.entities.find((x) => e.attr.startsWith(x.ns + "/")), base = reference(e.of);
|
|
45
|
+
if (!base ||
|
|
46
|
+
!entity ||
|
|
47
|
+
(base !== entity.name && !entity.implements.some((b) => b.role === base)))
|
|
48
|
+
return undefined;
|
|
49
|
+
return target(entity.fields.find((f) => f.name === e.attr.slice(entity.ns.length + 1))?.type);
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
};
|
|
53
|
+
const recipient = reference(n.to);
|
|
54
|
+
if (!recipient || ![...ir.roles, ...ir.entities].some((x) => x.name === recipient))
|
|
55
|
+
error("E_NOTICE_RECIPIENT", "A notice needs one entity reference in its component's key-closed scope.", n.to.at);
|
|
56
|
+
}
|
|
57
|
+
return errors;
|
|
58
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ParamBound, PolicyNumber, TypeAlias } from "../world-ir/types.generated.js";
|
|
2
|
+
export declare const policyNumberValid: (value: PolicyNumber) => boolean;
|
|
3
|
+
export declare const policyBoundValid: (bound: ParamBound) => boolean;
|
|
4
|
+
export declare const policyValueWithin: (bound: ParamBound, value: PolicyNumber) => boolean;
|
|
5
|
+
export declare const policyParameterType: (type: unknown, aliases: readonly TypeAlias[], seen?: Set<string>) => "integer" | "duration" | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const policyNumberValid = (value) => Number.isSafeInteger(value.n) &&
|
|
2
|
+
value.n >= 0 &&
|
|
3
|
+
["integer", "days", "years", "hours", "minutes"].includes(value.unit);
|
|
4
|
+
export const policyBoundValid = (bound) => [bound.min, bound.default, bound.max].every(policyNumberValid) &&
|
|
5
|
+
bound.min.unit === bound.default.unit &&
|
|
6
|
+
bound.max.unit === bound.default.unit &&
|
|
7
|
+
bound.min.n <= bound.default.n &&
|
|
8
|
+
bound.default.n <= bound.max.n &&
|
|
9
|
+
(bound.tighten === "lower"
|
|
10
|
+
? bound.default.n === bound.max.n
|
|
11
|
+
: bound.tighten === "higher" && bound.default.n === bound.min.n);
|
|
12
|
+
export const policyValueWithin = (bound, value) => policyBoundValid(bound) &&
|
|
13
|
+
policyNumberValid(value) &&
|
|
14
|
+
value.unit === bound.default.unit &&
|
|
15
|
+
value.n >= bound.min.n &&
|
|
16
|
+
value.n <= bound.max.n;
|
|
17
|
+
export const policyParameterType = (type, aliases, seen = new Set()) => {
|
|
18
|
+
if (Array.isArray(type) && type[0] === "Brand")
|
|
19
|
+
return policyParameterType(type[1], aliases, seen);
|
|
20
|
+
if (type === "Int")
|
|
21
|
+
return "integer";
|
|
22
|
+
if (type === "Duration")
|
|
23
|
+
return "duration";
|
|
24
|
+
if (typeof type !== "string" || seen.has(type))
|
|
25
|
+
return null;
|
|
26
|
+
const alias = aliases.find((a) => a.name === type);
|
|
27
|
+
return alias ? policyParameterType(alias.type, aliases, new Set([...seen, type])) : null;
|
|
28
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Span } from "./index.js";
|
|
2
|
+
/** A structural view, shared across compiler/runtime Effect versions without services or codecs. */
|
|
3
|
+
export interface PrincipalIR {
|
|
4
|
+
readonly types: readonly unknown[];
|
|
5
|
+
readonly roles: readonly unknown[];
|
|
6
|
+
readonly entities: readonly unknown[];
|
|
7
|
+
readonly components: readonly unknown[];
|
|
8
|
+
readonly derives: readonly unknown[];
|
|
9
|
+
readonly decisions?: readonly unknown[];
|
|
10
|
+
}
|
|
11
|
+
export type PrincipalKind = "entity" | "group";
|
|
12
|
+
export interface PrincipalDiagnostic {
|
|
13
|
+
readonly code: "E_PRINCIPAL_KIND";
|
|
14
|
+
readonly severity: "error";
|
|
15
|
+
readonly message: string;
|
|
16
|
+
readonly help: string;
|
|
17
|
+
readonly at?: Span;
|
|
18
|
+
}
|
|
19
|
+
export declare const principalActionKey: (component: string, action: string) => string;
|
|
20
|
+
export declare const principalEscalationKey: (component: string, requirement: string, index: number) => string;
|
|
21
|
+
export declare const principalKinds: (ir: PrincipalIR, validateClaims?: boolean) => {
|
|
22
|
+
diagnostics: PrincipalDiagnostic[];
|
|
23
|
+
authorities: Map<string, PrincipalKind>;
|
|
24
|
+
assignees: Map<string, PrincipalKind>;
|
|
25
|
+
escalations: Map<string, PrincipalKind>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
const node = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2
|
+
const array = (value) => (Array.isArray(value) ? value : []);
|
|
3
|
+
const help = "Use one principal kind (entity references or groups) in every branch/union; split mixed policies into separate actions, decisions or escalation steps.";
|
|
4
|
+
class KindError extends Error {
|
|
5
|
+
}
|
|
6
|
+
export const principalActionKey = (component, action) => JSON.stringify([component, action]);
|
|
7
|
+
export const principalEscalationKey = (component, requirement, index) => JSON.stringify([component, requirement, index]);
|
|
8
|
+
export const principalKinds = (ir, validateClaims = false) => {
|
|
9
|
+
const named = (values) => new Map(values.map((value) => {
|
|
10
|
+
const item = node(value);
|
|
11
|
+
return [String(item.name), item];
|
|
12
|
+
}));
|
|
13
|
+
const aliases = named(ir.types), roles = named(ir.roles), entities = named(ir.entities), components = named(ir.components), derives = named(ir.derives);
|
|
14
|
+
const field = (owner, name) => array(owner?.fields)
|
|
15
|
+
.map(node)
|
|
16
|
+
.find((f) => f.name === name)?.type;
|
|
17
|
+
const input = (owner, name) => [...array(owner?.inputs), ...array(owner?.params)].map(node).find((f) => f.name === name)?.type;
|
|
18
|
+
const unwrap = (type, seen = new Set()) => {
|
|
19
|
+
if (typeof type === "string" && aliases.has(type)) {
|
|
20
|
+
if (seen.has(type))
|
|
21
|
+
throw new KindError("Recursive principal aliases have no provable kind.");
|
|
22
|
+
return unwrap(aliases.get(type).type, new Set([...seen, type]));
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(type) && (type[0] === "Option" || type[0] === "Brand"))
|
|
25
|
+
return unwrap(type[1], seen);
|
|
26
|
+
return type;
|
|
27
|
+
};
|
|
28
|
+
const combine = (kinds) => {
|
|
29
|
+
const distinct = new Set(kinds.filter((kind) => kind !== null));
|
|
30
|
+
if (distinct.size > 1)
|
|
31
|
+
throw new KindError("A principal expression mixes entity references and groups.");
|
|
32
|
+
return distinct.values().next().value ?? null;
|
|
33
|
+
};
|
|
34
|
+
const typeKind = (type, seen = new Set()) => {
|
|
35
|
+
if (type === null || type === "Unit")
|
|
36
|
+
return null;
|
|
37
|
+
if (typeof type === "string" && aliases.has(type)) {
|
|
38
|
+
if (seen.has(type))
|
|
39
|
+
throw new KindError("Recursive principal aliases have no provable kind.");
|
|
40
|
+
return typeKind(aliases.get(type).type, new Set([...seen, type]));
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(type)) {
|
|
43
|
+
if (type[0] === "Option" || type[0] === "Brand")
|
|
44
|
+
return typeKind(type[1], seen);
|
|
45
|
+
if (type[0] === "Union")
|
|
46
|
+
return combine(type.slice(1).map((t) => typeKind(t, seen)));
|
|
47
|
+
if (type[0] === "Id" && (roles.has(String(type[1])) || entities.has(String(type[1]))))
|
|
48
|
+
return "entity";
|
|
49
|
+
}
|
|
50
|
+
if (typeof type === "string" &&
|
|
51
|
+
(type.startsWith(":") || ["Group", "String", "Keyword", "Date", "Status"].includes(type)))
|
|
52
|
+
return "group";
|
|
53
|
+
throw new KindError("The principal has no statically provable entity/group kind.");
|
|
54
|
+
};
|
|
55
|
+
const expressionType = (owner, e) => {
|
|
56
|
+
if (e.k === "lit")
|
|
57
|
+
return e.v === null ? null : typeof e.v === "string" ? "String" : undefined;
|
|
58
|
+
if (e.k === "kw")
|
|
59
|
+
return "Keyword";
|
|
60
|
+
if (e.k === "var") {
|
|
61
|
+
if (e.name === "self")
|
|
62
|
+
return ["Id", owner.name];
|
|
63
|
+
if (e.name === "today")
|
|
64
|
+
return "Date";
|
|
65
|
+
const found = input(owner, e.name);
|
|
66
|
+
if (found !== undefined)
|
|
67
|
+
return found;
|
|
68
|
+
if ([...array(owner.requirements), ...array(owner.outputs)].some((q) => node(q).name === e.name))
|
|
69
|
+
return "Status";
|
|
70
|
+
}
|
|
71
|
+
if (e.k === "read")
|
|
72
|
+
return field(roles.get(String(e.role)), e.field);
|
|
73
|
+
if (e.k === "attr") {
|
|
74
|
+
const attr = String(e.attr), slash = attr.indexOf("/");
|
|
75
|
+
return field([...entities.values()].find((entity) => entity.ns === attr.slice(0, slash)), attr.slice(slash + 1));
|
|
76
|
+
}
|
|
77
|
+
if (e.k === "inst") {
|
|
78
|
+
const reference = unwrap(expressionType(owner, node(e.of)));
|
|
79
|
+
if (Array.isArray(reference) && reference[0] === "Id") {
|
|
80
|
+
const component = components.get(String(reference[1]));
|
|
81
|
+
const found = input(component, e.field);
|
|
82
|
+
if (found !== undefined)
|
|
83
|
+
return found;
|
|
84
|
+
if ([...array(component?.requirements), ...array(component?.outputs)].some((q) => node(q).name === e.field))
|
|
85
|
+
return "Status";
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (e.k === "call") {
|
|
89
|
+
const derive = derives.get(String(e.fn));
|
|
90
|
+
if (derive)
|
|
91
|
+
return derive.returns;
|
|
92
|
+
if (e.fn === "members")
|
|
93
|
+
return "Group";
|
|
94
|
+
if ([
|
|
95
|
+
"earliest",
|
|
96
|
+
"latest",
|
|
97
|
+
"years-after",
|
|
98
|
+
"months-after",
|
|
99
|
+
"days-after",
|
|
100
|
+
"days-before",
|
|
101
|
+
"business-days-after",
|
|
102
|
+
"asserted-at",
|
|
103
|
+
"added-on",
|
|
104
|
+
].includes(String(e.fn)))
|
|
105
|
+
return "Date";
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
108
|
+
};
|
|
109
|
+
const expressionKind = (owner, expression) => {
|
|
110
|
+
const e = node(expression);
|
|
111
|
+
if (e.k === "if")
|
|
112
|
+
return combine([expressionKind(owner, e.then), expressionKind(owner, e.else)]);
|
|
113
|
+
return typeKind(expressionType(owner, e));
|
|
114
|
+
};
|
|
115
|
+
const diagnostics = [];
|
|
116
|
+
const authorities = new Map(), assignees = new Map(), escalations = new Map();
|
|
117
|
+
const check = (owner, expression, claim, receive, entityOnly = false) => {
|
|
118
|
+
try {
|
|
119
|
+
const kind = expressionKind(owner, expression);
|
|
120
|
+
if (entityOnly && kind !== "entity")
|
|
121
|
+
throw new KindError("An excluded principal must be an entity reference.");
|
|
122
|
+
const actual = kind ?? "group";
|
|
123
|
+
if (validateClaims && claim !== undefined && claim !== actual)
|
|
124
|
+
throw new KindError("Principal-kind metadata disagrees with the declared expression type.");
|
|
125
|
+
receive(actual);
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
if (!(error instanceof KindError))
|
|
129
|
+
throw error;
|
|
130
|
+
const at = node(expression).at;
|
|
131
|
+
diagnostics.push({
|
|
132
|
+
code: "E_PRINCIPAL_KIND",
|
|
133
|
+
severity: "error",
|
|
134
|
+
message: error.message,
|
|
135
|
+
help,
|
|
136
|
+
...(at ? { at } : {}),
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
for (const owner of components.values())
|
|
141
|
+
for (const value of array(owner.actions)) {
|
|
142
|
+
const action = node(value);
|
|
143
|
+
if (action.assignee !== undefined)
|
|
144
|
+
check(owner, action.assignee, action.assigneeKind, (kind) => assignees.set(principalActionKey(String(owner.name), String(action.name)), kind));
|
|
145
|
+
}
|
|
146
|
+
for (const owner of components.values())
|
|
147
|
+
for (const value of array(owner.requirements)) {
|
|
148
|
+
const requirement = node(value);
|
|
149
|
+
array(requirement.escalate).forEach((value, index) => {
|
|
150
|
+
const step = node(value);
|
|
151
|
+
check(owner, step.who, step.whoKind, (kind) => escalations.set(principalEscalationKey(String(owner.name), String(requirement.name), index), kind));
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
for (const value of ir.decisions ?? []) {
|
|
155
|
+
const decision = node(value), owner = components.get(String(decision.of)) ?? {};
|
|
156
|
+
const claim = decision.byKind === "individual" ? "entity" : decision.byKind;
|
|
157
|
+
check(owner, decision.by, claim, (kind) => authorities.set(String(decision.name), kind));
|
|
158
|
+
for (const exclusion of array(decision.distinctFrom))
|
|
159
|
+
check(owner, exclusion, undefined, () => { }, true);
|
|
160
|
+
}
|
|
161
|
+
return { diagnostics, authorities, assignees, escalations };
|
|
162
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
interface Span {
|
|
2
|
+
readonly src: string;
|
|
3
|
+
readonly from: number;
|
|
4
|
+
readonly to: number;
|
|
5
|
+
readonly line: number;
|
|
6
|
+
readonly col: number;
|
|
7
|
+
}
|
|
8
|
+
interface Citation {
|
|
9
|
+
readonly source: string;
|
|
10
|
+
readonly clause: string;
|
|
11
|
+
readonly at: Span;
|
|
12
|
+
}
|
|
13
|
+
export declare const priorCycleDecisionName: (component: string, requirement: string, choice: "accepted" | "declined") => string;
|
|
14
|
+
/** Publish-time sugar and legacy-IR normalization share these owned operation contracts. */
|
|
15
|
+
export declare const priorCycleDecisions: <E>(input: {
|
|
16
|
+
readonly component: string;
|
|
17
|
+
readonly requirement: string;
|
|
18
|
+
readonly by: E;
|
|
19
|
+
readonly byKind?: "individual" | "group";
|
|
20
|
+
readonly at: Span;
|
|
21
|
+
readonly cites?: readonly Citation[];
|
|
22
|
+
}) => {
|
|
23
|
+
cites?: readonly Citation[];
|
|
24
|
+
effect: "accept" | "reject";
|
|
25
|
+
reason: readonly ["Option", "String"];
|
|
26
|
+
at: Span;
|
|
27
|
+
byKind?: "individual" | "group";
|
|
28
|
+
name: string;
|
|
29
|
+
doc: string;
|
|
30
|
+
of: string;
|
|
31
|
+
applies: string;
|
|
32
|
+
by: E;
|
|
33
|
+
}[];
|
|
34
|
+
/** An explicit accept policy owns the legacy confirmation syntax too. */
|
|
35
|
+
export declare const priorCycleOperationName: (definitions: readonly {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly of: string;
|
|
38
|
+
readonly applies: string;
|
|
39
|
+
readonly effect: string;
|
|
40
|
+
}[], component: string, requirement: string, choice: "accepted" | "declined") => string;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const priorCycleDecisionName = (component, requirement, choice) => `$prior:${JSON.stringify([component, requirement, choice])}`;
|
|
2
|
+
/** Publish-time sugar and legacy-IR normalization share these owned operation contracts. */
|
|
3
|
+
export const priorCycleDecisions = (input) => ["accepted", "declined"].map((choice) => ({
|
|
4
|
+
name: priorCycleDecisionName(input.component, input.requirement, choice),
|
|
5
|
+
doc: `${choice === "accepted" ? "Accept" : "Decline"} prior-cycle evidence for ${input.component}/${input.requirement}.`,
|
|
6
|
+
of: input.component,
|
|
7
|
+
applies: input.requirement,
|
|
8
|
+
by: input.by,
|
|
9
|
+
...(input.byKind ? { byKind: input.byKind } : {}),
|
|
10
|
+
effect: choice === "accepted" ? "accept" : "reject",
|
|
11
|
+
reason: ["Option", "String"],
|
|
12
|
+
at: input.at,
|
|
13
|
+
...(input.cites ? { cites: input.cites } : {}),
|
|
14
|
+
}));
|
|
15
|
+
/** An explicit accept policy owns the legacy confirmation syntax too. */
|
|
16
|
+
export const priorCycleOperationName = (definitions, component, requirement, choice) => choice === "accepted"
|
|
17
|
+
? (definitions.find((d) => d.of === component &&
|
|
18
|
+
d.applies === requirement &&
|
|
19
|
+
d.effect === "accept" &&
|
|
20
|
+
d.name !== priorCycleDecisionName(component, requirement, "accepted"))?.name ?? priorCycleDecisionName(component, requirement, choice))
|
|
21
|
+
: priorCycleDecisionName(component, requirement, choice);
|