@cleocode/core 2026.4.46 → 2026.4.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,7 @@
20
20
  */
21
21
 
22
22
  import { reconcileOrphanedRefs } from '../store/cross-db-cleanup.js';
23
- import { applyTemporalDecay, consolidateMemories } from './brain-lifecycle.js';
23
+ import { applyTemporalDecay, consolidateMemories, runTierPromotion } from './brain-lifecycle.js';
24
24
  import { populateEmbeddings } from './brain-retrieval.js';
25
25
 
26
26
  // ============================================================================
@@ -61,6 +61,14 @@ export interface BrainMaintenanceEmbeddingsResult {
61
61
  errors: number;
62
62
  }
63
63
 
64
+ /** Tier promotion step result. */
65
+ export interface BrainMaintenanceTierPromotionResult {
66
+ /** Number of entries promoted (short→medium or medium→long). */
67
+ promoted: number;
68
+ /** Number of stale short-tier entries soft-evicted. */
69
+ evicted: number;
70
+ }
71
+
64
72
  /**
65
73
  * Aggregated result from a full brain maintenance run.
66
74
  *
@@ -74,6 +82,8 @@ export interface BrainMaintenanceResult {
74
82
  consolidation: BrainMaintenanceConsolidationResult;
75
83
  /** Results from the cross-DB orphaned reference reconciliation step. */
76
84
  reconciliation: BrainMaintenanceReconciliationResult;
85
+ /** Results from the tier promotion step. */
86
+ tierPromotion: BrainMaintenanceTierPromotionResult;
77
87
  /** Results from the embedding backfill step. */
78
88
  embeddings: BrainMaintenanceEmbeddingsResult;
79
89
  /** Total wall-clock duration of the maintenance run in milliseconds. */
@@ -93,6 +103,8 @@ export interface BrainMaintenanceOptions {
93
103
  skipConsolidation?: boolean;
94
104
  /** Skip the cross-DB orphaned reference reconciliation step. Default: false. */
95
105
  skipReconciliation?: boolean;
106
+ /** Skip the tier promotion step (short→medium, medium→long). Default: false. */
107
+ skipTierPromotion?: boolean;
96
108
  /** Skip the embedding backfill step. Default: false. */
97
109
  skipEmbeddings?: boolean;
98
110
  /**
@@ -146,6 +158,7 @@ export async function runBrainMaintenance(
146
158
  skipDecay = false,
147
159
  skipConsolidation = false,
148
160
  skipReconciliation = false,
161
+ skipTierPromotion = false,
149
162
  skipEmbeddings = false,
150
163
  onProgress,
151
164
  } = options ?? {};
@@ -160,6 +173,7 @@ export async function runBrainMaintenance(
160
173
  observationsFixed: 0,
161
174
  linksRemoved: 0,
162
175
  };
176
+ const tierPromotionResult: BrainMaintenanceTierPromotionResult = { promoted: 0, evicted: 0 };
163
177
  const embeddingsResult: BrainMaintenanceEmbeddingsResult = {
164
178
  processed: 0,
165
179
  skipped: 0,
@@ -193,7 +207,17 @@ export async function runBrainMaintenance(
193
207
  onProgress?.('reconciliation', 1, 1);
194
208
  }
195
209
 
196
- // Step 4: Embedding backfill (with per-item progress relay)
210
+ // Step 4: Tier promotion promote short→medium and medium→long based on
211
+ // age, quality score, citation count, and verification status (T614).
212
+ if (!skipTierPromotion) {
213
+ onProgress?.('tier-promotion', 0, 1);
214
+ const raw = await runTierPromotion(projectRoot);
215
+ tierPromotionResult.promoted = raw.promoted.length;
216
+ tierPromotionResult.evicted = raw.evicted.length;
217
+ onProgress?.('tier-promotion', 1, 1);
218
+ }
219
+
220
+ // Step 5: Embedding backfill (with per-item progress relay)
197
221
  if (!skipEmbeddings) {
198
222
  const raw = await populateEmbeddings(projectRoot, {
199
223
  onProgress: (current, total) => {
@@ -209,6 +233,7 @@ export async function runBrainMaintenance(
209
233
  decay: decayResult,
210
234
  consolidation: consolidationResult,
211
235
  reconciliation: reconciliationResult,
236
+ tierPromotion: tierPromotionResult,
212
237
  embeddings: embeddingsResult,
213
238
  duration: Date.now() - startTime,
214
239
  };