@ldclabs/kip-lang 0.4.0 → 2.0.0

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 (54) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/LICENSE +21 -0
  3. package/README.md +89 -64
  4. package/dist/ast.d.ts +511 -145
  5. package/dist/ast.d.ts.map +1 -1
  6. package/dist/diagnostics.d.ts +8 -2
  7. package/dist/diagnostics.d.ts.map +1 -1
  8. package/dist/diagnostics.js +32 -3
  9. package/dist/diagnostics.js.map +1 -1
  10. package/dist/exec-ast.d.ts +514 -149
  11. package/dist/exec-ast.d.ts.map +1 -1
  12. package/dist/exec-ast.js +8 -7
  13. package/dist/exec-ast.js.map +1 -1
  14. package/dist/formatter.d.ts.map +1 -1
  15. package/dist/formatter.js +870 -479
  16. package/dist/formatter.js.map +1 -1
  17. package/dist/index.d.ts +4 -4
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +2 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/lexer.d.ts.map +1 -1
  22. package/dist/lexer.js +12 -30
  23. package/dist/lexer.js.map +1 -1
  24. package/dist/lower.d.ts +1 -2
  25. package/dist/lower.d.ts.map +1 -1
  26. package/dist/lower.js +1287 -598
  27. package/dist/lower.js.map +1 -1
  28. package/dist/parser.d.ts.map +1 -1
  29. package/dist/parser.js +2410 -1300
  30. package/dist/parser.js.map +1 -1
  31. package/dist/semantics.d.ts +11 -7
  32. package/dist/semantics.d.ts.map +1 -1
  33. package/dist/semantics.js +295 -180
  34. package/dist/semantics.js.map +1 -1
  35. package/dist/token.d.ts +130 -40
  36. package/dist/token.d.ts.map +1 -1
  37. package/dist/token.js +264 -83
  38. package/dist/token.js.map +1 -1
  39. package/dist/version.d.ts +2 -2
  40. package/dist/version.js +2 -2
  41. package/package.json +35 -5
  42. package/src/ast.ts +914 -0
  43. package/src/budget.ts +108 -0
  44. package/src/diagnostics.ts +182 -0
  45. package/src/errors.ts +42 -0
  46. package/src/exec-ast.ts +614 -0
  47. package/src/formatter.ts +1339 -0
  48. package/src/index.ts +226 -0
  49. package/src/lexer.ts +459 -0
  50. package/src/lower.ts +2011 -0
  51. package/src/parser.ts +3506 -0
  52. package/src/semantics.ts +392 -0
  53. package/src/token.ts +408 -0
  54. package/src/version.ts +13 -0
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The *executable* KIP AST.
2
+ * The *executable* KIP 2.0 AST.
3
3
  *
4
4
  * This is a different tree from `ast.ts`, on purpose. `ast.ts` is a syntax
5
5
  * tree: it keeps ranges, comments, quoting style and raw number text, because
@@ -7,23 +7,46 @@
7
7
  * engine needs instead — every construct already collapsed to the one shape it
8
8
  * means, with the open-ended parts of the grammar closed:
9
9
  *
10
- * - a concept matcher is one of four identified forms, not a bag of entries;
10
+ * - a predicate is an atom or a path, not a nested alternation/quantifier tree;
11
11
  * - a filter is a comparison, a logical node, a negation, or a call to one of
12
- * seven functions, not a general expression tree;
13
- * - a variable is a name and a dot path, not a chain of member accesses.
12
+ * the registered functions, not a general expression tree;
13
+ * - a variable is a name and a path of steps, not a chain of member accesses;
14
+ * - `ASSERT` is gone: it has been desugared to the parts it is defined as.
14
15
  *
15
16
  * A consumer switching on these tags is total: there is no "some other
16
17
  * function name" case to defend against, because `lower` rejected it.
17
18
  *
18
- * The shape is the wire form of `anda_kip`'s Rust AST (serde's default
19
- * externally-tagged enum encoding), so an engine can consume either
20
- * interchangeably and a differential test can compare them field for field.
19
+ * The shape follows serde's default externally-tagged enum encoding, so a
20
+ * Rust engine can consume it directly and a differential test can compare the
21
+ * two field for field.
21
22
  */
