@astrale-os/kernel-core 0.9.0-beta.47 → 0.9.0-beta.49

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.
@@ -0,0 +1,2 @@
1
+ /** Canonical form, not an authorization decision. Crossing values still require admission. */
2
+ export declare function isCanonical(input: unknown): boolean;
@@ -0,0 +1,15 @@
1
+ import * as portable from '@astrale-os/kernel-dsl/value';
2
+ import { accept } from './accept.js';
3
+ import { ownsCanonical } from './ownership.optimization.js';
4
+ /** Canonical form, not an authorization decision. Crossing values still require admission. */
5
+ export function isCanonical(input) {
6
+ if (ownsCanonical(input))
7
+ return true;
8
+ try {
9
+ const canonical = accept(input);
10
+ return portable.json.serialize(canonical) === portable.json.serialize(input);
11
+ }
12
+ catch {
13
+ return false;
14
+ }
15
+ }
@@ -1,4 +1,5 @@
1
1
  export { accept } from './accept.js';
2
+ export { isCanonical } from './canonical.js';
2
3
  export { limits } from './admission/index.js';
3
4
  export { canonicalize } from './normalization/index.js';
4
5
  export { AUTHORITY_PREDICATE_VERSION } from './language/index.js';
@@ -1,4 +1,5 @@
1
1
  export { accept } from './accept.js';
2
+ export { isCanonical } from './canonical.js';
2
3
  export { limits } from './admission/index.js';
3
4
  export { canonicalize } from './normalization/index.js';
4
5
  export { AUTHORITY_PREDICATE_VERSION } from './language/index.js';
@@ -4,16 +4,17 @@ import { AuthValueError } from '../../error.js';
4
4
  import { canonicalize as canonicalizeGrant } from '../../grant/index.js';
5
5
  import { admitAuthorityExpr, limits } from '../admission/index.js';
6
6
  import { AUTHORITY_PREDICATE_VERSION } from '../language/index.js';
7
+ import { ownCanonical } from '../ownership.optimization.js';
7
8
  /** Validate and canonicalize one authority expression into its versioned crossing envelope. */
8
9
  export function canonicalize(expr) {
9
10
  const admitted = admitAuthorityExpr(portable.accept(expr));
10
11
  return canonicalizeAdmitted(admitted);
11
12
  }
12
13
  export function canonicalizeAdmitted(expr) {
13
- return Object.freeze({
14
+ return ownCanonical(Object.freeze({
14
15
  version: AUTHORITY_PREDICATE_VERSION,
15
16
  predicate: normalize(expr, '/predicate', new Set(), false),
16
- });
17
+ }));
17
18
  }
