@astrale-os/kernel-dsl 0.2.0-beta.42 → 0.2.0-beta.44

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 (39) hide show
  1. package/dist/v1/compiled/admission/accept.js +10 -27
  2. package/dist/v1/compiled/admission/semantics.js +19 -4
  3. package/dist/v1/compiled/loader/load.d.ts +2 -11
  4. package/dist/v1/compiled/loader/load.js +1 -3
  5. package/dist/v1/language/policy/analysis/checks.d.ts +28 -0
  6. package/dist/v1/language/policy/analysis/checks.js +80 -0
  7. package/dist/v1/language/value/evaluate/evaluator.js +29 -11
  8. package/dist/v1/language/value/profile/rules.js +25 -0
  9. package/dist/v1/language/value/regexp/compile.d.ts +6 -0
  10. package/dist/v1/language/value/regexp/compile.js +18 -0
  11. package/dist/v1/schema/compatibility/api.d.ts +2 -1
  12. package/dist/v1/schema/compatibility/api.js +1 -0
  13. package/dist/v1/schema/compatibility/evidence.d.ts +6 -2
  14. package/dist/v1/schema/compatibility/evidence.js +5 -3
  15. package/dist/v1/schema/compatibility/index.d.ts +1 -3
  16. package/dist/v1/schema/compatibility/index.js +0 -1
  17. package/dist/v1/schema/compatibility/meaning/index.js +1 -1
  18. package/dist/v1/schema/compatibility/model.d.ts +33 -3
  19. package/dist/v1/schema/compatibility/scope.d.ts +8 -0
  20. package/dist/v1/schema/compatibility/scope.js +50 -21
  21. package/dist/v1/schema/compatibility/structure/index.js +6 -1
  22. package/dist/v1/schema/compatibility/structure/requirements.js +5 -3
  23. package/dist/v1/schema/compatibility/subjects.d.ts +5 -0
  24. package/dist/v1/schema/compatibility/subjects.js +39 -0
  25. package/dist/v1/schema/compatibility/versioning/index.d.ts +8 -0
  26. package/dist/v1/schema/compatibility/versioning/index.js +50 -0
  27. package/dist/v1/schema/compatibility/versioning/members.d.ts +12 -0
  28. package/dist/v1/schema/compatibility/versioning/members.js +47 -0
  29. package/dist/v1/schema/compatibility/versioning/surface.d.ts +11 -0
  30. package/dist/v1/schema/compatibility/versioning/surface.js +61 -0
  31. package/dist/v1/schema/diagnostic.d.ts +1 -1
  32. package/dist/v1/schema/index.d.ts +2 -4
  33. package/dist/v1/schema/index.js +1 -2
  34. package/dist/v1/schema/validation/policy/typing.d.ts +2 -0
  35. package/dist/v1/schema/validation/policy/typing.js +5 -1
  36. package/dist/v1/schema/validation/policy/uses.js +20 -8
  37. package/package.json +5 -1
  38. package/dist/v1/schema/compatibility/legacy/index.d.ts +0 -58
  39. package/dist/v1/schema/compatibility/legacy/index.js +0 -145