22
- /** A JSON value, as carried by attribute and metadata blocks. */
23
- export type Json = null | boolean | number | string | Json[] | {
24
- [key: string]: Json;
23
+ /**
24
+ * A `data_value`: a value that may still contain unbound parameters.
25
+ *
26
+ * The grammar admits `parameter` at every depth of an array or object, so no
27
+ * assignment, option block or epistemic setting is plain JSON. A subtree with
28
+ * nothing left to bind collapses to `Value`; anything else keeps its shape so
29
+ * the runtime envelope can fill the holes without touching text.
30
+ */
31
+ export type BoundValue = {
32
+ Value: KipValue;
33
+ } | {
34
+ Param: string;
35
+ } | {
36
+ Handle: string;
37
+ } | {
38
+ Variable: DotPathVar;
39
+ } | {
40
+ Array: BoundValue[];
41
+ } | {
42
+ Object: [string, BoundValue][];
25
43
  };
26
- /** A KIP literal. Externally tagged; `Null` is a bare string. */
44
+ /**
45
+ * A KIP literal. Externally tagged; `Null` is a bare string.
46
+ *
47
+ * Arrays and objects are not baseline Core Literals (Spec §9.2); they appear
48
+ * here only as the option/assignment payloads that the grammar admits.
49
+ */
27
50
  export type KipValue = 'Null' | {
28
51
  Bool: boolean;
29
52
  } | {
@@ -35,6 +58,32 @@ export type KipValue = 'Null' | {
35
58
  } | {
36
59
  Object: Record<string, KipValue>;
37
60
  };
61
+ /**
62
+ * A value slot the grammar spells `parameter | literal`.
63
+ *
64
+ * KIP 2.0 parameters are structurally bound data, never string-spliced, so an
65
+ * unbound `:name` survives lowering as a `Param` for the runtime envelope to
66
+ * fill — it is not an error and never becomes text.
67
+ */
68
+ export type Scalar = {
69
+ Literal: KipValue;
70
+ } | {
71
+ Param: string;
72
+ };
73
+ /** A schema symbol: `string_literal | parameter`. */
74
+ export type SymbolRef = {
75
+ Name: string;
76
+ } | {
77
+ Param: string;
78
+ };
79
+ /** A mutation target: `variable | parameter | string_literal`. */
80
+ export type ElementRef = {
81
+ Handle: string;
82
+ } | {
83
+ Param: string;
84
+ } | {
85
+ Id: string;
86
+ };
38
87
  /** One parsed command. */
39
88
  export type Command = {
40
89
  Kql: KqlQuery;
@@ -43,21 +92,117 @@ export type Command = {
43
92
  } | {
44
93
  Meta: MetaCommand;
45
94
  };
95
+ /** `?var` plus a resolved path, e.g. `?x.facets["MnemonicState"].salience`. */
96
+ export interface DotPathVar {
97
+ var: string;
98
+ path: PathStep[];
99
+ }
100
+ /** A dot step names a field; an index step keys into a map-valued field. */
101
+ export type PathStep = {
102
+ Field: string;
103
+ } | {
104
+ Key: string;
105
+ };
106
+ /** `predicate_atom` — the exact predicate slot. */
107
+ export type PredAtom = {
108
+ Variable: string;
109
+ } | {
110
+ Literal: string;
111
+ } | {
112
+ Param: string;
113
+ };
114
+ export interface HopRange {
115
+ min: number;
116
+ /** `null` means unbounded. */
117
+ max: number | null;
118
+ }
119
+ export interface PredPathAtom {
120
+ predicate: PredAtom;
121
+ hops: HopRange | null;
122
+ }
123
+ /**
124
+ * `Atom` is the plain predicate every language accepts. `Path` carries the
125
+ * KQL-only traversal forms — alternation and hop quantifiers — which never
126
+ * propagate belief and are rejected in KML and EXPORT selections.
127
+ */
128
+ export type PredTerm = {
129
+ Atom: PredAtom;
130
+ } | {
131
+ Path: PredPathAtom[];
132
+ };
133
+ /** One endpoint of a tuple. A term may itself be a tuple: KIP states things about statements. */
134
+ export type Term = {
135
+ Variable: string;
136
+ } | {
137
+ Param: string;
138
+ } | {
139
+ Literal: KipValue;
140
+ } | {
141
+ Match: ObjectMatcher;
142
+ } | {
143
+ Proposition: PropositionMatcher;
144
+ };
145
+ /**
146
+ * `object_pattern` — an open, schema-validated field map.
147
+ *
148
+ * Unlike KIP 1.x, v2 does not close this to a fixed set of identity forms:
149
+ * which fields identify an element is Schema's decision, not the grammar's.
150
+ */
151
+ export type ObjectMatcher = Record<string, MatchValue>;
152
+ export type MatchValue = {
153
+ Variable: string;
154
+ } | {
155
+ Param: string;
156
+ } | {
157
+ Literal: KipValue;
158
+ } | {
159
+ Array: MatchValue[];
160
+ } | {
161
+ Match: ObjectMatcher;
162
+ } | {
163
+ Proposition: PropositionMatcher;
164
+ };
165
+ export interface PropositionTriple {
166
+ subject: Term;
167
+ predicate: PredTerm;
168
+ object: Term;
169
+ }
170
+ /**
171
+ * The Proposition expression slot (Spec §43.2).
172
+ *
173
+ * `Tuple` addresses a Proposition by structure, `Id` by record identity. Both
174
+ * live in the same slot, which is why an id reference works everywhere a
175
+ * triple does — including as a {@link Term} endpoint. `Id` is match-only: it
176
+ * never resolves-or-creates, so `lower` rejects it in ENSURE PROPOSITION and
177
+ * in the ASSERT sugar that desugars through it.
178
+ */
179
+ export type PropositionMatcher = {
180
+ Tuple: PropositionTriple;
181
+ } | {
182
+ Id: Scalar;
183
+ };
46
184
  export interface KqlQuery {
47
185
  find_clause: FindClause;
48
186
  where_clauses: WhereClause[];
187
+ /** Cognitive history basis — what the Brain contained/believed then. */
188
+ as_of: AsOf | null;
189
+ /** World-valid time — what was applicable then. An independent axis. */
190
+ for_time: Scalar | null;
191
+ epistemic: Record<string, BoundValue> | null;
49
192
  order_by: OrderByItem[] | null;
50
- limit: number | null;
51
- cursor: string | null;
193
+ limit: Scalar | null;
194
+ cursor: Scalar | null;
52
195
  }
196
+ export type AsOf = {
197
+ Seq: Scalar;
198
+ } | {
199
+ Tx: Scalar;
200
+ } | {
201
+ Time: Scalar;
202
+ };
53
203
  export interface FindClause {
54
204
  expressions: FindExpression[];
55
205
  }
56
- /** `?var` with an optional dot path, e.g. `?d.attributes.risk`. Names carry no `?`. */
57
- export interface DotPathVar {
58
- var: string;
59
- path: string[];
60
- }
61
206
  export type FindExpression = {
62
207
  Variable: DotPathVar;
63
208
  } | {
@@ -77,7 +222,7 @@ export type OrderDirection = 'Asc' | 'Desc';
77
222
  export type WhereClause = {
78
223
  Concept: {
79
224
  variable: string;
80
- matcher: ConceptMatcher;
225
+ matcher: ObjectMatcher;
81
226
  };
82
227
  } | {
83
228
  Proposition: {
@@ -85,63 +230,64 @@ export type WhereClause = {
85
230
  matcher: PropositionMatcher;
86
231
  };
87
232
  } | {
88
- Filter: {
89
- expression: FilterExpression;
233
+ Assertion: {
234
+ variable: string;
235
+ matcher: ObjectMatcher;
90
236
  };
91
237
  } | {
92
- Not: WhereClause[];
93
- } | {
94
- Optional: WhereClause[];
238
+ Evidence: {
239
+ variable: string;
240
+ matcher: ObjectMatcher;
241
+ };
95
242
  } | {
96
- Union: WhereClause[];
97
- };
98
- export type ConceptMatcher = {
99
- ID: string;
243
+ Activity: {
244
+ variable: string;
245
+ matcher: ObjectMatcher;
246
+ };
100
247
  } | {
101
- Type: string;
248
+ Structural: {
249
+ variable: string | null;
250
+ subject: Term;
251
+ field: SymbolRef;
252
+ object: Term;
253
+ };
102
254
  } | {
103
- Name: string;
255
+ Belief: {
256
+ variable: string;
257
+ target: BeliefTarget;
258
+ };
104
259
  } | {
105
- Object: {
106
- type: string;
107
- name: string;
260
+ BeliefSlot: {
261
+ variable: string;
262
+ subject: Term;
263
+ predicate: PredAtom;
108
264
  };
109
- };
110
- export type PropositionMatcher = {
111
- ID: string;
112
265
  } | {
113
- Object: {
114
- subject: TargetTerm;
115
- predicate: PredTerm;
116
- object: TargetTerm;
266
+ Filter: {
267
+ expression: FilterExpression;
117
268
  };
269
+ } | {
270
+ Not: WhereClause[];
271
+ } | {
272
+ Optional: WhereClause[];
273
+ } | {
274
+ Union: WhereClause[];
118
275
  };
119
276
  /**
120
- * One endpoint of a proposition pattern.
277
+ * What a BELIEF projects: an already-bound Proposition variable, a Proposition
278
+ * named by id, or a tuple stated inline.
121
279
  *
122
- * `Proposition` is the meta-statement case: an endpoint may itself be a
123
- * proposition, which is how KIP states things about statements. It nests
124
- * arbitrarily deep.
280
+ * `BELIEF (...)` is the Proposition expression slot, so the id form that names
281
+ * a Proposition in a pattern names it here too (Spec §43.2 / §46.1). The
282
+ * inline tuple always carries an exact predicate: projection never walks a
283
+ * raw path (Spec §45).
125
284
  */
126
- export type TargetTerm = {
127
- Variable: string;
285
+ export type BeliefTarget = {
286
+ Proposition: string;
128
287
  } | {
129
- Concept: ConceptMatcher;
288
+ Id: Scalar;
130
289
  } | {
131
- Proposition: PropositionMatcher;
132
- };
133
- export type PredTerm = {
134
- Variable: string;
135
- } | {
136
- Literal: string;
137
- } | {
138
- Alternative: string[];
139
- } | {
140
- MultiHop: {
141
- predicate: string;
142
- min: number;
143
- max: number | null;
144
- };
290
+ Tuple: PropositionTriple;
145
291
  };
146
292
  export type FilterExpression = {
147
293
  Comparison: {
@@ -168,73 +314,138 @@ export type FilterOperand = {
168
314
  } | {
169
315
  Literal: KipValue;
170
316
  } | {
171
- List: KipValue[];
317
+ Param: string;
318
+ } | {
319
+ List: FilterOperand[];
320
+ } | {
321
+ Negate: FilterOperand;
172
322
  };
173
323
  export type ComparisonOperator = 'Equal' | 'NotEqual' | 'LessThan' | 'GreaterThan' | 'LessEqual' | 'GreaterEqual';
174
324
  export type LogicalOperator = 'And' | 'Or';
175
325
  export type FilterFunction = 'Contains' | 'StartsWith' | 'EndsWith' | 'Regex'
176
326
  /** `IN(?expr, [a, b])` — membership. A function, not a comparison operator. */
177
- | 'In' | 'IsNull' | 'IsNotNull';
178
- export type KmlStatement = {
179
- Upsert: UpsertBlock[];
327
+ | 'In' | 'IsNull' | 'IsNotNull' | 'IsLiteral' | 'IsElement' | 'IsKind' | 'LiteralType';
328
+ /**
329
+ * One atomic cognitive transition.
330
+ *
331
+ * A KML mutation becomes durable only via a Transaction, so a statement
332
+ * written on its own is still a one-clause transaction. `explicit_transaction`
333
+ * records which spelling the source used without changing that meaning.
334
+ */
335
+ export interface KmlStatement {
336
+ explicit_transaction: boolean;
337
+ clauses: MutationClause[];
338
+ }
339
+ export type MutationClause = {
340
+ CreateConcept: ConceptCreate;
341
+ } | {
342
+ UpsertConcept: ConceptUpsert;
343
+ } | {
344
+ EnsureProposition: EnsureProposition;
345
+ } | {
346
+ CreateEvidence: RecordCreate;
347
+ } | {
348
+ CreateAssertion: RecordCreate;
349
+ } | {
350
+ CreateActivity: RecordCreate;
180
351
  } | {
181
352
  Update: UpdateStatement;
182
353
  } | {
183
- Merge: MergeStatement;
354
+ RetractAssertion: RetractAssertion;
184
355
  } | {
185
- Delete: DeleteStatement;
186
- };
187
- export interface UpsertBlock {
188
- items: UpsertItem[];
189
- metadata: Record<string, Json> | null;
190
- }
191
- export type UpsertItem = {
192
- Concept: ConceptBlock;
356
+ SupersedeAssertion: SupersedeAssertion;
193
357
  } | {
194
- Proposition: PropositionBlock;
358
+ CorrectEvidence: CorrectEvidence;
359
+ } | {
360
+ TransitionActivity: TransitionActivity;
361
+ } | {
362
+ SetRetention: SetRetention;
363
+ } | {
364
+ Archive: RemovalStatement;
365
+ } | {
366
+ Tombstone: RemovalStatement;
367
+ } | {
368
+ Purge: PurgeStatement;
369
+ } | {
370
+ MergeConcept: MergeConcept;
195
371
  };
196
- export interface ConceptBlock {
197
- handle: string | null;
198
- concept: ConceptMatcher;
199
- set_attributes: Record<string, Json> | null;
200
- set_propositions: SetProposition[] | null;
201
- metadata: Record<string, Json> | null;
202
- /** `EXPECT VERSION <n>` — optimistic guard, omitted when not written. */
203
- expect_version?: number;
372
+ export interface ConceptCreate {
373
+ handle: string;
374
+ type: SymbolRef | null;
375
+ client_key: Scalar | null;
376
+ name: Scalar | null;
377
+ set_fields: Assignments | null;
378
+ set_attributes: Assignments | null;
379
+ set_facets: FacetAssignment[];
380
+ set_structural: StructuralEdge[] | null;
204
381
  }
205
- export interface SetProposition {
206
- predicate: string;
207
- object: TargetTerm;
208
- metadata: Record<string, Json> | null;
382
+ export interface ConceptUpsert {
383
+ handle: string;
384
+ match: ObjectMatcher | null;
385
+ expect_version: Scalar | null;
386
+ set_fields: Assignments | null;
387
+ set_attributes: Assignments | null;
388
+ set_facets: FacetAssignment[];
389
+ unset_attributes: string[] | null;
390
+ unset_facets: FacetUnset[];
391
+ set_structural: StructuralEdge[] | null;
392
+ unset_structural: StructuralRemoval[] | null;
209
393
  }
210
- export interface PropositionBlock {
394
+ /** CREATE EVIDENCE / ASSERTION / ACTIVITY share one shape. */
395
+ export interface RecordCreate {
396
+ handle: string;
397
+ client_key: Scalar | null;
398
+ set_fields: Assignments | null;
399
+ set_facets: FacetAssignment[];
400
+ set_structural: StructuralEdge[] | null;
401
+ }
402
+ export interface EnsureProposition {
211
403
  handle: string | null;
212
- proposition: PropositionMatcher;
213
- set_attributes: Record<string, Json> | null;
214
- metadata: Record<string, Json> | null;
215
- expect_version?: number;
404
+ subject: Term;
405
+ predicate: PredAtom;
406
+ object: Term;
407
+ expect_version: Scalar | null;
216
408
  }
217
- export interface UpdateStatement {
218
- target: string;
219
- set_attributes: [string, UpdateValue][] | null;
220
- set_metadata: [string, UpdateValue][] | null;
221
- where_clauses: WhereClause[];
222
- limit: number | null;
409
+ export interface FacetAssignment {
410
+ facet: SymbolRef;
411
+ values: Assignments;
412
+ }
413
+ export interface FacetUnset {
414
+ facet: SymbolRef;
415
+ fields: string[];
416
+ }
417
+ export interface StructuralEdge {
418
+ field: SymbolRef;
419
+ value: MutationValue;
420
+ /** Edge options; `index` is meaningful only on an ordered field. */
421
+ options: Record<string, BoundValue> | null;
223
422
  }
224
423
  /**
225
- * An UPDATE right-hand side: a literal, or arithmetic over the target's *own*
424
+ * `UNSET STRUCTURAL { (field, target) }` one reference to remove.
425
+ *
426
+ * The SET STRUCTURAL edge without options: removal is per reference, ordered
427
+ * fields re-densify, cardinality is validated at commit (Spec §17.5).
428
+ */
429
+ export interface StructuralRemoval {
430
+ field: SymbolRef;
431
+ value: MutationValue;
432
+ }
433
+ /** Assignment pairs, kept ordered so lowering stays deterministic. */
434
+ export type Assignments = [string, MutationValue][];
435
+ /**
436
+ * A KML right-hand side: a bound value, or arithmetic over the target's *own*
226
437
  * fields. References to any other variable are rejected during lowering, which
227
438
  * is what lets each matched element be updated from its own row without a join.
228
439
  */
229
- export type UpdateValue = {
230
- Json: Json;
231
- } | {
440
+ export type MutationValue = BoundValue | {
232
441
  Expr: UpdateExpr;
233
442
  };
234
443
  export type UpdateExpr = {
235
444
  Variable: DotPathVar;
236
445
  } | {
237
446
  Number: number;
447
+ } | {
448
+ Param: string;
238
449
  } | {
239
450
  Function: {
240
451
  func: UpdateFunction;
@@ -242,73 +453,227 @@ export type UpdateExpr = {
242
453
  };
243
454
  };
244
455
  export type UpdateFunction = 'Add' | 'Mul' | 'Clamp' | 'Coalesce';
245
- export interface MergeStatement {
246
- source: string;
247
- target: string;
248
- where_clauses: WhereClause[];
456
+ export interface UpdateStatement {
457
+ target: ElementRef;
458
+ expect_version: Scalar | null;
459
+ actions: UpdateAction[];
460
+ /**
461
+ * `null` when the statement names its target directly and omits WHERE —
462
+ * the same shape as the removal family (Spec §58).
463
+ */
464
+ where_clauses: WhereClause[] | null;
465
+ limit: Scalar | null;
249
466
  }
250
- export type DeleteStatement = {
251
- DeleteAttributes: {
252
- attributes: string[];
253
- target: string;
254
- where_clauses: WhereClause[];
255
- };
467
+ export type UpdateAction = {
468
+ SetFields: Assignments;
256
469
  } | {
257
- DeleteMetadata: {
258
- keys: string[];
259
- target: string;
260
- where_clauses: WhereClause[];
261
- };
470
+ SetAttributes: Assignments;
262
471
  } | {
263
- DeletePropositions: {
264
- target: string;
265
- where_clauses: WhereClause[];
266
- };
472
+ SetFacet: FacetAssignment;
267
473
  } | {
268
- DeleteConcept: {
269
- target: string;
270
- where_clauses: WhereClause[];
271
- };
474
+ UnsetAttributes: string[];
475
+ } | {
476
+ UnsetFacet: FacetUnset;
477
+ } | {
478
+ SetStructural: StructuralEdge[];
479
+ } | {
480
+ UnsetStructural: StructuralRemoval[];
272
481
  };
482
+ export interface RetractAssertion {
483
+ target: ElementRef;
484
+ where_clauses: WhereClause[] | null;
485
+ limit: Scalar | null;
486
+ expect_state: Scalar | null;
487
+ }
488
+ export interface SupersedeAssertion {
489
+ target: ElementRef;
490
+ by: ElementRef;
491
+ expect_state: Scalar | null;
492
+ }
493
+ export interface CorrectEvidence {
494
+ target: ElementRef;
495
+ by: ElementRef;
496
+ expect_state: Scalar | null;
497
+ }
498
+ export interface TransitionActivity {
499
+ target: ElementRef;
500
+ to: Scalar;
501
+ set_fields: Assignments | null;
502
+ set_structural: StructuralEdge[] | null;
503
+ expect_state: Scalar | null;
504
+ }
505
+ export interface SetRetention {
506
+ target: ElementRef;
507
+ values: Assignments;
508
+ where_clauses: WhereClause[] | null;
509
+ limit: Scalar | null;
510
+ expect_version: Scalar | null;
511
+ }
512
+ export interface RemovalStatement {
513
+ target: ElementRef;
514
+ where_clauses: WhereClause[] | null;
515
+ limit: Scalar | null;
516
+ expect_state: Scalar | null;
517
+ }
518
+ export interface PurgeStatement {
519
+ target: ElementRef;
520
+ where_clauses: WhereClause[] | null;
521
+ limit: Scalar | null;
522
+ reference_policy: Scalar | null;
523
+ /** Always the literal `PURGE`; the grammar freezes the spelling. */
524
+ confirm: string;
525
+ }
526
+ export interface MergeConcept {
527
+ source: ElementRef;
528
+ into: ElementRef;
529
+ where_clauses: WhereClause[] | null;
530
+ expect_version: Scalar | null;
531
+ }
273
532
  export type MetaCommand = {
274
533
  Describe: DescribeTarget;
534
+ } | {
535
+ List: ListCommand;
275
536
  } | {
276
537
  Search: SearchCommand;
277
538
  } | {
278
- Export: ExportCommand;
539
+ Verify: {
540
+ target: VerifyTarget;
541
+ value: Scalar;
542
+ };
543
+ } | {
544
+ Validate: ValidateCommand;
545
+ } | {
546
+ Preview: PreviewCommand;
547
+ } | {
548
+ History: HistoryCommand;
549
+ } | {
550
+ Changes: ChangesCommand;
551
+ } | {
552
+ Snapshot: {
553
+ as_of: AsOf | null;
554
+ };
555
+ } | {
556
+ ExportCapsule: ExportCapsuleCommand;
279
557
  };
280
- export type DescribeTarget = 'Primer' | 'Domains' | {
281
- ConceptTypes: {
282
- limit: number | null;
283
- cursor: string | null;
558
+ export type DescribeTarget = {
559
+ Primer: {
560
+ mode: Scalar | null;
284
561
  };
562
+ } | 'Protocol' | 'ExecutionContext' | 'Capabilities' | {
563
+ Space: {
564
+ value: Scalar | null;
565
+ };
566
+ } | {
567
+ SchemaEnvironment: {
568
+ as_of: AsOf | null;
569
+ };
570
+ } | {
571
+ Package: Scalar;
572
+ } | {
573
+ Type: Scalar;
574
+ } | {
575
+ Predicate: Scalar;
285
576
  } | {
286
- ConceptType: string;
577
+ Facet: Scalar;
287
578
  } | {
288
- PropositionTypes: {
289
- limit: number | null;
290
- cursor: string | null;
579
+ StructuralField: Scalar;
580
+ } | {
581
+ Compatibility: {
582
+ from: Scalar;
583
+ to: Scalar;
584
+ };
585
+ } | {
586
+ Error: Scalar;
587
+ } | {
588
+ Transaction: Scalar;
589
+ } | {
590
+ TransactionByIdempotencyKey: Scalar;
591
+ } | {
592
+ Snapshot: {
593
+ as_of: AsOf | null;
291
594
  };
292
595
  } | {
293
- PropositionType: string;
596
+ Capsule: Scalar;
597
+ } | {
598
+ EpistemicPolicy: {
599
+ value: Scalar | null;
600
+ };
601
+ } | 'ProjectionCapability' | {
602
+ Trust: {
603
+ value: Scalar | null;
604
+ };
605
+ } | {
606
+ Access: {
607
+ with: Record<string, BoundValue> | null;
608
+ };
294
609
  };
610
+ export interface ListCommand {
611
+ target: ListTarget;
612
+ /** `LIST SCHEMA PACKAGES STATUS ...` only. */
613
+ status: Scalar | null;
614
+ limit: Scalar | null;
615
+ cursor: Scalar | null;
616
+ }
617
+ export type ListTarget = 'Spaces' | 'SchemaPackages' | 'Types' | 'Predicates' | 'Facets' | 'StructuralFields' | 'EpistemicPolicies';
295
618
  export interface SearchCommand {
296
619
  target: SearchTarget;
297
- term: string;
298
- in_type: string | null;
299
- /** Omitted when the command wrote no `MODE`. */
300
- mode?: SearchMode;
301
- /** Omitted when the command wrote no `THRESHOLD`. */
302
- threshold?: number;
303
- limit: number | null;
620
+ term: Scalar;
621
+ with_type: Scalar | null;
622
+ with_predicate: Scalar | null;
623
+ mode: Scalar | null;
624
+ threshold: Scalar | null;
625
+ /** Historical index basis, `AS OF SEQ`. */
626
+ as_of_seq: Scalar | null;
627
+ limit: Scalar | null;
628
+ cursor: Scalar | null;
304
629
  }
305
- export type SearchTarget = 'Concept' | 'Proposition';
306
- export type SearchMode = 'Keyword' | 'Semantic' | 'Hybrid';
307
- export interface ExportCommand {
308
- target: string;
630
+ export type SearchTarget = 'Concept' | 'Proposition' | 'Assertion' | 'Evidence' | 'Activity' | 'Cognition';
631
+ export type VerifyTarget = 'Capsule' | 'SchemaPackage' | 'Receipt' | 'Blob' | 'Checkpoint';
632
+ export interface ValidateCommand {
633
+ target: ValidateTarget;
634
+ value: Scalar;
635
+ options: Record<string, BoundValue> | null;
636
+ }
637
+ export type ValidateTarget = 'Kql' | 'Kml' | 'Capsule' | 'SchemaPackage' | 'ImportPlan';
638
+ export type PreviewCommand = {
639
+ Kml: Scalar;
640
+ } | {
641
+ ImportCapsule: {
642
+ capsule: Scalar;
643
+ into: Scalar;
644
+ };
645
+ };
646
+ export type HistoryCommand = {
647
+ Element: {
648
+ value: Scalar;
649
+ from_seq: Scalar | null;
650
+ to_seq: Scalar | null;
651
+ limit: Scalar | null;
652
+ cursor: Scalar | null;
653
+ };
654
+ } | {
655
+ Space: {
656
+ from_seq: Scalar | null;
657
+ to_seq: Scalar | null;
658
+ limit: Scalar | null;
659
+ cursor: Scalar | null;
660
+ };
661
+ };
662
+ export type ChangesCommand = {
663
+ Since: {
664
+ cursor: Scalar;
665
+ limit: Scalar | null;
666
+ };
667
+ } | {
668
+ AfterSeq: {
669
+ seq: Scalar;
670
+ limit: Scalar | null;
671
+ };
672
+ };
673
+ export interface ExportCapsuleCommand {
674
+ target: ElementRef;
309
675
  where_clauses: WhereClause[];
310
- limit: number | null;
311
- /** Omitted when the command wrote no `CURSOR`. */
312
- cursor?: string;
676
+ options: Record<string, BoundValue> | null;
677
+ as_of: AsOf | null;
313
678
  }
314
679
  //# sourceMappingURL=exec-ast.d.ts.map