@astrale-os/kernel-core 0.9.0-beta.38 → 0.9.0-beta.39

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.
@@ -44,6 +44,13 @@ function admit(input, path, locals, subjectBound, depth) {
44
44
  grant: acceptGrant(value.grant),
45
45
  where: admit(required(value.where, `${path}/where`), `${path}/where`, locals, true, depth + 1),
46
46
  };
47
+ case 'same-node':
48
+ exact(value, ['op', 'left', 'right'], path);
49
+ return {
50
+ op: 'same-node',
51
+ left: term(value.left, `${path}/left`, locals, subjectBound),
52
+ right: term(value.right, `${path}/right`, locals, subjectBound),
53
+ };
47
54
  case 'related': {
48
55
  const hasRepeat = Object.hasOwn(value, 'repeat');
49
56
  exact(value, hasRepeat
@@ -119,6 +126,16 @@ function term(input, path, locals, subjectBound) {
119
126
  case 'domain':
120
127
  exact(value, ['kind', 'origin'], path);
121
128
  return { kind: 'domain', origin: domainOrigin(value.origin, `${path}/origin`) };
129
+ case 'ref': {
130
+ exact(value, ['kind', 'ref'], path);
131
+ const ref = absoluteRef(value.ref, `${path}/ref`);
132
+ if (ref.kind === 'core')
133
+ return { kind: 'ref', ref: coreRef(value.ref, `${path}/ref`) };
134
+ if (!['class', 'function', 'policy', 'view'].includes(ref.kind))
135
+ invalid(`${path}/ref/kind`, 'Expected a projected Schema member');
136
+ definitionName(ref.name, `${path}/ref/name`);
137
+ return { kind: 'ref', ref: ref };
138
+ }
122
139
  case 'core':
123
140
  exact(value, ['kind', 'ref'], path);
124
141
  return { kind: 'core', ref: coreRef(value.ref, `${path}/ref`) };
@@ -1,7 +1,8 @@
1
1
  import type { ClassRef, CoreRef, Key } from '@astrale-os/kernel-dsl/v1/addressing';
2
+ import type { PolicyObjectRef } from '@astrale-os/kernel-dsl/v1/language';
2
3
  import type { NodeId } from '../../../graph/node/index.js';
3
4
  import type { Grant } from '../../grant/index.js';
4
- export declare const AUTHORITY_PREDICATE_VERSION: 7;
5
+ export declare const AUTHORITY_PREDICATE_VERSION: 8;
5
6
  export type Operation = 'create' | 'read' | 'traverse' | 'update' | 'delete';
6
7
  export type Input = 'object' | 'source' | 'target';
7
8
  export type { ClassRef } from '@astrale-os/kernel-dsl/v1/addressing';
@@ -20,6 +21,9 @@ export type Term = {
20
21
  } | {
21
22
  readonly kind: 'core';
22
23
  readonly ref: CoreRef;
24
+ } | {
25
+ readonly kind: 'ref';
26
+ readonly ref: PolicyObjectRef;
23
27
  } | {
24
28
  readonly kind: 'local';
25
29
  readonly id: number;
@@ -46,6 +50,10 @@ export interface Requirement {
46
50
  readonly evidence: 'allowed' | 'owner';
47
51
  }
48
52
  export type AuthorityExpr = {
53
+ readonly op: 'same-node';
54
+ readonly left: Term;
55
+ readonly right: Term;
56
+ } | {
49
57
  readonly op: 'true';
50
58
  } | {
51
59
  readonly op: 'false';
@@ -1 +1 @@
1
- export const AUTHORITY_PREDICATE_VERSION = 7;
1
+ export const AUTHORITY_PREDICATE_VERSION = 8;
@@ -39,6 +39,13 @@ function normalize(expr, path, locals, subjectBound) {
39
39
  grant: canonicalizeGrant(expr.grant),
40
40
  where: normalize(expr.where, `${path}/where`, locals, true),
41
41
  });
42
+ case 'same-node': {
43
+ const left = normalizeTerm(expr.left);
44
+ const right = normalizeTerm(expr.right);
45
+ return Object.freeze(compare(portable.json.serialize(left), portable.json.serialize(right)) <= 0
46
+ ? { op: 'same-node', left, right }
47
+ : { op: 'same-node', left: right, right: left });
48
+ }
42
49
  case 'related':
43
50
  return Object.freeze({
44
51
  op: 'related',
@@ -114,6 +121,8 @@ function normalizeTerm(term) {
114
121
  return Object.freeze({ kind: 'class', ref: Object.freeze({ ...term.ref }) });
115
122
  case 'domain':
116
123
  return Object.freeze({ kind: 'domain', origin: term.origin });
124
+ case 'ref':
125
+ return Object.freeze({ kind: 'ref', ref: Object.freeze({ ...term.ref }) });
117
126
  case 'core':
118
127
  return Object.freeze({ kind: 'core', ref: Object.freeze({ ...term.ref }) });
119
128
  case 'local':
@@ -6474,6 +6474,31 @@ export declare const KernelRootFunctions: readonly ((import("@astrale-os/kernel-
6474
6474
  readonly value: string;
6475
6475
  }, true, "default", "authenticated", import("@astrale-os/kernel-dsl/v1").PolicyCheckExpression<import("@astrale-os/kernel-dsl/v1").PolicyRef, import("@astrale-os/kernel-dsl/v1/language").PolicyCheckObject>, "kernel.astrale.ai:class.Identity.method.mint"> & {
6476
6476
  readonly name: "mint";
6477
+ }) | (import("@astrale-os/kernel-dsl/v1").ResolvedMethod<{
6478
+ iss: string;
6479
+ sub: string;
6480
+ }, {
6481
+ readonly mode: 'value';
6482
+ readonly value: {
6483
+ id: string;
6484
+ iss: string;
6485
+ sub: string;
6486
+ frozen: boolean;
6487
+ requiredClaims: ({
6488
+ claim: string;
6489
+ op: "contains";
6490
+ value: unknown;
6491
+ } | {
6492
+ claim: string;
6493
+ op: "eq";
6494
+ value: unknown;
6495
+ } | {
6496
+ claim: string;
6497
+ op: "exists";
6498
+ })[];
6499
+ } | null;
6500
+ }, true, "default", "authorized", import("@astrale-os/kernel-dsl/v1").PolicyCheckExpression<import("@astrale-os/kernel-dsl/v1").PolicyRef, import("@astrale-os/kernel-dsl/v1/language").PolicyCheckObject>, "kernel.astrale.ai:class.Identity.method.whois"> & {
6501
+ readonly name: "whois";
6477
6502
  }) | (import("@astrale-os/kernel-dsl/v1").ResolvedMethod<{
6478
6503
  target: string;
6479
6504
  }, {
@@ -6508,31 +6533,6 @@ export declare const KernelRootFunctions: readonly ((import("@astrale-os/kernel-
6508
6533
  };
6509
6534
  }, true, "sealed", "authorized", import("@astrale-os/kernel-dsl/v1").PolicyCheckExpression<import("@astrale-os/kernel-dsl/v1").PolicyRef, import("@astrale-os/kernel-dsl/v1/language").PolicyCheckObject>, "kernel.astrale.ai:class.View.method.resolve"> & {
6510
6535
  readonly name: "resolve";
6511
- }) | (import("@astrale-os/kernel-dsl/v1").ResolvedMethod<{
6512
- iss: string;
6513
- sub: string;
6514
- }, {
6515
- readonly mode: 'value';
6516
- readonly value: {
6517
- id: string;
6518
- iss: string;
6519
- sub: string;
6520
- frozen: boolean;
6521
- requiredClaims: ({
6522
- claim: string;
6523
- op: "contains";
6524
- value: unknown;
6525
- } | {
6526
- claim: string;
6527
- op: "eq";
6528
- value: unknown;
6529
- } | {
6530
- claim: string;
6531
- op: "exists";
6532
- })[];
6533
- } | null;
6534
- }, true, "default", "authorized", import("@astrale-os/kernel-dsl/v1").PolicyCheckExpression<import("@astrale-os/kernel-dsl/v1").PolicyRef, import("@astrale-os/kernel-dsl/v1/language").PolicyCheckObject>, "kernel.astrale.ai:class.Identity.method.whois"> & {
6535
- readonly name: "whois";
6536
6536
  }))[];
6537
6537
  export { AuthorityOperationOrder, AuthorityOperations, operationOf } from '../authority/index.js';
6538
6538
  export type { AuthorityOperation, AuthorityRelation } from '../authority/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-core",
3
- "version": "0.9.0-beta.38",
3
+ "version": "0.9.0-beta.39",
4
4
  "description": "Astrale Kernel Core - Types, Invariants, and Pure Logic",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -160,7 +160,7 @@
160
160
  "access": "public"
161
161
  },
162
162
  "dependencies": {
163
- "@astrale-os/kernel-dsl": "0.2.0-beta.29",
163
+ "@astrale-os/kernel-dsl": "0.2.0-beta.30",
164
164
  "@noble/hashes": "2.3.0",
165
165
  "@types/json-schema": "^7.0.15",
166
166
  "dequal": "2.0.3"