@basou/core 0.8.0 → 0.10.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/dist/index.d.ts CHANGED
@@ -149,6 +149,10 @@ declare const SessionInnerImportSchema: z.ZodObject<{
149
149
  active_time_method: z.ZodOptional<z.ZodString>;
150
150
  machine_active_time_ms: z.ZodOptional<z.ZodNumber>;
151
151
  }, z.core.$strip>>;
152
+ integrity: z.ZodOptional<z.ZodObject<{
153
+ head_hash: z.ZodString;
154
+ event_count: z.ZodNumber;
155
+ }, z.core.$strict>>;
152
156
  }, z.core.$strict>;
153
157
  /**
154
158
  * Schema for the round-trip JSON payload accepted by `basou session import
@@ -210,6 +214,10 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
210
214
  active_time_method: z.ZodOptional<z.ZodString>;
211
215
  machine_active_time_ms: z.ZodOptional<z.ZodNumber>;
212
216
  }, z.core.$strip>>;
217
+ integrity: z.ZodOptional<z.ZodObject<{
218
+ head_hash: z.ZodString;
219
+ event_count: z.ZodNumber;
220
+ }, z.core.$strict>>;
213
221
  }, z.core.$strict>;
214
222
  events: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
215
223
  schema_version: z.ZodLiteral<"0.1.0">;
@@ -217,6 +225,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
217
225
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
218
226
  occurred_at: z.ZodString;
219
227
  source: z.ZodString;
228
+ prev_hash: z.ZodOptional<z.ZodString>;
220
229
  type: z.ZodLiteral<"session_started">;
221
230
  }, z.core.$strip>, z.ZodObject<{
222
231
  schema_version: z.ZodLiteral<"0.1.0">;
@@ -224,6 +233,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
224
233
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
225
234
  occurred_at: z.ZodString;
226
235
  source: z.ZodString;
236
+ prev_hash: z.ZodOptional<z.ZodString>;
227
237
  type: z.ZodLiteral<"session_ended">;
228
238
  exit_code: z.ZodOptional<z.ZodNumber>;
229
239
  }, z.core.$strip>, z.ZodObject<{
@@ -232,6 +242,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
232
242
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
233
243
  occurred_at: z.ZodString;
234
244
  source: z.ZodString;
245
+ prev_hash: z.ZodOptional<z.ZodString>;
235
246
  type: z.ZodLiteral<"session_status_changed">;
236
247
  from: z.ZodString;
237
248
  to: z.ZodString;
@@ -241,6 +252,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
241
252
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
242
253
  occurred_at: z.ZodString;
243
254
  source: z.ZodString;
255
+ prev_hash: z.ZodOptional<z.ZodString>;
244
256
  type: z.ZodLiteral<"approval_requested">;
245
257
  approval_id: z.ZodString & z.ZodType<`appr_${string}`, string, z.core.$ZodTypeInternals<`appr_${string}`, string>>;
246
258
  expires_at: z.ZodDefault<z.ZodNullable<z.ZodString>>;
@@ -261,6 +273,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
261
273
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
262
274
  occurred_at: z.ZodString;
263
275
  source: z.ZodString;
276
+ prev_hash: z.ZodOptional<z.ZodString>;
264
277
  type: z.ZodLiteral<"approval_approved">;
265
278
  approval_id: z.ZodString & z.ZodType<`appr_${string}`, string, z.core.$ZodTypeInternals<`appr_${string}`, string>>;
266
279
  resolver: z.ZodOptional<z.ZodString>;
@@ -271,6 +284,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
271
284
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
272
285
  occurred_at: z.ZodString;
273
286
  source: z.ZodString;
287
+ prev_hash: z.ZodOptional<z.ZodString>;
274
288
  type: z.ZodLiteral<"approval_rejected">;
275
289
  approval_id: z.ZodString & z.ZodType<`appr_${string}`, string, z.core.$ZodTypeInternals<`appr_${string}`, string>>;
276
290
  resolver: z.ZodOptional<z.ZodString>;
@@ -281,6 +295,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
281
295
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
282
296
  occurred_at: z.ZodString;
283
297
  source: z.ZodString;
298
+ prev_hash: z.ZodOptional<z.ZodString>;
284
299
  type: z.ZodLiteral<"approval_expired">;
285
300
  approval_id: z.ZodString & z.ZodType<`appr_${string}`, string, z.core.$ZodTypeInternals<`appr_${string}`, string>>;
286
301
  }, z.core.$strip>, z.ZodObject<{
@@ -289,6 +304,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
289
304
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
290
305
  occurred_at: z.ZodString;
291
306
  source: z.ZodString;
307
+ prev_hash: z.ZodOptional<z.ZodString>;
292
308
  type: z.ZodLiteral<"command_executed">;
293
309
  command: z.ZodString;
294
310
  args: z.ZodArray<z.ZodString>;
@@ -303,6 +319,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
303
319
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
304
320
  occurred_at: z.ZodString;
305
321
  source: z.ZodString;
322
+ prev_hash: z.ZodOptional<z.ZodString>;
306
323
  type: z.ZodLiteral<"git_snapshot">;
307
324
  head: z.ZodString;
308
325
  branch: z.ZodString;
@@ -318,6 +335,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
318
335
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
319
336
  occurred_at: z.ZodString;
320
337
  source: z.ZodString;
338
+ prev_hash: z.ZodOptional<z.ZodString>;
321
339
  type: z.ZodLiteral<"file_changed">;
322
340
  path: z.ZodString;
323
341
  change_type: z.ZodEnum<{
@@ -333,6 +351,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
333
351
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
334
352
  occurred_at: z.ZodString;
335
353
  source: z.ZodString;
354
+ prev_hash: z.ZodOptional<z.ZodString>;
336
355
  type: z.ZodLiteral<"decision_recorded">;
337
356
  decision_id: z.ZodString & z.ZodType<`decision_${string}`, string, z.core.$ZodTypeInternals<`decision_${string}`, string>>;
338
357
  title: z.ZodString;
@@ -347,6 +366,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
347
366
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
348
367
  occurred_at: z.ZodString;
349
368
  source: z.ZodString;
369
+ prev_hash: z.ZodOptional<z.ZodString>;
350
370
  type: z.ZodLiteral<"task_created">;
351
371
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
352
372
  title: z.ZodString;
@@ -356,6 +376,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
356
376
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
357
377
  occurred_at: z.ZodString;
358
378
  source: z.ZodString;
379
+ prev_hash: z.ZodOptional<z.ZodString>;
359
380
  type: z.ZodLiteral<"task_status_changed">;
360
381
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
361
382
  from: z.ZodString;
@@ -366,6 +387,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
366
387
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
367
388
  occurred_at: z.ZodString;
368
389
  source: z.ZodString;
390
+ prev_hash: z.ZodOptional<z.ZodString>;
369
391
  type: z.ZodLiteral<"task_reconciled">;
370
392
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
371
393
  removed_created_in_session: z.ZodDefault<z.ZodNullable<z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>>>;
@@ -377,6 +399,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
377
399
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
378
400
  occurred_at: z.ZodString;
379
401
  source: z.ZodString;
402
+ prev_hash: z.ZodOptional<z.ZodString>;
380
403
  type: z.ZodLiteral<"task_linkage_refreshed">;
381
404
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
382
405
  added_linked_sessions: z.ZodDefault<z.ZodArray<z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>>>;
@@ -388,6 +411,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
388
411
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
389
412
  occurred_at: z.ZodString;
390
413
  source: z.ZodString;
414
+ prev_hash: z.ZodOptional<z.ZodString>;
391
415
  type: z.ZodLiteral<"task_deleted">;
392
416
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
393
417
  title: z.ZodString;
@@ -397,6 +421,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
397
421
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
398
422
  occurred_at: z.ZodString;
399
423
  source: z.ZodString;
424
+ prev_hash: z.ZodOptional<z.ZodString>;
400
425
  type: z.ZodLiteral<"task_archived">;
401
426
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
402
427
  title: z.ZodString;
@@ -406,6 +431,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
406
431
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
407
432
  occurred_at: z.ZodString;
408
433
  source: z.ZodString;
434
+ prev_hash: z.ZodOptional<z.ZodString>;
409
435
  type: z.ZodLiteral<"note_added">;
410
436
  body: z.ZodString;
411
437
  }, z.core.$strip>, z.ZodObject<{
@@ -414,6 +440,7 @@ declare const SessionImportPayloadSchema: z.ZodObject<{
414
440
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
415
441
  occurred_at: z.ZodString;
416
442
  source: z.ZodString;
443
+ prev_hash: z.ZodOptional<z.ZodString>;
417
444
  type: z.ZodLiteral<"adapter_output">;
418
445
  stream: z.ZodEnum<{
419
446
  stdout: "stdout";
@@ -728,6 +755,7 @@ declare const SessionStartedEventSchema: z.ZodObject<{
728
755
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
729
756
  occurred_at: z.ZodString;
730
757
  source: z.ZodString;
758
+ prev_hash: z.ZodOptional<z.ZodString>;
731
759
  type: z.ZodLiteral<"session_started">;
732
760
  }, z.core.$strip>;
733
761
  declare const SessionEndedEventSchema: z.ZodObject<{
@@ -736,6 +764,7 @@ declare const SessionEndedEventSchema: z.ZodObject<{
736
764
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
737
765
  occurred_at: z.ZodString;
738
766
  source: z.ZodString;
767
+ prev_hash: z.ZodOptional<z.ZodString>;
739
768
  type: z.ZodLiteral<"session_ended">;
740
769
  exit_code: z.ZodOptional<z.ZodNumber>;
741
770
  }, z.core.$strip>;
@@ -745,6 +774,7 @@ declare const SessionStatusChangedEventSchema: z.ZodObject<{
745
774
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
746
775
  occurred_at: z.ZodString;
747
776
  source: z.ZodString;
777
+ prev_hash: z.ZodOptional<z.ZodString>;
748
778
  type: z.ZodLiteral<"session_status_changed">;
749
779
  from: z.ZodString;
750
780
  to: z.ZodString;
@@ -755,6 +785,7 @@ declare const ApprovalRequestedEventSchema: z.ZodObject<{
755
785
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
756
786
  occurred_at: z.ZodString;
757
787
  source: z.ZodString;
788
+ prev_hash: z.ZodOptional<z.ZodString>;
758
789
  type: z.ZodLiteral<"approval_requested">;
759
790
  approval_id: z.ZodString & z.ZodType<`appr_${string}`, string, z.core.$ZodTypeInternals<`appr_${string}`, string>>;
760
791
  expires_at: z.ZodDefault<z.ZodNullable<z.ZodString>>;
@@ -776,6 +807,7 @@ declare const ApprovalApprovedEventSchema: z.ZodObject<{
776
807
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
777
808
  occurred_at: z.ZodString;
778
809
  source: z.ZodString;
810
+ prev_hash: z.ZodOptional<z.ZodString>;
779
811
  type: z.ZodLiteral<"approval_approved">;
780
812
  approval_id: z.ZodString & z.ZodType<`appr_${string}`, string, z.core.$ZodTypeInternals<`appr_${string}`, string>>;
781
813
  resolver: z.ZodOptional<z.ZodString>;
@@ -787,6 +819,7 @@ declare const ApprovalRejectedEventSchema: z.ZodObject<{
787
819
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
788
820
  occurred_at: z.ZodString;
789
821
  source: z.ZodString;
822
+ prev_hash: z.ZodOptional<z.ZodString>;
790
823
  type: z.ZodLiteral<"approval_rejected">;
791
824
  approval_id: z.ZodString & z.ZodType<`appr_${string}`, string, z.core.$ZodTypeInternals<`appr_${string}`, string>>;
792
825
  resolver: z.ZodOptional<z.ZodString>;
@@ -798,6 +831,7 @@ declare const ApprovalExpiredEventSchema: z.ZodObject<{
798
831
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
799
832
  occurred_at: z.ZodString;
800
833
  source: z.ZodString;
834
+ prev_hash: z.ZodOptional<z.ZodString>;
801
835
  type: z.ZodLiteral<"approval_expired">;
802
836
  approval_id: z.ZodString & z.ZodType<`appr_${string}`, string, z.core.$ZodTypeInternals<`appr_${string}`, string>>;
803
837
  }, z.core.$strip>;
@@ -807,6 +841,7 @@ declare const CommandExecutedEventSchema: z.ZodObject<{
807
841
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
808
842
  occurred_at: z.ZodString;
809
843
  source: z.ZodString;
844
+ prev_hash: z.ZodOptional<z.ZodString>;
810
845
  type: z.ZodLiteral<"command_executed">;
811
846
  command: z.ZodString;
812
847
  args: z.ZodArray<z.ZodString>;
@@ -822,6 +857,7 @@ declare const GitSnapshotEventSchema: z.ZodObject<{
822
857
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
823
858
  occurred_at: z.ZodString;
824
859
  source: z.ZodString;
860
+ prev_hash: z.ZodOptional<z.ZodString>;
825
861
  type: z.ZodLiteral<"git_snapshot">;
826
862
  head: z.ZodString;
827
863
  branch: z.ZodString;
@@ -838,6 +874,7 @@ declare const FileChangedEventSchema: z.ZodObject<{
838
874
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
839
875
  occurred_at: z.ZodString;
840
876
  source: z.ZodString;
877
+ prev_hash: z.ZodOptional<z.ZodString>;
841
878
  type: z.ZodLiteral<"file_changed">;
842
879
  path: z.ZodString;
843
880
  change_type: z.ZodEnum<{
@@ -854,6 +891,7 @@ declare const DecisionRecordedEventSchema: z.ZodObject<{
854
891
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
855
892
  occurred_at: z.ZodString;
856
893
  source: z.ZodString;
894
+ prev_hash: z.ZodOptional<z.ZodString>;
857
895
  type: z.ZodLiteral<"decision_recorded">;
858
896
  decision_id: z.ZodString & z.ZodType<`decision_${string}`, string, z.core.$ZodTypeInternals<`decision_${string}`, string>>;
859
897
  title: z.ZodString;
@@ -869,6 +907,7 @@ declare const TaskCreatedEventSchema: z.ZodObject<{
869
907
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
870
908
  occurred_at: z.ZodString;
871
909
  source: z.ZodString;
910
+ prev_hash: z.ZodOptional<z.ZodString>;
872
911
  type: z.ZodLiteral<"task_created">;
873
912
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
874
913
  title: z.ZodString;
@@ -879,6 +918,7 @@ declare const TaskStatusChangedEventSchema: z.ZodObject<{
879
918
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
880
919
  occurred_at: z.ZodString;
881
920
  source: z.ZodString;
921
+ prev_hash: z.ZodOptional<z.ZodString>;
882
922
  type: z.ZodLiteral<"task_status_changed">;
883
923
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
884
924
  from: z.ZodString;
@@ -890,6 +930,7 @@ declare const TaskReconciledEventSchema: z.ZodObject<{
890
930
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
891
931
  occurred_at: z.ZodString;
892
932
  source: z.ZodString;
933
+ prev_hash: z.ZodOptional<z.ZodString>;
893
934
  type: z.ZodLiteral<"task_reconciled">;
894
935
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
895
936
  removed_created_in_session: z.ZodDefault<z.ZodNullable<z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>>>;
@@ -902,6 +943,7 @@ declare const TaskLinkageRefreshedEventSchema: z.ZodObject<{
902
943
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
903
944
  occurred_at: z.ZodString;
904
945
  source: z.ZodString;
946
+ prev_hash: z.ZodOptional<z.ZodString>;
905
947
  type: z.ZodLiteral<"task_linkage_refreshed">;
906
948
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
907
949
  added_linked_sessions: z.ZodDefault<z.ZodArray<z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>>>;
@@ -914,6 +956,7 @@ declare const TaskDeletedEventSchema: z.ZodObject<{
914
956
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
915
957
  occurred_at: z.ZodString;
916
958
  source: z.ZodString;
959
+ prev_hash: z.ZodOptional<z.ZodString>;
917
960
  type: z.ZodLiteral<"task_deleted">;
918
961
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
919
962
  title: z.ZodString;
@@ -924,6 +967,7 @@ declare const TaskArchivedEventSchema: z.ZodObject<{
924
967
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
925
968
  occurred_at: z.ZodString;
926
969
  source: z.ZodString;
970
+ prev_hash: z.ZodOptional<z.ZodString>;
927
971
  type: z.ZodLiteral<"task_archived">;
928
972
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
929
973
  title: z.ZodString;
@@ -934,6 +978,7 @@ declare const NoteAddedEventSchema: z.ZodObject<{
934
978
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
935
979
  occurred_at: z.ZodString;
936
980
  source: z.ZodString;
981
+ prev_hash: z.ZodOptional<z.ZodString>;
937
982
  type: z.ZodLiteral<"note_added">;
938
983
  body: z.ZodString;
939
984
  }, z.core.$strip>;
@@ -943,6 +988,7 @@ declare const AdapterOutputEventSchema: z.ZodObject<{
943
988
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
944
989
  occurred_at: z.ZodString;
945
990
  source: z.ZodString;
991
+ prev_hash: z.ZodOptional<z.ZodString>;
946
992
  type: z.ZodLiteral<"adapter_output">;
947
993
  stream: z.ZodEnum<{
948
994
  stdout: "stdout";
@@ -963,6 +1009,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
963
1009
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
964
1010
  occurred_at: z.ZodString;
965
1011
  source: z.ZodString;
1012
+ prev_hash: z.ZodOptional<z.ZodString>;
966
1013
  type: z.ZodLiteral<"session_started">;
967
1014
  }, z.core.$strip>, z.ZodObject<{
968
1015
  schema_version: z.ZodLiteral<"0.1.0">;
@@ -970,6 +1017,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
970
1017
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
971
1018
  occurred_at: z.ZodString;
972
1019
  source: z.ZodString;
1020
+ prev_hash: z.ZodOptional<z.ZodString>;
973
1021
  type: z.ZodLiteral<"session_ended">;
974
1022
  exit_code: z.ZodOptional<z.ZodNumber>;
975
1023
  }, z.core.$strip>, z.ZodObject<{
@@ -978,6 +1026,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
978
1026
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
979
1027
  occurred_at: z.ZodString;
980
1028
  source: z.ZodString;
1029
+ prev_hash: z.ZodOptional<z.ZodString>;
981
1030
  type: z.ZodLiteral<"session_status_changed">;
982
1031
  from: z.ZodString;
983
1032
  to: z.ZodString;
@@ -987,6 +1036,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
987
1036
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
988
1037
  occurred_at: z.ZodString;
989
1038
  source: z.ZodString;
1039
+ prev_hash: z.ZodOptional<z.ZodString>;
990
1040
  type: z.ZodLiteral<"approval_requested">;
991
1041
  approval_id: z.ZodString & z.ZodType<`appr_${string}`, string, z.core.$ZodTypeInternals<`appr_${string}`, string>>;
992
1042
  expires_at: z.ZodDefault<z.ZodNullable<z.ZodString>>;
@@ -1007,6 +1057,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1007
1057
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1008
1058
  occurred_at: z.ZodString;
1009
1059
  source: z.ZodString;
1060
+ prev_hash: z.ZodOptional<z.ZodString>;
1010
1061
  type: z.ZodLiteral<"approval_approved">;
1011
1062
  approval_id: z.ZodString & z.ZodType<`appr_${string}`, string, z.core.$ZodTypeInternals<`appr_${string}`, string>>;
1012
1063
  resolver: z.ZodOptional<z.ZodString>;
@@ -1017,6 +1068,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1017
1068
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1018
1069
  occurred_at: z.ZodString;
1019
1070
  source: z.ZodString;
1071
+ prev_hash: z.ZodOptional<z.ZodString>;
1020
1072
  type: z.ZodLiteral<"approval_rejected">;
1021
1073
  approval_id: z.ZodString & z.ZodType<`appr_${string}`, string, z.core.$ZodTypeInternals<`appr_${string}`, string>>;
1022
1074
  resolver: z.ZodOptional<z.ZodString>;
@@ -1027,6 +1079,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1027
1079
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1028
1080
  occurred_at: z.ZodString;
1029
1081
  source: z.ZodString;
1082
+ prev_hash: z.ZodOptional<z.ZodString>;
1030
1083
  type: z.ZodLiteral<"approval_expired">;
1031
1084
  approval_id: z.ZodString & z.ZodType<`appr_${string}`, string, z.core.$ZodTypeInternals<`appr_${string}`, string>>;
1032
1085
  }, z.core.$strip>, z.ZodObject<{
@@ -1035,6 +1088,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1035
1088
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1036
1089
  occurred_at: z.ZodString;
1037
1090
  source: z.ZodString;
1091
+ prev_hash: z.ZodOptional<z.ZodString>;
1038
1092
  type: z.ZodLiteral<"command_executed">;
1039
1093
  command: z.ZodString;
1040
1094
  args: z.ZodArray<z.ZodString>;
@@ -1049,6 +1103,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1049
1103
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1050
1104
  occurred_at: z.ZodString;
1051
1105
  source: z.ZodString;
1106
+ prev_hash: z.ZodOptional<z.ZodString>;
1052
1107
  type: z.ZodLiteral<"git_snapshot">;
1053
1108
  head: z.ZodString;
1054
1109
  branch: z.ZodString;
@@ -1064,6 +1119,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1064
1119
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1065
1120
  occurred_at: z.ZodString;
1066
1121
  source: z.ZodString;
1122
+ prev_hash: z.ZodOptional<z.ZodString>;
1067
1123
  type: z.ZodLiteral<"file_changed">;
1068
1124
  path: z.ZodString;
1069
1125
  change_type: z.ZodEnum<{
@@ -1079,6 +1135,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1079
1135
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1080
1136
  occurred_at: z.ZodString;
1081
1137
  source: z.ZodString;
1138
+ prev_hash: z.ZodOptional<z.ZodString>;
1082
1139
  type: z.ZodLiteral<"decision_recorded">;
1083
1140
  decision_id: z.ZodString & z.ZodType<`decision_${string}`, string, z.core.$ZodTypeInternals<`decision_${string}`, string>>;
1084
1141
  title: z.ZodString;
@@ -1093,6 +1150,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1093
1150
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1094
1151
  occurred_at: z.ZodString;
1095
1152
  source: z.ZodString;
1153
+ prev_hash: z.ZodOptional<z.ZodString>;
1096
1154
  type: z.ZodLiteral<"task_created">;
1097
1155
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
1098
1156
  title: z.ZodString;
@@ -1102,6 +1160,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1102
1160
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1103
1161
  occurred_at: z.ZodString;
1104
1162
  source: z.ZodString;
1163
+ prev_hash: z.ZodOptional<z.ZodString>;
1105
1164
  type: z.ZodLiteral<"task_status_changed">;
1106
1165
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
1107
1166
  from: z.ZodString;
@@ -1112,6 +1171,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1112
1171
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1113
1172
  occurred_at: z.ZodString;
1114
1173
  source: z.ZodString;
1174
+ prev_hash: z.ZodOptional<z.ZodString>;
1115
1175
  type: z.ZodLiteral<"task_reconciled">;
1116
1176
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
1117
1177
  removed_created_in_session: z.ZodDefault<z.ZodNullable<z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>>>;
@@ -1123,6 +1183,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1123
1183
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1124
1184
  occurred_at: z.ZodString;
1125
1185
  source: z.ZodString;
1186
+ prev_hash: z.ZodOptional<z.ZodString>;
1126
1187
  type: z.ZodLiteral<"task_linkage_refreshed">;
1127
1188
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
1128
1189
  added_linked_sessions: z.ZodDefault<z.ZodArray<z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>>>;
@@ -1134,6 +1195,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1134
1195
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1135
1196
  occurred_at: z.ZodString;
1136
1197
  source: z.ZodString;
1198
+ prev_hash: z.ZodOptional<z.ZodString>;
1137
1199
  type: z.ZodLiteral<"task_deleted">;
1138
1200
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
1139
1201
  title: z.ZodString;
@@ -1143,6 +1205,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1143
1205
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1144
1206
  occurred_at: z.ZodString;
1145
1207
  source: z.ZodString;
1208
+ prev_hash: z.ZodOptional<z.ZodString>;
1146
1209
  type: z.ZodLiteral<"task_archived">;
1147
1210
  task_id: z.ZodString & z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
1148
1211
  title: z.ZodString;
@@ -1152,6 +1215,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1152
1215
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1153
1216
  occurred_at: z.ZodString;
1154
1217
  source: z.ZodString;
1218
+ prev_hash: z.ZodOptional<z.ZodString>;
1155
1219
  type: z.ZodLiteral<"note_added">;
1156
1220
  body: z.ZodString;
1157
1221
  }, z.core.$strip>, z.ZodObject<{
@@ -1160,6 +1224,7 @@ declare const EventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1160
1224
  session_id: z.ZodString & z.ZodType<`ses_${string}`, string, z.core.$ZodTypeInternals<`ses_${string}`, string>>;
1161
1225
  occurred_at: z.ZodString;
1162
1226
  source: z.ZodString;
1227
+ prev_hash: z.ZodOptional<z.ZodString>;
1163
1228
  type: z.ZodLiteral<"adapter_output">;
1164
1229
  stream: z.ZodEnum<{
1165
1230
  stdout: "stdout";
@@ -1345,6 +1410,22 @@ declare const SessionMetricsSchema: z.ZodObject<{
1345
1410
  }, z.core.$strip>;
1346
1411
  /** Inferred runtime type for {@link SessionMetricsSchema}. */
