@astrale-os/kernel-dsl 1.0.0-beta.3 → 1.0.0-beta.30
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/v1/addressing/class-key.js +3 -3
- package/dist/v1/addressing/definition-ref.js +21 -37
- package/dist/v1/addressing/domain-dependency.d.ts +0 -6
- package/dist/v1/addressing/domain-dependency.js +1 -6
- package/dist/v1/addressing/key.d.ts +4 -1
- package/dist/v1/addressing/key.js +23 -3
- package/dist/v1/addressing/ordering.d.ts +2 -0
- package/dist/v1/addressing/ordering.js +2 -0
- package/dist/v1/addressing/patterns.d.ts +1 -1
- package/dist/v1/addressing/patterns.js +2 -6
- package/dist/v1/builder/callable/authoring.d.ts +11 -5
- package/dist/v1/builder/callable/authoring.js +2 -0
- package/dist/v1/builder/class/authoring.d.ts +94 -224
- package/dist/v1/builder/class/authoring.js +30 -35
- package/dist/v1/builder/class/handle.d.ts +27 -0
- package/dist/v1/builder/class/handle.js +1 -0
- package/dist/v1/builder/class/input.d.ts +159 -0
- package/dist/v1/builder/class/projection.d.ts +129 -0
- package/dist/v1/builder/class/projection.js +1 -0
- package/dist/v1/builder/class/property.d.ts +3 -9
- package/dist/v1/builder/class/property.js +1 -0
- package/dist/v1/builder/core/authoring.d.ts +1 -1
- package/dist/v1/builder/index.d.ts +10 -2
- package/dist/v1/builder/index.js +2 -0
- package/dist/v1/builder/lowering/callable.js +1 -0
- package/dist/v1/builder/lowering/class.d.ts +9 -1
- package/dist/v1/builder/lowering/class.js +62 -17
- package/dist/v1/builder/lowering/policy.js +6 -24
- package/dist/v1/builder/lowering/property-keys.d.ts +27 -0
- package/dist/v1/builder/lowering/property-keys.js +108 -0
- package/dist/v1/builder/lowering/schema/compile.js +13 -6
- package/dist/v1/builder/lowering/schema/context.d.ts +9 -1
- package/dist/v1/builder/lowering/schema/context.js +36 -7
- package/dist/v1/builder/lowering/schema/lifetime.d.ts +11 -0
- package/dist/v1/builder/lowering/schema/lifetime.js +55 -0
- package/dist/v1/builder/lowering/value/compile.js +29 -22
- package/dist/v1/builder/lowering/value/file.d.ts +7 -0
- package/dist/v1/builder/lowering/value/file.js +14 -0
- package/dist/v1/builder/lowering/value/path.d.ts +1 -1
- package/dist/v1/builder/lowering/value/path.js +2 -4
- package/dist/v1/builder/lowering/value/zod.js +41 -7
- package/dist/v1/builder/policy/authoring.d.ts +80 -9
- package/dist/v1/builder/policy/authoring.js +99 -68
- package/dist/v1/builder/policy/legacy/edge.d.ts +28 -0
- package/dist/v1/builder/policy/legacy/edge.js +16 -0
- package/dist/v1/builder/schema/define.d.ts +0 -1
- package/dist/v1/builder/schema/diagnostic.d.ts +3 -2
- package/dist/v1/builder/schema/diagnostic.js +5 -10
- package/dist/v1/builder/schema/input.d.ts +4 -1
- package/dist/v1/builder/schema/projection/callable.d.ts +7 -5
- package/dist/v1/builder/schema/projection/class.d.ts +78 -16
- package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
- package/dist/v1/builder/schema/projection/domain.d.ts +13 -2
- package/dist/v1/builder/schema/projection/identity.d.ts +74 -9
- package/dist/v1/builder/schema/projection/model.d.ts +4 -2
- package/dist/v1/builder/schema/projection/property.d.ts +38 -4
- package/dist/v1/builder/schema/projection/resolved-class.d.ts +5 -4
- package/dist/v1/builder/schema/projection.d.ts +1 -1
- package/dist/v1/builder/schema/rule.d.ts +316 -0
- package/dist/v1/builder/schema/rule.js +192 -0
- package/dist/v1/builder/value/file.d.ts +34 -0
- package/dist/v1/builder/value/file.js +77 -0
- package/dist/v1/builder/value/full-match.d.ts +0 -1
- package/dist/v1/builder/value/full-match.js +0 -1
- package/dist/v1/builder/value/path-metadata.d.ts +1 -1
- package/dist/v1/builder/value/path.d.ts +1 -1
- package/dist/v1/bundle/codec.js +55 -74
- package/dist/v1/bundle/diagnostic.d.ts +3 -1
- package/dist/v1/bundle/diagnostic.js +9 -7
- package/dist/v1/bundle/index.d.ts +2 -0
- package/dist/v1/bundle/index.js +1 -0
- package/dist/v1/bundle/model.js +1 -1
- package/dist/v1/bundle/rule.d.ts +14 -0
- package/dist/v1/bundle/rule.js +41 -0
- package/dist/v1/bundle/structure.js +6 -8
- package/dist/v1/compiled/admission/accept.js +9 -15
- package/dist/v1/compiled/admission/closure.js +17 -34
- package/dist/v1/compiled/admission/diagnostic.d.ts +23 -1
- package/dist/v1/compiled/admission/diagnostic.js +40 -3
- package/dist/v1/compiled/admission/revision.d.ts +9 -1
- package/dist/v1/compiled/admission/revision.js +7 -3
- package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/class.js +48 -19
- package/dist/v1/compiled/admission/semantics/core.d.ts +1 -24
- package/dist/v1/compiled/admission/semantics/core.js +56 -24
- package/dist/v1/compiled/admission/semantics/edge.d.ts +2 -4
- package/dist/v1/compiled/admission/semantics/edge.js +6 -65
- package/dist/v1/compiled/admission/semantics/policy/admit.js +4 -19
- package/dist/v1/compiled/admission/semantics/policy/callable.js +2 -5
- package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +5 -20
- package/dist/v1/compiled/admission/semantics/policy/contracts.js +8 -21
- package/dist/v1/compiled/admission/semantics/policy/parity.js +44 -53
- package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/policy/pattern.js +7 -21
- package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +2 -24
- package/dist/v1/compiled/admission/semantics/policy/typing.js +19 -201
- package/dist/v1/compiled/admission/wire/callable.d.ts +5 -2
- package/dist/v1/compiled/admission/wire/callable.js +24 -20
- package/dist/v1/compiled/admission/wire/class.js +79 -30
- package/dist/v1/compiled/admission/wire/entry.d.ts +1 -1
- package/dist/v1/compiled/admission/wire/entry.js +36 -13
- package/dist/v1/compiled/admission/wire/policy.d.ts +4 -3
- package/dist/v1/compiled/admission/wire/policy.js +27 -20
- package/dist/v1/compiled/admission/wire/program.d.ts +13 -3
- package/dist/v1/compiled/admission/wire/program.js +39 -44
- package/dist/v1/compiled/admission/wire/property.d.ts +4 -1
- package/dist/v1/compiled/admission/wire/property.js +8 -5
- package/dist/v1/compiled/admission/wire/value.d.ts +0 -2
- package/dist/v1/compiled/admission/wire/value.js +0 -7
- package/dist/v1/compiled/codec/json.js +4 -3
- package/dist/v1/compiled/compiler/compile.js +15 -33
- package/dist/v1/compiled/diagnostic.d.ts +1 -1
- package/dist/v1/compiled/diagnostic.js +2 -3
- package/dist/v1/compiled/index.d.ts +2 -0
- package/dist/v1/compiled/index.js +1 -0
- package/dist/v1/compiled/loader/load.d.ts +3 -2
- package/dist/v1/compiled/loader/load.js +12 -51
- package/dist/v1/compiled/model/schema.d.ts +3 -0
- package/dist/v1/compiled/rule.d.ts +49 -0
- package/dist/v1/compiled/rule.js +169 -0
- package/dist/v1/domain/create.js +9 -10
- package/dist/v1/domain/model/domain.d.ts +2 -7
- package/dist/v1/domain/model/input.d.ts +15 -10
- package/dist/v1/domain/namespace/member-collection.js +8 -7
- package/dist/v1/domain/projection/classes.js +11 -8
- package/dist/v1/domain/validation/create.d.ts +7 -16
- package/dist/v1/domain/validation/create.js +35 -81
- package/dist/v1/index.d.ts +5 -3
- package/dist/v1/index.js +1 -1
- package/dist/v1/language/.spec/schemas/draft-2020-12.schema.json +462 -0
- package/dist/v1/language/.spec/schemas/value-schema.schema.json +23 -0
- package/dist/v1/language/callable/admission.d.ts +15 -0
- package/dist/v1/language/callable/admission.js +44 -0
- package/dist/v1/language/callable/model/callable.d.ts +10 -0
- package/dist/v1/language/callable/resolved.d.ts +16 -3
- package/dist/v1/language/chain.d.ts +7 -0
- package/dist/v1/language/chain.js +24 -0
- package/dist/v1/language/class/inheritance.d.ts +36 -5
- package/dist/v1/language/class/inheritance.js +85 -1
- package/dist/v1/language/class/lifetime.d.ts +50 -11
- package/dist/v1/language/class/lifetime.js +89 -20
- package/dist/v1/language/class/model/class.d.ts +45 -9
- package/dist/v1/language/class/model/edge.d.ts +31 -2
- package/dist/v1/language/class/model/property.d.ts +16 -7
- package/dist/v1/language/class/property-values.js +2 -4
- package/dist/v1/language/class/resolved.d.ts +9 -4
- package/dist/v1/language/class/unique.d.ts +143 -0
- package/dist/v1/language/class/unique.js +264 -0
- package/dist/v1/language/core/facts.d.ts +85 -0
- package/dist/v1/language/core/facts.js +116 -0
- package/dist/v1/language/cycle.d.ts +10 -0
- package/dist/v1/language/cycle.js +30 -0
- package/dist/v1/language/definition/metadata.d.ts +38 -0
- package/dist/v1/language/definition/metadata.js +51 -0
- package/dist/v1/language/freeze.d.ts +5 -0
- package/dist/v1/{schema/canonical → language}/freeze.js +4 -0
- package/dist/v1/language/index.d.ts +7 -2
- package/dist/v1/language/index.js +5 -1
- package/dist/v1/language/limits.d.ts +83 -0
- package/dist/v1/language/limits.js +77 -0
- package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
- package/dist/v1/language/policy/analysis/branches.js +8 -8
- package/dist/v1/language/policy/analysis/budgets.d.ts +45 -12
- package/dist/v1/language/policy/analysis/budgets.js +140 -20
- package/dist/v1/language/policy/analysis/checks.js +8 -6
- package/dist/v1/language/policy/analysis/composition.d.ts +4 -0
- package/dist/v1/language/policy/analysis/composition.js +11 -0
- package/dist/v1/language/policy/analysis/typing.d.ts +51 -0
- package/dist/v1/language/policy/analysis/typing.js +456 -0
- package/dist/v1/language/policy/model/policy.d.ts +71 -9
- package/dist/v1/language/policy/model/policy.js +42 -4
- package/dist/v1/language/policy/normalization/normalize.d.ts +6 -6
- package/dist/v1/language/policy/normalization/normalize.js +46 -68
- package/dist/v1/language/suspended.d.ts +7 -0
- package/dist/v1/language/suspended.js +23 -0
- package/dist/v1/language/validation/diagnostic.d.ts +15 -1
- package/dist/v1/language/validation/diagnostic.js +21 -0
- package/dist/v1/language/validation/rule.d.ts +45 -0
- package/dist/v1/language/validation/rule.js +109 -0
- package/dist/v1/language/value/compile/fields.js +16 -16
- package/dist/v1/language/value/compile/load.d.ts +5 -0
- package/dist/v1/language/value/compile/load.js +13 -0
- package/dist/v1/language/value/evaluate/assertions.d.ts +5 -1
- package/dist/v1/language/value/evaluate/assertions.js +19 -8
- package/dist/v1/language/value/evaluate/evaluator.js +117 -120
- package/dist/v1/language/value/evaluate/preparation.d.ts +16 -0
- package/dist/v1/language/value/evaluate/preparation.js +100 -47
- package/dist/v1/language/value/evaluate/program.d.ts +2 -1
- package/dist/v1/language/value/evaluate/program.js +6 -6
- package/dist/v1/language/value/evaluate/validate.d.ts +3 -3
- package/dist/v1/language/value/evaluate/validate.js +14 -10
- package/dist/v1/language/value/evaluate/validity.optimization.d.ts +14 -0
- package/dist/v1/language/value/evaluate/validity.optimization.js +338 -0
- package/dist/v1/language/value/files.d.ts +44 -0
- package/dist/v1/language/value/files.js +151 -0
- package/dist/v1/language/value/inclusion/arrays.d.ts +3 -0
- package/dist/v1/language/value/inclusion/arrays.js +85 -0
- package/dist/v1/language/value/inclusion/assertions.d.ts +18 -0
- package/dist/v1/language/value/inclusion/assertions.js +28 -0
- package/dist/v1/language/value/inclusion/combinators.d.ts +3 -0
- package/dist/v1/language/value/inclusion/combinators.js +67 -0
- package/dist/v1/language/value/inclusion/equivalence.d.ts +4 -0
- package/dist/v1/language/value/inclusion/equivalence.js +76 -0
- package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
- package/dist/v1/language/value/inclusion/evidence.js +140 -0
- package/dist/v1/language/value/inclusion/includes.d.ts +29 -3
- package/dist/v1/language/value/inclusion/includes.js +58 -723
- package/dist/v1/language/value/inclusion/keywords.d.ts +5 -0
- package/dist/v1/language/value/inclusion/keywords.js +31 -0
- package/dist/v1/language/value/inclusion/kinds.d.ts +17 -0
- package/dist/v1/language/value/inclusion/kinds.js +57 -0
- package/dist/v1/language/value/inclusion/location.d.ts +24 -0
- package/dist/v1/language/value/inclusion/location.js +66 -0
- package/dist/v1/language/value/inclusion/numbers.d.ts +3 -0
- package/dist/v1/language/value/inclusion/numbers.js +41 -0
- package/dist/v1/language/value/inclusion/objects.d.ts +3 -0
- package/dist/v1/language/value/inclusion/objects.js +190 -0
- package/dist/v1/language/value/inclusion/strings.d.ts +3 -0
- package/dist/v1/language/value/inclusion/strings.js +29 -0
- package/dist/v1/language/value/inclusion/types.d.ts +3 -0
- package/dist/v1/language/value/inclusion/types.js +34 -0
- package/dist/v1/language/value/model/blob.d.ts +6 -0
- package/dist/v1/language/value/model/blob.js +8 -0
- package/dist/v1/language/value/model/file.d.ts +41 -0
- package/dist/v1/language/value/model/file.js +122 -0
- package/dist/v1/language/value/ordering.d.ts +14 -0
- package/dist/v1/language/value/ordering.js +144 -77
- package/dist/v1/language/value/profile/canonicalize.d.ts +6 -1
- package/dist/v1/language/value/profile/canonicalize.js +67 -87
- package/dist/v1/language/value/profile/json.validate.d.ts +12 -0
- package/dist/v1/language/value/profile/json.validate.js +18 -5
- package/dist/v1/language/value/profile/meta-schema.compiled.d.ts +1 -0
- package/dist/v1/language/value/profile/meta-schema.compiled.js +21 -5
- package/dist/v1/language/value/profile/rules.js +27 -44
- package/dist/v1/language/value/profile/validate.js +1 -10
- package/dist/v1/language/value/profile/vocabulary.d.ts +36 -2
- package/dist/v1/language/value/profile/vocabulary.js +58 -5
- package/dist/v1/language/value/reference/closure.js +6 -6
- package/dist/v1/language/value/reference/recursion.js +9 -48
- package/dist/v1/language/value/reference/references.d.ts +3 -1
- package/dist/v1/language/value/reference/references.js +7 -7
- package/dist/v1/language/value/reference/registry.index.d.ts +2 -0
- package/dist/v1/language/value/reference/registry.index.js +33 -16
- package/dist/v1/language/value/regexp/ast.js +6 -7
- package/dist/v1/language/value/regexp/compile.d.ts +5 -11
- package/dist/v1/language/value/regexp/compile.js +14 -12
- package/dist/v1/language/value/regexp/syntax.js +3 -2
- package/dist/v1/language/value/regexp/unicode.d.ts +1 -1
- package/dist/v1/language/value/regexp/unicode.js +1 -1
- package/dist/v1/language/value/syntax/keywords.d.ts +3 -3
- package/dist/v1/language/value/syntax/keywords.js +4 -20
- package/dist/v1/language/value/syntax/node-path/validate.js +2 -3
- package/dist/v1/language/value/syntax/pointer.d.ts +2 -0
- package/dist/v1/language/value/syntax/pointer.js +5 -2
- package/dist/v1/language/value/syntax/walk.d.ts +9 -0
- package/dist/v1/language/value/syntax/walk.js +37 -20
- package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +2596 -0
- package/dist/v1/schema/admission/accept.d.ts +3 -1
- package/dist/v1/schema/admission/accept.js +6 -14
- package/dist/v1/schema/admission/callable.d.ts +21 -0
- package/dist/v1/schema/admission/callable.js +96 -0
- package/dist/v1/schema/analysis/class.d.ts +4 -0
- package/dist/v1/schema/analysis/class.js +57 -17
- package/dist/v1/schema/canonical/revision.d.ts +4 -1
- package/dist/v1/schema/canonical/revision.js +8 -5
- package/dist/v1/schema/compatibility/api.d.ts +4 -1
- package/dist/v1/schema/compatibility/api.js +2 -0
- package/dist/v1/schema/compatibility/comparators/callables.js +1 -1
- package/dist/v1/schema/compatibility/comparators/classes.d.ts +9 -4
- package/dist/v1/schema/compatibility/comparators/classes.js +50 -29
- package/dist/v1/schema/compatibility/comparators/index.d.ts +1 -1
- package/dist/v1/schema/compatibility/comparators/members.js +1 -1
- package/dist/v1/schema/compatibility/comparators/values.js +2 -2
- package/dist/v1/schema/compatibility/context.d.ts +5 -2
- package/dist/v1/schema/compatibility/context.js +8 -6
- package/dist/v1/schema/compatibility/coordinate.js +3 -3
- package/dist/v1/schema/compatibility/diff.js +2 -4
- package/dist/v1/schema/compatibility/extension.d.ts +11 -0
- package/dist/v1/schema/compatibility/extension.js +22 -0
- package/dist/v1/schema/compatibility/fields.d.ts +20 -4
- package/dist/v1/schema/compatibility/fields.js +13 -3
- package/dist/v1/schema/compatibility/meaning/footprint.js +16 -51
- package/dist/v1/schema/compatibility/model.d.ts +17 -5
- package/dist/v1/schema/compatibility/references.d.ts +0 -3
- package/dist/v1/schema/compatibility/references.js +1 -9
- package/dist/v1/schema/compatibility/report.js +1 -1
- package/dist/v1/schema/compatibility/rule.d.ts +13 -0
- package/dist/v1/schema/compatibility/rule.js +23 -0
- package/dist/v1/schema/compatibility/scope.d.ts +2 -0
- package/dist/v1/schema/compatibility/scope.js +4 -1
- package/dist/v1/schema/compatibility/structure/index.js +6 -4
- package/dist/v1/schema/compatibility/structure/requirements.js +58 -61
- package/dist/v1/schema/compatibility/versioning/index.js +1 -1
- package/dist/v1/schema/compatibility/versioning/surface.d.ts +1 -1
- package/dist/v1/schema/compatibility/versioning/surface.js +30 -2
- package/dist/v1/schema/compatibility/walk.d.ts +17 -0
- package/dist/v1/schema/compatibility/walk.js +41 -0
- package/dist/v1/schema/diagnostic.d.ts +17 -3
- package/dist/v1/schema/diagnostic.js +14 -11
- package/dist/v1/schema/enforcement/changes.d.ts +590 -0
- package/dist/v1/schema/enforcement/changes.js +566 -0
- package/dist/v1/schema/enforcement/derived.d.ts +236 -0
- package/dist/v1/schema/enforcement/derived.js +243 -0
- package/dist/v1/schema/enforcement/dispose.d.ts +308 -0
- package/dist/v1/schema/enforcement/dispose.js +275 -0
- package/dist/v1/schema/enforcement/facts.d.ts +89 -0
- package/dist/v1/schema/enforcement/facts.js +70 -0
- package/dist/v1/schema/enforcement/fields.d.ts +65 -0
- package/dist/v1/schema/enforcement/fields.js +36 -0
- package/dist/v1/schema/enforcement/index.d.ts +39 -0
- package/dist/v1/schema/enforcement/index.js +10 -0
- package/dist/v1/schema/enforcement/install.d.ts +1634 -0
- package/dist/v1/schema/enforcement/install.js +1223 -0
- package/dist/v1/schema/enforcement/lifecycle.d.ts +87 -0
- package/dist/v1/schema/enforcement/lifecycle.js +91 -0
- package/dist/v1/schema/enforcement/model.d.ts +253 -0
- package/dist/v1/schema/enforcement/model.js +1 -0
- package/dist/v1/schema/enforcement/obligations.d.ts +248 -0
- package/dist/v1/schema/enforcement/obligations.js +240 -0
- package/dist/v1/schema/enforcement/write.d.ts +1314 -0
- package/dist/v1/schema/enforcement/write.js +1017 -0
- package/dist/v1/schema/index.d.ts +11 -1
- package/dist/v1/schema/index.js +5 -0
- package/dist/v1/schema/model/schema.d.ts +23 -1
- package/dist/v1/schema/model/schema.js +1 -1
- package/dist/v1/schema/normalization/domain.d.ts +2 -0
- package/dist/v1/schema/normalization/domain.js +50 -13
- package/dist/v1/schema/resolution/closure.js +2 -1
- package/dist/v1/schema/resolution/context.js +17 -18
- package/dist/v1/schema/resolution/domain.d.ts +5 -0
- package/dist/v1/schema/resolution/domain.js +5 -13
- package/dist/v1/schema/resolution/origins.js +6 -8
- package/dist/v1/schema/rule.d.ts +25 -0
- package/dist/v1/schema/rule.js +459 -0
- package/dist/v1/schema/validation/callable.d.ts +35 -2
- package/dist/v1/schema/validation/callable.js +65 -9
- package/dist/v1/schema/validation/class.d.ts +6 -2
- package/dist/v1/schema/validation/class.js +128 -105
- package/dist/v1/schema/validation/core.js +103 -173
- package/dist/v1/schema/validation/domain.js +25 -15
- package/dist/v1/schema/validation/domain.json-schema.d.ts +15 -0
- package/dist/v1/schema/validation/domain.json-schema.js +222 -0
- package/dist/v1/schema/validation/domain.route.d.ts +6 -1
- package/dist/v1/schema/validation/domain.route.js +18 -0
- package/dist/v1/schema/validation/domain.structure.d.ts +7797 -0
- package/dist/v1/schema/validation/domain.structure.js +516 -160
- package/dist/v1/schema/validation/icon.d.ts +4 -0
- package/dist/v1/schema/validation/icon.js +29 -0
- package/dist/v1/schema/validation/json.json-schema.d.ts +40 -0
- package/dist/v1/schema/validation/json.json-schema.js +46 -0
- package/dist/v1/schema/validation/policy/budgets.d.ts +37 -2
- package/dist/v1/schema/validation/policy/budgets.js +94 -121
- package/dist/v1/schema/validation/policy/context.d.ts +6 -5
- package/dist/v1/schema/validation/policy/context.js +7 -10
- package/dist/v1/schema/validation/policy/objects.d.ts +1 -1
- package/dist/v1/schema/validation/policy/objects.js +6 -14
- package/dist/v1/schema/validation/policy/references.js +20 -62
- package/dist/v1/schema/validation/policy/typing.d.ts +3 -18
- package/dist/v1/schema/validation/policy/typing.js +22 -356
- package/dist/v1/schema/validation/policy/uses.d.ts +40 -3
- package/dist/v1/schema/validation/policy/uses.js +63 -91
- package/dist/v1/schema/validation/policy/validate.js +5 -5
- package/dist/v1/schema/validation/value-api.d.ts +27 -1
- package/dist/v1/schema/validation/value-api.js +37 -2
- package/dist/v1/schema/validation/value.d.ts +3 -0
- package/dist/v1/schema/validation/value.js +9 -17
- package/dist/v1/schema/validation/value.json-schema.d.ts +54 -0
- package/dist/v1/schema/validation/value.json-schema.js +163 -0
- package/dist/v1/schema/validation/view.js +4 -8
- package/dist/value/accept.d.ts +9 -3
- package/dist/value/accept.js +25 -1
- package/dist/value/canonical.d.ts +22 -1
- package/dist/value/canonical.js +114 -21
- package/dist/value/decode.d.ts +7 -0
- package/dist/value/decode.js +159 -9
- package/dist/value/equal.d.ts +9 -1
- package/dist/value/equal.js +37 -3
- package/dist/value/immutable.optimization.d.ts +2 -0
- package/dist/value/immutable.optimization.js +4 -0
- package/dist/value/index.d.ts +5 -3
- package/dist/value/index.js +2 -1
- package/dist/value/json.d.ts +2 -2
- package/dist/value/json.js +2 -2
- package/dist/value/limits.d.ts +11 -0
- package/dist/value/rule.d.ts +12 -0
- package/dist/value/rule.js +50 -0
- package/dist/value/types.d.ts +6 -0
- package/dist/value/unicode.d.ts +2 -1
- package/dist/value/unicode.js +2 -0
- package/package.json +15 -4
- package/dist/v1/builder/lowering/core-properties.d.ts +0 -10
- package/dist/v1/builder/lowering/core-properties.js +0 -76
- package/dist/v1/compiled/admission/semantics/cardinality.d.ts +0 -5
- package/dist/v1/compiled/admission/semantics/cardinality.js +0 -113
- package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +0 -8
- package/dist/v1/compiled/admission/semantics/policy/equality.js +0 -27
- package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +0 -9
- package/dist/v1/compiled/admission/semantics/policy/measure.js +0 -81
- package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +0 -10
- package/dist/v1/compiled/admission/semantics/policy/variants.js +0 -65
- package/dist/v1/compiled/admission/wire/pattern.d.ts +0 -12
- package/dist/v1/compiled/admission/wire/pattern.js +0 -111
- package/dist/v1/language/class/index.d.ts +0 -8
- package/dist/v1/language/class/index.js +0 -1
- package/dist/v1/language/core/index.d.ts +0 -2
- package/dist/v1/language/value/index.d.ts +0 -11
- package/dist/v1/language/value/index.js +0 -8
- package/dist/v1/schema/canonical/domain.d.ts +0 -3
- package/dist/v1/schema/canonical/domain.digest.d.ts +0 -3
- package/dist/v1/schema/canonical/domain.digest.js +0 -5
- package/dist/v1/schema/canonical/domain.js +0 -5
- package/dist/v1/schema/canonical/freeze.d.ts +0 -1
- /package/dist/v1/{language/core/index.js → builder/class/input.js} +0 -0
|
@@ -1,71 +1,25 @@
|
|
|
1
1
|
import { Key } from '../../../addressing/index.js';
|
|
2
2
|
import { compareUnicode } from '../../../addressing/ordering.js';
|
|
3
|
-
import {
|
|
3
|
+
import { edgeContractRefines } from '../../../language/class/inheritance.js';
|
|
4
4
|
import {} from '../../../language/class/model/edge.js';
|
|
5
5
|
import { fail } from '../diagnostic.js';
|
|
6
|
-
import { isCompiledEdge, classSatisfiesAny
|
|
7
|
-
/** Check Edge
|
|
6
|
+
import { isCompiledEdge, classSatisfiesAny } from './context.js';
|
|
7
|
+
/** Check safe Edge inheritance refinement; the wire and closure checks own the endpoints. */
|
|
8
8
|
export function validateEdges(context) {
|
|
9
9
|
for (const located of context.classes.values()) {
|
|
10
10
|
if (!isCompiledEdge(located.value))
|
|
11
11
|
continue;
|
|
12
12
|
const edge = located.value;
|
|
13
|
-
const endpoints = edge.orientation === 'directed'
|
|
14
|
-
? [edge.endpoints.source, edge.endpoints.target]
|
|
15
|
-
: edge.endpoints;
|
|
16
|
-
if (endpoints[0].role === endpoints[1].role)
|
|
17
|
-
fail(`${located.pointer}/endpoints`, 'Edge endpoint roles must differ.');
|
|
18
|
-
for (const [endpointIndex, endpoint] of endpoints.entries()) {
|
|
19
|
-
const seen = new Set();
|
|
20
|
-
for (const [acceptIndex, ref] of endpoint.accepts.entries()) {
|
|
21
|
-
const key = Key.of(ref);
|
|
22
|
-
if (seen.has(key))
|
|
23
|
-
fail(`${located.pointer}/endpoints/${endpointIndex}/accepts/${acceptIndex}`, 'Edge endpoint repeats an accepted Class.');
|
|
24
|
-
seen.add(key);
|
|
25
|
-
if (context.classes.get(key)?.value.kind !== 'node')
|
|
26
|
-
fail(`${located.pointer}/endpoints/${endpointIndex}/accepts/${acceptIndex}`, 'Edge endpoint must accept a Node Class.');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
13
|
for (const [parentIndex, parentRef] of edge.extends.entries()) {
|
|
30
14
|
const parent = context.classes.get(Key.of(parentRef))?.value;
|
|
31
|
-
if (parent !== undefined &&
|
|
15
|
+
if (parent !== undefined &&
|
|
16
|
+
isCompiledEdge(parent) &&
|
|
17
|
+
!edgeContractRefines(edge, parent, (candidate, accepts) => classSatisfiesAny(context, candidate, accepts))) {
|
|
32
18
|
fail(`${located.pointer}/extends/${parentIndex}`, 'Edge Class does not safely refine its parent.');
|
|
33
19
|
}
|
|
34
20
|
}
|
|
35
21
|
}
|
|
36
22
|
}
|
|
37
|
-
function edgeRefines(context, child, parent) {
|
|
38
|
-
if (isGraphRoot(parent))
|
|
39
|
-
return true;
|
|
40
|
-
if (child.orientation !== parent.orientation)
|
|
41
|
-
return false;
|
|
42
|
-
if (parent.constraints.noSelf === true && child.constraints.noSelf !== true)
|
|
43
|
-
return false;
|
|
44
|
-
if (parent.constraints.acyclic === true && child.constraints.acyclic !== true)
|
|
45
|
-
return false;
|
|
46
|
-
if (child.orientation === 'directed' && parent.orientation === 'directed') {
|
|
47
|
-
return (endpointRefines(context, child.endpoints.source, parent.endpoints.source) &&
|
|
48
|
-
countRefines(child.endpoints.source.outgoing, parent.endpoints.source.outgoing) &&
|
|
49
|
-
endpointRefines(context, child.endpoints.target, parent.endpoints.target) &&
|
|
50
|
-
countRefines(child.endpoints.target.incoming, parent.endpoints.target.incoming));
|
|
51
|
-
}
|
|
52
|
-
if (child.orientation !== 'undirected' || parent.orientation !== 'undirected')
|
|
53
|
-
return false;
|
|
54
|
-
const refine = (a, b) => endpointRefines(context, child.endpoints[a], parent.endpoints[b]) &&
|
|
55
|
-
countRefines(child.endpoints[a].incident, parent.endpoints[b].incident);
|
|
56
|
-
const direct = refine(0, 0) && refine(1, 1);
|
|
57
|
-
if (direct)
|
|
58
|
-
return true;
|
|
59
|
-
return refine(0, 1) && refine(1, 0);
|
|
60
|
-
}
|
|
61
|
-
function endpointRefines(context, child, parent) {
|
|
62
|
-
return child.accepts.every((accepted) => classSatisfiesAny(context, accepted, parent.accepts));
|
|
63
|
-
}
|
|
64
|
-
function countRefines(child, parent) {
|
|
65
|
-
const [childMin, childMax] = countBounds(child);
|
|
66
|
-
const [parentMin, parentMax] = countBounds(parent);
|
|
67
|
-
return childMin >= parentMin && childMax <= parentMax;
|
|
68
|
-
}
|
|
69
23
|
/** Compare undirected endpoint acceptance and cardinality contracts. */
|
|
70
24
|
export function sameIncidentEndpoint(left, right) {
|
|
71
25
|
const a = left.accepts.map(Key.of).sort(compareUnicode);
|
|
@@ -74,16 +28,3 @@ export function sameIncidentEndpoint(left, right) {
|
|
|
74
28
|
a.length === b.length &&
|
|
75
29
|
a.every((value, index) => value === b[index]));
|
|
76
30
|
}
|
|
77
|
-
/** Interpret an Edge count as inclusive degree bounds. */
|
|
78
|
-
export function countBounds(value) {
|
|
79
|
-
switch (value) {
|
|
80
|
-
case '0..*':
|
|
81
|
-
return [0, Number.POSITIVE_INFINITY];
|
|
82
|
-
case '1..*':
|
|
83
|
-
return [1, Number.POSITIVE_INFINITY];
|
|
84
|
-
case '0..1':
|
|
85
|
-
return [0, 1];
|
|
86
|
-
case '1':
|
|
87
|
-
return [1, 1];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Key } from '../../../../addressing/index.js';
|
|
2
|
+
import { compositionCycles } from '../../../../language/policy/analysis/composition.js';
|
|
2
3
|
import { isClassRuleChecks } from '../../../../language/policy/model/policy.js';
|
|
3
4
|
import {} from '../../../model/schema.js';
|
|
4
5
|
import { fail } from '../../diagnostic.js';
|
|
@@ -41,23 +42,7 @@ export function validatePolicies(candidate, context, admitted) {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
function validatePolicyCycles(entry, local, entryIndex) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (visiting.has(name))
|
|
48
|
-
fail(`/closure/${entryIndex}/definitions/policies`, `Named Policy composition cycle reaches ${name}.`);
|
|
49
|
-
if (visited.has(name))
|
|
50
|
-
return;
|
|
51
|
-
visiting.add(name);
|
|
52
|
-
const expression = local.get(name)?.expression;
|
|
53
|
-
if (expression !== undefined && !('match' in expression)) {
|
|
54
|
-
for (const ref of 'allOf' in expression ? expression.allOf : expression.anyOf)
|
|
55
|
-
if (ref.origin === entry.origin && ref.kind === 'policy')
|
|
56
|
-
visit(ref.name);
|
|
57
|
-
}
|
|
58
|
-
visiting.delete(name);
|
|
59
|
-
visited.add(name);
|
|
60
|
-
};
|
|
61
|
-
for (const name of local.keys())
|
|
62
|
-
visit(name);
|
|
45
|
+
const [cycle] = compositionCycles(local.keys(), (name) => local.get(name)?.expression, entry.origin);
|
|
46
|
+
if (cycle !== undefined)
|
|
47
|
+
fail(`/closure/${entryIndex}/definitions/policies`, `Named Policy composition cycle reaches ${cycle.target}.`);
|
|
63
48
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Key } from '../../../../addressing/index.js';
|
|
2
|
-
import {} from '../../../../language/policy/model/policy.js';
|
|
2
|
+
import { PolicyComposition, } from '../../../../language/policy/model/policy.js';
|
|
3
3
|
import { GRAPH_NODE_PATH_SCHEMA_ID } from '../../../../language/value/syntax/node-path/schema.js';
|
|
4
4
|
import {} from '../../../model/schema.js';
|
|
5
5
|
import { fail } from '../../diagnostic.js';
|
|
@@ -27,10 +27,7 @@ export function validateCallablePolicy(context, entry, expression, inputIndex, f
|
|
|
27
27
|
}
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
if (children.length === 0)
|
|
32
|
-
fail(path, 'Callable Policy composition must be non-empty.');
|
|
33
|
-
children.forEach((child, index) => validateCallablePolicy(context, entry, child, inputIndex, fields, instanceMethod, `${path}/${index}`));
|
|
30
|
+
PolicyComposition.of(expression).operands.forEach((child, index) => validateCallablePolicy(context, entry, child, inputIndex, fields, instanceMethod, `${path}/${index}`));
|
|
34
31
|
}
|
|
35
32
|
function isSingleNodePathField(context, entry, inputIndex, field) {
|
|
36
33
|
const rootValue = entry.values[inputIndex]?.nodes[entry.values[inputIndex].root]?.schema;
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ObjectContract } from '../../../../language/policy/analysis/typing.js';
|
|
2
2
|
import { type ClassRef } from '../../../../addressing/index.js';
|
|
3
|
+
import { type PolicyCheckObject, type PolicyObjectRef } from '../../../../language/policy/model/policy.js';
|
|
3
4
|
import { type CompiledSchemaEntry } from '../../../model/schema.js';
|
|
4
5
|
import { type SemanticIndex } from '../context.js';
|
|
5
|
-
/** The default protected object contract or one exact Class. */
|
|
6
|
-
export type CompiledObjectContract = {
|
|
7
|
-
readonly kind: 'default';
|
|
8
|
-
} | {
|
|
9
|
-
readonly kind: 'exact';
|
|
10
|
-
readonly ref: ClassRef;
|
|
11
|
-
};
|
|
12
|
-
/** The protected object or endpoint contracts of one Policy use. */
|
|
13
|
-
export type CompiledPolicyUse = {
|
|
14
|
-
readonly kind: 'object';
|
|
15
|
-
readonly object: CompiledObjectContract;
|
|
16
|
-
} | {
|
|
17
|
-
readonly kind: 'edge';
|
|
18
|
-
readonly source: CompiledObjectContract;
|
|
19
|
-
readonly target: CompiledObjectContract;
|
|
20
|
-
};
|
|
21
6
|
/** Resolve callable Policy objects to their protected Class contracts. */
|
|
22
|
-
export declare function callableObjectContracts(context: SemanticIndex, entry: CompiledSchemaEntry, input: number, receiver: ClassRef | undefined, object: PolicyCheckObject): readonly
|
|
23
|
-
/**
|
|
24
|
-
export declare function
|
|
7
|
+
export declare function callableObjectContracts(context: SemanticIndex, entry: CompiledSchemaEntry, input: number, receiver: ClassRef | undefined, object: PolicyCheckObject): readonly ObjectContract[] | undefined;
|
|
8
|
+
/** Resolve a referenced Policy object to its protected Class contract. */
|
|
9
|
+
export declare function referenceContract(context: SemanticIndex, ref: PolicyObjectRef): ObjectContract | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Key } from '../../../../addressing/index.js';
|
|
2
|
+
import { projectedMemberClass, } from '../../../../language/policy/model/policy.js';
|
|
2
3
|
import {} from '../../../model/schema.js';
|
|
3
4
|
import {} from '../context.js';
|
|
4
5
|
/** Resolve callable Policy objects to their protected Class contracts. */
|
|
@@ -9,24 +10,16 @@ export function callableObjectContracts(context, entry, input, receiver, object)
|
|
|
9
10
|
if (object.kind === 'input') {
|
|
10
11
|
return nodePathAccepts(entry, input, object.field).map((ref) => ({ kind: 'exact', ref }));
|
|
11
12
|
}
|
|
12
|
-
const
|
|
13
|
+
const contract = referenceContract(context, object.ref);
|
|
14
|
+
return contract === undefined ? undefined : [contract];
|
|
15
|
+
}
|
|
16
|
+
/** Resolve a referenced Policy object to its protected Class contract. */
|
|
17
|
+
export function referenceContract(context, ref) {
|
|
13
18
|
if (ref.kind === 'core') {
|
|
14
19
|
const node = context.core.get(Key.of(ref))?.value;
|
|
15
|
-
return node === undefined ? undefined :
|
|
20
|
+
return node === undefined ? undefined : { kind: 'exact', ref: node.class };
|
|
16
21
|
}
|
|
17
|
-
|
|
18
|
-
? 'Class'
|
|
19
|
-
: ref.kind === 'function' || ref.kind === 'method'
|
|
20
|
-
? 'Function'
|
|
21
|
-
: ref.kind === 'policy'
|
|
22
|
-
? 'Policy'
|
|
23
|
-
: 'View';
|
|
24
|
-
return [
|
|
25
|
-
{
|
|
26
|
-
kind: 'exact',
|
|
27
|
-
ref: { origin: 'kernel.astrale.ai', kind: 'class', name: projection },
|
|
28
|
-
},
|
|
29
|
-
];
|
|
22
|
+
return { kind: 'exact', ref: projectedMemberClass(ref) };
|
|
30
23
|
}
|
|
31
24
|
function nodePathAccepts(entry, input, field) {
|
|
32
25
|
const root = entry.values[input]?.nodes[entry.values[input].root]?.schema;
|
|
@@ -37,9 +30,3 @@ function nodePathAccepts(entry, input, field) {
|
|
|
37
30
|
? annotation.accepts
|
|
38
31
|
: [];
|
|
39
32
|
}
|
|
40
|
-
/** Select the protected contract for an object or Edge endpoint term. */
|
|
41
|
-
export function compiledTargetContract(term, use) {
|
|
42
|
-
if (use.kind === 'object')
|
|
43
|
-
return term === 'object' ? use.object : undefined;
|
|
44
|
-
return term === 'source' ? use.source : term === 'target' ? use.target : undefined;
|
|
45
|
-
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { Key } from '../../../../addressing/index.js';
|
|
2
|
-
import {} from '../../../../language/class/model/edge.js';
|
|
3
2
|
import { branchesOf, targetMode, isConnected, } from '../../../../language/policy/analysis/branches.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { exceededLimits, measureChecks, policyMeasurer, } from '../../../../language/policy/analysis/budgets.js';
|
|
4
|
+
import { neverAdmittedClasses, } from '../../../../language/policy/analysis/checks.js';
|
|
5
|
+
import {} from '../../../../language/policy/analysis/typing.js';
|
|
6
|
+
import { CLASS_OPERATIONS, checksNameTheCaller, isClassRuleChecks, PolicyComposition, } from '../../../../language/policy/model/policy.js';
|
|
7
7
|
import { normalizePolicyExpression } from '../../../../language/policy/normalization/normalize.js';
|
|
8
8
|
import {} from '../../../model/schema.js';
|
|
9
|
-
import { fail } from '../../diagnostic.js';
|
|
10
|
-
import { isCompiledEdge } from '../context.js';
|
|
9
|
+
import { fail, POLICY_CHECK_SITE } from '../../diagnostic.js';
|
|
10
|
+
import { isCompiledEdge, } from '../context.js';
|
|
11
11
|
import { callableObjectContracts } from './contracts.js';
|
|
12
|
-
import {
|
|
13
|
-
import { CompiledPolicyTyping } from './typing.js';
|
|
12
|
+
import { compiledPolicyTyping } from './typing.js';
|
|
14
13
|
/** Check Policy typing and expansion budgets against the entry’s own closure. */
|
|
15
14
|
export function validatePolicyParity(context, entry, entryIndex, policies, origins) {
|
|
16
15
|
const normalized = new Map([...policies].map(([name, policy]) => [name, normalizePolicyExpression(policy.expression)]));
|
|
17
|
-
const typing =
|
|
16
|
+
const typing = compiledPolicyTyping(context, entry, normalized, origins);
|
|
17
|
+
const measurePolicy = policyMeasurer(entry.origin, normalized, (ref) => ref.origin === entry.origin);
|
|
18
18
|
for (const [name, declaration] of policies) {
|
|
19
19
|
const path = `/closure/${entryIndex}/definitions/policies/${declarationIndex(entry, 'policies', name)}`;
|
|
20
20
|
if ('match' in declaration.expression) {
|
|
@@ -27,15 +27,11 @@ export function validatePolicyParity(context, entry, entryIndex, policies, origi
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
const measure =
|
|
31
|
-
if (measure !== undefined &&
|
|
32
|
-
(measure.depth > MAX_PATTERN_DEPTH ||
|
|
33
|
-
measure.edgeCounts.length > MAX_BRANCHES ||
|
|
34
|
-
Math.max(0, ...measure.edgeCounts) > MAX_EDGES ||
|
|
35
|
-
measure.domains.size > MAX_DOMAINS)) {
|
|
30
|
+
const measure = measurePolicy(name);
|
|
31
|
+
if (measure !== undefined && exceededLimits(measure).length > 0) {
|
|
36
32
|
fail(path, 'Policy expansion exceeds the V1 depth, branch, Edge, or Domain budget.');
|
|
37
33
|
}
|
|
38
|
-
const branches = typing.expandedBranches(name,
|
|
34
|
+
const branches = typing.expandedBranches(name, `$${name}`);
|
|
39
35
|
if (branches !== undefined) {
|
|
40
36
|
for (const branch of branches) {
|
|
41
37
|
const mode = targetMode(branch);
|
|
@@ -50,31 +46,25 @@ export function validatePolicyParity(context, entry, entryIndex, policies, origi
|
|
|
50
46
|
}
|
|
51
47
|
}
|
|
52
48
|
for (const [classIndex, definition] of entry.definitions.classes.entries()) {
|
|
53
|
-
|
|
49
|
+
const edge = isCompiledEdge(definition) ? definition : undefined;
|
|
50
|
+
for (const operation of CLASS_OPERATIONS) {
|
|
54
51
|
const policy = definition.policies[operation];
|
|
55
52
|
if (typeof policy !== 'object')
|
|
56
53
|
continue;
|
|
57
54
|
const path = `/closure/${entryIndex}/definitions/classes/${classIndex}/policies/${operation}`;
|
|
58
55
|
if (isClassRuleChecks(policy)) {
|
|
59
|
-
// The wire admits rules only
|
|
60
|
-
validatePolicyChecks(context, typing, entry, policy, -1, definition.ref, path, 'class');
|
|
56
|
+
// The wire admits rules only over `self` and `ref` objects, and `ref` alone to create a Node.
|
|
57
|
+
validatePolicyChecks(context, typing, entry, policy, -1, definition.ref, path, 'class', edge);
|
|
61
58
|
continue;
|
|
62
59
|
}
|
|
63
|
-
const label = operation
|
|
60
|
+
const label = `${operation[0].toUpperCase()}${operation.slice(1)}`;
|
|
64
61
|
if (definition.kind === 'node') {
|
|
65
62
|
if (!typing.policyAccepts(policy.name, { kind: 'exact', ref: definition.ref })) {
|
|
66
63
|
fail(path, `${label} Policy is incompatible with its protected Node Class.`);
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
|
-
else if (
|
|
70
|
-
|
|
71
|
-
? [definition.endpoints.source, definition.endpoints.target]
|
|
72
|
-
: definition.endpoints;
|
|
73
|
-
const sources = typing.concreteEndpointClasses(endpoints[0].accepts);
|
|
74
|
-
const targets = typing.concreteEndpointClasses(endpoints[1].accepts);
|
|
75
|
-
if (sources.some((source) => targets.some((target) => !typing.policyAcceptsEdge(policy.name, { kind: 'exact', ref: source }, { kind: 'exact', ref: target })))) {
|
|
76
|
-
fail(path, `${label} Policy is incompatible with an accepted Edge endpoint pair.`);
|
|
77
|
-
}
|
|
66
|
+
else if (edge !== undefined && !typing.policyAcceptsEdgeClass(policy.name, edge)) {
|
|
67
|
+
fail(path, `${label} Policy is incompatible with an accepted Edge endpoint pair.`);
|
|
78
68
|
}
|
|
79
69
|
}
|
|
80
70
|
if (definition.kind === 'node') {
|
|
@@ -94,46 +84,47 @@ export function validatePolicyParity(context, entry, entryIndex, policies, origi
|
|
|
94
84
|
function declarationIndex(entry, kind, name) {
|
|
95
85
|
return entry.definitions[kind].findIndex(({ ref }) => ref.name === name);
|
|
96
86
|
}
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
callable: { checks: 'Callable Policy checks', objects: 'the callable object contract' },
|
|
100
|
-
class: { checks: 'Class rule checks', objects: 'the Class rule object contract' },
|
|
101
|
-
};
|
|
102
|
-
function validatePolicyChecks(context, typing, entry, expression, input, receiver, path, site) {
|
|
87
|
+
function validatePolicyChecks(context, typing, entry, expression, input, receiver, path, site, edge) {
|
|
88
|
+
const label = POLICY_CHECK_SITE[site];
|
|
103
89
|
if (!checksNameTheCaller(expression)) {
|
|
104
|
-
fail(path, `${
|
|
90
|
+
fail(path, `${label.name} checks must check a Policy on every branch: sameNode alone names no caller.`);
|
|
105
91
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
measure.branches > MAX_BRANCHES ||
|
|
109
|
-
measure.leaves > MAX_CHECK_LEAVES) {
|
|
110
|
-
fail(path, `${SITE[site].checks} exceed the V1 depth, branch, or leaf budget.`);
|
|
92
|
+
if (exceededLimits(measureChecks(expression)).length > 0) {
|
|
93
|
+
fail(path, `${label.name} checks exceed the V1 depth, branch, or leaf budget.`);
|
|
111
94
|
}
|
|
112
95
|
const leaves = new Map();
|
|
113
96
|
const visit = (value, pointer) => {
|
|
114
|
-
if ('sameNode' in value)
|
|
97
|
+
if ('sameNode' in value) {
|
|
98
|
+
// `self` is an Edge in an Edge Class rule, and sameNode compares Nodes.
|
|
99
|
+
if (edge !== undefined &&
|
|
100
|
+
(value.sameNode.left.kind === 'self' || value.sameNode.right.kind === 'self'))
|
|
101
|
+
fail(pointer, 'sameNode compares Nodes: self is an Edge here.');
|
|
115
102
|
return;
|
|
103
|
+
}
|
|
116
104
|
if (!('check' in value)) {
|
|
117
|
-
|
|
118
|
-
|
|
105
|
+
PolicyComposition.of(value).operands.forEach((child, index) => visit(child, `${pointer}/${index}`));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (edge !== undefined && value.object.kind === 'self') {
|
|
109
|
+
// An Edge is checked as an Edge Class Policy is: over every concrete endpoint pair.
|
|
110
|
+
if (!typing.policyAcceptsEdgeClass(value.check.name, edge))
|
|
111
|
+
fail(pointer, 'Named Policy is incompatible with an accepted Edge endpoint pair.');
|
|
112
|
+
const name = Key.of(edge.ref);
|
|
113
|
+
leaves.set(value, { accepted: [name], admitted: new Set([name]) });
|
|
119
114
|
return;
|
|
120
115
|
}
|
|
121
116
|
const contracts = callableObjectContracts(context, entry, input, receiver, value.object);
|
|
122
117
|
if (contracts === undefined)
|
|
123
118
|
return;
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
]));
|
|
128
|
-
const admitted = admittedCheckClasses(typings);
|
|
129
|
-
if (admitted === undefined) {
|
|
130
|
-
fail(pointer, `Named Policy is incompatible with ${SITE[site].objects}.`);
|
|
119
|
+
const classes = typing.checkLeafClasses(value.check.name, contracts);
|
|
120
|
+
if (classes === undefined) {
|
|
121
|
+
fail(pointer, `Named Policy is incompatible with ${label.objects}.`);
|
|
131
122
|
}
|
|
132
|
-
leaves.set(value,
|
|
123
|
+
leaves.set(value, classes);
|
|
133
124
|
};
|
|
134
125
|
visit(expression, path);
|
|
135
126
|
const [never] = neverAdmittedClasses(expression, leaves);
|
|
136
127
|
if (never !== undefined) {
|
|
137
|
-
fail(path, `${
|
|
128
|
+
fail(path, `${label.name} checks can never admit ${never[0]} of Class ${never[1]}.`);
|
|
138
129
|
}
|
|
139
130
|
}
|
|
@@ -2,7 +2,10 @@ import { type MethodAddress } from '../../../../addressing/index.js';
|
|
|
2
2
|
import { type PolicyExpression } from '../../../../language/policy/model/policy.js';
|
|
3
3
|
import { type CompiledSchemaEntry } from '../../../model/schema.js';
|
|
4
4
|
import { type SemanticIndex, type CompiledPolicy } from '../context.js';
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Check named Policy composition and scoped pattern references. The wire grammar already bounds
|
|
7
|
+
* repeats and variables and refuses empty compositions.
|
|
8
|
+
*/
|
|
6
9
|
export declare function validatePolicyExpression(context: SemanticIndex, entry: CompiledSchemaEntry, expression: PolicyExpression, path: string, local: ReadonlyMap<string, CompiledPolicy>): void;
|
|
7
10
|
/** Require an exact executable Method declaration for a Policy reference. */
|
|
8
11
|
export declare function validatePolicyMethod(context: SemanticIndex, ref: MethodAddress, path: string): void;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { Key } from '../../../../addressing/index.js';
|
|
2
2
|
import { isMethodExecutable } from '../../../../language/callable/executable.js';
|
|
3
3
|
import { policyVariableClass } from '../../../../language/index.js';
|
|
4
|
-
import {
|
|
5
|
-
import {} from '../../../../language/policy/model/policy.js';
|
|
4
|
+
import { PolicyComposition, } from '../../../../language/policy/model/policy.js';
|
|
6
5
|
import {} from '../../../model/schema.js';
|
|
7
6
|
import { fail } from '../../diagnostic.js';
|
|
8
7
|
import {} from '../context.js';
|
|
9
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Check named Policy composition and scoped pattern references. The wire grammar already bounds
|
|
10
|
+
* repeats and variables and refuses empty compositions.
|
|
11
|
+
*/
|
|
10
12
|
export function validatePolicyExpression(context, entry, expression, path, local) {
|
|
11
13
|
if ('match' in expression) {
|
|
12
14
|
validatePattern(context, expression.match, `${path}/match`, new Set(), new Set());
|
|
13
15
|
return;
|
|
14
16
|
}
|
|
15
|
-
const
|
|
16
|
-
if (values.length === 0)
|
|
17
|
-
fail(path, 'Named Policy composition must be non-empty.');
|
|
18
|
-
for (const [index, ref] of values.entries()) {
|
|
17
|
+
for (const [index, ref] of PolicyComposition.of(expression).operands.entries()) {
|
|
19
18
|
if (ref.origin !== entry.origin || ref.kind !== 'policy' || !local.has(ref.name))
|
|
20
19
|
fail(`${path}/${index}`, 'Named Policy composition must reference a local Policy.');
|
|
21
20
|
}
|
|
@@ -31,19 +30,9 @@ function validatePattern(context, expression, path, scope, declared) {
|
|
|
31
30
|
fail(`${path}/class`, 'Policy pattern Class must resolve to an Edge Class.');
|
|
32
31
|
validatePolicyTerm(context, expression.source, `${path}/source`, scope);
|
|
33
32
|
validatePolicyTerm(context, expression.target, `${path}/target`, scope);
|
|
34
|
-
if (expression.repeat !== undefined &&
|
|
35
|
-
(!Number.isInteger(expression.repeat.min) ||
|
|
36
|
-
!Number.isInteger(expression.repeat.max) ||
|
|
37
|
-
expression.repeat.min < 0 ||
|
|
38
|
-
expression.repeat.max < expression.repeat.min ||
|
|
39
|
-
expression.repeat.max > MAX_REPEAT))
|
|
40
|
-
fail(`${path}/repeat`, 'Policy repeat is outside the V1 bounds.');
|
|
41
33
|
return;
|
|
42
34
|
}
|
|
43
35
|
if ('exists' in expression) {
|
|
44
|
-
if (expression.exists.nodes.length > MAX_VARIABLES) {
|
|
45
|
-
fail(`${path}/exists/nodes`, 'Policy exists exceeds the V1 variable budget.');
|
|
46
|
-
}
|
|
47
36
|
const nested = new Set(scope);
|
|
48
37
|
for (const [index, node] of expression.exists.nodes.entries()) {
|
|
49
38
|
const id = node.variable.id;
|
|
@@ -58,10 +47,7 @@ function validatePattern(context, expression, path, scope, declared) {
|
|
|
58
47
|
validatePattern(context, expression.exists.where, `${path}/exists/where`, nested, declared);
|
|
59
48
|
return;
|
|
60
49
|
}
|
|
61
|
-
|
|
62
|
-
if (values.length === 0)
|
|
63
|
-
fail(path, 'Policy pattern composition must be non-empty.');
|
|
64
|
-
values.forEach((value, index) => validatePattern(context, value, `${path}/${index}`, scope, declared));
|
|
50
|
+
PolicyComposition.of(expression).operands.forEach((value, index) => validatePattern(context, value, `${path}/${index}`, scope, declared));
|
|
65
51
|
}
|
|
66
52
|
function validatePolicyTerm(context, term, path, scope) {
|
|
67
53
|
if (term.kind === 'ref' && term.ref.kind === 'method')
|
|
@@ -1,28 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type PatternBranch } from '../../../../language/policy/analysis/branches.js';
|
|
1
|
+
import { PolicyTyping } from '../../../../language/policy/analysis/typing.js';
|
|
3
2
|
import { type PolicyExpression } from '../../../../language/policy/model/policy.js';
|
|
4
3
|
import { type CompiledSchemaEntry } from '../../../model/schema.js';
|
|
5
4
|
import { type SemanticIndex } from '../context.js';
|
|
6
|
-
import { type CompiledObjectContract, type CompiledPolicyUse } from './contracts.js';
|
|
7
5
|
/** Types one entry's Policies against the Node Classes of its own closure, as source admission. */
|
|
8
|
-
export declare
|
|
9
|
-
readonly context: SemanticIndex;
|
|
10
|
-
readonly entry: CompiledSchemaEntry;
|
|
11
|
-
readonly normalized: ReadonlyMap<string, PolicyExpression>;
|
|
12
|
-
readonly allNodeClasses: readonly ClassRef[];
|
|
13
|
-
readonly concreteNodeClasses: readonly ClassRef[];
|
|
14
|
-
constructor(context: SemanticIndex, entry: CompiledSchemaEntry, normalized: ReadonlyMap<string, PolicyExpression>, origins: ReadonlySet<string>);
|
|
15
|
-
expandedBranches(name: string, visiting: Set<string>, namespace: string): readonly PatternBranch[] | undefined;
|
|
16
|
-
policyAccepts(name: string, object: CompiledObjectContract): boolean;
|
|
17
|
-
policyBranchTyping(name: string, object: CompiledObjectContract): readonly boolean[] | undefined;
|
|
18
|
-
policyAcceptsEdge(name: string, source: CompiledObjectContract, target: CompiledObjectContract): boolean;
|
|
19
|
-
concreteEndpointClasses(accepts: readonly ClassRef[]): readonly ClassRef[];
|
|
20
|
-
endpointsOverlap(left: readonly ClassRef[], right: readonly ClassRef[]): boolean;
|
|
21
|
-
branchIsTyped(branch: PatternBranch, use: CompiledPolicyUse): boolean;
|
|
22
|
-
private constraintsSatisfiable;
|
|
23
|
-
private applyInitial;
|
|
24
|
-
private applyExact;
|
|
25
|
-
private applyAnyNodeClass;
|
|
26
|
-
private applyRequirement;
|
|
27
|
-
private applyEndpoint;
|
|
28
|
-
}
|
|
6
|
+
export declare function compiledPolicyTyping(context: SemanticIndex, entry: CompiledSchemaEntry, normalized: ReadonlyMap<string, PolicyExpression>, origins: ReadonlySet<string>): PolicyTyping;
|