18
19
  function normalize(expr, path, locals, subjectBound) {
19
20
  switch (expr.op) {
@@ -0,0 +1,4 @@
1
+ import type { AuthorityPredicate } from './language/index.js';
2
+ /** Called only by the owner after detachment, admission and immutable normalization. */
3
+ export declare function ownCanonical(predicate: AuthorityPredicate): AuthorityPredicate;
4
+ export declare function ownsCanonical(input: unknown): boolean;
@@ -0,0 +1,10 @@
1
+ // Static construction provenance only. No evaluated authority or graph facts live here.
2
+ const canonical = new WeakSet();
3
+ /** Called only by the owner after detachment, admission and immutable normalization. */
4
+ export function ownCanonical(predicate) {
5
+ canonical.add(predicate);
6
+ return predicate;
7
+ }
8
+ export function ownsCanonical(input) {
9
+ return input !== null && typeof input === 'object' && canonical.has(input);
10
+ }
@@ -5503,6 +5503,32 @@ export declare const KernelRootFunctions: readonly ((import("@astrale-os/kernel-
5503
5503
  }, true, false, "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.impersonate"> & {
5504
5504
  readonly name: "impersonate";
5505
5505
  readonly executable: true;
5506
+ }) | (import("@astrale-os/kernel-dsl/v1").ResolvedMethod<{
5507
+ iss: string;
5508
+ sub: string;
5509
+ }, {
5510
+ readonly mode: 'value';
5511
+ readonly value: {
5512
+ id: string;
5513
+ iss: string;
5514
+ sub: string;
5515
+ frozen: boolean;
5516
+ requiredClaims: ({
5517
+ claim: string;
5518
+ op: "contains";
5519
+ value: unknown;
5520
+ } | {
5521
+ claim: string;
5522
+ op: "eq";
5523
+ value: unknown;
5524
+ } | {
5525
+ claim: string;
5526
+ op: "exists";
5527
+ })[];
5528
+ } | null;
5529
+ }, true, false, "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"> & {
5530
+ readonly name: "whois";
5531
+ readonly executable: true;
5506
5532
  }) | (import("@astrale-os/kernel-dsl/v1").ResolvedMethod<{
5507
5533
  target: string;
5508
5534
  }, {
@@ -5545,32 +5571,6 @@ export declare const KernelRootFunctions: readonly ((import("@astrale-os/kernel-
5545
5571
  }, true, false, "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"> & {
5546
5572
  readonly name: "resolve";
5547
5573
  readonly executable: true;
5548
- }) | (import("@astrale-os/kernel-dsl/v1").ResolvedMethod<{
5549
- iss: string;
5550
- sub: string;
5551
- }, {
5552
- readonly mode: 'value';
5553
- readonly value: {
5554
- id: string;
5555
- iss: string;
5556
- sub: string;
5557
- frozen: boolean;
5558
- requiredClaims: ({
5559
- claim: string;
5560
- op: "contains";
5561
- value: unknown;
5562
- } | {
5563
- claim: string;
5564
- op: "eq";
5565
- value: unknown;
5566
- } | {
5567
- claim: string;
5568
- op: "exists";
5569
- })[];
5570
- } | null;
5571
- }, true, false, "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"> & {
5572
- readonly name: "whois";
5573
- readonly executable: true;
5574
5574
  }))[];
5575
5575
  export { AuthorityOperationOrder, AuthorityOperations, operationOf } from '../authority/index.js';
5576
5576
  export type { AuthorityOperation, AuthorityRelation } from '../authority/index.js';
@@ -379,6 +379,29 @@ export declare const Functions: Readonly<{
379
379
  };
380
380
  })[];
381
381
  operations: ({
382
+ op: "edge.update";
383
+ edge: {
384
+ source: string;
385
+ target: string;
386
+ class: string;
387
+ };
388
+ slug: unknown;
389
+ props?: {
390
+ set: Record<string, unknown>;
391
+ unset: string[];
392
+ } | undefined;
393
+ } | {
394
+ op: "edge.update";
395
+ edge: {
396
+ source: string;
397
+ target: string;
398
+ class: string;
399
+ };
400
+ props: {
401
+ set: Record<string, unknown>;
402
+ unset: string[];
403
+ };
404
+ } | {
382
405
  op: "node.create";
383
406
  as: string;
384
407
  class: string;
@@ -406,29 +429,6 @@ export declare const Functions: Readonly<{
406
429
  };
407
430
  slug?: unknown;
408
431
  props: Record<string, unknown>;
409
- } | {
410
- op: "edge.update";
411
- edge: {
412
- source: string;
413
- target: string;
414
- class: string;
415
- };
416
- slug: unknown;
417
- props?: {
418
- set: Record<string, unknown>;
419
- unset: string[];
420
- } | undefined;
421
- } | {
422
- op: "edge.update";
423
- edge: {
424
- source: string;
425
- target: string;
426
- class: string;
427
- };
428
- props: {
429
- set: Record<string, unknown>;
430
- unset: string[];
431
- };
432
432
  } | {
433
433
  op: "edge.delete";
434
434
  edge: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-core",
3
- "version": "0.9.0-beta.47",
3
+ "version": "0.9.0-beta.49",
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.33",
163
+ "@astrale-os/kernel-dsl": "0.2.0-beta.34",
164
164
  "@noble/hashes": "2.3.0",
165
165
  "@types/json-schema": "^7.0.15",
166
166
  "dequal": "2.0.3"