1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//! Event types sent from the proxy hot path to the background storage writer.
//!
//! These are the "write side" of the storage engine. The proxy constructs events
//! from MCP request/response data and sends them through an mpsc channel —
//! never blocking the hot path.
//!
//! # Separation from McprEvent
//!
//! `mcpr-integrations` has its own `McprEvent` for cloud/stdout emission.
//! `StoreEvent` is intentionally independent — different schema, different
//! lifecycle, no coupling between crates. The conversion happens at the
//! proxy's emit stage (`mcpr_core::proxy::pipeline::emit`) where both are
//! built from the same locals.
/// Top-level event enum sent through the storage channel.
///
/// The background writer dispatches on this to decide which table to write to
/// and whether to INSERT, UPDATE, or close a session.
/// One completed MCP request, ready to be written to the `requests` table.
///
/// Built from the same data the proxy already computes for logging and cloud
/// emission (method, tool name, latency, status, sizes). No extra parsing needed.
/// Emitted once per MCP session, when the proxy intercepts the `initialize` handshake.
///
/// The `clientInfo` field in the MCP `initialize` request is the authoritative source
/// of client identity — we don't guess from headers or user-agent strings.
/// A new `SchemaVersion` produced by the proxy's `SchemaManager`.
///
/// The writer trusts the event: `SchemaManager` guarantees the payload
/// differs from the previous version (unchanged ingests return `None`
/// and produce no event). The writer only diffs against the prior row
/// to populate `schema_changes`.
/// Outcome of a single MCP request.
///
/// Maps to the `status` CHECK constraint in the `requests` table:
/// `CHECK (status IN ('ok', 'error', 'timeout'))`.