Skip to content

v0.1.0 — MVP: 副作用安全测试

Choose a tag to compare

@HangChi HangChi released this 12 Nov 15:49
· 88 commits to main since this release

AgentReplayGuard v0.1.0

首个 MVP 版本:面向 LangGraph + pytest 的确定性副作用安全测试工具,验证重试、Checkpoint 恢复与 Interrupt 重放不会重复执行外部副作用。

核心能力

  • EffectGuard:用 @guard.effect 包裹有副作用的工具,记录每次提交并可断言「服务端提交了几次」
  • 确定性故障注入:lost-ack(提交成功但响应丢失)、before_commit、after_commit,支持按次数与固定 seed 概率
  • 三条重放路径覆盖:显式重试、LangGraph Checkpoint resume、Command(resume=...) interrupt 恢复
  • 业务不变量:NoDuplicateEffects、MaxEffectCount、CustomInvariant
  • 可定位报告:确定性文本报告,包含 effect 账本、attempt 累计与违规期望/实际值
  • pytest 插件:replayguard fixture,单场景 <5 秒、断网可运行

快速开始

pip install "agentreplayguard[langgraph] @ git+https://github.com/HangChi/AgentReplayGuard.git@v0.1.0"
# 或本地开发
git clone https://github.com/HangChi/AgentReplayGuard.git && cd AgentReplayGuard
uv sync --extra dev --extra langgraph
uv run pytest examples/refund -q

参考示例:lost-ack 复现、幂等键修复、Checkpoint 恢复、Interrupt 重放。

质量状态

  • 92 个测试通过(单元 / 契约 / 集成 / 示例),核心模块行覆盖率 97%
  • ruff check、mypy 全绿;CI 覆盖 Linux/macOS × Python 3.10–3.13,含断网确定性任务

已知限制(0.1.x)

  • 仅适配 LangGraph,尚未支持其他 Agent 框架
  • 故障注入作用于模拟服务,不代理真实网络层
  • API 可能在小版本内演进,1.0 前不做兼容承诺

完整设计见 spec 与 公开 API 契约。