1347
1412
  type SessionMetrics = z.infer<typeof SessionMetricsSchema>;
1413
+ /**
1414
+ * Tamper-evidence head anchor for a session whose `events.jsonl` is hash
1415
+ * chained: `head_hash` is the hex sha-256 of the last written event line
1416
+ * (excluding the trailing newline), `event_count` the number of chained lines.
1417
+ * Written by the import / in-place re-import writers and, for a live session
1418
+ * (`exec` / `run` / ad-hoc), by the finalize once it reaches a terminal status.
1419
+ * Absent on a still-live session (the anchor is stamped at finalize) and on a
1420
+ * pre-feature unchained session. Additive optional => no schema_version bump.
1421
+ * `.strict()` because the writers fully own the shape.
1422
+ */
1423
+ declare const SessionIntegritySchema: z.ZodObject<{
1424
+ head_hash: z.ZodString;
1425
+ event_count: z.ZodNumber;
1426
+ }, z.core.$strict>;
1427
+ /** Inferred runtime type for {@link SessionIntegritySchema}. */
1428
+ type SessionIntegrity = z.infer<typeof SessionIntegritySchema>;
1348
1429
  /**
1349
1430
  * Schema for `.basou/sessions/<session_id>/session.yaml`. The minimal
1350
1431
  * session document carries the actual fields nested under the outer
@@ -1405,6 +1486,10 @@ declare const SessionSchema: z.ZodObject<{
1405
1486
  active_time_method: z.ZodOptional<z.ZodString>;
1406
1487
  machine_active_time_ms: z.ZodOptional<z.ZodNumber>;
1407
1488
  }, z.core.$strip>>;
1489
+ integrity: z.ZodOptional<z.ZodObject<{
1490
+ head_hash: z.ZodString;
1491
+ event_count: z.ZodNumber;
1492
+ }, z.core.$strict>>;
1408
1493
  }, z.core.$strip>;
1409
1494
  }, z.core.$strip>;
1410
1495
  /** Inferred runtime type for {@link SessionSchema}. */
