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
//! Candidate-search plans: DSFB's only output that affects the pipeline —
//! an *ordered* list of channels to try and a budget. Selection of the
//! winning representation is always exact cost (ADR-0004/0010).
//!
//! # Purpose
//!
//! Translate a chunk's regime and trust vector into the only artifact the
//! search consumes from DSFB (`src/optimizer/search.rs`): a total order
//! over channels plus a budget that bounds how many ordered positions are
//! evaluated. The winning representation is always chosen by exact
//! deterministic cost (ADR-0010) after byte-exact validation (§32) — this
//! plan only decides what gets *searched for*, and in what order.
//!
//! # Units
//!
//! Budgets are **candidate counts** — the number of ordered plan positions
//! that may be evaluated — not bytes and not a cap on the whole search.
//! The always-on families (exact dedup, structural, rANS, RAW) are
//! evaluated regardless; only the budgeted base/universe channels
//! (`BUDGETED_CHANNELS` in `src/optimizer/search.rs`) are consumed from
//! the plan.
//!
//! # Regime → strategy mapping
//!
//! `ShardedStorageObserver::plan` maps: Stable/Unknown → Narrow (4),
//! Drift → Balanced (12), Slew → Broad (32). Drift keeps the basis — the
//! winning channel ranks first by trust — with a mid budget so slow
//! residual evolution is re-checked without paying full search cost; slew
//! broadens to everything; stable narrows to the trusted head of the
//! order.
//!
//! # Boundary
//!
//! A plan never decides which representation wins; it contains only
//! evaluation order and a budget. It is a value type produced under the
//! store's DSFB mutex and consumed lock-free afterwards.
//!
//! # Invariants
//!
//! - `budget` equals `SearchStrategy::budget()` for the carried strategy.
//! - `should_evaluate` is true exactly for positions `< budget` whose
//! channel sits at that position — the caller iterates positions in
//! order, so this is the budget gate.
use crateChannel;
/// Search strategy (regime-derived): the breadth the search may use.
/// The ordered candidate-search plan for one chunk.
///
/// Role: the complete DSFB output consumed by the search.
/// `ordered_channels` is a total order over all channels
/// (trust-descending); `strategy` and `budget` bound how many of those
/// positions are actually evaluated.