@astrale-os/kernel-dsl 1.0.0-beta.27 → 1.0.0-beta.28

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.
Files changed (78) hide show
  1. package/dist/v1/addressing/ordering.d.ts +2 -2
  2. package/dist/v1/addressing/ordering.js +2 -4
  3. package/dist/v1/builder/index.d.ts +2 -0
  4. package/dist/v1/builder/index.js +1 -0
  5. package/dist/v1/builder/schema/rule.d.ts +316 -0
  6. package/dist/v1/builder/schema/rule.js +192 -0
  7. package/dist/v1/bundle/index.d.ts +2 -0
  8. package/dist/v1/bundle/index.js +1 -0
  9. package/dist/v1/bundle/rule.d.ts +14 -0
  10. package/dist/v1/bundle/rule.js +41 -0
  11. package/dist/v1/compiled/admission/diagnostic.d.ts +14 -0
  12. package/dist/v1/compiled/admission/diagnostic.js +6 -0
  13. package/dist/v1/compiled/admission/semantics/policy/callable.js +2 -3
  14. package/dist/v1/compiled/admission/semantics/policy/parity.js +8 -13
  15. package/dist/v1/compiled/admission/semantics/policy/pattern.js +3 -5
  16. package/dist/v1/compiled/admission/wire/policy.js +16 -11
  17. package/dist/v1/compiled/index.d.ts +2 -0
  18. package/dist/v1/compiled/index.js +1 -0
  19. package/dist/v1/compiled/rule.d.ts +49 -0
  20. package/dist/v1/compiled/rule.js +169 -0
  21. package/dist/v1/language/callable/admission.js +2 -1
  22. package/dist/v1/language/policy/analysis/branches.js +6 -7
  23. package/dist/v1/language/policy/analysis/budgets.js +8 -6
  24. package/dist/v1/language/policy/analysis/checks.js +5 -4
  25. package/dist/v1/language/policy/analysis/composition.js +2 -2
  26. package/dist/v1/language/policy/analysis/typing.js +3 -2
  27. package/dist/v1/language/policy/model/policy.d.ts +22 -0
  28. package/dist/v1/language/policy/model/policy.js +28 -4
  29. package/dist/v1/language/policy/normalization/normalize.js +33 -56
  30. package/dist/v1/language/value/evaluate/assertions.d.ts +2 -2
  31. package/dist/v1/language/value/evaluate/assertions.js +4 -34
  32. package/dist/v1/language/value/evaluate/evaluator.js +10 -15
  33. package/dist/v1/language/value/evaluate/validity.optimization.js +9 -14
  34. package/dist/v1/language/value/files.js +2 -1
  35. package/dist/v1/language/value/ordering.js +1 -3
  36. package/dist/v1/language/value/profile/canonicalize.js +1 -3
  37. package/dist/v1/language/value/syntax/walk.d.ts +2 -0
  38. package/dist/v1/language/value/syntax/walk.js +4 -0
  39. package/dist/v1/schema/compatibility/api.d.ts +2 -0
  40. package/dist/v1/schema/compatibility/api.js +1 -0
  41. package/dist/v1/schema/compatibility/rule.d.ts +13 -0
  42. package/dist/v1/schema/compatibility/rule.js +23 -0
  43. package/dist/v1/schema/enforcement/changes.d.ts +590 -0
  44. package/dist/v1/schema/enforcement/changes.js +566 -0
  45. package/dist/v1/schema/enforcement/derived.d.ts +236 -0
  46. package/dist/v1/schema/enforcement/derived.js +243 -0
  47. package/dist/v1/schema/enforcement/dispose.d.ts +308 -0
  48. package/dist/v1/schema/enforcement/dispose.js +275 -0
  49. package/dist/v1/schema/enforcement/facts.d.ts +89 -0
  50. package/dist/v1/schema/enforcement/facts.js +70 -0
  51. package/dist/v1/schema/enforcement/fields.d.ts +65 -0
  52. package/dist/v1/schema/enforcement/fields.js +36 -0
  53. package/dist/v1/schema/enforcement/index.d.ts +39 -0
  54. package/dist/v1/schema/enforcement/index.js +10 -0
  55. package/dist/v1/schema/enforcement/install.d.ts +1634 -0
  56. package/dist/v1/schema/enforcement/install.js +1223 -0
  57. package/dist/v1/schema/enforcement/lifecycle.d.ts +87 -0
  58. package/dist/v1/schema/enforcement/lifecycle.js +91 -0
  59. package/dist/v1/schema/enforcement/model.d.ts +253 -0
  60. package/dist/v1/schema/enforcement/model.js +1 -0
  61. package/dist/v1/schema/enforcement/obligations.d.ts +248 -0
  62. package/dist/v1/schema/enforcement/obligations.js +240 -0
  63. package/dist/v1/schema/enforcement/write.d.ts +1314 -0
  64. package/dist/v1/schema/enforcement/write.js +1017 -0
  65. package/dist/v1/schema/index.d.ts +1 -0
  66. package/dist/v1/schema/index.js +1 -0
  67. package/dist/v1/schema/resolution/origins.js +4 -7
  68. package/dist/v1/schema/rule.d.ts +4 -5
  69. package/dist/v1/schema/rule.js +19 -13
  70. package/dist/v1/schema/validation/policy/references.js +5 -11
  71. package/dist/v1/schema/validation/policy/uses.js +3 -8
  72. package/dist/value/canonical.d.ts +16 -1
  73. package/dist/value/canonical.js +90 -33
  74. package/dist/value/index.d.ts +2 -0
  75. package/dist/value/index.js +1 -0
  76. package/dist/value/rule.d.ts +12 -0
  77. package/dist/value/rule.js +50 -0
  78. package/package.json +5 -1