@@ -1470,6 +1555,35 @@ declare function enumerateSessionDirs(paths: BasouPaths): Promise<string[]>;
1470
1555
  * or the zod error).
1471
1556
  */
1472
1557
  declare function readSessionYaml(paths: BasouPaths, sessionId: string): Promise<Session>;
1558
+ /**
1559
+ * Apply a terminal-status mutation to a live session's `session.yaml` AND, in
1560
+ * the same locked write, stamp the tamper-evidence head anchor derived from the
1561
+ * on-disk `events.jsonl` tail. Used by the `exec` / `run` orchestrators for
1562
+ * BOTH terminal writers (the normal end-of-run finalize and the spawn-failure
1563
+ * `failed` finalize).
1564
+ *
1565
+ * Why locked + anchor-from-tail: live appends chain the LOG only and leave the
1566
+ * anchor for finalize. Reading the final tail under the session lock means a
1567
+ * foreign line appended just before finalize (e.g. a `decision record` attached
1568
+ * to a still-running session) is included in the anchor, and a foreign attach
1569
+ * that arrives after the terminal status is set is rejected by the attach gate
1570
+ * — so the anchor can never disagree with the at-rest log. The whole-document
1571
+ * read-modify-write also preserves any field a foreign locked writer set (e.g.
1572
+ * a task attach's `task_id`).
1573
+ *
1574
+ * The anchor is written only when the log is actually chained with at least one
1575
+ * line; a legacy unchained session (and an empty log) is left with no
1576
+ * `integrity` anchor, matching the import writers. The mutator receives the
1577
+ * full {@link Session} document and typically sets
1578
+ * `session.session.status` / `ended_at` / `invocation.exit_code` /
1579
+ * `related_files`.
1580
+ *
1581
+ * Throws the {@link inspectChainTail} errors (torn / mixed log), the
1582
+ * {@link readSessionYaml} errors, a zod error if the mutation produces an
1583
+ * invalid document, or `Error("Failed to overwrite YAML file")` on a disk
1584
+ * failure.
1585
+ */
1586
+ declare function finalizeSessionYaml(paths: BasouPaths, sessionId: string, mutate: (session: Session) => void): Promise<void>;
1473
1587
  /**
1474
1588
  * Classify a `running` session as suspect using one of two rules:
1475
1589
  *
@@ -1539,6 +1653,144 @@ type DecisionsRendererResult = {
1539
1653
  */
