@astrale-os/kernel-core 0.9.0-beta.35 → 0.9.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.
@@ -89,7 +89,8 @@ function normalizeBoolean(op, input, path, locals, subjectBound) {
89
89
  for (const expr of flattened) {
90
90
  if (expr.op === identity)
91
91
  continue;
92
- unique.set(portable.json.serialize(expr), expr);
92
+ // Admission and normalization own these detached subtrees; sorting does not lose that proof.
93
+ unique.set(portable.json.serializeAdmitted(expr), expr);
93
94
  }
94
95
  const predicates = [...unique.entries()]
95
96
  .sort(([left], [right]) => compare(left, right))
@@ -1,5 +1,4 @@
1
- import { isNodeId } from '../../node/index.js';
2
- import { Path } from '../../path/index.js';
1
+ import { Path, PathError } from '../../path/index.js';
3
2
  import { MutationLanguage } from '../language/index.js';
4
3
  /** Lower rich TypeScript inputs into the one canonical public MutationAST representation. */
5
4
  export function createMutationAST(input) {
@@ -69,6 +68,9 @@ function lowerOperation(operation) {
69
68
  }
70
69
  }
71
70
  function lowerEndpoint(endpoint) {
71
+ if (typeof endpoint === 'object' && endpoint !== null && 'kind' in endpoint) {
72
+ return nodeTargetText(endpoint);
73
+ }
72
74
  return typeof endpoint === 'object' && endpoint !== null && 'created' in endpoint
73
75
  ? endpoint
74
76
  : nodeTargetText(endpoint);
@@ -84,9 +86,15 @@ function pathText(path) {
84
86
  return nodeTargetText(path);
85
87
  }
86
88
  function nodeTargetText(target) {
87
- if (target instanceof Path)
88
- return target.raw;
89
- return isNodeId(target) ? Path.id(target).raw : target;
89
+ try {
90
+ return Path.target(target).raw;
91
+ }
92
+ catch (cause) {
93
+ // The Mutation codec owns invalid-input errors and their operation/precondition coordinates.
94
+ if (cause instanceof PathError)
95
+ return target;
96
+ throw cause;
97
+ }
90
98
  }
91
99
  function mutationProps(input) {
92
100
  return input;
@@ -1,4 +1,4 @@
1
- import type { CoreRef, DefinitionRef, Key } from '@astrale-os/kernel-dsl/v1/addressing';
1
+ import type { DefinitionRef, Key } from '@astrale-os/kernel-dsl/v1/addressing';
2
2
  import { type ClassKey as ClassKeyValue } from '@astrale-os/kernel-dsl/v1/addressing';
3
3
  import type { NodeId } from '../../node/identity/index.js';
4
4
  import type { DomainAnchor as PathDomainAnchor, DomainProjection as PathDomainProjection, IdAnchor as PathIdAnchor, MethodStep as PathMethodStep, NodePath, PathAST, PathAnchor, PathDiagnostic, PathDiagnosticCode, PathStep, ProjectionKind as PathProjectionKind, ProjectionStep as PathProjectionStep, TraversalStep as PathTraversalStep } from '../language/index.js';
@@ -11,6 +11,8 @@ export declare class Path {
11
11
  private constructor();
12
12
  /** Retain an admitted rich Path or parse its canonical serialized form. */
13
13
  static from(input: PathLike): Path;
14
+ /** Normalize an exact graph target without resolving its installed Node identity. */
15
+ static target(input: NodeTarget): Path;
14
16
  static parse(input: string): Path;
15
17
  static fromAST(ast: Path.AST): Path;
16
18
  static id(id: NodeId): Path.Id;
@@ -27,8 +29,8 @@ export declare class Path {
27
29
  }
28
30
  /** Rich or already-admitted serialized Path accepted at in-process authoring boundaries. */
29
31
  export type PathLike = Path | NodePath;
30
- /** Exact existing Node accepted by ID-first graph authoring facades. */
31
- export type NodeTarget = NodeId | PathLike;
32
+ /** Exact existing Node; DefinitionRefs address their projected graph nodes, not Class extents. */
33
+ export type NodeTarget = NodeId | PathLike | DefinitionRef;
32
34
  /** Runtime-established proof that a Path addresses one callable Node. */
33
35
  export type CallablePath = Path & {
34
36
  readonly [CALLABLE_PATH]: true;
@@ -46,7 +48,7 @@ export declare namespace Path {
46
48
  type ProjectionKind = PathProjectionKind;
47
49
  type DomainProjection = PathDomainProjection;
48
50
  /** Structured coordinate accepted for a graph-projected Definition or Core object. */
49
- type ProjectionRef = DefinitionRef<'class' | 'function' | 'policy' | 'view'> | CoreRef;
51
+ type ProjectionRef = DefinitionRef;
50
52
  interface TraversalOptions {
51
53
  readonly slug?: EdgeSlugValue;
52
54
  }
@@ -1,5 +1,6 @@
1
- import { ClassKey } from '@astrale-os/kernel-dsl/v1/addressing';
1
+ import { ClassKey, isDefinitionRef, } from '@astrale-os/kernel-dsl/v1/addressing';
2
2
  import { EdgeSlug } from '../../edge/slug/index.js';
3
+ import { isNodeId } from '../../node/identity/index.js';
3
4
  import { normalizePathAST, parsePathAST, pathError, serializePathAST } from '../language/index.js';
4
5
  /** Immutable rich value for one admitted NodePath. */
5
6
  export class Path {
@@ -10,6 +11,18 @@ export class Path {
10
11
  static from(input) {
11
12
  return input instanceof Path ? input : Path.parse(input);
12
13
  }
14
+ /** Normalize an exact graph target without resolving its installed Node identity. */
15
+ static target(input) {
16
+ if (input instanceof Path)
17
+ return input;
18
+ if (isNodeId(input))
19
+ return Path.id(input);
20
+ if (typeof input === 'string')
21
+ return Path.parse(input);
22
+ if (isDefinitionRef(input))
23
+ return Path.project(input);
24
+ throw pathError(input, 'PATH_INVALID_PROJECTION', 'Node target requires an ID, Path, or DefinitionRef.');
25
+ }
13
26
  static parse(input) {
14
27
  return createPath(parsePathAST(input));
15
28
  }
@@ -1,6 +1,5 @@
1
1
  import { ClassKey, PropertyKey, } from '@astrale-os/kernel-dsl/v1/addressing';
2
2
  import * as portable from '@astrale-os/kernel-dsl/value';
3
- import { isNodeId } from '../../node/index.js';
4
3
  import { Path } from '../../path/index.js';
5
4
  import { QueryAST as QueryASTBoundary, QueryASTDecodeError } from '../language/index.js';
6
5
  function from(input) {
@@ -373,9 +372,15 @@ function lowerNodeSource(input, index) {
373
372
  if (ClassKey.is(input)) {
374
373
  return Object.freeze({ kind: 'class', class: ClassKey.ref(input) });
375
374
  }
376
- if (input instanceof Path || typeof input === 'string') {
375
+ if (input instanceof Path ||
376
+ typeof input === 'string' ||
377
+ (isRecord(input) &&
378
+ (input.kind === 'core' ||
379
+ input.kind === 'function' ||
380
+ input.kind === 'policy' ||
381
+ input.kind === 'view'))) {
377
382
  try {
378
- const target = input instanceof Path ? input : isNodeId(input) ? Path.id(input) : Path.parse(input);
383
+ const target = Path.target(input);
379
384
  return Object.freeze({ kind: 'path', path: target.raw });
380
385
  }
381
386
  catch (cause) {
@@ -5625,6 +5625,16 @@ export declare const AuthorityRelations: Readonly<{
5625
5625
  }>;
5626
5626
  /** Exact authorized Kernel Functions for which pristine Root receives direct can_use authority. */
5627
5627
  export declare const KernelRootFunctions: readonly ((import("@astrale-os/kernel-dsl/v1").ResolvedFunction<{
5628
+ kind: "bundle" | "inspect";
5629
+ origin: string;
5630
+ }, {
5631
+ readonly mode: 'binary';
5632
+ }, "authenticated", import("@astrale-os/kernel-dsl/v1").PolicyCheckExpression<import("@astrale-os/kernel-dsl/v1").PolicyRef, import("@astrale-os/kernel-dsl/v1/language").PolicyCheckObject>> & {
5633
+ readonly ref: import("@astrale-os/kernel-dsl/v1").FunctionRef<"introspect"> & {
5634
+ readonly origin: "kernel.astrale.ai";
5635
+ };
5636
+ readonly key: "kernel.astrale.ai:function.introspect";
5637
+ }) | (import("@astrale-os/kernel-dsl/v1").ResolvedFunction<{
5628
5638
  operation: string;
5629
5639
  domains: ({
5630
5640
  artifact: {
@@ -5650,15 +5660,232 @@ export declare const KernelRootFunctions: readonly ((import("@astrale-os/kernel-
5650
5660
  };
5651
5661
  readonly key: "kernel.astrale.ai:function.install";
5652
5662
  }) | (import("@astrale-os/kernel-dsl/v1").ResolvedFunction<{
5653
- kind: "bundle" | "inspect";
5654
- origin: string;
5663
+ ast: {
5664
+ format: "astrale.graph.query";
5665
+ version: "v6";
5666
+ source: {
5667
+ kind: "node";
5668
+ terms: ({
5669
+ kind: "path";
5670
+ path: string;
5671
+ } | {
5672
+ kind: "class";
5673
+ class: {
5674
+ origin: string;
5675
+ kind: "class";
5676
+ name: string;
5677
+ };
5678
+ })[];
5679
+ binding: string;
5680
+ } | {
5681
+ kind: "edge";
5682
+ terms: {
5683
+ kind: "class";
5684
+ class: {
5685
+ origin: string;
5686
+ kind: "class";
5687
+ name: string;
5688
+ };
5689
+ }[];
5690
+ bindings: {
5691
+ source: string;
5692
+ edge: string;
5693
+ target: string;
5694
+ };
5695
+ };
5696
+ steps: ({
5697
+ op: "filter";
5698
+ binding: string;
5699
+ predicate: {
5700
+ kind: "class.satisfies";
5701
+ class: {
5702
+ origin: string;
5703
+ kind: "class";
5704
+ name: string;
5705
+ };
5706
+ } | {
5707
+ kind: "class.equal";
5708
+ class: {
5709
+ origin: string;
5710
+ kind: "class";
5711
+ name: string;
5712
+ };
5713
+ } | {
5714
+ kind: "property.equal";
5715
+ property: string;
5716
+ value: unknown;
5717
+ } | {
5718
+ kind: "property.present";
5719
+ property: string;
5720
+ } | {
5721
+ kind: "identity.equal";
5722
+ identity: string | {
5723
+ source: string;
5724
+ target: string;
5725
+ class: string;
5726
+ };
5727
+ };
5728
+ } | {
5729
+ op: "expand";
5730
+ from: string;
5731
+ via: {
5732
+ origin: string;
5733
+ kind: "class";
5734
+ name: string;
5735
+ }[];
5736
+ direction: "incident" | "incoming" | "outgoing";
5737
+ bindings: {
5738
+ edge: string;
5739
+ node: string;
5740
+ };
5741
+ })[];
5742
+ select: {
5743
+ kind: "graph";
5744
+ binding: string;
5745
+ order?: {
5746
+ property: string;
5747
+ direction: "asc" | "desc";
5748
+ unranked: "first" | "last";
5749
+ } | undefined;
5750
+ } | {
5751
+ kind: "nodes";
5752
+ binding: string;
5753
+ projection: {
5754
+ kind: "reference" | "value";
5755
+ };
5756
+ order?: {
5757
+ property: string;
5758
+ direction: "asc" | "desc";
5759
+ unranked: "first" | "last";
5760
+ } | undefined;
5761
+ } | {
5762
+ kind: "edges";
5763
+ binding: string;
5764
+ projection: {
5765
+ edge: "reference" | "value";
5766
+ source: "reference" | "value";
5767
+ target: "reference" | "value";
5768
+ };
5769
+ order?: {
5770
+ property: string;
5771
+ direction: "asc" | "desc";
5772
+ unranked: "first" | "last";
5773
+ } | undefined;
5774
+ };
5775
+ };
5776
+ expected?: {
5777
+ origin: string;
5778
+ revision: string;
5779
+ }[] | undefined;
5780
+ page: {
5781
+ size: number;
5782
+ after?: string | undefined;
5783
+ };
5655
5784
  }, {
5656
- readonly mode: 'binary';
5657
- }, "authenticated", import("@astrale-os/kernel-dsl/v1").PolicyCheckExpression<import("@astrale-os/kernel-dsl/v1").PolicyRef, import("@astrale-os/kernel-dsl/v1/language").PolicyCheckObject>> & {
5658
- readonly ref: import("@astrale-os/kernel-dsl/v1").FunctionRef<"introspect"> & {
5785
+ readonly mode: 'value';
5786
+ readonly value: {
5787
+ result: {
5788
+ kind: "graph";
5789
+ graph: {
5790
+ nodes: {
5791
+ id: string;
5792
+ class: string;
5793
+ props: Record<string, unknown>;
5794
+ }[];
5795
+ edges: {
5796
+ source: string;
5797
+ target: string;
5798
+ class: string;
5799
+ slug?: import("../../graph/edge/index.js").EdgeSlug | undefined;
5800
+ props: Record<string, unknown>;
5801
+ }[];
5802
+ };
5803
+ selection: {
5804
+ kind: "node";
5805
+ ids: string[];
5806
+ } | {
5807
+ kind: "edge";
5808
+ keys: {
5809
+ source: string;
5810
+ target: string;
5811
+ class: string;
5812
+ }[];
5813
+ };
5814
+ } | {
5815
+ kind: "nodes";
5816
+ nodes: ({
5817
+ kind: "reference";
5818
+ value: {
5819
+ id: string;
5820
+ class: string;
5821
+ };
5822
+ } | {
5823
+ kind: "value";
5824
+ value: {
5825
+ id: string;
5826
+ class: string;
5827
+ props: Record<string, unknown>;
5828
+ };
5829
+ })[];
5830
+ } | {
5831
+ kind: "edges";
5832
+ edges: {
5833
+ edge: {
5834
+ kind: "reference";
5835
+ value: {
5836
+ source: string;
5837
+ target: string;
5838
+ class: string;
5839
+ };
5840
+ } | {
5841
+ kind: "value";
5842
+ value: {
5843
+ source: string;
5844
+ target: string;
5845
+ class: string;
5846
+ slug?: import("../../graph/edge/index.js").EdgeSlug | undefined;
5847
+ props: Record<string, unknown>;
5848
+ };
5849
+ };
5850
+ source: {
5851
+ kind: "reference";
5852
+ value: {
5853
+ id: string;
5854
+ class: string;
5855
+ };
5856
+ } | {
5857
+ kind: "value";
5858
+ value: {
5859
+ id: string;
5860
+ class: string;
5861
+ props: Record<string, unknown>;
5862
+ };
5863
+ };
5864
+ target: {
5865
+ kind: "reference";
5866
+ value: {
5867
+ id: string;
5868
+ class: string;
5869
+ };
5870
+ } | {
5871
+ kind: "value";
5872
+ value: {
5873
+ id: string;
5874
+ class: string;
5875
+ props: Record<string, unknown>;
5876
+ };
5877
+ };
5878
+ }[];
5879
+ };
5880
+ page: {
5881
+ next?: string | undefined;
5882
+ };
5883
+ };
5884
+ }, "authorized", import("@astrale-os/kernel-dsl/v1").PolicyCheckExpression<import("@astrale-os/kernel-dsl/v1").PolicyRef, import("@astrale-os/kernel-dsl/v1/language").PolicyCheckObject>> & {
5885
+ readonly ref: import("@astrale-os/kernel-dsl/v1").FunctionRef<"query"> & {
5659
5886
  readonly origin: "kernel.astrale.ai";
5660
5887
  };
5661
- readonly key: "kernel.astrale.ai:function.introspect";
5888
+ readonly key: "kernel.astrale.ai:function.query";
5662
5889
  }) | (import("@astrale-os/kernel-dsl/v1").ResolvedFunction<{
5663
5890
  invocation?: {
5664
5891
  source: string;
@@ -6193,233 +6420,6 @@ export declare const KernelRootFunctions: readonly ((import("@astrale-os/kernel-
6193
6420
  readonly origin: "kernel.astrale.ai";
6194
6421
  };
6195
6422
  readonly key: "kernel.astrale.ai:function.provision";
6196
- }) | (import("@astrale-os/kernel-dsl/v1").ResolvedFunction<{
6197
- ast: {
6198
- format: "astrale.graph.query";
6199
- version: "v6";
6200
- source: {
6201
- kind: "node";
6202
- terms: ({
6203
- kind: "path";
6204
- path: string;
6205
- } | {
6206
- kind: "class";
6207
- class: {
6208
- origin: string;
6209
- kind: "class";
6210
- name: string;
6211
- };
6212
- })[];
6213
- binding: string;
6214
- } | {
6215
- kind: "edge";
6216
- terms: {
6217
- kind: "class";
6218
- class: {
6219
- origin: string;
6220
- kind: "class";
6221
- name: string;
6222
- };
6223
- }[];
6224
- bindings: {
6225
- source: string;
6226
- edge: string;
6227
- target: string;
6228
- };
6229
- };
6230
- steps: ({
6231
- op: "filter";
6232
- binding: string;
6233
- predicate: {
6234
- kind: "class.satisfies";
6235
- class: {
6236
- origin: string;
6237
- kind: "class";
6238
- name: string;
6239
- };
6240
- } | {
6241
- kind: "class.equal";
6242
- class: {
6243
- origin: string;
6244
- kind: "class";
6245
- name: string;
6246
- };
6247
- } | {
6248
- kind: "property.equal";
6249
- property: string;
6250
- value: unknown;
6251
- } | {
6252
- kind: "property.present";
6253
- property: string;
6254
- } | {
6255
- kind: "identity.equal";
6256
- identity: string | {
6257
- source: string;
6258
- target: string;
6259
- class: string;
6260
- };
6261
- };
6262
- } | {
6263
- op: "expand";
6264
- from: string;
6265
- via: {
6266
- origin: string;
6267
- kind: "class";
6268
- name: string;
6269
- }[];
6270
- direction: "incident" | "incoming" | "outgoing";
6271
- bindings: {
6272
- edge: string;
6273
- node: string;
6274
- };
6275
- })[];
6276
- select: {
6277
- kind: "graph";
6278
- binding: string;
6279
- order?: {
6280
- property: string;
6281
- direction: "asc" | "desc";
6282
- unranked: "first" | "last";
6283
- } | undefined;
6284
- } | {
6285
- kind: "nodes";
6286
- binding: string;
6287
- projection: {
6288
- kind: "reference" | "value";
6289
- };
6290
- order?: {
6291
- property: string;
6292
- direction: "asc" | "desc";
6293
- unranked: "first" | "last";
6294
- } | undefined;
6295
- } | {
6296
- kind: "edges";
6297
- binding: string;
6298
- projection: {
6299
- edge: "reference" | "value";
6300
- source: "reference" | "value";
6301
- target: "reference" | "value";
6302
- };
6303
- order?: {
6304
- property: string;
6305
- direction: "asc" | "desc";
6306
- unranked: "first" | "last";
6307
- } | undefined;
6308
- };
6309
- };
6310
- expected?: {
6311
- origin: string;
6312
- revision: string;
6313
- }[] | undefined;
6314
- page: {
6315
- size: number;
6316
- after?: string | undefined;
6317
- };
6318
- }, {
6319
- readonly mode: 'value';
6320
- readonly value: {
6321
- result: {
6322
- kind: "graph";
6323
- graph: {
6324
- nodes: {
6325
- id: string;
6326
- class: string;
6327
- props: Record<string, unknown>;
6328
- }[];
6329
- edges: {
6330
- source: string;
6331
- target: string;
6332
- class: string;
6333
- slug?: import("../../graph/edge/index.js").EdgeSlug | undefined;
6334
- props: Record<string, unknown>;
6335
- }[];
6336
- };
6337
- selection: {
6338
- kind: "node";
6339
- ids: string[];
6340
- } | {
6341
- kind: "edge";
6342
- keys: {
6343
- source: string;
6344
- target: string;
6345
- class: string;
6346
- }[];
6347
- };
6348
- } | {
6349
- kind: "nodes";
6350
- nodes: ({
6351
- kind: "reference";
6352
- value: {
6353
- id: string;
6354
- class: string;
6355
- };
6356
- } | {
6357
- kind: "value";
6358
- value: {
6359
- id: string;
6360
- class: string;
6361
- props: Record<string, unknown>;
6362
- };
6363
- })[];
6364
- } | {
6365
- kind: "edges";
6366
- edges: {
6367
- edge: {
6368
- kind: "reference";
6369
- value: {
6370
- source: string;
6371
- target: string;
6372
- class: string;
6373
- };
6374
- } | {
6375
- kind: "value";
6376
- value: {
6377
- source: string;
6378
- target: string;
6379
- class: string;
6380
- slug?: import("../../graph/edge/index.js").EdgeSlug | undefined;
6381
- props: Record<string, unknown>;
6382
- };
6383
- };
6384
- source: {
6385
- kind: "reference";
6386
- value: {
6387
- id: string;
6388
- class: string;
6389
- };
6390
- } | {
6391
- kind: "value";
6392
- value: {
6393
- id: string;
6394
- class: string;
6395
- props: Record<string, unknown>;
6396
- };
6397
- };
6398
- target: {
6399
- kind: "reference";
6400
- value: {
6401
- id: string;
6402
- class: string;
6403
- };
6404
- } | {
6405
- kind: "value";
6406
- value: {
6407
- id: string;
6408
- class: string;
6409
- props: Record<string, unknown>;
6410
- };
6411
- };
6412
- }[];
6413
- };
6414
- page: {
6415
- next?: string | undefined;
6416
- };
6417
- };
6418
- }, "authorized", import("@astrale-os/kernel-dsl/v1").PolicyCheckExpression<import("@astrale-os/kernel-dsl/v1").PolicyRef, import("@astrale-os/kernel-dsl/v1/language").PolicyCheckObject>> & {
6419
- readonly ref: import("@astrale-os/kernel-dsl/v1").FunctionRef<"query"> & {
6420
- readonly origin: "kernel.astrale.ai";
6421
- };
6422
- readonly key: "kernel.astrale.ai:function.query";
6423
6423
  }) | (import("@astrale-os/kernel-dsl/v1").ResolvedFunction<{
6424
6424
  operation: string;
6425
6425
  domains: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-core",
3
- "version": "0.9.0-beta.35",
3
+ "version": "0.9.0-beta.36",
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.26",
163
+ "@astrale-os/kernel-dsl": "0.2.0-beta.27",
164
164
  "@noble/hashes": "2.3.0",
165
165
  "@types/json-schema": "^7.0.15",
166
166
  "dequal": "2.0.3"