1#![allow(missing_docs)]
18
19use serde::{Deserialize, Serialize};
20
21pub type WireUuid = [u8; 16];
23pub type WireSessionId = u64;
25pub type WireMemoryId = u128;
27
28#[derive(
34 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
35)]
36#[repr(u8)]
37pub enum MemoryKindWire {
38 Episodic = 0,
39 Semantic = 1,
40 Consolidated = 2,
41}
42
43#[derive(
45 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
46)]
47#[repr(u8)]
48pub enum EdgeKindWire {
49 Caused = 0,
50 FollowedBy = 1,
51 DerivedFrom = 2,
52 SimilarTo = 3,
53 Contradicts = 4,
54 Supports = 5,
55 References = 6,
56 PartOf = 7,
57}
58
59#[derive(
61 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
62)]
63#[repr(u8)]
64pub enum ForgetMode {
65 Soft = 0,
66 Hard = 1,
67}
68
69#[derive(
71 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
72)]
73#[repr(u8)]
74pub enum StageKind {
75 AutoEdge = 0,
76 TemporalEdge = 1,
77 Extractor = 2,
78 Hype = 3,
79}
80
81#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
87pub struct HelloCapabilities {
88 pub streaming: bool,
89 pub compression_zstd: bool,
90 pub server_push: bool,
91}
92
93#[derive(
95 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
96)]
97#[repr(u8)]
98pub enum AuthMethod {
99 Token = 0,
100 Mtls = 1,
101}
102
103#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
106pub enum AuthCredentials {
107 Token(Vec<u8>),
108 Mtls(MtlsClaim),
109}
110
111#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
113pub struct MtlsClaim {
114 #[serde(with = "serde_bytes")]
115 pub cert_fingerprint: [u8; 32],
116 pub asserted_subject: String,
117}
118
119#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
121pub struct SpacePermissions {
122 pub can_encode: bool,
123 pub can_recall: bool,
124 pub can_plan: bool,
125 pub can_reason: bool,
126 pub can_forget: bool,
127 pub can_admin: bool,
128 pub can_act_as: bool,
133}
134
135#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
137pub struct ServerFeatures {
138 pub max_payload_size: u32,
139 pub max_concurrent_streams: u32,
140 pub idle_timeout_seconds: u32,
141 pub auth_methods: Vec<AuthMethod>,
142}
143
144#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
146pub struct HelloPayload {
147 pub client_id: String,
148 pub supported_versions: Vec<u8>,
149 pub capabilities: HelloCapabilities,
150 #[serde(with = "serde_bytes")]
152 pub client_connection_token: Option<[u8; 32]>,
153}
154
155#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
157pub struct WelcomePayload {
158 pub server_id: String,
159 pub chosen_version: u8,
160 #[serde(with = "serde_bytes")]
162 pub connection_id: [u8; 16],
163 pub capabilities: HelloCapabilities,
164 pub server_features: ServerFeatures,
165}
166
167#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
171pub struct AuthPayload {
172 pub method: AuthMethod,
173 pub credentials: AuthCredentials,
174}
175
176#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
178pub struct AuthOkPayload {
179 #[serde(with = "serde_bytes")]
180 pub space_id: WireUuid,
181 pub bound_shard_id: u16,
182 pub permissions: SpacePermissions,
183 pub namespace: String,
187 pub server_time_unix_nanos: u64,
188}
189
190#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
205pub struct ActAs {
206 pub namespace: String,
208 pub space_id: String,
213 #[serde(default, skip_serializing_if = "is_zero_u32")]
219 pub grant: u32,
220}
221
222pub mod act_as_grant {
224 pub const SCHEMA_UPLOAD: u32 = 1 << 4;
226 pub const ADMIN: u32 = 1 << 5;
228}
229
230#[allow(clippy::trivially_copy_pass_by_ref)] fn is_zero_u32(v: &u32) -> bool {
232 *v == 0
233}
234
235#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
241pub struct EdgeRequest {
242 pub target: WireMemoryId,
243 pub kind: EdgeKindWire,
244 pub weight: f32,
245}
246
247#[derive(
255 Clone,
256 Copy,
257 Debug,
258 Default,
259 Eq,
260 PartialEq,
261 serde_repr::Serialize_repr,
262 serde_repr::Deserialize_repr,
263)]
264#[repr(u8)]
265pub enum WaitMode {
266 #[default]
269 Ack = 0,
270 Derived = 1,
272}
273
274impl WaitMode {
275 #[must_use]
278 pub fn is_ack(&self) -> bool {
279 matches!(self, WaitMode::Ack)
280 }
281}
282
283#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
285pub struct EncodeRequest {
286 pub text: String,
287 pub session_id: WireSessionId,
288 #[serde(with = "serde_bytes")]
289 pub request_id: WireUuid,
290 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
291 pub txn_id: Option<WireUuid>,
292 pub occurred_at_unix_nanos: Option<u64>,
293 #[serde(skip_serializing_if = "Option::is_none", default)]
296 pub act_as: Option<ActAs>,
297 #[serde(default, skip_serializing_if = "WaitMode::is_ack")]
306 pub wait: WaitMode,
307 #[serde(default, skip_serializing_if = "is_false")]
315 pub allow_duplicates: bool,
316}
317
318#[allow(clippy::trivially_copy_pass_by_ref)]
321fn is_false(b: &bool) -> bool {
322 !*b
323}
324
325#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
329pub struct EncodeVectorDirectRequest {
330 pub text: String,
331 #[serde(skip, default)]
333 pub vector: Vec<f32>,
334 #[serde(with = "serde_bytes")]
335 pub model_fingerprint: [u8; 16],
336 pub session_id: WireSessionId,
337 pub kind: MemoryKindWire,
338 pub salience_hint: f32,
339 pub edges: Vec<EdgeRequest>,
340 #[serde(with = "serde_bytes")]
341 pub request_id: WireUuid,
342 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
343 pub txn_id: Option<WireUuid>,
344 pub deduplicate: bool,
345}
346
347#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
349pub struct EncodeResponse {
350 pub memory_id: WireMemoryId,
351 pub was_deduplicated: bool,
352 pub salience: f32,
353 pub auto_edges_added: u32,
354 pub lsn: u64,
355 #[serde(with = "serde_bytes")]
356 pub space_id: WireUuid,
357 pub session_id: WireSessionId,
358 pub kind: MemoryKindWire,
359 pub created_at_unix_nanos: u64,
360 pub edges_out_count: u32,
361 #[serde(with = "serde_bytes")]
362 pub embedding_model_fp: [u8; 16],
363 pub pending_stages: Vec<StageKind>,
364 pub has_active_schema: bool,
365 #[serde(skip_serializing_if = "Option::is_none", default)]
370 pub trace: Option<EncodeTrace>,
371}
372
373#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
378pub struct EncodeTrace {
379 pub stages: Vec<EncodeTraceStage>,
380 pub artifacts: EncodeTraceArtifacts,
381 pub total_latency_us: u64,
382}
383
384#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
386pub struct EncodeTraceStage {
387 pub name: String,
388 pub status: EncodeTraceStageStatus,
389 pub latency_us: u64,
390 pub detail: String,
391 #[serde(default, skip_serializing_if = "Option::is_none")]
396 pub artifact: Option<EncodeStageArtifact>,
397}
398
399#[derive(
401 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
402)]
403#[repr(u8)]
404pub enum EncodeTraceStageStatus {
405 Ok = 0,
406 Skipped = 1,
407 Failed = 2,
408 Timeout = 3,
409}
410
411#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
413pub struct EncodeTraceArtifacts {
414 pub entities: Vec<EncodeTraceEntity>,
415 pub statements: Vec<EncodeTraceStatement>,
416 pub relations: Vec<EncodeTraceRelation>,
417 pub indexes: Vec<EncodeTraceIndex>,
418 pub dedup: EncodeTraceDedup,
419}
420
421#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
423pub struct EncodeTraceEntity {
424 #[serde(with = "serde_bytes")]
425 pub id: [u8; 16],
426 pub name: String,
427 pub type_qname: String,
428}
429
430#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
432pub struct EncodeTraceStatement {
433 #[serde(with = "serde_bytes")]
434 pub id: [u8; 16],
435 pub subject_name: String,
436 pub predicate: String,
437 pub object_name: String,
438 pub confidence: f32,
439 #[serde(skip_serializing_if = "Option::is_none", default)]
443 pub event_at_unix_nanos: Option<u64>,
444}
445
446#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
448pub struct EncodeTraceRelation {
449 pub source_name: String,
450 pub predicate: String,
451 pub target_name: String,
452}
453
454#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
456pub struct EncodeTraceIndex {
457 pub name: String,
458 pub status: EncodeTraceStageStatus,
459}
460
461#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
463pub struct EncodeTraceDedup {
464 pub was_deduplicated: bool,
465 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
466 pub matched_memory_id: Option<[u8; 16]>,
467}
468
469#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
479pub struct EncodeStageArtifact {
480 #[serde(default, skip_serializing_if = "Vec::is_empty")]
481 pub vector: Vec<f32>,
482 #[serde(default, skip_serializing_if = "Option::is_none")]
483 pub record: Option<EncodeStageRecord>,
484 #[serde(default, skip_serializing_if = "Vec::is_empty")]
485 pub hype_questions: Vec<String>,
486 #[serde(default, skip_serializing_if = "Vec::is_empty")]
487 pub keyword_fields: Vec<EncodeStageKeywordField>,
488 #[serde(default, skip_serializing_if = "Option::is_none")]
489 pub graph: Option<EncodeStageGraph>,
490}
491
492#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
494pub struct EncodeStageRecord {
495 #[serde(with = "serde_bytes")]
496 pub memory_id: [u8; 16],
497 pub kind: u8,
498 pub salience: f32,
499 pub created_at_unix_nanos: u64,
500 pub occurred_at_unix_nanos: u64,
501 pub vector_dim: u32,
502 pub text_len: u32,
503 pub lsn: u64,
504}
505
506#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
508pub struct EncodeStageKeywordField {
509 pub field: String,
510 pub terms: Vec<String>,
511}
512
513#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
515pub struct EncodeGraphNode {
516 #[serde(with = "serde_bytes")]
517 pub id: [u8; 16],
518 pub name: String,
519 pub kind: String,
520 pub type_qname: String,
521}
522
523#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
525pub struct EncodeGraphEdge {
526 #[serde(with = "serde_bytes")]
527 pub source: [u8; 16],
528 #[serde(with = "serde_bytes")]
529 pub target: [u8; 16],
530 pub predicate: String,
531 pub kind: String,
532 pub confidence: f32,
533 #[serde(skip_serializing_if = "Option::is_none", default)]
537 pub event_at_unix_nanos: Option<u64>,
538}
539
540#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
542pub struct EncodeStageGraph {
543 pub nodes: Vec<EncodeGraphNode>,
544 pub edges: Vec<EncodeGraphEdge>,
545}
546
547#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
554pub struct MemoryInspectRequest {
555 #[serde(with = "serde_bytes")]
556 pub memory_id: [u8; 16],
557 #[serde(skip_serializing_if = "Option::is_none", default)]
558 pub act_as: Option<ActAs>,
559}
560
561#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
565pub struct MemoryInspectResponse {
566 pub found: bool,
567 #[serde(with = "serde_bytes")]
568 pub memory_id: [u8; 16],
569 pub text: String,
570 pub artifact: EncodeStageArtifact,
571}
572
573#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
580pub enum AnswerKindWire {
581 Single,
582 Many,
583 None,
584}
585
586#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
595pub enum RecallScopeWire {
596 #[default]
598 Space,
599 Namespace,
601}
602
603#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
605pub struct RecallRequest {
606 pub cue_text: String,
607 pub subject_name: String,
608 pub max_results: u32,
609 pub confidence_threshold: f32,
610 pub session_filter: Option<Vec<WireSessionId>>,
611 pub age_bound_unix_nanos: Option<u64>,
612 pub as_of_record_time_unix_nanos: Option<u64>,
613 pub kind_filter: Option<Vec<MemoryKindWire>>,
614 pub salience_floor: f32,
615 pub include_edges: bool,
616 pub include_graph: bool,
617 pub include_text: bool,
618 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
619 pub request_id: Option<WireUuid>,
620 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
621 pub txn_id: Option<WireUuid>,
622 #[serde(default)]
626 pub trace: bool,
627 #[serde(skip_serializing_if = "Option::is_none", default)]
630 pub act_as: Option<ActAs>,
631 #[serde(default)]
635 pub scope: RecallScopeWire,
636}
637
638#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
640pub struct RecallResponseFrame {
641 pub answer_kind: AnswerKindWire,
642 pub memories: Vec<MemoryResult>,
643 pub is_final: bool,
644 pub cumulative_count: u32,
645 pub estimated_remaining: Option<u32>,
646 #[serde(skip_serializing_if = "Option::is_none", default)]
649 pub trace: Option<RecallTrace>,
650}
651
652#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
655pub struct RecallTrace {
656 pub retrievers: Vec<RecallTraceRetriever>,
657 pub filter_chain: RecallTraceFilterChain,
658 pub rerank: Option<RecallTraceRerank>,
659 pub total_latency_ms: f64,
660 pub fusion: Option<RecallTraceFusion>,
664}
665
666#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
668pub struct RecallTraceRetriever {
669 pub name: RetrieverNameWire,
670 pub status: RecallTraceRetrieverStatus,
671 pub status_detail: String,
673 pub latency_ms: f64,
674 pub candidate_count: u32,
675 pub candidates: Vec<RecallTraceCandidate>,
678}
679
680#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
682pub struct RecallTraceCandidate {
683 pub item_id: WireMemoryId,
686 pub kind: RecallCandidateKind,
688 pub text: String,
691 pub score: f32,
693}
694
695#[derive(
699 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
700)]
701#[repr(u8)]
702pub enum RecallCandidateKind {
703 Memory = 0,
704 Statement = 1,
705 Entity = 2,
706 Relation = 3,
707}
708
709#[derive(
711 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
712)]
713#[repr(u8)]
714pub enum RecallTraceRetrieverStatus {
715 Success = 0,
716 Skipped = 1,
717 Timeout = 2,
718 Failure = 3,
719}
720
721#[derive(
729 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
730)]
731#[repr(u8)]
732pub enum RankedItemKindWire {
733 Memory = 0,
734 Statement = 1,
735 Entity = 2,
736 Relation = 3,
737}
738
739#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
745pub struct RecallTraceDroppedId {
746 pub kind: RankedItemKindWire,
747 pub id: u128,
748}
749
750#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
752pub struct RecallTraceFilterChain {
753 pub before: u32,
754 pub after_type: u32,
755 pub after_temporal: u32,
756 pub after_confidence: u32,
757 pub after_tombstone: u32,
758 pub after_supersession: u32,
759 pub after_as_of: u32,
760 pub after_limit: u32,
761 pub dropped_by_type: Vec<WireMemoryId>,
764 pub dropped_by_temporal: Vec<WireMemoryId>,
767 pub dropped_by_confidence: Vec<WireMemoryId>,
770 pub dropped_by_tombstone: Vec<WireMemoryId>,
773 pub dropped_by_supersession: Vec<RecallTraceDroppedId>,
778 pub dropped_by_as_of: Vec<RecallTraceDroppedId>,
782 pub dropped_by_limit: Vec<RecallTraceDroppedId>,
786}
787
788#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
790pub struct RecallTraceRerank {
791 pub applied: bool,
792 pub candidates: u32,
793 pub latency_ms: f64,
794 pub before_order: Vec<WireMemoryId>,
797 pub after_order: Vec<WireMemoryId>,
800}
801
802#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
806pub struct RecallTraceFusion {
807 pub items: Vec<RecallTraceFusionItem>,
808}
809
810#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
813pub struct RecallTraceFusionItem {
814 pub memory_id: WireMemoryId,
815 pub rrf_score: f32,
816 pub lane_scores: Vec<(RetrieverNameWire, f32)>,
817}
818
819#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
821pub struct MemoryResult {
822 pub memory_id: WireMemoryId,
823 pub text: String,
824 pub similarity_score: f32,
825 pub confidence: f32,
826 pub salience: f32,
827 pub kind: MemoryKindWire,
828 #[serde(with = "serde_bytes")]
829 pub space_id: WireUuid,
830 pub session_id: WireSessionId,
831 pub created_at_unix_nanos: u64,
832 pub last_accessed_at_unix_nanos: u64,
833 pub edges: Option<Vec<EdgeView>>,
834 pub contributing_retrievers: Vec<RetrieverNameWire>,
835 pub fused_score: f32,
836 pub rerank_score: Option<f32>,
837 pub salience_initial: f32,
838 pub access_count: u32,
839 pub lsn: u64,
840 pub flags: u32,
841 pub consolidated_at_unix_nanos: Option<u64>,
842 pub occurred_at_unix_nanos: Option<u64>,
843 pub edges_out_count: u32,
844 pub edges_in_count: u32,
845 pub graph: Option<GraphEnrichment>,
846}
847
848#[derive(
850 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
851)]
852#[repr(u8)]
853pub enum RetrieverNameWire {
854 Semantic = 0,
855 Lexical = 1,
856 Graph = 2,
857}
858
859#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
861pub struct EdgeView {
862 pub target: WireMemoryId,
863 pub kind: EdgeKindWire,
864 pub weight: f32,
865}
866
867#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
869pub struct GraphEnrichment {
870 pub entities: Vec<EnrichedEntity>,
871 pub statements: Vec<EnrichedStatement>,
872 pub relations: Vec<EnrichedRelation>,
873}
874
875#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
878pub struct EnrichedEntity {
879 #[serde(with = "serde_bytes")]
880 pub id: [u8; 16],
881 pub name: String,
882 pub type_qname: String,
883}
884
885#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
889pub struct EnrichedStatement {
890 #[serde(with = "serde_bytes")]
891 pub id: [u8; 16],
892 pub subject_name: String,
893 pub predicate: String,
894 pub object_label: String,
895 #[serde(default, with = "crate::wire::cbor::opt_byte_array16")]
904 pub object_entity_id: Option<[u8; 16]>,
905 pub confidence: f32,
906 #[serde(skip_serializing_if = "Option::is_none", default)]
910 pub event_at_unix_nanos: Option<u64>,
911}
912
913#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
916pub struct EnrichedRelation {
917 pub from_name: String,
918 pub predicate: String,
919 pub to_name: String,
920}
921
922#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
928pub struct ForgetRequest {
929 pub memory_id: WireMemoryId,
930 pub mode: ForgetMode,
931 #[serde(with = "serde_bytes")]
932 pub request_id: WireUuid,
933 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
934 pub txn_id: Option<WireUuid>,
935 #[serde(skip_serializing_if = "Option::is_none", default)]
938 pub act_as: Option<ActAs>,
939}
940
941#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
943pub struct ForgetResponse {
944 pub memory_id: WireMemoryId,
945 pub was_already_forgotten: bool,
946 pub edges_removed: u32,
947}
948
949#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
955pub struct LinkRequest {
956 pub source: WireMemoryId,
957 pub target: WireMemoryId,
958 pub kind: EdgeKindWire,
959 pub weight: f32,
961 #[serde(with = "serde_bytes")]
962 pub request_id: WireUuid,
963 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
964 pub txn_id: Option<WireUuid>,
965 #[serde(skip_serializing_if = "Option::is_none", default)]
968 pub act_as: Option<ActAs>,
969}
970
971#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
973pub struct LinkResponse {
974 pub source: WireMemoryId,
975 pub target: WireMemoryId,
976 pub kind: EdgeKindWire,
977 pub weight: f32,
978 pub created_at_unix_nanos: u64,
979 pub already_existed: bool,
982}
983
984#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
987pub struct UnlinkRequest {
988 pub source: WireMemoryId,
989 pub target: WireMemoryId,
990 pub kind: EdgeKindWire,
991 #[serde(with = "serde_bytes")]
992 pub request_id: WireUuid,
993 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
994 pub txn_id: Option<WireUuid>,
995 #[serde(skip_serializing_if = "Option::is_none", default)]
998 pub act_as: Option<ActAs>,
999}
1000
1001#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
1003pub struct UnlinkResponse {
1004 pub source: WireMemoryId,
1005 pub target: WireMemoryId,
1006 pub kind: EdgeKindWire,
1007 pub removed: bool,
1010}
1011
1012#[derive(
1019 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1020)]
1021#[repr(u8)]
1022pub enum MemoryListSortWire {
1023 Created = 0,
1024 Salience = 1,
1025 Occurred = 2,
1026 LastAccessed = 3,
1027}
1028
1029#[derive(
1031 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1032)]
1033#[repr(u8)]
1034pub enum MemoryListDirWire {
1035 Asc = 0,
1036 Desc = 1,
1037}
1038
1039#[derive(
1042 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1043)]
1044#[repr(u8)]
1045pub enum MemoryListTimeAxisWire {
1046 Created = 0,
1047 Occurred = 1,
1048}
1049
1050#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1057pub struct MemoryListRequest {
1058 pub sort: MemoryListSortWire,
1059 pub dir: MemoryListDirWire,
1060 pub limit: u32,
1062 pub cursor: Vec<u8>,
1064 pub kinds: Vec<MemoryKindWire>,
1066 pub include_tombstoned: bool,
1069 pub time_axis: MemoryListTimeAxisWire,
1071 pub from_unix_nanos: u64,
1073 pub to_unix_nanos: u64,
1075 pub salience_min: f32,
1077 pub salience_max: f32,
1079 pub text_contains: String,
1081 #[serde(skip_serializing_if = "Option::is_none", default)]
1086 pub act_as: Option<ActAs>,
1087}
1088
1089#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1092pub struct MemoryListItem {
1093 #[serde(with = "serde_bytes")]
1094 pub memory_id: [u8; 16],
1095 #[serde(with = "serde_bytes")]
1097 pub space_id: [u8; 16],
1098 pub session_id: WireSessionId,
1100 pub text: String,
1101 pub kind: u8,
1103 pub state: u8,
1105 pub created_at_unix_nanos: u64,
1106 pub occurred_at_unix_nanos: u64,
1108 pub last_accessed_at_unix_nanos: u64,
1109 pub salience: f32,
1111 pub access_count: u32,
1112 #[serde(with = "serde_bytes")]
1113 pub source_request_id: [u8; 16],
1114 pub statement_count: u32,
1115 pub entity_count: u32,
1116 pub relation_count: u32,
1117}
1118
1119#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1123pub struct MemoryListResponseFrame {
1124 pub items: Vec<MemoryListItem>,
1125 pub next_cursor: Vec<u8>,
1126 pub cumulative_count: u32,
1127 pub is_final: bool,
1128}
1129
1130#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1137pub struct GraphNode {
1138 #[serde(with = "serde_bytes")]
1139 pub id: [u8; 16],
1140 pub kind: u8,
1141 pub label: String,
1142 pub type_qname: String,
1144}
1145
1146#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1152pub struct GraphEdge {
1153 #[serde(with = "serde_bytes")]
1154 pub from_id: [u8; 16],
1155 #[serde(with = "serde_bytes")]
1156 pub to_id: [u8; 16],
1157 pub kind: u8,
1158 pub label: String,
1160}
1161
1162#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1169pub struct GraphFetchRequest {
1170 pub limit: u32,
1172 pub cursor: Vec<u8>,
1174 pub include_statements: bool,
1176 pub include_memories: bool,
1178 pub include_memory_edges: bool,
1184 pub include_tombstoned: bool,
1186 #[serde(skip_serializing_if = "Option::is_none", default)]
1189 pub act_as: Option<ActAs>,
1190}
1191
1192#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1196pub struct GraphFetchResponseFrame {
1197 pub nodes: Vec<GraphNode>,
1198 pub edges: Vec<GraphEdge>,
1199 pub next_cursor: Vec<u8>,
1200 pub is_final: bool,
1201}
1202
1203#[derive(
1209 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1210)]
1211#[repr(u8)]
1212pub enum PlanStrategy {
1213 Auto = 0,
1214 AStar = 1,
1215 Mcts = 2,
1216 AttractorRollout = 3,
1217}
1218
1219#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1222pub enum PlanState {
1223 ByMemoryId(WireMemoryId),
1224 ByText(String),
1225 ByVector { offset: u32, dim: u16 },
1226}
1227
1228#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
1230pub struct PlanBudget {
1231 pub max_steps: u32,
1232 pub max_wall_time_ms: u32,
1233 pub max_branches_explored: u32,
1234}
1235
1236#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1238pub struct PlanRequest {
1239 pub start: PlanState,
1240 pub goal: PlanState,
1241 pub budget: PlanBudget,
1242 pub strategy_hint: Option<PlanStrategy>,
1243 pub session_filter: Option<Vec<WireSessionId>>,
1244 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
1245 pub request_id: Option<WireUuid>,
1246 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
1247 pub txn_id: Option<WireUuid>,
1248 #[serde(default)]
1255 pub trace: bool,
1256 #[serde(skip_serializing_if = "Option::is_none", default)]
1259 pub act_as: Option<ActAs>,
1260}
1261
1262#[derive(
1264 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1265)]
1266#[repr(u8)]
1267pub enum PlanStatus {
1268 GoalReached = 0,
1269 BudgetExhausted = 1,
1270 NoPathFound = 2,
1271 Cancelled = 3,
1272}
1273
1274#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1277pub enum TransitionKind {
1278 Initial,
1279 Causal,
1280 Temporal,
1281 Similarity,
1282 Other(String),
1283}
1284
1285#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1287pub struct PlanStep {
1288 pub step_index: u32,
1289 pub memory_id: WireMemoryId,
1290 pub text: String,
1291 pub transition_kind: TransitionKind,
1292 pub confidence: f32,
1293 pub estimated_distance_to_goal: f32,
1294}
1295
1296#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1299pub struct PlanResponseFrame {
1300 pub steps: Vec<PlanStep>,
1301 pub is_final: bool,
1302 pub plan_status: Option<PlanStatus>,
1303 #[serde(skip_serializing_if = "Option::is_none", default)]
1308 pub trace: Option<PlanTrace>,
1309}
1310
1311#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1319pub struct PlanTrace {
1320 pub explored: Vec<PlanTraceNode>,
1322 pub meeting_points: Vec<PlanTraceMeetingPoint>,
1325}
1326
1327#[derive(
1330 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1331)]
1332#[repr(u8)]
1333pub enum PlanTraceDirection {
1334 Forward = 0,
1336 Backward = 1,
1338}
1339
1340#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1342pub struct PlanTraceNode {
1343 pub memory_id: WireMemoryId,
1344 pub text: String,
1345 pub direction: PlanTraceDirection,
1346 pub depth: u32,
1347 pub parent_edge: Option<WireMemoryId>,
1351 pub alignment_score: Option<f32>,
1354}
1355
1356#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1359pub struct PlanTraceMeetingPoint {
1360 pub memory_id: WireMemoryId,
1361 pub text: String,
1362 pub included_in_result: bool,
1366}
1367
1368#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1374pub enum ObservationInput {
1375 ByMemoryId(WireMemoryId),
1376 ByText(String),
1377}
1378
1379#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1381pub struct ReasonRequest {
1382 pub observation: ObservationInput,
1383 pub depth: u32,
1384 pub confidence_threshold: f32,
1385 pub session_filter: Option<Vec<WireSessionId>>,
1386 pub max_inferences: u32,
1387 pub budget_wall_time_ms: u32,
1388 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
1389 pub request_id: Option<WireUuid>,
1390 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
1391 pub txn_id: Option<WireUuid>,
1392 #[serde(default)]
1400 pub trace: bool,
1401 #[serde(skip_serializing_if = "Option::is_none", default)]
1404 pub act_as: Option<ActAs>,
1405}
1406
1407#[derive(
1409 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1410)]
1411#[repr(u8)]
1412pub enum ReasonStatus {
1413 Complete = 0,
1414 BudgetExhausted = 1,
1415 DepthLimitReached = 2,
1416 Cancelled = 3,
1417}
1418
1419#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1422pub enum InferenceKind {
1423 CausalExplanation,
1424 EvidenceAccumulation,
1425 AnalogicalInference,
1426 Other(String),
1427}
1428
1429#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1431pub struct InferenceStep {
1432 pub step_index: u32,
1433 pub claim: String,
1434 pub supporting_memories: Vec<WireMemoryId>,
1435 pub contradicting_memories: Vec<WireMemoryId>,
1436 pub confidence: f32,
1437 pub inference_kind: InferenceKind,
1438}
1439
1440#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1443pub struct ReasonResponseFrame {
1444 pub inferences: Vec<InferenceStep>,
1445 pub is_final: bool,
1446 pub reason_status: Option<ReasonStatus>,
1447 #[serde(skip_serializing_if = "Option::is_none", default)]
1452 pub trace: Option<ReasonTrace>,
1453}
1454
1455#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1462pub struct ReasonTrace {
1463 pub base: ReasonTraceBase,
1466 pub walk: ReasonTraceWalk,
1469 pub scoring: Vec<ReasonTraceScoreBreakdown>,
1471 pub centroid: ReasonTraceCentroid,
1474}
1475
1476#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1478pub struct ReasonTraceBase {
1479 pub candidates: Vec<ReasonTraceCandidate>,
1480}
1481
1482#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1484pub struct ReasonTraceCandidate {
1485 pub memory_id: WireMemoryId,
1486 pub text: String,
1487 pub score: f32,
1488}
1489
1490#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1493pub struct ReasonTraceWalk {
1494 pub considered: Vec<ReasonTraceEdgeCandidate>,
1497 pub dropped_by_edge_kind: Vec<ReasonTraceEdgeCandidate>,
1499 pub dropped_by_tombstone: Vec<ReasonTraceIdWithText>,
1501 pub dropped_by_visited: Vec<ReasonTraceIdWithText>,
1503 pub dropped_by_confidence: Vec<ReasonTraceScoredId>,
1505 pub dropped_by_max_supporting: Vec<ReasonTraceIdWithText>,
1507 pub dropped_by_max_contradicting: Vec<ReasonTraceIdWithText>,
1509}
1510
1511#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1513pub struct ReasonTraceEdgeCandidate {
1514 pub memory_id: WireMemoryId,
1515 pub text: String,
1516 pub edge_kind: EdgeKindWire,
1517 pub depth: u32,
1518 pub from_memory_id: WireMemoryId,
1519 pub raw_score: f32,
1520}
1521
1522#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1527pub struct ReasonTraceIdWithText {
1528 pub memory_id: WireMemoryId,
1529 pub text: String,
1530}
1531
1532#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1534pub struct ReasonTraceScoredId {
1535 pub memory_id: WireMemoryId,
1536 pub text: String,
1537 pub score: f32,
1538}
1539
1540#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1543pub struct ReasonTraceScoreBreakdown {
1544 pub memory_id: WireMemoryId,
1545 pub text: String,
1546 pub base_similarity: f32,
1547 pub decay: f32,
1548 pub weight_product: f32,
1549 pub alignment: f32,
1550 pub analogical_fit: f32,
1555 pub final_score: f32,
1556}
1557
1558#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1563pub struct ReasonTraceCentroid {
1564 pub computed: bool,
1565 pub skipped_reason: Option<String>,
1567}
1568
1569#[derive(
1575 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1576)]
1577#[repr(u8)]
1578pub enum ErrorCategoryWire {
1579 Protocol = 0,
1580 Authentication = 1,
1581 Authorization = 2,
1582 Validation = 3,
1583 NotFound = 4,
1584 Conflict = 5,
1585 ResourceExhausted = 6,
1586 Internal = 7,
1587 Unavailable = 8,
1588}
1589
1590#[derive(Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr)]
1610#[repr(u16)]
1611pub enum ErrorCodeWire {
1612 BadMagic = 0x0001,
1614 BadHeaderCrc = 0x0002,
1615 BadPayloadCrc = 0x0003,
1616 BadOpcode = 0x0004,
1617 BadVersion = 0x0005,
1618 BadFrame = 0x0006,
1619 OversizePayload = 0x0007,
1620 ReservedFieldNonZero = 0x0008,
1621 BadFlagCombination = 0x0009,
1622 MalformedPayload = 0x000A,
1623 MalformedVector = 0x000B,
1624 VersionNotSupported = 0x0020,
1626 NoSuchAuthMethod = 0x0021,
1627 Unauthenticated = 0x0022,
1628 NotAuthenticated = 0x0023,
1629 AuthBackendUnavailable = 0x0024,
1630 SessionExpired = 0x0025,
1631 PermissionDenied = 0x0030,
1633 AdminPermissionRequired = 0x0031,
1634 WrongShard = 0x0032,
1635 ActAsDenied = 0x0033,
1636 InvalidArgument = 0x0040,
1638 MissingRequiredField = 0x0041,
1639 TextTooLarge = 0x0042,
1640 TextEmpty = 0x0043,
1641 BadSessionId = 0x0044,
1642 BadMemoryKind = 0x0045,
1643 BadEdgeKind = 0x0046,
1644 BadStrategyHint = 0x0047,
1645 TopKOutOfRange = 0x0048,
1646 BudgetTooLarge = 0x0049,
1647 BadModelFingerprint = 0x004A,
1648 PredicateNotInSchema = 0x004B,
1649 RelationTypeNotInSchema = 0x004C,
1650 MemoryNotFound = 0x0050,
1652 ContextNotFound = 0x0051,
1653 SubscriptionNotFound = 0x0052,
1654 SnapshotNotFound = 0x0053,
1655 TxnNotFound = 0x0054,
1656 IdempotencyConflict = 0x0060,
1658 TransactionConflict = 0x0061,
1659 TransactionTimeout = 0x0062,
1660 StreamIdInUse = 0x0063,
1661 SubscriptionLsnTooOld = 0x0064,
1662 CardinalityViolation = 0x0065,
1663 LlmCredentialMissing = 0x0066,
1666 OutOfSlots = 0x0070,
1668 OutOfDisk = 0x0071,
1669 OutOfMemory = 0x0072,
1670 RateLimited = 0x0073,
1671 StreamLimitExceeded = 0x0074,
1672 ConnectionLimitExceeded = 0x0075,
1673 TransactionLimitExceeded = 0x0076,
1674 TransactionTooLarge = 0x0077,
1675 Internal = 0x0080,
1677 StorageError = 0x0081,
1678 IndexError = 0x0082,
1679 EmbeddingError = 0x0083,
1680 MetadataError = 0x0084,
1681 Cancelled = 0x0085,
1682 ShardUnavailable = 0x0090,
1684 Overloaded = 0x0091,
1685 Restarting = 0x0092,
1686 Maintenance = 0x0093,
1687 RetrieverDegraded = 0x0094,
1688 LlmCredentialUnavailable = 0x0095,
1691 SchemaInvalid = 0x0120,
1693 SchemaMigrationRequired = 0x0121,
1694 EntityNotFound = 0x0130,
1695 EntityTypeMismatch = 0x0131,
1696 EntityAmbiguous = 0x0132,
1697 EntityMergeConflict = 0x0133,
1698 StatementNotFound = 0x0140,
1699 StatementObjectTypeMismatch = 0x0141,
1700 StatementContradictsExisting = 0x0142,
1701 QueryTimeout = 0x0160,
1702 QueryOverBudget = 0x0161,
1703 ExtractorDisabled = 0x0170,
1704 ExtractorBudgetExceeded = 0x0171,
1705 ExtractionFailed = 0x0172,
1706 Unknown = 0xFFFF,
1709}
1710
1711impl ErrorCodeWire {
1712 #[must_use]
1717 pub fn from_raw(raw: u16) -> Self {
1718 match raw {
1719 0x0001 => Self::BadMagic,
1720 0x0002 => Self::BadHeaderCrc,
1721 0x0003 => Self::BadPayloadCrc,
1722 0x0004 => Self::BadOpcode,
1723 0x0005 => Self::BadVersion,
1724 0x0006 => Self::BadFrame,
1725 0x0007 => Self::OversizePayload,
1726 0x0008 => Self::ReservedFieldNonZero,
1727 0x0009 => Self::BadFlagCombination,
1728 0x000A => Self::MalformedPayload,
1729 0x000B => Self::MalformedVector,
1730 0x0020 => Self::VersionNotSupported,
1731 0x0021 => Self::NoSuchAuthMethod,
1732 0x0022 => Self::Unauthenticated,
1733 0x0023 => Self::NotAuthenticated,
1734 0x0024 => Self::AuthBackendUnavailable,
1735 0x0025 => Self::SessionExpired,
1736 0x0030 => Self::PermissionDenied,
1737 0x0031 => Self::AdminPermissionRequired,
1738 0x0032 => Self::WrongShard,
1739 0x0033 => Self::ActAsDenied,
1740 0x0040 => Self::InvalidArgument,
1741 0x0041 => Self::MissingRequiredField,
1742 0x0042 => Self::TextTooLarge,
1743 0x0043 => Self::TextEmpty,
1744 0x0044 => Self::BadSessionId,
1745 0x0045 => Self::BadMemoryKind,
1746 0x0046 => Self::BadEdgeKind,
1747 0x0047 => Self::BadStrategyHint,
1748 0x0048 => Self::TopKOutOfRange,
1749 0x0049 => Self::BudgetTooLarge,
1750 0x004A => Self::BadModelFingerprint,
1751 0x004B => Self::PredicateNotInSchema,
1752 0x004C => Self::RelationTypeNotInSchema,
1753 0x0050 => Self::MemoryNotFound,
1754 0x0051 => Self::ContextNotFound,
1755 0x0052 => Self::SubscriptionNotFound,
1756 0x0053 => Self::SnapshotNotFound,
1757 0x0054 => Self::TxnNotFound,
1758 0x0060 => Self::IdempotencyConflict,
1759 0x0061 => Self::TransactionConflict,
1760 0x0062 => Self::TransactionTimeout,
1761 0x0063 => Self::StreamIdInUse,
1762 0x0064 => Self::SubscriptionLsnTooOld,
1763 0x0065 => Self::CardinalityViolation,
1764 0x0070 => Self::OutOfSlots,
1765 0x0071 => Self::OutOfDisk,
1766 0x0072 => Self::OutOfMemory,
1767 0x0073 => Self::RateLimited,
1768 0x0074 => Self::StreamLimitExceeded,
1769 0x0075 => Self::ConnectionLimitExceeded,
1770 0x0076 => Self::TransactionLimitExceeded,
1771 0x0077 => Self::TransactionTooLarge,
1772 0x0080 => Self::Internal,
1773 0x0081 => Self::StorageError,
1774 0x0082 => Self::IndexError,
1775 0x0083 => Self::EmbeddingError,
1776 0x0084 => Self::MetadataError,
1777 0x0085 => Self::Cancelled,
1778 0x0090 => Self::ShardUnavailable,
1779 0x0091 => Self::Overloaded,
1780 0x0092 => Self::Restarting,
1781 0x0093 => Self::Maintenance,
1782 0x0094 => Self::RetrieverDegraded,
1783 0x0120 => Self::SchemaInvalid,
1784 0x0121 => Self::SchemaMigrationRequired,
1785 0x0130 => Self::EntityNotFound,
1786 0x0131 => Self::EntityTypeMismatch,
1787 0x0132 => Self::EntityAmbiguous,
1788 0x0133 => Self::EntityMergeConflict,
1789 0x0140 => Self::StatementNotFound,
1790 0x0141 => Self::StatementObjectTypeMismatch,
1791 0x0142 => Self::StatementContradictsExisting,
1792 0x0160 => Self::QueryTimeout,
1793 0x0161 => Self::QueryOverBudget,
1794 0x0170 => Self::ExtractorDisabled,
1795 0x0171 => Self::ExtractorBudgetExceeded,
1796 0x0172 => Self::ExtractionFailed,
1797 0x0066 => Self::LlmCredentialMissing,
1798 0x0095 => Self::LlmCredentialUnavailable,
1799 _ => Self::Unknown,
1800 }
1801 }
1802}
1803
1804impl<'de> serde::Deserialize<'de> for ErrorCodeWire {
1805 fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
1806 Ok(Self::from_raw(u16::deserialize(d)?))
1807 }
1808}
1809
1810#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
1812pub struct ErrorDetails {
1813 pub field: Option<String>,
1814 pub expected: Option<String>,
1815 pub actual: Option<String>,
1816}
1817
1818#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1820pub struct ErrorResponse {
1821 pub code: ErrorCodeWire,
1822 pub category: ErrorCategoryWire,
1823 pub message: String,
1824 pub details: Option<ErrorDetails>,
1825 pub retry_after_ms: Option<u32>,
1826}
1827
1828impl ErrorResponse {
1829 #[must_use]
1833 pub fn code_is_unknown(&self) -> bool {
1834 self.code == ErrorCodeWire::Unknown
1835 }
1836}
1837
1838#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
1849pub enum StatementKindWire {
1850 Fact,
1851 Preference,
1852 Event,
1853 Attribute,
1854 Relation,
1855 Directive,
1856 Custom(u8),
1857}
1858
1859impl StatementKindWire {
1860 #[must_use]
1862 pub fn to_storage_byte(self) -> u8 {
1863 match self {
1864 StatementKindWire::Fact => 0,
1865 StatementKindWire::Preference => 1,
1866 StatementKindWire::Event => 2,
1867 StatementKindWire::Attribute => 3,
1868 StatementKindWire::Relation => 4,
1869 StatementKindWire::Directive => 5,
1870 StatementKindWire::Custom(b) => b,
1871 }
1872 }
1873
1874 #[must_use]
1877 pub fn from_storage_byte(byte: u8) -> Self {
1878 match byte {
1879 0 => StatementKindWire::Fact,
1880 1 => StatementKindWire::Preference,
1881 2 => StatementKindWire::Event,
1882 3 => StatementKindWire::Attribute,
1883 4 => StatementKindWire::Relation,
1884 5 => StatementKindWire::Directive,
1885 b => StatementKindWire::Custom(b),
1886 }
1887 }
1888}
1889
1890#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1892pub enum StatementValueWire {
1893 Text(String),
1894 Integer(i64),
1895 Float(f64),
1896 Bool(bool),
1897 UnixNanos(u64),
1898 Blob(Vec<u8>),
1899}
1900
1901#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1903pub enum StatementObjectWire {
1904 EntityRef(#[serde(with = "serde_bytes")] WireUuid),
1905 Value(StatementValueWire),
1906 MemoryRef(#[serde(with = "serde_bytes")] [u8; 16]),
1907 StatementRef(#[serde(with = "serde_bytes")] WireUuid),
1908}
1909
1910#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1912pub enum EvidenceRefWire {
1913 Inline(#[serde(with = "crate::wire::cbor::vec_byte_array16")] Vec<[u8; 16]>),
1914 Overflow(#[serde(with = "serde_bytes")] WireUuid),
1915}
1916
1917#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1919pub struct EntityCreateRequest {
1920 pub entity_type_id: u32,
1921 pub canonical_name: String,
1922 pub aliases: Vec<String>,
1923 pub attributes_blob: Vec<u8>,
1924 #[serde(default)]
1927 pub session_id: WireSessionId,
1928 #[serde(with = "serde_bytes")]
1929 pub request_id: WireUuid,
1930 #[serde(skip_serializing_if = "Option::is_none", default)]
1933 pub act_as: Option<ActAs>,
1934}
1935
1936#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1940pub struct EntityUpdateRequest {
1941 #[serde(with = "serde_bytes")]
1942 pub entity_id: WireUuid,
1943 pub canonical_name: String,
1944 pub aliases: Vec<String>,
1945 pub attributes_blob: Vec<u8>,
1946 #[serde(with = "serde_bytes")]
1947 pub request_id: WireUuid,
1948}
1949
1950#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1952pub struct EntityUpdateResponse {
1953 pub entity: EntityView,
1954}
1955
1956#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1960pub struct EntityRenameRequest {
1961 #[serde(with = "serde_bytes")]
1962 pub entity_id: WireUuid,
1963 pub new_canonical_name: String,
1964 pub move_to_alias: bool,
1965 #[serde(with = "serde_bytes")]
1966 pub request_id: WireUuid,
1967}
1968
1969#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1971pub struct EntityRenameResponse {
1972 pub entity: EntityView,
1973}
1974
1975#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1980pub struct EntityMergeRequest {
1981 #[serde(with = "serde_bytes")]
1982 pub survivor: WireUuid,
1983 #[serde(with = "serde_bytes")]
1984 pub merged: WireUuid,
1985 pub confidence: f32,
1986 pub reason: String,
1987 #[serde(with = "serde_bytes")]
1988 pub request_id: WireUuid,
1989}
1990
1991#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
1994pub struct EntityMergeResponse {
1995 #[serde(with = "serde_bytes")]
1996 pub audit_id: WireUuid,
1997 pub grace_period_seconds: u64,
1998}
1999
2000#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2003pub struct EntityUnmergeRequest {
2004 #[serde(with = "serde_bytes")]
2005 pub merged_entity: WireUuid,
2006 #[serde(with = "serde_bytes")]
2007 pub request_id: WireUuid,
2008}
2009
2010#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2012pub struct EntityUnmergeResponse {
2013 #[serde(with = "serde_bytes")]
2014 pub restored_entity_id: WireUuid,
2015}
2016
2017#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2021pub struct EntityTombstoneRequest {
2022 #[serde(with = "serde_bytes")]
2023 pub entity_id: WireUuid,
2024 pub reason: String,
2025 #[serde(with = "serde_bytes")]
2026 pub request_id: WireUuid,
2027}
2028
2029#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2031pub struct EntityTombstoneResponse {
2032 pub tombstoned_at_unix_nanos: u64,
2033}
2034
2035#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2039pub struct EntityCreateResponse {
2040 #[serde(with = "serde_bytes")]
2041 pub entity_id: WireUuid,
2042}
2043
2044#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2046pub struct StatementCreateRequest {
2047 pub kind: StatementKindWire,
2048 #[serde(with = "serde_bytes")]
2049 pub subject: WireUuid,
2050 pub predicate: String,
2051 pub object: StatementObjectWire,
2052 pub confidence: f32,
2053 pub evidence: EvidenceRefWire,
2054 pub extractor_id: u32,
2055 pub valid_from_unix_nanos: u64,
2056 pub valid_to_unix_nanos: u64,
2057 pub event_at_unix_nanos: u64,
2058 pub schema_version: u32,
2059 #[serde(default)]
2062 pub session_id: WireSessionId,
2063 #[serde(with = "serde_bytes")]
2064 pub request_id: WireUuid,
2065 #[serde(skip_serializing_if = "Option::is_none", default)]
2068 pub act_as: Option<ActAs>,
2069}
2070
2071#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2074pub struct StatementCreateResponse {
2075 #[serde(with = "serde_bytes")]
2076 pub statement_id: WireUuid,
2077 #[serde(with = "serde_bytes")]
2078 pub auto_superseded: WireUuid,
2079 #[serde(with = "serde_bytes")]
2080 pub chain_root: WireUuid,
2081}
2082
2083#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2088pub struct StatementSupersedeRequest {
2089 #[serde(with = "serde_bytes")]
2090 pub old_statement_id: WireUuid,
2091 pub new_statement: StatementCreateRequest,
2092 #[serde(with = "serde_bytes")]
2093 pub request_id: WireUuid,
2094}
2095
2096#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2099pub struct StatementSupersedeResponse {
2100 #[serde(with = "serde_bytes")]
2101 pub new_statement_id: WireUuid,
2102 #[serde(with = "serde_bytes")]
2103 pub chain_root: WireUuid,
2104 pub version: u32,
2105}
2106
2107#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2110pub struct StatementTombstoneRequest {
2111 #[serde(with = "serde_bytes")]
2112 pub statement_id: WireUuid,
2113 pub reason: u8,
2114 pub reason_message: String,
2115 #[serde(with = "serde_bytes")]
2116 pub request_id: WireUuid,
2117}
2118
2119#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2121pub struct StatementTombstoneResponse {
2122 pub tombstoned_at_unix_nanos: u64,
2123}
2124
2125#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2129pub struct StatementRetractRequest {
2130 #[serde(with = "serde_bytes")]
2131 pub statement_id: WireUuid,
2132 pub reason: u8,
2133 pub reason_message: String,
2134 #[serde(with = "serde_bytes")]
2135 pub request_id: WireUuid,
2136}
2137
2138#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2141pub struct StatementRetractResponse {
2142 pub retracted_at_unix_nanos: u64,
2143 pub will_zero_at_unix_nanos: u64,
2144}
2145
2146#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2151pub struct StatementHistoryRequest {
2152 #[serde(with = "serde_bytes")]
2153 pub anchor_id: WireUuid,
2154 pub include_tombstoned: bool,
2155 pub limit: u32,
2156 pub cursor: Vec<u8>,
2157}
2158
2159#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2163pub struct StatementHistoryResponseFrame {
2164 pub items: Vec<StatementView>,
2165 #[serde(with = "serde_bytes")]
2166 pub chain_root: WireUuid,
2167 pub total_versions: u32,
2168 pub next_cursor: Vec<u8>,
2169 pub is_final: bool,
2170}
2171
2172#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2174pub struct RelationCreateRequest {
2175 pub relation_type: String,
2176 #[serde(with = "serde_bytes")]
2177 pub from_entity: WireUuid,
2178 #[serde(with = "serde_bytes")]
2179 pub to_entity: WireUuid,
2180 pub properties_blob: Vec<u8>,
2181 pub evidence: EvidenceRefWire,
2182 pub extractor_id: u32,
2183 pub confidence: f32,
2184 pub valid_from_unix_nanos: u64,
2185 pub valid_to_unix_nanos: u64,
2186 #[serde(default)]
2189 pub session_id: WireSessionId,
2190 #[serde(with = "serde_bytes")]
2191 pub request_id: WireUuid,
2192 #[serde(skip_serializing_if = "Option::is_none", default)]
2195 pub act_as: Option<ActAs>,
2196}
2197
2198#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2200pub struct RelationCreateResponse {
2201 #[serde(with = "serde_bytes")]
2202 pub relation_id: WireUuid,
2203}
2204
2205#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2207pub struct SchemaUploadRequest {
2208 pub schema_document: String,
2209 pub dry_run: bool,
2210 pub allow_breaking: bool,
2211 #[serde(with = "serde_bytes")]
2212 pub request_id: WireUuid,
2213 #[serde(skip_serializing_if = "Option::is_none", default)]
2215 pub act_as: Option<ActAs>,
2216}
2217
2218#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2220pub struct SchemaValidationErrorWire {
2221 pub code: String,
2222 pub message: String,
2223 pub line: u32,
2224 pub column: u32,
2225 pub length: u32,
2226 pub severity: u8,
2227}
2228
2229#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2231pub struct SchemaUploadResponse {
2232 pub namespace: String,
2233 pub schema_version: u32,
2234 pub validation_errors: Vec<SchemaValidationErrorWire>,
2235 pub backward_compatible: bool,
2236 pub migration_summary_blob: Vec<u8>,
2237}
2238
2239pub mod schema_drop_target {
2246 pub const PREDICATE: u8 = 0;
2248 pub const RELATION_TYPE: u8 = 1;
2250}
2251
2252#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2264pub struct SchemaDropRequest {
2265 pub namespace: String,
2268 pub target_kind: u8,
2270 pub target_name: String,
2273 pub force: bool,
2275 #[serde(with = "serde_bytes")]
2276 pub request_id: WireUuid,
2277 #[serde(skip_serializing_if = "Option::is_none", default)]
2279 pub act_as: Option<ActAs>,
2280}
2281
2282#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2290pub struct SchemaDropResponse {
2291 pub namespace: String,
2292 pub schema_version: u32,
2293 pub target_kind: u8,
2294 pub target_name: String,
2295 pub dropped: bool,
2296 pub live_rows: u32,
2297 pub validation_errors: Vec<SchemaValidationErrorWire>,
2298}
2299
2300#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2311pub struct SchemaReplaceRequest {
2312 pub schema_document: String,
2315 pub force_drop_existing: bool,
2317 #[serde(with = "serde_bytes")]
2318 pub request_id: WireUuid,
2319 #[serde(skip_serializing_if = "Option::is_none", default)]
2321 pub act_as: Option<ActAs>,
2322}
2323
2324#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2330pub struct SchemaReplaceResponse {
2331 pub namespace: String,
2332 pub schema_version: u32,
2333 pub dropped_count: u32,
2334 pub validation_errors: Vec<SchemaValidationErrorWire>,
2335}
2336
2337#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2339pub enum CancellationReason {
2340 ClientUnneeded,
2343 Timeout,
2345 Other(String),
2347}
2348
2349#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2356pub struct CancelStreamRequest {
2357 pub target_stream_id: u32,
2358 pub reason: CancellationReason,
2359}
2360
2361#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2363pub struct CancelStreamAck {
2364 pub target_stream_id: u32,
2365 pub cancelled_at_unix_nanos: u64,
2366}
2367
2368#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2370pub struct TimeRangeWire {
2371 pub from_unix_ms: Option<u64>,
2372 pub to_unix_ms: Option<u64>,
2373}
2374
2375#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2389#[repr(u8)]
2390pub enum RetrieverWire {
2391 Semantic = 0,
2392 Lexical = 1,
2393 Graph = 2,
2394}
2395
2396#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2399pub enum RetrieverSelectionWire {
2400 Auto,
2401 Explicit(Vec<RetrieverWire>),
2402}
2403
2404#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2406pub struct FusionConfigWire {
2407 pub k: u32,
2408 pub semantic_weight: f32,
2409 pub lexical_weight: f32,
2410 pub graph_weight: f32,
2411}
2412
2413#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2416pub struct QueryRequest {
2417 pub text: String,
2418 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
2419 pub entity_anchor: Option<WireUuid>,
2420 pub kind_filter: Vec<u8>,
2421 pub predicate_filter: Vec<String>,
2422 pub session_filter: Option<Vec<WireSessionId>>,
2426 pub time_filter: Option<TimeRangeWire>,
2427 pub as_of_record_time_unix_nanos: Option<u64>,
2428 pub confidence_min: Option<f32>,
2429 pub include_tombstoned: bool,
2430 pub include_superseded: bool,
2431 pub limit: u32,
2432 pub retrievers: RetrieverSelectionWire,
2433 pub fusion_config: Option<FusionConfigWire>,
2434 #[serde(with = "serde_bytes")]
2435 pub request_id: WireUuid,
2436}
2437
2438#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2440pub struct MaterializeProceduralRequest {
2441 #[serde(with = "serde_bytes")]
2442 pub space_id: WireUuid,
2443 pub session_filter: Option<Vec<WireSessionId>>,
2444 pub top_k: u32,
2445 pub min_confidence: f32,
2446 pub categories: Vec<String>,
2447 #[serde(with = "serde_bytes")]
2448 pub request_id: WireUuid,
2449}
2450
2451#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2453pub struct MaterializeProceduralResponse {
2454 pub system_block: String,
2455 #[serde(with = "crate::wire::cbor::vec_byte_array16")]
2458 pub statement_ids: Vec<WireUuid>,
2459 pub total_candidates: u32,
2460 pub trimmed_by_budget: bool,
2461}
2462
2463#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2471pub struct SpaceView {
2472 pub space_id: String,
2473 pub created_at_unix_nanos: u64,
2474 pub last_active_unix_nanos: u64,
2475 pub memory_count: u64,
2476 pub session_count: u32,
2477}
2478
2479#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2483pub struct SpaceCreateRequest {
2484 #[serde(skip_serializing_if = "Option::is_none", default)]
2487 pub metadata: Option<Vec<u8>>,
2488 #[serde(with = "serde_bytes")]
2489 pub request_id: WireUuid,
2490 #[serde(skip_serializing_if = "Option::is_none", default)]
2491 pub act_as: Option<ActAs>,
2492}
2493
2494#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2497pub struct SpaceCreateResponse {
2498 pub space_id: String,
2499 pub created: bool,
2501 pub created_at_unix_nanos: u64,
2502 pub last_active_unix_nanos: u64,
2503 pub memory_count: u64,
2504 pub session_count: u32,
2505}
2506
2507#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2510pub struct SpaceListRequest {
2511 pub limit: u32,
2512 #[serde(skip_serializing_if = "Option::is_none", default)]
2513 pub act_as: Option<ActAs>,
2514}
2515
2516#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2518pub struct SpaceListResponse {
2519 pub spaces: Vec<SpaceView>,
2520 pub cross_shard_complete: bool,
2524}
2525
2526#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2529pub struct SpaceDeleteRequest {
2530 #[serde(with = "serde_bytes")]
2531 pub request_id: WireUuid,
2532 #[serde(skip_serializing_if = "Option::is_none", default)]
2533 pub act_as: Option<ActAs>,
2534}
2535
2536#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2539pub struct SpaceDeleteResponse {
2540 pub space_id: String,
2541 pub existed: bool,
2543 pub memories_forgotten: u64,
2545}
2546
2547#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2553pub struct SessionView {
2554 pub session_id: WireSessionId,
2555 pub created_at_unix_nanos: u64,
2556 pub last_active_unix_nanos: u64,
2557 #[serde(skip_serializing_if = "Option::is_none", default)]
2558 pub title: Option<String>,
2559 pub memory_count: u32,
2560}
2561
2562#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2565pub struct SessionCreateRequest {
2566 pub session_id: WireSessionId,
2567 #[serde(skip_serializing_if = "Option::is_none", default)]
2568 pub title: Option<String>,
2569 #[serde(with = "serde_bytes")]
2570 pub request_id: WireUuid,
2571 #[serde(skip_serializing_if = "Option::is_none", default)]
2572 pub act_as: Option<ActAs>,
2573}
2574
2575#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2578pub struct SessionCreateResponse {
2579 #[serde(with = "serde_bytes")]
2580 pub space_id: WireUuid,
2581 pub session_id: WireSessionId,
2582 pub created: bool,
2584 pub created_at_unix_nanos: u64,
2585 pub last_active_unix_nanos: u64,
2586 pub memory_count: u32,
2587}
2588
2589#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2592pub struct SessionListRequest {
2593 pub limit: u32,
2594 #[serde(skip_serializing_if = "Option::is_none", default)]
2595 pub act_as: Option<ActAs>,
2596}
2597
2598#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2601pub struct SessionListResponse {
2602 #[serde(with = "serde_bytes")]
2603 pub space_id: WireUuid,
2604 pub sessions: Vec<SessionView>,
2605}
2606
2607#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2611pub struct SessionDeleteRequest {
2612 pub session_id: WireSessionId,
2613 #[serde(default)]
2615 pub hard: bool,
2616 #[serde(with = "serde_bytes")]
2617 pub request_id: WireUuid,
2618 #[serde(skip_serializing_if = "Option::is_none", default)]
2619 pub act_as: Option<ActAs>,
2620}
2621
2622#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2625pub struct SessionDeleteResponse {
2626 #[serde(with = "serde_bytes")]
2627 pub space_id: WireUuid,
2628 pub session_id: WireSessionId,
2629 pub existed: bool,
2631 pub memories_forgotten: u64,
2633}
2634
2635#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2642pub struct TxnBeginRequest {
2643 #[serde(with = "serde_bytes")]
2644 pub txn_id: WireUuid,
2645 pub timeout_seconds: u32,
2646 #[serde(skip_serializing_if = "Option::is_none", default)]
2651 pub act_as: Option<ActAs>,
2652}
2653
2654#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2656pub struct TxnBeginResponse {
2657 #[serde(with = "serde_bytes")]
2658 pub txn_id: WireUuid,
2659 pub timeout_seconds: u32,
2660 pub started_at_unix_nanos: u64,
2661}
2662
2663#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2665pub struct TxnCommitRequest {
2666 #[serde(with = "serde_bytes")]
2667 pub txn_id: WireUuid,
2668}
2669
2670#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2672pub struct TxnCommitResponse {
2673 #[serde(with = "serde_bytes")]
2674 pub txn_id: WireUuid,
2675 pub committed_at_unix_nanos: u64,
2676 pub operations_applied: u32,
2677}
2678
2679#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2681pub struct TxnAbortRequest {
2682 #[serde(with = "serde_bytes")]
2683 pub txn_id: WireUuid,
2684}
2685
2686#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2688pub struct TxnAbortResponse {
2689 #[serde(with = "serde_bytes")]
2690 pub txn_id: WireUuid,
2691 pub operations_discarded: u32,
2692}
2693
2694#[derive(
2703 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
2704)]
2705#[repr(u8)]
2706pub enum EventType {
2707 Encoded = 0,
2709 Forgotten = 1,
2710 Reclaimed = 2,
2711 KindChanged = 3,
2712
2713 EntityCreated = 16,
2715 EntityUpdated = 17,
2716 EntityRenamed = 18,
2717 EntityMerged = 19,
2718 EntityUnmerged = 20,
2719 EntityTombstoned = 21,
2720 StatementCreated = 22,
2721 StatementSuperseded = 23,
2722 StatementTombstoned = 24,
2723 RelationCreated = 25,
2724 RelationSuperseded = 26,
2725 StageCompleted = 27,
2726 SchemaUpdated = 29,
2727 RelationTombstoned = 30,
2728
2729 EdgeAdded = 31,
2731 EdgeRemoved = 32,
2732 EdgeSuperseded = 33,
2733}
2734
2735#[derive(
2737 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
2738)]
2739#[repr(u8)]
2740pub enum StageOutcome {
2741 Ok = 0,
2742 Empty = 1,
2743 Failed = 2,
2744}
2745
2746#[derive(
2748 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
2749)]
2750#[repr(u8)]
2751pub enum StageAuditStatus {
2752 Succeeded = 0,
2753 PartiallyApplied = 1,
2754 Failed = 2,
2755 Skipped = 3,
2756}
2757
2758#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2761pub struct StageAutoEdgePayload {
2762 pub edges_written: u32,
2763}
2764
2765#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2768pub struct StageTemporalEdgePayload {
2769 pub edges_written: u32,
2770}
2771
2772#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2775pub struct StageExtractorPayload {
2776 pub entity_count: u32,
2777 pub statement_count: u32,
2778 pub relation_count: u32,
2779 pub audit_status: StageAuditStatus,
2780 pub error_message: String,
2782}
2783
2784#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2788pub struct StageHypePayload {
2789 pub questions_written: u32,
2792 pub cost_micro_usd: u64,
2794}
2795
2796#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2799pub enum StagePayload {
2800 AutoEdge(StageAutoEdgePayload),
2801 TemporalEdge(StageTemporalEdgePayload),
2802 Extractor(StageExtractorPayload),
2803 Hype(StageHypePayload),
2804}
2805
2806#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
2808pub struct SimilarityFilter {
2809 pub reference_memory_id: WireMemoryId,
2810 pub threshold: f32,
2811}
2812
2813#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2816pub struct SubscriptionFilter {
2817 pub session_filter: Option<Vec<WireSessionId>>,
2818 pub kinds: Option<Vec<MemoryKindWire>>,
2819 pub similar_to: Option<SimilarityFilter>,
2820 #[serde(with = "crate::wire::cbor::opt_vec_byte_array16")]
2823 pub spaces: Option<Vec<WireUuid>>,
2824 pub memory_ids: Option<Vec<WireMemoryId>>,
2829}
2830
2831#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2835pub struct SubscribeRequest {
2836 pub filter: SubscriptionFilter,
2837 pub include_history: bool,
2838 pub from_lsn: Option<u64>,
2839 pub max_inflight: u32,
2840 #[serde(skip_serializing_if = "Option::is_none", default)]
2845 pub act_as: Option<ActAs>,
2846}
2847
2848#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2851pub struct EdgeEventPayload {
2852 pub from_kind: u8,
2854 #[serde(with = "serde_bytes")]
2855 pub from_id: WireUuid,
2856 pub to_kind: u8,
2857 #[serde(with = "serde_bytes")]
2858 pub to_id: WireUuid,
2859 pub edge_kind_tag: u8,
2861 pub edge_kind_byte: u8,
2862 pub relation_type_id: Option<u32>,
2864 pub weight: f32,
2865 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
2866 pub relation_id: Option<WireUuid>,
2867 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
2868 pub superseded_relation_id: Option<WireUuid>,
2869 pub origin: u8,
2871}
2872
2873#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2875pub struct SubscriptionEvent {
2876 pub event_type: EventType,
2877 pub memory_id: WireMemoryId,
2878 pub session_id: WireSessionId,
2879 pub text: String,
2880 pub kind: MemoryKindWire,
2881 pub salience: f32,
2882 pub timestamp_unix_nanos: u64,
2883 pub lsn: u64,
2884 pub graph_payload: Option<GraphEventPayload>,
2886 pub edge_payload: Option<EdgeEventPayload>,
2888 pub stage_kind: Option<StageKind>,
2890 pub stage_outcome: Option<StageOutcome>,
2891 pub stage_payload: Option<StagePayload>,
2892}
2893
2894#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2897pub struct UnsubscribeRequest {
2898 pub target_stream_id: u32,
2899}
2900
2901#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2903pub struct UnsubscribeResponse {
2904 pub target_stream_id: u32,
2905 pub final_lsn: u64,
2906}
2907
2908#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2916pub enum GraphEventPayload {
2917 EntityCreated(EntityCreatedEvent),
2918 EntityUpdated(EntityUpdatedEvent),
2919 EntityRenamed(EntityRenamedEvent),
2920 EntityMerged(EntityMergedEvent),
2921 EntityUnmerged(EntityUnmergedEvent),
2922 EntityTombstoned(EntityTombstonedEvent),
2923 StatementCreated(StatementCreatedEvent),
2924 StatementSuperseded(StatementSupersededEvent),
2925 StatementTombstoned(StatementTombstonedEvent),
2926 RelationCreated(RelationCreatedEvent),
2927 RelationSuperseded(RelationSupersededEvent),
2928 RelationTombstoned(RelationTombstonedEvent),
2929 SchemaUpdated(SchemaUpdatedEvent),
2930}
2931
2932#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2934pub struct EntityCreatedEvent {
2935 #[serde(with = "serde_bytes")]
2936 pub entity_id: WireUuid,
2937 pub entity_type_id: u32,
2938 pub canonical_name: String,
2939}
2940
2941#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2944pub struct EntityUpdatedEvent {
2945 #[serde(with = "serde_bytes")]
2946 pub entity_id: WireUuid,
2947 pub entity_type_id: u32,
2948 pub canonical_name: String,
2949 pub embedding_version_changed: bool,
2950}
2951
2952#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2955pub struct EntityRenamedEvent {
2956 #[serde(with = "serde_bytes")]
2957 pub entity_id: WireUuid,
2958 pub old_canonical_name: String,
2959 pub new_canonical_name: String,
2960 pub old_moved_to_alias: bool,
2961}
2962
2963#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
2966pub struct EntityMergedEvent {
2967 #[serde(with = "serde_bytes")]
2968 pub survivor: WireUuid,
2969 #[serde(with = "serde_bytes")]
2970 pub merged: WireUuid,
2971 #[serde(with = "serde_bytes")]
2972 pub audit_id: WireUuid,
2973 pub confidence: f32,
2974 pub statements_rerouted: u32,
2975 pub relations_rerouted: u32,
2976}
2977
2978#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2981pub struct EntityUnmergedEvent {
2982 #[serde(with = "serde_bytes")]
2983 pub restored_entity_id: WireUuid,
2984 #[serde(with = "serde_bytes")]
2985 pub from_survivor: WireUuid,
2986 #[serde(with = "serde_bytes")]
2987 pub audit_id: WireUuid,
2988}
2989
2990#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2993pub struct EntityTombstonedEvent {
2994 #[serde(with = "serde_bytes")]
2995 pub entity_id: WireUuid,
2996 pub reason: String,
2997}
2998
2999#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3002pub struct StatementCreatedEvent {
3003 #[serde(with = "serde_bytes")]
3004 pub statement_id: WireUuid,
3005 pub kind: u8,
3007 #[serde(with = "serde_bytes")]
3008 pub subject: WireUuid,
3009 pub predicate: String,
3010 pub confidence: f32,
3011}
3012
3013#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
3016pub struct StatementSupersededEvent {
3017 #[serde(with = "serde_bytes")]
3018 pub old_statement_id: WireUuid,
3019 #[serde(with = "serde_bytes")]
3020 pub new_statement_id: WireUuid,
3021 #[serde(with = "serde_bytes")]
3022 pub chain_root: WireUuid,
3023}
3024
3025#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3028pub struct StatementTombstonedEvent {
3029 #[serde(with = "serde_bytes")]
3030 pub statement_id: WireUuid,
3031 pub reason: String,
3032}
3033
3034#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3037pub struct RelationCreatedEvent {
3038 #[serde(with = "serde_bytes")]
3039 pub relation_id: WireUuid,
3040 pub relation_type: String,
3041 #[serde(with = "serde_bytes")]
3042 pub from: WireUuid,
3043 #[serde(with = "serde_bytes")]
3044 pub to: WireUuid,
3045}
3046
3047#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
3050pub struct RelationSupersededEvent {
3051 #[serde(with = "serde_bytes")]
3052 pub old_relation_id: WireUuid,
3053 #[serde(with = "serde_bytes")]
3054 pub new_relation_id: WireUuid,
3055}
3056
3057#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3060pub struct RelationTombstonedEvent {
3061 #[serde(with = "serde_bytes")]
3062 pub relation_id: WireUuid,
3063 pub reason: String,
3064}
3065
3066#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3069pub struct SchemaUpdatedEvent {
3070 pub namespace: String,
3071 pub from_version: u32,
3072 pub to_version: u32,
3073 pub backward_compatible: bool,
3075}
3076
3077#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
3086pub struct GetCapabilitiesRequest {
3087 #[serde(skip_serializing_if = "Option::is_none", default)]
3090 pub act_as: Option<ActAs>,
3091}
3092
3093#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3095pub struct Capabilities {
3096 pub rerank: bool,
3098 pub llm_extractor: bool,
3100 pub classifier_extractor: bool,
3102 pub pattern_extractor: bool,
3104 pub schema_namespaces: Vec<String>,
3107 pub vector_dim: u16,
3109}
3110
3111#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3113pub struct GetCapabilitiesResponse {
3114 pub capabilities: Capabilities,
3115}
3116
3117#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
3126pub struct ExtractorListRequest {}
3127
3128#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3130pub struct ExtractorListItem {
3131 pub extractor_id: u32,
3132 pub namespace: String,
3133 pub name: String,
3134 pub kind: u8,
3136 pub schema_version: u32,
3137 pub created_at_unix_nanos: u64,
3138}
3139
3140#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3143pub struct ExtractorListResponseFrame {
3144 pub items: Vec<ExtractorListItem>,
3145 pub total: u32,
3146 pub is_final: bool,
3147}
3148
3149#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3155pub struct EntityView {
3156 #[serde(with = "serde_bytes")]
3157 pub entity_id: WireUuid,
3158 pub entity_type_id: u32,
3159 pub canonical_name: String,
3160 pub normalized_name: String,
3161 pub aliases: Vec<String>,
3162 pub attributes_blob: Vec<u8>,
3163 pub mention_count: u32,
3164 pub created_at_unix_nanos: u64,
3165 pub updated_at_unix_nanos: u64,
3166 #[serde(with = "serde_bytes")]
3168 pub merged_into: WireUuid,
3169 pub embedding_version: u32,
3170 pub flags: u32,
3171}
3172
3173#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3175pub struct EntityGetRequest {
3176 #[serde(with = "serde_bytes")]
3177 pub entity_id: WireUuid,
3178 #[serde(skip_serializing_if = "Option::is_none", default)]
3183 pub act_as: Option<ActAs>,
3184}
3185
3186#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3188pub struct EntityGetResponse {
3189 pub entity: EntityView,
3190 pub resolved_from: Vec<WireUuid>,
3198}
3199
3200#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3202pub struct EntityListRequest {
3203 pub entity_type_id: u32,
3205 pub name_prefix: String,
3207 pub mention_count_min: u32,
3208 pub include_tombstoned: bool,
3209 pub include_merged: bool,
3210 pub limit: u32,
3212 pub cursor: Vec<u8>,
3214 #[serde(skip_serializing_if = "Option::is_none", default)]
3219 pub act_as: Option<ActAs>,
3220}
3221
3222#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3224pub struct EntityListItem {
3225 pub entity: EntityView,
3226}
3227
3228#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3231pub struct EntityListResponseFrame {
3232 pub items: Vec<EntityListItem>,
3233 pub next_cursor: Vec<u8>,
3236 pub cumulative_count: u32,
3237 pub is_final: bool,
3238}
3239
3240#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3248pub struct EntityResolveRequest {
3249 pub candidate_name: String,
3250 pub resolution_context: String,
3251 pub entity_type_hint: u32,
3253 pub allow_create: bool,
3254 #[serde(with = "serde_bytes")]
3255 pub request_id: WireUuid,
3256 #[serde(skip_serializing_if = "Option::is_none", default)]
3261 pub act_as: Option<ActAs>,
3262}
3263
3264#[derive(
3267 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
3268)]
3269#[repr(u8)]
3270pub enum ResolutionOutcomeWire {
3271 Resolved = 1,
3272 Created = 2,
3273 Ambiguous = 3,
3274 NotFound = 4,
3275}
3276
3277#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3279pub struct EntityResolveResponse {
3280 pub outcome: ResolutionOutcomeWire,
3281 pub tier: u8,
3283 pub confidence: f32,
3284 #[serde(with = "serde_bytes")]
3287 pub resolved_entity: WireUuid,
3288 #[serde(with = "crate::wire::cbor::vec_byte_array16")]
3290 pub candidate_ids: Vec<WireUuid>,
3291 #[serde(with = "serde_bytes")]
3293 pub audit_id: WireUuid,
3294}
3295
3296#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3304pub struct StatementView {
3305 #[serde(with = "serde_bytes")]
3306 pub statement_id: WireUuid,
3307 pub kind: StatementKindWire,
3308 #[serde(with = "serde_bytes")]
3309 pub subject: WireUuid,
3310 #[serde(with = "serde_bytes")]
3311 pub subject_pending_audit_id: WireUuid,
3312 pub predicate: String,
3313 pub object: StatementObjectWire,
3314 pub confidence: f32,
3315 pub evidence: EvidenceRefWire,
3316 pub extractor_id: u32,
3317 pub extracted_at_unix_nanos: u64,
3318 pub schema_version: u32,
3319 pub valid_from_unix_nanos: u64,
3320 pub valid_to_unix_nanos: u64,
3321 pub event_at_unix_nanos: u64,
3322 pub version: u32,
3323 #[serde(with = "serde_bytes")]
3324 pub superseded_by: WireUuid,
3325 #[serde(with = "serde_bytes")]
3326 pub supersedes: WireUuid,
3327 #[serde(with = "serde_bytes")]
3328 pub chain_root: WireUuid,
3329 pub tombstoned: bool,
3330 pub tombstoned_at_unix_nanos: u64,
3331 pub tombstone_reason: u8,
3332 pub flags: u32,
3333 pub is_stateful: bool,
3335}
3336
3337#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3339pub struct StatementGetRequest {
3340 #[serde(with = "serde_bytes")]
3341 pub statement_id: WireUuid,
3342 pub follow_supersession: bool,
3345 #[serde(skip_serializing_if = "Option::is_none", default)]
3350 pub act_as: Option<ActAs>,
3351}
3352
3353#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3355pub struct StatementGetResponse {
3356 pub statement: StatementView,
3357 pub returned_via_supersession: bool,
3359}
3360
3361#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3365pub struct StatementListRequest {
3366 #[serde(with = "serde_bytes")]
3367 pub subject: WireUuid,
3368 pub predicate: String,
3369 pub kind: u8,
3370 pub min_confidence: f32,
3371 pub time_range_start_unix_nanos: u64,
3372 pub time_range_end_unix_nanos: u64,
3373 pub only_current: bool,
3374 pub include_tombstoned: bool,
3375 pub limit: u32,
3376 pub cursor: Vec<u8>,
3377 #[serde(skip_serializing_if = "Option::is_none", default)]
3382 pub act_as: Option<ActAs>,
3383}
3384
3385#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3387pub struct StatementListResponseFrame {
3388 pub items: Vec<StatementView>,
3389 pub next_cursor: Vec<u8>,
3390 pub cumulative_count: u32,
3391 pub is_final: bool,
3392}
3393
3394#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3401pub struct RelationView {
3402 #[serde(with = "serde_bytes")]
3403 pub relation_id: WireUuid,
3404 #[serde(with = "serde_bytes")]
3405 pub chain_root: WireUuid,
3406 pub relation_type: String,
3407 #[serde(with = "serde_bytes")]
3408 pub from_entity: WireUuid,
3409 #[serde(with = "serde_bytes")]
3410 pub to_entity: WireUuid,
3411 pub properties_blob: Vec<u8>,
3412 pub evidence: EvidenceRefWire,
3413 pub extractor_id: u32,
3414 pub extracted_at_unix_nanos: u64,
3415 pub confidence: f32,
3416 pub valid_from_unix_nanos: u64,
3417 pub valid_to_unix_nanos: u64,
3418 pub version: u32,
3419 #[serde(with = "serde_bytes")]
3420 pub superseded_by: WireUuid,
3421 #[serde(with = "serde_bytes")]
3422 pub supersedes: WireUuid,
3423 pub tombstoned: bool,
3424 pub tombstoned_at_unix_nanos: u64,
3425 pub flags: u32,
3426}
3427
3428#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3431pub struct RelationListFromRequest {
3432 #[serde(with = "serde_bytes")]
3433 pub from_entity: WireUuid,
3434 pub relation_type_filter: String,
3435 pub time_range_start_unix_nanos: u64,
3436 pub time_range_end_unix_nanos: u64,
3437 pub include_superseded: bool,
3438 pub include_tombstoned: bool,
3439 pub limit: u32,
3440 pub cursor: Vec<u8>,
3441 #[serde(skip_serializing_if = "Option::is_none", default)]
3444 pub act_as: Option<ActAs>,
3445}
3446
3447#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3449pub struct RelationListFromResponseFrame {
3450 pub items: Vec<RelationView>,
3451 pub next_cursor: Vec<u8>,
3452 pub cumulative_count: u32,
3453 pub is_final: bool,
3454}
3455
3456#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3459pub struct RelationListToRequest {
3460 #[serde(with = "serde_bytes")]
3461 pub to_entity: WireUuid,
3462 pub relation_type_filter: String,
3463 pub time_range_start_unix_nanos: u64,
3464 pub time_range_end_unix_nanos: u64,
3465 pub include_superseded: bool,
3466 pub include_tombstoned: bool,
3467 pub limit: u32,
3468 pub cursor: Vec<u8>,
3469 #[serde(skip_serializing_if = "Option::is_none", default)]
3472 pub act_as: Option<ActAs>,
3473}
3474
3475#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3477pub struct RelationListToResponseFrame {
3478 pub items: Vec<RelationView>,
3479 pub next_cursor: Vec<u8>,
3480 pub cumulative_count: u32,
3481 pub is_final: bool,
3482}
3483
3484#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3490pub struct SchemaGetRequest {
3491 pub namespace: String,
3492 pub version: u32,
3493 #[serde(skip_serializing_if = "Option::is_none", default)]
3495 pub act_as: Option<ActAs>,
3496}
3497
3498#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3500pub struct SchemaGetResponse {
3501 pub namespace: String,
3502 pub schema_version: u32,
3503 pub schema_document: String,
3505 pub source_blob: Vec<u8>,
3507 pub uploaded_at_unix_nanos: u64,
3508 pub validator_version: u32,
3509}
3510
3511#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3513pub struct SchemaListRequest {
3514 pub namespace: String,
3515 pub limit: u32,
3516 pub cursor: Vec<u8>,
3517 #[serde(skip_serializing_if = "Option::is_none", default)]
3519 pub act_as: Option<ActAs>,
3520}
3521
3522#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3524pub struct SchemaListItemWire {
3525 pub schema_version: u32,
3526 pub uploaded_at_unix_nanos: u64,
3527 pub validator_version: u32,
3528 pub has_source_text: bool,
3529}
3530
3531#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3533pub struct SchemaListResponseFrame {
3534 pub namespace: String,
3535 pub items: Vec<SchemaListItemWire>,
3536 pub total: u32,
3537 pub next_cursor: Vec<u8>,
3538 pub is_final: bool,
3539}
3540
3541#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3543pub struct SchemaValidateRequest {
3544 pub schema_document: String,
3545 #[serde(skip_serializing_if = "Option::is_none", default)]
3547 pub act_as: Option<ActAs>,
3548}
3549
3550#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3552pub struct SchemaValidateResponse {
3553 pub namespace: String,
3556 pub would_be_version: u32,
3558 pub validation_errors: Vec<SchemaValidationErrorWire>,
3559}
3560
3561#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
3575pub struct ByeRequest {
3576 pub reason: Option<String>,
3583}
3584
3585#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
3587pub struct PingRequest {
3588 pub client_timestamp_unix_nanos: u64,
3589}
3590
3591#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
3594pub struct PongResponse {
3595 pub client_timestamp_unix_nanos: u64,
3596 pub server_timestamp_unix_nanos: u64,
3597}
3598
3599#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
3603pub struct ServerPingResponse {
3604 pub server_timestamp_unix_nanos: u64,
3605}
3606
3607#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
3610pub struct ClientPongRequest {
3611 pub server_timestamp_unix_nanos: u64,
3612 pub client_timestamp_unix_nanos: u64,
3613}
3614
3615#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3623pub struct RelationGetRequest {
3624 #[serde(with = "serde_bytes")]
3625 pub relation_id: WireUuid,
3626 pub follow_supersession: bool,
3627 #[serde(skip_serializing_if = "Option::is_none", default)]
3630 pub act_as: Option<ActAs>,
3631}
3632
3633#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3636pub struct RelationGetResponse {
3637 pub relation: RelationView,
3638 pub returned_via_supersession: bool,
3639}
3640
3641#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3643pub struct RelationSupersedeRequest {
3644 #[serde(with = "serde_bytes")]
3645 pub old_relation_id: WireUuid,
3646 pub new_relation: RelationCreateRequest,
3647 #[serde(with = "serde_bytes")]
3648 pub request_id: WireUuid,
3649}
3650
3651#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
3653pub struct RelationSupersedeResponse {
3654 #[serde(with = "serde_bytes")]
3655 pub new_relation_id: WireUuid,
3656 pub version: u32,
3657}
3658
3659#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3661pub struct RelationTombstoneRequest {
3662 #[serde(with = "serde_bytes")]
3663 pub relation_id: WireUuid,
3664 pub reason: String,
3665 #[serde(with = "serde_bytes")]
3666 pub request_id: WireUuid,
3667}
3668
3669#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
3671pub struct RelationTombstoneResponse {
3672 pub tombstoned_at_unix_nanos: u64,
3673}
3674
3675#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3677pub struct TraversalStepWire {
3678 #[serde(with = "serde_bytes")]
3679 pub relation_id: WireUuid,
3680 #[serde(with = "serde_bytes")]
3681 pub from: WireUuid,
3682 #[serde(with = "serde_bytes")]
3683 pub to: WireUuid,
3684 pub relation_type: String,
3685 pub depth: u32,
3686}
3687
3688#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3690pub struct TraversalPathWire {
3691 pub steps: Vec<TraversalStepWire>,
3692}
3693
3694#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3698pub struct RelationTraverseRequest {
3699 #[serde(with = "serde_bytes")]
3700 pub start_entity: WireUuid,
3701 pub relation_types: Vec<String>,
3702 pub direction: u8,
3703 pub max_depth: u32,
3704 pub max_nodes: u32,
3705 pub time_at_unix_nanos: u64,
3706 pub include_superseded: bool,
3707 #[serde(with = "serde_bytes")]
3708 pub request_id: WireUuid,
3709 #[serde(skip_serializing_if = "Option::is_none", default)]
3714 pub act_as: Option<ActAs>,
3715}
3716
3717#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3720pub struct RelationTraverseResponseFrame {
3721 pub paths: Vec<TraversalPathWire>,
3722 pub total_paths: u32,
3723 pub truncated: bool,
3724 pub is_final: bool,
3725}
3726
3727#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3733pub struct QueryExplainRequest {
3734 pub query: QueryRequest,
3735}
3736
3737#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3739pub struct QueryExplainResponse {
3740 pub plan_text: String,
3741 pub estimated_cost_ms: f32,
3742}
3743
3744#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3746pub struct QueryTraceRequest {
3747 pub query: QueryRequest,
3748}
3749
3750#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3752pub struct QueryTraceResponse {
3753 pub trace_text: String,
3754 pub total_latency_ms: f64,
3755}
3756
3757#[cfg(test)]
3758mod error_code_forward_compat_tests {
3759 use super::*;
3760
3761 #[test]
3762 fn known_codes_round_trip_through_from_raw() {
3763 assert_eq!(
3764 ErrorCodeWire::from_raw(0x0033),
3765 ErrorCodeWire::ActAsDenied,
3766 "an existing code must still decode to its own variant"
3767 );
3768 assert_eq!(
3769 ErrorCodeWire::from_raw(0x0066),
3770 ErrorCodeWire::LlmCredentialMissing
3771 );
3772 assert_eq!(
3773 ErrorCodeWire::from_raw(0x0095),
3774 ErrorCodeWire::LlmCredentialUnavailable
3775 );
3776 }
3777
3778 #[test]
3779 fn an_unrecognised_code_decodes_to_unknown_instead_of_failing() {
3780 assert_eq!(ErrorCodeWire::from_raw(0xDEAD), ErrorCodeWire::Unknown);
3786 assert_eq!(ErrorCodeWire::from_raw(0x7FFF), ErrorCodeWire::Unknown);
3787 }
3788
3789 #[test]
3790 fn an_error_response_carrying_an_unknown_code_still_decodes() {
3791 let json = serde_json::json!({
3795 "code": 0xDEAD_u16,
3796 "category": 8,
3797 "message": "from a newer server",
3798 "details": null,
3799 "retry_after_ms": null,
3800 });
3801 let decoded: ErrorResponse =
3802 serde_json::from_value(json).expect("an unknown code must not break the frame");
3803 assert!(decoded.code_is_unknown());
3804 assert_eq!(decoded.category, ErrorCategoryWire::Unavailable);
3805 assert_eq!(decoded.message, "from a newer server");
3806 }
3807}