Skip to content

fix(dream): degraded 轮跳过明细落库到 dream_runs.skipped (#104) - #142

Merged
modusensus merged 1 commit into
slow-stack:mainfrom
483218131:fix/dream-degraded-skipped-104
Sep 12, 2026
Merged

modusensus merged 1 commit into
slow-stack:mainfrom
483218131:fix/dream-degraded-skipped-104

Conversation

@483218131

@483218131 483218131 commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

背景

degraded(合法子集已应用)路径上,validateDecisions 会把非法决策就地 splice 出数组(数组长度可能不变、内容已变——src/dream/decisions.js 末尾有一段注释专门说明这一点),dream_runs.decisions 落库的是幸存列表,被跳过的条目只进 logger.warn。

离线回放 dream_runs 因此无法定位 degraded 的成因:分不清被跳的是跨类型 merge、update 保护期还是 unknown id。

#137 覆盖的是整单拒绝(failed)路径(decisions: [{ _validationFailed: true, errors, skipped }]),degraded 路径此前没有等价的落库形态。

证据等级:

论断 等级 依据
被跳决策在 validateDecisions 里被就地抹掉 可执行实测 用 main 的 src/dream/decisions.js 纯函数复现,输出见 #104 跟进评论
degraded 出口不把 skipped 交给落库 代码结构事实 main 的 src/dream.js degraded 出口 finish 载荷不含 skipped

改动

按 #104 中确认的形态实现——独立字段,不用内联标记:

文件 改动
src/store.js dream_runs 新增 skipped TEXT(JSON)+ addColumn 幂等迁移(同 policy_epoch/run_type 先例);saveDreamRun 写入、toDreamRun 读回
src/dream.js degraded 出口把 skipped 透传给 finish,由 finish 写进审计行
test/dream.test.js 新增断言:degraded run 的审计行含逐条 index/action/error,且 decisions 不含内联标记

只在真发生跳过时才写(degraded 也可能仅因 summary 为空而 degraded),ok 轮落 NULL——避免「空数组」与「无此字段」两种假明细占据审计行。

这样 degraded 与 failed 两条路径的处置都可在审计行里离线定位,不必重跑 LLM。

验证

npm test:848 个用例,847 通过。唯一失败是 test/peer-blockers.test.js 的 peer-C(8 进程并发原子递增),在本机沙箱下 spawn EPERM(环境不允许子进程命名管道),与本改动无关。

lib/ 由 npm run sync 同步(仅 dream.js / store.js 内容变化)。

Summary by CodeRabbit

  • Bug Fixes

    • Degraded consolidation runs now preserve details about decisions that were skipped due to validation issues.
    • Run results and audit records distinguish partially applied runs from successful runs without adding empty skip data.
    • Previously recorded runs continue to work through an automatic database update.
  • Observability

    • Skipped decision details are now available in the run history, improving troubleshooting and replayability of degraded runs.

宽容路径上 validateDecisions 就地 splice 抹掉被跳决策(数组长度不变、内容已变),
dream_runs.decisions 存的已是幸存列表,被跳条目只进 logger.warn——离线回放
degraded 轮无法判断被跳的是跨类型 merge、update 保护期还是 unknown id。
slow-stack#137 只覆盖了整单拒绝(failed)路径。

- src/store.js: dream_runs 新增 skipped TEXT 列(JSON,addColumn 迁移,同
  policy_epoch/run_type 先例),saveDreamRun 写入 + toDreamRun 读回;
- src/dream.js: degraded 出口把 skipped 明细透传给 finish,写独立字段而不内联进
  decisions(degraded 的 decisions 是合法子集,下游按「决策数组」消费);
- test/dream.test.js: 断言 degraded 审计行含 index/action/error,且 decisions
  不含内联标记;
- lib/ 由 npm run sync 同步(仅 dream.js / store.js 内容变化)。

测试:839/840 通过。唯一失败 test/peer-blockers.test.js 的 peer-C(8 进程并发
原子递增)在本机沙箱下 spawn EPERM,与本改动无关。
@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: fe6793a2-b713-4906-9576-29b017983b8c

📥 Commits

Reviewing files that changed from the base of the PR and between 4666d56 and adff10a.

📒 Files selected for processing (5)
  • dsh-mneme/lib/dream.js
  • dsh-mneme/lib/store.js
  • dsh-mneme/src/dream.js
  • dsh-mneme/src/store.js
  • dsh-mneme/test/dream.test.js

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds nullable skipped audit data for degraded consolidation runs. Run results include skipped decisions only when present. Both storage implementations support schema migration, JSON serialization, deserialization, and upsert handling. A regression test verifies persistence.

Changes

Skipped decision audit

Layer / File(s) Summary
Propagate skipped decisions
dsh-mneme/lib/dream.js, dsh-mneme/src/dream.js
runDream returns skipped decision details only for degraded runs. finish passes those details to saveDreamRun.
Store skipped audit data
dsh-mneme/lib/store.js, dsh-mneme/src/store.js
The dream_runs table gains a nullable JSON column. Legacy databases migrate the column. Row mapping, inserts, and conflict updates serialize and parse the field.
Validate degraded-run persistence
dsh-mneme/test/dream.test.js
The test verifies that an invalid cross-type decision is persisted in run.skipped without adding markers to run.decisions.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: modusensus

Merge Risk: ⚪ Minimal · up to adff1

Skipped decision audit details are retained for degraded runs while normal runs remain unchanged. No actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: persisting skipped details from degraded dream rounds into dream_runs.skipped.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants