Skip to content

#647 [test] GUI の残り 14 関数を状態待機 helper に統一する - #652

Merged
Kewton merged 1 commit into
developfrom
feature/issue-647-test-gui-14-helper
Oct 10, 2026
Merged

Kewton merged 1 commit into
developfrom
feature/issue-647-test-gui-14-helper

Conversation

@Kewton

@Kewton Kewton commented Oct 10, 2026

Copy link
Copy Markdown
Owner

概要

tests/gui_server.rs に残っていた、状態を待つ独自のループを、#621 の状態待機 helper(tests/support/gui_wait.rs)に統一します。対象は 14 関数・23 箇所です。

変更

  • tests/gui_server.rs(+230 −166)だけを変えました。製品コードと gui_wait.rs は変えていません。
  • 元の 17 関数・30 箇所について、J と K の対応表を commit message とファイル冒頭のコメントに書きました。漏れはありません。
  • 同時実行で見つかった競合を直すため、3 箇所に待ちを足しました:recovery_auto_run、failure_explanation.projection_status、gate。
    • 3 箇所とも、待った後に 1 回だけサーバーの状態を読んでいました。これを、後の assertion と同じ値になるまで gui_wait::wait_for で待つ形にしました(上限は SESSION_STATE_TIMEOUT)。
    • 待った後の assertion はそのままです。成功するまでの再実行、上限の延長、固定の sleep は足していません。
  • 既存の内容の assertion(auth・event bytes・hash・generation・recovery rejection)は 1 つも消していません。
    • 消えたのは待ちのループの中の判定だけです。これらは helper の有限の上限と、Failed の扱いに置き換わりました。

検証

  • commandmate verify の 15 ゲート(fmt・clippy -D warnings・cargo test の全体を含む)は、develop c98bdc7c の上の HEAD 26d9bf56 で 15/15 pass でした。
  • cargo test --features gui --test gui_server:87 passed でした。
  • 同時実行:受け入れ条件の「2 checkout で同時に 3 回」の代わりに、同じビルドのテストバイナリ(87 本の全体)を 2 プロセス同時に起動することを 5 回くり返しました。ビルドは 1 本ずつという運用のためです。
    • SIGINT と SIGQUIT は既定に戻して起動しました。
    • 結果は 10/10 pass で、プロセスは残っていません。
    • 同じ条件で develop c98bdc7c を対照として回すと、10 本中 9 本が FAIL しました(主に unclassified_nextjs_create_is_unmeasured_confirmed_and_delegated)。
  • 二点測定は対象外です(待ちの統一のため)。worker は、待ちの条件を届かない値に変えると、helper の「timed out … last state」で FAIL することを確かめています。
  • 成長上限の対象(runner.rs・loop_run.rs・baseline)は変えていません。

確かめてほしい点

  • 純増は +64 行で、Issue の目安(純増 0 以下)を超えています。大半(+62)は、同時実行の競合を直すために足した 3 箇所の待ちです。
  • J の範囲(gui_stop_*・server_ready_wait_*)は、修正の前の同時実行でまれに落ちました。修正後の 10 本では起きていませんが、この PR では直していません。

レビュー

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

Refs #647

🤖 Generated with Claude Code

