@@ -3871,6 +3871,38 @@ export function createStore(path) {
38713871 ) . run ( before ) . changes ;
38723872 }
38733873
3874+ // #557 的裁列面:input 之外的大头是 decisions / outcome 两列 JSON(issue 评论区
3875+ // 实测 13.26 MB 列文本里 50.1% + 30.5%)。拍板 3 的口径是「裁列同意、删行不同意」
3876+ // ——行与骨架列(status / provider / receipt / policy_epoch / store_count…)永远
3877+ // 保留,回放能力对窗口外的轮次降级为骨架级(与 reclaim 清 input、#625 的瘦身同
3878+ // 一条口径)。organize 行整体豁免:input 是 apply 的重放载荷、outcome 挂着
3879+ // dry_run_id / applied_at 链,裁了会让 apply 静默空转(clearDreamRunInputs 的同一
3880+ // 条边界)。读侧已逐个核对:lastDreamRunAt / lastDreamBaseline / getLatestPolicyEpoch
3881+ // 读的都是骨架列,/dream-status 的 decisions.demotion 是可选链(裁掉的老轮退化成
3882+ // null);reclaim 的 A 项刻意不碰 decisions/outcome——那是「随手跑的无损回收」的
3883+ // 边界,这里是显式配置键(dreamRunsTrimDays,opt-in 默认 0 = 关)驱动的启动期裁剪。
3884+ function dreamRunsTrimStats ( before ) {
3885+ const row = db . prepare (
3886+ `SELECT count(*) AS c,
3887+ COALESCE(SUM(LENGTH(input)), 0) + COALESCE(SUM(LENGTH(decisions)), 0)
3888+ + COALESCE(SUM(LENGTH(outcome)), 0) AS b
3889+ FROM dream_runs
3890+ WHERE created_at < ? AND run_type != 'organize'
3891+ AND (input IS NOT NULL OR decisions IS NOT NULL OR outcome IS NOT NULL)`
3892+ ) . get ( before ) ;
3893+ return { runs : row . c , bytes : row . b } ;
3894+ }
3895+
3896+ /** 裁掉窗口外 run 的三列重载(organize 豁免)。返回实际改动的行数;重跑幂等。 */
3897+ function trimDreamRunPayloads ( before ) {
3898+ return db . prepare (
3899+ `UPDATE dream_runs
3900+ SET input = NULL, decisions = NULL, outcome = NULL
3901+ WHERE created_at < ? AND run_type != 'organize'
3902+ AND (input IS NOT NULL OR decisions IS NOT NULL OR outcome IS NOT NULL)`
3903+ ) . run ( before ) . changes ;
3904+ }
3905+
38743906 /**
38753907 * 归档行仍带的向量统计(#275 B 项)。检索 SQL 恒带 `archived = 0`,所以这部分
38763908 * 向量按定义不可达,清掉不改变任何检索结果。
@@ -5986,6 +6018,8 @@ export function createStore(path) {
59866018 // 存储生命周期(#275 第一批):无损回收的统计、清理与体积口径。
59876019 dreamRunInputStats,
59886020 clearDreamRunInputs,
6021+ dreamRunsTrimStats,
6022+ trimDreamRunPayloads,
59896023 archivedEmbeddingStats,
59906024 clearArchivedEmbeddings,
59916025 storageStats,
0 commit comments