1540
1654
  declare function renderDecisions(input: DecisionsRendererInput): Promise<DecisionsRendererResult>;
1541
1655
 
1656
+ /**
1657
+ * Session-bound genesis hash: the `prev_hash` carried by the FIRST event line
1658
+ * of a chained `events.jsonl`. Binding the genesis to the session id means a
1659
+ * chain copied verbatim from another session fails verification at line 1
1660
+ * even though its internal back-pointers are intact.
1661
+ */
1662
+ declare function genesisHash(sessionId: string): string;
1663
+ /**
1664
+ * Hex sha-256 of one event line's written bytes (EXCLUDING the trailing
1665
+ * `\n`). The hash covers the literal serialized bytes — no canonical JSON
1666
+ * form. Writers pass the line string (always valid UTF-8, so its UTF-8
1667
+ * encoding IS the written bytes); the verifier passes the RAW BYTES it read,
1668
+ * so a byte-level mutation that decodes to the same string (e.g. an invalid
1669
+ * UTF-8 sequence collapsing to U+FFFD) still breaks the chain.
1670
+ */
1671
+ declare function lineHash(rawLine: string | Buffer): string;
1672
+ /**
1673
+ * The single serializer for event lines. Every writer (bulk and append) MUST
1674
+ * go through this function so the bytes a chain hashes can never diverge from
1675
+ * the bytes another code path would write.
1676
+ */
1677
+ declare function serializeEventLine(event: Event): string;
1678
+ /** Result of {@link chainEvents}: the serialized lines plus the head anchor inputs. */
1679
+ type ChainedEvents = {
1680
+ /** Serialized event lines (no trailing newline on the entries). */
1681
+ lines: string[];
1682
+ /**
1683
+ * Hex sha-256 of the LAST line — the value `session.yaml.integrity.head_hash`
1684
+ * anchors. For an empty batch this is the genesis hash and no anchor is
1685
+ * written.
1686
+ */
1687
+ headHash: string;
1688
+ /** Number of chained lines (= `integrity.event_count`). */
1689
+ count: number;
1690
+ };
1691
+ /**
1692
+ * Thread a `prev_hash` back-pointer through `events` and serialize them:
1693
+ * line 0 carries `genesisHash(sessionId)`, line N carries the hash of line
1694
+ * N-1's written bytes. Any `prev_hash` already present on an incoming event
1695
+ * (e.g. a round-trip import payload) is discarded and recomputed — chains are
1696
+ * never trusted from input, only derived at write time.
1697
+ */
1698
+ declare function chainEvents(events: ReadonlyArray<Event>, sessionId: string): ChainedEvents;
1699
+ /**
1700
+ * Chain PRE-EXISTING serialized event lines WITHOUT re-serializing them
1701
+ * through the schema layer: each original line is JSON-parsed, given a
1702
+ * `prev_hash`, and stringified again. Because `JSON.parse`/`JSON.stringify`
1703
+ * round-trips key insertion order and every value verbatim, the output line
1704
+ * is the original line with only the `prev_hash` member appended — no zod
1705
+ * key-stripping or default materialization can occur. Used by the in-place
1706
+ * rechain migration of pre-chaining imported sessions.
1707
+ *
1708
+ * Callers MUST gate validity first (non-empty, JSON-parseable,
1709
+ * schema-valid, byte-identical JSON round-trip); this helper assumes
1710
+ * parseable lines and throws raw on a parse failure.
1711
+ */
1712
+ declare function chainRawJsonLines(rawLines: ReadonlyArray<string>, sessionId: string): ChainedEvents;
1713
+
1714
+ /**
1715
+ * The chain state of an existing `events.jsonl`, as needed by the live append
1716
+ * and finalize paths.
1717
+ *
1718
+ * - `chained` — whether the NEXT line written to this log must carry a
1719
+ * `prev_hash`. True for an empty / not-yet-created log (a fresh session
1720
+ * chains from its genesis) and for a log whose FIRST complete line already
1721
+ * carries `prev_hash`. False for a legacy / pre-feature log whose first line
1722
+ * is unchained (so it stays unchained — we never half-chain a file).
1723
+ * - `head` — the `prev_hash` value the next line carries when `chained`:
1724
+ * `genesisHash(sessionId)` for an empty log, otherwise `lineHash` of the LAST
1725
+ * complete line's raw bytes. Meaningless (set to the genesis hash) when
1726
+ * `chained` is false.
1727
+ * - `count` — number of complete (newline-terminated) lines on disk; the
1728
+ * `event_count` an integrity anchor records.
1729
+ */
1730
+ type ChainTailState = {
1731
+ chained: boolean;
1732
+ head: string;
1733
+ count: number;
1734
+ };
1735
+ /**
1736
+ * Inspect `<sessions>/<sessionId>/events.jsonl` to decide how the next append
1737
+ * (or the finalize anchor) must treat the chain. READ-ONLY; the caller MUST
1738
+ * already hold the session lock so the inspected tail cannot move underneath a
1739
+ * subsequent append.
1740
+ *
1741
+ * Chained-ness is decided from the FIRST complete line (does the log claim to
1742
+ * be chained), and the head pointer is taken from the LAST complete line. If
1743
+ * the first and last lines DISAGREE — a mixed / partially-tampered file — the
1744
+ * call THROWS rather than extending a broken chain; verify is the detector, the
1745
+ * writer must not deepen a break. An unterminated final line (a torn tail from
1746
+ * a crashed prior append) also THROWS so a new line is never glued onto a
1747
+ * fragment.
1748
+ *
1749
+ * Throws `Error("Failed to read events.jsonl")` for non-ENOENT I/O,
1750
+ * `Error("Unterminated final line in events.jsonl")` for a torn tail, and
1751
+ * `Error("events.jsonl is partially chained")` for a mixed first/last line.
1752
+ */
1753
+ declare function inspectChainTail(paths: BasouPaths, sessionId: string): Promise<ChainTailState>;
1754
+ /**
1755
+ * Append one event to `<sessions>/<sessionId>/events.jsonl`, threading the
1756
+ * tamper-evidence hash chain. The caller MUST already hold the session lock
1757
+ * (`acquireLock(paths, "session", sessionId)`); this function does NOT acquire
1758
+ * it, so it composes inside a larger caller-owned critical section (the
1759
+ * convention used by `decision record`, `session note`, task attach and
1760
+ * approval resolution) without re-entrant lock deadlock.
1761
+ *
1762
+ * The event is validated against {@link EventSchema}, then — if the existing
1763
+ * log is chained (or empty) — written with a `prev_hash` back-pointer derived
1764
+ * from the real on-disk tail (see {@link inspectChainTail}); a legacy unchained
1765
+ * log keeps receiving plain unchained lines. The single serializer
1766
+ * ({@link serializeEventLine}) is shared with the bulk writers so the bytes a
1767
+ * chain hashes can never diverge from another path's bytes.
1768
+ *
1769
+ * Does NOT touch `session.yaml.integrity`: the head anchor is written once, at
1770
+ * the terminal-status finalize, by {@link finalizeSessionYaml}. A still-live
1771
+ * session therefore has a chained log but no anchor yet, which `verify` reports
1772
+ * as the benign `in_progress`.
1773
+ *
1774
+ * Throws `"Invalid Basou event payload"` on validation failure, the
1775
+ * {@link inspectChainTail} errors on a torn / mixed log, or `"Failed to append
1776
+ * event to events.jsonl"` on a disk failure. The native error is attached as
1777
+ * `cause`.
1778
+ */
1779
+ declare function appendChainedEventLocked(paths: BasouPaths, sessionId: string, event: unknown): Promise<{
1780
+ chained: boolean;
1781
+ }>;
1782
+ /**
1783
+ * Self-locking wrapper around {@link appendChainedEventLocked} for callers that
1784
+ * do NOT already hold the session lock (the `exec` / `run` orchestrators, which
1785
+ * append one event at a time to a session they own). Acquires the session lock,
1786
+ * appends, and releases. Each append is a short-lived lock hold — the lock is
1787
+ * NEVER held across a child process — so a foreign attach can interleave safely
1788
+ * and the next append chains onto the true tail.
1789
+ */
1790
+ declare function appendChainedEvent(paths: BasouPaths, sessionId: string, event: unknown): Promise<{
1791
+ chained: boolean;
1792
+ }>;
1793
+
1542
1794
  /**
1543
1795
  * Append a single Basou event to `<sessionDir>/events.jsonl`.
1544
1796
  *
@@ -1547,6 +1799,14 @@ declare function renderDecisions(input: DecisionsRendererInput): Promise<Decisio
1547
1799
  * Validation enforces the per-variant contract (required fields, source
1548
1800
  * vocabulary, strict variants such as `adapter_output`).
1549
1801
  *
1802
+ * This LOW-LEVEL writer does NOT hash-chain — it writes the validated event as
1803
+ * a plain line. Hash-chained appends go through `appendChainedEvent` /
1804
+ * `appendChainedEventLocked` (the live `exec` / `run` / attach / approval
1805
+ * paths), and the bulk import writers chain via {@link writeEventsBulk} with
1806
+ * `chain: true`. A direct caller of this raw export can still add an unchained
1807
+ * line to a chained log; that is DETECTED by `basou verify`
1808
+ * (`missing_prev_hash`), not prevented — a documented boundary.
1809
+ *
1550
1810
  * Atomicity: writes go through `appendFile` which uses `O_APPEND`. Lines up
1551
1811
  * to `PIPE_BUF` bytes (Linux 4096 / macOS 512) are written atomically by the
1552
1812
  * kernel; longer lines may interleave with concurrent writers and are not
@@ -1560,6 +1820,23 @@ declare function renderDecisions(input: DecisionsRendererInput): Promise<Decisio
1560
1820
  * @param event unknown payload to validate and append
1561
1821
  */
