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
// Copyright 2026 AlphaOne LLC
// SPDX-License-Identifier: Apache-2.0
//! `CompactionPass` trait — the generic pipeline interface that every
//! compaction strategy (consolidation, reflection, forget-superseded, …)
//! must implement.
//!
//! ## Design contract
//!
//! A `CompactionPass` encapsulates one full lifecycle of compaction:
//!
//! 1. **`cluster`** — partition an input slice of memories into groups
//! that are candidates for compaction. Groups with < 2 members are
//! ignored by callers.
//! 2. **`eligible`** — secondary gate: given an already-formed cluster,
//! decide whether this pass should actually act on it (e.g. minimum
//! cluster size, namespace allow-lists, dry-run).
//! 3. **`summarize`** — produce the single consolidated [`Memory`] that
//! replaces the cluster. Must NOT write to the database.
//! 4. **`persist`** — atomically write the summary and record the source
//! ids in the rollback log.
//! 5. **`verify`** — check that the persisted summary is readable and
//! internally consistent. A failure here does NOT yet trigger rollback
//! (rollback is v0.8.0 Pillar 2.5 scope — see issue #664).
//!
//! ## Visibility contract (R7)
//!
//! The trait is `pub(crate)`. Every helper exposed from this module is
//! at most `pub(super)`. No new bare `pub` items.
//!
//! ## L2-1 hook
//!
//! `ReflectionPass` (Task L2-1) will `impl CompactionPass` against this
//! trait. The trait is intentionally small so the reflection engine can
//! plug in with zero changes to the pipeline runner.
use Result;
use crateMemory;
/// Type alias used throughout the compaction pipeline. A memory's
/// stable identifier is its `id` field — a UUID string.
// L1-7: type alias is defined here; external call-sites land in L2-1.
pub type MemoryId = String;
// ---------------------------------------------------------------------------
// CompactionPass trait
// ---------------------------------------------------------------------------
/// A single, self-contained compaction strategy.
///
/// Implementors live in `src/curator/compaction.rs`
/// (`ConsolidationPass`) and future `src/curator/reflection_pass.rs`
/// (`ReflectionPass`, Task L2-1). The pipeline runner in
/// `src/curator/compaction.rs` drives the six-step lifecycle.
// L1-7: trait is defined here; the generic runner and L2-1 impl ship next.
pub