@tenphi/akno-protocol 0.4.0 → 0.5.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.
@@ -40,10 +40,10 @@ export declare const RetainedTime: z.ZodObject<{
40
40
  due: "due";
41
41
  }>;
42
42
  status: z.ZodEnum<{
43
+ tentative: "tentative";
43
44
  planned: "planned";
44
45
  scheduled: "scheduled";
45
46
  actual: "actual";
46
- tentative: "tentative";
47
47
  }>;
48
48
  timezone: z.ZodOptional<z.ZodString>;
49
49
  mentioned_at: z.ZodOptional<z.ZodString>;
@@ -95,10 +95,10 @@ export declare const ProvidedRetainCandidate: z.ZodObject<{
95
95
  kind: z.ZodEnum<{
96
96
  question: "question";
97
97
  claim: "claim";
98
- event: "event";
99
- plan: "plan";
100
98
  decision: "decision";
101
99
  preference: "preference";
100
+ plan: "plan";
101
+ event: "event";
102
102
  }>;
103
103
  text: z.ZodString;
104
104
  subject: z.ZodString;
@@ -126,20 +126,20 @@ export declare const ProvidedRetainCandidate: z.ZodObject<{
126
126
  discourse: z.ZodObject<{
127
127
  commitment: z.ZodEnum<{
128
128
  none: "none";
129
- tentative: "tentative";
130
129
  asserted: "asserted";
130
+ tentative: "tentative";
131
131
  hypothetical: "hypothetical";
132
132
  counterfactual: "counterfactual";
133
133
  }>;
134
134
  disposition: z.ZodEnum<{
135
- superseded: "superseded";
136
- rejected: "rejected";
137
- completed: "completed";
138
- proposed: "proposed";
139
135
  active: "active";
136
+ proposed: "proposed";
140
137
  accepted: "accepted";
138
+ rejected: "rejected";
141
139
  resolved: "resolved";
142
140
  cancelled: "cancelled";
141
+ completed: "completed";
142
+ superseded: "superseded";
143
143
  }>;
144
144
  }, z.core.$strip>;
145
145
  epistemic: z.ZodObject<{
@@ -210,10 +210,10 @@ export declare const ProvidedRetainCandidate: z.ZodObject<{
210
210
  due: "due";
211
211
  }>;
212
212
  status: z.ZodEnum<{
213
+ tentative: "tentative";
213
214
  planned: "planned";
214
215
  scheduled: "scheduled";
215
216
  actual: "actual";
216
- tentative: "tentative";
217
217
  }>;
218
218
  timezone: z.ZodOptional<z.ZodString>;
219
219
  mentioned_at: z.ZodOptional<z.ZodString>;
@@ -237,10 +237,10 @@ export declare const ProvidedRetainCandidate: z.ZodObject<{
237
237
  until: z.ZodOptional<z.ZodString>;
238
238
  }, z.core.$strip>>;
239
239
  }, z.core.$strip>>;
240
- destination: z.ZodObject<{
240
+ destination: z.ZodOptional<z.ZodObject<{
241
241
  slug: z.ZodString;
242
242
  section: z.ZodOptional<z.ZodString>;
243
- }, z.core.$strip>;
243
+ }, z.core.$strip>>;
244
244
  }, z.core.$strip>;
245
245
  export type ProvidedRetainCandidate = z.infer<typeof ProvidedRetainCandidate>;
246
246
  export declare const RetainSourceItem: z.ZodObject<{
@@ -285,18 +285,21 @@ export declare const RetainUpsertSource: z.ZodObject<{
285
285
  mentioned_at: z.ZodOptional<z.ZodString>;
286
286
  }, z.core.$strip>>;
287
287
  }, z.core.$strip>]>;
