@eddacraft/anvil-kindling-integration 0.1.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/LICENSE +14 -0
- package/README.md +542 -0
- package/dist/adapter.d.ts +49 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +100 -0
- package/dist/config.d.ts +89 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +173 -0
- package/dist/emitters/action-emitter.d.ts +40 -0
- package/dist/emitters/action-emitter.d.ts.map +1 -0
- package/dist/emitters/action-emitter.js +52 -0
- package/dist/emitters/constraint-emitter.d.ts +32 -0
- package/dist/emitters/constraint-emitter.d.ts.map +1 -0
- package/dist/emitters/constraint-emitter.js +41 -0
- package/dist/emitters/error-emitter.d.ts +33 -0
- package/dist/emitters/error-emitter.d.ts.map +1 -0
- package/dist/emitters/error-emitter.js +50 -0
- package/dist/emitters/gate-emitter.d.ts +37 -0
- package/dist/emitters/gate-emitter.d.ts.map +1 -0
- package/dist/emitters/gate-emitter.js +53 -0
- package/dist/emitters/human-input-emitter.d.ts +30 -0
- package/dist/emitters/human-input-emitter.d.ts.map +1 -0
- package/dist/emitters/human-input-emitter.js +38 -0
- package/dist/emitters/index.d.ts +13 -0
- package/dist/emitters/index.d.ts.map +1 -0
- package/dist/emitters/index.js +19 -0
- package/dist/emitters/plan-emitter.d.ts +75 -0
- package/dist/emitters/plan-emitter.d.ts.map +1 -0
- package/dist/emitters/plan-emitter.js +116 -0
- package/dist/emitters/session-emitter.d.ts +57 -0
- package/dist/emitters/session-emitter.d.ts.map +1 -0
- package/dist/emitters/session-emitter.js +80 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +111 -0
- package/dist/kindling-service.d.ts +122 -0
- package/dist/kindling-service.d.ts.map +1 -0
- package/dist/kindling-service.js +203 -0
- package/dist/observation-contract.d.ts +561 -0
- package/dist/observation-contract.d.ts.map +1 -0
- package/dist/observation-contract.js +391 -0
- package/dist/query-contract.d.ts +463 -0
- package/dist/query-contract.d.ts.map +1 -0
- package/dist/query-contract.js +314 -0
- package/dist/query-limits.d.ts +40 -0
- package/dist/query-limits.d.ts.map +1 -0
- package/dist/query-limits.js +79 -0
- package/dist/query-service.d.ts +109 -0
- package/dist/query-service.d.ts.map +1 -0
- package/dist/query-service.js +140 -0
- package/dist/retention.d.ts +79 -0
- package/dist/retention.d.ts.map +1 -0
- package/dist/retention.js +81 -0
- package/dist/sensitive-data-validator.d.ts +47 -0
- package/dist/sensitive-data-validator.d.ts.map +1 -0
- package/dist/sensitive-data-validator.js +135 -0
- package/dist/status.d.ts +104 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +136 -0
- package/dist/utils/debug.d.ts +9 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +55 -0
- package/package.json +114 -0
- package/src/adapter.ts +117 -0
- package/src/config.ts +202 -0
- package/src/emitters/action-emitter.ts +90 -0
- package/src/emitters/constraint-emitter.ts +73 -0
- package/src/emitters/error-emitter.ts +86 -0
- package/src/emitters/gate-emitter.ts +87 -0
- package/src/emitters/human-input-emitter.ts +71 -0
- package/src/emitters/index.ts +40 -0
- package/src/emitters/plan-emitter.ts +183 -0
- package/src/emitters/session-emitter.ts +131 -0
- package/src/index.ts +254 -0
- package/src/kindling-service.ts +272 -0
- package/src/malicious-ai.test.ts +949 -0
- package/src/observation-contract.ts +500 -0
- package/src/query-contract.ts +389 -0
- package/src/query-limits.ts +106 -0
- package/src/query-service.ts +217 -0
- package/src/retention.ts +153 -0
- package/src/sensitive-data-validator.ts +167 -0
- package/src/status.ts +221 -0
- package/src/utils/debug.ts +65 -0
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kindling Query Contract (v1)
|
|
3
|
+
*
|
|
4
|
+
* Defines the read-only, bounded query surface for Kindling observations.
|
|
5
|
+
* This is a system of record, not a reasoning engine.
|
|
6
|
+
*
|
|
7
|
+
* GOVERNING RULE:
|
|
8
|
+
* Queries may retrieve facts; interpretation is the caller's responsibility.
|
|
9
|
+
* User-supplied AI may read, but may not mutate, infer, or generalise via Kindling.
|
|
10
|
+
*
|
|
11
|
+
* @see plans/modules/kindling-integration.aps.md for integration plan
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
export declare const KINDLING_QUERY_CONTRACT_VERSION = "1.0.0";
|
|
15
|
+
/**
|
|
16
|
+
* Every query must specify exactly one scope.
|
|
17
|
+
* No free-text search. No global scans. No cross-project reads.
|
|
18
|
+
*/
|
|
19
|
+
export declare const QueryScopeSchema: z.ZodEnum<{
|
|
20
|
+
session: "session";
|
|
21
|
+
plan: "plan";
|
|
22
|
+
gate: "gate";
|
|
23
|
+
action: "action";
|
|
24
|
+
}>;
|
|
25
|
+
export type QueryScope = z.infer<typeof QueryScopeSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* How results should be structured
|
|
28
|
+
*/
|
|
29
|
+
export declare const ResultShapeSchema: z.ZodEnum<{
|
|
30
|
+
timeline: "timeline";
|
|
31
|
+
list: "list";
|
|
32
|
+
entity: "entity";
|
|
33
|
+
}>;
|
|
34
|
+
export type ResultShape = z.infer<typeof ResultShapeSchema>;
|
|
35
|
+
/**
|
|
36
|
+
* Result serialisation format
|
|
37
|
+
*/
|
|
38
|
+
export declare const OutputFormatSchema: z.ZodEnum<{
|
|
39
|
+
json: "json";
|
|
40
|
+
text: "text";
|
|
41
|
+
}>;
|
|
42
|
+
export type OutputFormat = z.infer<typeof OutputFormatSchema>;
|
|
43
|
+
/**
|
|
44
|
+
* Base query request with mandatory constraints
|
|
45
|
+
*/
|
|
46
|
+
export declare const QueryRequestBaseSchema: z.ZodObject<{
|
|
47
|
+
scope: z.ZodEnum<{
|
|
48
|
+
session: "session";
|
|
49
|
+
plan: "plan";
|
|
50
|
+
gate: "gate";
|
|
51
|
+
action: "action";
|
|
52
|
+
}>;
|
|
53
|
+
shape: z.ZodEnum<{
|
|
54
|
+
timeline: "timeline";
|
|
55
|
+
list: "list";
|
|
56
|
+
entity: "entity";
|
|
57
|
+
}>;
|
|
58
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
59
|
+
json: "json";
|
|
60
|
+
text: "text";
|
|
61
|
+
}>>;
|
|
62
|
+
time_after: z.ZodOptional<z.ZodString>;
|
|
63
|
+
time_before: z.ZodOptional<z.ZodString>;
|
|
64
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
65
|
+
max_payload_bytes: z.ZodDefault<z.ZodNumber>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type QueryRequestBase = z.infer<typeof QueryRequestBaseSchema>;
|
|
68
|
+
/**
|
|
69
|
+
* Query: "What happened in this run?"
|
|
70
|
+
*
|
|
71
|
+
* Returns ordered observations grouped by phase (plan / gate / action / outcome).
|
|
72
|
+
* Raw payloads only, no summaries.
|
|
73
|
+
*/
|
|
74
|
+
export declare const SessionQuerySchema: z.ZodObject<{
|
|
75
|
+
shape: z.ZodEnum<{
|
|
76
|
+
timeline: "timeline";
|
|
77
|
+
list: "list";
|
|
78
|
+
entity: "entity";
|
|
79
|
+
}>;
|
|
80
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
81
|
+
json: "json";
|
|
82
|
+
text: "text";
|
|
83
|
+
}>>;
|
|
84
|
+
time_after: z.ZodOptional<z.ZodString>;
|
|
85
|
+
time_before: z.ZodOptional<z.ZodString>;
|
|
86
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
87
|
+
max_payload_bytes: z.ZodDefault<z.ZodNumber>;
|
|
88
|
+
scope: z.ZodLiteral<"session">;
|
|
89
|
+
session_id: z.ZodString;
|
|
90
|
+
include_phases: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
91
|
+
outcome: "outcome";
|
|
92
|
+
error: "error";
|
|
93
|
+
plan: "plan";
|
|
94
|
+
gate: "gate";
|
|
95
|
+
action: "action";
|
|
96
|
+
}>>>;
|
|
97
|
+
}, z.core.$strip>;
|
|
98
|
+
export type SessionQuery = z.infer<typeof SessionQuerySchema>;
|
|
99
|
+
/**
|
|
100
|
+
* Query: "What happened because of this plan?"
|
|
101
|
+
*
|
|
102
|
+
* Returns plan metadata, versions, and linked executions.
|
|
103
|
+
* This is the ONLY cross-session read allowed, via explicit plan_id.
|
|
104
|
+
*/
|
|
105
|
+
export declare const PlanQuerySchema: z.ZodObject<{
|
|
106
|
+
shape: z.ZodEnum<{
|
|
107
|
+
timeline: "timeline";
|
|
108
|
+
list: "list";
|
|
109
|
+
entity: "entity";
|
|
110
|
+
}>;
|
|
111
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
112
|
+
json: "json";
|
|
113
|
+
text: "text";
|
|
114
|
+
}>>;
|
|
115
|
+
time_after: z.ZodOptional<z.ZodString>;
|
|
116
|
+
time_before: z.ZodOptional<z.ZodString>;
|
|
117
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
118
|
+
max_payload_bytes: z.ZodDefault<z.ZodNumber>;
|
|
119
|
+
scope: z.ZodLiteral<"plan">;
|
|
120
|
+
plan_id: z.ZodString;
|
|
121
|
+
include_executions: z.ZodDefault<z.ZodBoolean>;
|
|
122
|
+
include_versions: z.ZodDefault<z.ZodBoolean>;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
export type PlanQuery = z.infer<typeof PlanQuerySchema>;
|
|
125
|
+
/**
|
|
126
|
+
* Query: "Why did this gate pass/fail?"
|
|
127
|
+
*
|
|
128
|
+
* Returns gate evaluation details with rule IDs, inputs (sanitised), and outcomes.
|
|
129
|
+
* No prose. No explanation layer.
|
|
130
|
+
*/
|
|
131
|
+
export declare const GateQuerySchema: z.ZodObject<{
|
|
132
|
+
shape: z.ZodEnum<{
|
|
133
|
+
timeline: "timeline";
|
|
134
|
+
list: "list";
|
|
135
|
+
entity: "entity";
|
|
136
|
+
}>;
|
|
137
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
138
|
+
json: "json";
|
|
139
|
+
text: "text";
|
|
140
|
+
}>>;
|
|
141
|
+
time_after: z.ZodOptional<z.ZodString>;
|
|
142
|
+
time_before: z.ZodOptional<z.ZodString>;
|
|
143
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
144
|
+
max_payload_bytes: z.ZodDefault<z.ZodNumber>;
|
|
145
|
+
scope: z.ZodLiteral<"gate">;
|
|
146
|
+
gate_eval_id: z.ZodString;
|
|
147
|
+
}, z.core.$strip>;
|
|
148
|
+
export type GateQuery = z.infer<typeof GateQuerySchema>;
|
|
149
|
+
/**
|
|
150
|
+
* Query: "What exactly did this action do?"
|
|
151
|
+
*
|
|
152
|
+
* Returns action details with redacted command, environment, and linked governance.
|
|
153
|
+
* This is the atomic unit of accountability.
|
|
154
|
+
*/
|
|
155
|
+
export declare const ActionQuerySchema: z.ZodObject<{
|
|
156
|
+
shape: z.ZodEnum<{
|
|
157
|
+
timeline: "timeline";
|
|
158
|
+
list: "list";
|
|
159
|
+
entity: "entity";
|
|
160
|
+
}>;
|
|
161
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
162
|
+
json: "json";
|
|
163
|
+
text: "text";
|
|
164
|
+
}>>;
|
|
165
|
+
time_after: z.ZodOptional<z.ZodString>;
|
|
166
|
+
time_before: z.ZodOptional<z.ZodString>;
|
|
167
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
168
|
+
max_payload_bytes: z.ZodDefault<z.ZodNumber>;
|
|
169
|
+
scope: z.ZodLiteral<"action">;
|
|
170
|
+
action_id: z.ZodString;
|
|
171
|
+
include_approval_chain: z.ZodDefault<z.ZodBoolean>;
|
|
172
|
+
}, z.core.$strip>;
|
|
173
|
+
export type ActionQuery = z.infer<typeof ActionQuerySchema>;
|
|
174
|
+
/**
|
|
175
|
+
* All query types (discriminated union)
|
|
176
|
+
*/
|
|
177
|
+
export declare const QueryRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
178
|
+
shape: z.ZodEnum<{
|
|
179
|
+
timeline: "timeline";
|
|
180
|
+
list: "list";
|
|
181
|
+
entity: "entity";
|
|
182
|
+
}>;
|
|
183
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
184
|
+
json: "json";
|
|
185
|
+
text: "text";
|
|
186
|
+
}>>;
|
|
187
|
+
time_after: z.ZodOptional<z.ZodString>;
|
|
188
|
+
time_before: z.ZodOptional<z.ZodString>;
|
|
189
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
190
|
+
max_payload_bytes: z.ZodDefault<z.ZodNumber>;
|
|
191
|
+
scope: z.ZodLiteral<"session">;
|
|
192
|
+
session_id: z.ZodString;
|
|
193
|
+
include_phases: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
194
|
+
outcome: "outcome";
|
|
195
|
+
error: "error";
|
|
196
|
+
plan: "plan";
|
|
197
|
+
gate: "gate";
|
|
198
|
+
action: "action";
|
|
199
|
+
}>>>;
|
|
200
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
201
|
+
shape: z.ZodEnum<{
|
|
202
|
+
timeline: "timeline";
|
|
203
|
+
list: "list";
|
|
204
|
+
entity: "entity";
|
|
205
|
+
}>;
|
|
206
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
207
|
+
json: "json";
|
|
208
|
+
text: "text";
|
|
209
|
+
}>>;
|
|
210
|
+
time_after: z.ZodOptional<z.ZodString>;
|
|
211
|
+
time_before: z.ZodOptional<z.ZodString>;
|
|
212
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
213
|
+
max_payload_bytes: z.ZodDefault<z.ZodNumber>;
|
|
214
|
+
scope: z.ZodLiteral<"plan">;
|
|
215
|
+
plan_id: z.ZodString;
|
|
216
|
+
include_executions: z.ZodDefault<z.ZodBoolean>;
|
|
217
|
+
include_versions: z.ZodDefault<z.ZodBoolean>;
|
|
218
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
219
|
+
shape: z.ZodEnum<{
|
|
220
|
+
timeline: "timeline";
|
|
221
|
+
list: "list";
|
|
222
|
+
entity: "entity";
|
|
223
|
+
}>;
|
|
224
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
225
|
+
json: "json";
|
|
226
|
+
text: "text";
|
|
227
|
+
}>>;
|
|
228
|
+
time_after: z.ZodOptional<z.ZodString>;
|
|
229
|
+
time_before: z.ZodOptional<z.ZodString>;
|
|
230
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
231
|
+
max_payload_bytes: z.ZodDefault<z.ZodNumber>;
|
|
232
|
+
scope: z.ZodLiteral<"gate">;
|
|
233
|
+
gate_eval_id: z.ZodString;
|
|
234
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
235
|
+
shape: z.ZodEnum<{
|
|
236
|
+
timeline: "timeline";
|
|
237
|
+
list: "list";
|
|
238
|
+
entity: "entity";
|
|
239
|
+
}>;
|
|
240
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
241
|
+
json: "json";
|
|
242
|
+
text: "text";
|
|
243
|
+
}>>;
|
|
244
|
+
time_after: z.ZodOptional<z.ZodString>;
|
|
245
|
+
time_before: z.ZodOptional<z.ZodString>;
|
|
246
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
247
|
+
max_payload_bytes: z.ZodDefault<z.ZodNumber>;
|
|
248
|
+
scope: z.ZodLiteral<"action">;
|
|
249
|
+
action_id: z.ZodString;
|
|
250
|
+
include_approval_chain: z.ZodDefault<z.ZodBoolean>;
|
|
251
|
+
}, z.core.$strip>], "scope">;
|
|
252
|
+
export type QueryRequest = z.infer<typeof QueryRequestSchema>;
|
|
253
|
+
/**
|
|
254
|
+
* Standard metadata for all responses
|
|
255
|
+
*/
|
|
256
|
+
export declare const QueryResponseMetadataSchema: z.ZodObject<{
|
|
257
|
+
query_id: z.ZodString;
|
|
258
|
+
executed_at: z.ZodString;
|
|
259
|
+
contract_version: z.ZodString;
|
|
260
|
+
result_count: z.ZodNumber;
|
|
261
|
+
truncated: z.ZodBoolean;
|
|
262
|
+
truncation_reason: z.ZodOptional<z.ZodEnum<{
|
|
263
|
+
max_results: "max_results";
|
|
264
|
+
max_payload_bytes: "max_payload_bytes";
|
|
265
|
+
none: "none";
|
|
266
|
+
}>>;
|
|
267
|
+
}, z.core.$strip>;
|
|
268
|
+
export type QueryResponseMetadata = z.infer<typeof QueryResponseMetadataSchema>;
|
|
269
|
+
/**
|
|
270
|
+
* Standard provenance link
|
|
271
|
+
*/
|
|
272
|
+
export declare const ProvenanceLinkSchema: z.ZodObject<{
|
|
273
|
+
type: z.ZodEnum<{
|
|
274
|
+
approved_by: "approved_by";
|
|
275
|
+
caused_by: "caused_by";
|
|
276
|
+
governed_by: "governed_by";
|
|
277
|
+
linked_to: "linked_to";
|
|
278
|
+
}>;
|
|
279
|
+
entity_type: z.ZodEnum<{
|
|
280
|
+
human: "human";
|
|
281
|
+
session: "session";
|
|
282
|
+
plan: "plan";
|
|
283
|
+
gate: "gate";
|
|
284
|
+
action: "action";
|
|
285
|
+
}>;
|
|
286
|
+
entity_id: z.ZodString;
|
|
287
|
+
timestamp: z.ZodString;
|
|
288
|
+
}, z.core.$strip>;
|
|
289
|
+
export type ProvenanceLink = z.infer<typeof ProvenanceLinkSchema>;
|
|
290
|
+
/**
|
|
291
|
+
* Observation (base type for all returned data)
|
|
292
|
+
*/
|
|
293
|
+
export declare const ObservationSchema: z.ZodObject<{
|
|
294
|
+
id: z.ZodString;
|
|
295
|
+
kind: z.ZodEnum<{
|
|
296
|
+
session_start: "session_start";
|
|
297
|
+
session_end: "session_end";
|
|
298
|
+
error: "error";
|
|
299
|
+
plan_created: "plan_created";
|
|
300
|
+
plan_edited: "plan_edited";
|
|
301
|
+
plan_approved: "plan_approved";
|
|
302
|
+
plan_rejected: "plan_rejected";
|
|
303
|
+
action_executed: "action_executed";
|
|
304
|
+
gate_evaluated: "gate_evaluated";
|
|
305
|
+
constraint_applied: "constraint_applied";
|
|
306
|
+
human_input: "human_input";
|
|
307
|
+
}>;
|
|
308
|
+
timestamp: z.ZodString;
|
|
309
|
+
session_id: z.ZodString;
|
|
310
|
+
provenance: z.ZodArray<z.ZodObject<{
|
|
311
|
+
type: z.ZodEnum<{
|
|
312
|
+
approved_by: "approved_by";
|
|
313
|
+
caused_by: "caused_by";
|
|
314
|
+
governed_by: "governed_by";
|
|
315
|
+
linked_to: "linked_to";
|
|
316
|
+
}>;
|
|
317
|
+
entity_type: z.ZodEnum<{
|
|
318
|
+
human: "human";
|
|
319
|
+
session: "session";
|
|
320
|
+
plan: "plan";
|
|
321
|
+
gate: "gate";
|
|
322
|
+
action: "action";
|
|
323
|
+
}>;
|
|
324
|
+
entity_id: z.ZodString;
|
|
325
|
+
timestamp: z.ZodString;
|
|
326
|
+
}, z.core.$strip>>;
|
|
327
|
+
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
328
|
+
}, z.core.$strip>;
|
|
329
|
+
export type Observation = z.infer<typeof ObservationSchema>;
|
|
330
|
+
/**
|
|
331
|
+
* Query response
|
|
332
|
+
*/
|
|
333
|
+
export declare const QueryResponseSchema: z.ZodObject<{
|
|
334
|
+
metadata: z.ZodObject<{
|
|
335
|
+
query_id: z.ZodString;
|
|
336
|
+
executed_at: z.ZodString;
|
|
337
|
+
contract_version: z.ZodString;
|
|
338
|
+
result_count: z.ZodNumber;
|
|
339
|
+
truncated: z.ZodBoolean;
|
|
340
|
+
truncation_reason: z.ZodOptional<z.ZodEnum<{
|
|
341
|
+
max_results: "max_results";
|
|
342
|
+
max_payload_bytes: "max_payload_bytes";
|
|
343
|
+
none: "none";
|
|
344
|
+
}>>;
|
|
345
|
+
}, z.core.$strip>;
|
|
346
|
+
observations: z.ZodArray<z.ZodObject<{
|
|
347
|
+
id: z.ZodString;
|
|
348
|
+
kind: z.ZodEnum<{
|
|
349
|
+
session_start: "session_start";
|
|
350
|
+
session_end: "session_end";
|
|
351
|
+
error: "error";
|
|
352
|
+
plan_created: "plan_created";
|
|
353
|
+
plan_edited: "plan_edited";
|
|
354
|
+
plan_approved: "plan_approved";
|
|
355
|
+
plan_rejected: "plan_rejected";
|
|
356
|
+
action_executed: "action_executed";
|
|
357
|
+
gate_evaluated: "gate_evaluated";
|
|
358
|
+
constraint_applied: "constraint_applied";
|
|
359
|
+
human_input: "human_input";
|
|
360
|
+
}>;
|
|
361
|
+
timestamp: z.ZodString;
|
|
362
|
+
session_id: z.ZodString;
|
|
363
|
+
provenance: z.ZodArray<z.ZodObject<{
|
|
364
|
+
type: z.ZodEnum<{
|
|
365
|
+
approved_by: "approved_by";
|
|
366
|
+
caused_by: "caused_by";
|
|
367
|
+
governed_by: "governed_by";
|
|
368
|
+
linked_to: "linked_to";
|
|
369
|
+
}>;
|
|
370
|
+
entity_type: z.ZodEnum<{
|
|
371
|
+
human: "human";
|
|
372
|
+
session: "session";
|
|
373
|
+
plan: "plan";
|
|
374
|
+
gate: "gate";
|
|
375
|
+
action: "action";
|
|
376
|
+
}>;
|
|
377
|
+
entity_id: z.ZodString;
|
|
378
|
+
timestamp: z.ZodString;
|
|
379
|
+
}, z.core.$strip>>;
|
|
380
|
+
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
381
|
+
}, z.core.$strip>>;
|
|
382
|
+
}, z.core.$strip>;
|
|
383
|
+
export type QueryResponse = z.infer<typeof QueryResponseSchema>;
|
|
384
|
+
/**
|
|
385
|
+
* Every Kindling response guarantees:
|
|
386
|
+
*
|
|
387
|
+
* 1. Stable field names - No field names change between queries
|
|
388
|
+
* 2. Explicit timestamps - Every observation has ISO8601 timestamp
|
|
389
|
+
* 3. Explicit links - Provenance via typed links (caused_by, governed_by, approved_by)
|
|
390
|
+
* 4. No hidden inference - Payload contains only raw facts
|
|
391
|
+
* 5. No reordered history - Observations returned in recorded order
|
|
392
|
+
*
|
|
393
|
+
* This makes Kindling LLM-safe by construction.
|
|
394
|
+
*
|
|
395
|
+
* AI can:
|
|
396
|
+
* - Narrate events
|
|
397
|
+
* - Summarise outcomes
|
|
398
|
+
* - Explain facts
|
|
399
|
+
*
|
|
400
|
+
* But AI will always be explaining facts, not ghosts.
|
|
401
|
+
*/
|
|
402
|
+
/**
|
|
403
|
+
* Operations that MUST NOT exist in the query API:
|
|
404
|
+
*
|
|
405
|
+
* ❌ write()
|
|
406
|
+
* ❌ update()
|
|
407
|
+
* ❌ delete()
|
|
408
|
+
* ❌ annotate()
|
|
409
|
+
* ❌ tag()
|
|
410
|
+
* ❌ learn()
|
|
411
|
+
* ❌ embed()
|
|
412
|
+
* ❌ infer()
|
|
413
|
+
*
|
|
414
|
+
* If user AI wants memory, it must bring its own store.
|
|
415
|
+
*/
|
|
416
|
+
/**
|
|
417
|
+
* The following are explicitly OUT OF SCOPE for v1:
|
|
418
|
+
*
|
|
419
|
+
* ❌ Semantic search
|
|
420
|
+
* ❌ Similarity queries
|
|
421
|
+
* ❌ Embeddings
|
|
422
|
+
* ❌ Cross-plan discovery
|
|
423
|
+
* ❌ Learned relevance
|
|
424
|
+
* ❌ Auto-summaries (stored in Kindling)
|
|
425
|
+
* ❌ AI-generated annotations stored in Kindling
|
|
426
|
+
*
|
|
427
|
+
* These belong to Edda / Ember, not Kindling v1.
|
|
428
|
+
*/
|
|
429
|
+
/**
|
|
430
|
+
* Validate a query request
|
|
431
|
+
*/
|
|
432
|
+
export declare function validateQueryRequest(data: unknown): {
|
|
433
|
+
success: boolean;
|
|
434
|
+
data?: QueryRequest;
|
|
435
|
+
error?: string;
|
|
436
|
+
};
|
|
437
|
+
/**
|
|
438
|
+
* Validate a query response
|
|
439
|
+
*/
|
|
440
|
+
export declare function validateQueryResponse(data: unknown): {
|
|
441
|
+
success: boolean;
|
|
442
|
+
data?: QueryResponse;
|
|
443
|
+
error?: string;
|
|
444
|
+
};
|
|
445
|
+
/**
|
|
446
|
+
* All queries have CLI equivalents:
|
|
447
|
+
*
|
|
448
|
+
* anvil run show <run_id> --json
|
|
449
|
+
* → SessionQuery { scope: 'session', session_id: run_id, shape: 'timeline' }
|
|
450
|
+
*
|
|
451
|
+
* anvil plan trace <plan_id> --json
|
|
452
|
+
* → PlanQuery { scope: 'plan', plan_id: plan_id, shape: 'entity' }
|
|
453
|
+
*
|
|
454
|
+
* anvil gate show <gate_eval_id> --json
|
|
455
|
+
* → GateQuery { scope: 'gate', gate_eval_id: gate_eval_id, shape: 'entity' }
|
|
456
|
+
*
|
|
457
|
+
* anvil action show <action_id> --json
|
|
458
|
+
* → ActionQuery { scope: 'action', action_id: action_id, shape: 'entity' }
|
|
459
|
+
*
|
|
460
|
+
* The CLI is a thin wrapper over this query surface.
|
|
461
|
+
* That symmetry is intentional.
|
|
462
|
+
*/
|
|
463
|
+
//# sourceMappingURL=query-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-contract.d.ts","sourceRoot":"","sources":["../src/query-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,+BAA+B,UAAU,CAAC;AAMvD;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;EAK3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAM1D;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;EAI5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAM5D;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;EAG7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAM9D;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;iBAwBjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAMtE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;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