Skip to content

feat(todos): per-todo validation timeout overrides the 20s default - #3210

Merged
huangruiteng merged 1 commit into
huangruiteng:mainfrom
NIU-123370:feat/validation-timeout-per-todo
Aug 15, 2026
Merged

feat(todos): per-todo validation timeout overrides the 20s default#3210
huangruiteng merged 1 commit into
huangruiteng:mainfrom
NIU-123370:feat/validation-timeout-per-todo

Conversation

@NIU-123370

Copy link
Copy Markdown
Contributor

Summary

Lands the second P2 flagged in the #3142 review: the completion-validation gate ran every declared validation_command with a fixed 20s module constant, so tests could only exercise the timeout path by monkeypatching the constant.

  • todo add accepts an optional --validation-timeout-seconds alongside --validation-command. Range-checked to 1–29 at the writer side: a timed-out validation must still produce a typed receipt before the outer CLI/MCP subprocess budget (30s) kills the call. Declaring a timeout without a command is rejected.
  • The value persists in the todo metadata block and flows through _read_declared_validation into run_completion_validation_gate, replacing the constant in both the runner call and the timeout receipt summary ("timed out after Ns" now reports the declared value).
  • Unchanged elsewhere: todos without the field keep the 20s default, the no-command fast path is untouched, and the receipt still captures no stdout/stderr/local paths.

Verification

  • pytest tests/control_plane/test_todo_completion_validation.py — 10 passed (3 new: declared 1s timeout cuts off a sleeping command and reports after 1s; out-of-range 30 rejected; timeout-without-command rejected). The override test needs no monkeypatch — the declared value itself drives the timeout.
  • all todo-related suites (14 files) — 152 passed
  • pytest tests/canary/ (incl. maintainability ratchet) — 20 passed; loopx/todos.py baseline bumped 2165 → 2190 (honest bump for the new flag plumbing)
  • mypy — the 4 pre-existing loopx/todos.py errors are identical to main; the new plumbing adds none

Refs #3142 (second P2 follow-up; the first, the module extraction, landed in #3209).

The completion-validation gate ran every declared validation_command with a
fixed 20s module constant. Add an optional per-todo --validation-timeout-seconds
(set on todo add next to --validation-command, 1-29 so a timed-out validation
still produces a typed receipt inside the 30s outer subprocess budget; the
writer side rejects out-of-range values and timeouts declared without a
command). The declared value flows through the todo metadata block into
run_completion_validation_gate and replaces the constant in both the runner
call and the timeout receipt summary. Todos without the field keep the 20s
default and the no-command fast path unchanged.

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论:通过(Approve)

实现干净、边界合理:#3142 review 标记的第二个 P2 完成——todo add 新增 --validation-timeout-seconds(1–29,writer 侧强校验,声明 timeout 必须同时声明 validation_command),值持久化到 todo metadata 并流经 run_completion_validation_gate,替换 20s 模块常量;超时 receipt 的 summary 现在报告实际使用的声明值。无字段时保持 20s 默认,fast path 与隐私边界不变。

验证(exact head 3a0d1a870,独立 worktree,PR 实际 diff 7 文件 +130/−22):

  • pytest tests/control_plane/test_todo_completion_validation.py tests/canary/:30 passed(含 3 个新用例:1s 超时覆盖、30 越界拒绝、无 command 拒绝)
  • git diff --check:无输出
  • 新参数导入与上限常量验证正常
  • GitHub Actions:build / dependency-review 通过;pytest 正在运行(评审时 pending)

无阻塞问题。CI pytest 转绿后即可合并。

@huangruiteng
huangruiteng merged commit 58f545a into huangruiteng:main Aug 15, 2026
5 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