@astrale-os/kernel-dsl 0.2.0-beta.34 → 0.2.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.
- package/dist/v1/schema/compatibility/compare.d.ts +57 -0
- package/dist/v1/schema/compatibility/compare.js +166 -0
- package/dist/v1/schema/compatibility/context.d.ts +15 -0
- package/dist/v1/schema/compatibility/context.js +43 -0
- package/dist/v1/schema/compatibility/coordinate.d.ts +44 -0
- package/dist/v1/schema/compatibility/coordinate.js +42 -0
- package/dist/v1/schema/compatibility/diff.d.ts +12 -0
- package/dist/v1/schema/compatibility/diff.js +39 -0
- package/dist/v1/schema/compatibility/fields.d.ts +180 -0
- package/dist/v1/schema/compatibility/fields.js +83 -0
- package/dist/v1/schema/compatibility/footprint.d.ts +25 -0
- package/dist/v1/schema/compatibility/footprint.js +263 -0
- package/dist/v1/schema/compatibility/index.d.ts +7 -0
- package/dist/v1/schema/compatibility/index.js +3 -0
- package/dist/v1/schema/compatibility/meaning.d.ts +39 -39
- package/dist/v1/schema/compatibility/meaning.js +102 -516
- package/dist/v1/schema/fingerprint.d.ts +2 -0
- package/dist/v1/schema/fingerprint.js +1 -0
- package/dist/v1/schema/index.d.ts +2 -2
- package/dist/v1/schema/index.js +1 -1
- package/dist/v1/schema/resolution/origins.d.ts +2 -0
- package/dist/v1/schema/resolution/origins.js +6 -2
- package/package.json +5 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const IDENTITY = Object.freeze({ excluded: 'identity' });
|
|
2
|
+
const ANNOTATION = Object.freeze({ excluded: 'annotation' });
|
|
3
|
+
const AUTHORIZATION = Object.freeze({ excluded: 'authorization' });
|
|
4
|
+
const PRESENTATION = Object.freeze({ excluded: 'presentation' });
|
|
5
|
+
/** The coordinate Key already names the declaration; its `ref` is never repeated in the meaning. */
|
|
6
|
+
export const CLASS_FIELDS = Object.freeze({
|
|
7
|
+
ref: IDENTITY,
|
|
8
|
+
kind: 'always',
|
|
9
|
+
abstract: 'always',
|
|
10
|
+
orientation: 'always',
|
|
11
|
+
extends: 'inherit',
|
|
12
|
+
policies: 'inherit',
|
|
13
|
+
data: 'inherit',
|
|
14
|
+
endpoints: 'inherit',
|
|
15
|
+
constraints: 'inherit',
|
|
16
|
+
properties: 'members',
|
|
17
|
+
methods: 'members',
|
|
18
|
+
description: ANNOTATION,
|
|
19
|
+
icon: PRESENTATION,
|
|
20
|
+
});
|
|
21
|
+
export const PROPERTY_FIELDS = Object.freeze({
|
|
22
|
+
schema: 'always',
|
|
23
|
+
required: 'always',
|
|
24
|
+
auto: 'always',
|
|
25
|
+
state: 'always',
|
|
26
|
+
description: ANNOTATION,
|
|
27
|
+
});
|
|
28
|
+
/** The auth level and Policy check are decided by the Runtime at invocation, never compiled against. */
|
|
29
|
+
export const CALLABLE_FIELDS = Object.freeze({
|
|
30
|
+
ref: IDENTITY,
|
|
31
|
+
input: 'always',
|
|
32
|
+
output: 'always',
|
|
33
|
+
static: 'always',
|
|
34
|
+
abstract: 'always',
|
|
35
|
+
auth: AUTHORIZATION,
|
|
36
|
+
policy: AUTHORIZATION,
|
|
37
|
+
description: ANNOTATION,
|
|
38
|
+
});
|
|
39
|
+
export const POLICY_FIELDS = Object.freeze({
|
|
40
|
+
ref: IDENTITY,
|
|
41
|
+
expression: 'always',
|
|
42
|
+
description: ANNOTATION,
|
|
43
|
+
});
|
|
44
|
+
export const VIEW_FIELDS = Object.freeze({
|
|
45
|
+
ref: IDENTITY,
|
|
46
|
+
target: 'always',
|
|
47
|
+
description: ANNOTATION,
|
|
48
|
+
});
|
|
49
|
+
export const CORE_FIELDS = Object.freeze({
|
|
50
|
+
ref: IDENTITY,
|
|
51
|
+
class: 'always',
|
|
52
|
+
properties: 'always',
|
|
53
|
+
source: 'always',
|
|
54
|
+
target: 'always',
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* JSON Schema keywords that annotate a value schema without constraining its values. Every other
|
|
58
|
+
* keyword, `x-astrale-path` included, is semantic; arbitrary JSON data is never inspected as schema.
|
|
59
|
+
* A frozen, Unicode-ordered list like the role tables: printable, and immutable at runtime.
|
|
60
|
+
*/
|
|
61
|
+
export const ANNOTATION_KEYWORDS = Object.freeze([
|
|
62
|
+
'$comment',
|
|
63
|
+
'contentEncoding',
|
|
64
|
+
'contentMediaType',
|
|
65
|
+
'contentSchema',
|
|
66
|
+
'default',
|
|
67
|
+
'deprecated',
|
|
68
|
+
'description',
|
|
69
|
+
'examples',
|
|
70
|
+
'format',
|
|
71
|
+
'readOnly',
|
|
72
|
+
'title',
|
|
73
|
+
'writeOnly',
|
|
74
|
+
]);
|
|
75
|
+
/** The complete classification, one table per declaration kind. */
|
|
76
|
+
export const FIELD_ROLES = Object.freeze({
|
|
77
|
+
class: CLASS_FIELDS,
|
|
78
|
+
property: PROPERTY_FIELDS,
|
|
79
|
+
callable: CALLABLE_FIELDS,
|
|
80
|
+
policy: POLICY_FIELDS,
|
|
81
|
+
view: VIEW_FIELDS,
|
|
82
|
+
core: CORE_FIELDS,
|
|
83
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import type { Key as SemanticKey } from '../../addressing/index.js';
|
|
3
|
+
import type { DomainSchema } from '../model/schema.js';
|
|
4
|
+
import type { Context } from './context.js';
|
|
5
|
+
import type { Coordinate } from './coordinate.js';
|
|
6
|
+
import type { DependencyMeaningLevel } from './fields.js';
|
|
7
|
+
import type { ClassRequirement, MeaningFingerprint } from './meaning.js';
|
|
8
|
+
/** One footprint coordinate with the meaning the dependent was authored against. */
|
|
9
|
+
export interface SourceMeaning {
|
|
10
|
+
readonly coordinate: Coordinate;
|
|
11
|
+
readonly meaning: JsonValue;
|
|
12
|
+
readonly fingerprint: MeaningFingerprint;
|
|
13
|
+
readonly requirement?: ClassRequirement;
|
|
14
|
+
}
|
|
15
|
+
/** Every dependency Definition the dependent's own declarations name, at its strongest usage. */
|
|
16
|
+
export declare function collectSchemaRoots(owner: DomainSchema): readonly Coordinate[];
|
|
17
|
+
/**
|
|
18
|
+
* The transitive footprint: from the roots, every Class, Property, Method, Function, Policy, View
|
|
19
|
+
* and Core coordinate of the selected origin that the dependent's meaning reaches. A Class carries
|
|
20
|
+
* its strongest usage level; only inheritance traverses ancestors and Edge endpoint contracts, and
|
|
21
|
+
* a reached callable contributes its contract references but never its Policy check.
|
|
22
|
+
*/
|
|
23
|
+
export declare function collectReachableMeanings(roots: readonly Coordinate[], selectedOrigin: string, context: Context): ReadonlyMap<SemanticKey, SourceMeaning>;
|
|
24
|
+
/** Resolve one caller-supplied Key of the source into an exact coordinate that exists there. */
|
|
25
|
+
export declare function coordinateForKey(context: Context, source: DomainSchema, input: SemanticKey, index: number, level?: DependencyMeaningLevel): Coordinate;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { Key } from '../../addressing/index.js';
|
|
2
|
+
import { compareUnicode, definitionRefIndex } from '../../addressing/ordering.js';
|
|
3
|
+
import { SchemaError, diagnostic } from '../diagnostic.js';
|
|
4
|
+
import { collectCallableContractRefs, collectCallableRefs, collectClassPolicyRefs, collectClassRefs, collectCoreRefs, collectEndpointRefs, collectPolicyDefinitionRefs, collectValueDefinitionRefs, } from '../resolution/origins.js';
|
|
5
|
+
import { contextInvalid, effectiveDefinition, effectiveMethod, requireOwner } from './context.js';
|
|
6
|
+
import { classCoordinate, keyReference, levelOf, memberCoordinate, methodCoordinate, propertyCoordinate, } from './coordinate.js';
|
|
7
|
+
import { classMeaning, fingerprintMeaning, meaningForCoordinate, memberMeaning, methodMeaning, propertyMeaning, } from './meaning.js';
|
|
8
|
+
/** Every dependency Definition the dependent's own declarations name, at its strongest usage. */
|
|
9
|
+
export function collectSchemaRoots(owner) {
|
|
10
|
+
const classes = new Map();
|
|
11
|
+
const members = new Map();
|
|
12
|
+
const add = (ref, site) => {
|
|
13
|
+
if (ref.kind === 'class') {
|
|
14
|
+
const index = definitionRefIndex(ref);
|
|
15
|
+
const level = levelOf(site);
|
|
16
|
+
const previous = classes.get(index);
|
|
17
|
+
if (previous === undefined || (previous.level === 'reference' && level === 'inherit')) {
|
|
18
|
+
classes.set(index, classCoordinate(ref, level));
|
|
19
|
+
}
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
members.set(definitionRefIndex(ref), memberCoordinate(ref));
|
|
23
|
+
};
|
|
24
|
+
for (const declaration of Object.values(owner.classes))
|
|
25
|
+
collectClassRefs(declaration, add);
|
|
26
|
+
for (const declaration of Object.values(owner.functions))
|
|
27
|
+
collectCallableRefs(declaration, add);
|
|
28
|
+
for (const declaration of Object.values(owner.policies)) {
|
|
29
|
+
collectPolicyDefinitionRefs(declaration, add);
|
|
30
|
+
}
|
|
31
|
+
for (const declaration of Object.values(owner.views)) {
|
|
32
|
+
if (declaration.target.kind === 'definition') {
|
|
33
|
+
declaration.target.definitions.forEach((ref) => add(ref, 'view'));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
collectCoreRefs(owner, add);
|
|
37
|
+
return [...classes.values(), ...members.values()].sort((left, right) => compareUnicode(left.key, right.key));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The transitive footprint: from the roots, every Class, Property, Method, Function, Policy, View
|
|
41
|
+
* and Core coordinate of the selected origin that the dependent's meaning reaches. A Class carries
|
|
42
|
+
* its strongest usage level; only inheritance traverses ancestors and Edge endpoint contracts, and
|
|
43
|
+
* a reached callable contributes its contract references but never its Policy check.
|
|
44
|
+
*/
|
|
45
|
+
export function collectReachableMeanings(roots, selectedOrigin, context) {
|
|
46
|
+
const meanings = new Map();
|
|
47
|
+
const classLevels = new Map();
|
|
48
|
+
const visitedMembers = new Set();
|
|
49
|
+
const pendingClasses = [];
|
|
50
|
+
const pendingMembers = [];
|
|
51
|
+
const push = (ref, site) => {
|
|
52
|
+
if (ref.kind === 'class')
|
|
53
|
+
pendingClasses.push(classCoordinate(ref, levelOf(site)));
|
|
54
|
+
else
|
|
55
|
+
pendingMembers.push(memberCoordinate(ref));
|
|
56
|
+
};
|
|
57
|
+
for (const coordinate of roots) {
|
|
58
|
+
if (coordinate.kind === 'class') {
|
|
59
|
+
pendingClasses.push(coordinate);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (coordinate.kind === 'member') {
|
|
63
|
+
pendingMembers.push(coordinate);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const meaning = meaningForCoordinate(context, coordinate);
|
|
67
|
+
if (meaning === undefined) {
|
|
68
|
+
throw new SchemaError([
|
|
69
|
+
diagnostic('DM_MEMBER_ROOT_INVALID', '/roots', `Member comparison root ${coordinate.key} does not exist in its source context.`, coordinate.key),
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
retainMeaning(meanings, selectedOrigin, coordinate, meaning);
|
|
73
|
+
collectCoordinateSemanticRefs(context, coordinate, push);
|
|
74
|
+
}
|
|
75
|
+
const visitClass = (coordinate) => {
|
|
76
|
+
const index = definitionRefIndex(coordinate.ref);
|
|
77
|
+
const previous = classLevels.get(index);
|
|
78
|
+
if (previous === 'inherit' || previous === coordinate.level)
|
|
79
|
+
return;
|
|
80
|
+
classLevels.set(index, coordinate.level);
|
|
81
|
+
const owner = requireOwner(context, coordinate.ref, coordinate.key);
|
|
82
|
+
const declaration = owner.classes[coordinate.ref.name];
|
|
83
|
+
const analysis = effectiveDefinition(context, owner, coordinate.ref);
|
|
84
|
+
const resolved = classMeaning(context, coordinate);
|
|
85
|
+
if (declaration === undefined || analysis === undefined || resolved === undefined) {
|
|
86
|
+
throw contextInvalid(`Retained acceptance context has no meaning for ${coordinate.key}.`, coordinate.key);
|
|
87
|
+
}
|
|
88
|
+
retainMeaning(meanings, selectedOrigin, coordinate, resolved.meaning, resolved.requirement);
|
|
89
|
+
if (previous === undefined) {
|
|
90
|
+
// The surface is level-independent: every effective Property and Method the dependent may
|
|
91
|
+
// read or call, with the Definitions their contracts and policies name.
|
|
92
|
+
for (const field of analysis.properties.values()) {
|
|
93
|
+
retainMeaning(meanings, selectedOrigin, propertyCoordinate(field.owner, field.name), propertyMeaning(field));
|
|
94
|
+
collectValueDefinitionRefs(field.schema, push);
|
|
95
|
+
}
|
|
96
|
+
for (const method of analysis.methods.values()) {
|
|
97
|
+
retainMeaning(meanings, selectedOrigin, methodCoordinate(method.owner, method.name), methodMeaning(method));
|
|
98
|
+
collectCallableContractRefs(method.declaration, push);
|
|
99
|
+
}
|
|
100
|
+
collectClassPolicyRefs(declaration, push);
|
|
101
|
+
}
|
|
102
|
+
if (coordinate.level === 'inherit') {
|
|
103
|
+
// Only inheritance takes on the ancestry and, for an Edge, the endpoint contract.
|
|
104
|
+
declaration.extends.forEach((parent) => push(parent, 'extends'));
|
|
105
|
+
if (declaration.kind === 'edge')
|
|
106
|
+
collectEndpointRefs(declaration, push);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const visitMember = (coordinate) => {
|
|
110
|
+
const index = definitionRefIndex(coordinate.ref);
|
|
111
|
+
if (visitedMembers.has(index))
|
|
112
|
+
return;
|
|
113
|
+
visitedMembers.add(index);
|
|
114
|
+
const owner = requireOwner(context, coordinate.ref, coordinate.key);
|
|
115
|
+
const meaning = memberMeaning(owner, coordinate.ref);
|
|
116
|
+
if (meaning === undefined) {
|
|
117
|
+
throw contextInvalid(`Retained acceptance context has no meaning for ${coordinate.key}.`, coordinate.key);
|
|
118
|
+
}
|
|
119
|
+
retainMeaning(meanings, selectedOrigin, coordinate, meaning);
|
|
120
|
+
collectMemberSemanticRefs(owner, coordinate.ref, push);
|
|
121
|
+
};
|
|
122
|
+
let classIndex = 0;
|
|
123
|
+
let memberIndex = 0;
|
|
124
|
+
while (classIndex < pendingClasses.length || memberIndex < pendingMembers.length) {
|
|
125
|
+
if (classIndex < pendingClasses.length)
|
|
126
|
+
visitClass(pendingClasses[classIndex++]);
|
|
127
|
+
else
|
|
128
|
+
visitMember(pendingMembers[memberIndex++]);
|
|
129
|
+
}
|
|
130
|
+
return meanings;
|
|
131
|
+
}
|
|
132
|
+
/** Resolve one caller-supplied Key of the source into an exact coordinate that exists there. */
|
|
133
|
+
export function coordinateForKey(context, source, input, index, level = 'reference') {
|
|
134
|
+
let key;
|
|
135
|
+
try {
|
|
136
|
+
key = Key(input);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return invalidMemberRoot(input, index, 'is not a canonical semantic Key');
|
|
140
|
+
}
|
|
141
|
+
if (Key.origin(key) !== source.origin) {
|
|
142
|
+
return invalidMemberRoot(key, index, `belongs to ${Key.origin(key)}, not source ${source.origin}`);
|
|
143
|
+
}
|
|
144
|
+
const reference = keyReference(key);
|
|
145
|
+
let coordinate;
|
|
146
|
+
if (reference.member !== undefined && reference.ownerName !== undefined) {
|
|
147
|
+
if (source.classes[reference.ownerName] === undefined) {
|
|
148
|
+
return invalidMemberRoot(key, index, 'has no exact owning Definition');
|
|
149
|
+
}
|
|
150
|
+
const owner = { origin: source.origin, kind: 'class', name: reference.ownerName };
|
|
151
|
+
coordinate =
|
|
152
|
+
reference.member === 'property'
|
|
153
|
+
? propertyCoordinate(owner, reference.name)
|
|
154
|
+
: methodCoordinate(owner, reference.name);
|
|
155
|
+
}
|
|
156
|
+
else if (reference.kind === 'class') {
|
|
157
|
+
if (source.classes[reference.name] === undefined) {
|
|
158
|
+
return invalidMemberRoot(key, index, 'does not exist in the source');
|
|
159
|
+
}
|
|
160
|
+
// A Class root takes the caller's level; compareMemberMeaning passes none and compares the
|
|
161
|
+
// surface at reference level without inferring an inheritance contract.
|
|
162
|
+
coordinate = classCoordinate({ origin: source.origin, kind: 'class', name: reference.name }, level);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
coordinate = memberCoordinate({
|
|
166
|
+
origin: source.origin,
|
|
167
|
+
kind: reference.kind,
|
|
168
|
+
name: reference.name,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (meaningForCoordinate(context, coordinate) === undefined) {
|
|
172
|
+
return invalidMemberRoot(key, index, 'does not exist in the source');
|
|
173
|
+
}
|
|
174
|
+
return coordinate;
|
|
175
|
+
}
|
|
176
|
+
function collectCoordinateSemanticRefs(context, coordinate, add) {
|
|
177
|
+
const owner = context.schemas.get(coordinate.owner.origin);
|
|
178
|
+
const analysis = owner === undefined ? undefined : effectiveDefinition(context, owner, coordinate.owner);
|
|
179
|
+
if (analysis === undefined)
|
|
180
|
+
return;
|
|
181
|
+
if (coordinate.kind === 'property') {
|
|
182
|
+
const field = analysis.properties.get(coordinate.key);
|
|
183
|
+
if (field !== undefined)
|
|
184
|
+
collectValueDefinitionRefs(field.schema, add);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const method = effectiveMethod(analysis, coordinate.key);
|
|
188
|
+
if (method !== undefined)
|
|
189
|
+
collectCallableContractRefs(method.declaration, add);
|
|
190
|
+
}
|
|
191
|
+
function collectMemberSemanticRefs(owner, ref, add) {
|
|
192
|
+
switch (ref.kind) {
|
|
193
|
+
case 'function': {
|
|
194
|
+
const declaration = owner.functions[ref.name];
|
|
195
|
+
if (declaration !== undefined)
|
|
196
|
+
collectCallableRefs(declaration, add);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
case 'policy': {
|
|
200
|
+
const declaration = owner.policies[ref.name];
|
|
201
|
+
if (declaration !== undefined)
|
|
202
|
+
collectPolicyDefinitionRefs(declaration, add);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
case 'view': {
|
|
206
|
+
const declaration = owner.views[ref.name];
|
|
207
|
+
if (declaration?.target.kind === 'definition') {
|
|
208
|
+
declaration.target.definitions.forEach((definition) => add(definition, 'view'));
|
|
209
|
+
}
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
case 'core': {
|
|
213
|
+
// The dependency instantiates its own Core; the dependent only refers to it.
|
|
214
|
+
const node = owner.core.nodes[ref.name];
|
|
215
|
+
if (node === undefined)
|
|
216
|
+
return;
|
|
217
|
+
add(node.class);
|
|
218
|
+
for (const edge of owner.core.edges) {
|
|
219
|
+
const incident = (edge.source.kind === 'core' && edge.source.name === ref.name) ||
|
|
220
|
+
(edge.target.kind === 'core' && edge.target.name === ref.name);
|
|
221
|
+
if (!incident)
|
|
222
|
+
continue;
|
|
223
|
+
add(edge.class);
|
|
224
|
+
if (edge.source.kind !== 'domain')
|
|
225
|
+
add(edge.source);
|
|
226
|
+
if (edge.target.kind !== 'domain')
|
|
227
|
+
add(edge.target);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function retainMeaning(meanings, selectedOrigin, coordinate, meaning, requirement) {
|
|
233
|
+
if (Key.origin(coordinate.key) !== selectedOrigin)
|
|
234
|
+
return;
|
|
235
|
+
const fingerprint = fingerprintMeaning(meaning);
|
|
236
|
+
const previous = meanings.get(coordinate.key);
|
|
237
|
+
if (previous !== undefined) {
|
|
238
|
+
const upgraded = previous.coordinate.kind === 'class' &&
|
|
239
|
+
coordinate.kind === 'class' &&
|
|
240
|
+
previous.coordinate.level !== coordinate.level;
|
|
241
|
+
if (upgraded) {
|
|
242
|
+
// A stronger requirement replaces the weaker one for the same Class.
|
|
243
|
+
if (coordinate.level === 'reference')
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
else if (previous.fingerprint !== fingerprint) {
|
|
247
|
+
throw new SchemaError([
|
|
248
|
+
diagnostic('DM_MEANING_INCONSISTENT', '', `Semantic coordinate ${coordinate.key} produced inconsistent effective meaning.`, coordinate.key),
|
|
249
|
+
]);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
meanings.set(coordinate.key, Object.freeze({
|
|
253
|
+
coordinate,
|
|
254
|
+
meaning,
|
|
255
|
+
fingerprint,
|
|
256
|
+
...(requirement === undefined ? {} : { requirement }),
|
|
257
|
+
}));
|
|
258
|
+
}
|
|
259
|
+
function invalidMemberRoot(key, index, reason) {
|
|
260
|
+
throw new SchemaError([
|
|
261
|
+
diagnostic('DM_MEMBER_ROOT_INVALID', `/roots/${index}`, `Key ${JSON.stringify(key)} ${reason}.`, typeof key === 'string' ? key : undefined),
|
|
262
|
+
]);
|
|
263
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { compareDependencyMeaning, compareMemberMeaning, describeMeaningChange, footprintOf, meaningOf, } from './compare.js';
|
|
2
|
+
export type { DependencyMeaningChange, DependencyMeaningChangeKind, DependencyMeaningComparison, FootprintEntry, } from './compare.js';
|
|
3
|
+
export type { MeaningDifference } from './diff.js';
|
|
4
|
+
export { ANNOTATION_KEYWORDS, FIELD_ROLES } from './fields.js';
|
|
5
|
+
export type { DependencyMeaningLevel, FieldRole } from './fields.js';
|
|
6
|
+
export { callableFingerprint } from './meaning.js';
|
|
7
|
+
export type { MeaningFingerprint } from './meaning.js';
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import type { Key as SemanticKey, PropertyKey as SemanticPropertyKey } from '../../addressing/index.js';
|
|
3
|
+
import type { ResolvedFunction, ResolvedMethod } from '../../language/callable/resolved.js';
|
|
4
|
+
import type { JsonSchema } from '../../language/value/model/schema.js';
|
|
5
|
+
import type { EffectiveField, EffectiveMethod } from '../analysis/class.js';
|
|
3
6
|
import type { DomainSchema } from '../model/schema.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
* How strongly a dependent relies on a dependency Class. `inherit` covers `extends` and Core
|
|
7
|
-
* instantiation, which take on the Class creation contract; `reference` covers every other site,
|
|
8
|
-
* which only names the Class and reads its surface.
|
|
9
|
-
*/
|
|
10
|
-
export type DependencyMeaningLevel = 'reference' | 'inherit';
|
|
11
|
-
export type DependencyMeaningChangeKind = 'missing' | 'changed' | 'added';
|
|
7
|
+
import type { Context } from './context.js';
|
|
8
|
+
import type { ClassCoordinate, Coordinate, MemberRef } from './coordinate.js';
|
|
12
9
|
export type MeaningFingerprint = `sha256:${string}`;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
17
|
-
} | {
|
|
18
|
-
readonly key: SemanticKey;
|
|
19
|
-
readonly kind: 'changed';
|
|
20
|
-
readonly sourceFingerprint: MeaningFingerprint;
|
|
21
|
-
readonly targetFingerprint: MeaningFingerprint;
|
|
22
|
-
} | {
|
|
23
|
-
/** A required, non-automatic Property the target adds to an inherited Class. */
|
|
24
|
-
readonly key: SemanticKey;
|
|
25
|
-
readonly kind: 'added';
|
|
26
|
-
readonly targetFingerprint: MeaningFingerprint;
|
|
27
|
-
};
|
|
28
|
-
export interface DependencyMeaningComparison {
|
|
29
|
-
readonly version: 2;
|
|
30
|
-
readonly dependency: Key.Origin;
|
|
31
|
-
readonly source: Revision;
|
|
32
|
-
readonly target: Revision;
|
|
33
|
-
readonly footprint: readonly SemanticKey[];
|
|
34
|
-
readonly changes: readonly DependencyMeaningChange[];
|
|
35
|
-
readonly fingerprint: MeaningFingerprint;
|
|
10
|
+
/** What the source Class projects onto the target before comparing an inherited Class. */
|
|
11
|
+
export interface ClassRequirement {
|
|
12
|
+
readonly ancestors: readonly SemanticKey[];
|
|
13
|
+
readonly properties: ReadonlySet<SemanticPropertyKey>;
|
|
36
14
|
}
|
|
37
15
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
16
|
+
* The meaning of one coordinate is a portable value built from the fields `fields.ts` classifies
|
|
17
|
+
* as counting at the coordinate's usage level; `__tests__/fields.test.ts` proves the two agree.
|
|
18
|
+
* Comparison works on these values, so every difference can name its exact path.
|
|
19
|
+
*/
|
|
20
|
+
export declare function meaningForCoordinate(context: Context, coordinate: Coordinate, requirement?: ClassRequirement): JsonValue | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* A reference needs the Class to exist with its kind, abstractness and orientation; inheritance
|
|
23
|
+
* additionally takes on the source ancestors, class policies, data contract and, for an Edge, the
|
|
24
|
+
* endpoint and constraint contracts. A target projected onto a source requirement keeps only the
|
|
25
|
+
* ancestors the source named, so a superset satisfies it while a removal changes it.
|
|
26
|
+
*/
|
|
27
|
+
export declare function classMeaning(context: Context, coordinate: ClassCoordinate, onto?: ClassRequirement): {
|
|
28
|
+
readonly meaning: JsonValue;
|
|
29
|
+
readonly requirement: ClassRequirement;
|
|
30
|
+
} | undefined;
|
|
31
|
+
export declare function memberMeaning(owner: DomainSchema, ref: MemberRef): JsonValue | undefined;
|
|
32
|
+
export declare function propertyMeaning(field: EffectiveField): JsonValue;
|
|
33
|
+
export declare function methodMeaning(method: EffectiveMethod): JsonValue;
|
|
34
|
+
/**
|
|
35
|
+
* Fingerprint the contract a caller compiles against, independently of its Domain revision: the
|
|
36
|
+
* exact key, the owner, dispatch and abstractness of a Method, and the semantic input and output
|
|
37
|
+
* contracts; authorization is excluded (DM-CALLABLE-FINGERPRINT). A static consumer pins this
|
|
38
|
+
* instead of a Domain revision, so a dependency release that leaves the callable contract untouched
|
|
39
|
+
* keeps every bound invocation valid.
|
|
41
40
|
*/
|
|
42
|
-
export declare function
|
|
43
|
-
/**
|
|
44
|
-
export declare function
|
|
41
|
+
export declare function callableFingerprint(callable: ResolvedFunction | ResolvedMethod): MeaningFingerprint;
|
|
42
|
+
/** Drop annotation keywords wherever a schema keyword nests a schema; never inside data. */
|
|
43
|
+
export declare function semanticValueSchema(value: JsonSchema): JsonSchema;
|
|
44
|
+
export declare function fingerprintMeaning(value: unknown): MeaningFingerprint;
|