@@ -4,5 +4,5 @@ export declare function definitionRefIndex(ref: DefinitionRef): string;
4
4
  export declare function compareDefinitionRefs(left: DefinitionRef, right: DefinitionRef): number;
5
5
  /** Locale-independent Unicode code-point ordering for canonical DSL values. */
6
6
  export declare function compareUnicode(left: string, right: string): number;
7
- /** Order strings by UTF-16 code unit, the order `<` gives strings. */
8
- export declare function compareCodeUnits(left: string, right: string): number;
7
+ /** Order strings by UTF-16 code unit, the order `<` gives strings and canonical JSON its members. */
8
+ export { compareCodeUnits } from '../../value/canonical.js';
@@ -18,7 +18,5 @@ export function compareUnicode(left, right) {
18
18
  }
19
19
  return a.length - b.length;
20
20
  }
21
- /** Order strings by UTF-16 code unit, the order `<` gives strings. */
22
- export function compareCodeUnits(left, right) {
23
- return left < right ? -1 : left > right ? 1 : 0;
24
- }
21
+ /** Order strings by UTF-16 code unit, the order `<` gives strings and canonical JSON its members. */
22
+ export { compareCodeUnits } from '../../value/canonical.js';
@@ -12,6 +12,8 @@ export type { ResolvedDomainOfInput } from './schema/projection.js';
12
12
  export { valueSchema } from './value/schema.js';
13
13
  export { view } from './view/authoring.js';
14
14
  export { BuilderError as Error } from './schema/diagnostic.js';
15
+ export { BUILDER_RULES } from './schema/rule.js';
16
+ export type { BuilderRule, BuilderRuleOnDocument } from './schema/rule.js';
15
17
  export type { BuilderDiagnostic as Diagnostic, BuilderDiagnosticCode as DiagnosticCode, } from './schema/diagnostic.js';
16
18
  export type { CallableInputBase, CallableInput, BinaryInputAuthoring, CallableOutputInput, CallableProjection, CallablePolicyBuilder, CallablePolicyContext, PolicyCheckContext, BinaryOutput, Function, FunctionInput, Method, MethodInput, PolicyObjectInput, StreamOutput, } from './callable/authoring.js';
17
19
  export type { CoreEdge, CoreEndpoint, CoreInput, CoreNode } from './core/authoring.js';
@@ -10,3 +10,4 @@ export { defineSchema } from './schema/define.js';
10
10
  export { valueSchema } from './value/schema.js';
11
11
  export { view } from './view/authoring.js';
12
12
  export { BuilderError as Error } from './schema/diagnostic.js';