1562
1822
  declare function appendEvent(sessionDir: string, event: unknown): Promise<void>;
1823
+ /** Options for {@link writeEventsBulk}. */
1824
+ type WriteEventsBulkOptions = {
1825
+ /**
1826
+ * Thread a per-line `prev_hash` hash chain through the batch and return the
1827
+ * head anchor inputs. Used ONLY by the import writers (fresh import and
1828
+ * in-place re-import); defaults to false so the live / ad-hoc writers keep
1829
+ * producing plain unchained lines.
1830
+ */
1831
+ chain?: boolean;
1832
+ };
1833
+ /** Head anchor inputs returned by a chained {@link writeEventsBulk}. */
1834
+ type BulkChainResult = {
1835
+ /** Hex sha-256 of the last written line (excluding the trailing `\n`). */
1836
+ headHash: string;
1837
+ /** Number of chained lines written. */
1838
+ count: number;
1839
+ };
1563
1840
  /**
1564
1841
  * Write `events.jsonl` in one atomic tmp+rename pass via {@link atomicReplace},
1565
1842
  * validating every event against {@link EventSchema} before any disk I/O so
@@ -1570,12 +1847,116 @@ declare function appendEvent(sessionDir: string, event: unknown): Promise<void>;
1570
1847
  * of events must land together or not at all. Zero events produces a
1571
1848
  * zero-byte file so the session_yaml `events_log` pointer remains valid.
1572
1849
  *
1850
+ * With `options.chain` set, each line is written with a `prev_hash`
1851
+ * back-pointer (any incoming `prev_hash` is discarded and recomputed; the
1852
+ * chain's genesis is bound to `basename(sessionDir)` = the session id) and
1853
+ * the head anchor inputs are returned so the caller can persist
1854
+ * `session.yaml.integrity`. An empty chained batch writes a zero-byte file
1855
+ * and returns null — no anchor. Without `chain` the return value is null and
1856
+ * the written bytes are identical to the previous unchained format.
1857
+ *
1573
1858
  * Throws `"Invalid Basou event payload"` (same fixed message as
1574
1859
  * {@link appendEvent}) on validation failure, or `"Failed to write
1575
1860
  * events.jsonl"` on a disk I/O failure. The original native error is attached
1576
1861
  * as `cause`.
1577
1862
  */
