@astrale-os/kernel-core 0.9.0-beta.63 → 0.9.0-beta.65
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/auth/authority/admission/admission.d.ts +2 -2
- package/dist/auth/authority/admission/admission.js +10 -8
- package/dist/auth/authority/admission/index.d.ts +1 -1
- package/dist/auth/authority/admission/index.js +1 -1
- package/dist/auth/authority/index.d.ts +7 -3
- package/dist/auth/authority/index.js +4 -2
- package/dist/auth/authority/language/index.d.ts +2 -0
- package/dist/auth/authority/language/index.js +1 -0
- package/dist/auth/authority/language/predicate.d.ts +10 -5
- package/dist/auth/authority/language/predicate.js +1 -1
- package/dist/auth/authority/language/program.d.ts +21 -0
- package/dist/auth/authority/language/program.js +2 -0
- package/dist/auth/authority/normalization/index.d.ts +1 -1
- package/dist/auth/authority/normalization/index.js +1 -1
- package/dist/auth/authority/normalization/normalize.d.ts +1 -1
- package/dist/auth/authority/normalization/normalize.js +4 -5
- package/dist/auth/authority/ownership.optimization.js +2 -2
- package/dist/auth/authority/prepare-binder-body.d.ts +4 -0
- package/dist/auth/authority/prepare-binder-body.js +31 -0
- package/dist/auth/authority/program.d.ts +28 -0
- package/dist/auth/authority/program.js +191 -0
- package/dist/auth/authority/semantics/class-authority.d.ts +8 -0
- package/dist/auth/authority/semantics/class-authority.js +26 -0
- package/dist/auth/authority/semantics/composition.d.ts +39 -0
- package/dist/auth/authority/semantics/composition.js +112 -0
- package/dist/auth/authority/semantics/failure.d.ts +21 -0
- package/dist/auth/authority/semantics/failure.js +10 -0
- package/dist/auth/authority/semantics/index.d.ts +11 -0
- package/dist/auth/authority/semantics/index.js +5 -0
- package/dist/auth/authority/semantics/interpret.d.ts +35 -0
- package/dist/auth/authority/semantics/interpret.js +215 -0
- package/dist/auth/authority/semantics/snapshot.d.ts +34 -0
- package/dist/auth/authority/semantics/terms.d.ts +20 -0
- package/dist/auth/authority/semantics/terms.js +96 -0
- package/dist/auth/authority/semantics/vocabulary.d.ts +19 -0
- package/dist/auth/authority/semantics/vocabulary.js +1 -0
- package/dist/auth/context/context.d.ts +4 -3
- package/dist/auth/expression/authoring/builder.d.ts +2 -11
- package/dist/auth/expression/authoring/builder.js +1 -45
- package/dist/auth/expression/authoring/index.d.ts +1 -1
- package/dist/auth/expression/authoring/index.js +1 -1
- package/dist/auth/expression/index.d.ts +1 -2
- package/dist/auth/expression/index.js +1 -2
- package/dist/auth/expression/language/identity-expression.d.ts +2 -22
- package/dist/auth/grant/index.d.ts +1 -1
- package/dist/auth/grant/index.js +1 -1
- package/dist/auth/grant/resolved/admission.d.ts +4 -3
- package/dist/auth/grant/resolved/admission.js +23 -13
- package/dist/auth/grant/resolved/grant.d.ts +1 -1
- package/dist/auth/grant/resolved/index.d.ts +1 -1
- package/dist/auth/grant/resolved/index.js +1 -1
- package/dist/auth/grant/unresolved/admission.d.ts +4 -1
- package/dist/auth/grant/unresolved/admission.js +27 -67
- package/dist/auth/grant/unresolved/limits.d.ts +2 -4
- package/dist/auth/grant/unresolved/limits.js +1 -5
- package/dist/auth/index.d.ts +1 -1
- package/dist/graph/graph/graph.d.ts +1 -5
- package/dist/graph/graph/graph.js +3 -27
- package/dist/graph/graph/index.d.ts +1 -3
- package/dist/graph/graph/index.js +1 -2
- package/dist/graph/query/index.d.ts +2 -0
- package/dist/graph/query/index.js +1 -0
- package/dist/graph/query/order/index.d.ts +46 -0
- package/dist/graph/query/order/index.js +59 -0
- package/dist/graph/query/reference/evaluate.js +24 -50
- package/dist/graph/reconcile/planning/canonical.d.ts +6 -0
- package/dist/graph/reconcile/planning/canonical.js +28 -0
- package/dist/graph/reconcile/planning/model.d.ts +4 -0
- package/dist/graph/reconcile/planning/plan.js +2 -1
- package/dist/schema/authority/vocabulary.d.ts +3 -0
- package/dist/schema/authority/vocabulary.js +25 -0
- package/dist/schema/callables/function.d.ts +120 -90
- package/dist/schema/domain/domain.d.ts +120 -90
- package/dist/schema/identity/composition.d.ts +5 -0
- package/dist/schema/identity/composition.js +5 -0
- package/dist/schema/identity/identity.d.ts +8 -6
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/kernel/schema.d.ts +337 -276
- package/dist/schema/kernel/syscalls/contracts/delegate.d.ts +4 -1
- package/dist/schema/kernel/syscalls/contracts/delegate.js +4 -3
- package/dist/schema/kernel/syscalls/contracts/impersonate.d.ts +0 -1
- package/dist/schema/kernel/syscalls/contracts/legacy/delegate.d.ts +5 -0
- package/dist/schema/kernel/syscalls/contracts/legacy/delegate.js +25 -0
- package/dist/schema/kernel/syscalls/contracts/mint.d.ts +0 -1
- package/dist/schema/kernel/syscalls/contracts/mint.js +1 -2
- package/dist/schema/kernel/syscalls/declarations/delegate.d.ts +4 -1
- package/dist/schema/kernel/syscalls/declarations/impersonate.d.ts +0 -1
- package/dist/schema/kernel/syscalls/declarations/index.d.ts +35 -34
- package/dist/schema/kernel/syscalls/declarations/install.d.ts +8 -8
- package/dist/schema/kernel/syscalls/declarations/mint.d.ts +0 -1
- package/dist/schema/kernel/syscalls/declarations/mutate.d.ts +23 -23
- package/dist/schema/kernel/syscalls/descriptors/identity.d.ts +4 -3
- package/package.json +2 -2
- package/dist/auth/authority/prepare-grant-body.d.ts +0 -4
- package/dist/auth/authority/prepare-grant-body.js +0 -27
- package/dist/auth/expression/normalization/canonicalize.d.ts +0 -7
- package/dist/auth/expression/normalization/canonicalize.js +0 -102
- package/dist/auth/expression/normalization/index.d.ts +0 -2
- package/dist/auth/expression/normalization/index.js +0 -2
- package/dist/auth/expression/normalization/raise-denials.d.ts +0 -3
- package/dist/auth/expression/normalization/raise-denials.js +0 -59
- package/dist/graph/graph/navigation/error.d.ts +0 -12
- package/dist/graph/graph/navigation/error.js +0 -20
- package/dist/graph/graph/navigation/index.d.ts +0 -2
- package/dist/graph/graph/navigation/index.js +0 -1
- package/dist/graph/graph/navigation/model.d.ts +0 -15
- package/dist/schema/kernel/projection/path.d.ts +0 -2
- package/dist/schema/kernel/projection/path.js +0 -113
- /package/dist/{graph/graph/navigation/model.js → auth/authority/semantics/snapshot.js} +0 -0
|
@@ -6,6 +6,7 @@ import { GraphData } from '../../graph/index.js';
|
|
|
6
6
|
import { NodeId as admitNodeId } from '../../node/index.js';
|
|
7
7
|
import { compareNodeIds } from '../../node/index.js';
|
|
8
8
|
import { encodeQueryAST, QueryASTDecodeError } from '../language/index.js';
|
|
9
|
+
import { compareQueryRank } from '../order/index.js';
|
|
9
10
|
import { decodeQueryResult } from '../result/index.js';
|
|
10
11
|
import { QueryReferenceError } from './error.js';
|
|
11
12
|
/** Independent backend-neutral executable Query V6 row algebra. */
|
|
@@ -273,9 +274,13 @@ function decodeWitness(input, path, context) {
|
|
|
273
274
|
}
|
|
274
275
|
function selectNodes(rows, select, size, after, admission, properties) {
|
|
275
276
|
const selected = new Map();
|
|
277
|
+
const ordered = orderedClasses(select.order, 'node', properties);
|
|
276
278
|
rows.forEach((row) => {
|
|
277
279
|
const node = boundNode(row, select.binding, '/select/binding');
|
|
278
|
-
|
|
280
|
+
// A value is read; an ordered reference reads a fact its order applies to before ranking it.
|
|
281
|
+
const needsRead = select.kind === 'graph' ||
|
|
282
|
+
(select.kind === 'nodes' && select.projection.kind === 'value') ||
|
|
283
|
+
ordered.has(node.class);
|
|
279
284
|
if (needsRead && !admission.readNode(node, '/select/binding'))
|
|
280
285
|
return;
|
|
281
286
|
selected.set(node.id, node);
|
|
@@ -305,6 +310,7 @@ function selectNodes(rows, select, size, after, admission, properties) {
|
|
|
305
310
|
}
|
|
306
311
|
function selectEdges(rows, select, size, after, context, admission, properties) {
|
|
307
312
|
const selected = new Map();
|
|
313
|
+
const ordered = orderedClasses(select.order, 'edge', properties);
|
|
308
314
|
rows.forEach((row) => {
|
|
309
315
|
const edge = boundEdge(row, select.binding, '/select/binding');
|
|
310
316
|
const source = requireNode(context, edge.source, '/select/binding');
|
|
@@ -319,7 +325,7 @@ function selectEdges(rows, select, size, after, context, admission, properties)
|
|
|
319
325
|
admission.readNode(source, '/select/binding') &&
|
|
320
326
|
admission.readNode(target, '/select/binding')
|
|
321
327
|
: select.kind === 'edges'
|
|
322
|
-
? (select.projection.edge === 'reference' ||
|
|
328
|
+
? ((select.projection.edge === 'reference' && !ordered.has(edge.class)) ||
|
|
323
329
|
admission.readEdge(edge, '/select/binding')) &&
|
|
324
330
|
(select.projection.source === 'reference' ||
|
|
325
331
|
admission.readNode(source, '/select/binding')) &&
|
|
@@ -362,12 +368,24 @@ function selectEdges(rows, select, size, after, context, admission, properties)
|
|
|
362
368
|
const next = last === undefined ? undefined : frontierOf(last, order, 'edge', properties);
|
|
363
369
|
return Object.freeze({ result, ...(next === undefined ? {} : { next }) });
|
|
364
370
|
}
|
|
371
|
+
/** The Classes a Property order applies to, whose facts are read before they are ranked. */
|
|
372
|
+
function orderedClasses(order, kind, properties) {
|
|
373
|
+
return order === undefined
|
|
374
|
+
? new Set()
|
|
375
|
+
: properties.close(order.property, kind, '/select/order/property');
|
|
376
|
+
}
|
|
365
377
|
function orderingComparator(order, kind, properties) {
|
|
366
|
-
|
|
378
|
+
const ordering = orderingOf(order, kind, properties);
|
|
379
|
+
return (left, right) => compareReferenceRank(rankOf(left, order, kind, properties), rankOf(right, order, kind, properties), order, ordering);
|
|
380
|
+
}
|
|
381
|
+
function orderingOf(order, kind, properties) {
|
|
382
|
+
return order === undefined
|
|
383
|
+
? undefined
|
|
384
|
+
: properties.ordering(order.property, kind, '/select/order/property');
|
|
367
385
|
}
|
|
368
386
|
function compareFrontier(frontier, fact, order, kind, properties) {
|
|
369
387
|
const admitted = decodeReferenceFrontier(frontier, order, kind, properties);
|
|
370
|
-
return compareReferenceRank(admitted, rankOf(fact, order, kind, properties), order);
|
|
388
|
+
return compareReferenceRank(admitted, rankOf(fact, order, kind, properties), order, orderingOf(order, kind, properties));
|
|
371
389
|
}
|
|
372
390
|
function frontierOf(fact, order, kind, properties) {
|
|
373
391
|
const rank = rankOf(fact, order, kind, properties);
|
|
@@ -413,36 +431,8 @@ function decodeReferenceFrontier(frontier, order, kind, properties) {
|
|
|
413
431
|
}
|
|
414
432
|
return Object.freeze({ bucket: 'ranked', value: frontier.value, identity });
|
|
415
433
|
}
|
|
416
|
-
function compareReferenceRank(left, right, order) {
|
|
417
|
-
|
|
418
|
-
return compareIdentity(left.identity, right.identity);
|
|
419
|
-
if (left.bucket !== right.bucket) {
|
|
420
|
-
return left.bucket === 'unranked'
|
|
421
|
-
? order.unranked === 'first'
|
|
422
|
-
? -1
|
|
423
|
-
: 1
|
|
424
|
-
: order.unranked === 'first'
|
|
425
|
-
? 1
|
|
426
|
-
: -1;
|
|
427
|
-
}
|
|
428
|
-
if (left.bucket === 'ranked' && right.bucket === 'ranked') {
|
|
429
|
-
const kind = typeof left.value === 'boolean'
|
|
430
|
-
? 'boolean'
|
|
431
|
-
: typeof left.value === 'number'
|
|
432
|
-
? 'number'
|
|
433
|
-
: 'string';
|
|
434
|
-
const compared = compareOrderingValue(left.value, right.value, kind);
|
|
435
|
-
if (compared !== 0)
|
|
436
|
-
return order.direction === 'asc' ? compared : -compared;
|
|
437
|
-
}
|
|
438
|
-
return compareIdentity(left.identity, right.identity);
|
|
439
|
-
}
|
|
440
|
-
function compareIdentity(left, right) {
|
|
441
|
-
if (typeof left === 'string' && typeof right === 'string')
|
|
442
|
-
return compareNodeIds(left, right);
|
|
443
|
-
if (typeof left !== 'string' && typeof right !== 'string')
|
|
444
|
-
return compareEdgeKeys(left, right);
|
|
445
|
-
invalid('/after/identity', 'Frontier identity kind disagrees with selection');
|
|
434
|
+
function compareReferenceRank(left, right, order, ordering) {
|
|
435
|
+
return compareQueryRank(left, right, order === undefined || ordering === undefined ? undefined : { ...order, kind: ordering });
|
|
446
436
|
}
|
|
447
437
|
function orderingValue(input, kind) {
|
|
448
438
|
if (kind === 'boolean')
|
|
@@ -451,22 +441,6 @@ function orderingValue(input, kind) {
|
|
|
451
441
|
return typeof input === 'number' && Number.isFinite(input);
|
|
452
442
|
return typeof input === 'string';
|
|
453
443
|
}
|
|
454
|
-
function compareOrderingValue(left, right, kind) {
|
|
455
|
-
if (kind === 'boolean')
|
|
456
|
-
return Number(left) - Number(right);
|
|
457
|
-
if (kind === 'number')
|
|
458
|
-
return left - right;
|
|
459
|
-
return compareUnicodeScalars(left, right);
|
|
460
|
-
}
|
|
461
|
-
function compareUnicodeScalars(left, right) {
|
|
462
|
-
const a = Array.from(left, (value) => value.codePointAt(0));
|
|
463
|
-
const b = Array.from(right, (value) => value.codePointAt(0));
|
|
464
|
-
for (let index = 0; index < Math.min(a.length, b.length); index += 1) {
|
|
465
|
-
if (a[index] !== b[index])
|
|
466
|
-
return a[index] - b[index];
|
|
467
|
-
}
|
|
468
|
-
return a.length - b.length;
|
|
469
|
-
}
|
|
470
444
|
function projectNode(node, shape) {
|
|
471
445
|
return shape === 'value'
|
|
472
446
|
? Object.freeze({ kind: 'value', value: node })
|
|
@@ -2,6 +2,12 @@ import { type ObservationRequirement } from '#graph/reconcile/evidence';
|
|
|
2
2
|
import type { Effect, PlanningBlocker, PlanningConflict, Premise, ReconciliationPlan } from './model.js';
|
|
3
3
|
export declare function canonicalRequirements(values: readonly ObservationRequirement[]): ObservationRequirement[];
|
|
4
4
|
export declare function canonicalPremises(values: readonly Premise[]): Premise[];
|
|
5
|
+
/**
|
|
6
|
+
* Distinct desired refs can name one target: an explicit NodeId and a binding whose
|
|
7
|
+
* correspondence observes that Node. Effects with one key and equal content collapse; effects with
|
|
8
|
+
* one key and different content contradict the desired state, which no transition can establish.
|
|
9
|
+
*/
|
|
10
|
+
export declare function contradictoryEffects(values: readonly Effect[]): PlanningConflict[];
|
|
5
11
|
export declare function canonicalEffects(values: readonly Effect[]): Effect[];
|
|
6
12
|
export declare function canonicalConflicts(values: readonly PlanningConflict[]): PlanningConflict[];
|
|
7
13
|
export declare function canonicalBlockers(values: readonly PlanningBlocker[]): PlanningBlocker[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as portable from '@astrale-os/kernel-dsl/value';
|
|
1
2
|
import { freezeRequirement, requirementKey, } from '#graph/reconcile/evidence';
|
|
2
3
|
import { encodeEdgeKey } from '../../edge/index.js';
|
|
3
4
|
export function canonicalRequirements(values) {
|
|
@@ -8,6 +9,30 @@ export function canonicalRequirements(values) {
|
|
|
8
9
|
export function canonicalPremises(values) {
|
|
9
10
|
return [...new Map(values.map((value) => [premiseKey(value), value])).values()].sort(comparePremises);
|
|
10
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Distinct desired refs can name one target: an explicit NodeId and a binding whose
|
|
14
|
+
* correspondence observes that Node. Effects with one key and equal content collapse; effects with
|
|
15
|
+
* one key and different content contradict the desired state, which no transition can establish.
|
|
16
|
+
*/
|
|
17
|
+
export function contradictoryEffects(values) {
|
|
18
|
+
const groups = new Map();
|
|
19
|
+
for (const value of values) {
|
|
20
|
+
const key = effectKey(value);
|
|
21
|
+
const group = groups.get(key) ?? new Map();
|
|
22
|
+
group.set(portable.json.serialize(value), value);
|
|
23
|
+
groups.set(key, group);
|
|
24
|
+
}
|
|
25
|
+
const conflicts = [];
|
|
26
|
+
for (const group of groups.values()) {
|
|
27
|
+
if (group.size < 2)
|
|
28
|
+
continue;
|
|
29
|
+
conflicts.push({
|
|
30
|
+
kind: 'desired-target-contradictory',
|
|
31
|
+
effects: [...group].sort(([left], [right]) => compare(left, right)).map(([, value]) => value),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return conflicts;
|
|
35
|
+
}
|
|
11
36
|
export function canonicalEffects(values) {
|
|
12
37
|
return [...new Map(values.map((value) => [effectKey(value), value])).values()].sort(compareEffects);
|
|
13
38
|
}
|
|
@@ -66,6 +91,9 @@ function freezeConflict(value) {
|
|
|
66
91
|
if (value.kind === 'correspondence-noninjective') {
|
|
67
92
|
return Object.freeze({ ...value, desired: Object.freeze([...value.desired]) });
|
|
68
93
|
}
|
|
94
|
+
if (value.kind === 'desired-target-contradictory') {
|
|
95
|
+
return Object.freeze({ ...value, effects: Object.freeze([...value.effects]) });
|
|
96
|
+
}
|
|
69
97
|
return Object.freeze({ ...value });
|
|
70
98
|
}
|
|
71
99
|
function compare(left, right) {
|
|
@@ -72,6 +72,10 @@ export type PlanningConflict = ReconcileConflict | CorrespondenceConflict | Obse
|
|
|
72
72
|
} | {
|
|
73
73
|
readonly kind: 'node-identity-absent';
|
|
74
74
|
readonly node: NodeId;
|
|
75
|
+
} | {
|
|
76
|
+
/** One effect target reached through aliasing refs with different desired content. */
|
|
77
|
+
readonly kind: 'desired-target-contradictory';
|
|
78
|
+
readonly effects: readonly Effect[];
|
|
75
79
|
};
|
|
76
80
|
export type PlanningBlocker = {
|
|
77
81
|
readonly kind: 'selection-unsatisfied';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fingerprint } from '../condition/index.js';
|
|
2
|
-
import { canonicalBlockers, canonicalConflicts, canonicalEffects, canonicalPremises, canonicalRequirements, createPlan, } from './canonical.js';
|
|
2
|
+
import { canonicalBlockers, canonicalConflicts, canonicalEffects, canonicalPremises, canonicalRequirements, contradictoryEffects, createPlan, } from './canonical.js';
|
|
3
3
|
import { createPlanningContext } from './context.js';
|
|
4
4
|
import { planEdge } from './edge.js';
|
|
5
5
|
import { planNode } from './node.js';
|
|
@@ -13,6 +13,7 @@ export function plan(input) {
|
|
|
13
13
|
planEdge(edge, context);
|
|
14
14
|
for (const selection of input.desired.selections)
|
|
15
15
|
planSelection(selection, context);
|
|
16
|
+
context.conflicts.push(...contradictoryEffects(context.effects));
|
|
16
17
|
if (context.conflicts.length > 0) {
|
|
17
18
|
return Object.freeze({
|
|
18
19
|
kind: 'conflict',
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { K } from '../kernel/schema.js';
|
|
2
|
+
/** The Kernel instance of the authority vocabulary; Core Auth interprets authority through it. */
|
|
3
|
+
export const authorityVocabulary = Object.freeze({
|
|
4
|
+
identity: ref(K.classes.Identity.ref),
|
|
5
|
+
composition: Object.freeze({
|
|
6
|
+
extension: ref(K.classes.extends_with.ref),
|
|
7
|
+
constraint: ref(K.classes.constrained_by.ref),
|
|
8
|
+
exclusion: ref(K.classes.excluded_from.ref),
|
|
9
|
+
}),
|
|
10
|
+
capabilities: Object.freeze({
|
|
11
|
+
create: ref(K.classes.can_create.ref),
|
|
12
|
+
read: ref(K.classes.can_read.ref),
|
|
13
|
+
traverse: ref(K.classes.can_traverse.ref),
|
|
14
|
+
update: ref(K.classes.can_update.ref),
|
|
15
|
+
delete: ref(K.classes.can_delete.ref),
|
|
16
|
+
}),
|
|
17
|
+
instanceOf: ref(K.classes.instance_of.ref),
|
|
18
|
+
});
|
|
19
|
+
function ref(value) {
|
|
20
|
+
return Object.freeze({
|
|
21
|
+
origin: value.origin,
|
|
22
|
+
kind: 'class',
|
|
23
|
+
name: value.name,
|
|
24
|
+
});
|
|
25
|
+
}
|