13
+ export { BUILDER_RULES } from './schema/rule.js';
@@ -0,0 +1,316 @@
1
+ import type { SchemaDiagnosticCode } from '../../schema/diagnostic.js';
2
+ import type { InstallId } from '../../schema/enforcement/install.js';
3
+ /**
4
+ * What answers a Schema document that breaks a rule of the Builder: a document reaches the Kernel
5
+ * without passing through the Builder. `refused`: admission refuses it by `admission`, or the install
6
+ * by the row `install`. `nothing`: it is accepted and installs, so only an authored Schema holds the
7
+ * rule. `unsayable`: the rule is about an authoring value, which a document cannot hold. `unexamined`:
8
+ * a rule of Policies, Functions, Methods or Views, whose document is not compared here.
9
+ */
10
+ export type BuilderRuleOnDocument = {
11
+ readonly holds: 'refused';
12
+ readonly admission?: readonly [SchemaDiagnosticCode, ...SchemaDiagnosticCode[]];
13
+ readonly install?: InstallId;
14
+ } | {
15
+ readonly holds: 'nothing';
16
+ } | {
17
+ readonly holds: 'unsayable';
18
+ } | {
19
+ readonly holds: 'unexamined';
20
+ };
21
+ /** The rule one diagnostic code of the Builder reports. */
22
+ export interface BuilderRule {
23
+ /** The rule, in one plain sentence. */
24
+ readonly statement: string;
25
+ readonly document: BuilderRuleOnDocument;
26
+ }
27
+ /**
28
+ * Every diagnostic code the Builder owns with the rule it reports. A code added to the Builder does
29
+ * not compile until it is described here. A rule of the Language is in `schema.values.RULES`.
30
+ */
31
+ export declare const BUILDER_RULES: Readonly<{
32
+ readonly BUILDER_ABSTRACT_POLICY: {
33
+ readonly statement: 'An abstract Class declares no Class Policy, and an abstract Method no Policy.';
34
+ readonly document: {
35
+ readonly holds: 'unexamined';
36
+ };
37
+ };
38
+ readonly BUILDER_AMBIGUOUS_OWNERSHIP: {
39
+ readonly statement: 'One authoring handle is owned by one Definition.';
40
+ readonly document: {
41
+ readonly holds: 'unsayable';
42
+ };
43
+ };
44
+ readonly BUILDER_AUTO_EVENT_INVALID: {
45
+ readonly statement: 'An automatic Property runs on at least one event, each of them create or update, and a required one runs on create.';
46
+ readonly document: {
47
+ readonly holds: 'refused';
48
+ readonly admission: readonly ["STRUCTURE_MINIMUM", "STRUCTURE_VALUE", "DV_PROPERTY_AUTO"];
49
+ };
50
+ };
51
+ readonly BUILDER_AUTO_IMMUTABLE: {
52
+ readonly statement: 'An automatic Property is not immutable.';
53
+ readonly document: {
54
+ readonly holds: 'refused';
55
+ readonly admission: readonly ["DV_PROPERTY_IMMUTABLE"];
56
+ };
57
+ };
58
+ readonly BUILDER_AUTO_NESTED: {
59
+ readonly statement: '`auto(...)` wraps a Property which is not already automatic.';
60
+ readonly document: {
61
+ readonly holds: 'unsayable';
62
+ };
63
+ };
64
+ readonly BUILDER_AUTO_SET_INVALID: {
65
+ readonly statement: 'The setter of an automatic Property is `instant`.';
66
+ readonly document: {
67
+ readonly holds: 'refused';
68
+ readonly admission: readonly ["STRUCTURE_VALUE"];
69
+ };
70
+ };
71
+ readonly BUILDER_CALLABLE_AUTH: {
72
+ readonly statement: 'A Function declares its auth as anonymous, authenticated or authorized.';
73
+ readonly document: {
74
+ readonly holds: 'unexamined';
75
+ };
76
+ };
77
+ readonly BUILDER_CALLABLE_PLACEMENT: {
78
+ readonly statement: 'A standalone Function declares no staticness or abstractness, and a Method takes a Value input.';
79
+ readonly document: {
80
+ readonly holds: 'unexamined';
81
+ };
82
+ };
83
+ readonly BUILDER_CALLABLE_POLICY_AUTH: {
84
+ readonly statement: 'Only an authorized Function or Method declares a Policy check.';
85
+ readonly document: {
86
+ readonly holds: 'unexamined';
87
+ };
88
+ };
89
+ readonly BUILDER_CLASS_INHERITANCE: {
90
+ readonly statement: 'A Class extends a Class of another Domain only where that Class is open in the revision it binds.';
91
+ readonly document: {
92
+ readonly holds: 'refused';
93
+ readonly admission: readonly ["DV_CLASS_INHERITANCE"];
94
+ readonly install: 'DEPENDENCY_INCOMPATIBLE';
95
+ };
96
+ };
97
+ readonly BUILDER_CORE_CLASS: {
98
+ readonly statement: 'The Class of a Core Node or a Core Edge is local to the owning Domain.';
99
+ readonly document: {
100
+ readonly holds: 'refused';
101
+ readonly admission: readonly ["DV_CORE_NODE_CLASS", "DV_CORE_EDGE_CLASS"];
102
+ };
103
+ };
104
+ readonly BUILDER_CORE_EDGE: {
105
+ readonly statement: 'An entry of `core.edges` is created by `core.edge(...)`.';
106
+ readonly document: {
107
+ readonly holds: 'unsayable';
108
+ };
109
+ };
110
+ readonly BUILDER_CORE_NODE: {
111
+ readonly statement: 'An entry of `core.nodes` is created by `core.node(...)`.';
112
+ readonly document: {
113
+ readonly holds: 'unsayable';
114
+ };
115
+ };
116
+ readonly BUILDER_CORE_PROPERTY: {
117
+ readonly statement: 'A Core fact names a Property of its Class by name, each once, and its Class is concrete and resolves.';
118
+ readonly document: {
119
+ readonly holds: 'refused';
120
+ readonly admission: readonly ["DV_CORE_NODE_PROPERTIES"];
121
+ };
122
+ };
123
+ readonly BUILDER_CORE_REF: {
124
+ readonly statement: 'An endpoint of a Core Edge names the owning Domain or one local Definition, Function, Method, Policy, View or Core Node.';
125
+ readonly document: {
126
+ readonly holds: 'refused';
127
+ readonly admission: readonly ["DV_CORE_REF"];
128
+ };
129
+ };
130
+ readonly BUILDER_DEFINITION: {
131
+ readonly statement: 'An entry of `classes` is created by a Definition builder.';
132
+ readonly document: {
133
+ readonly holds: 'unsayable';
134
+ };
135
+ };
136
+ readonly BUILDER_DEPENDENCY_ALIAS: {
137
+ readonly statement: 'A dependency alias is an ASCII lower-camel identifier and is not reserved.';
138
+ readonly document: {
139
+ readonly holds: 'refused';
140
+ readonly admission: readonly ["STRUCTURE_KEY", "STRUCTURE_DEPENDENCY_ALIAS"];
141
+ };
142
+ };
143
+ readonly BUILDER_DEPENDENCY_CONFLICT: {
144
+ readonly statement: 'One origin is declared under one dependency alias.';
145
+ readonly document: {
146
+ readonly holds: 'refused';
147
+ readonly admission: readonly ["DV_DEPENDENCY_UNIQUE"];
148
+ };
149
+ };
150
+ readonly BUILDER_DEPENDENCY_DIRECT: {
151
+ readonly statement: 'A foreign Definition belongs to a direct dependency.';
152
+ readonly document: {
153
+ readonly holds: 'refused';
154
+ readonly admission: readonly ["DV_REF_RESOLVES", "DV_DEPENDENCY_DIRECT"];
155
+ };
156
+ };
157
+ readonly BUILDER_EDGE_LIFETIME: {
158
+ readonly statement: 'An Edge Class with an endpoint which can hold a Node of another Domain requires no Edge at any endpoint, and an Edge Class keeps the lifetimes of the Edge Classes it extends.';
159
+ readonly document: {
160
+ readonly holds: 'nothing';
161
+ };
162
+ };
163
+ readonly BUILDER_FILE_INVALID: {
164
+ readonly statement: 'A file field states valid constraints, within those of the blob it is copied from.';
165
+ readonly document: {
166
+ readonly holds: 'refused';
167
+ readonly admission: readonly ["DV_VALUE_SCHEMA"];
168
+ };
169
+ };
170
+ readonly BUILDER_FOREIGN_POLICY: {
171
+ readonly statement: 'A Policy reference names a local Policy.';
172
+ readonly document: {
173
+ readonly holds: 'unexamined';
174
+ };
175
+ };
176
+ readonly BUILDER_FULL_MATCH_INVALID: {
177
+ readonly statement: '`fullMatch(...)` takes a complete I-Regexp source within the state budget.';
178
+ readonly document: {
179
+ readonly holds: 'refused';
180
+ readonly admission: readonly ["DV_VALUE_SCHEMA"];
181
+ };
182
+ };
183
+ readonly BUILDER_FUNCTION: {
184
+ readonly statement: 'An entry of `functions` is created by `func(...)`.';
185
+ readonly document: {
186
+ readonly holds: 'unexamined';
187
+ };
188
+ };
189
+ readonly BUILDER_METHOD: {
190
+ readonly statement: 'An entry of `methods` is created by `method(...)`.';
191
+ readonly document: {
192
+ readonly holds: 'unexamined';
193
+ };
194
+ };
195
+ readonly BUILDER_PATH_DUPLICATE: {
196
+ readonly statement: '`path(...)` names one Node Definition once. A path stands in a Zod input, so the refusal reaches the caller as `ZOD_SCHEMA_NOT_LOSSLESS`, whose message holds this code.';
197
+ readonly document: {
198
+ readonly holds: 'refused';
199
+ readonly admission: readonly ["DV_VALUE_SCHEMA"];
200
+ };
201
+ };
202
+ readonly BUILDER_PATH_EMPTY: {
203
+ readonly statement: '`path(...)` names at least one Node Definition.';
204
+ readonly document: {
205
+ readonly holds: 'refused';
206
+ readonly admission: readonly ["DV_VALUE_SCHEMA"];
207
+ };
208
+ };
209
+ readonly BUILDER_POLICY: {
210
+ readonly statement: 'A Policy is created by `policy(...)` and its operands take the object it checks.';
211
+ readonly document: {
212
+ readonly holds: 'unexamined';
213
+ };
214
+ };
215
+ readonly BUILDER_POLICY_COMPOSITION: {
216
+ readonly statement: 'A Policy composition is created by `policy.allOf(...)` or `policy.anyOf(...)`.';
217
+ readonly document: {
218
+ readonly holds: 'unexamined';
219
+ };
220
+ };
221
+ readonly BUILDER_POLICY_CYCLE: {
222
+ readonly statement: 'A Policy composition does not reach itself.';
223
+ readonly document: {
224
+ readonly holds: 'unexamined';
225
+ };
226
+ };
227
+ readonly BUILDER_POLICY_EMPTY_COMPOSITION: {
228
+ readonly statement: 'A Policy composition has at least one operand.';
229
+ readonly document: {
230
+ readonly holds: 'unexamined';
231
+ };
232
+ };
233
+ readonly BUILDER_POLICY_EMPTY_EXISTS: {
234
+ readonly statement: '`exists(...)` declares at least one variable Node.';
235
+ readonly document: {
236
+ readonly holds: 'unexamined';
237
+ };
238
+ };
239
+ readonly BUILDER_POLICY_INPUT: {
240
+ readonly statement: 'A Policy input is one direct required field holding one Node path.';
241
+ readonly document: {
242
+ readonly holds: 'unexamined';
243
+ };
244
+ };
245
+ readonly BUILDER_POLICY_REF: {
246
+ readonly statement: 'A Policy `ref(...)` names one local or direct-dependency Definition, Function, Method, Policy, View or Core Node.';
247
+ readonly document: {
248
+ readonly holds: 'unexamined';
249
+ };
250
+ };
251
+ readonly BUILDER_POLICY_SELF: {
252
+ readonly statement: '`self` is available only to a non-static Node Method.';
253
+ readonly document: {
254
+ readonly holds: 'unexamined';
255
+ };
256
+ };
257
+ readonly BUILDER_PROPERTY_IMMUTABLE_INVALID: {
258
+ readonly statement: '`immutable` is `create` or `once`.';
259
+ readonly document: {
260
+ readonly holds: 'refused';
261
+ readonly admission: readonly ["STRUCTURE_VALUE"];
262
+ };
263
+ };
264
+ readonly BUILDER_REFERENCE_CYCLE: {
265
+ readonly statement: 'A lazy reference resolves without reaching itself.';
266
+ readonly document: {
267
+ readonly holds: 'unsayable';
268
+ };
269
+ };
270
+ readonly BUILDER_REFERENCE_KIND: {
271
+ readonly statement: 'A reference names a Class of the kind its position takes.';
272
+ readonly document: {
273
+ readonly holds: 'refused';
274
+ readonly admission: readonly ["DV_CLASS_KIND"];
275
+ };
276
+ };
277
+ readonly BUILDER_REFERENCE_MISSING: {
278
+ readonly statement: 'A local reference names a Definition the Domain declares.';
279
+ readonly document: {
280
+ readonly holds: 'refused';
281
+ readonly admission: readonly ["DV_REF_RESOLVES"];
282
+ };
283
+ };
284
+ readonly BUILDER_UNIQUE_PROPERTY: {
285
+ readonly statement: 'A key names a Property its Class holds.';
286
+ readonly document: {
287
+ readonly holds: 'refused';
288
+ readonly admission: readonly ["DV_NODE_UNIQUE"];
289
+ };
290
+ };
291
+ readonly BUILDER_UNKNOWN_FIELD: {
292
+ readonly statement: 'An authoring input holds no field its builder does not read.';
293
+ readonly document: {
294
+ readonly holds: 'refused';
295
+ readonly admission: readonly ["STRUCTURE_UNKNOWN_FIELD"];
296
+ };
297
+ };
298
+ readonly BUILDER_UNOWNED_REFERENCE: {
299
+ readonly statement: 'A reference to an authoring handle names a handle some Domain owns.';
300
+ readonly document: {
301
+ readonly holds: 'unsayable';
302
+ };
303
+ };
304
+ readonly BUILDER_VIEW: {
305
+ readonly statement: 'An entry of `views` is created by `view(...)`, which names no target.';
306
+ readonly document: {
307
+ readonly holds: 'unexamined';
308
+ };
309
+ };
310
+ readonly ZOD_SCHEMA_NOT_LOSSLESS: {
311
+ readonly statement: 'A Zod schema is one Draft 2020-12 can state with the same acceptance. A document states a value schema directly.';
312
+ readonly document: {
313
+ readonly holds: 'unsayable';
314
+ };
315
+ };
316
+ }>;
@@ -0,0 +1,192 @@
1
+ import { deepFreeze } from '../../language/freeze.js';
2
+ const UNSAYABLE = { holds: 'unsayable' };
3
+ const UNEXAMINED = { holds: 'unexamined' };
4
+ /**
5
+ * Every diagnostic code the Builder owns with the rule it reports. A code added to the Builder does
6
+ * not compile until it is described here. A rule of the Language is in `schema.values.RULES`.
7
+ */
8
+ export const BUILDER_RULES = deepFreeze({
9
+ BUILDER_ABSTRACT_POLICY: {
10
+ statement: 'An abstract Class declares no Class Policy, and an abstract Method no Policy.',
11
+ document: UNEXAMINED,
12
+ },
13
+ BUILDER_AMBIGUOUS_OWNERSHIP: {
14
+ statement: 'One authoring handle is owned by one Definition.',
15
+ document: UNSAYABLE,
16
+ },
17
+ BUILDER_AUTO_EVENT_INVALID: {
18
+ statement: 'An automatic Property runs on at least one event, each of them create or update, and a required one runs on create.',
19
+ document: {
20
+ holds: 'refused',
21
+ admission: ['STRUCTURE_MINIMUM', 'STRUCTURE_VALUE', 'DV_PROPERTY_AUTO'],
22
+ },
23
+ },
24
+ BUILDER_AUTO_IMMUTABLE: {
25
+ statement: 'An automatic Property is not immutable.',
26
+ document: { holds: 'refused', admission: ['DV_PROPERTY_IMMUTABLE'] },
27
+ },
28
+ BUILDER_AUTO_NESTED: {
29
+ statement: '`auto(...)` wraps a Property which is not already automatic.',
30
+ document: UNSAYABLE,
31
+ },
32
+ BUILDER_AUTO_SET_INVALID: {
33
+ statement: 'The setter of an automatic Property is `instant`.',
34
+ document: { holds: 'refused', admission: ['STRUCTURE_VALUE'] },
35
+ },
36
+ BUILDER_CALLABLE_AUTH: {
37
+ statement: 'A Function declares its auth as anonymous, authenticated or authorized.',
38
+ document: UNEXAMINED,
39
+ },
40
+ BUILDER_CALLABLE_PLACEMENT: {
41
+ statement: 'A standalone Function declares no staticness or abstractness, and a Method takes a Value input.',
42
+ document: UNEXAMINED,
43
+ },
44
+ BUILDER_CALLABLE_POLICY_AUTH: {
45
+ statement: 'Only an authorized Function or Method declares a Policy check.',
46
+ document: UNEXAMINED,
47
+ },
48
+ BUILDER_CLASS_INHERITANCE: {
49
+ statement: 'A Class extends a Class of another Domain only where that Class is open in the revision it binds.',
50
+ document: {
51
+ holds: 'refused',
52
+ admission: ['DV_CLASS_INHERITANCE'],
53
+ install: 'DEPENDENCY_INCOMPATIBLE',
54
+ },
55
+ },
56
+ BUILDER_CORE_CLASS: {
57
+ statement: 'The Class of a Core Node or a Core Edge is local to the owning Domain.',
58
+ document: { holds: 'refused', admission: ['DV_CORE_NODE_CLASS', 'DV_CORE_EDGE_CLASS'] },
59
+ },
60
+ BUILDER_CORE_EDGE: {
61
+ statement: 'An entry of `core.edges` is created by `core.edge(...)`.',
62
+ document: UNSAYABLE,
63
+ },
64
+ BUILDER_CORE_NODE: {
65
+ statement: 'An entry of `core.nodes` is created by `core.node(...)`.',
66
+ document: UNSAYABLE,
67
+ },
68
+ BUILDER_CORE_PROPERTY: {
69
+ statement: 'A Core fact names a Property of its Class by name, each once, and its Class is concrete and resolves.',
70
+ document: { holds: 'refused', admission: ['DV_CORE_NODE_PROPERTIES'] },
71
+ },
72
+ BUILDER_CORE_REF: {
73
+ statement: 'An endpoint of a Core Edge names the owning Domain or one local Definition, Function, Method, Policy, View or Core Node.',
74
+ document: { holds: 'refused', admission: ['DV_CORE_REF'] },
75
+ },
76
+ BUILDER_DEFINITION: {
77
+ statement: 'An entry of `classes` is created by a Definition builder.',
78
+ document: UNSAYABLE,
79
+ },
80
+ BUILDER_DEPENDENCY_ALIAS: {
81
+ statement: 'A dependency alias is an ASCII lower-camel identifier and is not reserved.',
82
+ document: { holds: 'refused', admission: ['STRUCTURE_KEY', 'STRUCTURE_DEPENDENCY_ALIAS'] },
83
+ },
84
+ BUILDER_DEPENDENCY_CONFLICT: {
85
+ statement: 'One origin is declared under one dependency alias.',
86
+ document: { holds: 'refused', admission: ['DV_DEPENDENCY_UNIQUE'] },
87
+ },
88
+ BUILDER_DEPENDENCY_DIRECT: {
89
+ statement: 'A foreign Definition belongs to a direct dependency.',
90
+ document: { holds: 'refused', admission: ['DV_REF_RESOLVES', 'DV_DEPENDENCY_DIRECT'] },
91
+ },
92
+ BUILDER_EDGE_LIFETIME: {
93
+ statement: 'An Edge Class with an endpoint which can hold a Node of another Domain requires no Edge at any endpoint, and an Edge Class keeps the lifetimes of the Edge Classes it extends.',
94
+ document: { holds: 'nothing' },
95
+ },
96
+ BUILDER_FILE_INVALID: {
97
+ statement: 'A file field states valid constraints, within those of the blob it is copied from.',
98
+ document: { holds: 'refused', admission: ['DV_VALUE_SCHEMA'] },
99
+ },
100
+ BUILDER_FOREIGN_POLICY: {
101
+ statement: 'A Policy reference names a local Policy.',
102
+ document: UNEXAMINED,
103
+ },
104
+ BUILDER_FULL_MATCH_INVALID: {
105
+ statement: '`fullMatch(...)` takes a complete I-Regexp source within the state budget.',
106
+ document: { holds: 'refused', admission: ['DV_VALUE_SCHEMA'] },
107
+ },
108
+ BUILDER_FUNCTION: {
109
+ statement: 'An entry of `functions` is created by `func(...)`.',
110
+ document: UNEXAMINED,
111
+ },
112
+ BUILDER_METHOD: {
113
+ statement: 'An entry of `methods` is created by `method(...)`.',
114
+ document: UNEXAMINED,
115
+ },
116
+ BUILDER_PATH_DUPLICATE: {
117
+ statement: '`path(...)` names one Node Definition once. A path stands in a Zod input, so the refusal reaches the caller as `ZOD_SCHEMA_NOT_LOSSLESS`, whose message holds this code.',
118
+ document: { holds: 'refused', admission: ['DV_VALUE_SCHEMA'] },
119
+ },
120
+ BUILDER_PATH_EMPTY: {
121
+ statement: '`path(...)` names at least one Node Definition.',
122
+ document: { holds: 'refused', admission: ['DV_VALUE_SCHEMA'] },
123
+ },
124
+ BUILDER_POLICY: {
125
+ statement: 'A Policy is created by `policy(...)` and its operands take the object it checks.',
126
+ document: UNEXAMINED,
127
+ },
128
+ BUILDER_POLICY_COMPOSITION: {
129
+ statement: 'A Policy composition is created by `policy.allOf(...)` or `policy.anyOf(...)`.',
130
+ document: UNEXAMINED,
131
+ },
132
+ BUILDER_POLICY_CYCLE: {
133
+ statement: 'A Policy composition does not reach itself.',
134
+ document: UNEXAMINED,
135
+ },
136
+ BUILDER_POLICY_EMPTY_COMPOSITION: {
137
+ statement: 'A Policy composition has at least one operand.',
138
+ document: UNEXAMINED,
139
+ },
140
+ BUILDER_POLICY_EMPTY_EXISTS: {
141
+ statement: '`exists(...)` declares at least one variable Node.',
142
+ document: UNEXAMINED,
143
+ },
144
+ BUILDER_POLICY_INPUT: {
145
+ statement: 'A Policy input is one direct required field holding one Node path.',
146
+ document: UNEXAMINED,
147
+ },
148
+ BUILDER_POLICY_REF: {
149
+ statement: 'A Policy `ref(...)` names one local or direct-dependency Definition, Function, Method, Policy, View or Core Node.',
150
+ document: UNEXAMINED,
151
+ },
152
+ BUILDER_POLICY_SELF: {
153
+ statement: '`self` is available only to a non-static Node Method.',
154
+ document: UNEXAMINED,
155
+ },
156
+ BUILDER_PROPERTY_IMMUTABLE_INVALID: {
157
+ statement: '`immutable` is `create` or `once`.',
158
+ document: { holds: 'refused', admission: ['STRUCTURE_VALUE'] },
159
+ },
160
+ BUILDER_REFERENCE_CYCLE: {
161
+ statement: 'A lazy reference resolves without reaching itself.',
162
+ document: UNSAYABLE,
163
+ },
164
+ BUILDER_REFERENCE_KIND: {
165
+ statement: 'A reference names a Class of the kind its position takes.',
166
+ document: { holds: 'refused', admission: ['DV_CLASS_KIND'] },
167
+ },
168
+ BUILDER_REFERENCE_MISSING: {
169
+ statement: 'A local reference names a Definition the Domain declares.',
170
+ document: { holds: 'refused', admission: ['DV_REF_RESOLVES'] },
171
+ },
172
+ BUILDER_UNIQUE_PROPERTY: {
173
+ statement: 'A key names a Property its Class holds.',
174
+ document: { holds: 'refused', admission: ['DV_NODE_UNIQUE'] },
175
+ },
176
+ BUILDER_UNKNOWN_FIELD: {
177
+ statement: 'An authoring input holds no field its builder does not read.',
178
+ document: { holds: 'refused', admission: ['STRUCTURE_UNKNOWN_FIELD'] },
179
+ },
180
+ BUILDER_UNOWNED_REFERENCE: {
181
+ statement: 'A reference to an authoring handle names a handle some Domain owns.',
182
+ document: UNSAYABLE,
183
+ },
184
+ BUILDER_VIEW: {
185
+ statement: 'An entry of `views` is created by `view(...)`, which names no target.',
186
+ document: UNEXAMINED,
187
+ },
188
+ ZOD_SCHEMA_NOT_LOSSLESS: {
189
+ statement: 'A Zod schema is one Draft 2020-12 can state with the same acceptance. A document states a value schema directly.',
190
+ document: UNSAYABLE,
191
+ },
192
+ });
@@ -14,5 +14,7 @@ export declare function decode(input: string | Uint8Array): Bundle;
14
14
  export declare function encode(bundle: Bundle): Uint8Array;
