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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
//! The partition journal this crate reads, named as a capability (#1565,
//! chunk B6).
//!
//! Every read the query plane makes — the sealed funnel's scoped replays, the
//! fleet dashboard's rebuild, the search index's reconcile and its coverage
//! checks — used to name [`polyc_eventlog_host::EventLogHost`] directly. Chunk
//! B6 moves the journal's single writer to the State plane, and a read plane
//! left pointing at a store nothing writes reads an empty deployment forever.
//! So this module names what those reads actually need, and the Container
//! decides what stands behind it.
//!
//! # What a position means here
//!
//! A position is a **zero-based index into the partition's own caller
//! records**: a partition holding `n` records answers
//! [`PartitionJournal::partition_event_count`] with `n` and reports positions
//! `0..n`. Every range in this module is half-open — `[start, end)` — and every
//! watermark this crate stores is "one past the last record read", which under
//! that numbering equals the count of records covered.
//!
//! That is stated here rather than left to whichever implementation is mounted
//! because the two differ underneath. The event-log host numbers its own
//! tamper-evidence markers into the same sequence; State numbers caller records
//! only, one-based, and filters its markers out of every read. An
//! implementation reconciles its own numbering to this one — it does not leak
//! it — so nothing in this crate's arithmetic depends on which is mounted.
//!
//! [`port_position`] and [`state_position`] are that reconciliation, stated
//! once. Every place a State position crosses into this crate's coordinate —
//! the read adapter the Container mounts, and [`crate::feed::commit_events`] on
//! the way in from the durable commit feed — converts through these two rather
//! than through arithmetic of its own. See #2146 for why: the feed spelled the
//! conversion by omission and the read path spelled it by subtraction, the two
//! sides disagreed by one, and every watermark the search index derived from
//! the feed named a position its own replay could not reach.
//!
//! # Why the errors are two, and only two
//!
//! Because two is what the callers act on. A read that did not complete for a
//! reason unrelated to this partition's bytes ([`JournalError::Unreachable`])
//! is worth another attempt, and one where the bytes themselves are the problem
//! ([`JournalError::Unreadable`]) is not — replaying them again reads the same
//! bytes. The search index's own
//! `UnavailableReason` split is exactly that distinction, and the dashboard and
//! the query funnel both treat any failure as a skip-and-log, so a finer
//! taxonomy here would carry information nothing downstream could use.
// NOT `cfg(test)`, and it cannot be. The two re-exports below are, but the
// module is not, so the `impl PartitionJournal for EventLogHost` inside it
// compiles into every build. A `cfg(test)` here is active only for THIS
// crate's own suite, and the control plane's `QueryEngine::for_test` coerces a
// host into a journal from its own test build, where this crate's gate is off.
// See `host.rs` for what that leaves reachable and what actually bounds it.
pub use classify_host_error;
pub use over_host;
use ;
use JournalPosition;
/// Returns the port position one State position occupies.
///
/// State's first durable record is position one — a commit assigns
/// `position.next()` from [`JournalPosition::ORIGIN`] — and this module's
/// positions are zero-based, so the two differ by exactly one.
///
/// Stated here, once, and reached for by name on both sides of the boundary.
/// A caller that instead reads [`JournalPosition::get`] straight through has
/// not converted at all, which is a skew rather than a compile error; naming
/// the conversion is what makes the omission visible at the call site.
pub const
/// Returns the State position one port position names.
///
/// The inverse of [`port_position`] over every position a record can occupy.
pub const
/// Why a partition read did not answer.
/// The partition journal the query plane reads.
///
/// One trait rather than one per consumer, because the three consumers overlap
/// almost entirely and a split would make the Container hand out three views of
/// one client for no boundary anybody enforces.
///
/// # Cancellation safety
///
/// Every method a deployment can reach is a read: dropping one mid-await loses
/// an answer and nothing more. The one append this trait declares exists only
/// in this crate's own test builds, and dropping that abandons the call rather
/// than undoing it.