@@ -43,7 +43,8 @@ CREATE TABLE IF NOT EXISTS dream_runs (
4343 summary_stored INTEGER NOT NULL DEFAULT 0,
4444 receipt TEXT NOT NULL,
4545 policy_epoch INTEGER NOT NULL DEFAULT 0, -- 裁决规则版本:规则升级后旧裁决降级为历史证据
46- run_type TEXT NOT NULL DEFAULT 'auto' -- auto | sleep:睡眠周期的审计区分
46+ run_type TEXT NOT NULL DEFAULT 'auto', -- auto | sleep:睡眠周期的审计区分
47+ skipped TEXT -- JSON: degraded 轮被跳过的逐条明细(index/action/ids/error)
4748);
4849CREATE INDEX IF NOT EXISTS idx_dream_runs_created ON dream_runs(created_at);
4950
@@ -371,7 +372,9 @@ function toDreamRun(row) {
371372 summary_stored : row . summary_stored === 1 ,
372373 receipt : row . receipt ,
373374 policy_epoch : row . policy_epoch ?? 0 ,
374- run_type : row . run_type ?? "auto"
375+ run_type : row . run_type ?? "auto" ,
376+ // Issue #104:degraded 轮的逐条跳过明细(JSON 列,NULL = 该轮无跳过项)。
377+ skipped : row . skipped ? JSON . parse ( row . skipped ) : undefined
375378 } ;
376379}
377380
@@ -597,6 +600,9 @@ export function createStore(path) {
597600 // Legacy dream_runs without policy_epoch → backfill with the default epoch.
598601 addColumn ( "dream_runs" , "policy_epoch" , "ALTER TABLE dream_runs ADD COLUMN policy_epoch INTEGER NOT NULL DEFAULT 0" ) ;
599602 addColumn ( "dream_runs" , "run_type" , "ALTER TABLE dream_runs ADD COLUMN run_type TEXT NOT NULL DEFAULT 'auto'" ) ;
603+ // Issue #104:degraded(合法子集已应用)轮被跳过的决策明细。此前只进 logger.warn,
604+ // 离线回放 dream_runs 无法定位 degraded 成因(跨类型 merge / update 保护期 / unknown id)。
605+ addColumn ( "dream_runs" , "skipped" , "ALTER TABLE dream_runs ADD COLUMN skipped TEXT" ) ;
600606
601607 // Legacy mirror_state without v0.3.6 generation columns → add each missing
602608 // column idempotently (old DBs open cleanly, no data loss).
@@ -1126,16 +1132,20 @@ export function createStore(path) {
11261132 const now = nowIso ( ) ;
11271133 const policyEpoch = Number . isInteger ( run . policy_epoch ) ? run . policy_epoch : 0 ;
11281134 const runType = run . run_type ?? "auto" ;
1135+ // Issue #104:degraded 轮的跳过明细(JSON)。与 decisions/outcome 同为可选
1136+ // 载荷,未提供时落 NULL(而不是 "[]"),审计行只记真实发生过的跳过。
1137+ const skipped = run . skipped !== undefined ? JSON . stringify ( run . skipped ) : null ;
11291138 db . prepare (
11301139 `INSERT INTO dream_runs (id, created_at, status, error, provider, model, snapshot_hash,
1131- input_count, input, decisions, outcome, applied, summary_stored, receipt, policy_epoch, run_type)
1132- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
1140+ input_count, input, decisions, outcome, applied, summary_stored, receipt, policy_epoch, run_type, skipped )
1141+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
11331142 ON CONFLICT(id) DO UPDATE SET
11341143 created_at=excluded.created_at, status=excluded.status, error=excluded.error,
11351144 provider=excluded.provider, model=excluded.model, snapshot_hash=excluded.snapshot_hash,
11361145 input_count=excluded.input_count, input=excluded.input, decisions=excluded.decisions,
11371146 outcome=excluded.outcome, applied=excluded.applied, summary_stored=excluded.summary_stored,
1138- receipt=excluded.receipt, policy_epoch=excluded.policy_epoch, run_type=excluded.run_type`
1147+ receipt=excluded.receipt, policy_epoch=excluded.policy_epoch, run_type=excluded.run_type,
1148+ skipped=excluded.skipped`
11391149 ) . run (
11401150 id ,
11411151 run . created_at ?? now ,
@@ -1152,7 +1162,8 @@ export function createStore(path) {
11521162 run . summary_stored ? 1 : 0 ,
11531163 run . receipt ,
11541164 policyEpoch ,
1155- runType
1165+ runType ,
1166+ skipped
11561167 ) ;
11571168 return getDreamRun ( id ) ;
11581169 }
0 commit comments