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 #[serde(default)]
581 pub edges: Vec<MemoryEdgeWire>,
582}
583
584#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
589pub struct MemoryEdgeWire {
590 pub kind: EdgeKindWire,
591 pub direction: EdgeDirectionWire,
592 pub peer: WireMemoryId,
594 pub weight: f32,
595 pub created_at_unix_nanos: u64,
596 #[serde(default)]
597 pub annotation: Option<String>,
598}
599
600#[derive(
602 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
603)]
604#[repr(u8)]
605pub enum EdgeDirectionWire {
606 Outgoing = 0,
607 Incoming = 1,
608}
609
610#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
617pub enum AnswerKindWire {
618 Single,
619 Many,
620 None,
621}
622
623#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
632pub enum RecallScopeWire {
633 #[default]
635 Space,
636 Namespace,
638}
639
640#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
642pub struct RecallRequest {
643 pub cue_text: String,
644 pub subject_name: String,
645 pub max_results: u32,
646 pub confidence_threshold: f32,
647 pub session_filter: Option<Vec<WireSessionId>>,
648 pub age_bound_unix_nanos: Option<u64>,
649 pub as_of_record_time_unix_nanos: Option<u64>,
650 pub kind_filter: Option<Vec<MemoryKindWire>>,
651 pub salience_floor: f32,
652 pub include_edges: bool,
653 pub include_graph: bool,
654 pub include_text: bool,
655 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
656 pub request_id: Option<WireUuid>,
657 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
658 pub txn_id: Option<WireUuid>,
659 #[serde(default)]
663 pub trace: bool,
664 #[serde(skip_serializing_if = "Option::is_none", default)]
667 pub act_as: Option<ActAs>,
668 #[serde(default)]
672 pub scope: RecallScopeWire,
673}
674
675#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
677pub struct RecallResponseFrame {
678 pub answer_kind: AnswerKindWire,
679 pub memories: Vec<MemoryResult>,
680 pub is_final: bool,
681 pub cumulative_count: u32,
682 pub estimated_remaining: Option<u32>,
683 #[serde(skip_serializing_if = "Option::is_none", default)]
686 pub trace: Option<RecallTrace>,
687}
688
689#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
692pub struct RecallTrace {
693 pub retrievers: Vec<RecallTraceRetriever>,
694 pub filter_chain: RecallTraceFilterChain,
695 pub rerank: Option<RecallTraceRerank>,
696 pub total_latency_ms: f64,
697 pub fusion: Option<RecallTraceFusion>,
701}
702
703#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
705pub struct RecallTraceRetriever {
706 pub name: RetrieverNameWire,
707 pub status: RecallTraceRetrieverStatus,
708 pub status_detail: String,
710 pub latency_ms: f64,
711 pub candidate_count: u32,
712 pub candidates: Vec<RecallTraceCandidate>,
715}
716
717#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
719pub struct RecallTraceCandidate {
720 pub item_id: WireMemoryId,
723 pub kind: RecallCandidateKind,
725 pub text: String,
728 pub score: f32,
730}
731
732#[derive(
736 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
737)]
738#[repr(u8)]
739pub enum RecallCandidateKind {
740 Memory = 0,
741 Statement = 1,
742 Entity = 2,
743 Relation = 3,
744}
745
746#[derive(
748 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
749)]
750#[repr(u8)]
751pub enum RecallTraceRetrieverStatus {
752 Success = 0,
753 Skipped = 1,
754 Timeout = 2,
755 Failure = 3,
756}
757
758#[derive(
766 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
767)]
768#[repr(u8)]
769pub enum RankedItemKindWire {
770 Memory = 0,
771 Statement = 1,
772 Entity = 2,
773 Relation = 3,
774}
775
776#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
782pub struct RecallTraceDroppedId {
783 pub kind: RankedItemKindWire,
784 pub id: u128,
785}
786
787#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
789pub struct RecallTraceFilterChain {
790 pub before: u32,
791 pub after_type: u32,
792 pub after_temporal: u32,
793 pub after_confidence: u32,
794 pub after_tombstone: u32,
795 pub after_supersession: u32,
796 pub after_as_of: u32,
797 pub after_limit: u32,
798 pub dropped_by_type: Vec<WireMemoryId>,
801 pub dropped_by_temporal: Vec<WireMemoryId>,
804 pub dropped_by_confidence: Vec<WireMemoryId>,
807 pub dropped_by_tombstone: Vec<WireMemoryId>,
810 pub dropped_by_supersession: Vec<RecallTraceDroppedId>,
815 pub dropped_by_as_of: Vec<RecallTraceDroppedId>,
819 pub dropped_by_limit: Vec<RecallTraceDroppedId>,
823}
824
825#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
827pub struct RecallTraceRerank {
828 pub applied: bool,
829 pub candidates: u32,
830 pub latency_ms: f64,
831 pub before_order: Vec<WireMemoryId>,
834 pub after_order: Vec<WireMemoryId>,
837}
838
839#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
843pub struct RecallTraceFusion {
844 pub items: Vec<RecallTraceFusionItem>,
845}
846
847#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
850pub struct RecallTraceFusionItem {
851 pub memory_id: WireMemoryId,
852 pub rrf_score: f32,
853 pub lane_scores: Vec<(RetrieverNameWire, f32)>,
854}
855
856#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
858pub struct MemoryResult {
859 pub memory_id: WireMemoryId,
860 pub text: String,
861 pub similarity_score: f32,
862 pub confidence: f32,
863 pub salience: f32,
864 pub kind: MemoryKindWire,
865 #[serde(with = "serde_bytes")]
866 pub space_id: WireUuid,
867 pub session_id: WireSessionId,
868 pub created_at_unix_nanos: u64,
869 pub last_accessed_at_unix_nanos: u64,
870 pub edges: Option<Vec<EdgeView>>,
871 pub contributing_retrievers: Vec<RetrieverNameWire>,
872 pub fused_score: f32,
873 pub rerank_score: Option<f32>,
874 pub salience_initial: f32,
875 pub access_count: u32,
876 pub lsn: u64,
877 pub flags: u32,
878 pub consolidated_at_unix_nanos: Option<u64>,
879 pub occurred_at_unix_nanos: Option<u64>,
880 pub edges_out_count: u32,
881 pub edges_in_count: u32,
882 pub graph: Option<GraphEnrichment>,
883}
884
885#[derive(
887 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
888)]
889#[repr(u8)]
890pub enum RetrieverNameWire {
891 Semantic = 0,
892 Lexical = 1,
893 Graph = 2,
894}
895
896#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
898pub struct EdgeView {
899 pub target: WireMemoryId,
900 pub kind: EdgeKindWire,
901 pub weight: f32,
902}
903
904#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
906pub struct GraphEnrichment {
907 pub entities: Vec<EnrichedEntity>,
908 pub statements: Vec<EnrichedStatement>,
909 pub relations: Vec<EnrichedRelation>,
910}
911
912#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
915pub struct EnrichedEntity {
916 #[serde(with = "serde_bytes")]
917 pub id: [u8; 16],
918 pub name: String,
919 pub type_qname: String,
920}
921
922#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
926pub struct EnrichedStatement {
927 #[serde(with = "serde_bytes")]
928 pub id: [u8; 16],
929 pub subject_name: String,
930 pub predicate: String,
931 pub object_label: String,
932 #[serde(default, with = "crate::wire::cbor::opt_byte_array16")]
941 pub object_entity_id: Option<[u8; 16]>,
942 pub confidence: f32,
943 #[serde(skip_serializing_if = "Option::is_none", default)]
947 pub event_at_unix_nanos: Option<u64>,
948}
949
950#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
953pub struct EnrichedRelation {
954 pub from_name: String,
955 pub predicate: String,
956 pub to_name: String,
957}
958
959#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
965pub struct ForgetRequest {
966 pub memory_id: WireMemoryId,
967 pub mode: ForgetMode,
968 #[serde(with = "serde_bytes")]
969 pub request_id: WireUuid,
970 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
971 pub txn_id: Option<WireUuid>,
972 #[serde(skip_serializing_if = "Option::is_none", default)]
975 pub act_as: Option<ActAs>,
976}
977
978#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
980pub struct ForgetResponse {
981 pub memory_id: WireMemoryId,
982 pub was_already_forgotten: bool,
983 pub edges_removed: u32,
984}
985
986#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
992pub struct LinkRequest {
993 pub source: WireMemoryId,
994 pub target: WireMemoryId,
995 pub kind: EdgeKindWire,
996 pub weight: f32,
998 #[serde(with = "serde_bytes")]
999 pub request_id: WireUuid,
1000 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
1001 pub txn_id: Option<WireUuid>,
1002 #[serde(skip_serializing_if = "Option::is_none", default)]
1005 pub act_as: Option<ActAs>,
1006}
1007
1008#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
1010pub struct LinkResponse {
1011 pub source: WireMemoryId,
1012 pub target: WireMemoryId,
1013 pub kind: EdgeKindWire,
1014 pub weight: f32,
1015 pub created_at_unix_nanos: u64,
1016 pub already_existed: bool,
1019}
1020
1021#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1024pub struct UnlinkRequest {
1025 pub source: WireMemoryId,
1026 pub target: WireMemoryId,
1027 pub kind: EdgeKindWire,
1028 #[serde(with = "serde_bytes")]
1029 pub request_id: WireUuid,
1030 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
1031 pub txn_id: Option<WireUuid>,
1032 #[serde(skip_serializing_if = "Option::is_none", default)]
1035 pub act_as: Option<ActAs>,
1036}
1037
1038#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
1040pub struct UnlinkResponse {
1041 pub source: WireMemoryId,
1042 pub target: WireMemoryId,
1043 pub kind: EdgeKindWire,
1044 pub removed: bool,
1047}
1048
1049#[derive(
1056 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1057)]
1058#[repr(u8)]
1059pub enum MemoryListSortWire {
1060 Created = 0,
1061 Salience = 1,
1062 Occurred = 2,
1063 LastAccessed = 3,
1064}
1065
1066#[derive(
1068 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1069)]
1070#[repr(u8)]
1071pub enum MemoryListDirWire {
1072 Asc = 0,
1073 Desc = 1,
1074}
1075
1076#[derive(
1079 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1080)]
1081#[repr(u8)]
1082pub enum MemoryListTimeAxisWire {
1083 Created = 0,
1084 Occurred = 1,
1085}
1086
1087#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1094pub struct MemoryListRequest {
1095 pub sort: MemoryListSortWire,
1096 pub dir: MemoryListDirWire,
1097 pub limit: u32,
1099 pub cursor: Vec<u8>,
1101 pub kinds: Vec<MemoryKindWire>,
1103 pub include_tombstoned: bool,
1106 pub time_axis: MemoryListTimeAxisWire,
1108 pub from_unix_nanos: u64,
1110 pub to_unix_nanos: u64,
1112 pub salience_min: f32,
1114 pub salience_max: f32,
1116 pub text_contains: String,
1118 #[serde(skip_serializing_if = "Option::is_none", default)]
1123 pub act_as: Option<ActAs>,
1124}
1125
1126#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1129pub struct MemoryListItem {
1130 #[serde(with = "serde_bytes")]
1131 pub memory_id: [u8; 16],
1132 #[serde(with = "serde_bytes")]
1134 pub space_id: [u8; 16],
1135 pub session_id: WireSessionId,
1137 pub text: String,
1138 pub kind: u8,
1140 pub state: u8,
1142 pub created_at_unix_nanos: u64,
1143 pub occurred_at_unix_nanos: u64,
1145 pub last_accessed_at_unix_nanos: u64,
1146 pub salience: f32,
1148 pub access_count: u32,
1149 #[serde(with = "serde_bytes")]
1150 pub source_request_id: [u8; 16],
1151 pub statement_count: u32,
1152 pub entity_count: u32,
1153 pub relation_count: u32,
1154}
1155
1156#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1160pub struct MemoryListResponseFrame {
1161 pub items: Vec<MemoryListItem>,
1162 pub next_cursor: Vec<u8>,
1163 pub cumulative_count: u32,
1164 pub is_final: bool,
1165}
1166
1167#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1174pub struct GraphNode {
1175 #[serde(with = "serde_bytes")]
1176 pub id: [u8; 16],
1177 pub kind: u8,
1178 pub label: String,
1179 pub type_qname: String,
1181}
1182
1183#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1189pub struct GraphEdge {
1190 #[serde(with = "serde_bytes")]
1191 pub from_id: [u8; 16],
1192 #[serde(with = "serde_bytes")]
1193 pub to_id: [u8; 16],
1194 pub kind: u8,
1195 pub label: String,
1197}
1198
1199#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1206pub struct GraphFetchRequest {
1207 pub limit: u32,
1209 pub cursor: Vec<u8>,
1211 pub include_statements: bool,
1213 pub include_memories: bool,
1215 pub include_memory_edges: bool,
1221 pub include_tombstoned: bool,
1223 #[serde(skip_serializing_if = "Option::is_none", default)]
1226 pub act_as: Option<ActAs>,
1227}
1228
1229#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1233pub struct GraphFetchResponseFrame {
1234 pub nodes: Vec<GraphNode>,
1235 pub edges: Vec<GraphEdge>,
1236 pub next_cursor: Vec<u8>,
1237 pub is_final: bool,
1238}
1239
1240#[derive(
1246 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1247)]
1248#[repr(u8)]
1249pub enum PlanStrategy {
1250 Auto = 0,
1251 AStar = 1,
1252 Mcts = 2,
1253 AttractorRollout = 3,
1254}
1255
1256#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1259pub enum PlanState {
1260 ByMemoryId(WireMemoryId),
1261 ByText(String),
1262 ByVector { offset: u32, dim: u16 },
1263}
1264
1265#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
1267pub struct PlanBudget {
1268 pub max_steps: u32,
1269 pub max_wall_time_ms: u32,
1270 pub max_branches_explored: u32,
1271}
1272
1273#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1275pub struct PlanRequest {
1276 pub start: PlanState,
1277 pub goal: PlanState,
1278 pub budget: PlanBudget,
1279 pub strategy_hint: Option<PlanStrategy>,
1280 pub session_filter: Option<Vec<WireSessionId>>,
1281 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
1282 pub request_id: Option<WireUuid>,
1283 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
1284 pub txn_id: Option<WireUuid>,
1285 #[serde(default)]
1292 pub trace: bool,
1293 #[serde(skip_serializing_if = "Option::is_none", default)]
1296 pub act_as: Option<ActAs>,
1297}
1298
1299#[derive(
1301 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1302)]
1303#[repr(u8)]
1304pub enum PlanStatus {
1305 GoalReached = 0,
1306 BudgetExhausted = 1,
1307 NoPathFound = 2,
1308 Cancelled = 3,
1309}
1310
1311#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1314pub enum TransitionKind {
1315 Initial,
1316 Causal,
1317 Temporal,
1318 Similarity,
1319 Other(String),
1320}
1321
1322#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1324pub struct PlanStep {
1325 pub step_index: u32,
1326 pub memory_id: WireMemoryId,
1327 pub text: String,
1328 pub transition_kind: TransitionKind,
1329 pub confidence: f32,
1330 pub estimated_distance_to_goal: f32,
1331}
1332
1333#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1336pub struct PlanResponseFrame {
1337 pub steps: Vec<PlanStep>,
1338 pub is_final: bool,
1339 pub plan_status: Option<PlanStatus>,
1340 #[serde(skip_serializing_if = "Option::is_none", default)]
1345 pub trace: Option<PlanTrace>,
1346}
1347
1348#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1356pub struct PlanTrace {
1357 pub explored: Vec<PlanTraceNode>,
1359 pub meeting_points: Vec<PlanTraceMeetingPoint>,
1362}
1363
1364#[derive(
1367 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1368)]
1369#[repr(u8)]
1370pub enum PlanTraceDirection {
1371 Forward = 0,
1373 Backward = 1,
1375}
1376
1377#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1379pub struct PlanTraceNode {
1380 pub memory_id: WireMemoryId,
1381 pub text: String,
1382 pub direction: PlanTraceDirection,
1383 pub depth: u32,
1384 pub parent_edge: Option<WireMemoryId>,
1388 pub alignment_score: Option<f32>,
1391}
1392
1393#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1396pub struct PlanTraceMeetingPoint {
1397 pub memory_id: WireMemoryId,
1398 pub text: String,
1399 pub included_in_result: bool,
1403}
1404
1405#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1411pub enum ObservationInput {
1412 ByMemoryId(WireMemoryId),
1413 ByText(String),
1414}
1415
1416#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1418pub struct ReasonRequest {
1419 pub observation: ObservationInput,
1420 pub depth: u32,
1421 pub confidence_threshold: f32,
1422 pub session_filter: Option<Vec<WireSessionId>>,
1423 pub max_inferences: u32,
1424 pub budget_wall_time_ms: u32,
1425 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
1426 pub request_id: Option<WireUuid>,
1427 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
1428 pub txn_id: Option<WireUuid>,
1429 #[serde(default)]
1437 pub trace: bool,
1438 #[serde(skip_serializing_if = "Option::is_none", default)]
1441 pub act_as: Option<ActAs>,
1442}
1443
1444#[derive(
1446 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1447)]
1448#[repr(u8)]
1449pub enum ReasonStatus {
1450 Complete = 0,
1451 BudgetExhausted = 1,
1452 DepthLimitReached = 2,
1453 Cancelled = 3,
1454}
1455
1456#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1459pub enum InferenceKind {
1460 CausalExplanation,
1461 EvidenceAccumulation,
1462 AnalogicalInference,
1463 Other(String),
1464}
1465
1466#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1468pub struct InferenceStep {
1469 pub step_index: u32,
1470 pub claim: String,
1471 pub supporting_memories: Vec<WireMemoryId>,
1472 pub contradicting_memories: Vec<WireMemoryId>,
1473 pub confidence: f32,
1474 pub inference_kind: InferenceKind,
1475}
1476
1477#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1480pub struct ReasonResponseFrame {
1481 pub inferences: Vec<InferenceStep>,
1482 pub is_final: bool,
1483 pub reason_status: Option<ReasonStatus>,
1484 #[serde(skip_serializing_if = "Option::is_none", default)]
1489 pub trace: Option<ReasonTrace>,
1490}
1491
1492#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1499pub struct ReasonTrace {
1500 pub base: ReasonTraceBase,
1503 pub walk: ReasonTraceWalk,
1506 pub scoring: Vec<ReasonTraceScoreBreakdown>,
1508 pub centroid: ReasonTraceCentroid,
1511}
1512
1513#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1515pub struct ReasonTraceBase {
1516 pub candidates: Vec<ReasonTraceCandidate>,
1517}
1518
1519#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1521pub struct ReasonTraceCandidate {
1522 pub memory_id: WireMemoryId,
1523 pub text: String,
1524 pub score: f32,
1525}
1526
1527#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1530pub struct ReasonTraceWalk {
1531 pub considered: Vec<ReasonTraceEdgeCandidate>,
1534 pub dropped_by_edge_kind: Vec<ReasonTraceEdgeCandidate>,
1536 pub dropped_by_tombstone: Vec<ReasonTraceIdWithText>,
1538 pub dropped_by_visited: Vec<ReasonTraceIdWithText>,
1540 pub dropped_by_confidence: Vec<ReasonTraceScoredId>,
1542 pub dropped_by_max_supporting: Vec<ReasonTraceIdWithText>,
1544 pub dropped_by_max_contradicting: Vec<ReasonTraceIdWithText>,
1546}
1547
1548#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1550pub struct ReasonTraceEdgeCandidate {
1551 pub memory_id: WireMemoryId,
1552 pub text: String,
1553 pub edge_kind: EdgeKindWire,
1554 pub depth: u32,
1555 pub from_memory_id: WireMemoryId,
1556 pub raw_score: f32,
1557}
1558
1559#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1564pub struct ReasonTraceIdWithText {
1565 pub memory_id: WireMemoryId,
1566 pub text: String,
1567}
1568
1569#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1571pub struct ReasonTraceScoredId {
1572 pub memory_id: WireMemoryId,
1573 pub text: String,
1574 pub score: f32,
1575}
1576
1577#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1580pub struct ReasonTraceScoreBreakdown {
1581 pub memory_id: WireMemoryId,
1582 pub text: String,
1583 pub base_similarity: f32,
1584 pub decay: f32,
1585 pub weight_product: f32,
1586 pub alignment: f32,
1587 pub analogical_fit: f32,
1592 pub final_score: f32,
1593}
1594
1595#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1600pub struct ReasonTraceCentroid {
1601 pub computed: bool,
1602 pub skipped_reason: Option<String>,
1604}
1605
1606#[derive(
1612 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
1613)]
1614#[repr(u8)]
1615pub enum ErrorCategoryWire {
1616 Protocol = 0,
1617 Authentication = 1,
1618 Authorization = 2,
1619 Validation = 3,
1620 NotFound = 4,
1621 Conflict = 5,
1622 ResourceExhausted = 6,
1623 Internal = 7,
1624 Unavailable = 8,
1625}
1626
1627#[derive(Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr)]
1647#[repr(u16)]
1648pub enum ErrorCodeWire {
1649 BadMagic = 0x0001,
1651 BadHeaderCrc = 0x0002,
1652 BadPayloadCrc = 0x0003,
1653 BadOpcode = 0x0004,
1654 BadVersion = 0x0005,
1655 BadFrame = 0x0006,
1656 OversizePayload = 0x0007,
1657 ReservedFieldNonZero = 0x0008,
1658 BadFlagCombination = 0x0009,
1659 MalformedPayload = 0x000A,
1660 MalformedVector = 0x000B,
1661 VersionNotSupported = 0x0020,
1663 NoSuchAuthMethod = 0x0021,
1664 Unauthenticated = 0x0022,
1665 NotAuthenticated = 0x0023,
1666 AuthBackendUnavailable = 0x0024,
1667 SessionExpired = 0x0025,
1668 PermissionDenied = 0x0030,
1670 AdminPermissionRequired = 0x0031,
1671 WrongShard = 0x0032,
1672 ActAsDenied = 0x0033,
1673 InvalidArgument = 0x0040,
1675 MissingRequiredField = 0x0041,
1676 TextTooLarge = 0x0042,
1677 TextEmpty = 0x0043,
1678 BadSessionId = 0x0044,
1679 BadMemoryKind = 0x0045,
1680 BadEdgeKind = 0x0046,
1681 BadStrategyHint = 0x0047,
1682 TopKOutOfRange = 0x0048,
1683 BudgetTooLarge = 0x0049,
1684 BadModelFingerprint = 0x004A,
1685 PredicateNotInSchema = 0x004B,
1686 RelationTypeNotInSchema = 0x004C,
1687 MemoryNotFound = 0x0050,
1689 ContextNotFound = 0x0051,
1690 SubscriptionNotFound = 0x0052,
1691 SnapshotNotFound = 0x0053,
1692 TxnNotFound = 0x0054,
1693 IdempotencyConflict = 0x0060,
1695 TransactionConflict = 0x0061,
1696 TransactionTimeout = 0x0062,
1697 StreamIdInUse = 0x0063,
1698 SubscriptionLsnTooOld = 0x0064,
1699 CardinalityViolation = 0x0065,
1700 LlmCredentialMissing = 0x0066,
1703 OutOfSlots = 0x0070,
1705 OutOfDisk = 0x0071,
1706 OutOfMemory = 0x0072,
1707 RateLimited = 0x0073,
1708 StreamLimitExceeded = 0x0074,
1709 ConnectionLimitExceeded = 0x0075,
1710 TransactionLimitExceeded = 0x0076,
1711 TransactionTooLarge = 0x0077,
1712 Internal = 0x0080,
1714 StorageError = 0x0081,
1715 IndexError = 0x0082,
1716 EmbeddingError = 0x0083,
1717 MetadataError = 0x0084,
1718 Cancelled = 0x0085,
1719 ShardUnavailable = 0x0090,
1721 Overloaded = 0x0091,
1722 Restarting = 0x0092,
1723 Maintenance = 0x0093,
1724 RetrieverDegraded = 0x0094,
1725 LlmCredentialUnavailable = 0x0095,
1728 SchemaInvalid = 0x0120,
1730 SchemaMigrationRequired = 0x0121,
1731 EntityNotFound = 0x0130,
1732 EntityTypeMismatch = 0x0131,
1733 EntityAmbiguous = 0x0132,
1734 EntityMergeConflict = 0x0133,
1735 StatementNotFound = 0x0140,
1736 StatementObjectTypeMismatch = 0x0141,
1737 StatementContradictsExisting = 0x0142,
1738 QueryTimeout = 0x0160,
1739 QueryOverBudget = 0x0161,
1740 ExtractorDisabled = 0x0170,
1741 ExtractorBudgetExceeded = 0x0171,
1742 ExtractionFailed = 0x0172,
1743 Unknown = 0xFFFF,
1746}
1747
1748impl ErrorCodeWire {
1749 #[must_use]
1754 pub fn from_raw(raw: u16) -> Self {
1755 match raw {
1756 0x0001 => Self::BadMagic,
1757 0x0002 => Self::BadHeaderCrc,
1758 0x0003 => Self::BadPayloadCrc,
1759 0x0004 => Self::BadOpcode,
1760 0x0005 => Self::BadVersion,
1761 0x0006 => Self::BadFrame,
1762 0x0007 => Self::OversizePayload,
1763 0x0008 => Self::ReservedFieldNonZero,
1764 0x0009 => Self::BadFlagCombination,
1765 0x000A => Self::MalformedPayload,
1766 0x000B => Self::MalformedVector,
1767 0x0020 => Self::VersionNotSupported,
1768 0x0021 => Self::NoSuchAuthMethod,
1769 0x0022 => Self::Unauthenticated,
1770 0x0023 => Self::NotAuthenticated,
1771 0x0024 => Self::AuthBackendUnavailable,
1772 0x0025 => Self::SessionExpired,
1773 0x0030 => Self::PermissionDenied,
1774 0x0031 => Self::AdminPermissionRequired,
1775 0x0032 => Self::WrongShard,
1776 0x0033 => Self::ActAsDenied,
1777 0x0040 => Self::InvalidArgument,
1778 0x0041 => Self::MissingRequiredField,
1779 0x0042 => Self::TextTooLarge,
1780 0x0043 => Self::TextEmpty,
1781 0x0044 => Self::BadSessionId,
1782 0x0045 => Self::BadMemoryKind,
1783 0x0046 => Self::BadEdgeKind,
1784 0x0047 => Self::BadStrategyHint,
1785 0x0048 => Self::TopKOutOfRange,
1786 0x0049 => Self::BudgetTooLarge,
1787 0x004A => Self::BadModelFingerprint,
1788 0x004B => Self::PredicateNotInSchema,
1789 0x004C => Self::RelationTypeNotInSchema,
1790 0x0050 => Self::MemoryNotFound,
1791 0x0051 => Self::ContextNotFound,
1792 0x0052 => Self::SubscriptionNotFound,
1793 0x0053 => Self::SnapshotNotFound,
1794 0x0054 => Self::TxnNotFound,
1795 0x0060 => Self::IdempotencyConflict,
1796 0x0061 => Self::TransactionConflict,
1797 0x0062 => Self::TransactionTimeout,
1798 0x0063 => Self::StreamIdInUse,
1799 0x0064 => Self::SubscriptionLsnTooOld,
1800 0x0065 => Self::CardinalityViolation,
1801 0x0070 => Self::OutOfSlots,
1802 0x0071 => Self::OutOfDisk,
1803 0x0072 => Self::OutOfMemory,
1804 0x0073 => Self::RateLimited,
1805 0x0074 => Self::StreamLimitExceeded,
1806 0x0075 => Self::ConnectionLimitExceeded,
1807 0x0076 => Self::TransactionLimitExceeded,
1808 0x0077 => Self::TransactionTooLarge,
1809 0x0080 => Self::Internal,
1810 0x0081 => Self::StorageError,
1811 0x0082 => Self::IndexError,
1812 0x0083 => Self::EmbeddingError,
1813 0x0084 => Self::MetadataError,
1814 0x0085 => Self::Cancelled,
1815 0x0090 => Self::ShardUnavailable,
1816 0x0091 => Self::Overloaded,
1817 0x0092 => Self::Restarting,
1818 0x0093 => Self::Maintenance,
1819 0x0094 => Self::RetrieverDegraded,
1820 0x0120 => Self::SchemaInvalid,
1821 0x0121 => Self::SchemaMigrationRequired,
1822 0x0130 => Self::EntityNotFound,
1823 0x0131 => Self::EntityTypeMismatch,
1824 0x0132 => Self::EntityAmbiguous,
1825 0x0133 => Self::EntityMergeConflict,
1826 0x0140 => Self::StatementNotFound,
1827 0x0141 => Self::StatementObjectTypeMismatch,
1828 0x0142 => Self::StatementContradictsExisting,
1829 0x0160 => Self::QueryTimeout,
1830 0x0161 => Self::QueryOverBudget,
1831 0x0170 => Self::ExtractorDisabled,
1832 0x0171 => Self::ExtractorBudgetExceeded,
1833 0x0172 => Self::ExtractionFailed,
1834 0x0066 => Self::LlmCredentialMissing,
1835 0x0095 => Self::LlmCredentialUnavailable,
1836 _ => Self::Unknown,
1837 }
1838 }
1839}
1840
1841impl<'de> serde::Deserialize<'de> for ErrorCodeWire {
1842 fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
1843 Ok(Self::from_raw(u16::deserialize(d)?))
1844 }
1845}
1846
1847#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
1849pub struct ErrorDetails {
1850 pub field: Option<String>,
1851 pub expected: Option<String>,
1852 pub actual: Option<String>,
1853}
1854
1855#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1857pub struct ErrorResponse {
1858 pub code: ErrorCodeWire,
1859 pub category: ErrorCategoryWire,
1860 pub message: String,
1861 pub details: Option<ErrorDetails>,
1862 pub retry_after_ms: Option<u32>,
1863}
1864
1865impl ErrorResponse {
1866 #[must_use]
1870 pub fn code_is_unknown(&self) -> bool {
1871 self.code == ErrorCodeWire::Unknown
1872 }
1873}
1874
1875#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
1886pub enum StatementKindWire {
1887 Fact,
1888 Preference,
1889 Event,
1890 Attribute,
1891 Relation,
1892 Directive,
1893 Custom(u8),
1894}
1895
1896impl StatementKindWire {
1897 #[must_use]
1899 pub fn to_storage_byte(self) -> u8 {
1900 match self {
1901 StatementKindWire::Fact => 0,
1902 StatementKindWire::Preference => 1,
1903 StatementKindWire::Event => 2,
1904 StatementKindWire::Attribute => 3,
1905 StatementKindWire::Relation => 4,
1906 StatementKindWire::Directive => 5,
1907 StatementKindWire::Custom(b) => b,
1908 }
1909 }
1910
1911 #[must_use]
1914 pub fn from_storage_byte(byte: u8) -> Self {
1915 match byte {
1916 0 => StatementKindWire::Fact,
1917 1 => StatementKindWire::Preference,
1918 2 => StatementKindWire::Event,
1919 3 => StatementKindWire::Attribute,
1920 4 => StatementKindWire::Relation,
1921 5 => StatementKindWire::Directive,
1922 b => StatementKindWire::Custom(b),
1923 }
1924 }
1925}
1926
1927#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1929pub enum StatementValueWire {
1930 Text(String),
1931 Integer(i64),
1932 Float(f64),
1933 Bool(bool),
1934 UnixNanos(u64),
1935 Blob(Vec<u8>),
1936}
1937
1938#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1940pub enum StatementObjectWire {
1941 EntityRef(#[serde(with = "serde_bytes")] WireUuid),
1942 Value(StatementValueWire),
1943 MemoryRef(#[serde(with = "serde_bytes")] [u8; 16]),
1944 StatementRef(#[serde(with = "serde_bytes")] WireUuid),
1945}
1946
1947#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1949pub enum EvidenceRefWire {
1950 Inline(#[serde(with = "crate::wire::cbor::vec_byte_array16")] Vec<[u8; 16]>),
1951 Overflow(#[serde(with = "serde_bytes")] WireUuid),
1952}
1953
1954#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1956pub struct EntityCreateRequest {
1957 pub entity_type_id: u32,
1958 pub canonical_name: String,
1959 pub aliases: Vec<String>,
1960 pub attributes_blob: Vec<u8>,
1961 #[serde(default)]
1964 pub session_id: WireSessionId,
1965 #[serde(with = "serde_bytes")]
1966 pub request_id: WireUuid,
1967 #[serde(skip_serializing_if = "Option::is_none", default)]
1970 pub act_as: Option<ActAs>,
1971}
1972
1973#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1977pub struct EntityUpdateRequest {
1978 #[serde(with = "serde_bytes")]
1979 pub entity_id: WireUuid,
1980 pub canonical_name: String,
1981 pub aliases: Vec<String>,
1982 pub attributes_blob: Vec<u8>,
1983 #[serde(with = "serde_bytes")]
1984 pub request_id: WireUuid,
1985}
1986
1987#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1989pub struct EntityUpdateResponse {
1990 pub entity: EntityView,
1991}
1992
1993#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1997pub struct EntityRenameRequest {
1998 #[serde(with = "serde_bytes")]
1999 pub entity_id: WireUuid,
2000 pub new_canonical_name: String,
2001 pub move_to_alias: bool,
2002 #[serde(with = "serde_bytes")]
2003 pub request_id: WireUuid,
2004}
2005
2006#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2008pub struct EntityRenameResponse {
2009 pub entity: EntityView,
2010}
2011
2012#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2017pub struct EntityMergeRequest {
2018 #[serde(with = "serde_bytes")]
2019 pub survivor: WireUuid,
2020 #[serde(with = "serde_bytes")]
2021 pub merged: WireUuid,
2022 pub confidence: f32,
2023 pub reason: String,
2024 #[serde(with = "serde_bytes")]
2025 pub request_id: WireUuid,
2026}
2027
2028#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2031pub struct EntityMergeResponse {
2032 #[serde(with = "serde_bytes")]
2033 pub audit_id: WireUuid,
2034 pub grace_period_seconds: u64,
2035}
2036
2037#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2040pub struct EntityUnmergeRequest {
2041 #[serde(with = "serde_bytes")]
2042 pub merged_entity: WireUuid,
2043 #[serde(with = "serde_bytes")]
2044 pub request_id: WireUuid,
2045}
2046
2047#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2049pub struct EntityUnmergeResponse {
2050 #[serde(with = "serde_bytes")]
2051 pub restored_entity_id: WireUuid,
2052}
2053
2054#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2058pub struct EntityTombstoneRequest {
2059 #[serde(with = "serde_bytes")]
2060 pub entity_id: WireUuid,
2061 pub reason: String,
2062 #[serde(with = "serde_bytes")]
2063 pub request_id: WireUuid,
2064}
2065
2066#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2068pub struct EntityTombstoneResponse {
2069 pub tombstoned_at_unix_nanos: u64,
2070}
2071
2072#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2076pub struct EntityCreateResponse {
2077 #[serde(with = "serde_bytes")]
2078 pub entity_id: WireUuid,
2079}
2080
2081#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2083pub struct StatementCreateRequest {
2084 pub kind: StatementKindWire,
2085 #[serde(with = "serde_bytes")]
2086 pub subject: WireUuid,
2087 pub predicate: String,
2088 pub object: StatementObjectWire,
2089 pub confidence: f32,
2090 pub evidence: EvidenceRefWire,
2091 pub extractor_id: u32,
2092 pub valid_from_unix_nanos: u64,
2093 pub valid_to_unix_nanos: u64,
2094 pub event_at_unix_nanos: u64,
2095 pub schema_version: u32,
2096 #[serde(default)]
2099 pub session_id: WireSessionId,
2100 #[serde(with = "serde_bytes")]
2101 pub request_id: WireUuid,
2102 #[serde(skip_serializing_if = "Option::is_none", default)]
2105 pub act_as: Option<ActAs>,
2106}
2107
2108#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2111pub struct StatementCreateResponse {
2112 #[serde(with = "serde_bytes")]
2113 pub statement_id: WireUuid,
2114 #[serde(with = "serde_bytes")]
2115 pub auto_superseded: WireUuid,
2116 #[serde(with = "serde_bytes")]
2117 pub chain_root: WireUuid,
2118}
2119
2120#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2125pub struct StatementSupersedeRequest {
2126 #[serde(with = "serde_bytes")]
2127 pub old_statement_id: WireUuid,
2128 pub new_statement: StatementCreateRequest,
2129 #[serde(with = "serde_bytes")]
2130 pub request_id: WireUuid,
2131}
2132
2133#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2136pub struct StatementSupersedeResponse {
2137 #[serde(with = "serde_bytes")]
2138 pub new_statement_id: WireUuid,
2139 #[serde(with = "serde_bytes")]
2140 pub chain_root: WireUuid,
2141 pub version: u32,
2142}
2143
2144#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2147pub struct StatementTombstoneRequest {
2148 #[serde(with = "serde_bytes")]
2149 pub statement_id: WireUuid,
2150 pub reason: u8,
2151 pub reason_message: String,
2152 #[serde(with = "serde_bytes")]
2153 pub request_id: WireUuid,
2154}
2155
2156#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2158pub struct StatementTombstoneResponse {
2159 pub tombstoned_at_unix_nanos: u64,
2160}
2161
2162#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2166pub struct StatementRetractRequest {
2167 #[serde(with = "serde_bytes")]
2168 pub statement_id: WireUuid,
2169 pub reason: u8,
2170 pub reason_message: String,
2171 #[serde(with = "serde_bytes")]
2172 pub request_id: WireUuid,
2173}
2174
2175#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2178pub struct StatementRetractResponse {
2179 pub retracted_at_unix_nanos: u64,
2180 pub will_zero_at_unix_nanos: u64,
2181}
2182
2183#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2188pub struct StatementHistoryRequest {
2189 #[serde(with = "serde_bytes")]
2190 pub anchor_id: WireUuid,
2191 pub include_tombstoned: bool,
2192 pub limit: u32,
2193 pub cursor: Vec<u8>,
2194}
2195
2196#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2200pub struct StatementHistoryResponseFrame {
2201 pub items: Vec<StatementView>,
2202 #[serde(with = "serde_bytes")]
2203 pub chain_root: WireUuid,
2204 pub total_versions: u32,
2205 pub next_cursor: Vec<u8>,
2206 pub is_final: bool,
2207}
2208
2209#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2211pub struct RelationCreateRequest {
2212 pub relation_type: String,
2213 #[serde(with = "serde_bytes")]
2214 pub from_entity: WireUuid,
2215 #[serde(with = "serde_bytes")]
2216 pub to_entity: WireUuid,
2217 pub properties_blob: Vec<u8>,
2218 pub evidence: EvidenceRefWire,
2219 pub extractor_id: u32,
2220 pub confidence: f32,
2221 pub valid_from_unix_nanos: u64,
2222 pub valid_to_unix_nanos: u64,
2223 #[serde(default)]
2226 pub session_id: WireSessionId,
2227 #[serde(with = "serde_bytes")]
2228 pub request_id: WireUuid,
2229 #[serde(skip_serializing_if = "Option::is_none", default)]
2232 pub act_as: Option<ActAs>,
2233}
2234
2235#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2237pub struct RelationCreateResponse {
2238 #[serde(with = "serde_bytes")]
2239 pub relation_id: WireUuid,
2240}
2241
2242#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2244pub struct SchemaUploadRequest {
2245 pub schema_document: String,
2246 pub dry_run: bool,
2247 pub allow_breaking: bool,
2248 #[serde(with = "serde_bytes")]
2249 pub request_id: WireUuid,
2250 #[serde(skip_serializing_if = "Option::is_none", default)]
2252 pub act_as: Option<ActAs>,
2253}
2254
2255#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2257pub struct SchemaValidationErrorWire {
2258 pub code: String,
2259 pub message: String,
2260 pub line: u32,
2261 pub column: u32,
2262 pub length: u32,
2263 pub severity: u8,
2264}
2265
2266#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2268pub struct SchemaUploadResponse {
2269 pub namespace: String,
2270 pub schema_version: u32,
2271 pub validation_errors: Vec<SchemaValidationErrorWire>,
2272 pub backward_compatible: bool,
2273 pub migration_summary_blob: Vec<u8>,
2274}
2275
2276pub mod schema_drop_target {
2283 pub const PREDICATE: u8 = 0;
2285 pub const RELATION_TYPE: u8 = 1;
2287}
2288
2289#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2301pub struct SchemaDropRequest {
2302 pub namespace: String,
2305 pub target_kind: u8,
2307 pub target_name: String,
2310 pub force: bool,
2312 #[serde(with = "serde_bytes")]
2313 pub request_id: WireUuid,
2314 #[serde(skip_serializing_if = "Option::is_none", default)]
2316 pub act_as: Option<ActAs>,
2317}
2318
2319#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2327pub struct SchemaDropResponse {
2328 pub namespace: String,
2329 pub schema_version: u32,
2330 pub target_kind: u8,
2331 pub target_name: String,
2332 pub dropped: bool,
2333 pub live_rows: u32,
2334 pub validation_errors: Vec<SchemaValidationErrorWire>,
2335}
2336
2337#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2348pub struct SchemaReplaceRequest {
2349 pub schema_document: String,
2352 pub force_drop_existing: bool,
2354 #[serde(with = "serde_bytes")]
2355 pub request_id: WireUuid,
2356 #[serde(skip_serializing_if = "Option::is_none", default)]
2358 pub act_as: Option<ActAs>,
2359}
2360
2361#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2367pub struct SchemaReplaceResponse {
2368 pub namespace: String,
2369 pub schema_version: u32,
2370 pub dropped_count: u32,
2371 pub validation_errors: Vec<SchemaValidationErrorWire>,
2372}
2373
2374#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2376pub enum CancellationReason {
2377 ClientUnneeded,
2380 Timeout,
2382 Other(String),
2384}
2385
2386#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2393pub struct CancelStreamRequest {
2394 pub target_stream_id: u32,
2395 pub reason: CancellationReason,
2396}
2397
2398#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2400pub struct CancelStreamAck {
2401 pub target_stream_id: u32,
2402 pub cancelled_at_unix_nanos: u64,
2403}
2404
2405#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2407pub struct TimeRangeWire {
2408 pub from_unix_ms: Option<u64>,
2409 pub to_unix_ms: Option<u64>,
2410}
2411
2412#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2426#[repr(u8)]
2427pub enum RetrieverWire {
2428 Semantic = 0,
2429 Lexical = 1,
2430 Graph = 2,
2431}
2432
2433#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2436pub enum RetrieverSelectionWire {
2437 Auto,
2438 Explicit(Vec<RetrieverWire>),
2439}
2440
2441#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2443pub struct FusionConfigWire {
2444 pub k: u32,
2445 pub semantic_weight: f32,
2446 pub lexical_weight: f32,
2447 pub graph_weight: f32,
2448}
2449
2450#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2453pub struct QueryRequest {
2454 pub text: String,
2455 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
2456 pub entity_anchor: Option<WireUuid>,
2457 pub kind_filter: Vec<u8>,
2458 pub predicate_filter: Vec<String>,
2459 pub session_filter: Option<Vec<WireSessionId>>,
2463 pub time_filter: Option<TimeRangeWire>,
2464 pub as_of_record_time_unix_nanos: Option<u64>,
2465 pub confidence_min: Option<f32>,
2466 pub include_tombstoned: bool,
2467 pub include_superseded: bool,
2468 pub limit: u32,
2469 pub retrievers: RetrieverSelectionWire,
2470 pub fusion_config: Option<FusionConfigWire>,
2471 #[serde(with = "serde_bytes")]
2472 pub request_id: WireUuid,
2473}
2474
2475#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2477pub struct MaterializeProceduralRequest {
2478 #[serde(with = "serde_bytes")]
2479 pub space_id: WireUuid,
2480 pub session_filter: Option<Vec<WireSessionId>>,
2481 pub top_k: u32,
2482 pub min_confidence: f32,
2483 pub categories: Vec<String>,
2484 #[serde(with = "serde_bytes")]
2485 pub request_id: WireUuid,
2486}
2487
2488#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2490pub struct MaterializeProceduralResponse {
2491 pub system_block: String,
2492 #[serde(with = "crate::wire::cbor::vec_byte_array16")]
2495 pub statement_ids: Vec<WireUuid>,
2496 pub total_candidates: u32,
2497 pub trimmed_by_budget: bool,
2498}
2499
2500#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2508pub struct SpaceView {
2509 pub space_id: String,
2510 pub created_at_unix_nanos: u64,
2511 pub last_active_unix_nanos: u64,
2512 pub memory_count: u64,
2513 pub session_count: u32,
2514}
2515
2516#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2520pub struct SpaceCreateRequest {
2521 #[serde(skip_serializing_if = "Option::is_none", default)]
2524 pub metadata: Option<Vec<u8>>,
2525 #[serde(with = "serde_bytes")]
2526 pub request_id: WireUuid,
2527 #[serde(skip_serializing_if = "Option::is_none", default)]
2528 pub act_as: Option<ActAs>,
2529}
2530
2531#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2534pub struct SpaceCreateResponse {
2535 pub space_id: String,
2536 pub created: bool,
2538 pub created_at_unix_nanos: u64,
2539 pub last_active_unix_nanos: u64,
2540 pub memory_count: u64,
2541 pub session_count: u32,
2542}
2543
2544#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2547pub struct SpaceListRequest {
2548 pub limit: u32,
2549 #[serde(skip_serializing_if = "Option::is_none", default)]
2550 pub act_as: Option<ActAs>,
2551}
2552
2553#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2555pub struct SpaceListResponse {
2556 pub spaces: Vec<SpaceView>,
2557 pub cross_shard_complete: bool,
2561}
2562
2563#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2566pub struct SpaceDeleteRequest {
2567 #[serde(with = "serde_bytes")]
2568 pub request_id: WireUuid,
2569 #[serde(skip_serializing_if = "Option::is_none", default)]
2570 pub act_as: Option<ActAs>,
2571}
2572
2573#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2576pub struct SpaceDeleteResponse {
2577 pub space_id: String,
2578 pub existed: bool,
2580 pub memories_forgotten: u64,
2582}
2583
2584#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2590pub struct SessionView {
2591 pub session_id: WireSessionId,
2592 pub created_at_unix_nanos: u64,
2593 pub last_active_unix_nanos: u64,
2594 #[serde(skip_serializing_if = "Option::is_none", default)]
2595 pub title: Option<String>,
2596 pub memory_count: u32,
2597}
2598
2599#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2602pub struct SessionCreateRequest {
2603 pub session_id: WireSessionId,
2604 #[serde(skip_serializing_if = "Option::is_none", default)]
2605 pub title: Option<String>,
2606 #[serde(with = "serde_bytes")]
2607 pub request_id: WireUuid,
2608 #[serde(skip_serializing_if = "Option::is_none", default)]
2609 pub act_as: Option<ActAs>,
2610}
2611
2612#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2615pub struct SessionCreateResponse {
2616 #[serde(with = "serde_bytes")]
2617 pub space_id: WireUuid,
2618 pub session_id: WireSessionId,
2619 pub created: bool,
2621 pub created_at_unix_nanos: u64,
2622 pub last_active_unix_nanos: u64,
2623 pub memory_count: u32,
2624}
2625
2626#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2629pub struct SessionListRequest {
2630 pub limit: u32,
2631 #[serde(skip_serializing_if = "Option::is_none", default)]
2632 pub act_as: Option<ActAs>,
2633}
2634
2635#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2638pub struct SessionListResponse {
2639 #[serde(with = "serde_bytes")]
2640 pub space_id: WireUuid,
2641 pub sessions: Vec<SessionView>,
2642}
2643
2644#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2648pub struct SessionDeleteRequest {
2649 pub session_id: WireSessionId,
2650 #[serde(default)]
2652 pub hard: bool,
2653 #[serde(with = "serde_bytes")]
2654 pub request_id: WireUuid,
2655 #[serde(skip_serializing_if = "Option::is_none", default)]
2656 pub act_as: Option<ActAs>,
2657}
2658
2659#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2662pub struct SessionDeleteResponse {
2663 #[serde(with = "serde_bytes")]
2664 pub space_id: WireUuid,
2665 pub session_id: WireSessionId,
2666 pub existed: bool,
2668 pub memories_forgotten: u64,
2670}
2671
2672#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2679pub struct TxnBeginRequest {
2680 #[serde(with = "serde_bytes")]
2681 pub txn_id: WireUuid,
2682 pub timeout_seconds: u32,
2683 #[serde(skip_serializing_if = "Option::is_none", default)]
2688 pub act_as: Option<ActAs>,
2689}
2690
2691#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2693pub struct TxnBeginResponse {
2694 #[serde(with = "serde_bytes")]
2695 pub txn_id: WireUuid,
2696 pub timeout_seconds: u32,
2697 pub started_at_unix_nanos: u64,
2698}
2699
2700#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2702pub struct TxnCommitRequest {
2703 #[serde(with = "serde_bytes")]
2704 pub txn_id: WireUuid,
2705}
2706
2707#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2709pub struct TxnCommitResponse {
2710 #[serde(with = "serde_bytes")]
2711 pub txn_id: WireUuid,
2712 pub committed_at_unix_nanos: u64,
2713 pub operations_applied: u32,
2714}
2715
2716#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2718pub struct TxnAbortRequest {
2719 #[serde(with = "serde_bytes")]
2720 pub txn_id: WireUuid,
2721}
2722
2723#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2725pub struct TxnAbortResponse {
2726 #[serde(with = "serde_bytes")]
2727 pub txn_id: WireUuid,
2728 pub operations_discarded: u32,
2729}
2730
2731#[derive(
2740 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
2741)]
2742#[repr(u8)]
2743pub enum EventType {
2744 Encoded = 0,
2746 Forgotten = 1,
2747 Reclaimed = 2,
2748 KindChanged = 3,
2749
2750 EntityCreated = 16,
2752 EntityUpdated = 17,
2753 EntityRenamed = 18,
2754 EntityMerged = 19,
2755 EntityUnmerged = 20,
2756 EntityTombstoned = 21,
2757 StatementCreated = 22,
2758 StatementSuperseded = 23,
2759 StatementTombstoned = 24,
2760 RelationCreated = 25,
2761 RelationSuperseded = 26,
2762 StageCompleted = 27,
2763 SchemaUpdated = 29,
2764 RelationTombstoned = 30,
2765
2766 EdgeAdded = 31,
2768 EdgeRemoved = 32,
2769 EdgeSuperseded = 33,
2770}
2771
2772#[derive(
2774 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
2775)]
2776#[repr(u8)]
2777pub enum StageOutcome {
2778 Ok = 0,
2779 Empty = 1,
2780 Failed = 2,
2781}
2782
2783#[derive(
2785 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
2786)]
2787#[repr(u8)]
2788pub enum StageAuditStatus {
2789 Succeeded = 0,
2790 PartiallyApplied = 1,
2791 Failed = 2,
2792 Skipped = 3,
2793}
2794
2795#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2798pub struct StageAutoEdgePayload {
2799 pub edges_written: u32,
2800}
2801
2802#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2805pub struct StageTemporalEdgePayload {
2806 pub edges_written: u32,
2807}
2808
2809#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2812pub struct StageExtractorPayload {
2813 pub entity_count: u32,
2814 pub statement_count: u32,
2815 pub relation_count: u32,
2816 pub audit_status: StageAuditStatus,
2817 pub error_message: String,
2819}
2820
2821#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2825pub struct StageHypePayload {
2826 pub questions_written: u32,
2829 pub cost_micro_usd: u64,
2831}
2832
2833#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2836pub enum StagePayload {
2837 AutoEdge(StageAutoEdgePayload),
2838 TemporalEdge(StageTemporalEdgePayload),
2839 Extractor(StageExtractorPayload),
2840 Hype(StageHypePayload),
2841}
2842
2843#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
2845pub struct SimilarityFilter {
2846 pub reference_memory_id: WireMemoryId,
2847 pub threshold: f32,
2848}
2849
2850#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2853pub struct SubscriptionFilter {
2854 pub session_filter: Option<Vec<WireSessionId>>,
2855 pub kinds: Option<Vec<MemoryKindWire>>,
2856 pub similar_to: Option<SimilarityFilter>,
2857 #[serde(with = "crate::wire::cbor::opt_vec_byte_array16")]
2860 pub spaces: Option<Vec<WireUuid>>,
2861 pub memory_ids: Option<Vec<WireMemoryId>>,
2866}
2867
2868#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2872pub struct SubscribeRequest {
2873 pub filter: SubscriptionFilter,
2874 pub include_history: bool,
2875 pub from_lsn: Option<u64>,
2876 pub max_inflight: u32,
2877 #[serde(skip_serializing_if = "Option::is_none", default)]
2882 pub act_as: Option<ActAs>,
2883}
2884
2885#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2888pub struct EdgeEventPayload {
2889 pub from_kind: u8,
2891 #[serde(with = "serde_bytes")]
2892 pub from_id: WireUuid,
2893 pub to_kind: u8,
2894 #[serde(with = "serde_bytes")]
2895 pub to_id: WireUuid,
2896 pub edge_kind_tag: u8,
2898 pub edge_kind_byte: u8,
2899 pub relation_type_id: Option<u32>,
2901 pub weight: f32,
2902 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
2903 pub relation_id: Option<WireUuid>,
2904 #[serde(with = "crate::wire::cbor::opt_byte_array16")]
2905 pub superseded_relation_id: Option<WireUuid>,
2906 pub origin: u8,
2908}
2909
2910#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2912pub struct SubscriptionEvent {
2913 pub event_type: EventType,
2914 pub memory_id: WireMemoryId,
2915 pub session_id: WireSessionId,
2916 pub text: String,
2917 pub kind: MemoryKindWire,
2918 pub salience: f32,
2919 pub timestamp_unix_nanos: u64,
2920 pub lsn: u64,
2921 pub graph_payload: Option<GraphEventPayload>,
2923 pub edge_payload: Option<EdgeEventPayload>,
2925 pub stage_kind: Option<StageKind>,
2927 pub stage_outcome: Option<StageOutcome>,
2928 pub stage_payload: Option<StagePayload>,
2929}
2930
2931#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2934pub struct UnsubscribeRequest {
2935 pub target_stream_id: u32,
2936}
2937
2938#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
2940pub struct UnsubscribeResponse {
2941 pub target_stream_id: u32,
2942 pub final_lsn: u64,
2943}
2944
2945#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2953pub enum GraphEventPayload {
2954 EntityCreated(EntityCreatedEvent),
2955 EntityUpdated(EntityUpdatedEvent),
2956 EntityRenamed(EntityRenamedEvent),
2957 EntityMerged(EntityMergedEvent),
2958 EntityUnmerged(EntityUnmergedEvent),
2959 EntityTombstoned(EntityTombstonedEvent),
2960 StatementCreated(StatementCreatedEvent),
2961 StatementSuperseded(StatementSupersededEvent),
2962 StatementTombstoned(StatementTombstonedEvent),
2963 RelationCreated(RelationCreatedEvent),
2964 RelationSuperseded(RelationSupersededEvent),
2965 RelationTombstoned(RelationTombstonedEvent),
2966 SchemaUpdated(SchemaUpdatedEvent),
2967}
2968
2969#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2971pub struct EntityCreatedEvent {
2972 #[serde(with = "serde_bytes")]
2973 pub entity_id: WireUuid,
2974 pub entity_type_id: u32,
2975 pub canonical_name: String,
2976}
2977
2978#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2981pub struct EntityUpdatedEvent {
2982 #[serde(with = "serde_bytes")]
2983 pub entity_id: WireUuid,
2984 pub entity_type_id: u32,
2985 pub canonical_name: String,
2986 pub embedding_version_changed: bool,
2987}
2988
2989#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2992pub struct EntityRenamedEvent {
2993 #[serde(with = "serde_bytes")]
2994 pub entity_id: WireUuid,
2995 pub old_canonical_name: String,
2996 pub new_canonical_name: String,
2997 pub old_moved_to_alias: bool,
2998}
2999
3000#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
3003pub struct EntityMergedEvent {
3004 #[serde(with = "serde_bytes")]
3005 pub survivor: WireUuid,
3006 #[serde(with = "serde_bytes")]
3007 pub merged: WireUuid,
3008 #[serde(with = "serde_bytes")]
3009 pub audit_id: WireUuid,
3010 pub confidence: f32,
3011 pub statements_rerouted: u32,
3012 pub relations_rerouted: u32,
3013}
3014
3015#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
3018pub struct EntityUnmergedEvent {
3019 #[serde(with = "serde_bytes")]
3020 pub restored_entity_id: WireUuid,
3021 #[serde(with = "serde_bytes")]
3022 pub from_survivor: WireUuid,
3023 #[serde(with = "serde_bytes")]
3024 pub audit_id: WireUuid,
3025}
3026
3027#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3030pub struct EntityTombstonedEvent {
3031 #[serde(with = "serde_bytes")]
3032 pub entity_id: WireUuid,
3033 pub reason: String,
3034}
3035
3036#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3039pub struct StatementCreatedEvent {
3040 #[serde(with = "serde_bytes")]
3041 pub statement_id: WireUuid,
3042 pub kind: u8,
3044 #[serde(with = "serde_bytes")]
3045 pub subject: WireUuid,
3046 pub predicate: String,
3047 pub confidence: f32,
3048}
3049
3050#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
3053pub struct StatementSupersededEvent {
3054 #[serde(with = "serde_bytes")]
3055 pub old_statement_id: WireUuid,
3056 #[serde(with = "serde_bytes")]
3057 pub new_statement_id: WireUuid,
3058 #[serde(with = "serde_bytes")]
3059 pub chain_root: WireUuid,
3060}
3061
3062#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3065pub struct StatementTombstonedEvent {
3066 #[serde(with = "serde_bytes")]
3067 pub statement_id: WireUuid,
3068 pub reason: String,
3069}
3070
3071#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3074pub struct RelationCreatedEvent {
3075 #[serde(with = "serde_bytes")]
3076 pub relation_id: WireUuid,
3077 pub relation_type: String,
3078 #[serde(with = "serde_bytes")]
3079 pub from: WireUuid,
3080 #[serde(with = "serde_bytes")]
3081 pub to: WireUuid,
3082}
3083
3084#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
3087pub struct RelationSupersededEvent {
3088 #[serde(with = "serde_bytes")]
3089 pub old_relation_id: WireUuid,
3090 #[serde(with = "serde_bytes")]
3091 pub new_relation_id: WireUuid,
3092}
3093
3094#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3097pub struct RelationTombstonedEvent {
3098 #[serde(with = "serde_bytes")]
3099 pub relation_id: WireUuid,
3100 pub reason: String,
3101}
3102
3103#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3106pub struct SchemaUpdatedEvent {
3107 pub namespace: String,
3108 pub from_version: u32,
3109 pub to_version: u32,
3110 pub backward_compatible: bool,
3112}
3113
3114#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
3123pub struct GetCapabilitiesRequest {
3124 #[serde(skip_serializing_if = "Option::is_none", default)]
3127 pub act_as: Option<ActAs>,
3128}
3129
3130#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3132pub struct Capabilities {
3133 pub rerank: bool,
3135 pub llm_extractor: bool,
3137 pub classifier_extractor: bool,
3139 pub pattern_extractor: bool,
3141 pub schema_namespaces: Vec<String>,
3144 pub vector_dim: u16,
3146}
3147
3148#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3150pub struct GetCapabilitiesResponse {
3151 pub capabilities: Capabilities,
3152}
3153
3154#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
3163pub struct ExtractorListRequest {}
3164
3165#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3167pub struct ExtractorListItem {
3168 pub extractor_id: u32,
3169 pub namespace: String,
3170 pub name: String,
3171 pub kind: u8,
3173 pub schema_version: u32,
3174 pub created_at_unix_nanos: u64,
3175}
3176
3177#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3180pub struct ExtractorListResponseFrame {
3181 pub items: Vec<ExtractorListItem>,
3182 pub total: u32,
3183 pub is_final: bool,
3184}
3185
3186#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3192pub struct EntityView {
3193 #[serde(with = "serde_bytes")]
3194 pub entity_id: WireUuid,
3195 pub entity_type_id: u32,
3196 pub canonical_name: String,
3197 pub normalized_name: String,
3198 pub aliases: Vec<String>,
3199 pub attributes_blob: Vec<u8>,
3200 pub mention_count: u32,
3201 pub created_at_unix_nanos: u64,
3202 pub updated_at_unix_nanos: u64,
3203 #[serde(with = "serde_bytes")]
3205 pub merged_into: WireUuid,
3206 pub embedding_version: u32,
3207 pub flags: u32,
3208}
3209
3210#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3212pub struct EntityGetRequest {
3213 #[serde(with = "serde_bytes")]
3214 pub entity_id: WireUuid,
3215 #[serde(skip_serializing_if = "Option::is_none", default)]
3220 pub act_as: Option<ActAs>,
3221}
3222
3223#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3225pub struct EntityGetResponse {
3226 pub entity: EntityView,
3227 pub resolved_from: Vec<WireUuid>,
3235}
3236
3237#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3239pub struct EntityListRequest {
3240 pub entity_type_id: u32,
3242 pub name_prefix: String,
3244 pub mention_count_min: u32,
3245 pub include_tombstoned: bool,
3246 pub include_merged: bool,
3247 pub limit: u32,
3249 pub cursor: Vec<u8>,
3251 #[serde(skip_serializing_if = "Option::is_none", default)]
3256 pub act_as: Option<ActAs>,
3257}
3258
3259#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3261pub struct EntityListItem {
3262 pub entity: EntityView,
3263}
3264
3265#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3268pub struct EntityListResponseFrame {
3269 pub items: Vec<EntityListItem>,
3270 pub next_cursor: Vec<u8>,
3273 pub cumulative_count: u32,
3274 pub is_final: bool,
3275}
3276
3277#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3285pub struct EntityResolveRequest {
3286 pub candidate_name: String,
3287 pub resolution_context: String,
3288 pub entity_type_hint: u32,
3290 pub allow_create: bool,
3291 #[serde(with = "serde_bytes")]
3292 pub request_id: WireUuid,
3293 #[serde(skip_serializing_if = "Option::is_none", default)]
3298 pub act_as: Option<ActAs>,
3299}
3300
3301#[derive(
3304 Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr,
3305)]
3306#[repr(u8)]
3307pub enum ResolutionOutcomeWire {
3308 Resolved = 1,
3309 Created = 2,
3310 Ambiguous = 3,
3311 NotFound = 4,
3312}
3313
3314#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3316pub struct EntityResolveResponse {
3317 pub outcome: ResolutionOutcomeWire,
3318 pub tier: u8,
3320 pub confidence: f32,
3321 #[serde(with = "serde_bytes")]
3324 pub resolved_entity: WireUuid,
3325 #[serde(with = "crate::wire::cbor::vec_byte_array16")]
3327 pub candidate_ids: Vec<WireUuid>,
3328 #[serde(with = "serde_bytes")]
3330 pub audit_id: WireUuid,
3331}
3332
3333#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3341pub struct StatementView {
3342 #[serde(with = "serde_bytes")]
3343 pub statement_id: WireUuid,
3344 pub kind: StatementKindWire,
3345 #[serde(with = "serde_bytes")]
3346 pub subject: WireUuid,
3347 #[serde(with = "serde_bytes")]
3348 pub subject_pending_audit_id: WireUuid,
3349 pub predicate: String,
3350 pub object: StatementObjectWire,
3351 pub confidence: f32,
3352 pub evidence: EvidenceRefWire,
3353 pub extractor_id: u32,
3354 pub extracted_at_unix_nanos: u64,
3355 pub schema_version: u32,
3356 pub valid_from_unix_nanos: u64,
3357 pub valid_to_unix_nanos: u64,
3358 pub event_at_unix_nanos: u64,
3359 pub version: u32,
3360 #[serde(with = "serde_bytes")]
3361 pub superseded_by: WireUuid,
3362 #[serde(with = "serde_bytes")]
3363 pub supersedes: WireUuid,
3364 #[serde(with = "serde_bytes")]
3365 pub chain_root: WireUuid,
3366 pub tombstoned: bool,
3367 pub tombstoned_at_unix_nanos: u64,
3368 pub tombstone_reason: u8,
3369 pub flags: u32,
3370 pub is_stateful: bool,
3372}
3373
3374#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3376pub struct StatementGetRequest {
3377 #[serde(with = "serde_bytes")]
3378 pub statement_id: WireUuid,
3379 pub follow_supersession: bool,
3382 #[serde(skip_serializing_if = "Option::is_none", default)]
3387 pub act_as: Option<ActAs>,
3388}
3389
3390#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3392pub struct StatementGetResponse {
3393 pub statement: StatementView,
3394 pub returned_via_supersession: bool,
3396}
3397
3398#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3402pub struct StatementListRequest {
3403 #[serde(with = "serde_bytes")]
3404 pub subject: WireUuid,
3405 pub predicate: String,
3406 pub kind: u8,
3407 pub min_confidence: f32,
3408 pub time_range_start_unix_nanos: u64,
3409 pub time_range_end_unix_nanos: u64,
3410 pub only_current: bool,
3411 pub include_tombstoned: bool,
3412 pub limit: u32,
3413 pub cursor: Vec<u8>,
3414 #[serde(skip_serializing_if = "Option::is_none", default)]
3419 pub act_as: Option<ActAs>,
3420}
3421
3422#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3424pub struct StatementListResponseFrame {
3425 pub items: Vec<StatementView>,
3426 pub next_cursor: Vec<u8>,
3427 pub cumulative_count: u32,
3428 pub is_final: bool,
3429}
3430
3431#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3438pub struct RelationView {
3439 #[serde(with = "serde_bytes")]
3440 pub relation_id: WireUuid,
3441 #[serde(with = "serde_bytes")]
3442 pub chain_root: WireUuid,
3443 pub relation_type: String,
3444 #[serde(with = "serde_bytes")]
3445 pub from_entity: WireUuid,
3446 #[serde(with = "serde_bytes")]
3447 pub to_entity: WireUuid,
3448 pub properties_blob: Vec<u8>,
3449 pub evidence: EvidenceRefWire,
3450 pub extractor_id: u32,
3451 pub extracted_at_unix_nanos: u64,
3452 pub confidence: f32,
3453 pub valid_from_unix_nanos: u64,
3454 pub valid_to_unix_nanos: u64,
3455 pub version: u32,
3456 #[serde(with = "serde_bytes")]
3457 pub superseded_by: WireUuid,
3458 #[serde(with = "serde_bytes")]
3459 pub supersedes: WireUuid,
3460 pub tombstoned: bool,
3461 pub tombstoned_at_unix_nanos: u64,
3462 pub flags: u32,
3463}
3464
3465#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3468pub struct RelationListFromRequest {
3469 #[serde(with = "serde_bytes")]
3470 pub from_entity: WireUuid,
3471 pub relation_type_filter: String,
3472 pub time_range_start_unix_nanos: u64,
3473 pub time_range_end_unix_nanos: u64,
3474 pub include_superseded: bool,
3475 pub include_tombstoned: bool,
3476 pub limit: u32,
3477 pub cursor: Vec<u8>,
3478 #[serde(skip_serializing_if = "Option::is_none", default)]
3481 pub act_as: Option<ActAs>,
3482}
3483
3484#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3486pub struct RelationListFromResponseFrame {
3487 pub items: Vec<RelationView>,
3488 pub next_cursor: Vec<u8>,
3489 pub cumulative_count: u32,
3490 pub is_final: bool,
3491}
3492
3493#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3496pub struct RelationListToRequest {
3497 #[serde(with = "serde_bytes")]
3498 pub to_entity: WireUuid,
3499 pub relation_type_filter: String,
3500 pub time_range_start_unix_nanos: u64,
3501 pub time_range_end_unix_nanos: u64,
3502 pub include_superseded: bool,
3503 pub include_tombstoned: bool,
3504 pub limit: u32,
3505 pub cursor: Vec<u8>,
3506 #[serde(skip_serializing_if = "Option::is_none", default)]
3509 pub act_as: Option<ActAs>,
3510}
3511
3512#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3514pub struct RelationListToResponseFrame {
3515 pub items: Vec<RelationView>,
3516 pub next_cursor: Vec<u8>,
3517 pub cumulative_count: u32,
3518 pub is_final: bool,
3519}
3520
3521#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3527pub struct SchemaGetRequest {
3528 pub namespace: String,
3529 pub version: u32,
3530 #[serde(skip_serializing_if = "Option::is_none", default)]
3532 pub act_as: Option<ActAs>,
3533}
3534
3535#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3537pub struct SchemaGetResponse {
3538 pub namespace: String,
3539 pub schema_version: u32,
3540 pub schema_document: String,
3542 pub source_blob: Vec<u8>,
3544 pub uploaded_at_unix_nanos: u64,
3545 pub validator_version: u32,
3546}
3547
3548#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3550pub struct SchemaListRequest {
3551 pub namespace: String,
3552 pub limit: u32,
3553 pub cursor: Vec<u8>,
3554 #[serde(skip_serializing_if = "Option::is_none", default)]
3556 pub act_as: Option<ActAs>,
3557}
3558
3559#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3561pub struct SchemaListItemWire {
3562 pub schema_version: u32,
3563 pub uploaded_at_unix_nanos: u64,
3564 pub validator_version: u32,
3565 pub has_source_text: bool,
3566}
3567
3568#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3570pub struct SchemaListResponseFrame {
3571 pub namespace: String,
3572 pub items: Vec<SchemaListItemWire>,
3573 pub total: u32,
3574 pub next_cursor: Vec<u8>,
3575 pub is_final: bool,
3576}
3577
3578#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3580pub struct SchemaValidateRequest {
3581 pub schema_document: String,
3582 #[serde(skip_serializing_if = "Option::is_none", default)]
3584 pub act_as: Option<ActAs>,
3585}
3586
3587#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3589pub struct SchemaValidateResponse {
3590 pub namespace: String,
3593 pub would_be_version: u32,
3595 pub validation_errors: Vec<SchemaValidationErrorWire>,
3596}
3597
3598#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
3612pub struct ByeRequest {
3613 pub reason: Option<String>,
3620}
3621
3622#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
3624pub struct PingRequest {
3625 pub client_timestamp_unix_nanos: u64,
3626}
3627
3628#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
3631pub struct PongResponse {
3632 pub client_timestamp_unix_nanos: u64,
3633 pub server_timestamp_unix_nanos: u64,
3634}
3635
3636#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
3640pub struct ServerPingResponse {
3641 pub server_timestamp_unix_nanos: u64,
3642}
3643
3644#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
3647pub struct ClientPongRequest {
3648 pub server_timestamp_unix_nanos: u64,
3649 pub client_timestamp_unix_nanos: u64,
3650}
3651
3652#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3660pub struct RelationGetRequest {
3661 #[serde(with = "serde_bytes")]
3662 pub relation_id: WireUuid,
3663 pub follow_supersession: bool,
3664 #[serde(skip_serializing_if = "Option::is_none", default)]
3667 pub act_as: Option<ActAs>,
3668}
3669
3670#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3673pub struct RelationGetResponse {
3674 pub relation: RelationView,
3675 pub returned_via_supersession: bool,
3676}
3677
3678#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3680pub struct RelationSupersedeRequest {
3681 #[serde(with = "serde_bytes")]
3682 pub old_relation_id: WireUuid,
3683 pub new_relation: RelationCreateRequest,
3684 #[serde(with = "serde_bytes")]
3685 pub request_id: WireUuid,
3686}
3687
3688#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
3690pub struct RelationSupersedeResponse {
3691 #[serde(with = "serde_bytes")]
3692 pub new_relation_id: WireUuid,
3693 pub version: u32,
3694}
3695
3696#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3698pub struct RelationTombstoneRequest {
3699 #[serde(with = "serde_bytes")]
3700 pub relation_id: WireUuid,
3701 pub reason: String,
3702 #[serde(with = "serde_bytes")]
3703 pub request_id: WireUuid,
3704}
3705
3706#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
3708pub struct RelationTombstoneResponse {
3709 pub tombstoned_at_unix_nanos: u64,
3710}
3711
3712#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3714pub struct TraversalStepWire {
3715 #[serde(with = "serde_bytes")]
3716 pub relation_id: WireUuid,
3717 #[serde(with = "serde_bytes")]
3718 pub from: WireUuid,
3719 #[serde(with = "serde_bytes")]
3720 pub to: WireUuid,
3721 pub relation_type: String,
3722 pub depth: u32,
3723}
3724
3725#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3727pub struct TraversalPathWire {
3728 pub steps: Vec<TraversalStepWire>,
3729}
3730
3731#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3735pub struct RelationTraverseRequest {
3736 #[serde(with = "serde_bytes")]
3737 pub start_entity: WireUuid,
3738 pub relation_types: Vec<String>,
3739 pub direction: u8,
3740 pub max_depth: u32,
3741 pub max_nodes: u32,
3742 pub time_at_unix_nanos: u64,
3743 pub include_superseded: bool,
3744 #[serde(with = "serde_bytes")]
3745 pub request_id: WireUuid,
3746 #[serde(skip_serializing_if = "Option::is_none", default)]
3751 pub act_as: Option<ActAs>,
3752}
3753
3754#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3757pub struct RelationTraverseResponseFrame {
3758 pub paths: Vec<TraversalPathWire>,
3759 pub total_paths: u32,
3760 pub truncated: bool,
3761 pub is_final: bool,
3762}
3763
3764#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3770pub struct QueryExplainRequest {
3771 pub query: QueryRequest,
3772}
3773
3774#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3776pub struct QueryExplainResponse {
3777 pub plan_text: String,
3778 pub estimated_cost_ms: f32,
3779}
3780
3781#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3783pub struct QueryTraceRequest {
3784 pub query: QueryRequest,
3785}
3786
3787#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
3789pub struct QueryTraceResponse {
3790 pub trace_text: String,
3791 pub total_latency_ms: f64,
3792}
3793
3794#[cfg(test)]
3795mod error_code_forward_compat_tests {
3796 use super::*;
3797
3798 #[test]
3799 fn known_codes_round_trip_through_from_raw() {
3800 assert_eq!(
3801 ErrorCodeWire::from_raw(0x0033),
3802 ErrorCodeWire::ActAsDenied,
3803 "an existing code must still decode to its own variant"
3804 );
3805 assert_eq!(
3806 ErrorCodeWire::from_raw(0x0066),
3807 ErrorCodeWire::LlmCredentialMissing
3808 );
3809 assert_eq!(
3810 ErrorCodeWire::from_raw(0x0095),
3811 ErrorCodeWire::LlmCredentialUnavailable
3812 );
3813 }
3814
3815 #[test]
3816 fn an_unrecognised_code_decodes_to_unknown_instead_of_failing() {
3817 assert_eq!(ErrorCodeWire::from_raw(0xDEAD), ErrorCodeWire::Unknown);
3823 assert_eq!(ErrorCodeWire::from_raw(0x7FFF), ErrorCodeWire::Unknown);
3824 }
3825
3826 #[test]
3827 fn an_error_response_carrying_an_unknown_code_still_decodes() {
3828 let json = serde_json::json!({
3832 "code": 0xDEAD_u16,
3833 "category": 8,
3834 "message": "from a newer server",
3835 "details": null,
3836 "retry_after_ms": null,
3837 });
3838 let decoded: ErrorResponse =
3839 serde_json::from_value(json).expect("an unknown code must not break the frame");
3840 assert!(decoded.code_is_unknown());
3841 assert_eq!(decoded.category, ErrorCategoryWire::Unavailable);
3842 assert_eq!(decoded.message, "from a newer server");
3843 }
3844}