288
- retention: z.ZodObject<{
288
+ retention: z.ZodUnion<readonly [z.ZodObject<{
289
289
  mode: z.ZodLiteral<"provided">;
290
- placement: z.ZodLiteral<"exact">;
290
+ placement: z.ZodEnum<{
291
+ exact: "exact";
292
+ automatic: "automatic";
293
+ }>;
291
294
  candidates: z.ZodArray<z.ZodObject<{
292
295
  candidate_id: z.ZodString;
293
296
  kind: z.ZodEnum<{
294
297
  question: "question";
295
298
  claim: "claim";
296
- event: "event";
297
- plan: "plan";
298
299
  decision: "decision";
299
300
  preference: "preference";
301
+ plan: "plan";
302
+ event: "event";
300
303
  }>;
301
304
  text: z.ZodString;
302
305
  subject: z.ZodString;
@@ -324,20 +327,20 @@ export declare const RetainUpsertSource: z.ZodObject<{
324
327
  discourse: z.ZodObject<{
325
328
  commitment: z.ZodEnum<{
326
329
  none: "none";
327
- tentative: "tentative";
328
330
  asserted: "asserted";
331
+ tentative: "tentative";
329
332
  hypothetical: "hypothetical";
330
333
  counterfactual: "counterfactual";
331
334
  }>;
332
335
  disposition: z.ZodEnum<{
333
- superseded: "superseded";
334
- rejected: "rejected";
335
- completed: "completed";
336
- proposed: "proposed";
337
336
  active: "active";
337
+ proposed: "proposed";
338
338
  accepted: "accepted";
339
+ rejected: "rejected";
339
340
  resolved: "resolved";
340
341
  cancelled: "cancelled";
342
+ completed: "completed";
343
+ superseded: "superseded";
341
344
  }>;
342
345
  }, z.core.$strip>;
343
346
  epistemic: z.ZodObject<{
@@ -408,10 +411,10 @@ export declare const RetainUpsertSource: z.ZodObject<{
408
411
  due: "due";
409
412
  }>;
410
413
  status: z.ZodEnum<{
414
+ tentative: "tentative";
411
415
  planned: "planned";
412
416
  scheduled: "scheduled";
413
417
  actual: "actual";
414
- tentative: "tentative";
415
418
  }>;
416
419
  timezone: z.ZodOptional<z.ZodString>;
417
420
  mentioned_at: z.ZodOptional<z.ZodString>;
@@ -435,12 +438,15 @@ export declare const RetainUpsertSource: z.ZodObject<{
435
438
  until: z.ZodOptional<z.ZodString>;
436
439
  }, z.core.$strip>>;
437
440
  }, z.core.$strip>>;
438
- destination: z.ZodObject<{
441
+ destination: z.ZodOptional<z.ZodObject<{
439
442
  slug: z.ZodString;
440
443
  section: z.ZodOptional<z.ZodString>;
441
- }, z.core.$strip>;
444
+ }, z.core.$strip>>;
442
445
  }, z.core.$strip>>;
443
- }, z.core.$strip>;
446
+ }, z.core.$strip>, z.ZodObject<{
447
+ mode: z.ZodLiteral<"extract">;
448
+ mission: z.ZodOptional<z.ZodString>;
449
+ }, z.core.$strip>]>;
444
450
  source_id: z.ZodString;
445
451
  revision: z.ZodString;
446
452
  }, z.core.$strip>;
@@ -490,18 +496,21 @@ export declare const RetainInput: z.ZodObject<{
490
496
  mentioned_at: z.ZodOptional<z.ZodString>;
491
497
  }, z.core.$strip>>;
492
498
  }, z.core.$strip>]>;
