Skip to content

fix(eval): 串行化评估存储写入,避免反馈与追踪记录相互覆盖 - #423

Open
soyorin33 wants to merge 1 commit into
helsome:mainfrom
soyorin33:fix/evaluation-store-concurrency
Open

soyorin33 wants to merge 1 commit into
helsome:mainfrom
soyorin33:fix/evaluation-store-concurrency

Conversation

@soyorin33

Copy link
Copy Markdown

改动说明

EvaluationStore 的运行、结果、设置、反馈和 trace 等九个写入口共用 evaluation/store.json,原先各自执行读取 → 修改 → 保存。并发 addFeedback 和 recordTraceLink 可以都成功返回,但后一次保存会覆盖前一次记录。底层 JSON 原子替换只能保护一次写入,不能保护整个读改写周期。

本次复用现有 withWriteLock,通过私有 mutate 方法串行化全部九个写入口。同一文件跨实例共享队列,并统一绝对/相对路径及 Windows 大小写路径。API、文件结构与记录保留上限不变。

新增可控并发回归和真实 JsonFileStore 集成测试:同实例反馈并发、跨实例设置/trace/反馈混合写入、Windows 路径别名、写失败后的队列恢复,以及并发保存 12 组 run/trace/feedback 后由新实例完整重载。

关联 Issue

未关联现有 Issue。已核对当前 main 与已有 PR;此前其他仓库的读改写保护没有覆盖 EvaluationStore。

测试报告

环境

  • Bun:1.4.2 (744846f84)
  • OS:Windows NT 10.0.26300.0
  • 基线:helsome/folio 的 main,e42e9279bf6aac810dd1361ba458fec0b94be9dc
  • 依赖:bun install --frozen-lockfile --ignore-scripts

实际执行命令与结果

bun test packages/shared/src/evaluation/store.concurrent.test.ts
→ 原生产代码 + 新回归:1 pass / 4 fail
→ 修复后:5 pass / 0 fail / 23 expect

bun test --isolate packages/shared/src/evaluation packages/shared/src/storage
→ 221 pass / 0 fail / 1299 expect(15 files)

bun test packages/shared --isolate
→ 1482 pass / 0 fail / 5915 expect(121 files)

bun run typecheck
→ core / i18n / shared / ui / electron 全部 exit 0

git diff --check
→ exit 0
  • 已提供实际测试命令、环境和结果
  • 核心改动已有 focused test 与真实磁盘持久化集成验证
  • 本 PR 无可见 UI 变化(仅存储行为与测试)

Scope / 后续

保护同一进程中指向同一文件的并发读改写;不引入跨操作系统进程锁,也不处理符号链接别名。

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.

1 participant