1578
- declare function writeEventsBulk(sessionDir: string, events: Event[]): Promise<void>;
1863
+ declare function writeEventsBulk(sessionDir: string, events: Event[], options?: WriteEventsBulkOptions): Promise<BulkChainResult | null>;
1864
+
1865
+ /**
1866
+ * Verification outcome for one session's `events.jsonl`.
1867
+ *
1868
+ * - `unchained` — no event line carries `prev_hash` (live / ad-hoc / legacy
1869
+ * session) and `session.yaml` carries no integrity anchor. Informational.
1870
+ * - `empty` — zero events and no integrity anchor. Informational.
1871
+ * - `incomplete` — the log is chained but `session.yaml` is ENTIRELY absent
1872
+ * (an import crashed between the events write and the yaml write, or the
1873
+ * yaml was deleted out of band). Benign: a re-import / `--force` repairs it.
1874
+ * - `tampered` — a real integrity break (see {@link ChainBreakReason}).
1875
+ * - `in_progress` — a chained log whose session is still LIVE (a non-terminal
1876
+ * status: initialized / running / waiting_approval). The internal
1877
+ * back-pointer chain is fully verified, but the tail and head anchor are
1878
+ * forgiven because a live session's log is legitimately still growing and its
1879
+ * anchor is not written until the terminal finalize. Informational, exit 0.
1880
+ * - `verified` — every back-pointer, genesis, session-id and line-discipline
1881
+ * check passed AND the head anchor matches the on-disk log.
1882
+ */
1883
+ type ChainVerdictStatus = "verified" | "unchained" | "empty" | "incomplete" | "in_progress" | "tampered";
1884
+ /** Machine-readable detail for a `tampered` (or `incomplete`) verdict. */
1885
+ type ChainBreakReason =
1886
+ /** The file does not end with `\n`; chained writers always terminate the last line. */
1887
+ "torn_tail"
1888
+ /** A blank line inside a chained log; chained writers never emit one. */
1889
+ | "blank_line"
1890
+ /** A line of a chained log failed JSON parsing; writers only emit valid JSON. */
1891
+ | "malformed_line"
1892
+ /** A chained log has a line without `prev_hash`; chained writers chain every line. */
1893
+ | "missing_prev_hash"
1894
+ /** Line 1's `prev_hash` is not this session's genesis hash (edit or cross-session copy). */
1895
+ | "genesis_mismatch"
1896
+ /** A line's `prev_hash` does not hash-match the previous line (edit / insert / delete / reorder). */
1897
+ | "broken_link"
1898
+ /** A line's `session_id` is not this session's id (cross-session copied line). */
1899
+ | "session_id_mismatch"
1900
+ /** `session.yaml` exists but its `integrity` anchor is missing (anchor stripped). */
1901
+ | "anchor_missing"
1902
+ /** The anchor's `head_hash` / `event_count` disagree with the on-disk log (edit or truncation). */
1903
+ | "anchor_mismatch"
1904
+ /** An integrity anchor exists but the log is unchained, empty, or missing (chain stripped). */
1905
+ | "anchor_without_chain"
1906
+ /** `session.yaml` exists but could not be parsed / validated, so the anchor is unreadable. */
1907
+ | "yaml_unreadable"
1908
+ /** `incomplete` only: `session.yaml` is entirely absent. */
1909
+ | "yaml_missing";
1910
+ /** Result of {@link verifyEventsChain}. */
1911
+ type ChainVerdict = {
1912
+ status: ChainVerdictStatus;
1913
+ /** Complete (newline-terminated) event lines found on disk. */
1914
+ eventCount: number;
1915
+ /** Detail for `tampered` / `incomplete`; absent otherwise. */
1916
+ reason?: ChainBreakReason;
1917
+ /** 1-based line number of the first break, when one specific line broke. */
1918
+ line?: number;
1919
+ };
1920
+ /**
1921
+ * Verify the tamper-evidence hash chain of `<sessions>/<sessionId>/events.jsonl`
1922
+ * against the head anchor in `session.yaml.integrity`. READ-ONLY.
1923
+ *
1924
+ * The verifier reads the RAW line BYTES (not the schema-filtering replay
1925
+ * reader, which silently drops bad lines; and not a decoded string, which
1926
+ * would collapse invalid UTF-8 sequences into U+FFFD and let a byte-level
1927
+ * substitution survive re-hashing) and hashes exactly the bytes it read.
1928
+ * The verdict is decided on the events first, then the anchor:
1929
+ *
1930
+ * - No line carries `prev_hash` (or there are zero lines / no file): the log
1931
+ * is unchained. If `session.yaml` nevertheless carries an integrity anchor,
1932
+ * the chain was stripped out of band => `tampered` (`anchor_without_chain`);
1933
+ * otherwise `unchained` / `empty`.
1934
+ * - At least one line carries `prev_hash`: the log claims to be chained, and
1935
+ * every check applies — line discipline (terminating `\n`, no blank lines,
1936
+ * valid JSON), genesis binding, per-line back-pointers, per-line session id,
1937
+ * and finally the head anchor (`incomplete` when `session.yaml` is entirely
1938
+ * absent; `tampered` when it is present without a matching anchor).
1939
+ *
1940
+ * - When the chained log belongs to a LIVE session (a non-terminal status),
1941
+ * the internal chain is verified but a torn tail / absent / mismatching
1942
+ * anchor is FORGIVEN as `in_progress`: a live session's tail is legitimately
1943
+ * still growing and its anchor is written only at the terminal finalize.
1944
+ *
1945
+ * NON-CRYPTOGRAPHIC: the anchor lives in `session.yaml`, which is itself
1946
+ * editable; an attacker rewriting BOTH files consistently is not detected.
1947
+ * Signing is a follow-up.
1948
+ *
1949
+ * Throws `Error("Failed to read events.jsonl")` only for non-ENOENT I/O
1950
+ * failures (EACCES etc.) — an unreadable file is an environment problem, not
1951
+ * a verdict.
1952
+ *
1953
+ * READ-ONLY and lock-free: a session being finalized concurrently can leave the
1954
+ * two files momentarily out of step (old events read before a finalize, new
1955
+ * anchor read after it). A strict `anchor_mismatch` is therefore re-snapshotted
1956
+ * ONCE before being returned — a genuine mismatch is deterministic across the
1957
+ * retry, while a finalize-in-flight resolves within it.
1958
+ */
1959
+ declare function verifyEventsChain(paths: BasouPaths, sessionId: string): Promise<ChainVerdict>;
1579
1960
 
1580
1961
  /**
1581
1962
  * Status classification used by the `file_changed` event schema. Limited to
@@ -1755,8 +2136,8 @@ declare function isValidPrefixedId(value: string): boolean;
1755
2136
  * Self-edges are rejected so the audit trail stays monotonic.
1756
2137
  */
1757
2138
  declare const TaskStatusSchema: z.ZodEnum<{
1758
- planned: "planned";
1759
2139
  in_progress: "in_progress";
2140
+ planned: "planned";
1760
2141
  done: "done";
1761
2142
  cancelled: "cancelled";
1762
2143
  }>;