493
- retention: z.ZodObject<{
499
+ retention: z.ZodUnion<readonly [z.ZodObject<{
494
500
  mode: z.ZodLiteral<"provided">;
495
- placement: z.ZodLiteral<"exact">;
501
+ placement: z.ZodEnum<{
502
+ exact: "exact";
503
+ automatic: "automatic";
504
+ }>;
496
505
  candidates: z.ZodArray<z.ZodObject<{
497
506
  candidate_id: z.ZodString;
498
507
  kind: z.ZodEnum<{
499
508
  question: "question";
500
509
  claim: "claim";
501
- event: "event";
502
- plan: "plan";
503
510
  decision: "decision";
504
511
  preference: "preference";
512
+ plan: "plan";
513
+ event: "event";
505
514
  }>;
506
515
  text: z.ZodString;
507
516
  subject: z.ZodString;
@@ -529,20 +538,20 @@ export declare const RetainInput: z.ZodObject<{
529
538
  discourse: z.ZodObject<{
530
539
  commitment: z.ZodEnum<{
531
540
  none: "none";
532
- tentative: "tentative";
533
541
  asserted: "asserted";
542
+ tentative: "tentative";
534
543
  hypothetical: "hypothetical";
535
544
  counterfactual: "counterfactual";
536
545
  }>;
537
546
  disposition: z.ZodEnum<{
538
- superseded: "superseded";
539
- rejected: "rejected";
540
- completed: "completed";
541
- proposed: "proposed";
542
547
  active: "active";
548
+ proposed: "proposed";
543
549
  accepted: "accepted";
550
+ rejected: "rejected";
544
551
  resolved: "resolved";
545
552
  cancelled: "cancelled";
553
+ completed: "completed";
554
+ superseded: "superseded";
546
555
  }>;
547
556
  }, z.core.$strip>;
548
557
  epistemic: z.ZodObject<{
@@ -613,10 +622,10 @@ export declare const RetainInput: z.ZodObject<{
613
622
  due: "due";
614
623
  }>;
615
624
  status: z.ZodEnum<{
625
+ tentative: "tentative";
616
626
  planned: "planned";
617
627
  scheduled: "scheduled";
618
628
  actual: "actual";
619
- tentative: "tentative";
620
629
  }>;
621
630
  timezone: z.ZodOptional<z.ZodString>;
622
631
  mentioned_at: z.ZodOptional<z.ZodString>;
@@ -640,12 +649,15 @@ export declare const RetainInput: z.ZodObject<{
640
649
  until: z.ZodOptional<z.ZodString>;
641
650
  }, z.core.$strip>>;
642
651
  }, z.core.$strip>>;
643
- destination: z.ZodObject<{
652
+ destination: z.ZodOptional<z.ZodObject<{
644
653
  slug: z.ZodString;
645
654
  section: z.ZodOptional<z.ZodString>;
646
- }, z.core.$strip>;
655
+ }, z.core.$strip>>;
647
656
  }, z.core.$strip>>;
648
- }, z.core.$strip>;
657
+ }, z.core.$strip>, z.ZodObject<{
658
+ mode: z.ZodLiteral<"extract">;
659
+ mission: z.ZodOptional<z.ZodString>;
660
+ }, z.core.$strip>]>;
649
661
  source_id: z.ZodString;
650
662
  revision: z.ZodString;
651
663
  }, z.core.$strip>, z.ZodObject<{
@@ -665,6 +677,30 @@ export declare const RetainInput: z.ZodObject<{
665
677
  dry_run: z.ZodOptional<z.ZodBoolean>;
666
678
  }, z.core.$strip>;
667
679
  export type RetainInput = z.infer<typeof RetainInput>;
680
+ export declare const RetainHoldReason: z.ZodEnum<{
681
+ conflict: "conflict";
682
+ routing_uncertain: "routing_uncertain";
683
+ no_writable_destination: "no_writable_destination";
684
+ source_unavailable: "source_unavailable";
685
+ discourse_uncertain: "discourse_uncertain";
686
+ context_too_large: "context_too_large";
687
+ time_unresolved: "time_unresolved";
688
+ noncanonical_without_context: "noncanonical_without_context";
689
+ support_limit: "support_limit";
690
+ placement_degraded: "placement_degraded";
691
+ apply_failed: "apply_failed";
692
+ validation_failed: "validation_failed";
693
+ }>;
694
+ export type RetainHoldReason = z.infer<typeof RetainHoldReason>;
695
+ /** Content-free receipt for one automatic-retention model request. */
696
+ export declare const RetainModelCallReceipt: z.ZodObject<{
697
+ model: z.ZodString;
698
+ latency_ms: z.ZodNumber;
699
+ input_tokens: z.ZodNullable<z.ZodNumber>;
700
+ output_tokens: z.ZodNullable<z.ZodNumber>;
701
+ total_tokens: z.ZodNullable<z.ZodNumber>;
702
+ }, z.core.$strip>;
703
+ export type RetainModelCallReceipt = z.infer<typeof RetainModelCallReceipt>;
668
704
  export declare const RetainCandidateResult: z.ZodObject<{
669
705
  candidate_id: z.ZodString;
670
706
  outcome: z.ZodEnum<{
@@ -677,6 +713,20 @@ export declare const RetainCandidateResult: z.ZodObject<{
677
713
  }>;
678
714
  memory_id: z.ZodOptional<z.ZodString>;
679
715
  slug: z.ZodOptional<z.ZodString>;
716
+ reason_code: z.ZodOptional<z.ZodEnum<{
717
+ conflict: "conflict";
718
+ routing_uncertain: "routing_uncertain";
719
+ no_writable_destination: "no_writable_destination";
720
+ source_unavailable: "source_unavailable";
721
+ discourse_uncertain: "discourse_uncertain";
722
+ context_too_large: "context_too_large";
723
+ time_unresolved: "time_unresolved";
724
+ noncanonical_without_context: "noncanonical_without_context";
725
+ support_limit: "support_limit";
726
+ placement_degraded: "placement_degraded";
727
+ apply_failed: "apply_failed";
728
+ validation_failed: "validation_failed";
729
+ }>>;
680
730
  reason: z.ZodOptional<z.ZodString>;
681
731
  }, z.core.$strip>;
682
732
  export type RetainCandidateResult = z.infer<typeof RetainCandidateResult>;
@@ -703,8 +753,90 @@ export declare const RetainSourceResult: z.ZodObject<{
703
753
  }>;
704
754
  memory_id: z.ZodOptional<z.ZodString>;
705
755
  slug: z.ZodOptional<z.ZodString>;
756
+ reason_code: z.ZodOptional<z.ZodEnum<{
757
+ conflict: "conflict";
758
+ routing_uncertain: "routing_uncertain";
759
+ no_writable_destination: "no_writable_destination";
760
+ source_unavailable: "source_unavailable";
761
+ discourse_uncertain: "discourse_uncertain";
762
+ context_too_large: "context_too_large";
763
+ time_unresolved: "time_unresolved";
764
+ noncanonical_without_context: "noncanonical_without_context";
765
+ support_limit: "support_limit";
766
+ placement_degraded: "placement_degraded";
767
+ apply_failed: "apply_failed";
768
+ validation_failed: "validation_failed";
769
+ }>>;
706
770
  reason: z.ZodOptional<z.ZodString>;
707
771
  }, z.core.$strip>>;
772
+ reason_code: z.ZodOptional<z.ZodEnum<{
773
+ conflict: "conflict";
774
+ routing_uncertain: "routing_uncertain";
775
+ no_writable_destination: "no_writable_destination";
776
+ source_unavailable: "source_unavailable";
777
+ discourse_uncertain: "discourse_uncertain";
778
+ context_too_large: "context_too_large";
779
+ time_unresolved: "time_unresolved";
780
+ noncanonical_without_context: "noncanonical_without_context";
781
+ support_limit: "support_limit";
782
+ placement_degraded: "placement_degraded";
783
+ apply_failed: "apply_failed";
784
+ validation_failed: "validation_failed";
785
+ }>>;
786
+ status: z.ZodOptional<z.ZodEnum<{
787
+ ok: "ok";
788
+ empty: "empty";
789
+ degraded: "degraded";
790
+ unavailable: "unavailable";
791
+ }>>;
792
+ degraded: z.ZodOptional<z.ZodArray<z.ZodEnum<{
793
+ no_embedding_model: "no_embedding_model";
794
+ no_reranker: "no_reranker";
795
+ no_derive_model: "no_derive_model";
796
+ no_expansion_model: "no_expansion_model";
797
+ embedding_failed: "embedding_failed";
798
+ rerank_failed: "rerank_failed";
799
+ derive_failed: "derive_failed";
800
+ retain_verification_failed: "retain_verification_failed";
801
+ retain_apply_failed: "retain_apply_failed";
802
+ expansion_failed: "expansion_failed";
803
+ no_vector_index: "no_vector_index";
804
+ partial_index: "partial_index";
805
+ no_document_text: "no_document_text";
806
+ document_source_missing: "document_source_missing";
807
+ no_graph_index: "no_graph_index";
808
+ no_entity_index: "no_entity_index";
809
+ entity_resolution_failed: "entity_resolution_failed";
810
+ partial_graph_index: "partial_graph_index";
811
+ graph_traversal_limited: "graph_traversal_limited";
812
+ no_answer_model: "no_answer_model";
813
+ answer_failed: "answer_failed";
814
+ answer_verification_failed: "answer_verification_failed";
815
+ answer_truncated: "answer_truncated";
816
+ }>>>;
817
+ model_usage: z.ZodOptional<z.ZodObject<{
818
+ extraction: z.ZodNullable<z.ZodObject<{
819
+ model: z.ZodString;
820
+ latency_ms: z.ZodNumber;
821
+ input_tokens: z.ZodNullable<z.ZodNumber>;
822
+ output_tokens: z.ZodNullable<z.ZodNumber>;
823
+ total_tokens: z.ZodNullable<z.ZodNumber>;
824
+ }, z.core.$strip>>;
825
+ verification: z.ZodNullable<z.ZodObject<{
826
+ model: z.ZodString;
827
+ latency_ms: z.ZodNumber;
828
+ input_tokens: z.ZodNullable<z.ZodNumber>;
829
+ output_tokens: z.ZodNullable<z.ZodNumber>;
830
+ total_tokens: z.ZodNullable<z.ZodNumber>;
831
+ }, z.core.$strip>>;
832
+ placement: z.ZodArray<z.ZodObject<{
833
+ model: z.ZodString;
834
+ latency_ms: z.ZodNumber;
835
+ input_tokens: z.ZodNullable<z.ZodNumber>;
836
+ output_tokens: z.ZodNullable<z.ZodNumber>;
837
+ total_tokens: z.ZodNullable<z.ZodNumber>;
838
+ }, z.core.$strip>>;
839
+ }, z.core.$strip>>;
708
840
  note: z.ZodOptional<z.ZodString>;
709
841
  }, z.core.$strip>;
