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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
use alloc::vec::Vec;
use crate::algebra::{AdmissibleFloor, admissible_installed_floor};
use crate::lifecycle::{ClosureAccounting, claim_frontier::BindingFateFrontierPlan};
use crate::wire::{BindingEpoch, DeliverySeq, ParticipantId};
use super::state::{accounting_after_floor, accounting_after_marker_crossings};
use super::{LiveFrontierError, LiveFrontierOwner, crossed_marker_anchors, map_frontier_error};
pub(in crate::lifecycle::operations) struct BindingFateOwnerPlan {
frontiers: BindingFateFrontierPlan,
accounting: ClosureAccounting,
}
impl LiveFrontierOwner {
pub(in crate::lifecycle::operations) fn prepare_binding_fate_transition(
&self,
participant_id: ParticipantId,
binding_epoch: BindingEpoch,
cursor: DeliverySeq,
resulting_floor: DeliverySeq,
reserve_finalizer: bool,
) -> Result<BindingFateOwnerPlan, LiveFrontierError> {
if self.frontiers.retained_records().len() != self.retained_charges.len()
|| self
.frontiers
.retained_records()
.iter()
.zip(&self.retained_charges)
.any(|(record, charge)| {
record.delivery_seq != charge.delivery_seq()
|| record.admission_order != charge.admission_order()
})
{
return Err(LiveFrontierError::RetainedCharge);
}
let frontiers = self
.frontiers
.prepare_binding_fate_transition(
participant_id,
binding_epoch,
cursor,
resulting_floor,
reserve_finalizer,
)
.map_err(map_frontier_error)?;
let released = self
.retained_charges
.iter()
.copied()
.take_while(|charge| charge.delivery_seq() < resulting_floor)
.collect::<Vec<_>>();
let accounting = accounting_after_floor(self.closure_accounting, &released)
.ok_or(LiveFrontierError::ClosureAccounting)?;
let accounting = self.accounting_after_fated_cursor_advance(
accounting,
participant_id,
cursor,
&frontiers,
)?;
Ok(BindingFateOwnerPlan {
frontiers,
accounting,
})
}
/// Retires the marker anchors the fate's own cursor advance accepts.
///
/// ⛔ THIS IS THE STOP-PATH ANCHOR MINT (docs/design/STOP-PATH-ANCHORS-2026-08-29.md).
/// The fate carries its participant's cursor to the candidate high
/// watermark, and a cursor that passes a retained compaction marker ACCEPTS
/// it: `ordinary_unaccepted_marker_anchors` stops deriving that anchor the
/// instant `cursor >= marker seq`. Every other cursor-advancing transition
/// moves the stored side in the same commit —
/// `apply_participant_ack_frontier`, `apply_nonzero_participant_ack_frontier`
/// and `apply_marker_ack_frontier` all call
/// [`accounting_after_marker_crossings`] over exactly this count. The
/// binding-fate path called only [`accounting_after_floor`], which by
/// construction leaves `marker_anchors` untouched, so the census dropped
/// and the stored ledger did not: one ORPHANED ANCHOR per marker the fated
/// participant was still short of.
///
/// The tear was invisible while the server ran — the fate's post-append
/// reconciliation retires the orphan in MEMORY at load end — and permanent
/// in the log, because nothing durable records that retirement. So every
/// later boot re-derived the same split and re-reconciled it, forever: the
/// 123 `reconciled orphaned marker anchors` lines on the 2026-08-29 estate
/// boot, and the 71 a clean stop manufactured on its own.
///
/// The retirement is BOUNDED by what the ledger actually holds. In a
/// ledger that is in step, `stored >= census >= crossed` and the bound
/// never binds; a stored count already short of the census is a
/// pre-existing tear that the three census-authoritative reconcile sites
/// own, and refusing the fate over it would convert a repairable ledger
/// into a binding that can never be fated — the permanent-refusal shape
/// [`prepare_binding_fate`] already carries a warning about.
///
/// The advance is the FRONTIER's copy of the cursor only; the member's
/// durable acknowledged boundary does not move. A later attach by the same
/// participant installs that boundary again and re-opens every marker this
/// retirement crossed, so the attach re-mints exactly those anchors
/// (`reopened_marker_anchors` in `live_frontier.rs`). The two halves are
/// one rule: the stored ledger moves whenever the frontier cursor crosses
/// a retained marker, in either direction.
///
/// [`prepare_binding_fate`]: LiveFrontierOwner::prepare_binding_fate
fn accounting_after_fated_cursor_advance(
&self,
accounting: ClosureAccounting,
participant_id: ParticipantId,
cursor: DeliverySeq,
frontiers: &crate::lifecycle::claim_frontier::BindingFateFrontierPlan,
) -> Result<ClosureAccounting, LiveFrontierError> {
let crossed =
crossed_marker_anchors(self, participant_id, cursor, frontiers.resulting_cursor())
.min(accounting.marker_anchors());
if crossed == 0 {
return Ok(accounting);
}
accounting_after_marker_crossings(accounting, crossed)
.ok_or(LiveFrontierError::ClosureAccounting)
}
pub(in crate::lifecycle::operations) fn install_binding_fate_transition(
mut self,
plan: BindingFateOwnerPlan,
resulting_floor: DeliverySeq,
) -> Self {
self.frontiers = self
.frontiers
.install_binding_fate_transition(plan.frontiers);
self.retained_charges
.retain(|charge| charge.delivery_seq() >= resulting_floor);
self.closure_accounting = plan.accounting;
self
}
/// Applies a binding-fate floor that was MEASURED against an earlier
/// frontier, re-minted against this one.
///
/// PRECEDENCE-CLAMP M1/M1a. `PendingDiedOrdinaryFinalizer` freezes its
/// floor at measurement time and the caller holds it across an enclosing
/// transition, so by the time it arrives here the frontier it was measured
/// against no longer exists: the retained floor may have advanced, markers
/// may have been retained, and the high watermark has moved. Replaying the
/// frozen value and re-checking it is what made a refusal here permanent —
/// the enclosing source row is already durable, so the completion is
/// retried on every boot and refuses identically forever.
///
/// So the floor is RE-MINTED rather than replayed, against the marker set,
/// retained floor and high watermark as they stand NOW. Clamping only
/// downward would swap one permanent refusal for another: a downward clamp
/// can land below the current retained floor and be refused as
/// `ResultingFrontier`. `admissible_installed_floor` bounds BOTH ends.
///
/// The subsumed case is a decision, not an accident. When the retained
/// floor has already advanced past what this measurement could install, the
/// fate's floor means nothing and installing the older value would drive
/// the floor backwards over rows the frontier still owes. That is an
/// explicit no-op success: nothing is released, no charge is dropped, and
/// the accounting is untouched.
///
/// The measured floor is never RAISED to reach the interval. Only lowering
/// is safe: a raise would eat retained rows this fate never measured.
/// `admissible_installed_floor` returns `min(measured, upper)`, so the
/// installed floor is `<= measured` always.
///
/// # What was traced, and what was NOT proven (PRECEDENCE-CLAMP M1b)
///
/// The re-mint is structural insurance, and it is deliberately not resting
/// on either of the reachability findings below.
///
/// THE MARKER CONDITION CANNOT FIRE FROM A MARKER ADMITTED IN THE INTERVAL,
/// and that is mechanical rather than argued. `marker_records` gains rows in
/// exactly one place outside restore — `drain_next_marker_core`
/// (`claim_frontier.rs`, the sole `marker_records.push`) — which refuses
/// with `SequenceNotNext` unless the drained marker sits at exactly
/// `high_watermark + 1`. The sequence high watermark is monotone
/// non-decreasing, and a measured floor is at most `high_watermark + 1` at
/// measurement time (the preferred floor is `min(member_cursor,
/// observer_progress) + 1` with both inputs bounded by the watermark, and
/// the retained floor it is maxed against is itself bounded by
/// `high_watermark + 1`). So a marker retained after the measurement sits at
/// or above the measured floor, and the enforcer refuses only on STRICTLY
/// below. The condition can therefore only be met by a marker that was
/// already below the floor when it was measured, which is exactly what the
/// measurement-site clamp now prevents.
///
/// THE SUBSUMED CONDITION IS MARKER-FREE AND INDEPENDENT. It reads no marker
/// state at all: it needs only that `retained_floor` advanced past the
/// measured floor while the finalizer waited. `retained_floor` is written
/// in exactly three places — the ordinary-record projection and the two
/// binding-fate installs — and none of them appears between a
/// `prepare_pending_died_*` and its matching completion in any server call
/// chain that exists today (`ops_leave`, `ops_attach`, `ops_terminal_drain`
/// are straight-line `&mut self` sequences, and boot repair drains prepared
/// finalizers before anything else). NO REACHABLE SERVER PATH WAS FOUND.
/// That is a negative result from tracing and NOT a proof: the concurrency
/// of the conversation-authority seam was not exhaustively traced, and a
/// future caller that holds a finalizer across an ordinary admission reaches
/// it immediately. The unit
/// `a_floor_subsumed_while_the_finalizer_waited_installs_as_a_no_op` shows
/// the condition firing with an empty marker set, so the path is real at
/// this crate's public boundary whatever the server does with it.
///
/// # Errors
///
/// Returns [`LiveFrontierError`] if the retained charges disagree with the
/// retained rows, or if releasing the rows below the re-minted floor cannot
/// be reconciled with the closure accounting.
pub(in crate::lifecycle::operations) fn install_finalized_binding_fate_floor(
mut self,
measured_floor: DeliverySeq,
) -> Result<Self, LiveFrontierError> {
// FIRST, unchanged and deliberately before the re-mint: a charge/row
// disagreement is a real inconsistency and must still be reported as
// `RetainedCharge`. Letting the subsumed no-op below return early would
// swallow it.
if self.frontiers.retained_records().len() != self.retained_charges.len()
|| self
.frontiers
.retained_records()
.iter()
.zip(&self.retained_charges)
.any(|(record, charge)| {
record.delivery_seq != charge.delivery_seq()
|| record.admission_order != charge.admission_order()
})
{
return Err(LiveFrontierError::RetainedCharge);
}
let lowest_retained_marker_seq = self
.frontiers
.retained_marker_records()
.iter()
.map(|record| record.delivery_seq)
.min();
let resulting_floor = match admissible_installed_floor(
u128::from(measured_floor),
self.frontiers.retained_floor(),
lowest_retained_marker_seq,
self.frontiers.sequence().ledger().high_watermark(),
) {
AdmissibleFloor::Subsumed => return Ok(self),
AdmissibleFloor::Install(floor) => floor,
};
let released = self
.retained_charges
.iter()
.copied()
.take_while(|charge| u128::from(charge.delivery_seq()) < resulting_floor)
.collect::<Vec<_>>();
let accounting = accounting_after_floor(self.closure_accounting, &released)
.ok_or(LiveFrontierError::ClosureAccounting)?;
self.frontiers = self
.frontiers
.install_finalized_binding_fate_floor(resulting_floor)
.map_err(map_frontier_error)?;
self.retained_charges
.retain(|charge| u128::from(charge.delivery_seq()) >= resulting_floor);
self.closure_accounting = accounting;
Ok(self)
}
}