@@ -1,145 +0,0 @@
1
- import { Key } from '../../../addressing/index.js';
2
- import { compareUnicode } from '../../../addressing/ordering.js';
3
- import { compareFacet } from '../comparators/index.js';
4
- import { fingerprintMeaning } from '../comparators/values.js';
5
- import { compareMeaning, compareStructure } from '../compare.js';
6
- import { prepare, retainedContext } from '../scope.js';
7
- export function compareDependencyMeaning(dependent, target) {
8
- return legacyMeaning(compareMeaning({ scope: { kind: 'dependency', dependent }, target }));
9
- }
10
- export function compareMemberMeaning(source, target, roots) {
11
- return legacyMeaning(compareMeaning({ scope: { kind: 'members', source, roots }, target }));
12
- }
13
- export function compareDependencyStructure(dependent, target) {
14
- const report = compareStructure({ scope: { kind: 'dependency', dependent }, target });
15
- const failed = new Set(report.assessments.filter((item) => !item.satisfied).map((item) => item.observation.id));
16
- const changes = report.entries.flatMap((entry) => entry.observations.filter((item) => failed.has(item.id)).map((item) => changeOf(entry, item)));
17
- return Object.freeze({
18
- kind: 'structure',
19
- version: 1,
20
- dependency: report.scope.source.origin,
21
- source: report.scope.source.revision,
22
- target: report.scope.target.revision,
23
- footprint: Object.freeze(report.entries
24
- .filter((entry) => Key.origin(entry.subject.key) === report.scope.source.origin &&
25
- entry.observations.some((item) => item.before !== undefined))
26
- .map((entry) => entry.subject.key)),
27
- changes: Object.freeze(changes),
28
- fingerprint: report.evidence.fingerprint,
29
- });
30
- }
31
- export function footprintOf(dependent, origin) {
32
- const { source } = retainedContext(dependent, origin, '/origin');
33
- const report = compareMeaning({ scope: { kind: 'dependency', dependent }, target: source });
34
- return Object.freeze(report.entries.map((entry) => Object.freeze({
35
- ...entry.subject,
36
- ...(entry.subject.kind === 'class'
37
- ? {
38
- level: strongest(entry).facet === 'class.inherit'
39
- ? 'inherit'
40
- : 'reference',
41
- }
42
- : {}),
43
- })));
44
- }
45
- export function meaningOf(schema, key, level = 'reference') {
46
- const context = prepare({
47
- scope: { kind: 'members', source: schema, roots: [key] },
48
- target: schema,
49
- });
50
- const coordinate = context.roots[0].coordinate;
51
- const facet = coordinate.kind === 'class'
52
- ? level === 'inherit'
53
- ? 'class.inherit'
54
- : 'class.reference'
55
- : coordinate.kind === 'method'
56
- ? 'method.signature'
57
- : coordinate.kind === 'property'
58
- ? 'property'
59
- : coordinate.ref.kind === 'function'
60
- ? 'function.signature'
61
- : coordinate.ref.kind;
62
- return compareFacet({ context, pair: context.pair(coordinate), facet }).before;
63
- }
64
- function strongest(entry) {
65
- return (entry.observations.find((item) => item.facet === 'class.inherit') ??
66
- entry.observations.find((item) => item.facet !== 'property.required') ??
67
- entry.observations[0]);
68
- }
69
- function legacyMeaning(report) {
70
- const coordinates = [];
71
- const footprint = [];
72
- const changes = [];
73
- const additions = [];
74
- for (const entry of report.entries) {
75
- const added = entry.observations.find((item) => item.facet === 'property.required');
76
- if (added !== undefined)
77
- additions.push(changeOf(entry, added));
78
- const observation = strongest(entry);
79
- const change = changeOf(entry, observation);
80
- if (observation.before === undefined) {
81
- continue;
82
- }
83
- footprint.push(entry.subject.key);
84
- coordinates.push([
85
- entry.subject.key,
86
- fingerprintMeaning(observation.before),
87
- observation.after === undefined ? null : fingerprintMeaning(observation.after),
88
- ]);
89
- if (change !== undefined)
90
- changes.push(change);
91
- }
92
- additions.sort((a, b) => compareUnicode(a.key, b.key));
93
- const identity = {
94
- version: 3,
95
- dependency: report.scope.source.origin,
96
- source: report.scope.source.revision,
97
- target: report.scope.target.revision,
98
- };
99
- return Object.freeze({
100
- ...identity,
101
- footprint: Object.freeze(footprint),
102
- changes: Object.freeze([...changes, ...additions]),
103
- fingerprint: fingerprintMeaning({
104
- ...identity,
105
- coordinates,
106
- additions: additions.map(({ key, targetFingerprint }) => [key, targetFingerprint]),
107
- }),
108
- });
109
- }
110
- function changeOf(entry, observation) {
111
- const key = entry.subject.key;
112
- if (observation.state === 'equal')
113
- return undefined;
114
- if (observation.before === undefined)
115
- return Object.freeze({
116
- key,
117
- kind: 'added',
118
- targetFingerprint: fingerprintMeaning(observation.after),
119
- meaning: observation.after,
120
- });
121
- const sourceFingerprint = fingerprintMeaning(observation.before);
122
- if (observation.after === undefined)
123
- return Object.freeze({ key, kind: 'missing', sourceFingerprint });
124
- return Object.freeze({
125
- key,
126
- kind: 'changed',
127
- sourceFingerprint,
128
- targetFingerprint: fingerprintMeaning(observation.after),
129
- differences: observation.differences,
130
- });
131
- }
132
- /** One line an operator can act on, naming the exact paths of a changed meaning. */
133
- export function describeMeaningChange(change) {
134
- switch (change.kind) {
135
- case 'missing':
136
- return `${change.key} missing`;
137
- case 'added':
138
- return `${change.key} added as an obligation`;
139
- case 'changed': {
140
- const paths = change.differences.map(({ path }) => path);
141
- const shown = paths.slice(0, 3).join(', ');
142
- return `${change.key} changed at ${paths.length > 3 ? `${shown} and ${paths.length - 3} more` : shown}`;
143
- }
144
- }
145
- }