710
842
  export type RetainSourceResult = z.infer<typeof RetainSourceResult>;
@@ -723,6 +855,8 @@ export declare const RetainOutput: z.ZodObject<{
723
855
  embedding_failed: "embedding_failed";
724
856
  rerank_failed: "rerank_failed";
725
857
  derive_failed: "derive_failed";
858
+ retain_verification_failed: "retain_verification_failed";
859
+ retain_apply_failed: "retain_apply_failed";
726
860
  expansion_failed: "expansion_failed";
727
861
  no_vector_index: "no_vector_index";
728
862
  partial_index: "partial_index";
@@ -767,8 +901,90 @@ export declare const RetainOutput: z.ZodObject<{
767
901
  }>;
768
902
  memory_id: z.ZodOptional<z.ZodString>;
769
903
  slug: z.ZodOptional<z.ZodString>;
904
+ reason_code: z.ZodOptional<z.ZodEnum<{
905
+ conflict: "conflict";
906
+ routing_uncertain: "routing_uncertain";
907
+ no_writable_destination: "no_writable_destination";
908
+ source_unavailable: "source_unavailable";
909
+ discourse_uncertain: "discourse_uncertain";
910
+ context_too_large: "context_too_large";
911
+ time_unresolved: "time_unresolved";
912
+ noncanonical_without_context: "noncanonical_without_context";
913
+ support_limit: "support_limit";
914
+ placement_degraded: "placement_degraded";
915
+ apply_failed: "apply_failed";
916
+ validation_failed: "validation_failed";
917
+ }>>;
770
918
  reason: z.ZodOptional<z.ZodString>;
771
919
  }, z.core.$strip>>;
