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
//! Reindex lifecycle phases and bar-slot mapping.
//!
//! Why: the phase enum and its bar-slot mapping are referenced by three separate
//! files (`bars.rs`, `timings.rs`, and the `reindex_engine` submodules). Placing
//! them in their own module avoids circular dependencies and makes the phase
//! semantics independently reviewable.
//!
//! What: `ReindexPhase` encodes the lifecycle of a foreground reindex as a
//! strongly-typed value; `phase_to_bar_slot` maps each phase to the indicatif
//! bar slot it drives (0–3, or `None` for phases with no dedicated bar).
//!
//! Test: `tests::phase_labels_are_stable` and `tests::phase_to_bar_slot_coverage`
//! pin every string and slot mapping to prevent silent regressions.
// ─── Phase enum ──────────────────────────────────────────────────────────────
/// Distinct phases of a reindex, each corresponding to one of the 4 sequential
/// progress bars shown in the CLI.
///
/// Why: encodes the lifecycle of a reindex as a strongly-typed value so the
/// event loop in `reindex_engine.rs` can call `set_phase(…)` without magic
/// strings. Issue #401: four named bars replace the single relabelled bar of
/// the previous design (issue #317).
///
/// `ParseEmbed` is kept as a legacy alias for `Embedding` so existing tests
/// that used the old variant compile without modification.
///
/// What: each variant maps to a human-readable label via `label()`.
/// Test: `tests::phase_labels_are_stable` pins every label string.
pub
// ─── Bar-slot mapping ─────────────────────────────────────────────────────────
/// Which of the 4 stage bars a given phase maps to.
///
/// Why: the 4-bar layout has Crawl/Chunk/Embed/KG slots (bars 0–3). Not every
/// `ReindexPhase` drives a bar (e.g. `Bm25` and `Upsert` are fused into
/// batches and have no dedicated bar), so this mapping lives here rather than
/// on the enum itself.
/// What: returns `Some(0..=3)` for the four concrete stages, `None` for
/// everything else (the caller leaves the bar layout unchanged).
/// Test: `tests::phase_to_bar_slot_coverage` asserts every variant.
pub