Skip to content

#648 [test] headless SIGINT を実要求開始の合図後に送る - #653

Merged
Kewton merged 1 commit into
developfrom
feature/issue-648-test-headless-sigint
Oct 10, 2026
Merged

Kewton merged 1 commit into
developfrom
feature/issue-648-test-headless-sigint

Conversation

@Kewton

@Kewton Kewton commented Oct 10, 2026

Copy link
Copy Markdown
Owner

概要

headless の SIGINT のテストで、SIGINT を送る時機を、実際の provider の要求が始まった合図の後にします。これまでは、証跡のファイルと 100 ms の sleep で時機を推し量っていました。

変更

  • tests/headless_summary.rs(+239 −27)だけを変えました。製品コードは変えていません。
  • mock の Ollama endpoint を、保持した listener で動かします。
    • POST /api/chat の要求を最後まで読んだら、channel で親に合図します。
    • 応答は 200 のヘッダだけを返し、本体を開いたままにします。こうして provider の呼び出しを進行中のまま止めておきます。
  • 親は合図を受けてから、実 CLI の子に kill(SIGINT) を送ります。証跡のファイルと 100 ms の sleep はやめました。
  • ready を単調な clock で 15 秒まで待ちます。次の場合は、診断を付けて fail します:
    • 子が早く終わった
    • 要求が最後まで届かない
    • mock の thread が止まった
    • 合図が来ない
  • guard(Drop)が、失敗の経路でも、子の kill と wait、mock の thread の停止と join を行います。
  • exit 130 以降の既存の assertion(最後の stdout 行の schema、interrupted summary、events_path、interruption event)は 1 行も消していません。

検証

  • commandmate verify の 15 ゲート(fmt・clippy -D warnings・cargo test の全体を含む)は、develop c98bdc7c の上の HEAD 8435de32 で 15/15 pass でした。
  • 同時実行:受け入れ条件の「2 checkout で同時に 3 回」の代わりに、同じビルドのテストバイナリを対象のテストに絞って 2 プロセス同時に起動することを 3 回くり返しました。ビルドは 1 本ずつという運用のためです。
    • SIGINT と SIGQUIT は既定に戻して起動しました。
    • 結果は 6/6 pass で、各回の後にプロセスは残っていません。TTY は使っていません。
  • 二点測定は対象外です(テストの時機の修正で、新しいテストを足していないため)。
  • 成長上限の対象(runner.rs・loop_run.rs・baseline)は変えていません。

確かめてほしい点

  • 規模は +239 −27 で、Issue の目安を超えています。大半は、mock の HTTP の読み取り(ヘッダの終わり、Content-Length、timeout の診断)と guard です。
  • 子は provider を呼ぶ前に、自分で signal handler を入れます(src/lib.rs の DirectCommandCompletionGuard::start_inner)。そのため、テストは子の signal の状態を戻していません。親から SIG_IGN を継いだ状態での pass は確かめていません。
  • 要求を言い終えずに閉じた接続が 1 本でも来ると、mock は fail にします。今の --prompt の経路は到達確認をしないので、この形で起きません。

レビュー

テストの変更なので、merge 前レビューは行いません(利用者承認済み)。

Refs #648

🤖 Generated with Claude Code

The headless SIGINT test slept 100ms after the run-evidence file appeared,
which does not prove the SIGINT handler or the provider call had started.
Hold a mock Ollama endpoint, wait for the real POST /api/chat request, keep
that response body open so the call is still in flight, and only then send
the real SIGINT. Bound the ready and exit waits, diagnose an early child
exit and an incomplete HTTP request, and reclaim the child, its pipes, and
the server thread on every failure path.

判断: the mock answers the target chat with 200 headers and then holds the
body open instead of completing it, so the issue's "return the needed
startup response and signal that the target chat started" keeps the provider
call in flight for the real SIGINT.
判断: GET /api/tags is answered defensively for the startup probe; the
--prompt path does not currently probe ollama.
本文に無い指摘: the child handles SIGINT through its own signal_hook
installation (src/lib.rs DirectCommandCompletionGuard::start_inner) before
the provider call, so kill(SIGINT) does not rely on the parent's SIGINT
disposition and an inherited SIG_IGN from a backgrounded harness cannot
suppress it; the test intentionally does not reset the child's signal state.
本文に無い指摘: the acceptance criterion for 2-checkout concurrent runs is a
future verification plan per the issue's 共通制約 and needs leader
coordination; this change was verified with 3 sequential runs plus the full
cargo test suite.

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
@Kewton
Kewton merged commit d708619 into develop Oct 10, 2026
5 checks passed
@Kewton
Kewton deleted the feature/issue-648-test-headless-sigint branch October 10, 2026 16:47
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.

1 participant