920
+ reason_code: z.ZodOptional<z.ZodEnum<{
921
+ conflict: "conflict";
922
+ routing_uncertain: "routing_uncertain";
923
+ no_writable_destination: "no_writable_destination";
924
+ source_unavailable: "source_unavailable";
925
+ discourse_uncertain: "discourse_uncertain";
926
+ context_too_large: "context_too_large";
927
+ time_unresolved: "time_unresolved";
928
+ noncanonical_without_context: "noncanonical_without_context";
929
+ support_limit: "support_limit";
930
+ placement_degraded: "placement_degraded";
931
+ apply_failed: "apply_failed";
932
+ validation_failed: "validation_failed";
933
+ }>>;
934
+ status: z.ZodOptional<z.ZodEnum<{
935
+ ok: "ok";
936
+ empty: "empty";
937
+ degraded: "degraded";
938
+ unavailable: "unavailable";
939
+ }>>;
940
+ degraded: z.ZodOptional<z.ZodArray<z.ZodEnum<{
941
+ no_embedding_model: "no_embedding_model";
942
+ no_reranker: "no_reranker";
943
+ no_derive_model: "no_derive_model";
944
+ no_expansion_model: "no_expansion_model";
945
+ embedding_failed: "embedding_failed";
946
+ rerank_failed: "rerank_failed";
947
+ derive_failed: "derive_failed";
948
+ retain_verification_failed: "retain_verification_failed";
949
+ retain_apply_failed: "retain_apply_failed";
950
+ expansion_failed: "expansion_failed";
951
+ no_vector_index: "no_vector_index";
952
+ partial_index: "partial_index";
953
+ no_document_text: "no_document_text";
954
+ document_source_missing: "document_source_missing";
955
+ no_graph_index: "no_graph_index";
956
+ no_entity_index: "no_entity_index";
957
+ entity_resolution_failed: "entity_resolution_failed";
958
+ partial_graph_index: "partial_graph_index";
959
+ graph_traversal_limited: "graph_traversal_limited";
960
+ no_answer_model: "no_answer_model";
961
+ answer_failed: "answer_failed";
962
+ answer_verification_failed: "answer_verification_failed";
963
+ answer_truncated: "answer_truncated";
964
+ }>>>;
965
+ model_usage: z.ZodOptional<z.ZodObject<{
966
+ extraction: z.ZodNullable<z.ZodObject<{
967
+ model: z.ZodString;
968
+ latency_ms: z.ZodNumber;
969
+ input_tokens: z.ZodNullable<z.ZodNumber>;
970
+ output_tokens: z.ZodNullable<z.ZodNumber>;
971
+ total_tokens: z.ZodNullable<z.ZodNumber>;
972
+ }, z.core.$strip>>;
973
+ verification: z.ZodNullable<z.ZodObject<{
974
+ model: z.ZodString;
975
+ latency_ms: z.ZodNumber;
976
+ input_tokens: z.ZodNullable<z.ZodNumber>;
977
+ output_tokens: z.ZodNullable<z.ZodNumber>;
978
+ total_tokens: z.ZodNullable<z.ZodNumber>;
979
+ }, z.core.$strip>>;
980
+ placement: z.ZodArray<z.ZodObject<{
981
+ model: z.ZodString;
982
+ latency_ms: z.ZodNumber;
983
+ input_tokens: z.ZodNullable<z.ZodNumber>;
984
+ output_tokens: z.ZodNullable<z.ZodNumber>;
985
+ total_tokens: z.ZodNullable<z.ZodNumber>;
986
+ }, z.core.$strip>>;
987
+ }, z.core.$strip>>;
772
988
  note: z.ZodOptional<z.ZodString>;
