@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.
Files changed (84) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +542 -0
  3. package/dist/adapter.d.ts +49 -0
  4. package/dist/adapter.d.ts.map +1 -0
  5. package/dist/adapter.js +100 -0
  6. package/dist/config.d.ts +89 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +173 -0
  9. package/dist/emitters/action-emitter.d.ts +40 -0
  10. package/dist/emitters/action-emitter.d.ts.map +1 -0
  11. package/dist/emitters/action-emitter.js +52 -0
  12. package/dist/emitters/constraint-emitter.d.ts +32 -0
  13. package/dist/emitters/constraint-emitter.d.ts.map +1 -0
  14. package/dist/emitters/constraint-emitter.js +41 -0
  15. package/dist/emitters/error-emitter.d.ts +33 -0
  16. package/dist/emitters/error-emitter.d.ts.map +1 -0
  17. package/dist/emitters/error-emitter.js +50 -0
  18. package/dist/emitters/gate-emitter.d.ts +37 -0
  19. package/dist/emitters/gate-emitter.d.ts.map +1 -0
  20. package/dist/emitters/gate-emitter.js +53 -0
  21. package/dist/emitters/human-input-emitter.d.ts +30 -0
  22. package/dist/emitters/human-input-emitter.d.ts.map +1 -0
  23. package/dist/emitters/human-input-emitter.js +38 -0
  24. package/dist/emitters/index.d.ts +13 -0
  25. package/dist/emitters/index.d.ts.map +1 -0
  26. package/dist/emitters/index.js +19 -0
  27. package/dist/emitters/plan-emitter.d.ts +75 -0
  28. package/dist/emitters/plan-emitter.d.ts.map +1 -0
  29. package/dist/emitters/plan-emitter.js +116 -0
  30. package/dist/emitters/session-emitter.d.ts +57 -0
  31. package/dist/emitters/session-emitter.d.ts.map +1 -0
  32. package/dist/emitters/session-emitter.js +80 -0
  33. package/dist/index.d.ts +40 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +111 -0
  36. package/dist/kindling-service.d.ts +122 -0
  37. package/dist/kindling-service.d.ts.map +1 -0
  38. package/dist/kindling-service.js +203 -0
  39. package/dist/observation-contract.d.ts +561 -0
  40. package/dist/observation-contract.d.ts.map +1 -0
  41. package/dist/observation-contract.js +391 -0
  42. package/dist/query-contract.d.ts +463 -0
  43. package/dist/query-contract.d.ts.map +1 -0
  44. package/dist/query-contract.js +314 -0
  45. package/dist/query-limits.d.ts +40 -0
  46. package/dist/query-limits.d.ts.map +1 -0
  47. package/dist/query-limits.js +79 -0
  48. package/dist/query-service.d.ts +109 -0
  49. package/dist/query-service.d.ts.map +1 -0
  50. package/dist/query-service.js +140 -0
  51. package/dist/retention.d.ts +79 -0
  52. package/dist/retention.d.ts.map +1 -0
  53. package/dist/retention.js +81 -0
  54. package/dist/sensitive-data-validator.d.ts +47 -0
  55. package/dist/sensitive-data-validator.d.ts.map +1 -0
  56. package/dist/sensitive-data-validator.js +135 -0
  57. package/dist/status.d.ts +104 -0
  58. package/dist/status.d.ts.map +1 -0
  59. package/dist/status.js +136 -0
  60. package/dist/utils/debug.d.ts +9 -0
  61. package/dist/utils/debug.d.ts.map +1 -0
  62. package/dist/utils/debug.js +55 -0
  63. package/package.json +114 -0
  64. package/src/adapter.ts +117 -0
  65. package/src/config.ts +202 -0
  66. package/src/emitters/action-emitter.ts +90 -0
  67. package/src/emitters/constraint-emitter.ts +73 -0
  68. package/src/emitters/error-emitter.ts +86 -0
  69. package/src/emitters/gate-emitter.ts +87 -0
  70. package/src/emitters/human-input-emitter.ts +71 -0
  71. package/src/emitters/index.ts +40 -0
  72. package/src/emitters/plan-emitter.ts +183 -0
  73. package/src/emitters/session-emitter.ts +131 -0
  74. package/src/index.ts +254 -0
  75. package/src/kindling-service.ts +272 -0
  76. package/src/malicious-ai.test.ts +949 -0
  77. package/src/observation-contract.ts +500 -0
  78. package/src/query-contract.ts +389 -0
  79. package/src/query-limits.ts +106 -0
  80. package/src/query-service.ts +217 -0
  81. package/src/retention.ts +153 -0
  82. package/src/sensitive-data-validator.ts +167 -0
  83. package/src/status.ts +221 -0
  84. package/src/utils/debug.ts +65 -0
@@ -0,0 +1,561 @@
1
+ /**
2
+ * Observation Contract (v1)
3
+ *
4
+ * Defines the 9 observation kinds that Anvil must emit to Kindling.
5
+ * This is the write-only contract - what gets recorded, not how it's queried.
6
+ *
7
+ * Based on: "What Kindling is used for in Anvil v1" specification
8
+ *
9
+ * @see query-contract.ts for the read-only query surface
10
+ */
11
+ import { z } from 'zod';
12
+ export declare const OBSERVATION_CONTRACT_VERSION = "1.0.0";
13
+ /**
14
+ * Session Start: Every Anvil run opens a session capsule
15
+ */
16
+ export declare const SessionStartObservationSchema: z.ZodObject<{
17
+ kind: z.ZodLiteral<"session_start">;
18
+ session_id: z.ZodString;
19
+ timestamp: z.ZodString;
20
+ context: z.ZodObject<{
21
+ working_directory: z.ZodString;
22
+ git_ref: z.ZodOptional<z.ZodString>;
23
+ git_dirty: z.ZodOptional<z.ZodBoolean>;
24
+ anvil_version: z.ZodString;
25
+ command: z.ZodString;
26
+ args: z.ZodArray<z.ZodString>;
27
+ environment: z.ZodEnum<{
28
+ unknown: "unknown";
29
+ development: "development";
30
+ ci: "ci";
31
+ production: "production";
32
+ }>;
33
+ }, z.core.$strip>;
34
+ plan_id: z.ZodOptional<z.ZodString>;
35
+ }, z.core.$strip>;
36
+ export type SessionStartObservation = z.infer<typeof SessionStartObservationSchema>;
37
+ /**
38
+ * Session End: Closes the capsule with outcome
39
+ */
40
+ export declare const SessionEndObservationSchema: z.ZodObject<{
41
+ kind: z.ZodLiteral<"session_end">;
42
+ session_id: z.ZodString;
43
+ timestamp: z.ZodString;
44
+ outcome: z.ZodEnum<{
45
+ success: "success";
46
+ failure: "failure";
47
+ partial: "partial";
48
+ cancelled: "cancelled";
49
+ }>;
50
+ exit_code: z.ZodNumber;
51
+ duration_ms: z.ZodNumber;
52
+ summary: z.ZodObject<{
53
+ gates_evaluated: z.ZodNumber;
54
+ gates_passed: z.ZodNumber;
55
+ gates_failed: z.ZodNumber;
56
+ actions_executed: z.ZodNumber;
57
+ errors_encountered: z.ZodNumber;
58
+ }, z.core.$strip>;
59
+ }, z.core.$strip>;
60
+ export type SessionEndObservation = z.infer<typeof SessionEndObservationSchema>;
61
+ /**
62
+ * Plan Created: New plan authored
63
+ */
64
+ export declare const PlanCreatedObservationSchema: z.ZodObject<{
65
+ kind: z.ZodLiteral<"plan_created">;
66
+ session_id: z.ZodString;
67
+ timestamp: z.ZodString;
68
+ plan_id: z.ZodString;
69
+ plan_version: z.ZodString;
70
+ plan_path: z.ZodString;
71
+ plan_hash: z.ZodString;
72
+ created_by: z.ZodEnum<{
73
+ human: "human";
74
+ ai: "ai";
75
+ system: "system";
76
+ }>;
77
+ source: z.ZodOptional<z.ZodString>;
78
+ }, z.core.$strip>;
79
+ export type PlanCreatedObservation = z.infer<typeof PlanCreatedObservationSchema>;
80
+ /**
81
+ * Plan Edited: Plan modified
82
+ */
83
+ export declare const PlanEditedObservationSchema: z.ZodObject<{
84
+ kind: z.ZodLiteral<"plan_edited">;
85
+ session_id: z.ZodString;
86
+ timestamp: z.ZodString;
87
+ plan_id: z.ZodString;
88
+ previous_version: z.ZodString;
89
+ new_version: z.ZodString;
90
+ previous_hash: z.ZodString;
91
+ new_hash: z.ZodString;
92
+ edited_by: z.ZodEnum<{
93
+ human: "human";
94
+ ai: "ai";
95
+ system: "system";
96
+ }>;
97
+ change_summary: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$strip>;
99
+ export type PlanEditedObservation = z.infer<typeof PlanEditedObservationSchema>;
100
+ /**
101
+ * Plan Approved: Human approval recorded
102
+ */
103
+ export declare const PlanApprovedObservationSchema: z.ZodObject<{
104
+ kind: z.ZodLiteral<"plan_approved">;
105
+ session_id: z.ZodString;
106
+ timestamp: z.ZodString;
107
+ plan_id: z.ZodString;
108
+ plan_version: z.ZodString;
109
+ approved_by: z.ZodString;
110
+ approval_method: z.ZodEnum<{
111
+ cli_confirm: "cli_confirm";
112
+ explicit_flag: "explicit_flag";
113
+ ci_gate: "ci_gate";
114
+ }>;
115
+ }, z.core.$strip>;
116
+ export type PlanApprovedObservation = z.infer<typeof PlanApprovedObservationSchema>;
117
+ /**
118
+ * Plan Rejected: Human rejection recorded
119
+ */
120
+ export declare const PlanRejectedObservationSchema: z.ZodObject<{
121
+ kind: z.ZodLiteral<"plan_rejected">;
122
+ session_id: z.ZodString;
123
+ timestamp: z.ZodString;
124
+ plan_id: z.ZodString;
125
+ plan_version: z.ZodString;
126
+ rejected_by: z.ZodString;
127
+ rejection_reason: z.ZodOptional<z.ZodString>;
128
+ }, z.core.$strip>;
129
+ export type PlanRejectedObservation = z.infer<typeof PlanRejectedObservationSchema>;
130
+ /**
131
+ * Action Executed: Observable action taken
132
+ */
133
+ export declare const ActionExecutedObservationSchema: z.ZodObject<{
134
+ kind: z.ZodLiteral<"action_executed">;
135
+ session_id: z.ZodString;
136
+ timestamp: z.ZodString;
137
+ action_id: z.ZodString;
138
+ action_type: z.ZodEnum<{
139
+ command: "command";
140
+ tool_invocation: "tool_invocation";
141
+ file_write: "file_write";
142
+ file_delete: "file_delete";
143
+ diff_apply: "diff_apply";
144
+ }>;
145
+ details: z.ZodObject<{
146
+ command: z.ZodOptional<z.ZodString>;
147
+ tool_name: z.ZodOptional<z.ZodString>;
148
+ file_paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
149
+ diff_summary: z.ZodOptional<z.ZodObject<{
150
+ additions: z.ZodNumber;
151
+ deletions: z.ZodNumber;
152
+ files_changed: z.ZodNumber;
153
+ }, z.core.$strip>>;
154
+ working_directory: z.ZodString;
155
+ environment_target: z.ZodOptional<z.ZodString>;
156
+ }, z.core.$strip>;
157
+ governed_by_gate_id: z.ZodOptional<z.ZodString>;
158
+ governed_by_plan_id: z.ZodOptional<z.ZodString>;
159
+ outcome: z.ZodEnum<{
160
+ success: "success";
161
+ failure: "failure";
162
+ partial: "partial";
163
+ }>;
164
+ exit_code: z.ZodOptional<z.ZodNumber>;
165
+ duration_ms: z.ZodNumber;
166
+ }, z.core.$strip>;
167
+ export type ActionExecutedObservation = z.infer<typeof ActionExecutedObservationSchema>;
168
+ /**
169
+ * Gate Evaluated: Structured gate check result
170
+ */
171
+ export declare const GateEvaluatedObservationSchema: z.ZodObject<{
172
+ kind: z.ZodLiteral<"gate_evaluated">;
173
+ session_id: z.ZodString;
174
+ timestamp: z.ZodString;
175
+ gate_eval_id: z.ZodString;
176
+ gate_id: z.ZodString;
177
+ gate_version: z.ZodOptional<z.ZodString>;
178
+ inputs: z.ZodObject<{
179
+ file_count: z.ZodOptional<z.ZodNumber>;
180
+ changed_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
181
+ baseline_hash: z.ZodOptional<z.ZodString>;
182
+ }, z.core.$strip>;
183
+ outcome: z.ZodEnum<{
184
+ error: "error";
185
+ pass: "pass";
186
+ fail: "fail";
187
+ skipped: "skipped";
188
+ }>;
189
+ rules_evaluated: z.ZodArray<z.ZodString>;
190
+ rules_violated: z.ZodOptional<z.ZodArray<z.ZodString>>;
191
+ enforcement: z.ZodEnum<{
192
+ blocking: "blocking";
193
+ warning: "warning";
194
+ informational: "informational";
195
+ }>;
196
+ duration_ms: z.ZodNumber;
197
+ violation_count: z.ZodOptional<z.ZodNumber>;
198
+ warning_count: z.ZodOptional<z.ZodNumber>;
199
+ }, z.core.$strip>;
200
+ export type GateEvaluatedObservation = z.infer<typeof GateEvaluatedObservationSchema>;
201
+ /**
202
+ * Constraint Applied: When Anvil prevents an action
203
+ */
204
+ export declare const ConstraintAppliedObservationSchema: z.ZodObject<{
205
+ kind: z.ZodLiteral<"constraint_applied">;
206
+ session_id: z.ZodString;
207
+ timestamp: z.ZodString;
208
+ constraint_id: z.ZodString;
209
+ constraint_type: z.ZodEnum<{
210
+ environment: "environment";
211
+ policy: "policy";
212
+ rule: "rule";
213
+ scope: "scope";
214
+ approval_required: "approval_required";
215
+ }>;
216
+ prevented_action: z.ZodObject<{
217
+ action_type: z.ZodString;
218
+ action_target: z.ZodOptional<z.ZodString>;
219
+ }, z.core.$strip>;
220
+ reason: z.ZodString;
221
+ scope: z.ZodOptional<z.ZodString>;
222
+ environment: z.ZodOptional<z.ZodString>;
223
+ options_available: z.ZodOptional<z.ZodArray<z.ZodString>>;
224
+ options_allowed: z.ZodOptional<z.ZodArray<z.ZodString>>;
225
+ }, z.core.$strip>;
226
+ export type ConstraintAppliedObservation = z.infer<typeof ConstraintAppliedObservationSchema>;
227
+ /**
228
+ * Human Input: User action recorded
229
+ */
230
+ export declare const HumanInputObservationSchema: z.ZodObject<{
231
+ kind: z.ZodLiteral<"human_input">;
232
+ session_id: z.ZodString;
233
+ timestamp: z.ZodString;
234
+ input_type: z.ZodEnum<{
235
+ approval: "approval";
236
+ override: "override";
237
+ rejection: "rejection";
238
+ manual_edit: "manual_edit";
239
+ confirmation: "confirmation";
240
+ cancellation: "cancellation";
241
+ }>;
242
+ context: z.ZodObject<{
243
+ prompt: z.ZodOptional<z.ZodString>;
244
+ target: z.ZodOptional<z.ZodString>;
245
+ }, z.core.$strip>;
246
+ decision: z.ZodString;
247
+ reason: z.ZodOptional<z.ZodString>;
248
+ user_identifier: z.ZodString;
249
+ }, z.core.$strip>;
250
+ export type HumanInputObservation = z.infer<typeof HumanInputObservationSchema>;
251
+ /**
252
+ * Error: Failure recorded (not noise, data)
253
+ */
254
+ export declare const ErrorObservationSchema: z.ZodObject<{
255
+ kind: z.ZodLiteral<"error">;
256
+ session_id: z.ZodString;
257
+ timestamp: z.ZodString;
258
+ error_id: z.ZodString;
259
+ error_type: z.ZodEnum<{
260
+ command_failure: "command_failure";
261
+ tool_error: "tool_error";
262
+ aborted_execution: "aborted_execution";
263
+ partial_state: "partial_state";
264
+ validation_failure: "validation_failure";
265
+ }>;
266
+ context: z.ZodObject<{
267
+ component: z.ZodString;
268
+ action_id: z.ZodOptional<z.ZodString>;
269
+ gate_id: z.ZodOptional<z.ZodString>;
270
+ }, z.core.$strip>;
271
+ error_message: z.ZodString;
272
+ error_code: z.ZodOptional<z.ZodString>;
273
+ exit_code: z.ZodOptional<z.ZodNumber>;
274
+ recoverable: z.ZodBoolean;
275
+ partial_state_description: z.ZodOptional<z.ZodString>;
276
+ }, z.core.$strip>;
277
+ export type ErrorObservation = z.infer<typeof ErrorObservationSchema>;
278
+ /**
279
+ * All observation kinds (discriminated union by 'kind')
280
+ */
281
+ export declare const ObservationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
282
+ kind: z.ZodLiteral<"session_start">;
283
+ session_id: z.ZodString;
284
+ timestamp: z.ZodString;
285
+ context: z.ZodObject<{
286
+ working_directory: z.ZodString;
287
+ git_ref: z.ZodOptional<z.ZodString>;
288
+ git_dirty: z.ZodOptional<z.ZodBoolean>;
289
+ anvil_version: z.ZodString;
290
+ command: z.ZodString;
291
+ args: z.ZodArray<z.ZodString>;
292
+ environment: z.ZodEnum<{
293
+ unknown: "unknown";
294
+ development: "development";
295
+ ci: "ci";
296
+ production: "production";
297
+ }>;
298
+ }, z.core.$strip>;
299
+ plan_id: z.ZodOptional<z.ZodString>;
300
+ }, z.core.$strip>, z.ZodObject<{
301
+ kind: z.ZodLiteral<"session_end">;
302
+ session_id: z.ZodString;
303
+ timestamp: z.ZodString;
304
+ outcome: z.ZodEnum<{
305
+ success: "success";
306
+ failure: "failure";
307
+ partial: "partial";
308
+ cancelled: "cancelled";
309
+ }>;
310
+ exit_code: z.ZodNumber;
311
+ duration_ms: z.ZodNumber;
312
+ summary: z.ZodObject<{
313
+ gates_evaluated: z.ZodNumber;
314
+ gates_passed: z.ZodNumber;
315
+ gates_failed: z.ZodNumber;
316
+ actions_executed: z.ZodNumber;
317
+ errors_encountered: z.ZodNumber;
318
+ }, z.core.$strip>;
319
+ }, z.core.$strip>, z.ZodObject<{
320
+ kind: z.ZodLiteral<"plan_created">;
321
+ session_id: z.ZodString;
322
+ timestamp: z.ZodString;
323
+ plan_id: z.ZodString;
324
+ plan_version: z.ZodString;
325
+ plan_path: z.ZodString;
326
+ plan_hash: z.ZodString;
327
+ created_by: z.ZodEnum<{
328
+ human: "human";
329
+ ai: "ai";
330
+ system: "system";
331
+ }>;
332
+ source: z.ZodOptional<z.ZodString>;
333
+ }, z.core.$strip>, z.ZodObject<{
334
+ kind: z.ZodLiteral<"plan_edited">;
335
+ session_id: z.ZodString;
336
+ timestamp: z.ZodString;
337
+ plan_id: z.ZodString;
338
+ previous_version: z.ZodString;
339
+ new_version: z.ZodString;
340
+ previous_hash: z.ZodString;
341
+ new_hash: z.ZodString;
342
+ edited_by: z.ZodEnum<{
343
+ human: "human";
344
+ ai: "ai";
345
+ system: "system";
346
+ }>;
347
+ change_summary: z.ZodOptional<z.ZodString>;
348
+ }, z.core.$strip>, z.ZodObject<{
349
+ kind: z.ZodLiteral<"plan_approved">;
350
+ session_id: z.ZodString;
351
+ timestamp: z.ZodString;
352
+ plan_id: z.ZodString;
353
+ plan_version: z.ZodString;
354
+ approved_by: z.ZodString;
355
+ approval_method: z.ZodEnum<{
356
+ cli_confirm: "cli_confirm";
357
+ explicit_flag: "explicit_flag";
358
+ ci_gate: "ci_gate";
359
+ }>;
360
+ }, z.core.$strip>, z.ZodObject<{
361
+ kind: z.ZodLiteral<"plan_rejected">;
362
+ session_id: z.ZodString;
363
+ timestamp: z.ZodString;
364
+ plan_id: z.ZodString;
365
+ plan_version: z.ZodString;
366
+ rejected_by: z.ZodString;
367
+ rejection_reason: z.ZodOptional<z.ZodString>;
368
+ }, z.core.$strip>, z.ZodObject<{
369
+ kind: z.ZodLiteral<"action_executed">;
370
+ session_id: z.ZodString;
371
+ timestamp: z.ZodString;
372
+ action_id: z.ZodString;
373
+ action_type: z.ZodEnum<{
374
+ command: "command";
375
+ tool_invocation: "tool_invocation";
376
+ file_write: "file_write";
377
+ file_delete: "file_delete";
378
+ diff_apply: "diff_apply";
379
+ }>;
380
+ details: z.ZodObject<{
381
+ command: z.ZodOptional<z.ZodString>;
382
+ tool_name: z.ZodOptional<z.ZodString>;
383
+ file_paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
384
+ diff_summary: z.ZodOptional<z.ZodObject<{
385
+ additions: z.ZodNumber;
386
+ deletions: z.ZodNumber;
387
+ files_changed: z.ZodNumber;
388
+ }, z.core.$strip>>;
389
+ working_directory: z.ZodString;
390
+ environment_target: z.ZodOptional<z.ZodString>;
391
+ }, z.core.$strip>;
392
+ governed_by_gate_id: z.ZodOptional<z.ZodString>;
393
+ governed_by_plan_id: z.ZodOptional<z.ZodString>;
394
+ outcome: z.ZodEnum<{
395
+ success: "success";
396
+ failure: "failure";
397
+ partial: "partial";
398
+ }>;
399
+ exit_code: z.ZodOptional<z.ZodNumber>;
400
+ duration_ms: z.ZodNumber;
401
+ }, z.core.$strip>, z.ZodObject<{
402
+ kind: z.ZodLiteral<"gate_evaluated">;
403
+ session_id: z.ZodString;
404
+ timestamp: z.ZodString;
405
+ gate_eval_id: z.ZodString;
406
+ gate_id: z.ZodString;
407
+ gate_version: z.ZodOptional<z.ZodString>;
408
+ inputs: z.ZodObject<{
409
+ file_count: z.ZodOptional<z.ZodNumber>;
410
+ changed_files: z.ZodOptional<z.ZodArray<z.ZodString>>;
411
+ baseline_hash: z.ZodOptional<z.ZodString>;
412
+ }, z.core.$strip>;
413
+ outcome: z.ZodEnum<{
414
+ error: "error";
415
+ pass: "pass";
416
+ fail: "fail";
417
+ skipped: "skipped";
418
+ }>;
419
+ rules_evaluated: z.ZodArray<z.ZodString>;
420
+ rules_violated: z.ZodOptional<z.ZodArray<z.ZodString>>;
421
+ enforcement: z.ZodEnum<{
422
+ blocking: "blocking";
423
+ warning: "warning";
424
+ informational: "informational";
425
+ }>;
426
+ duration_ms: z.ZodNumber;
427
+ violation_count: z.ZodOptional<z.ZodNumber>;
428
+ warning_count: z.ZodOptional<z.ZodNumber>;
429
+ }, z.core.$strip>, z.ZodObject<{
430
+ kind: z.ZodLiteral<"constraint_applied">;
431
+ session_id: z.ZodString;
432
+ timestamp: z.ZodString;
433
+ constraint_id: z.ZodString;
434
+ constraint_type: z.ZodEnum<{
435
+ environment: "environment";
436
+ policy: "policy";
437
+ rule: "rule";
438
+ scope: "scope";
439
+ approval_required: "approval_required";
440
+ }>;
441
+ prevented_action: z.ZodObject<{
442
+ action_type: z.ZodString;
443
+ action_target: z.ZodOptional<z.ZodString>;
444
+ }, z.core.$strip>;
445
+ reason: z.ZodString;
446
+ scope: z.ZodOptional<z.ZodString>;
447
+ environment: z.ZodOptional<z.ZodString>;
448
+ options_available: z.ZodOptional<z.ZodArray<z.ZodString>>;
449
+ options_allowed: z.ZodOptional<z.ZodArray<z.ZodString>>;
450
+ }, z.core.$strip>, z.ZodObject<{
451
+ kind: z.ZodLiteral<"human_input">;
452
+ session_id: z.ZodString;
453
+ timestamp: z.ZodString;
454
+ input_type: z.ZodEnum<{
455
+ approval: "approval";
456
+ override: "override";
457
+ rejection: "rejection";
458
+ manual_edit: "manual_edit";
459
+ confirmation: "confirmation";
460
+ cancellation: "cancellation";
461
+ }>;
462
+ context: z.ZodObject<{
463
+ prompt: z.ZodOptional<z.ZodString>;
464
+ target: z.ZodOptional<z.ZodString>;
465
+ }, z.core.$strip>;
466
+ decision: z.ZodString;
467
+ reason: z.ZodOptional<z.ZodString>;
468
+ user_identifier: z.ZodString;
469
+ }, z.core.$strip>, z.ZodObject<{
470
+ kind: z.ZodLiteral<"error">;
471
+ session_id: z.ZodString;
472
+ timestamp: z.ZodString;
473
+ error_id: z.ZodString;
474
+ error_type: z.ZodEnum<{
475
+ command_failure: "command_failure";
476
+ tool_error: "tool_error";
477
+ aborted_execution: "aborted_execution";
478
+ partial_state: "partial_state";
479
+ validation_failure: "validation_failure";
480
+ }>;
481
+ context: z.ZodObject<{
482
+ component: z.ZodString;
483
+ action_id: z.ZodOptional<z.ZodString>;
484
+ gate_id: z.ZodOptional<z.ZodString>;
485
+ }, z.core.$strip>;
486
+ error_message: z.ZodString;
487
+ error_code: z.ZodOptional<z.ZodString>;
488
+ exit_code: z.ZodOptional<z.ZodNumber>;
489
+ recoverable: z.ZodBoolean;
490
+ partial_state_description: z.ZodOptional<z.ZodString>;
491
+ }, z.core.$strip>], "kind">;
492
+ export type Observation = SessionStartObservation | SessionEndObservation | PlanCreatedObservation | PlanEditedObservation | PlanApprovedObservation | PlanRejectedObservation | ActionExecutedObservation | GateEvaluatedObservation | ConstraintAppliedObservation | HumanInputObservation | ErrorObservation;
493
+ /**
494
+ * What Anvil must emit to be "Kindling-complete"
495
+ *
496
+ * Every Anvil execution must:
497
+ * 1. Emit SessionStartObservation when any command starts
498
+ * 2. Emit SessionEndObservation when command completes (success or failure)
499
+ * 3. Emit GateEvaluatedObservation for every gate check
500
+ * 4. Emit ActionExecutedObservation for every observable action
501
+ * 5. Emit ErrorObservation for every failure (even recoverable)
502
+ * 6. Emit HumanInputObservation for every approval/override/rejection
503
+ * 7. Emit ConstraintAppliedObservation when actions are prevented
504
+ * 8. Emit Plan* observations for all plan lifecycle events
505
+ *
506
+ * Observations are:
507
+ * - Immutable (write-once)
508
+ * - Timestamped (ISO8601)
509
+ * - Linked (session_id, plan_id, gate_id, action_id)
510
+ * - Sanitised (no secrets, redacted commands)
511
+ * - Facts only (no interpretation, no inference)
512
+ */
513
+ /**
514
+ * Anvil codebase integration points:
515
+ *
516
+ * SessionStart/End:
517
+ * - cli/src/commands/*.ts (every command entry/exit)
518
+ * - cli/src/commands/watch.ts (each watch cycle)
519
+ *
520
+ * GateEvaluated:
521
+ * - core/src/gate/gate-runner.ts (GateRunner.run completion)
522
+ * - Each check implementation (architecture, coverage, secrets, etc.)
523
+ *
524
+ * ActionExecuted:
525
+ * - Anywhere Anvil executes commands (via child_process)
526
+ * - File write/delete operations
527
+ * - Diff application
528
+ *
529
+ * Plan*:
530
+ * - core/src/aps/ (plan parsing, validation, execution)
531
+ * - cli/src/commands/plan.ts (plan management commands)
532
+ *
533
+ * HumanInput:
534
+ * - cli/src/tui/ (TUI confirmation prompts)
535
+ * - cli/src/commands/ (CLI --approve flags)
536
+ *
537
+ * ConstraintApplied:
538
+ * - core/src/gate/ (when gate blocks action)
539
+ * - Policy evaluation layers
540
+ *
541
+ * Error:
542
+ * - All try/catch blocks that handle failures
543
+ * - Process error handlers
544
+ * - Validation failures
545
+ */
546
+ /**
547
+ * Validate an observation before emission
548
+ */
549
+ export declare function validateObservation(data: unknown): {
550
+ success: boolean;
551
+ data?: Observation;
552
+ error?: string;
553
+ };
554
+ /**
555
+ * Check if observation contains sensitive data (should never pass validation)
556
+ */
557
+ export declare function containsSensitiveData(obs: Observation): {
558
+ hasSensitiveData: boolean;
559
+ issues: string[];
560
+ };
561
+ //# sourceMappingURL=observation-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observation-contract.d.ts","sourceRoot":"","sources":["../src/observation-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,4BAA4B,UAAU,CAAC;AAMpD;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;iBAoBxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;iBAkBtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAMhF;;GAEG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;iBAavC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;iBAatC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;iBAS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