@astrale-os/kernel-core 0.9.0-beta.9 → 0.9.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/dist/auth/authority/accept.js +4 -0
- package/dist/auth/authority/admission/admission.d.ts +4 -1
- package/dist/auth/authority/admission/admission.js +46 -147
- package/dist/auth/authority/admission/index.d.ts +1 -1
- package/dist/auth/authority/admission/index.js +1 -1
- package/dist/auth/authority/admission/references.d.ts +13 -0
- package/dist/auth/authority/admission/references.js +38 -0
- package/dist/auth/authority/admission/term.d.ts +6 -0
- package/dist/auth/authority/admission/term.js +60 -0
- package/dist/auth/authority/admission/wire.d.ts +8 -0
- package/dist/auth/authority/admission/wire.js +33 -0
- package/dist/auth/authority/canonical.d.ts +2 -0
- package/dist/auth/authority/canonical.js +15 -0
- package/dist/auth/authority/index.d.ts +9 -2
- package/dist/auth/authority/index.js +6 -1
- package/dist/auth/authority/language/index.d.ts +3 -1
- package/dist/auth/authority/language/index.js +1 -0
- package/dist/auth/authority/language/predicate.d.ts +31 -16
- package/dist/auth/authority/language/predicate.js +1 -1
- package/dist/auth/authority/language/program.d.ts +21 -0
- package/dist/auth/authority/language/program.js +2 -0
- package/dist/auth/authority/normalization/index.d.ts +1 -1
- package/dist/auth/authority/normalization/index.js +1 -1
- package/dist/auth/authority/normalization/normalize.d.ts +2 -0
- package/dist/auth/authority/normalization/normalize.js +38 -16
- package/dist/auth/authority/ownership.optimization.d.ts +8 -0
- package/dist/auth/authority/ownership.optimization.js +83 -0
- package/dist/auth/authority/prepare-binder-body.d.ts +4 -0
- package/dist/auth/authority/prepare-binder-body.js +31 -0
- package/dist/auth/authority/program.d.ts +28 -0
- package/dist/auth/authority/program.js +191 -0
- package/dist/auth/authority/semantics/class-authority.d.ts +8 -0
- package/dist/auth/authority/semantics/class-authority.js +26 -0
- package/dist/auth/authority/semantics/composition.d.ts +46 -0
- package/dist/auth/authority/semantics/composition.js +150 -0
- package/dist/auth/authority/semantics/failure.d.ts +21 -0
- package/dist/auth/authority/semantics/failure.js +10 -0
- package/dist/auth/authority/semantics/index.d.ts +13 -0
- package/dist/auth/authority/semantics/index.js +6 -0
- package/dist/auth/authority/semantics/interpret.d.ts +41 -0
- package/dist/auth/authority/semantics/interpret.js +388 -0
- package/dist/auth/authority/semantics/residual.d.ts +32 -0
- package/dist/auth/authority/semantics/residual.js +166 -0
- package/dist/auth/authority/semantics/snapshot.d.ts +40 -0
- package/dist/auth/authority/semantics/terms.d.ts +22 -0
- package/dist/auth/authority/semantics/terms.js +96 -0
- package/dist/auth/authority/semantics/vocabulary.d.ts +19 -0
- package/dist/auth/context/context.d.ts +4 -3
- package/dist/auth/expression/authoring/builder.d.ts +2 -11
- package/dist/auth/expression/authoring/builder.js +1 -45
- package/dist/auth/expression/authoring/index.d.ts +1 -1
- package/dist/auth/expression/authoring/index.js +1 -1
- package/dist/auth/expression/index.d.ts +1 -2
- package/dist/auth/expression/index.js +1 -2
- package/dist/auth/expression/language/identity-expression.d.ts +2 -22
- package/dist/auth/grant/index.d.ts +1 -1
- package/dist/auth/grant/index.js +1 -1
- package/dist/auth/grant/resolved/admission.d.ts +4 -3
- package/dist/auth/grant/resolved/admission.js +23 -13
- package/dist/auth/grant/resolved/grant.d.ts +1 -1
- package/dist/auth/grant/resolved/index.d.ts +1 -1
- package/dist/auth/grant/resolved/index.js +1 -1
- package/dist/auth/grant/unresolved/admission.d.ts +4 -1
- package/dist/auth/grant/unresolved/admission.js +27 -67
- package/dist/auth/grant/unresolved/limits.d.ts +2 -4
- package/dist/auth/grant/unresolved/limits.js +1 -5
- package/dist/auth/identity/admission.js +11 -3
- package/dist/auth/identity/identity.d.ts +15 -3
- package/dist/auth/identity/index.d.ts +1 -1
- package/dist/auth/index.d.ts +4 -4
- package/dist/auth/index.js +1 -1
- package/dist/auth/jwk/index.d.ts +1 -1
- package/dist/auth/jwk/index.js +1 -1
- package/dist/auth/jwk/thumbprint.d.ts +2 -0
- package/dist/auth/jwk/thumbprint.js +12 -6
- package/dist/auth/register/fingerprint/fingerprint.d.ts +25 -0
- package/dist/auth/register/fingerprint/fingerprint.js +31 -0
- package/dist/auth/register/fingerprint/index.d.ts +2 -0
- package/dist/auth/register/index.d.ts +5 -0
- package/dist/auth/register/request/admission.d.ts +3 -0
- package/dist/auth/register/request/admission.js +103 -0
- package/dist/auth/register/request/index.d.ts +3 -0
- package/dist/auth/register/request/limits.d.ts +6 -0
- package/dist/auth/register/request/limits.js +6 -0
- package/dist/auth/register/request/request.d.ts +19 -0
- package/dist/auth/{provision → register}/request/self-issuer.d.ts +1 -1
- package/dist/auth/{provision → register}/request/self-issuer.js +1 -1
- package/dist/auth/register/result/index.d.ts +1 -0
- package/dist/auth/register/result/result.d.ts +10 -0
- package/dist/auth/register/result/result.js +1 -0
- package/dist/callable/contract/body.d.ts +10 -0
- package/dist/callable/contract/body.js +7 -0
- package/dist/callable/contract/index.d.ts +2 -1
- package/dist/callable/contract/index.js +1 -1
- package/dist/callable/contract/output.d.ts +18 -2
- package/dist/callable/index.d.ts +3 -2
- package/dist/callable/index.js +2 -1
- package/dist/callable/invocation/call.d.ts +16 -2
- package/dist/callable/invocation/call.js +41 -1
- package/dist/callable/invocation/index.d.ts +1 -1
- package/dist/callable/invocation/index.js +1 -1
- package/dist/callable/invocation/result.d.ts +10 -3
- package/dist/dns-label.d.ts +1 -2
- package/dist/dns-label.js +2 -3
- package/dist/graph/graph/graph.d.ts +1 -5
- package/dist/graph/graph/graph.js +3 -27
- package/dist/graph/graph/index.d.ts +2 -4
- package/dist/graph/graph/index.js +2 -3
- package/dist/graph/graph/model/codec.js +4 -4
- package/dist/graph/graph/model/index.d.ts +1 -1
- package/dist/graph/graph/model/index.js +1 -1
- package/dist/graph/graph/model/model.d.ts +7 -7
- package/dist/graph/graph/model/model.js +6 -6
- package/dist/graph/graph/model/wire.d.ts +58 -78
- package/dist/graph/graph/model/wire.js +18 -19
- package/dist/graph/mutate/authoring/builder.d.ts +2 -2
- package/dist/graph/mutate/authoring/builder.js +2 -2
- package/dist/graph/mutate/authoring/create.js +13 -5
- package/dist/graph/mutate/index.d.ts +1 -1
- package/dist/graph/mutate/language/codec.js +3 -3
- package/dist/graph/mutate/language/model.d.ts +4 -4
- package/dist/graph/mutate/language/wire.d.ts +226 -215
- package/dist/graph/mutate/language/wire.js +42 -47
- package/dist/graph/mutate/result/index.d.ts +4 -3
- package/dist/graph/mutate/result/index.js +8 -6
- package/dist/graph/mutate/result/wire.d.ts +4 -4
- package/dist/graph/mutate/result/wire.js +7 -4
- package/dist/graph/node/identity/id.d.ts +0 -4
- package/dist/graph/node/identity/id.js +0 -5
- package/dist/graph/node/identity/order.js +20 -0
- package/dist/graph/path/authoring/path.d.ts +8 -5
- package/dist/graph/path/authoring/path.js +21 -3
- package/dist/graph/path/language/model.d.ts +8 -3
- package/dist/graph/path/language/syntax.js +23 -8
- package/dist/graph/query/authoring/builder.js +37 -5
- package/dist/graph/query/authoring/model.d.ts +20 -1
- package/dist/graph/query/index.d.ts +4 -2
- package/dist/graph/query/index.js +1 -0
- package/dist/graph/query/language/codec.js +18 -3
- package/dist/graph/query/language/fingerprint.js +8 -0
- package/dist/graph/query/language/model.d.ts +22 -4
- package/dist/graph/query/language/wire.d.ts +124 -114
- package/dist/graph/query/language/wire.js +54 -47
- package/dist/graph/query/order/index.d.ts +53 -0
- package/dist/graph/query/order/index.js +79 -0
- package/dist/graph/query/reference/evaluate.d.ts +1 -0
- package/dist/graph/query/reference/evaluate.js +39 -52
- package/dist/graph/query/result/index.js +1 -1
- package/dist/graph/query/result/wire.d.ts +93 -94
- package/dist/graph/query/result/wire.js +20 -20
- package/dist/graph/reconcile/condition/model.d.ts +2 -2
- package/dist/graph/reconcile/condition/references.d.ts +0 -1
- package/dist/graph/reconcile/condition/references.js +4 -4
- package/dist/graph/reconcile/correspondence.d.ts +9 -8
- package/dist/graph/reconcile/evidence.d.ts +2 -2
- package/dist/graph/reconcile/mutation/assess.d.ts +2 -1
- package/dist/graph/reconcile/observation.d.ts +4 -3
- package/dist/graph/reconcile/planning/canonical.d.ts +6 -0
- package/dist/graph/reconcile/planning/canonical.js +28 -0
- package/dist/graph/reconcile/planning/context.d.ts +3 -3
- package/dist/graph/reconcile/planning/model.d.ts +8 -4
- package/dist/graph/reconcile/planning/plan.js +2 -1
- package/dist/schema/authority/authority-relation.js +3 -0
- package/dist/schema/authority/claims.d.ts +24 -25
- package/dist/schema/authority/claims.js +8 -8
- package/dist/schema/authority/governed-by.d.ts +16 -91
- package/dist/schema/authority/governed-by.js +1 -1
- package/dist/schema/authority/operation-node.d.ts +27 -13
- package/dist/schema/authority/operations.d.ts +8 -168
- package/dist/schema/authority/policy.d.ts +27 -15
- package/dist/schema/authority/vocabulary.d.ts +3 -0
- package/dist/schema/authority/vocabulary.js +25 -0
- package/dist/schema/callables/entrypoint.d.ts +32 -0
- package/dist/schema/callables/entrypoint.js +12 -0
- package/dist/schema/callables/execution.d.ts +569 -0
- package/dist/schema/callables/execution.js +32 -0
- package/dist/schema/callables/function.d.ts +3400 -55
- package/dist/schema/callables/function.js +6 -4
- package/dist/schema/callables/index.d.ts +2 -1
- package/dist/schema/callables/index.js +2 -1
- package/dist/schema/callables/method-of.d.ts +18 -143
- package/dist/schema/callables/method-of.js +2 -2
- package/dist/schema/callables/view.d.ts +83 -51
- package/dist/schema/definitions/class.d.ts +45 -33
- package/dist/schema/definitions/extends.d.ts +16 -110
- package/dist/schema/definitions/instance-of.d.ts +17 -69
- package/dist/schema/domain/domain.d.ts +3343 -148
- package/dist/schema/domain/domain.js +6 -3
- package/dist/schema/domain/of-domain.d.ts +18 -192
- package/dist/schema/domain/of-domain.js +1 -1
- package/dist/schema/identity/composition.d.ts +5 -0
- package/dist/schema/identity/composition.js +5 -0
- package/dist/schema/identity/identity.d.ts +225 -122
- package/dist/schema/identity/identity.js +3 -4
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/installation/operation-id.d.ts +1 -2
- package/dist/schema/installation/operation-id.js +2 -4
- package/dist/schema/introspection/index.d.ts +1 -1
- package/dist/schema/introspection/language.d.ts +12 -28
- package/dist/schema/kernel/projection/callables.js +2 -3
- package/dist/schema/kernel/projection/core.d.ts +7 -0
- package/dist/schema/kernel/projection/core.js +51 -0
- package/dist/schema/kernel/projection/definitions.d.ts +13 -0
- package/dist/schema/kernel/projection/definitions.js +71 -0
- package/dist/schema/kernel/projection/index.d.ts +3 -3
- package/dist/schema/kernel/projection/index.js +2 -2
- package/dist/schema/kernel/projection/methods.d.ts +5 -0
- package/dist/schema/kernel/projection/methods.js +41 -0
- package/dist/schema/kernel/projection/part.d.ts +34 -0
- package/dist/schema/kernel/projection/part.js +42 -0
- package/dist/schema/kernel/projection/paths.d.ts +6 -0
- package/dist/schema/kernel/projection/{keys.js → paths.js} +12 -14
- package/dist/schema/kernel/projection/project.d.ts +4 -2
- package/dist/schema/kernel/projection/project.js +33 -258
- package/dist/schema/kernel/projection/properties.d.ts +11 -0
- package/dist/schema/kernel/projection/properties.js +36 -0
- package/dist/schema/kernel/projection/relations.d.ts +7 -0
- package/dist/schema/kernel/projection/relations.js +61 -0
- package/dist/schema/kernel/projection/types.d.ts +28 -2
- package/dist/schema/kernel/schema.d.ts +9008 -4939
- package/dist/schema/kernel/schema.js +12 -8
- package/dist/schema/kernel/syscalls/contracts/admit.d.ts +15 -12
- package/dist/schema/kernel/syscalls/contracts/admit.js +16 -9
- package/dist/schema/kernel/syscalls/contracts/blob.d.ts +31 -0
- package/dist/schema/kernel/syscalls/contracts/blob.js +24 -0
- package/dist/schema/kernel/syscalls/contracts/can.d.ts +19 -8
- package/dist/schema/kernel/syscalls/contracts/can.js +12 -4
- package/dist/schema/kernel/syscalls/contracts/delegate.d.ts +6 -7
- package/dist/schema/kernel/syscalls/contracts/delegate.js +5 -5
- package/dist/schema/kernel/syscalls/contracts/execution.d.ts +300 -0
- package/dist/schema/kernel/syscalls/contracts/execution.js +116 -0
- package/dist/schema/kernel/syscalls/contracts/expected.d.ts +5 -0
- package/dist/schema/kernel/syscalls/contracts/expected.js +9 -0
- package/dist/schema/kernel/syscalls/contracts/identity.d.ts +18 -19
- package/dist/schema/kernel/syscalls/contracts/identity.js +6 -7
- package/dist/schema/kernel/syscalls/contracts/impersonate.d.ts +6 -0
- package/dist/schema/kernel/syscalls/contracts/impersonate.js +4 -0
- package/dist/schema/kernel/syscalls/contracts/index.d.ts +6 -3
- package/dist/schema/kernel/syscalls/contracts/index.js +6 -3
- package/dist/schema/kernel/syscalls/contracts/install.d.ts +309 -217
- package/dist/schema/kernel/syscalls/contracts/install.js +68 -26
- package/dist/schema/kernel/syscalls/contracts/installation.d.ts +70 -351
- package/dist/schema/kernel/syscalls/contracts/installation.js +29 -67
- package/dist/schema/kernel/syscalls/contracts/introspect.d.ts +11 -15
- package/dist/schema/kernel/syscalls/contracts/introspect.js +8 -15
- package/dist/schema/kernel/syscalls/contracts/journal.d.ts +26 -27
- package/dist/schema/kernel/syscalls/contracts/journal.js +15 -15
- package/dist/schema/kernel/syscalls/contracts/mint.d.ts +5 -7
- package/dist/schema/kernel/syscalls/contracts/mint.js +4 -5
- package/dist/schema/kernel/syscalls/contracts/mutate.d.ts +243 -224
- package/dist/schema/kernel/syscalls/contracts/mutate.js +7 -1
- package/dist/schema/kernel/syscalls/contracts/query.d.ts +239 -222
- package/dist/schema/kernel/syscalls/contracts/query.js +17 -15
- package/dist/schema/kernel/syscalls/contracts/register.d.ts +20 -0
- package/dist/schema/kernel/syscalls/contracts/register.js +24 -0
- package/dist/schema/kernel/syscalls/contracts/uninstall.d.ts +55 -148
- package/dist/schema/kernel/syscalls/contracts/uninstall.js +7 -5
- package/dist/schema/kernel/syscalls/contracts/view-host-requirements.d.ts +17 -0
- package/dist/schema/kernel/syscalls/contracts/view-host-requirements.js +40 -0
- package/dist/schema/kernel/syscalls/contracts/view-resolve.d.ts +27 -28
- package/dist/schema/kernel/syscalls/contracts/view-resolve.js +16 -24
- package/dist/schema/kernel/syscalls/contracts/whoami.d.ts +19 -20
- package/dist/schema/kernel/syscalls/contracts/whoami.js +2 -2
- package/dist/schema/kernel/syscalls/contracts/whois.d.ts +22 -23
- package/dist/schema/kernel/syscalls/contracts/whois.js +3 -3
- package/dist/schema/kernel/syscalls/declarations/admit.d.ts +18 -18
- package/dist/schema/kernel/syscalls/declarations/admit.js +3 -3
- package/dist/schema/kernel/syscalls/declarations/can.d.ts +19 -14
- package/dist/schema/kernel/syscalls/declarations/can.js +4 -4
- package/dist/schema/kernel/syscalls/declarations/delegate.d.ts +9 -12
- package/dist/schema/kernel/syscalls/declarations/delegate.js +4 -4
- package/dist/schema/kernel/syscalls/declarations/download.d.ts +12 -0
- package/dist/schema/kernel/syscalls/declarations/download.js +10 -0
- package/dist/schema/kernel/syscalls/declarations/execution.d.ts +255 -0
- package/dist/schema/kernel/syscalls/declarations/execution.js +52 -0
- package/dist/schema/kernel/syscalls/declarations/impersonate.d.ts +9 -0
- package/dist/schema/kernel/syscalls/declarations/impersonate.js +12 -0
- package/dist/schema/kernel/syscalls/declarations/index.d.ts +1079 -1323
- package/dist/schema/kernel/syscalls/declarations/index.js +18 -2
- package/dist/schema/kernel/syscalls/declarations/install.d.ts +85 -172
- package/dist/schema/kernel/syscalls/declarations/install.js +7 -3
- package/dist/schema/kernel/syscalls/declarations/introspect.d.ts +8 -19
- package/dist/schema/kernel/syscalls/declarations/introspect.js +3 -4
- package/dist/schema/kernel/syscalls/declarations/journal.d.ts +29 -31
- package/dist/schema/kernel/syscalls/declarations/journal.js +4 -2
- package/dist/schema/kernel/syscalls/declarations/mint.d.ts +8 -13
- package/dist/schema/kernel/syscalls/declarations/mint.js +5 -5
- package/dist/schema/kernel/syscalls/declarations/mutate.d.ts +239 -256
- package/dist/schema/kernel/syscalls/declarations/mutate.js +4 -2
- package/dist/schema/kernel/syscalls/declarations/query.d.ts +236 -260
- package/dist/schema/kernel/syscalls/declarations/query.js +4 -2
- package/dist/schema/kernel/syscalls/declarations/register.d.ts +23 -0
- package/dist/schema/kernel/syscalls/declarations/register.js +10 -0
- package/dist/schema/kernel/syscalls/declarations/uninstall.d.ts +51 -153
- package/dist/schema/kernel/syscalls/declarations/uninstall.js +6 -2
- package/dist/schema/kernel/syscalls/declarations/upload.d.ts +15 -0
- package/dist/schema/kernel/syscalls/declarations/upload.js +10 -0
- package/dist/schema/kernel/syscalls/declarations/use-policy.d.ts +4 -0
- package/dist/schema/kernel/syscalls/declarations/use-policy.js +9 -0
- package/dist/schema/kernel/syscalls/declarations/view-resolve.d.ts +30 -37
- package/dist/schema/kernel/syscalls/declarations/view-resolve.js +5 -3
- package/dist/schema/kernel/syscalls/declarations/whoami.d.ts +22 -26
- package/dist/schema/kernel/syscalls/declarations/whoami.js +3 -3
- package/dist/schema/kernel/syscalls/declarations/whois.d.ts +25 -29
- package/dist/schema/kernel/syscalls/declarations/whois.js +5 -3
- package/dist/schema/kernel/syscalls/descriptors/execution.d.ts +303 -0
- package/dist/schema/kernel/syscalls/descriptors/execution.js +11 -0
- package/dist/schema/kernel/syscalls/descriptors/function.d.ts +8 -2
- package/dist/schema/kernel/syscalls/descriptors/functions.d.ts +3 -1
- package/dist/schema/kernel/syscalls/descriptors/functions.js +3 -1
- package/dist/schema/kernel/syscalls/descriptors/identity.d.ts +47 -13
- package/dist/schema/kernel/syscalls/descriptors/identity.js +2 -1
- package/dist/schema/kernel/syscalls/descriptors/index.d.ts +2 -1
- package/dist/schema/kernel/syscalls/descriptors/index.js +2 -1
- package/dist/schema/kernel/syscalls/descriptors/results/view-resolution.d.ts +5 -2
- package/dist/schema/kernel/syscalls/descriptors/results/view-resolution.js +8 -38
- package/dist/schema/kernel/syscalls/descriptors/view.d.ts +11 -9
- package/dist/schema/kernel/syscalls/index.d.ts +2 -2
- package/dist/schema/kernel/syscalls/index.js +2 -2
- package/dist/schema/kernel/syscalls/references/execution.d.ts +55 -0
- package/dist/schema/kernel/syscalls/references/execution.js +13 -0
- package/dist/schema/kernel/syscalls/references/functions.d.ts +12 -2
- package/dist/schema/kernel/syscalls/references/functions.js +3 -1
- package/dist/schema/kernel/syscalls/references/identity.d.ts +9 -0
- package/dist/schema/kernel/syscalls/references/identity.js +1 -0
- package/dist/schema/kernel/syscalls/references/index.d.ts +2 -1
- package/dist/schema/kernel/syscalls/references/index.js +2 -1
- package/dist/schema/meta/created-by.d.ts +32 -0
- package/dist/schema/meta/created-by.js +17 -0
- package/dist/schema/meta/descriptable.d.ts +13 -11
- package/dist/schema/meta/edge.d.ts +5 -9
- package/dist/schema/meta/iconable.d.ts +13 -11
- package/dist/schema/meta/index.d.ts +1 -0
- package/dist/schema/meta/index.js +1 -0
- package/dist/schema/meta/named.d.ts +13 -9
- package/dist/schema/meta/node.d.ts +9 -1
- package/dist/schema/meta/remotable.d.ts +15 -22
- package/dist/schema/meta/statused.d.ts +13 -7
- package/dist/schema/meta/timestamped.d.ts +14 -12
- package/package.json +9 -7
- package/dist/auth/expression/normalization/canonicalize.d.ts +0 -7
- package/dist/auth/expression/normalization/canonicalize.js +0 -102
- package/dist/auth/expression/normalization/index.d.ts +0 -2
- package/dist/auth/expression/normalization/index.js +0 -2
- package/dist/auth/expression/normalization/raise-denials.d.ts +0 -3
- package/dist/auth/expression/normalization/raise-denials.js +0 -59
- package/dist/auth/provision/fingerprint/fingerprint.d.ts +0 -9
- package/dist/auth/provision/fingerprint/fingerprint.js +0 -33
- package/dist/auth/provision/fingerprint/index.d.ts +0 -2
- package/dist/auth/provision/index.d.ts +0 -5
- package/dist/auth/provision/request/admission.d.ts +0 -3
- package/dist/auth/provision/request/admission.js +0 -125
- package/dist/auth/provision/request/index.d.ts +0 -3
- package/dist/auth/provision/request/request.d.ts +0 -29
- package/dist/auth/provision/result/index.d.ts +0 -1
- package/dist/auth/provision/result/result.d.ts +0 -12
- package/dist/graph/graph/navigation/error.d.ts +0 -12
- package/dist/graph/graph/navigation/error.js +0 -20
- package/dist/graph/graph/navigation/index.d.ts +0 -2
- package/dist/graph/graph/navigation/index.js +0 -1
- package/dist/graph/graph/navigation/model.d.ts +0 -15
- package/dist/schema/callables/view-for.d.ts +0 -296
- package/dist/schema/callables/view-for.js +0 -12
- package/dist/schema/kernel/projection/keys.d.ts +0 -3
- package/dist/schema/kernel/projection/path.d.ts +0 -2
- package/dist/schema/kernel/projection/path.js +0 -140
- package/dist/schema/kernel/syscalls/contracts/provision.d.ts +0 -292
- package/dist/schema/kernel/syscalls/contracts/provision.js +0 -19
- package/dist/schema/kernel/syscalls/declarations/define.d.ts +0 -5
- package/dist/schema/kernel/syscalls/declarations/define.js +0 -7
- package/dist/schema/kernel/syscalls/declarations/provision.d.ts +0 -296
- package/dist/schema/kernel/syscalls/declarations/provision.js +0 -8
- /package/dist/auth/{provision/request/request.js → authority/semantics/snapshot.js} +0 -0
- /package/dist/auth/{provision/result/index.js → authority/semantics/vocabulary.js} +0 -0
- /package/dist/auth/{provision → register}/fingerprint/index.js +0 -0
- /package/dist/auth/{provision → register}/index.js +0 -0
- /package/dist/auth/{provision → register}/request/index.js +0 -0
- /package/dist/auth/{provision/result/result.js → register/request/request.js} +0 -0
- /package/dist/{graph/graph/navigation/model.js → auth/register/result/index.js} +0 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { AuthorityFailure } from './failure.js';
|
|
2
|
+
/** A binder admits its Identity when its composed status is positive and not denied. */
|
|
3
|
+
export function allowed(status) {
|
|
4
|
+
return status.positive && !status.denied;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Close the composition of one binder root: the outgoing `extends_with`, `constrained_by` and
|
|
8
|
+
* `excluded_from` Edges, followed transitively. The root must be live and every member must have a
|
|
9
|
+
* concrete Identity Class of `identities`; otherwise the composition is invalid, not false.
|
|
10
|
+
*/
|
|
11
|
+
export function closeComposition(root, snapshot, vocabulary, identities, limits) {
|
|
12
|
+
const allowedClasses = new Set(identities.map(classKey));
|
|
13
|
+
const { extension, constraint, exclusion } = vocabulary.composition;
|
|
14
|
+
const members = [];
|
|
15
|
+
const ordinals = new Map();
|
|
16
|
+
const children = [];
|
|
17
|
+
let edges = 0;
|
|
18
|
+
const admit = (id) => {
|
|
19
|
+
let ordinal = ordinals.get(id);
|
|
20
|
+
if (ordinal !== undefined)
|
|
21
|
+
return ordinal;
|
|
22
|
+
const node = snapshot.node(id);
|
|
23
|
+
if (node === undefined) {
|
|
24
|
+
throw new AuthorityFailure('AUTHORITY_COMPOSITION_INVALID', 'An Identity binder names no live Node.', { identity: id });
|
|
25
|
+
}
|
|
26
|
+
if (!allowedClasses.has(classKey(node.class))) {
|
|
27
|
+
throw new AuthorityFailure('AUTHORITY_COMPOSITION_INVALID', 'An Identity composition reaches a Node that is not an Identity.', { identity: id });
|
|
28
|
+
}
|
|
29
|
+
ordinal = members.length;
|
|
30
|
+
if (limits !== undefined && ordinal >= limits.compositionNodes) {
|
|
31
|
+
throw new AuthorityFailure('AUTHORITY_BUDGET_EXCEEDED', 'An Identity composition exceeds its Node ceiling.', { root, limit: limits.compositionNodes });
|
|
32
|
+
}
|
|
33
|
+
members.push(id);
|
|
34
|
+
ordinals.set(id, ordinal);
|
|
35
|
+
children.push({ extensions: [], constraints: [], exclusions: [] });
|
|
36
|
+
return ordinal;
|
|
37
|
+
};
|
|
38
|
+
admit(root);
|
|
39
|
+
for (let next = 0; next < members.length; next++) {
|
|
40
|
+
const id = members[next];
|
|
41
|
+
const row = children[next];
|
|
42
|
+
const follow = (edge, bucket) => {
|
|
43
|
+
for (const child of snapshot.edges(id, edge, 'out')) {
|
|
44
|
+
edges += 1;
|
|
45
|
+
if (limits !== undefined && edges > limits.compositionEdges) {
|
|
46
|
+
throw new AuthorityFailure('AUTHORITY_BUDGET_EXCEEDED', 'An Identity composition exceeds its Edge ceiling.', { root, limit: limits.compositionEdges });
|
|
47
|
+
}
|
|
48
|
+
bucket.push(admit(child));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
follow(extension, row.extensions);
|
|
52
|
+
follow(constraint, row.constraints);
|
|
53
|
+
follow(exclusion, row.exclusions);
|
|
54
|
+
}
|
|
55
|
+
const order = childrenFirst(children);
|
|
56
|
+
const acyclic = order.length === members.length;
|
|
57
|
+
return Object.freeze({
|
|
58
|
+
root,
|
|
59
|
+
identities: Object.freeze(members),
|
|
60
|
+
acyclic,
|
|
61
|
+
status(leaf) {
|
|
62
|
+
if (!acyclic)
|
|
63
|
+
return undefined;
|
|
64
|
+
// Known leaves keep every value of the fold known.
|
|
65
|
+
const status = fold(leaf);
|
|
66
|
+
return Object.freeze({
|
|
67
|
+
full: status.full === true,
|
|
68
|
+
positive: status.positive === true,
|
|
69
|
+
denied: status.denied === true,
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
decide(leaf) {
|
|
73
|
+
if (!acyclic)
|
|
74
|
+
return false;
|
|
75
|
+
const status = fold(leaf);
|
|
76
|
+
return and(status.positive, not(status.denied));
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* The composed status of the root, children first, in Kleene's strong three-valued logic: an
|
|
81
|
+
* unknown leaf (undefined) leaves unknown only what it can change, and known leaves keep every
|
|
82
|
+
* value known. Iterative in the dependency order, so a deep valid composition needs no call
|
|
83
|
+
* stack; every member's leaf is decided once.
|
|
84
|
+
*/
|
|
85
|
+
function fold(leaf) {
|
|
86
|
+
const values = [];
|
|
87
|
+
// The children's `field`, combined by `or` when `absorbing` is true and by `and` otherwise.
|
|
88
|
+
const combine = (list, field, absorbing) => {
|
|
89
|
+
let result = !absorbing;
|
|
90
|
+
for (const child of list) {
|
|
91
|
+
const truth = values[child][field];
|
|
92
|
+
if (truth === absorbing)
|
|
93
|
+
return absorbing;
|
|
94
|
+
if (truth === undefined)
|
|
95
|
+
result = undefined;
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
};
|
|
99
|
+
for (const ordinal of order) {
|
|
100
|
+
const { extensions, constraints, exclusions } = children[ordinal];
|
|
101
|
+
const truth = leaf(members[ordinal]);
|
|
102
|
+
values[ordinal] = {
|
|
103
|
+
full: and(and(or(truth, combine(extensions, 'full', true)), combine(constraints, 'full', false)), not(combine(exclusions, 'full', true))),
|
|
104
|
+
positive: and(or(truth, combine(extensions, 'positive', true)), combine(constraints, 'positive', false)),
|
|
105
|
+
denied: or(or(combine(exclusions, 'full', true), combine(extensions, 'denied', true)), combine(constraints, 'denied', true)),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return values[0];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function and(left, right) {
|
|
112
|
+
if (left === false || right === false)
|
|
113
|
+
return false;
|
|
114
|
+
return left === undefined || right === undefined ? undefined : true;
|
|
115
|
+
}
|
|
116
|
+
function or(left, right) {
|
|
117
|
+
if (left === true || right === true)
|
|
118
|
+
return true;
|
|
119
|
+
return left === undefined || right === undefined ? undefined : false;
|
|
120
|
+
}
|
|
121
|
+
function not(value) {
|
|
122
|
+
return value === undefined ? undefined : !value;
|
|
123
|
+
}
|
|
124
|
+
/** Kahn order over the closure; shorter than the closure exactly when it contains a cycle. */
|
|
125
|
+
function childrenFirst(children) {
|
|
126
|
+
const parents = children.map(() => []);
|
|
127
|
+
const pending = new Uint32Array(children.length);
|
|
128
|
+
children.forEach((row, ordinal) => {
|
|
129
|
+
const dependencies = new Set([...row.extensions, ...row.constraints, ...row.exclusions]);
|
|
130
|
+
pending[ordinal] = dependencies.size;
|
|
131
|
+
for (const child of dependencies)
|
|
132
|
+
parents[child].push(ordinal);
|
|
133
|
+
});
|
|
134
|
+
const order = [];
|
|
135
|
+
pending.forEach((count, ordinal) => {
|
|
136
|
+
if (count === 0)
|
|
137
|
+
order.push(ordinal);
|
|
138
|
+
});
|
|
139
|
+
for (let next = 0; next < order.length; next++) {
|
|
140
|
+
for (const parent of parents[order[next]]) {
|
|
141
|
+
pending[parent] = pending[parent] - 1;
|
|
142
|
+
if (pending[parent] === 0)
|
|
143
|
+
order.push(parent);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return order;
|
|
147
|
+
}
|
|
148
|
+
function classKey(ref) {
|
|
149
|
+
return `${ref.origin}:${ref.kind}.${ref.name}`;
|
|
150
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An authority decision that cannot be made. A failure is never `false`: under `not` it would
|
|
3
|
+
* become `true`, so every backend surfaces it as a failed request instead of a decision.
|
|
4
|
+
*/
|
|
5
|
+
export type AuthorityFailureCode =
|
|
6
|
+
/** A bound input names no live Node. */
|
|
7
|
+
'AUTHORITY_TARGET_NOT_FOUND'
|
|
8
|
+
/** A term reads an input the decision frame does not bind. */
|
|
9
|
+
| 'AUTHORITY_INPUT_UNBOUND'
|
|
10
|
+
/** A fixed term does not resolve to exactly one live Node. */
|
|
11
|
+
| 'AUTHORITY_REFERENCE_INVALID'
|
|
12
|
+
/** A binder root is absent, or its composition reaches a Node that is not an Identity. */
|
|
13
|
+
| 'AUTHORITY_COMPOSITION_INVALID'
|
|
14
|
+
/** A binder composition exceeds the evaluating backend's ceilings. */
|
|
15
|
+
| 'AUTHORITY_BUDGET_EXCEEDED';
|
|
16
|
+
export declare class AuthorityFailure extends Error {
|
|
17
|
+
readonly code: AuthorityFailureCode;
|
|
18
|
+
readonly details: Readonly<Record<string, unknown>>;
|
|
19
|
+
readonly name: 'AuthorityFailure';
|
|
20
|
+
constructor(code: AuthorityFailureCode, message: string, details?: Readonly<Record<string, unknown>>);
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { classAuthorityMeaning } from './class-authority.js';
|
|
2
|
+
export { allowed, closeComposition } from './composition.js';
|
|
3
|
+
export type { CompositionClosure, CompositionLimits, CompositionStatus } from './composition.js';
|
|
4
|
+
export { AuthorityFailure } from './failure.js';
|
|
5
|
+
export type { AuthorityFailureCode } from './failure.js';
|
|
6
|
+
export { binderRoots, createAuthorityEvaluator } from './interpret.js';
|
|
7
|
+
export type { AuthorityAtom, AuthorityEvaluationOptions, AuthorityEvaluator } from './interpret.js';
|
|
8
|
+
export { residualProgram, staticAtoms } from './residual.js';
|
|
9
|
+
export type { StaticAtom } from './residual.js';
|
|
10
|
+
export type { AuthorityInputs, AuthorityNode, AuthoritySnapshot } from './snapshot.js';
|
|
11
|
+
export { fixedPaths, isFixedTerm, requiredInputs, termPath } from './terms.js';
|
|
12
|
+
export type { FixedTerm } from './terms.js';
|
|
13
|
+
export type { AuthorityVocabulary } from './vocabulary.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { classAuthorityMeaning } from './class-authority.js';
|
|
2
|
+
export { allowed, closeComposition } from './composition.js';
|
|
3
|
+
export { AuthorityFailure } from './failure.js';
|
|
4
|
+
export { binderRoots, createAuthorityEvaluator } from './interpret.js';
|
|
5
|
+
export { residualProgram, staticAtoms } from './residual.js';
|
|
6
|
+
export { fixedPaths, isFixedTerm, requiredInputs, termPath } from './terms.js';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { NodeId } from '../../../graph/node/index.js';
|
|
2
|
+
import type { AuthorityExpr, AuthorityProgram, PredicateRef } from '../language/index.js';
|
|
3
|
+
import type { CompositionLimits } from './composition.js';
|
|
4
|
+
import type { AuthorityInputs, AuthoritySnapshot } from './snapshot.js';
|
|
5
|
+
import type { AuthorityVocabulary } from './vocabulary.js';
|
|
6
|
+
/** A leaf the Boolean and binder structure does not decompose. */
|
|
7
|
+
export type AuthorityAtom = Exclude<AuthorityExpr, {
|
|
8
|
+
readonly op: 'true' | 'false' | 'all' | 'any' | 'not' | 'as';
|
|
9
|
+
}>;
|
|
10
|
+
export interface AuthorityEvaluationOptions {
|
|
11
|
+
/** The evaluating backend's composition ceilings. */
|
|
12
|
+
readonly limits?: CompositionLimits;
|
|
13
|
+
/**
|
|
14
|
+
* Decide an atom outside every existential scope from evidence the snapshot does not hold, such
|
|
15
|
+
* as a captured fact table. Undefined leaves the atom to its meaning over the snapshot.
|
|
16
|
+
*/
|
|
17
|
+
readonly atom?: (atom: AuthorityAtom, subject: NodeId | undefined) => boolean | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Pure observation of the snapshot's evidence token. It changes (Object.is) at every
|
|
20
|
+
* acquisition and stays stable otherwise; observing it must not acquire evidence.
|
|
21
|
+
* Stable snapshots may omit it. Tokens must not be mutated or reused across acquisitions.
|
|
22
|
+
*/
|
|
23
|
+
readonly evidenceEpoch?: () => unknown;
|
|
24
|
+
}
|
|
25
|
+
/** Decisions of one program over one snapshot. Memoized evidence never outlives the evaluator. */
|
|
26
|
+
export interface AuthorityEvaluator {
|
|
27
|
+
/**
|
|
28
|
+
* Resolve every fixed reference and admit every binder composition of the program, as a backend
|
|
29
|
+
* does for its whole request family before it exposes any decision.
|
|
30
|
+
*/
|
|
31
|
+
admit(): void;
|
|
32
|
+
/** Decide one predicate for one input frame; throws `AuthorityFailure`, never returns it. */
|
|
33
|
+
evaluate(predicate: PredicateRef, inputs?: AuthorityInputs): boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The reference interpreter of authority. It is parametric over one snapshot and the Kernel
|
|
37
|
+
* vocabulary, and every backend lowering must agree with it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createAuthorityEvaluator(program: AuthorityProgram, snapshot: AuthoritySnapshot, vocabulary: AuthorityVocabulary, options?: AuthorityEvaluationOptions): AuthorityEvaluator;
|
|
40
|
+
/** Every Identity a binder of the program names, sorted. */
|
|
41
|
+
export declare function binderRoots(expressions: readonly AuthorityExpr[]): readonly NodeId[];
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { Path } from '../../../graph/path/index.js';
|
|
2
|
+
import { allowed, closeComposition } from './composition.js';
|
|
3
|
+
import { AuthorityFailure } from './failure.js';
|
|
4
|
+
import { fixedPaths, termPath } from './terms.js';
|
|
5
|
+
/**
|
|
6
|
+
* The reference interpreter of authority. It is parametric over one snapshot and the Kernel
|
|
7
|
+
* vocabulary, and every backend lowering must agree with it.
|
|
8
|
+
*/
|
|
9
|
+
export function createAuthorityEvaluator(program, snapshot, vocabulary, options = {}) {
|
|
10
|
+
const references = new Map();
|
|
11
|
+
const closures = new Map();
|
|
12
|
+
const projections = new Map();
|
|
13
|
+
const walks = new Map();
|
|
14
|
+
const walkPlans = new WeakMap();
|
|
15
|
+
const existentialPlans = new WeakMap();
|
|
16
|
+
const instanceOf = classKey(vocabulary.instanceOf);
|
|
17
|
+
const reference = (path) => {
|
|
18
|
+
const known = references.get(path.raw);
|
|
19
|
+
if (known !== undefined)
|
|
20
|
+
return known;
|
|
21
|
+
const nodes = [...new Set(snapshot.resolve(path))].filter((id) => snapshot.node(id));
|
|
22
|
+
if (nodes.length !== 1) {
|
|
23
|
+
throw new AuthorityFailure('AUTHORITY_REFERENCE_INVALID', 'An authority fixed reference does not resolve to exactly one live Node.', { path: path.raw, candidates: nodes.length });
|
|
24
|
+
}
|
|
25
|
+
references.set(path.raw, nodes[0]);
|
|
26
|
+
return nodes[0];
|
|
27
|
+
};
|
|
28
|
+
const closure = (root) => {
|
|
29
|
+
let value = closures.get(root);
|
|
30
|
+
if (value === undefined) {
|
|
31
|
+
value = closeComposition(root, snapshot, vocabulary, program.identities, options.limits);
|
|
32
|
+
closures.set(root, value);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
};
|
|
36
|
+
const term = (value, frame) => {
|
|
37
|
+
switch (value.kind) {
|
|
38
|
+
case 'input': {
|
|
39
|
+
const id = frame.inputs[value.input];
|
|
40
|
+
if (id === undefined) {
|
|
41
|
+
throw new AuthorityFailure('AUTHORITY_INPUT_UNBOUND', `Authority input ${value.input} is not bound by the decision frame.`);
|
|
42
|
+
}
|
|
43
|
+
return id;
|
|
44
|
+
}
|
|
45
|
+
case 'subject':
|
|
46
|
+
if (frame.subject === undefined)
|
|
47
|
+
throw new TypeError('Authority subject is unbound.');
|
|
48
|
+
return frame.subject;
|
|
49
|
+
case 'local': {
|
|
50
|
+
const id = frame.locals.get(value.id);
|
|
51
|
+
if (id === undefined)
|
|
52
|
+
throw new TypeError(`Authority local ${value.id} is unbound.`);
|
|
53
|
+
return id;
|
|
54
|
+
}
|
|
55
|
+
default:
|
|
56
|
+
return reference(termPath(value));
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const classOf = (id) => {
|
|
60
|
+
const node = snapshot.node(id);
|
|
61
|
+
if (node === undefined)
|
|
62
|
+
throw new TypeError('Authority evaluation reached a Node that is gone.');
|
|
63
|
+
return node.class;
|
|
64
|
+
};
|
|
65
|
+
/** `instance_of` is derived: the live projection of the Node's exact Class. */
|
|
66
|
+
const projection = (id) => {
|
|
67
|
+
const ref = classOf(id);
|
|
68
|
+
const key = classKey(ref);
|
|
69
|
+
let nodes = projections.get(key);
|
|
70
|
+
if (nodes === undefined) {
|
|
71
|
+
const candidates = snapshot.classProjection?.(ref) ?? snapshot.resolve(Path.project(ref));
|
|
72
|
+
nodes = Object.freeze([...new Set(candidates)].filter((node) => snapshot.node(node)));
|
|
73
|
+
projections.set(key, nodes);
|
|
74
|
+
}
|
|
75
|
+
return nodes;
|
|
76
|
+
};
|
|
77
|
+
const step = (from, edge) => classKey(edge) === instanceOf
|
|
78
|
+
? projection(from)
|
|
79
|
+
: snapshot.edges(from, edge, snapshot.orientation(edge) === 'undirected' ? 'both' : 'out');
|
|
80
|
+
/**
|
|
81
|
+
* Bounded walks: a Node reached at any depth within [min, max], revisits allowed. Each hop may
|
|
82
|
+
* take any member of the Edge Class extent.
|
|
83
|
+
*/
|
|
84
|
+
const related = (expression, source, target) => {
|
|
85
|
+
const { repeat, via: extent } = expression;
|
|
86
|
+
const min = repeat?.min ?? 1;
|
|
87
|
+
const max = repeat?.max ?? 1;
|
|
88
|
+
// The empty walk is already a proof. Do not spend a read budget exploring longer walks.
|
|
89
|
+
if (min === 0 && source === target)
|
|
90
|
+
return true;
|
|
91
|
+
let plan = walkPlans.get(expression);
|
|
92
|
+
if (plan === undefined) {
|
|
93
|
+
const key = JSON.stringify([min, max, extent.map(classKey)]);
|
|
94
|
+
plan = walks.get(key);
|
|
95
|
+
if (plan === undefined) {
|
|
96
|
+
plan = new Map();
|
|
97
|
+
walks.set(key, plan);
|
|
98
|
+
}
|
|
99
|
+
walkPlans.set(expression, plan);
|
|
100
|
+
}
|
|
101
|
+
const epoch = options.evidenceEpoch?.();
|
|
102
|
+
let walk = plan.get(source);
|
|
103
|
+
if (walk === undefined || !Object.is(walk.epoch, epoch)) {
|
|
104
|
+
walk = { epoch, layers: [new Set([source])] };
|
|
105
|
+
plan.delete(source);
|
|
106
|
+
}
|
|
107
|
+
let frontier = walk.layers[0];
|
|
108
|
+
for (let depth = 1; depth <= max && frontier.size > 0; depth++) {
|
|
109
|
+
let next = walk.layers[depth];
|
|
110
|
+
if (next === undefined) {
|
|
111
|
+
const before = options.evidenceEpoch?.();
|
|
112
|
+
const acquired = new Set();
|
|
113
|
+
for (const node of frontier) {
|
|
114
|
+
for (const edge of extent)
|
|
115
|
+
for (const reached of step(node, edge))
|
|
116
|
+
acquired.add(reached);
|
|
117
|
+
}
|
|
118
|
+
next = acquired;
|
|
119
|
+
walk.layers.push(next);
|
|
120
|
+
// Every retained layer must belong to the same epoch. A provisional prefix remains
|
|
121
|
+
// usable for this search only, even if its later extensions acquire no further evidence.
|
|
122
|
+
if (Object.is(walk.epoch, before) && Object.is(before, options.evidenceEpoch?.())) {
|
|
123
|
+
plan.set(source, walk);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
plan.delete(source);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Like the frozen interpreter, acquire no layer beyond the first admissible witness.
|
|
130
|
+
if (depth >= min && next.has(target))
|
|
131
|
+
return true;
|
|
132
|
+
frontier = next;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
};
|
|
136
|
+
const holds = (expression, frame) => {
|
|
137
|
+
switch (expression.op) {
|
|
138
|
+
case 'true':
|
|
139
|
+
return true;
|
|
140
|
+
case 'false':
|
|
141
|
+
return false;
|
|
142
|
+
case 'all':
|
|
143
|
+
return expression.predicates.every((child) => holds(child, frame));
|
|
144
|
+
case 'any':
|
|
145
|
+
return expression.predicates.some((child) => holds(child, frame));
|
|
146
|
+
case 'not':
|
|
147
|
+
return !holds(expression.predicate, frame);
|
|
148
|
+
case 'as': {
|
|
149
|
+
// A cyclic composition makes this binder false; the scope of a cycle is the binder.
|
|
150
|
+
const status = closure(expression.identity).status((identity) => holds(expression.where, { ...frame, subject: identity }));
|
|
151
|
+
return status !== undefined && allowed(status);
|
|
152
|
+
}
|
|
153
|
+
default:
|
|
154
|
+
return atom(expression, frame);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const atom = (expression, frame) => {
|
|
158
|
+
if (options.atom !== undefined && frame.locals.size === 0) {
|
|
159
|
+
const decided = options.atom(expression, frame.subject);
|
|
160
|
+
if (decided !== undefined)
|
|
161
|
+
return decided;
|
|
162
|
+
}
|
|
163
|
+
switch (expression.op) {
|
|
164
|
+
case 'same-node':
|
|
165
|
+
return term(expression.left, frame) === term(expression.right, frame);
|
|
166
|
+
case 'related':
|
|
167
|
+
return related(expression, term(expression.source, frame), term(expression.target, frame));
|
|
168
|
+
case 'instance-of':
|
|
169
|
+
return sameClass(classOf(term(expression.node, frame)), expression.class);
|
|
170
|
+
case 'edge-class': {
|
|
171
|
+
if (frame.inputs.edge === undefined) {
|
|
172
|
+
throw new AuthorityFailure('AUTHORITY_INPUT_UNBOUND', 'Authority edge-class requires a bound Edge object.');
|
|
173
|
+
}
|
|
174
|
+
return sameClass(frame.inputs.edge, expression.class);
|
|
175
|
+
}
|
|
176
|
+
case 'class-authority': {
|
|
177
|
+
// The meaning is `classAuthorityMeaning`; it is decided directly so no atom it expands to
|
|
178
|
+
// is ever asked of a captured fact table.
|
|
179
|
+
const identity = term(expression.identity, frame);
|
|
180
|
+
if (identity === reference(Path.domain(expression.class.origin)))
|
|
181
|
+
return true;
|
|
182
|
+
if (expression.evidence === 'owner')
|
|
183
|
+
return false;
|
|
184
|
+
const target = reference(Path.project(expression.class));
|
|
185
|
+
return snapshot
|
|
186
|
+
.edges(identity, vocabulary.capabilities[expression.operation], 'out')
|
|
187
|
+
.includes(target);
|
|
188
|
+
}
|
|
189
|
+
case 'exists':
|
|
190
|
+
return exists(expression, frame);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const exists = (expression, frame) => {
|
|
194
|
+
const candidates = expression.nodes.map((local) => local.kind === 'any' ? snapshot.nodes() : snapshot.nodes(local.classes));
|
|
195
|
+
// Acquire every extent in declaration order, even when the product has no tuple.
|
|
196
|
+
if (candidates.some((extent) => extent.length === 0))
|
|
197
|
+
return false;
|
|
198
|
+
let plan = existentialPlans.get(expression);
|
|
199
|
+
if (plan === undefined) {
|
|
200
|
+
const predicates = expression.where.op === 'all' ? expression.where.predicates : [expression.where];
|
|
201
|
+
const usedIndices = new Set();
|
|
202
|
+
// Each entry describes the whole prefix, including its earlier true predicates.
|
|
203
|
+
// gates[i] rejects values of local i; resets[i] invalidates their earlier context.
|
|
204
|
+
const gates = expression.nodes.map(() => []);
|
|
205
|
+
const resets = expression.nodes.map(() => []);
|
|
206
|
+
const dependency = predicates.map((predicate, item) => {
|
|
207
|
+
const used = localDependencies(predicate);
|
|
208
|
+
for (let index = 0; index < expression.nodes.length; index++) {
|
|
209
|
+
if (used.has(expression.nodes[index].id))
|
|
210
|
+
usedIndices.add(index);
|
|
211
|
+
}
|
|
212
|
+
const ordered = [...usedIndices].sort((left, right) => left - right);
|
|
213
|
+
const last = ordered.at(-1) ?? -1;
|
|
214
|
+
const earlier = ordered.at(-2) ?? -1;
|
|
215
|
+
if (last >= 0)
|
|
216
|
+
gates[last].push(item);
|
|
217
|
+
// An exclusion of the last dependency is valid only while all earlier ones stay fixed.
|
|
218
|
+
for (let index = 0; index <= earlier; index++)
|
|
219
|
+
resets[index].push(item);
|
|
220
|
+
return last;
|
|
221
|
+
});
|
|
222
|
+
plan = { predicates, dependency, gates, resets };
|
|
223
|
+
existentialPlans.set(expression, plan);
|
|
224
|
+
}
|
|
225
|
+
const { predicates, dependency, gates, resets } = plan;
|
|
226
|
+
const excluded = predicates.map(() => new Set());
|
|
227
|
+
const rejected = (index, node) => {
|
|
228
|
+
for (const item of gates[index])
|
|
229
|
+
if (excluded[item].has(node))
|
|
230
|
+
return true;
|
|
231
|
+
return false;
|
|
232
|
+
};
|
|
233
|
+
const clear = (item) => {
|
|
234
|
+
if (excluded[item].size === 0)
|
|
235
|
+
return;
|
|
236
|
+
excluded[item].clear();
|
|
237
|
+
};
|
|
238
|
+
let prefix = 0;
|
|
239
|
+
let observedEpoch = options.evidenceEpoch?.();
|
|
240
|
+
const refresh = () => {
|
|
241
|
+
const current = options.evidenceEpoch?.();
|
|
242
|
+
if (Object.is(current, observedEpoch))
|
|
243
|
+
return false;
|
|
244
|
+
observedEpoch = current;
|
|
245
|
+
prefix = 0;
|
|
246
|
+
excluded.forEach((_, item) => clear(item));
|
|
247
|
+
return true;
|
|
248
|
+
};
|
|
249
|
+
// -2 means a witness. Every other result identifies the last bound variable that
|
|
250
|
+
// may change the evaluated prefix. Descendants cannot alter its reads or result.
|
|
251
|
+
const locals = new Map(frame.locals);
|
|
252
|
+
const complete = { ...frame, locals };
|
|
253
|
+
const bind = (index) => {
|
|
254
|
+
if (index === expression.nodes.length) {
|
|
255
|
+
for (let item = prefix; item < predicates.length; item++) {
|
|
256
|
+
if (!holds(predicates[item], complete)) {
|
|
257
|
+
if (refresh())
|
|
258
|
+
return expression.nodes.length - 1;
|
|
259
|
+
const target = dependency[item];
|
|
260
|
+
if (target >= 0) {
|
|
261
|
+
const value = locals.get(expression.nodes[target].id);
|
|
262
|
+
if (!excluded[item].has(value)) {
|
|
263
|
+
excluded[item].add(value);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return dependency[item];
|
|
267
|
+
}
|
|
268
|
+
prefix = item + 1;
|
|
269
|
+
}
|
|
270
|
+
return -2;
|
|
271
|
+
}
|
|
272
|
+
const id = expression.nodes[index].id;
|
|
273
|
+
const previous = locals.get(id);
|
|
274
|
+
try {
|
|
275
|
+
for (let ordinal = 0; ordinal < candidates[index].length; ordinal++) {
|
|
276
|
+
refresh();
|
|
277
|
+
const node = candidates[index][ordinal];
|
|
278
|
+
if (rejected(index, node)) {
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
for (const item of resets[index])
|
|
282
|
+
clear(item);
|
|
283
|
+
while (prefix > 0 && dependency[prefix - 1] >= index)
|
|
284
|
+
prefix--;
|
|
285
|
+
locals.set(id, node);
|
|
286
|
+
const result = bind(index + 1);
|
|
287
|
+
if (result === -2 || result < index)
|
|
288
|
+
return result;
|
|
289
|
+
}
|
|
290
|
+
return index - 1;
|
|
291
|
+
}
|
|
292
|
+
finally {
|
|
293
|
+
if (previous === undefined)
|
|
294
|
+
locals.delete(id);
|
|
295
|
+
else
|
|
296
|
+
locals.set(id, previous);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
return bind(0) === -2;
|
|
300
|
+
};
|
|
301
|
+
return Object.freeze({
|
|
302
|
+
admit() {
|
|
303
|
+
for (const path of fixedPaths(program.predicates))
|
|
304
|
+
reference(path);
|
|
305
|
+
for (const root of binderRoots(program.predicates))
|
|
306
|
+
closure(root);
|
|
307
|
+
},
|
|
308
|
+
evaluate(predicate, inputs = {}) {
|
|
309
|
+
const expression = program.predicates[predicate];
|
|
310
|
+
if (expression === undefined)
|
|
311
|
+
throw new TypeError('Unknown Authority predicate ordinal.');
|
|
312
|
+
for (const input of ['object', 'source', 'target']) {
|
|
313
|
+
const id = inputs[input];
|
|
314
|
+
if (id !== undefined && snapshot.node(id) === undefined) {
|
|
315
|
+
throw new AuthorityFailure('AUTHORITY_TARGET_NOT_FOUND', `Authority ${input} does not exist in the evaluated graph.`, { [input]: id });
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return holds(expression, { inputs, subject: undefined, locals: new Map() });
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
/** Locals whose assignment can affect the result of this expression. */
|
|
323
|
+
function localDependencies(expression) {
|
|
324
|
+
const result = new Set();
|
|
325
|
+
const addTerm = (term) => {
|
|
326
|
+
if (term.kind === 'local')
|
|
327
|
+
result.add(term.id);
|
|
328
|
+
};
|
|
329
|
+
const visit = (value) => {
|
|
330
|
+
switch (value.op) {
|
|
331
|
+
case 'all':
|
|
332
|
+
case 'any':
|
|
333
|
+
value.predicates.forEach(visit);
|
|
334
|
+
return;
|
|
335
|
+
case 'not':
|
|
336
|
+
visit(value.predicate);
|
|
337
|
+
return;
|
|
338
|
+
case 'as':
|
|
339
|
+
case 'exists':
|
|
340
|
+
visit(value.where);
|
|
341
|
+
return;
|
|
342
|
+
case 'same-node':
|
|
343
|
+
addTerm(value.left);
|
|
344
|
+
addTerm(value.right);
|
|
345
|
+
return;
|
|
346
|
+
case 'related':
|
|
347
|
+
addTerm(value.source);
|
|
348
|
+
addTerm(value.target);
|
|
349
|
+
return;
|
|
350
|
+
case 'instance-of':
|
|
351
|
+
addTerm(value.node);
|
|
352
|
+
return;
|
|
353
|
+
case 'class-authority':
|
|
354
|
+
addTerm(value.identity);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
visit(expression);
|
|
358
|
+
return result;
|
|
359
|
+
}
|
|
360
|
+
/** Every Identity a binder of the program names, sorted. */
|
|
361
|
+
export function binderRoots(expressions) {
|
|
362
|
+
const roots = new Set();
|
|
363
|
+
const visit = (expression) => {
|
|
364
|
+
switch (expression.op) {
|
|
365
|
+
case 'all':
|
|
366
|
+
case 'any':
|
|
367
|
+
expression.predicates.forEach(visit);
|
|
368
|
+
return;
|
|
369
|
+
case 'not':
|
|
370
|
+
visit(expression.predicate);
|
|
371
|
+
return;
|
|
372
|
+
case 'exists':
|
|
373
|
+
visit(expression.where);
|
|
374
|
+
return;
|
|
375
|
+
case 'as':
|
|
376
|
+
roots.add(expression.identity);
|
|
377
|
+
visit(expression.where);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
expressions.forEach(visit);
|
|
381
|
+
return Object.freeze([...roots].sort((left, right) => (left < right ? -1 : left > right ? 1 : 0)));
|
|
382
|
+
}
|
|
383
|
+
function sameClass(left, right) {
|
|
384
|
+
return left.origin === right.origin && left.kind === right.kind && left.name === right.name;
|
|
385
|
+
}
|
|
386
|
+
function classKey(ref) {
|
|
387
|
+
return `${ref.origin}:${ref.kind}.${ref.name}`;
|
|
388
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { NodeId } from '../../../graph/node/index.js';
|
|
2
|
+
import type { AuthorityExpr, AuthorityProgram } from '../language/index.js';
|
|
3
|
+
import type { CompositionClosure } from './composition.js';
|
|
4
|
+
import type { AuthorityAtom } from './interpret.js';
|
|
5
|
+
/**
|
|
6
|
+
* An atom outside every existential scope that reads no input: one snapshot gives it one value,
|
|
7
|
+
* one per subject when it names the subject of its binder (`subject`).
|
|
8
|
+
*/
|
|
9
|
+
export interface StaticAtom {
|
|
10
|
+
readonly atom: AuthorityAtom;
|
|
11
|
+
readonly subject: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The static atoms of the expressions, each once by structure, in depth-first order: the atoms
|
|
15
|
+
* `residualProgram` asks to decide. An `exists` that reads no input is one atom.
|
|
16
|
+
*/
|
|
17
|
+
export declare function staticAtoms(expressions: readonly AuthorityExpr[]): readonly StaticAtom[];
|
|
18
|
+
/**
|
|
19
|
+
* The program specialized to one snapshot: each static atom replaced by the value `atom` gives it,
|
|
20
|
+
* and each expression those values decide folded into it, in Kleene's strong three-valued logic.
|
|
21
|
+
* `atom` receives the subject only for an atom that names it, and undefined leaves the atom in
|
|
22
|
+
* place. A binder whose composition decides it from its members' specialized leaves
|
|
23
|
+
* (`CompositionClosure.decide`) is folded too. Otherwise it keeps the leaf every member
|
|
24
|
+
* specializes to alike, or the leaf specialized without a subject. `closure` is the admitted
|
|
25
|
+
* composition of a binder root.
|
|
26
|
+
*
|
|
27
|
+
* Once the program is admitted in that snapshot (AUTH-FAILURE-ADMITTED-EAGERLY), the residual
|
|
28
|
+
* decides every input frame as the program does (`pe_sound` of `proofs/Authority.lean`). Each
|
|
29
|
+
* member keeps its ordinal, so the residual is not canonical, and an expression nothing decides
|
|
30
|
+
* stays the same object.
|
|
31
|
+
*/
|
|
32
|
+
export declare function residualProgram(program: AuthorityProgram, closure: (root: NodeId) => CompositionClosure | undefined, atom: (atom: AuthorityAtom, subject: NodeId | undefined) => boolean | undefined): AuthorityProgram;
|