@@ -1776,8 +2157,8 @@ declare const TaskSchema: z.ZodObject<{
1776
2157
  title: z.ZodString;
1777
2158
  label: z.ZodOptional<z.ZodString>;
1778
2159
  status: z.ZodEnum<{
1779
- planned: "planned";
1780
2160
  in_progress: "in_progress";
2161
+ planned: "planned";
1781
2162
  done: "done";
1782
2163
  cancelled: "cancelled";
1783
2164
  }>;
@@ -3139,6 +3520,9 @@ type LockHandle = {
3139
3520
  *
3140
3521
  * Acquisition strategy:
3141
3522
  * 1. {@link atomicCreate} the lockfile (POSIX link(2) + EEXIST).
3523
+ * On ENOENT (a workspace from before `.basou/locks/` existed), create
3524
+ * the directory and retry once; a retry failure throws the pathless
3525
+ * `"Failed to acquire lock"`.
3142
3526
  * 2. On EEXIST, probe the existing lockfile via {@link isStaleLock}.
3143
3527
  * - If stale (= holder pid is dead or lock is older than
3144
3528
  * {@link STALE_LOCK_MAX_AGE_MS}), `unlink` the stale file and retry
@@ -3344,7 +3728,7 @@ type ReimportResult = {
3344
3728
  reusedIdCount: number;
3345
3729
  } | {
3346
3730
  status: "skipped";
3347
- reason: "prior_events_unreadable" | "prior_derived_dropped";
3731
+ reason: "prior_events_unreadable" | "prior_derived_dropped" | "prior_chain_broken";
3348
3732
  };
3349
3733
  /**
3350
3734
  * Re-import a source whose native log GREW into the SAME Basou session,
@@ -3363,6 +3747,42 @@ type ReimportResult = {
3363
3747
  * ABORTED (`status: "skipped"`) rather than risk dropping data on the rewrite.
3364
3748
  */
3365
3749
  declare function reimportPreservingId(paths: BasouPaths, manifest: Manifest, priorSessionId: string, freshPayload: SessionImportPayload, options?: ReimportOptions): Promise<ReimportResult>;
3750
+ /** Options for {@link rechainSessionInPlace}. */
3751
+ type RechainOptions = {
3752
+ /**
3753
+ * Compute the outcome and write nothing. The session lock is STILL taken:
3754
+ * an unlocked read could observe a concurrent in-place re-import's
3755
+ * two-file write window (events rewritten, yaml not yet) and report a
3756
+ * state a locked run would never see.
3757
+ */
3758
+ dryRun?: boolean;
3759
+ };
3760
+ /** Result of {@link rechainSessionInPlace}. */
3761
+ type RechainResult = {
3762
+ status: "rechained";
3763
+ eventCount: number;
3764
+ } | {
3765
+ status: "skipped";
3766
+ reason: "already_chained" | "empty" | "not_imported" | "tampered" | "events_unreadable" | "session_id_mismatch" | "yaml_missing" | "yaml_unreadable";
3767
+ };
3768
+ /**
3769
+ * Add the tamper-evidence hash chain, IN PLACE, to an imported session that
3770
+ * was written before chaining existed (or whose chain was legitimately never
3771
+ * computed). Event ids, order, field sets, values and key order are all
3772
+ * preserved exactly — each original line is re-emitted with only `prev_hash`
3773
+ * appended (see {@link chainRawJsonLines}); `session.yaml` is rewritten as
3774
+ * read with only `integrity` added. Nothing else changes, so cross-session
3775
+ * references (`linked_events`) survive, unlike a `--force` re-import.
3776
+ *
3777
+ * Rechaining asserts tamper-evidence FROM NOW ON; it does not retroactively
3778
+ * prove the pre-existing content was never modified before the migration.
3779
+ *
3780
+ * Refuses anything it cannot preserve exactly or that is not the closed
3781
+ * imported corpus — see {@link RechainResult} reasons. Throws (rather than
3782
+ * returning a skip) on environment-level I/O failures, mirroring
3783
+ * `verifyEventsChain`.
3784
+ */
3785
+ declare function rechainSessionInPlace(paths: BasouPaths, sessionId: string, options?: RechainOptions): Promise<RechainResult>;
3366
3786
 
3367
3787
  /**
3368
3788
  * Walk the cause chain (up to `depth` levels) looking for an Error whose
@@ -3464,4 +3884,4 @@ declare function overwriteYamlFile(filePath: string, value: unknown): Promise<vo
3464
3884
  */
3465
3885
  declare const BASOU_CORE_VERSION = "0.1.0";
3466
3886
 
3467
- export { ACTIVE_GAP_CAP_MS, type ActiveTimeBasis, type AdapterOutputEvent, type AppendBasouGitignoreResult, type AppendEventToExistingInput, type AppendEventToExistingResult, type Approval, type ApprovalApprovedEvent, type ApprovalExpiredEvent, ApprovalIdSchema, type ApprovalLocation, type ApprovalRejectedEvent, type ApprovalRequestedEvent, ApprovalSchema, type ApprovalStatus, ApprovalStatusSchema, type ArchiveTaskInput, type ArchiveTaskResult, type AttachTaskInput, type AttachUpdateTaskStatusInput, type AttachableStatus, BASOU_CORE_VERSION, type BasouPaths, CLAUDE_IMPORT_SOURCE, CODEX_IMPORT_SOURCE, type CaptureMode, ChildProcessRunner, type ClaudeTranscriptRecord, type ClaudeTranscriptToPayloadOptions, type CodexRolloutRecord, type CodexRolloutToPayloadOptions, type CommandExecutedEvent, type CommandLookup, type CreateAdHocSessionInput, type CreateAdHocSessionResult, type CreateAdHocTaskInput, type CreateManifestInput, type CreateTaskInput, type CreateTaskResult, type DayWorkStats, DecisionIdSchema, type DecisionRecordedEvent, type DecisionsRendererInput, type DecisionsRendererResult, type DeleteTaskInput, type DeleteTaskResult, type DiffResult, type EditTaskInput, type EditTaskResult, type Event, EventIdSchema, EventSchema, EventSourceSchema, FailedToFinalizeError, type FileChange, type FileChangeStatus, type FileChangedEvent, GENERATED_END, GENERATED_START, type GitSnapshot, type GitSnapshotEvent, type HandoffRendererInput, type HandoffRendererResult, ID_PREFIXES, type IdPrefix, type ImportSessionOptions, type ImportSessionResult, IsoTimestampSchema, JSON_SCHEMA_VERSION, type JsonSchemaArtifact, type LoadSessionEntriesOptions, type LoadTaskEntriesOptions, type LoadedApproval, type LockHandle, type LockScope, type Manifest, ManifestSchema, type MarkerSection, type MeasureAvailability, type NoteAddedEvent, type PrefixedId, type ProcessRunner, type ReconcileAllResult, type ReconcileAllTasksInput, type ReconcileAllTasksOptions, type ReconcileFailure, type ReconcileResult, type ReconcileTaskInput, type RefreshLinkageInput, type RefreshLinkageResult, type ReimportOptions, type ReimportResult, type ReplayOptions, type ReplayWarning, type RiskLevel, RiskLevelSchema, type RunOptions, type RunResult, STUCK_THRESHOLD_MS, type SanitizePathOptions, type SanitizeRelatedFilesResult, SchemaVersionSchema, type Session, type SessionEndedEvent, type SessionEntry, SessionIdSchema, type SessionImportPayload, SessionImportPayloadSchema, type SessionInnerImportInput, SessionInnerImportSchema, type SessionMetrics, SessionMetricsSchema, SessionSchema, type SessionSkipReason, type SessionSourceKind, SessionSourceKindSchema, type SessionStartedEvent, type SessionStatus, type SessionStatusChangedEvent, SessionStatusSchema, type SessionWorkStats, type SourceWorkStats, type StatusCount, StatusSchema, type StatusSnapshot, type SuspectReason, type Task, type TaskArchivedEvent, type TaskCreatedEvent, type TaskDeletedEvent, type TaskDocument, TaskIdSchema, type TaskLinkageRefreshedEvent, type TaskReconciledEvent, TaskSchema, type TaskSkipReason, type TaskStatus, type TaskStatusChangedEvent, TaskStatusSchema, TaskWriteAfterEventError, type TaskWriteAfterEventPhase, type TokenTotals, type UpdateAdHocTaskStatusInput, type UpdateTaskStatusInput, type UpdateTaskStatusResult, type WorkStatsInput, type WorkStatsResult, type WorkStatsTotals, WorkspaceIdSchema, type WriteTaskFileMode, acquireLock, appendBasouGitignore, appendEvent, appendEventToExistingSession, archiveTask, assertBasouRootSafe, basouPaths, buildJsonSchemas, buildStatusSnapshot, classifySuspect, claudeCodeAdapterMetadata, claudeTranscriptToImportPayload, codexRolloutToImportPayload, computeWorkStats, createAdHocSessionWithEvent, createManifest, createTaskWithEvent, deleteTask, editTask, ensureBasouDirectory, enumerateApprovals, enumerateArchivedTaskIds, enumerateSessionDirs, enumerateTaskIds, findErrorCode, getDiff, getSnapshot, importSessionFromJson, isImportDerivedSource, isLazyExpired, isValidPrefixedId, linkYamlFile, loadApproval, loadSessionEntries, loadTaskEntries, overwriteYamlFile, parseDuration, parseMarkers, prefixedUlid, readAllEvents, readManifest, readMarkdownFile, readSessionYaml, readStatus, readTaskFile, readTaskFileWithArchiveFallback, readYamlFile, reconcileAllTasks, reconcileTask, refreshTaskLinkedSessions, reimportPreservingId, renderDecisions, renderHandoff, renderWithMarkers, replayEvents, resolveClaudeCodeCommand, resolveRepositoryRoot, resolveSessionId, resolveTaskId, sanitizePath, sanitizeRelatedFiles, sanitizeWorkingDirectory, serializeJsonSchema, sessionWorkStatsFromEvents, summarizeAdapterOutput, tryRemoteUrl, ulid, updateTaskStatusWithEvent, writeEventsBulk, writeManifest, writeMarkdownFile, writeStatus, writeTaskFile, writeYamlFile };
3887
+ export { ACTIVE_GAP_CAP_MS, type ActiveTimeBasis, type AdapterOutputEvent, type AppendBasouGitignoreResult, type AppendEventToExistingInput, type AppendEventToExistingResult, type Approval, type ApprovalApprovedEvent, type ApprovalExpiredEvent, ApprovalIdSchema, type ApprovalLocation, type ApprovalRejectedEvent, type ApprovalRequestedEvent, ApprovalSchema, type ApprovalStatus, ApprovalStatusSchema, type ArchiveTaskInput, type ArchiveTaskResult, type AttachTaskInput, type AttachUpdateTaskStatusInput, type AttachableStatus, BASOU_CORE_VERSION, type BasouPaths, type BulkChainResult, CLAUDE_IMPORT_SOURCE, CODEX_IMPORT_SOURCE, type CaptureMode, type ChainBreakReason, type ChainTailState, type ChainVerdict, type ChainVerdictStatus, type ChainedEvents, ChildProcessRunner, type ClaudeTranscriptRecord, type ClaudeTranscriptToPayloadOptions, type CodexRolloutRecord, type CodexRolloutToPayloadOptions, type CommandExecutedEvent, type CommandLookup, type CreateAdHocSessionInput, type CreateAdHocSessionResult, type CreateAdHocTaskInput, type CreateManifestInput, type CreateTaskInput, type CreateTaskResult, type DayWorkStats, DecisionIdSchema, type DecisionRecordedEvent, type DecisionsRendererInput, type DecisionsRendererResult, type DeleteTaskInput, type DeleteTaskResult, type DiffResult, type EditTaskInput, type EditTaskResult, type Event, EventIdSchema, EventSchema, EventSourceSchema, FailedToFinalizeError, type FileChange, type FileChangeStatus, type FileChangedEvent, GENERATED_END, GENERATED_START, type GitSnapshot, type GitSnapshotEvent, type HandoffRendererInput, type HandoffRendererResult, ID_PREFIXES, type IdPrefix, type ImportSessionOptions, type ImportSessionResult, IsoTimestampSchema, JSON_SCHEMA_VERSION, type JsonSchemaArtifact, type LoadSessionEntriesOptions, type LoadTaskEntriesOptions, type LoadedApproval, type LockHandle, type LockScope, type Manifest, ManifestSchema, type MarkerSection, type MeasureAvailability, type NoteAddedEvent, type PrefixedId, type ProcessRunner, type RechainOptions, type RechainResult, type ReconcileAllResult, type ReconcileAllTasksInput, type ReconcileAllTasksOptions, type ReconcileFailure, type ReconcileResult, type ReconcileTaskInput, type RefreshLinkageInput, type RefreshLinkageResult, type ReimportOptions, type ReimportResult, type ReplayOptions, type ReplayWarning, type RiskLevel, RiskLevelSchema, type RunOptions, type RunResult, STUCK_THRESHOLD_MS, type SanitizePathOptions, type SanitizeRelatedFilesResult, SchemaVersionSchema, type Session, type SessionEndedEvent, type SessionEntry, SessionIdSchema, type SessionImportPayload, SessionImportPayloadSchema, type SessionInnerImportInput, SessionInnerImportSchema, type SessionIntegrity, SessionIntegritySchema, type SessionMetrics, SessionMetricsSchema, SessionSchema, type SessionSkipReason, type SessionSourceKind, SessionSourceKindSchema, type SessionStartedEvent, type SessionStatus, type SessionStatusChangedEvent, SessionStatusSchema, type SessionWorkStats, type SourceWorkStats, type StatusCount, StatusSchema, type StatusSnapshot, type SuspectReason, type Task, type TaskArchivedEvent, type TaskCreatedEvent, type TaskDeletedEvent, type TaskDocument, TaskIdSchema, type TaskLinkageRefreshedEvent, type TaskReconciledEvent, TaskSchema, type TaskSkipReason, type TaskStatus, type TaskStatusChangedEvent, TaskStatusSchema, TaskWriteAfterEventError, type TaskWriteAfterEventPhase, type TokenTotals, type UpdateAdHocTaskStatusInput, type UpdateTaskStatusInput, type UpdateTaskStatusResult, type WorkStatsInput, type WorkStatsResult, type WorkStatsTotals, WorkspaceIdSchema, type WriteEventsBulkOptions, type WriteTaskFileMode, acquireLock, appendBasouGitignore, appendChainedEvent, appendChainedEventLocked, appendEvent, appendEventToExistingSession, archiveTask, assertBasouRootSafe, basouPaths, buildJsonSchemas, buildStatusSnapshot, chainEvents, chainRawJsonLines, classifySuspect, claudeCodeAdapterMetadata, claudeTranscriptToImportPayload, codexRolloutToImportPayload, computeWorkStats, createAdHocSessionWithEvent, createManifest, createTaskWithEvent, deleteTask, editTask, ensureBasouDirectory, enumerateApprovals, enumerateArchivedTaskIds, enumerateSessionDirs, enumerateTaskIds, finalizeSessionYaml, findErrorCode, genesisHash, getDiff, getSnapshot, importSessionFromJson, inspectChainTail, isImportDerivedSource, isLazyExpired, isValidPrefixedId, lineHash, linkYamlFile, loadApproval, loadSessionEntries, loadTaskEntries, overwriteYamlFile, parseDuration, parseMarkers, prefixedUlid, readAllEvents, readManifest, readMarkdownFile, readSessionYaml, readStatus, readTaskFile, readTaskFileWithArchiveFallback, readYamlFile, rechainSessionInPlace, reconcileAllTasks, reconcileTask, refreshTaskLinkedSessions, reimportPreservingId, renderDecisions, renderHandoff, renderWithMarkers, replayEvents, resolveClaudeCodeCommand, resolveRepositoryRoot, resolveSessionId, resolveTaskId, sanitizePath, sanitizeRelatedFiles, sanitizeWorkingDirectory, serializeEventLine, serializeJsonSchema, sessionWorkStatsFromEvents, summarizeAdapterOutput, tryRemoteUrl, ulid, updateTaskStatusWithEvent, verifyEventsChain, writeEventsBulk, writeManifest, writeMarkdownFile, writeStatus, writeTaskFile, writeYamlFile };