fix(agent-runtime): persist evidence ledger - #2426
Open
zvzuola wants to merge 1 commit into
Open
Conversation
limityan
requested changes
Aug 22, 2026
limityan
left a comment
Collaborator
There was a problem hiding this comment.
需要修改:回退会话后,已撤销的证据会在重启后重新出现
发生场景
- 某个会话 turn 产生了文件修改前的 checkpoint、失败命令,或 subagent 的部分结果。
- 用户把会话回退到这个 turn 之前,表示这些后续执行已经被撤销。
- 用户关闭并重新打开会话,或应用重启后恢复该会话。
当前行为
恢复代码会正确隐藏回退点之后的对话 turn,但随后仍会从 evidence-ledger.json 加载全部历史证据。永久提交回退时,代码也只删除对话 turn、上下文快照和压缩产物,没有同步删除被回退 turn 对应的 ledger 记录。
造成的后果
重启后,已经被用户撤销的文件、失败命令和 subagent 结果会再次进入上下文压缩与 Deep Review。系统会把旧工作误认为当前事实,可能让 Agent 继续处理已经撤销的文件或问题。换句话说:界面中的会话已经回退,但 Agent 使用的证据没有一起回退。
修复要求
- staged revert 和永久回退都应按仍然保留的 turn ID,同步裁剪磁盘 sidecar 与内存 ledger。
- 恢复会话时,只应发布当前可见 turn 对应的证据。
- 增加回归测试:先产生 evidence,再 rollback,随后 unload/restore,确认 compression contract 不再包含被撤销 turn 的证据。
该问题会破坏本 PR 要保证的恢复一致性,因此修复前建议不要合并。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Persist
EvidenceLedgerevents across session unloads, restarts, and restores to prevent long-running tasks from losing checkpoints, compression evidence, and partial subagent results.The ledger is stored as a versioned
evidence-ledger.jsonsidecar under the resolved session directory.Type and Areas
Type: Bug fix / reliability
Areas: Rust core, Agent Runtime, session persistence, remote workspace
Motivation / Impact
Previously,
EvidenceLedgerexisted only in process memory. When a session was unloaded or the host restarted, the ledger was lost. This could cause long-running tasks to lose important execution evidence and drift away from their original objective.This change:
event_id.No new user-facing strings, locale changes, or UI changes are required.
Verification
cargo check --locked -p bitfun-agent-runtime --no-default-features --features agent-runtime— passed.cargo test --locked -p bitfun-agent-runtime --no-default-features --features agent-runtime --lib evidence_ledger— 11 passed.cargo test --locked -p bitfun-core --no-default-features --features agent-runtime --lib evidence_ledger— 4 passed.cargo test --locked -p bitfun-core --no-default-features --features agent-runtime --lib concurrent_evidence_appends_keep_disk_and_memory_complete— passed.cargo test --locked -p bitfun-core --no-default-features --features agent-runtime,remote-workspace --lib remote_workspace_evidence_uses_the_resolved_session_mirror— passed.cargo check --locked -p bitfun-core --no-default-features --features product-full— passed.pnpm run check:core-boundaries— passed.pnpm run fmt:rs— passed.git diff --check— passed.The remote workspace scenario was exercised. Remote control, Peer Device Mode, and Detached Dispatch protocols were not changed by this PR and were not modified in the tests.
Reviewer Notes
1.Checklist