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
//! THE FOLD DOOR: where an emitted SET-similarity resolver gets the fold its `m` per-stream bests
//! are folded by.
//!
//! ```text
//! Schema::build(root, …)
//! .data(Shared::<Lance>::new(lance)) // WHERE the search runs
//! .data(FoldDoor::<Lance, ShotsByClip>::installed(Max::new())) // HOW its m streams combine
//! │
//! ▼
//! ctx.data_opt::<FoldDoor<Lance, ShotsByClip>>() → Some(fold) | None → the ELECTION's own
//! ```
//!
//! # The fold is a POLICY, and a policy has exactly one seat
//!
//! Ruled 2026-08-16. Three parties could have chosen which fold a set answer is scored by, and two
//! of them are refused:
//!
//! - **the REQUEST never chooses.** A fold changes what the answer MEANS — `sum` rewards a result
//! that answered many query vectors adequately, `max` rewards one that answered a single vector
//! perfectly — and a client able to swap that per query is a client able to make two answers of
//! one corpus that cannot be compared or cached against each other. It is the same posture every
//! other policy in this framework takes, and a request arm remains purely additive on the day one
//! is ruled.
//! - **the DECLARATION chooses the DEFAULT**, through `semantics(fold = "…")`, which is the word
//! that already exists and the one the emitted `fold_by_<field>()` accessor hands back — `Sum`
//! where an election declared none. No word is minted here.
//! - **the DEPLOYMENT overrides it at launch**, which is this module. The same act that installs
//! the door a resolver searches through installs the fold it scores through, and a deployment that
//! installs none runs the election's own.
//!
//! # THE SEAT IS A WIRE DOOR, and the family that proves it is the DOOR family
//!
//! Re-ruled 2026-08-16 (甲″), after a ruling had sent this citizen to `PolicyShelf` and three
//! measurements sent it back. The argument for the move was *policy-family uniformity*; all three of
//! its premises are false in this tree, and each is checkable:
//!
//! - `PolicyShelf` is an EMPTY trait by an explicit prior ruling — its own note refuses a knob now
//! because *a block that accepted a knob would be a knob whose meaning the selection mechanism
//! would then have to preserve*. `options ▸ policies.fold` was exactly that refused knob.
//! - NO emitted code reads any policy. The policy family serves the DRIVE layer's residents —
//! retry, overflow, deadline, tick — and the wire layer never meets it, so there was no *read it
//! exactly as the other policies are read* to follow.
//! - [`Policies`](crate::Policies) is currency-BLIND (`Arc<dyn TickPolicy>` and its siblings, none
//! generic) while [`FoldSemantics<S>`](crate::FoldSemantics) is currency-GENERIC and keyed per
//! (engine × election). Seating it there costs either a `TypeId` downcast or a new parameter on
//! `Policies`, and either way the keying below is lost.
//!
//! So the uniformity argument survives its own refutation, pointing the other way: **the wire
//! layer's uniform assembly mechanism is the ctx CITIZEN family** — [`Shared<R>`](crate::Shared),
//! [`BlobDoor`](crate::BlobDoor), [`SqlDoor`](crate::SqlDoor) — and a fold installed at launch and
//! read from a request's context is a wire fact assembled the way every other wire fact is. This
//! citizen sat in the right family from birth.
//!
//! What is genuinely still owed is the CONFIGURATION LINE: options reaching this door's
//! construction, with the fold's config in the door's OWN options section rather than in a policy
//! block. That lands with R5's emitted install glue, whose territory it always was — and it is a
//! line about how a door is BUILT, not about where the seat lives.
//!
//! # ONE DOOR PER (ENGINE × ELECTION), which is one grain finer than the search road
//!
//! The search road's citizen is keyed by the RESOURCE alone, a corpus being named per read. A fold
//! is a fact about ONE ELECTED COLUMN — a declaration electing a set of frames and a
//! set of captions has two sets of query vectors and no reason to fold them alike — so the key here
//! is the emitted ELECTION MARKER, `<Index>By<Field>`, which is the same type a lane serving that
//! column is already parameterized by. `Context::data` is a `TypeId` lookup, so the parameters ARE
//! the routing: there is no registry and no way for one election's resolver to reach another's fold.
//!
//! # It holds the fold ERASED, and the emitted door still dispatches statically
//!
//! What a resolver looks up is a concrete type, so the fold inside it is `Arc<dyn FoldSemantics<…>>`
//! — the openness living inside the citizen, exactly as a mount's own
//! [`FulltextMount`](crate::FulltextMount) impl and [`SqlDoor`](super::SqlDoor)'s pool do. The virtual call is paid ONCE PER ENTITY at the fold,
//! which is where a `Box<dyn …>` was refused for the `_with` door's own `fold` parameter — but there
//! the alternative was a caller naming the type, and here there is no caller: the type is a
//! deployment's, chosen after the schema was compiled. The Rust door beneath is untouched and still
//! takes its fold by value: `&dyn FoldSemantics<S>` folds, through the borrow's own forwarding impl.
use PhantomData;
use Arc;
use crate::;
/// The DOOR an emitted set-similarity resolver reads its fold out of — one per (engine × election) a
/// schema serves, and ABSENT wherever a deployment is content with the election's own.
///
/// Cloneable and cheap: the fold is behind an [`Arc`], so installing one costs a refcount.
///
/// # `T` is the ELECTION MARKER and carries no data
///
/// `FoldDoor<Lance, ShotsByClip>`. The marker is emitted beside the declaration and is the same type
/// the retrieve lanes are keyed by, so a deployment spells a name it already has rather than a
/// string this module would have had to invent. It is held as `PhantomData<fn(&T)>` — the crate's
/// marker spelling, holding nothing and leaving every auto trait independent of `T`.
/// Written out rather than derived, for the reason every parameterised handle in this crate writes
/// its own: a derive would bound `E: Clone` — which nothing here requires — and `T: Clone`, which is
/// an election marker and never a value.
/// Written out because a trait object carries no [`Debug`](core::fmt::Debug). What a reader wants
/// from this line is WHICH door it is and WHAT is installed in it, and the fold's own name is the
/// second half — which is one of the three places that row is spent.
/// THE FOLD one emitted set resolver runs under, or [`None`] where the deployment installed none.
///
/// # It answers `Option` rather than falling back here, and the emission is why
///
/// The fallback is the ELECTION's own — `semantics(fold = "…")`, or the shipped
/// [`Sum`](crate::Sum) where the election declared none — and that is a type only the EMISSION can
/// spell: this module has never seen the declaration. So the lookup answers whether a deployment
/// overrode it, and the resolver picks between two folds it can both name. A default invented here
/// would be this crate deciding what a declaration meant.
///
/// No refusal either, unlike [`search_slot`](super::search_slot): a missing search door is a
/// deployment that forgot to open its engine, and a missing fold door is a deployment that was
/// content with the fold its declaration elected — which is the ordinary case rather than a mistake.