Skip to content

fix: JSONStore.exists() validates meta.json integrity and add Agent.r…#37

Merged
CrazyBoyM merged 1 commit intoshareAI-lab:mainfrom
Gui-Yue:fix/jsonstore-exists-resume-consistency
Feb 11, 2026
Merged

fix: JSONStore.exists() validates meta.json integrity and add Agent.r…#37
CrazyBoyM merged 1 commit intoshareAI-lab:mainfrom
Gui-Yue:fix/jsonstore-exists-resume-consistency

Conversation

@Gui-Yue
Copy link
Contributor

@Gui-Yue Gui-Yue commented Feb 10, 2026

Summary

修复 JSONStore.exists()Agent.resumeFromStore() 的语义不一致。增强 exists() 使其验证 meta.json 完整性,并新增 Agent.resumeOrCreate() 提供安全的恢复回退机制。

Motivation / Context

JSONStore.exists() 仅通过 fs.access 检查目录是否存在,不验证 meta.json。导致目录存在但数据损坏时 exists() 返回 true,而 resumeFromStore() 抛出 ResumeError。集成方必须自行编写 try-catch + 清理逻辑。SQLite/Postgres Store 基于数据库查询,不存在此问题。相关 issue: #4

Type of Change

  • 缺陷修复
  • 新功能
  • 重构
  • 文档
  • 测试
  • 构建/杂项

Scope / Modules

  • core (agent / events / pool / room / scheduler)
  • infra (db / provider / sandbox / store)
  • tools (fs / bash / mcp / skills / task)
  • skills
  • examples
  • docs (en / zh-CN)
  • tests
  • other: ___

Public API

  • src/index.ts 导出有变更
  • 无公开 API 变更

Breaking Changes

  • 有,附报告(含必要性说明)及过渡方案

Testing

  • npm run test:unit(必需)
  • npm run test:integration(按需)
  • npm run test:e2e(按需)

Impact / Risk

  • JSONStore.exists() 对目录存在但 meta.json 缺失/损坏的情况现在返回 false,与 SQLite/Postgres Store 语义对齐。依赖旧行为(仅检查目录)的代码可能受影响。
  • Agent.resumeOrCreate() 是新增方法,不影响现有代码。

Checklist

  • 新功能包含相关测试
  • 测试遵循 tests/README.md 规范
  • 未提交密钥或令牌
  • dist/ 变更
  • 仅更新对应包管理器的 lockfile

@CrazyBoyM CrazyBoyM merged commit 88cdd88 into shareAI-lab:main Feb 11, 2026
8 checks passed
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