15
15
  export declare function serialize(bundle: Bundle): string;
16
16
  export { DOMAIN_BUNDLE_FORMAT as FORMAT, DOMAIN_BUNDLE_VERSION as VERSION } from './model.js';
17
+ export { BUNDLE_RULES as RULES } from './rule.js';
18
+ export type { BundleRule as Rule } from './rule.js';
17
19
  export { BundleError as Error } from './diagnostic.js';
18
20
  export type { BundleDiagnostic as Diagnostic, BundleDiagnosticCode as DiagnosticCode, } from './diagnostic.js';
@@ -17,4 +17,5 @@ export function serialize(bundle) {
17
17
  return serializeDomainSchemaBundle(bundle);
18
18
  }
19
19
  export { DOMAIN_BUNDLE_FORMAT as FORMAT, DOMAIN_BUNDLE_VERSION as VERSION } from './model.js';
20
+ export { BUNDLE_RULES as RULES } from './rule.js';
20
21
  export { BundleError as Error } from './diagnostic.js';
@@ -0,0 +1,14 @@
1
+ import type { SchemaDiagnosticCode } from '../schema/diagnostic.js';
2
+ import type { BundleDiagnosticCode } from './diagnostic.js';
3
+ /** The rule one diagnostic code of a Bundle reports. */
4
+ export interface BundleRule {
5
+ /** The positions its diagnostics point at, as the positions of `schema.Rule`. */
6
+ readonly positions: readonly [string, ...string[]];
7
+ /** The rule, in one plain sentence. */
8
+ readonly statement: string;
9
+ }
10
+ /**
11
+ * Every diagnostic code a Bundle owns with the rule it reports, frozen. A refused Schema of a
12
+ * Bundle answers with the codes of `schema.RULES`, rebased under its place in the Bundle.
13
+ */
14
+ export declare const BUNDLE_RULES: Readonly<Record<Exclude<BundleDiagnosticCode, SchemaDiagnosticCode>, BundleRule>>;
@@ -0,0 +1,41 @@
1
+ import { deepFreeze } from '../language/freeze.js';
2
+ import { DOMAIN_BUNDLE_FORMAT, DOMAIN_BUNDLE_VERSION } from './model.js';
3
+ const PIN = ['/root/dependencies/{alias}', '/closure/{index}/dependencies/{alias}'];
4
+ /**
5
+ * Every diagnostic code a Bundle owns with the rule it reports, frozen. A refused Schema of a
6
+ * Bundle answers with the codes of `schema.RULES`, rebased under its place in the Bundle.
7
+ */
8
+ export const BUNDLE_RULES = deepFreeze({
9
+ BUNDLE_STRUCTURE: {
10
+ positions: ['', '/{field}'],
11
+ statement: 'A Bundle is an object holding `format`, `version`, `root` and `closure` and no other field, its `closure` an array.',
12
+ },
13
+ UNSUPPORTED_BUNDLE_FORMAT: {
14
+ positions: ['/format'],
15
+ statement: `The \`format\` of a Bundle is \`${DOMAIN_BUNDLE_FORMAT}\`.`,
16
+ },
17
+ UNSUPPORTED_BUNDLE_VERSION: {
18
+ positions: ['/version'],
19
+ statement: `The \`version\` of a Bundle is \`${DOMAIN_BUNDLE_VERSION}\`.`,
20
+ },
21
+ BUNDLE_ROOT_DUPLICATED: {
22
+ positions: ['/closure/{index}'],
23
+ statement: 'The closure of a Bundle does not hold its root.',
24
+ },
25
+ BUNDLE_SCHEMA_DUPLICATED: {
26
+ positions: ['/closure/{index}'],
27
+ statement: 'The closure of a Bundle holds each origin at each revision once.',
28
+ },
29
+ BUNDLE_CLOSURE_EXTRA: {
30
+ positions: ['/closure/{index}'],
31
+ statement: 'The closure of a Bundle holds only Schemas its root reaches through exact pins.',
32
+ },
33
+ BUNDLE_CLOSURE_MISSING: {
34
+ positions: PIN,
35
+ statement: 'The closure of a Bundle holds the exact revision of every pin its root reaches.',
36
+ },
37
+ BUNDLE_REVISION_COHERENCE: {
38
+ positions: PIN,
39
+ statement: 'The pins a root reaches ask one revision of each origin.',
40
+ },
41
+ });
@@ -3,6 +3,20 @@ import { type CompiledDiagnosticCode } from '../diagnostic.js';
3
3
  export { appendPointer as pointer } from '../../language/value/syntax/pointer.js';
