@astrale-os/kernel-dsl 1.0.0-beta.34 → 1.0.0-beta.36

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 (59) hide show
  1. package/dist/v1/builder/lowering/schema/lifetime.js +3 -5
  2. package/dist/v1/builder/lowering/value/zod.js +3 -1
  3. package/dist/v1/compiled/admission/semantics/policy/callable.js +7 -29
  4. package/dist/v1/compiled/admission/semantics/policy/parity.js +4 -11
  5. package/dist/v1/compiled/admission/wire/core.js +2 -6
  6. package/dist/v1/compiled/admission/wire/property.js +6 -19
  7. package/dist/v1/domain/projection/classes.js +5 -7
  8. package/dist/v1/language/class/inheritance.d.ts +26 -2
  9. package/dist/v1/language/class/inheritance.js +63 -40
  10. package/dist/v1/language/class/lifetime.d.ts +7 -15
  11. package/dist/v1/language/class/lifetime.js +19 -40
  12. package/dist/v1/language/class/property-values.d.ts +13 -0
  13. package/dist/v1/language/class/property-values.js +35 -4
  14. package/dist/v1/language/class/unique.d.ts +1 -1
  15. package/dist/v1/language/class/unique.js +3 -13
  16. package/dist/v1/language/index.d.ts +2 -0
  17. package/dist/v1/language/index.js +2 -0
  18. package/dist/v1/language/limits.d.ts +3 -1
  19. package/dist/v1/language/limits.js +3 -1
  20. package/dist/v1/language/policy/analysis/branches.d.ts +5 -1
  21. package/dist/v1/language/policy/analysis/branches.js +21 -5
  22. package/dist/v1/language/policy/analysis/budgets.d.ts +2 -0
  23. package/dist/v1/language/policy/analysis/budgets.js +7 -1
  24. package/dist/v1/language/policy/analysis/typing.d.ts +9 -1
  25. package/dist/v1/language/policy/analysis/typing.js +44 -49
  26. package/dist/v1/language/state/topology.d.ts +24 -0
  27. package/dist/v1/language/state/topology.js +60 -19
  28. package/dist/v1/language/validation/rule.js +1 -1
  29. package/dist/v1/language/value/evaluate/evaluator.js +4 -0
  30. package/dist/v1/language/value/evaluate/validity.optimization.js +4 -1
  31. package/dist/v1/language/value/inclusion/evidence.js +1 -1
  32. package/dist/v1/language/value/model/date.d.ts +8 -0
  33. package/dist/v1/language/value/model/date.js +19 -0
  34. package/dist/v1/language/value/model/instant.d.ts +0 -1
  35. package/dist/v1/language/value/model/instant.js +2 -15
  36. package/dist/v1/language/value/ordering.d.ts +6 -2
  37. package/dist/v1/language/value/ordering.js +36 -8
  38. package/dist/v1/language/value/profile/rules.js +3 -2
  39. package/dist/v1/language/value/profile/vocabulary.d.ts +1 -1
  40. package/dist/v1/language/value/profile/vocabulary.js +5 -0
  41. package/dist/v1/language/value/syntax/node-path/schema.d.ts +7 -0
  42. package/dist/v1/language/value/syntax/node-path/schema.js +32 -0
  43. package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +3 -0
  44. package/dist/v1/schema/compatibility/comparators/classes.js +10 -21
  45. package/dist/v1/schema/enforcement/derived.d.ts +5 -0
  46. package/dist/v1/schema/enforcement/derived.js +7 -2
  47. package/dist/v1/schema/enforcement/dispose.d.ts +16 -6
  48. package/dist/v1/schema/enforcement/dispose.js +16 -6
  49. package/dist/v1/schema/resolution/origins.js +3 -5
  50. package/dist/v1/schema/rule.js +4 -3
  51. package/dist/v1/schema/validation/class.js +39 -47
  52. package/dist/v1/schema/validation/policy/budgets.js +1 -0
  53. package/dist/v1/schema/validation/policy/typing.js +7 -20
  54. package/dist/v1/schema/validation/policy/uses.js +5 -25
  55. package/dist/v1/schema/validation/value-api.d.ts +2 -1
  56. package/dist/v1/schema/validation/value-api.js +2 -1
  57. package/dist/v1/schema/validation/value.json-schema.js +3 -3
  58. package/dist/value/types.d.ts +1 -1
  59. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ /** A civil day in the proleptic Gregorian calendar, including year zero. */
