Repository navigation
fix(session): decouple Phase 2 extraction from live session files - #6332
Merged
Merged
Conversation
Keep archive isolation, metadata preservation and redelivery checks in the existing queued commit contract test. Remove the additional failure matrix and recovery test.
qin-ctx
approved these changes
Oct 20, 2026
3 of 4 tasks
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.
说明
队列消费者启动 Session Phase 2 时会先执行
session.load(),读取可能正在被前台 Phase 1 重写的实时messages.jsonl。实际提取已经使用归档消息和策略快照,这次完整加载既不必要,也引入了并发读取风险。另外,恢复和统计更新读取.meta.json失败时,原逻辑可能回退到旧的内存元数据并覆盖最新状态。补齐恢复与验证:恢复时补写自动提交冷却时间,更新核心测试和中英文文档。260 个相关测试、3 个真实场景验证通过。
人工参与
关联问题
暂无关联 issue;修复 Session Phase 2 启动时读取实时消息文件的并发风险。
变更类型
主要改动
phase1_recovery失败,不进入提取;成功恢复时补齐自动提交冷却时间。logger.warning,保留原.meta.json并继续完成归档。token_usage字段结构和数值类型;统计不可用时返回完整零值对象,零值只用于响应,不写回元数据。不新增stats_update字段,调用方无需修改解析逻辑。异常时返回的零值表示统计不可用,并不代表实际消耗为零;本次累计 token 和记忆数量不会自动补计,提取结果和遥测保留。
测试
单元测试:253 个通过。
集成回归:7 个通过,包含同步最新
main后的提取重试用例。运行时通过PYTHONPATH加载由当前源码构建的 RAGFS 绑定,未修改仓库内的二进制文件。.venv/bin/python -m pytest -q --no-cov -o addopts='' --tb=short -x \ tests/session/test_session_retention_integration.py::test_interrupted_phase1_recovers_when_root_rewrite_is_durable \ tests/session/test_session_retention_integration.py::test_session_state_lock_serializes_root_meta_without_blocking_archive_write \ tests/session/test_session_commit.py::TestCommit::test_memory_apply_failure_retries_only_before_any_write使用本地
ov.conf、真实 VLM 和实际 QueueFS worker,在独立数据目录验证三种场景,均通过:completed、生成.done,返回正常累计统计。上述三个场景的 Phase 2 实时
messages.jsonl读取次数均为 0。原始半条 JSON 竞态来自代码链路分析,验证采用确定性的故障注入和并发控制。检查清单
git diff --check通过补充说明
未运行全仓测试。pytest 输出 8 条既有依赖弃用警告。
类型检查未全绿:对两个变更的生产文件运行以下命令得到 7 条错误;使用
--shadow-file对照最新main源码,错误消息完全一致,本次修改未增加类型错误。