4
4
  /** Report a structural compiled-input violation with its stable diagnostic code. */
5
5
  export declare function invalid(label: string, code?: CompiledDiagnosticCode, path?: string): never;
6
+ /** How a refusal names the Policy checks of each use site and, once typed, their object contract. */
7
+ export declare const POLICY_CHECK_SITE: {
8
+ readonly callable: {
9
+ readonly name: 'Callable Policy';
10
+ readonly objects: 'the callable object contract';
11
+ };
12
+ readonly class: {
13
+ readonly name: 'Class rule';
14
+ readonly objects: 'the Class rule object contract';
15
+ };
16
+ readonly create: {
17
+ readonly name: 'Create rule';
18
+ };
19
+ };
6
20
  /** Report a contextual compiled-language violation at its original source pointer. */
7
21
  export declare function fail(pointer: string, message: string): never;
8
22
  /** Cross the portable value boundary with a compiled document, whose refusal is answered as one. */
@@ -6,6 +6,12 @@ export { appendPointer as pointer } from '../../language/value/syntax/pointer.js
6
6
  export function invalid(label, code = 'COMPILED_STRUCTURE_INVALID', path = '') {
7
7
  return invalidCompiled(code, `Invalid compiled Schema ${label}.`, path);
8
8
  }
9
+ /** How a refusal names the Policy checks of each use site and, once typed, their object contract. */
10
+ export const POLICY_CHECK_SITE = {
11
+ callable: { name: 'Callable Policy', objects: 'the callable object contract' },
12
+ class: { name: 'Class rule', objects: 'the Class rule object contract' },
13
+ create: { name: 'Create rule' },
14
+ };
9
15
  /** Report a contextual compiled-language violation at its original source pointer. */
10
16
  export function fail(pointer, message) {
11
17
  return invalidCompiled('COMPILED_SOURCE_INVALID', message, pointer);
@@ -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,8 +27,7 @@ export function validateCallablePolicy(context, entry, expression, inputIndex, f
27
27
  }
28
28
  return;
29
29
  }
30
- const children = 'allOf' in expression ? expression.allOf : expression.anyOf;
31
- 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}`));
32
31
  }
33
32
  function isSingleNodePathField(context, entry, inputIndex, field) {
34
33
  const rootValue = entry.values[inputIndex]?.nodes[entry.values[inputIndex].root]?.schema;