判断: 14 関数・23 箇所の生の `Instant::now() + Duration` ループを J (#621) の
  gui_wait helper (`wait_for` / `wait_for_file_content` /
  `wait_for_stop_evidence` / `wait_for_idle_lease`) に置き換え、上限は
  名前つきテスト用定数 DELEGATED_ARTIFACT_TIMEOUT (5s) /
  DRAFT_DELEGATION_TIMEOUT (3s) / SESSION_STATE_TIMEOUT (5s) と gui_wait の
  既存定数 (IDLE_LEASE_TIMEOUT / DESCENDANT_READY_TIMEOUT /
  STOP_EVIDENCE_TIMEOUT) にした。製品 timeout は変えていない
判断: 待機完了条件は元の assertion と一致させ、events は event 名だけでなく
  内容一致・バイト一致で待ち、args/env は期待内容が揃うまで ready としない。
  部分書込みを ready と認めない
判断: 待った直後に読むサーバーの状態自体も待機の完了条件に入れた。
  `GET /api/sessions/{id}` の gate / recovery_auto_run / failure_explanation は
  サーバーが委譲プロセスの終了を観測して初めて確定するため、events や args を
  待っただけでは 1 回読みで gate_2 / current 0 / projection null を掴みうる。
  後の assertion と同じ値を gui_wait::wait_for で待ってから read し、
  既存 assertion はそのまま残した
判断: gui_server.rs 冒頭に 17 関数の J/K 対応表をコメントで置き、下の
  30 箇所の表と突き合わせて漏れが無いことを示した

元の 17 関数・30 箇所の対応表(元の行 = 調査基準 f8ce541、J は merge 済み):

J (#621) - 3 関数 / 7 箇所
  gui_stop_is_generation_bound_idempotent_and_records_cli_interruption
    1863 wait_for_descendant_pid / 1938 wait_for_idle_lease
  gui_stop_force_kills_the_exact_process_group_without_false_success
    1979 wait_for_descendant_pid / 2009 wait_for_idle_lease
  gui_stop_targets_the_confirmed_directive_process_generation
    2050 wait_for_idle_lease / 2074 wait_for_descendant_pid / 2099 wait_for_idle_lease
K (#647) - 14 関数 / 23 箇所
  gui_lists_and_proposes_an_external_draft_profile_with_a_local_pack
    917 wait_for_event(DRAFT_DELEGATION_TIMEOUT)
  extension_supply_api_enforces_auth_origin_and_the_full_pack_lifecycle
    1226 gui_wait::wait_for(content predicate)
  later_gate_one_ignores_products_from_an_isolated_session_workspace
    2187 wait_for_idle_lease
  malformed_session_events_return_a_dedicated_error_code
    2363 wait_for_idle_lease
  failed_session_projects_exact_interval_and_reads_only_current_recovery_documents
    2523 gui_wait::wait_for_file_content(exact)
  recovery_documents_are_readable_when_trial_token_auth_is_off
    2675 gui_wait::wait_for_file_content(exact)
  confirmed_session_delegates_with_cli_event_bytes_unchanged
    2963 gui_wait::wait_for(byte equality) / 3242 gui_wait::wait_for(gate_3) / 3269 wait_for_idle_lease
  selected_working_directory_is_hash_bound_persisted_and_reused_after_restart
    3413 wait_for_idle_lease / 3474 wait_for_idle_lease
  typed_trial_intents_are_validated_frozen_and_delegated
    3613 wait_for_idle_lease
  unclassified_nextjs_create_is_unmeasured_confirmed_and_delegated
    3772 gui_wait::wait_for_file_content(args pairs) / 3798 wait_for_idle_lease
  selected_think_is_confirmed_and_delegated_only_for_an_ollama_role
    3887 wait_for_idle_lease
  recovery_auto_run_limit_is_hash_bound_validated_and_delegated
    3999 gui_wait::wait_for_file_content(args pair)
  gate_four_recovery_run_requires_confirmation_and_executes_exact_frozen_identity
    4048 wait_for_idle_lease / 4051 wait_for_idle_lease /
    4116 wait_for_path(DESCENDANT_READY_TIMEOUT) / 4184 wait_for_idle_lease
  recovery_run_rejects_stale_drift_pending_directive_and_treatment_rejection
    4200 wait_for_idle_lease / 4229 wait_for_idle_lease / 4272 wait_for_idle_lease
合計: J 7 + K 23 = 30 箇所、3 + 14 = 17 関数で漏れなし。

表の外(上の 30 箇所以外に統一・追加した待ち):
  Gate 4 の 8 秒 stop evidence (元 4182) -> wait_for_stop_evidence
    (session_id と process_generation に拘束)
  confirmed_session_delegates_with_cli_event_bytes_unchanged
    元 3141 の GET の前に gate_3 を待つ (ローカル helper wait_for_session_gate)。
    同じ test の directive continuation (元 3242) の gate_3 待ちも同 helper に統一
  failed_session_projects_exact_interval_and_reads_only_current_recovery_documents
    元 2588 の GET の前に failure_explanation.projection_status == "supported" を待つ
  recovery_auto_run_limit_is_hash_bound_validated_and_delegated
    元 4053 の GET の前に recovery_auto_run ==
    {current:1,used:1,limit:1,stop_reason:recovery_succeeded} を待つ
  いずれも上限は既存の名前つき定数 (SESSION_STATE_TIMEOUT / STOP_EVIDENCE_TIMEOUT)、
  後の assertion と同値を完了条件にし、既存 assertion は全て残置

テスト: 変換対象 14 test と、今回待ちを足した 3 test
  (`cargo test --features gui --test gui_server` の名前指定) が緑。3 test は
  連続 4 回実測していずれも緑
二点測定: auto-run の待機 predicate を到達不能な値に変異させ、
  gui_wait.rs の「timed out after 5s ...; last state: ...」で赤を実測し、
  復元して緑に戻した
本文に無い指摘: この worktree には gui/out が無いため、gui feature の静的配信系
  test は base でも赤になる。変換対象は gui/out に依存しないため名前指定で緑を実測
証跡: 契約の gate を実行し以下を実測 — cargo fmt --all -- --check /
  RUSTFLAGS='-D warnings' cargo clippy --all-targets -- -D warnings (gui feature も別途) /
  RUSTFLAGS='-D warnings' cargo test --all-targets /
  validate_codex_skills / ruff (両方) / shellcheck / pytest codex_orchestrate /
  unittest management scripts / eval 3 本 / npm ci + nextjs oracle
制約: 変更は tests/gui_server.rs のみ。tests/support/gui_wait.rs と製品コードは
  未変更。CARGO_TARGET_DIR / CARGO_BUILD_JOBS は上書きせず cargo mutants は未実行

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
@Kewton
Kewton merged commit 0549f75 into develop Oct 10, 2026
5 checks passed
@Kewton
Kewton deleted the feature/issue-647-test-gui-14-helper 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