2
+ export declare const date: Readonly<{
3
+ readonly type: 'string';
4
+ readonly 'x-astrale-value-kind': 'date';
5
+ }>;
6
+ export declare function isDateValue(input: unknown): input is string;
7
+ /** The fields are unsigned integers read from the fixed-width date or instant grammar. */
8
+ export declare function isCalendarDay(year: number, month: number, day: number): boolean;
@@ -0,0 +1,19 @@
1
+ /** A civil day in the proleptic Gregorian calendar, including year zero. */
2
+ export const date = Object.freeze({ type: 'string', 'x-astrale-value-kind': 'date' });
3
+ const DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/u;
4
+ export function isDateValue(input) {
5
+ if (typeof input !== 'string')
6
+ return false;
7
+ const match = DATE_PATTERN.exec(input);
8
+ return match !== null && isCalendarDay(Number(match[1]), Number(match[2]), Number(match[3]));
9
+ }
10
+ /** The fields are unsigned integers read from the fixed-width date or instant grammar. */
11
+ export function isCalendarDay(year, month, day) {
12
+ if (month < 1 || month > 12 || day < 1)
13
+ return false;
14
+ if (month === 2) {
15
+ const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
16
+ return day <= (leap ? 29 : 28);
17
+ }
18
+ return day <= (month === 4 || month === 6 || month === 9 || month === 11 ? 30 : 31);
19
+ }
@@ -1,4 +1,3 @@
1
- /** Exact portable UTC millisecond Instant used by the V1 value-schema dialect. */
2
1
  export declare const instant: Readonly<{
3
2
  readonly type: 'string';
4
3
  readonly 'x-astrale-value-kind': 'instant';
@@ -1,3 +1,4 @@
1
+ import { isCalendarDay } from './date.js';
1
2
  /** Exact portable UTC millisecond Instant used by the V1 value-schema dialect. */
2
3
  /** Canonical value-language annotation for an Instant string. */
3
4
  const INSTANT_VALUE_KIND = 'instant';
@@ -19,19 +20,5 @@ export function isInstantValue(input) {
19
20
  const hour = Number(match[4]);
20
21
  const minute = Number(match[5]);
21
22
  const second = Number(match[6]);
22
- return (month >= 1 &&
23
- month <= 12 &&
24
- day >= 1 &&
25
- day <= daysInMonth(year, month) &&
26
- hour <= 23 &&
27
- minute <= 59 &&
28
- second <= 59);
29
- }
30
- function daysInMonth(year, month) {
31
- if (month === 2)
32
- return isLeapYear(year) ? 29 : 28;
33
- return month === 4 || month === 6 || month === 9 || month === 11 ? 30 : 31;
34
- }
35
- function isLeapYear(year) {
36
- return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
23
+ return isCalendarDay(year, month, day) && hour <= 23 && minute <= 59 && second <= 59;
37
24
  }
@@ -3,7 +3,9 @@ import type { ValueProgram } from './compile/model.js';
3
3
  import type { CompiledInstanceSchema } from './evaluate/types.js';
4
4
  import type { JsonSchema } from './model/schema.js';
5
5
  import type { ValueSchemaRegistry } from './reference/registry.js';
6
- export type OrderingKind = 'boolean' | 'number' | 'string' | 'instant';
6
+ export type OrderingKind = 'boolean' | 'number' | 'string' | 'instant' | 'date';
7
+ /** Whether an external rank or literal belongs to a declared ordering domain. */
8
+ export declare function isOrderingValue(input: unknown, kind: OrderingKind): input is boolean | number | string;
7
9
  /**
8
10
  * Classify a schema only when every value it can admit belongs to one sortable scalar domain.
9
11
  *
@@ -22,8 +24,10 @@ export declare const VALUE_KINDS: readonly ValueKind[];
22
24
  /**
23
25
  * The value kind of a property schema (page "Fondations Query v7", § Atoms et value kinds, Y4):
24
26
  * the one kind its non-null values admit, `null` being a point of every kind. An annotated
25
- * instant is `instant`, a finite set of strings `enum`, an array of unique items `set`; an
27
+ * instant is `instant`, a declared day `date`, a finite set of strings `enum`, an array of unique items `set`; an
26
28
  * ambiguous union, an object, an array with repetitions or a domain without values is `json`.
27
29
  */
28
30
  export declare function classifyValueKind(contract: JsonSchema, registry: ValueSchemaRegistry): ValueKind;
31
+ /** Derive the non-null kind of a resolved Property, following its bound references. */
32
+ export declare function valueProgramKind(program: ValueProgram): ValueKind;
29
33
  export declare function classifyPreparedValueKind(compiled: CompiledInstanceSchema): ValueKind;
@@ -1,7 +1,24 @@
1
1
  import { runSuspended } from '../suspended.js';
2
2
  import { loadValueProgram } from './compile/load.js';
3
3
  import { prepareValueSchema } from './evaluate/preparation.js';
4
+ import { isDateValue } from './model/date.js';
5
+ import { isInstantValue } from './model/instant.js';
4
6
  import { schemaList } from './syntax/walk.js';
7
+ /** Whether an external rank or literal belongs to a declared ordering domain. */
8
+ export function isOrderingValue(input, kind) {
9
+ switch (kind) {
10
+ case 'boolean':
11
+ return typeof input === 'boolean';
12
+ case 'number':
13
+ return typeof input === 'number' && Number.isFinite(input);
14
+ case 'string':
15
+ return typeof input === 'string';
16
+ case 'date':
17
+ return isDateValue(input);
18
+ case 'instant':
19
+ return isInstantValue(input);
20
+ }
21
+ }
5
22
  const ALL_JSON_KINDS = new Set([
6
23
  'null',
7
24
  'boolean',
@@ -32,7 +49,11 @@ export function classifyPreparedOrdering(compiled) {
32
49
  if (candidates.size !== 1)
33
50
  return undefined;
34
51
  const [kind] = candidates;
35
- return kind === 'boolean' || kind === 'number' || kind === 'string' || kind === 'instant'
52
+ return kind === 'boolean' ||
53
+ kind === 'number' ||
54
+ kind === 'string' ||
55
+ kind === 'instant' ||
56
+ kind === 'date'
36
57
  ? kind
37
58
  : undefined;
38
59
  }
@@ -40,6 +61,7 @@ const valueKinds = {
40
61
  text: true,
41
62
  number: true,
42
63
  instant: true,
64
+ date: true,
43
65
  enum: true,
44
66
  boolean: true,
45
67
  set: true,
@@ -53,7 +75,7 @@ export const VALUE_KINDS = Object.freeze(Object.keys(valueKinds));
53
75
  /**
54
76
  * The value kind of a property schema (page "Fondations Query v7", § Atoms et value kinds, Y4):
55
77
  * the one kind its non-null values admit, `null` being a point of every kind. An annotated
56
- * instant is `instant`, a finite set of strings `enum`, an array of unique items `set`; an
78
+ * instant is `instant`, a declared day `date`, a finite set of strings `enum`, an array of unique items `set`; an
57
79
  * ambiguous union, an object, an array with repetitions or a domain without values is `json`.
58
80
  */
59
81
  export function classifyValueKind(contract, registry) {
@@ -62,6 +84,10 @@ export function classifyValueKind(contract, registry) {
62
84
  return 'json';
63
85
  return classifyPreparedValueKind(prepared.value);
64
86
  }
87
+ /** Derive the non-null kind of a resolved Property, following its bound references. */
88
+ export function valueProgramKind(program) {
89
+ return classifyPreparedValueKind(loadValueProgram(program));
90
+ }
65
91
  export function classifyPreparedValueKind(compiled) {
66
92
  const candidates = new Set(candidatesOf(compiled));
67
93
  candidates.delete('null');
@@ -73,6 +99,7 @@ export function classifyPreparedValueKind(compiled) {
73
99
  return 'text';
74
100
  case 'number':
75
101
  case 'boolean':
102
+ case 'date':
76
103
  case 'instant':
77
104
  case 'enum':
78
105
  case 'set':
@@ -107,10 +134,11 @@ function* classifySchema(compiled, location, read) {
107
134
  const schema = location.schema;
108
135
  let candidates = ALL_JSON_KINDS;
109
136
  if (Object.hasOwn(schema, 'x-astrale-value-kind')) {
110
- if (schema['x-astrale-value-kind'] !== 'instant' || schema.type !== 'string') {
137
+ const kind = schema['x-astrale-value-kind'];
138
+ if ((kind !== 'instant' && kind !== 'date') || schema.type !== 'string') {
111
139
  return new Set();
112
140
  }
113
- candidates = intersect(candidates, new Set(['instant']));
141
+ candidates = intersect(candidates, new Set([kind]));
114
142
  }
115
143
  const declaredTypes = typesOf(schema.type);
116
144
  if (declaredTypes !== undefined)
@@ -201,6 +229,8 @@ function meet(left, right) {
201
229
  * orders as instants.
202
230
  */
203
231
  const NARROWER = [
232
+ ['date', 'string'],
233
+ ['date', 'enum'],
204
234
  ['instant', 'string'],
205
235
  ['enum', 'string'],
206
236
  ['instant', 'enum'],
@@ -222,12 +252,10 @@ function union(left, right) {
222
252
  }
223
253
  /** A kind absorbs its subsets; strings of two subsets are strings. */
224
254
  function normalize(input) {
225
- if (input.has('enum') && input.has('instant')) {
226
- input.delete('enum');
227
- input.delete('instant');
255
+ if (input.has('enum') && (input.has('instant') || input.has('date')))
228
256
  input.add('string');
229
- }
230
257
  if (input.has('string')) {
258
+ input.delete('date');
231
259
  input.delete('instant');
232
260
  input.delete('enum');
233
261
  }
@@ -58,8 +58,9 @@ function validateValueKind(schema, context, depth, pointer, diagnostics) {
58
58
  diagnostics.push(diagnostic('VS_VALUE_KIND', `${pointer}/x-astrale-value-kind`, 'blob must be the exact schema.values.blob output at the root of a Node property.'));
59
59
  }
60
60
  }
61
- else if (schema['x-astrale-value-kind'] !== 'instant' || schema.type !== 'string') {
62
- diagnostics.push(diagnostic('VS_VALUE_KIND', `${pointer}/x-astrale-value-kind`, 'x-astrale-value-kind is exactly instant and requires type string at the same schema location.'));
61
+ else if ((schema['x-astrale-value-kind'] !== 'instant' && schema['x-astrale-value-kind'] !== 'date') ||
62
+ schema.type !== 'string') {
63
+ diagnostics.push(diagnostic('VS_VALUE_KIND', `${pointer}/x-astrale-value-kind`, 'Expected date or instant beside type string, a blob Property, or a callable input file.'));
63
64
  }
64
65
  }
65
66
  function isCanonicalBlobSchema(input) {
@@ -32,5 +32,5 @@ export interface DeclaredValueKind {
32
32
  readonly statement: string;
33
33
  }
34
34
  /** The value kinds `x-astrale-value-kind` declares; it admits no other value. */
35
- export declare const DECLARED_VALUE_KINDS: Readonly<Record<'instant' | 'blob' | 'file', DeclaredValueKind>>;
35
+ export declare const DECLARED_VALUE_KINDS: Readonly<Record<'instant' | 'date' | 'blob' | 'file', DeclaredValueKind>>;
36
36
  export {};
@@ -108,6 +108,11 @@ export const DECLARED_VALUE_KINDS = Object.freeze({
108
108
  placement: 'any',
109
109
  statement: 'A UTC instant written YYYY-MM-DDTHH:mm:ss.sssZ, in the years 0000 to 9999, whose text order is its chronological order.',
110
110
  }),
111
+ date: Object.freeze({
112
+ type: 'string',
113
+ placement: 'any',
114
+ statement: 'A calendar day written YYYY-MM-DD, in proleptic Gregorian years 0000 to 9999, whose text order is its chronological order.',
115
+ }),
111
116
  blob: Object.freeze({
112
117
  type: 'object',
113
118
  placement: 'node-property',
@@ -3,3 +3,10 @@ export declare const GRAPH_NODE_PATH_SCHEMA_ID: 'https://schemas.astrale.ai/grap
3
3
  /** Exact locally bundled artifact owned by graph/path/language's governed JSON Schema. */
4
4
  export declare const graphNodePathSchema: JsonSchemaObject;
5
5
  export declare function hasNodePathAnnotation(schema: JsonSchema): boolean;
6
+ /**
7
+ * The `accepts` of `field` where the callable input `input` binds it to one Node: a direct required
8
+ * single-Node Path field of a closed object input, neither of them carrying a combinator, so that
9
+ * the field's own annotation alone states the Classes of its Node. Otherwise the input binds no Node
10
+ * there: `undefined`. Source and compiled admission both read a Policy input binding through it.
11
+ */
12
+ export declare function singleNodePathFieldAccepts(input: unknown, field: string): readonly unknown[] | undefined;
@@ -16,3 +16,35 @@ export function hasNodePathAnnotation(schema) {
16
16
  schema.$ref === GRAPH_NODE_PATH_SCHEMA_ID &&
17
17
  Object.hasOwn(schema, 'x-astrale-path'));
18
18
  }
19
+ /**
20
+ * The `accepts` of `field` where the callable input `input` binds it to one Node: a direct required
21
+ * single-Node Path field of a closed object input, neither of them carrying a combinator, so that
22
+ * the field's own annotation alone states the Classes of its Node. Otherwise the input binds no Node
23
+ * there: `undefined`. Source and compiled admission both read a Policy input binding through it.
24
+ */
25
+ export function singleNodePathFieldAccepts(input, field) {
26
+ if (!isJsonObject(input) || hasCombinator(input))
27
+ return undefined;
28
+ const { properties, required } = input;
29
+ if (input.type !== 'object' ||
30
+ input.additionalProperties !== false ||
31
+ !Array.isArray(required) ||
32
+ !required.includes(field) ||
33
+ !isJsonObject(properties) ||
34
+ !Object.hasOwn(properties, field))
35
+ return undefined;
36
+ const schema = properties[field];
37
+ if (!isJsonObject(schema) || hasCombinator(schema) || schema.$ref !== GRAPH_NODE_PATH_SCHEMA_ID)
38
+ return undefined;
39
+ const annotation = schema['x-astrale-path'];
40
+ return isJsonObject(annotation) &&
41
+ annotation.target === 'node' &&
42
+ annotation.cardinality === 'one' &&
43
+ Array.isArray(annotation.accepts) &&
44
+ annotation.accepts.length > 0
45
+ ? annotation.accepts
46
+ : undefined;
47
+ }
48
+ function hasCombinator(schema) {
49
+ return ['allOf', 'anyOf', 'oneOf', 'not', 'if', 'then', 'else'].some((keyword) => Object.hasOwn(schema, keyword));
50
+ }
@@ -2509,6 +2509,7 @@
2509
2509
  "x-astrale-value-kind": {
2510
2510
  "enum": [
2511
2511
  "instant",
2512
+ "date",
2512
2513
  "file"
2513
2514
  ]
2514
2515
  }
@@ -2566,6 +2567,7 @@
2566
2567
  "x-astrale-value-kind": {
2567
2568
  "enum": [
2568
2569
  "instant",
2570
+ "date",
2569
2571
  "blob",
2570
2572
  "file"
2571
2573
  ]
@@ -2593,6 +2595,7 @@
2593
2595
  "x-astrale-value-kind": {
2594
2596
  "enum": [
2595
2597
  "instant",
2598
+ "date",
2596
2599
  "file"
2597
2600
  ]
2598
2601
  }
@@ -1,4 +1,5 @@
1
1
  import { compareUnicode } from '../../../addressing/ordering.js';
2
+ import { contractEndpoints, walkAncestry, } from '../../../language/class/inheritance.js';
2
3
  import { compareEdgeUniqueTuples, coveringEdgeUniqueTuples, } from '../../../language/class/unique.js';
3
4
  import { deepFreeze } from '../../../language/freeze.js';
4
5
  import { isClassRuleChecks } from '../../../language/policy/model/policy.js';
@@ -62,20 +63,19 @@ export function edgeEndpoints(context, coordinate) {
62
63
  const declaration = context.schemas.get(coordinate.ref.origin)?.classes[coordinate.ref.name];
63
64
  if (declaration?.kind !== 'edge')
64
65
  return undefined;
65
- const accepts = ({ accepts: refs }) => refs.map(keyForDefinitionRef).sort(compareUnicode);
66
+ const accepts = ({ endpoint }) => endpoint.accepts.map(keyForDefinitionRef).sort(compareUnicode);
67
+ const [first, second] = contractEndpoints(declaration);
66
68
  return deepFreeze(declaration.orientation === 'directed'
67
69
  ? {
68
70
  coordinate: 'class',
69
71
  orientation: 'directed',
70
- source: accepts(declaration.endpoints.source),
71
- target: accepts(declaration.endpoints.target),
72
+ source: accepts(first),
73
+ target: accepts(second),
72
74
  }
73
75
  : {
74
76
  coordinate: 'class',
75
77
  orientation: 'undirected',
76
- endpoints: declaration.endpoints
77
- .map(accepts)
78
- .sort((left, right) => compareUnicode(left.join('\n'), right.join('\n'))),
78
+ endpoints: [accepts(first), accepts(second)].sort((left, right) => compareUnicode(left.join('\n'), right.join('\n'))),
79
79
  });
80
80
  }
81
81
  export function propertyMeaning(field) {
@@ -88,21 +88,10 @@ export function propertyMeaning(field) {
88
88
  });
89
89
  }
90
90
  function ancestorKeys(context, ref) {
91
- const seen = new Set();
92
- const visit = (current) => {
93
- const declaration = context.schemas.get(current.origin)?.classes[current.name];
94
- if (declaration === undefined)
95
- return;
96
- for (const parent of declaration.extends) {
97
- const key = keyForDefinitionRef(parent);
98
- if (seen.has(key))
99
- continue;
100
- seen.add(key);
101
- visit(parent);
102
- }
103
- };
104
- visit(ref);
105
- return [...seen].sort(compareUnicode);
91
+ // Each declared parent ref is walked once; one its schema lacks still names an ancestor.
92
+ const parentsOf = (current) => context.schemas.get(current.origin)?.classes[current.name]?.extends ?? [];
93
+ const keys = new Set(Array.from(walkAncestry(parentsOf(ref), parentsOf), keyForDefinitionRef));
94
+ return [...keys].sort(compareUnicode);
106
95
  }
107
96
  /**
108
97
  * The uniqueness tuples covering an Edge Class (`coveringEdgeUniqueTuples`): those it and each of
@@ -124,6 +124,11 @@ declare const rows: {
124
124
  statement: string;
125
125
  laws: [string, string];
126
126
  };
127
+ VALUE_DATE: {
128
+ subjects: ["property.schema", "value"];
129
+ statement: string;
130
+ laws: [string];
131
+ };
127
132
  VALUE_INSTANT: {
128
133
  subjects: ["property.schema", "value"];
129
134
  statement: string;
@@ -62,7 +62,7 @@ const rows = {
62
62
  },
63
63
  PROPERTY_ORDERING: {
64
64
  subjects: ['property.schema'],
65
- statement: 'A Property orders as boolean, number, string or instant only when every value its schema admits is of that one scalar kind, as a conservative reading of the schema shows. A schema that also admits null, an array or an object, or one the reading does not settle, such as one that rules the other kinds out through `not` or `if`, gives it no ordering. Only the schema decides: no annotation keyword, example or stored value does.',
65
+ statement: 'A Property orders as boolean, number, string, instant or date only when every value its schema admits is of that one scalar kind, as a conservative reading of the schema shows. A schema that also admits null, an array or an object, or one the reading does not settle, such as one that rules the other kinds out through `not` or `if`, gives it no ordering. Only the schema decides: no annotation keyword, example or stored value does.',
66
66
  laws: ['VS-ORDERING-CLASSIFICATION', 'COMPILED-PROPERTY-ORDERING'],
67
67
  },
68
68
  AUTO_EXPLICIT: {
@@ -135,6 +135,11 @@ const rows = {
135
135
  statement: 'The canonical text of a value is its RFC 8785 JSON. Decoding reads exactly one strict JSON value, and refuses a duplicate name, a number past the binary64 range and one that resolves to negative zero. Any other number reads as its nearest binary64, as `1e-999` reads as 0.',
136
136
  laws: ['VALUE-CANONICAL', 'VALUE-DECODE'],
137
137
  },
138
+ VALUE_DATE: {
139
+ subjects: ['property.schema', 'value'],
140
+ statement: 'A calendar date is an existing proleptic Gregorian day written YYYY-MM-DD, from year 0000 through 9999. Code-point order gives chronological order.',
141
+ laws: ['VS-VALUE-KIND'],
142
+ },
138
143
  VALUE_INSTANT: {
139
144
  subjects: ['property.schema', 'value'],
140
145
  statement: 'An instant is a proleptic-Gregorian YYYY-MM-DDTHH:mm:ss.sssZ from year 0000 through 9999, in UTC, with three millisecond digits and no leap second. Code-point order of its text is chronological order, and two different texts are two different milliseconds.',
@@ -172,7 +177,7 @@ const rows = {
172
177
  },
173
178
  DEFINITION_PROJECTION: {
174
179
  subjects: ['fact.projection'],
175
- statement: 'Installing a Domain projects each of its Definitions as one Node at its canonical NodePath with exactly one `of_domain` Edge, its member locator. The Domain Node holds the name and, as `iconSmall`, `iconMedium` or `iconLarge`, the drawing of each size its icon declares, and one `entrypoint` Edge joins it to the View it declares, none without one. A Core Edge endpoint that is no Core Node is a path into the projected declarations.',
180
+ statement: 'Installing a Domain projects each of its Definitions as one Node at its canonical NodePath with exactly one `of_domain` Edge, its member locator. The Domain Node holds the name, as `Named.name` and as the deprecated `Domain.name`, and, as `iconSmall`, `iconMedium` or `iconLarge`, the drawing of each size its icon declares, and one `entrypoint` Edge joins it to the View it declares, none without one. A Core Edge endpoint that is no Core Node is a path into the projected declarations.',
176
181
  laws: [
177
182
  'KS-DECLARATION-LOCATORS',
178
183
  'KS-PROJECTION',
@@ -36,10 +36,19 @@ export declare const DISPOSE: Readonly<{
36
36
  readonly reason: 'restricted-deletion';
37
37
  };
38
38
  };
39
- readonly statement: "An Edge of a Class that stays, the Kernel's aside, keeps a Node from leaving unless every role holding that Node at that end detaches: an end no role accepts it at restricts, in a Class read because a role of it restricts or accepted a Class the target no longer declares concrete. A Class a destructive change retires is read under its previous contract, any other under the target. The end is named by the previous orientation and its roles by the target, so an Edge Class such a change also makes undirected restricts a Core Node that leaves, whatever the target declares.";
39
+ readonly statement: "An Edge of a Class that stays, the Kernel's aside, in contract at a Node that leaves keeps that Node unless every role holding it at that end detaches: an end no role accepts it at restricts, in a Class read because a role of it restricts or accepted a Class the target no longer declares concrete. A Node a destructive change retires is read under its previous contract, any other under the target. The end is named by the previous orientation and its roles by the target, so an Edge Class such a change also makes undirected restricts a Core Node that leaves, whatever the target declares. An Edge out of contract keeps no Node, as DISPOSE.EDGE_OUT_OF_CONTRACT_CUT states.";
40
40
  readonly accepted: 'DV_EDGE_LIFETIME';
41
41
  readonly laws: readonly ["SD-LIFETIMES", "SD-REMOVED-CORE-REFERENCE"];
42
42
  };
43
+ readonly EDGE_OUT_OF_CONTRACT_CUT: {
44
+ readonly phase: 'dispose';
45
+ readonly layer: 'structure';
46
+ readonly subjects: readonly ["endpoint.accepts", "fact.edge"];
47
+ readonly does: 'apply';
48
+ readonly modes: readonly DisposeMode[];
49
+ readonly statement: 'An Edge of a Class that stays at a Node that leaves is out of contract when a role of its Class in the Registry in force does not accept the Class of the Node at its end, an earlier Kernel having let a lineage narrow below it. No Mutation locates it, and it goes with the Node whatever its lifetimes: the activation cuts it with its tombstone and keeps it, in one count and the first 20 in key order, as the cut of the Execution it serves, and refuses with no effect when it serves none.';
50
+ readonly laws: readonly ["SD-LIFETIMES", "SCHEMA-RETIREMENT-CUT"];
51
+ };
43
52
  readonly INSPECTION_EXCEEDED: {
44
53
  readonly phase: 'dispose';
45
54
  readonly layer: 'limit';
@@ -127,9 +136,9 @@ export declare const DISPOSE: Readonly<{
127
136
  readonly subjects: readonly ["fact.edge"];
128
137
  readonly does: 'apply';
129
138
  readonly modes: readonly ["destructive"];
130
- readonly statement: 'The activation deletes every Edge of a target Class at a retiring Node, and every Edge of a retiring Class at a Node it deletes, each with its tombstone.';
131
- readonly divergence: 'On PostgreSQL the cost follows the smaller of the retiring Nodes and the Edges of the Classes whose endpoint can hold them. Reference scans every Edge.';
132
- readonly laws: readonly ["SCHEMA-RETIREMENT-ISLAND"];
139
+ readonly statement: 'The activation deletes every Edge of a target Class at a retiring Node, and every Edge of a retiring Class at a Node it deletes, each with its tombstone. The uninstall reports, in one count and the first 20 in key order, every Edge of a target Class it deleted, at the activation or in the purge.';
140
+ readonly divergence: 'On PostgreSQL the cost follows the smaller of the retiring Nodes and the Edges of the concrete Edge Classes of the target. Reference scans every Edge.';
141
+ readonly laws: readonly ["SCHEMA-RETIREMENT-ISLAND", "SCHEMA-RETIREMENT-CUT"];
133
142
  };
134
143
  readonly RETIRING_FACT_UNREADABLE: {
135
144
  readonly phase: 'dispose';
@@ -137,7 +146,8 @@ export declare const DISPOSE: Readonly<{
137
146
  readonly subjects: readonly ["fact.schema"];
138
147
  readonly does: 'apply';
139
148
  readonly modes: readonly DisposeMode[];
140
- readonly statement: 'A retiring fact stays stored until the purge erases it, and no Query or Path reads it. A Mutation names none, and meets one only as DISPOSE.RETIRING_ID_HELD and DISPOSE.RETIRING_EDGE_ERASED state.';
149
+ readonly statement: 'A retiring fact stays stored until the purge erases it, and no Query or Path answers it, nor an Edge of a Class that stays an earlier Kernel left at a retiring Node. A Mutation names none, and meets one only as DISPOSE.RETIRING_ID_HELD and DISPOSE.RETIRING_EDGE_ERASED state.';
150
+ readonly divergence: 'Until the purge cuts such an Edge, Reference answers every read as if neither it nor its retiring Node were stored. PostgreSQL leaves it out of the extent of its Class, but refuses QUERY_RESULT_INVALID a Query whose Path reaches the retiring Node through it.';
141
151
  readonly laws: readonly ["SCHEMA-RETIREMENT-AT-ACTIVATION", "POSTGRES-RETIRING-ABSENT"];
142
152
  };
143
153
  readonly RETIRING_ID_HELD: {
@@ -171,7 +181,7 @@ export declare const DISPOSE: Readonly<{
171
181
  readonly subjects: readonly ["fact.schema"];
172
182
  readonly does: 'apply';
173
183
  readonly modes: readonly DisposeMode[];
174
- readonly statement: 'The purge erases retiring facts in batches of at most its limit, every Edge before every Node, each with the tombstone of an ordinary deletion. A batch sent again erases the next facts and changes nothing a read sees. A purge and the record of its end ask again when the Instance admission moved, up to four times.';
184
+ readonly statement: 'The purge erases retiring facts in batches of at most its limit, every Edge before every Node, each with the tombstone of an ordinary deletion. A retiring Node leaves once no Edge is at it: the purge first deletes the Edges of Classes that stay still there, which an earlier Kernel could leave, each counting against the limit and spread over as many batches as it takes, so every batch deletes a fact. A batch sent again erases the next facts. A purge and the record of its end ask again when the Instance admission moved, up to four times.';
175
185
  readonly laws: readonly ["SCHEMA-PURGE-BATCH", "SCHEMA-PURGE-REPLAY", "UNINSTALL-WORKFLOW-PURGE", "POSTGRES-RETIREMENT-PURGE", "SA-PURGE-EVIDENCE"];
176
186
  };
177
187
  readonly SERVICE_AWAITS_PURGE: {
@@ -30,10 +30,19 @@ export const DISPOSE = deepFreeze({
30
30
  does: 'refuse',
31
31
  modes: LEAVING,
32
32
  refusal: { requirement: { operation: 'remove-facts', reason: 'restricted-deletion' } },
33
- statement: "An Edge of a Class that stays, the Kernel's aside, keeps a Node from leaving unless every role holding that Node at that end detaches: an end no role accepts it at restricts, in a Class read because a role of it restricts or accepted a Class the target no longer declares concrete. A Class a destructive change retires is read under its previous contract, any other under the target. The end is named by the previous orientation and its roles by the target, so an Edge Class such a change also makes undirected restricts a Core Node that leaves, whatever the target declares.",
33
+ statement: "An Edge of a Class that stays, the Kernel's aside, in contract at a Node that leaves keeps that Node unless every role holding it at that end detaches: an end no role accepts it at restricts, in a Class read because a role of it restricts or accepted a Class the target no longer declares concrete. A Node a destructive change retires is read under its previous contract, any other under the target. The end is named by the previous orientation and its roles by the target, so an Edge Class such a change also makes undirected restricts a Core Node that leaves, whatever the target declares. An Edge out of contract keeps no Node, as DISPOSE.EDGE_OUT_OF_CONTRACT_CUT states.",
34
34
  accepted: 'DV_EDGE_LIFETIME',
35
35
  laws: ['SD-LIFETIMES', 'SD-REMOVED-CORE-REFERENCE'],
36
36
  },
37
+ EDGE_OUT_OF_CONTRACT_CUT: {
38
+ phase: 'dispose',
39
+ layer: 'structure',
40
+ subjects: ['endpoint.accepts', 'fact.edge'],
41
+ does: 'apply',
42
+ modes: LEAVING,
43
+ statement: 'An Edge of a Class that stays at a Node that leaves is out of contract when a role of its Class in the Registry in force does not accept the Class of the Node at its end, an earlier Kernel having let a lineage narrow below it. No Mutation locates it, and it goes with the Node whatever its lifetimes: the activation cuts it with its tombstone and keeps it, in one count and the first 20 in key order, as the cut of the Execution it serves, and refuses with no effect when it serves none.',
44
+ laws: ['SD-LIFETIMES', 'SCHEMA-RETIREMENT-CUT'],
45
+ },
37
46
  INSPECTION_EXCEEDED: {
38
47
  phase: 'dispose',
39
48
  layer: 'limit',
@@ -116,9 +125,9 @@ export const DISPOSE = deepFreeze({
116
125
  subjects: ['fact.edge'],
117
126
  does: 'apply',
118
127
  modes: ['destructive'],
119
- statement: 'The activation deletes every Edge of a target Class at a retiring Node, and every Edge of a retiring Class at a Node it deletes, each with its tombstone.',
120
- divergence: 'On PostgreSQL the cost follows the smaller of the retiring Nodes and the Edges of the Classes whose endpoint can hold them. Reference scans every Edge.',
121
- laws: ['SCHEMA-RETIREMENT-ISLAND'],
128
+ statement: 'The activation deletes every Edge of a target Class at a retiring Node, and every Edge of a retiring Class at a Node it deletes, each with its tombstone. The uninstall reports, in one count and the first 20 in key order, every Edge of a target Class it deleted, at the activation or in the purge.',
129
+ divergence: 'On PostgreSQL the cost follows the smaller of the retiring Nodes and the Edges of the concrete Edge Classes of the target. Reference scans every Edge.',
130
+ laws: ['SCHEMA-RETIREMENT-ISLAND', 'SCHEMA-RETIREMENT-CUT'],
122
131
  },
123
132
  RETIRING_FACT_UNREADABLE: {
124
133
  phase: 'dispose',
@@ -126,7 +135,8 @@ export const DISPOSE = deepFreeze({
126
135
  subjects: ['fact.schema'],
127
136
  does: 'apply',
128
137
  modes: RETIRING,
129
- statement: 'A retiring fact stays stored until the purge erases it, and no Query or Path reads it. A Mutation names none, and meets one only as DISPOSE.RETIRING_ID_HELD and DISPOSE.RETIRING_EDGE_ERASED state.',
138
+ statement: 'A retiring fact stays stored until the purge erases it, and no Query or Path answers it, nor an Edge of a Class that stays an earlier Kernel left at a retiring Node. A Mutation names none, and meets one only as DISPOSE.RETIRING_ID_HELD and DISPOSE.RETIRING_EDGE_ERASED state.',
139
+ divergence: 'Until the purge cuts such an Edge, Reference answers every read as if neither it nor its retiring Node were stored. PostgreSQL leaves it out of the extent of its Class, but refuses QUERY_RESULT_INVALID a Query whose Path reaches the retiring Node through it.',
130
140
  laws: ['SCHEMA-RETIREMENT-AT-ACTIVATION', 'POSTGRES-RETIRING-ABSENT'],
131
141
  },
132
142
  RETIRING_ID_HELD: {
@@ -155,7 +165,7 @@ export const DISPOSE = deepFreeze({
155
165
  subjects: ['fact.schema'],
156
166
  does: 'apply',
157
167
  modes: RETIRING,
158
- statement: 'The purge erases retiring facts in batches of at most its limit, every Edge before every Node, each with the tombstone of an ordinary deletion. A batch sent again erases the next facts and changes nothing a read sees. A purge and the record of its end ask again when the Instance admission moved, up to four times.',
168
+ statement: 'The purge erases retiring facts in batches of at most its limit, every Edge before every Node, each with the tombstone of an ordinary deletion. A retiring Node leaves once no Edge is at it: the purge first deletes the Edges of Classes that stay still there, which an earlier Kernel could leave, each counting against the limit and spread over as many batches as it takes, so every batch deletes a fact. A batch sent again erases the next facts. A purge and the record of its end ask again when the Instance admission moved, up to four times.',
159
169
  laws: [
160
170
  'SCHEMA-PURGE-BATCH',
161
171
  'SCHEMA-PURGE-REPLAY',
@@ -1,5 +1,6 @@
1
1
  import { compareDefinitionRefs, definitionRefIndex } from '../../addressing/ordering.js';
2
2
  import { isBinaryInput } from '../../language/callable/model/callable.js';
3
+ import { contractEndpoints } from '../../language/class/inheritance.js';
3
4
  import { checkBindings } from '../../language/policy/model/policy.js';
4
5
  import { CLASS_OPERATIONS, isClassRuleChecks, PolicyComposition, policyVariableClass, } from '../../language/policy/model/policy.js';
5
6
  import { isValueObject as isJsonObject } from '../../language/value/model/object.js';
@@ -68,11 +69,8 @@ export function collectClassPolicyRefs(declaration, add) {
68
69
  }
69
70
  }
70
71
  export function collectEndpointRefs(declaration, add) {
71
- const endpoints = declaration.orientation === 'directed'
72
- ? [declaration.endpoints.source, declaration.endpoints.target]
73
- : declaration.endpoints;
74
- endpoints[0].accepts.forEach((ref) => add(ref, 'endpoint'));
75
- endpoints[1].accepts.forEach((ref) => add(ref, 'endpoint'));
72
+ for (const { endpoint } of contractEndpoints(declaration))
73
+ endpoint.accepts.forEach((ref) => add(ref, 'endpoint'));
76
74
  }
77
75
  export function collectCallableRefs(declaration, add) {
78
76
  collectCallableContractRefs(declaration, add);
@@ -174,7 +174,7 @@ const DECLARED = {
174
174
  DV_EDGE_UNIQUE: {
175
175
  stage: 'context',
176
176
  positions: ['/classes/{class}/unique/{index}/{index}/property'],
177
- statement: 'Each Property a unique tuple of an Edge Class names is a Property of the Class, own or inherited, that is keyable: a string, number, boolean or instant that no automatic program writes.',
177
+ statement: 'Each Property a unique tuple of an Edge Class names is a Property of the Class, own or inherited, that is keyable: a string, number, boolean, instant or date that no automatic program writes.',
178
178
  },
179
179
  DV_ENTRYPOINT: {
180
180
  stage: 'rule',
@@ -210,7 +210,7 @@ const DECLARED = {
210
210
  DV_NODE_UNIQUE: {
211
211
  stage: 'context',
212
212
  positions: ['/classes/{class}/unique/{index}/{index}'],
213
- statement: 'Each Property a unique tuple of a Node Class names is a Property of the Class, own or inherited, that is keyable: a string, number, boolean or instant that no automatic program writes.',
213
+ statement: 'Each Property a unique tuple of a Node Class names is a Property of the Class, own or inherited, that is keyable: a string, number, boolean, instant or date that no automatic program writes.',
214
214
  },
215
215
  DV_PROPERTY_AUTO: {
216
216
  stage: 'context',
@@ -256,10 +256,11 @@ const DECLARED = {
256
256
  PL_BUDGET: {
257
257
  stage: 'rule',
258
258
  positions: ['/policies/{policy}', ...CHECKS],
259
- statement: `A Policy declares at most ${policy.inputs} Node inputs and stays within its budgets once expanded: pattern depth ${policy.patternDepth}, ${policy.normalizedBranches} normalized branches, ${policy.edgePredicates} Edge predicates a branch and ${policy.referencedDomains} referenced Domains; and checks within depth ${policy.checkDepth}, ${policy.checkBranches} branches and ${policy.checkLeaves} leaves.`,
259
+ statement: `A Policy declares at most ${policy.inputs} Node inputs and stays within its budgets once expanded: pattern depth ${policy.patternDepth}, ${policy.existsDepth} nested exists scopes, ${policy.normalizedBranches} normalized branches, ${policy.edgePredicates} Edge predicates a branch and ${policy.referencedDomains} referenced Domains; and checks within depth ${policy.checkDepth}, ${policy.checkBranches} branches and ${policy.checkLeaves} leaves.`,
260
260
  limits: [
261
261
  'policy.inputs',
262
262
  'policy.patternDepth',
263
+ 'policy.existsDepth',
263
264
  'policy.normalizedBranches',
264
265
  'policy.edgePredicates',
265
266
  'policy.referencedDomains',