773
989
  }, z.core.$strip>>;
774
990
  }, z.core.$strip>;
@@ -1 +1 @@
1
- {"version":3,"file":"retain.d.ts","sourceRoot":"","sources":["../../src/ops/retain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,gBAAgB;;;;;EAAuD,CAAC;AACrF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,eAAO,MAAM,gBAAgB;;;iBAG3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,eAAO,MAAM,iBAAiB;;;;;;;;;;mBAK5B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4ErB,CAAC;AACL,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAgCxD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;iBAQ3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,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CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { ResultEnvelope } from "../common.js";
2
+ import { DegradedReason, ResultEnvelope } from "../common.js";
3
3
  const RetainRef = z.string().min(1).max(300);
4
4
  export const RetainSourceRole = z.enum(['user', 'assistant', 'external', 'unknown']);
5
5
  export const RetainSourceSpan = z.object({
@@ -165,7 +165,13 @@ export const ProvidedRetainCandidate = z
165
165
  discourse_frame: z.array(RetainSourceSpan).min(1).max(16),
166
166
  relations: z.array(RetainedRelation).max(8).optional(),
167
167
  time: RetainedTime.optional(),
168
- destination: z.object({ slug: z.string().min(1), section: z.string().min(1).max(100).optional() }),
168
+ /**
169
+ * Required by `provided + exact`; optional as a bounded taxonomy suggestion for automatic
170
+ * placement. Extraction never grants this suggestion write authority.
171
+ */
172
+ destination: z
173
+ .object({ slug: z.string().min(1), section: z.string().min(1).max(100).optional() })
174
+ .optional(),
169
175
  })
170
176
  .superRefine((candidate, ctx) => {
171
177
  const allowed = {
@@ -228,20 +234,37 @@ export const RetainUpsertSource = z
228
234
  z.object({ text: z.string().min(1).max(500_000) }),
229
235
  z.object({ items: z.array(RetainSourceItem).min(1).max(500) }),
230
236
  ]),
231
- retention: z.object({
232
- mode: z.literal('provided'),
233
- placement: z.literal('exact'),
234
- candidates: z.array(ProvidedRetainCandidate).min(1).max(50),
235
- }),
237
+ retention: z.union([
238
+ z.object({
239
+ mode: z.literal('provided'),
240
+ placement: z.enum(['exact', 'automatic']),
241
+ candidates: z.array(ProvidedRetainCandidate).min(1).max(50),
242
+ }),
243
+ z.object({
244
+ mode: z.literal('extract'),
245
+ /** Additive source-specific emphasis; it never replaces the fixed retention policy. */
246
+ mission: z.string().max(2000).optional(),
247
+ }),
248
+ ]),
236
249
  })
237
250
  .superRefine((source, ctx) => {
238
- const candidateIds = source.retention.candidates.map((candidate) => candidate.candidate_id);
239
- if (new Set(candidateIds).size !== candidateIds.length) {
240
- ctx.addIssue({
241
- code: 'custom',
242
- path: ['retention', 'candidates'],
243
- message: 'candidate ids must be unique within one source revision',
244
- });
251
+ if (source.retention.mode === 'provided') {
252
+ const candidateIds = source.retention.candidates.map((candidate) => candidate.candidate_id);
253
+ if (new Set(candidateIds).size !== candidateIds.length) {
254
+ ctx.addIssue({
255
+ code: 'custom',
256
+ path: ['retention', 'candidates'],
257
+ message: 'candidate ids must be unique within one source revision',
258
+ });
259
+ }
260
+ if (source.retention.placement === 'exact' &&
261
+ source.retention.candidates.some((candidate) => candidate.destination === undefined)) {
262
+ ctx.addIssue({
263
+ code: 'custom',
264
+ path: ['retention', 'candidates'],
265
+ message: 'provided exact candidates require a destination',
266
+ });
267
+ }
245
268
  }
246
269
  if ('items' in source.input) {
247
270
  const itemIds = source.input.items.map((item) => item.item_id);
@@ -270,11 +293,34 @@ export const RetainInput = z.object({
270
293
  .max(20),
271
294
  dry_run: z.boolean().optional(),
272
295
  });
296
+ export const RetainHoldReason = z.enum([
297
+ 'source_unavailable',
298
+ 'discourse_uncertain',
299
+ 'context_too_large',
300
+ 'time_unresolved',
301
+ 'noncanonical_without_context',
302
+ 'no_writable_destination',
303
+ 'routing_uncertain',
304
+ 'conflict',
305
+ 'support_limit',
306
+ 'placement_degraded',
307
+ 'apply_failed',
308
+ 'validation_failed',
309
+ ]);
310
+ /** Content-free receipt for one automatic-retention model request. */
311
+ export const RetainModelCallReceipt = z.object({
312
+ model: z.string(),
313
+ latency_ms: z.number().nonnegative(),
314
+ input_tokens: z.number().int().nonnegative().nullable(),
315
+ output_tokens: z.number().int().nonnegative().nullable(),
316
+ total_tokens: z.number().int().nonnegative().nullable(),
317
+ });
273
318
  export const RetainCandidateResult = z.object({
274
319
  candidate_id: z.string(),
275
320
  outcome: z.enum(['written', 'duplicate', 'support_added', 'retracted', 'held', 'not_found']),
276
321
  memory_id: z.string().optional(),
277
322
  slug: z.string().optional(),
323
+ reason_code: RetainHoldReason.optional(),
278
324
  reason: z.string().optional(),
279
325
  });
280
326
  export const RetainSourceResult = z.object({
@@ -283,6 +329,17 @@ export const RetainSourceResult = z.object({
283
329
  outcome: z.enum(['ok', 'replayed', 'noop', 'held', 'revision_conflict']),
284
330
  change_id: z.string().optional(),
285
331
  candidates: z.array(RetainCandidateResult),
332
+ /** Source-level hold when no safe candidate boundary exists yet. */
333
+ reason_code: RetainHoldReason.optional(),
334
+ status: z.enum(['ok', 'empty', 'degraded', 'unavailable']).optional(),
335
+ degraded: z.array(DegradedReason).optional(),
336
+ model_usage: z
337
+ .object({
338
+ extraction: RetainModelCallReceipt.nullable(),
339
+ verification: RetainModelCallReceipt.nullable(),
340
+ placement: z.array(RetainModelCallReceipt),
341
+ })
342
+ .optional(),
286
343
  note: z.string().optional(),
287
344
  });
288
345
  export const RetainOutput = ResultEnvelope.extend({