@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.
- package/CHANGELOG.md +53 -0
- package/LICENSE +21 -0
- package/README.md +89 -64
- package/dist/ast.d.ts +511 -145
- package/dist/ast.d.ts.map +1 -1
- package/dist/diagnostics.d.ts +8 -2
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +32 -3
- package/dist/diagnostics.js.map +1 -1
- package/dist/exec-ast.d.ts +514 -149
- package/dist/exec-ast.d.ts.map +1 -1
- package/dist/exec-ast.js +8 -7
- package/dist/exec-ast.js.map +1 -1
- package/dist/formatter.d.ts.map +1 -1
- package/dist/formatter.js +870 -479
- package/dist/formatter.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lexer.d.ts.map +1 -1
- package/dist/lexer.js +12 -30
- package/dist/lexer.js.map +1 -1
- package/dist/lower.d.ts +1 -2
- package/dist/lower.d.ts.map +1 -1
- package/dist/lower.js +1287 -598
- package/dist/lower.js.map +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +2410 -1300
- package/dist/parser.js.map +1 -1
- package/dist/semantics.d.ts +11 -7
- package/dist/semantics.d.ts.map +1 -1
- package/dist/semantics.js +295 -180
- package/dist/semantics.js.map +1 -1
- package/dist/token.d.ts +130 -40
- package/dist/token.d.ts.map +1 -1
- package/dist/token.js +264 -83
- package/dist/token.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/package.json +35 -5
- package/src/ast.ts +914 -0
- package/src/budget.ts +108 -0
- package/src/diagnostics.ts +182 -0
- package/src/errors.ts +42 -0
- package/src/exec-ast.ts +614 -0
- package/src/formatter.ts +1339 -0
- package/src/index.ts +226 -0
- package/src/lexer.ts +459 -0
- package/src/lower.ts +2011 -0
- package/src/parser.ts +3506 -0
- package/src/semantics.ts +392 -0
- package/src/token.ts +408 -0
- package/src/version.ts +13 -0
package/dist/exec-ast.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
*
|
|
13
|
-
* - a variable is a name and a
|
|
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
|
|
19
|
-
*
|
|
20
|
-
*
|
|
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
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
/**
|
|
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:
|
|
51
|
-
cursor:
|
|
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:
|
|
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
|
-
|
|
89
|
-
|
|
233
|
+
Assertion: {
|
|
234
|
+
variable: string;
|
|
235
|
+
matcher: ObjectMatcher;
|
|
90
236
|
};
|
|
91
237
|
} | {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
238
|
+
Evidence: {
|
|
239
|
+
variable: string;
|
|
240
|
+
matcher: ObjectMatcher;
|
|
241
|
+
};
|
|
95
242
|
} | {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
243
|
+
Activity: {
|
|
244
|
+
variable: string;
|
|
245
|
+
matcher: ObjectMatcher;
|
|
246
|
+
};
|
|
100
247
|
} | {
|
|
101
|
-
|
|
248
|
+
Structural: {
|
|
249
|
+
variable: string | null;
|
|
250
|
+
subject: Term;
|
|
251
|
+
field: SymbolRef;
|
|
252
|
+
object: Term;
|
|
253
|
+
};
|
|
102
254
|
} | {
|
|
103
|
-
|
|
255
|
+
Belief: {
|
|
256
|
+
variable: string;
|
|
257
|
+
target: BeliefTarget;
|
|
258
|
+
};
|
|
104
259
|
} | {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
260
|
+
BeliefSlot: {
|
|
261
|
+
variable: string;
|
|
262
|
+
subject: Term;
|
|
263
|
+
predicate: PredAtom;
|
|
108
264
|
};
|
|
109
|
-
};
|
|
110
|
-
export type PropositionMatcher = {
|
|
111
|
-
ID: string;
|
|
112
265
|
} | {
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
*
|
|
277
|
+
* What a BELIEF projects: an already-bound Proposition variable, a Proposition
|
|
278
|
+
* named by id, or a tuple stated inline.
|
|
121
279
|
*
|
|
122
|
-
* `
|
|
123
|
-
*
|
|
124
|
-
*
|
|
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
|
|
127
|
-
|
|
285
|
+
export type BeliefTarget = {
|
|
286
|
+
Proposition: string;
|
|
128
287
|
} | {
|
|
129
|
-
|
|
288
|
+
Id: Scalar;
|
|
130
289
|
} | {
|
|
131
|
-
|
|
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
|
-
|
|
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
|
-
|
|
179
|
-
|
|
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
|
-
|
|
354
|
+
RetractAssertion: RetractAssertion;
|
|
184
355
|
} | {
|
|
185
|
-
|
|
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
|
-
|
|
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
|
|
197
|
-
handle: string
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
expect_version
|
|
404
|
+
subject: Term;
|
|
405
|
+
predicate: PredAtom;
|
|
406
|
+
object: Term;
|
|
407
|
+
expect_version: Scalar | null;
|
|
216
408
|
}
|
|
217
|
-
export interface
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
|
251
|
-
|
|
252
|
-
attributes: string[];
|
|
253
|
-
target: string;
|
|
254
|
-
where_clauses: WhereClause[];
|
|
255
|
-
};
|
|
467
|
+
export type UpdateAction = {
|
|
468
|
+
SetFields: Assignments;
|
|
256
469
|
} | {
|
|
257
|
-
|
|
258
|
-
keys: string[];
|
|
259
|
-
target: string;
|
|
260
|
-
where_clauses: WhereClause[];
|
|
261
|
-
};
|
|
470
|
+
SetAttributes: Assignments;
|
|
262
471
|
} | {
|
|
263
|
-
|
|
264
|
-
target: string;
|
|
265
|
-
where_clauses: WhereClause[];
|
|
266
|
-
};
|
|
472
|
+
SetFacet: FacetAssignment;
|
|
267
473
|
} | {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
-
|
|
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 =
|
|
281
|
-
|
|
282
|
-
|
|
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
|
-
|
|
577
|
+
Facet: Scalar;
|
|
287
578
|
} | {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
|
|
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:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
mode
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
|
307
|
-
export interface
|
|
308
|
-
target:
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
cursor?: string;
|
|
676
|
+
options: Record<string, BoundValue> | null;
|
|
677
|
+
as_of: AsOf | null;
|
|
313
678
|
}
|
|
314
679
|
//# sourceMappingURL=exec-ast.d.ts.map
|