Skip to content

test: cover parsing edges, split fakes, and trim params wrappers#477

Merged
liujuanjuan1984 merged 2 commits intomainfrom
issue-437-439-evaluation
May 6, 2026
Merged

test: cover parsing edges, split fakes, and trim params wrappers#477
liujuanjuan1984 merged 2 commits intomainfrom
issue-437-439-evaluation

Conversation

@liujuanjuan1984
Copy link
Copy Markdown
Collaborator

@liujuanjuan1984 liujuanjuan1984 commented May 6, 2026

概要

  • src/opencode_a2a/parsing.py 新增直接边界测试,覆盖 int/string/bool/timestamp 解析行为
  • 扩充 CLI 与 client error mapping 测试,覆盖 run_call()、配置错误格式化,以及更多 A2A / HTTP / JSON-RPC / agent-card 错误分支
  • 拆分 DummySessionQueryOpencodeUpstreamClient 的宽接口 fake,按 session query、workspace control、interrupt 能力拆到独立测试支持模块,并迁移相关测试引用
  • 修正 AgentCardResolutionError(status_code=...) 走错错误映射路径的问题
  • 补充一次高确信死代码/薄壳清理,内联 jsonrpc params 中无额外语义的私有转发 helper,并移除冗余分支

关联 Issue

验证

  • bash ./scripts/doctor.sh

@liujuanjuan1984
Copy link
Copy Markdown
Collaborator Author

独立审查结果:当前未发现阻塞性问题,本 PR 的实现方向与 #437#439 目标一致。

代码变动审查:

  • #437 方面,parsing.py 已补上直接边界测试,CLI 与 client error mapping 的遗漏分支也已补齐;同时把 AgentCardResolutionError(status_code=...) 的映射修正为 agent-card HTTP 路径,和测试目标一致,没有引入额外复杂度。
  • #439 方面,拆分测试 fake 采用了“按能力拆模块、保留 composite 行为”的方式,只调整测试支持层与导入入口,没有把重构扩散到生产代码,属于比较稳健的收口。
  • 目前没有看到明显的需求偏差、实现冗余或回归风险;残余风险主要是后续若继续扩展测试 fake,仍需要保持新模块边界,不要再回堆到 helpers.py

PR 标题与描述审查:

  • 标题 test: cover parsing edges and split test upstream fakes 与本次唯一 commit 和实际改动范围一致,符合英文 commit message 风格。
  • 描述已更新为中文,且已覆盖核心代码变动、验证方式与 issue 关联,表述准确。

Issue 关系审查:

  • Closes #437Closes #439 是准确的。
  • 当前没有发现必须额外补充的 related / part of issue 关系。

@liujuanjuan1984 liujuanjuan1984 changed the title test: cover parsing edges and split test upstream fakes test: cover parsing edges, split fakes, and trim params wrappers May 6, 2026
@liujuanjuan1984
Copy link
Copy Markdown
Collaborator Author

补充一次独立审查结论,聚焦本次后续提交 bdcfd5c 引入的死代码/薄壳清理:

  1. 审查范围
  • 全仓做了一轮死代码与薄壳筛查,重点复核了 public facade、动态协议适配、task store decorator、测试 fake mixin 等容易被静态扫描误报的区域。
  • 结论是:当前仓库完成度较高,可直接删除的生产级 public API / 兼容层并不多;多数一层转发仍承担协议命名、fake 接口形状或动态分发职责,不适合机械清理。
  1. 本次实际清理是否合理
  • 本次仅保留一处高确信清理:移除 src/opencode_a2a/jsonrpc/params.py 中私有 helper _normalize_alias_field(),并将其单层转发直接内联到 parse_list_sessions_params() / parse_get_session_messages_params()
  • 同时删除了这些分支里对新建 dict 执行的冗余 pop(..., None);这些 key 在未赋值前本就不存在,保留 pop 只会增加阅读噪音。
  • 这属于纯结构性收敛,不改变 JSON-RPC params 校验、默认值、错误格式或返回形状。
  1. 风险评估
  • 未发现行为偏差风险;bash ./scripts/doctor.sh 已通过,包含全量测试、覆盖率门槛、构建与 smoke test。
  • ruff 自动顺手清掉了 tests/support/session_query_client.py 的一处空行,这只是格式化,无语义影响。
  1. 额外说明
  • 这轮审查里,像 TaskStoreDecorator.__getattr__、interrupt/workspace fake 上的命名方法、upstream facade methods 等候选都没有纳入清理,因为它们要么承接动态访问,要么承接显式协议名,删除收益小、误伤风险高。
  • 目前这版清理范围是克制且合理的,没有继续复杂化 PR。

@liujuanjuan1984 liujuanjuan1984 marked this pull request as ready for review May 6, 2026 12:43
@liujuanjuan1984 liujuanjuan1984 merged commit 09c4e3f into main May 6, 2026
3 checks passed
@liujuanjuan1984 liujuanjuan1984 deleted the issue-437-439-evaluation branch May 6, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant