fix(checkpoint): 保留 Persona 生成期间的并发更新#474
Conversation
YOMXXX
left a comment
There was a problem hiding this comment.
Approved.
I verified the PR locally on the branch with Node 24.15.0:
COREPACK_ENABLE_AUTO_PIN=0 pnpm vitest run src/utils/checkpoint.test.ts— 1 file / 4 tests passedCOREPACK_ENABLE_AUTO_PIN=0 pnpm test— 5 files / 71 tests passedCOREPACK_ENABLE_AUTO_PIN=0 pnpm build— passedgit diff --check HEAD~1..HEAD— passed
This is complementary to #177 rather than a duplicate of the recalibration lane. #177 handles post-cleanup counter reconciliation; this PR fixes the runtime race where persona generation clears work that arrived while the persona model was running. The baseline/coverage approach preserves concurrent L1 memory increments, keeps the legacy single-argument API behavior, and uses the scene time watermark captured before reading scene data.
|
Thank you for submitting this PR and participating in Tencent Rhino-bird Open-source Training Program! |
Description | 描述
本 PR 修复 Persona 生成完成时覆盖并发 checkpoint 更新的问题。
维护者已将 #177 确定为 #157 的标准计数重校准方案。本 PR 不实现
recalibrate(),也不替代 #177,而是解决其未覆盖的运行时并发问题。问题根因
L1、L2、L3 使用三条相互独立的队列。Persona 模型生成最长可运行 180 秒,在此期间其他会话仍可继续完成 L1/L2 处理。
当前 Persona 完成后会:
total_processed更新last_persona_atlast_persona_time设置为完成时间memories_since_last_persona清零因此,生成期间新增的 L1 记忆会被错误视为已经包含在当前 Persona 中;同时,生成期间更新的场景也可能落在新的时间水位之前,导致下一轮无法识别这些变化。
修复方案
last_persona_at写为生成开始时的消息水位。last_persona_time写为读取场景前的时间水位,确保并发场景更新仍可在下一轮被识别。markPersonaGenerated(totalProcessed)单参数调用的原有清零行为,避免破坏外部兼容性。行为示例
生成开始时:
memories_since_last_persona = 3生成期间另一条 L1 队列新增:
+2条记忆旧行为:
0修复后:
3条2条继续保留Related Issue | 关联 Issue
Related to #157
#177 仍是清理后计数重校准的标准修复;本 PR 仅处理 Persona 生成期间的并发覆盖竞态,因此不使用
Fixes #157。Change Type | 修改类型
Verification | 验证
4/4通过71/71通过git diff --check:通过自测覆盖:
验证截图