Repository navigation
Issue #54: 重複full-hanchan executionをtest-onlyで削減する - #55
Merged
Merged
Conversation
test_driver_delivery.BackwardCompatibilityTest / test_round_completionの setUpClass / test_driver.DriverResumeAndEndToEndTestで独立に実行していた full-hanchanを、既存の共有可能なfixture境界とdeterministic terminal position(West 4, dealer NORTH)へ置き換え、6本のfull-hanchan executionを 2本(round_completionの共有1半荘 + driverのgenuine multi-round E2E owner 1半荘)へ削減する。production codeの変更はなし。 - test_driver_delivery: on_delivery省略/explicit None/callbackの3経路を full-hanchan 2本から短いterminal-round run 3本の比較へ置き換え - test_round_completion: RoundCompletionProjectionTestとMatchCompletion ProjectionTestが独立に実行していた_play_deterministic_hanchan()を、 functools.cacheでラップしたmodule-local helperが返す単一のimmutable CompletedMatchで共有する(mutableなMatchStateは共有しない) - test_driver: genuine multi-round E2E ownerをsetUpClassに1本残し、 resume-from-active-round semanticsはterminal positionからの短い AWAITING_ROUND run / start_round()後resumeの比較で独立に確認する test_round_evidence_completion.DriverDeliveryTestのfull-hanchan exactly-once ownerは今回変更していない。
lisbun
marked this pull request as ready for review
August 29, 2026 13:41
lisbun
commented
Aug 29, 2026
lisbun
left a comment
Owner
Author
There was a problem hiding this comment.
Semantic review
Blocking findings: none.
Issue #54 のscope / acceptance criteria と3ファイルのdiffを照合しました。
test_driver_delivery: omittedon_delivery/ explicitNone/ callback の3 pathを同じterminal fixtureで比較しており、backward-compatibility contractを維持しつつfull-hanchan重複を除去できています。progress / ordering / failure semanticsは同moduleのfocused testsが引き続き所有しています。test_round_completion: cache対象はimmutableCompletedMatchのみで、mutableMatchStateを共有していません。既存projection assertionsも維持されています。test_driver: genuine multi-round E2Eを1本残し、resume-from-active-round equivalenceは同一seed / 同一terminal positionのAWAITING_ROUND vs ROUND_IN_PROGRESSで独立に維持されています。test_round_evidence_completionのfull-hanchan exactly-once / order / timing ownerは未変更です。- production code変更なし、test count 1449も不変です。
CI run #77も確認しました。CPython 3.14.7、ruff format/check pass、full suite 1449 tests / 84.886s / OK。直接のruntime evidenceもIssueの狙いと一致しています。
実測では immediate baseline 149.784s → 84.886s(-64.898s、約43.3%)。hosted runner varianceはあるため絶対値だけをKPIにはしませんが、full-hanchan execution shapeが6→2へ構造的に減っていることと、旧35.435sのtest_on_delivery_none_matches_pre_existing_behaviorがtop 30から消えたことが強い根拠です。
結論: merge可能です。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Profilingで確認された重複full-hanchan executionを、coverageを維持したままtest-onlyで削減する(Closes #54)。production codeの変更なし。
実装前レビュー(#54のコメント)の具体案をそのまま採用した。
1.
tests/test_driver_delivery.pyBackwardCompatibilityTest.test_on_delivery_none_matches_pre_existing_behaviorが実行していた2回のfull hanchanを、既存_match_at_position()を使ったdeterministic terminal position(West 4, dealer NORTH)からの短い実行へ置き換えた。on_delivery引数省略on_delivery=Noneon_delivery=recorded.extendの3 pathについて、completed resultとmatch historyが一致することを確認し、callback pathでは
recordedが空でないことも維持している。2.
tests/test_round_completion.pyRoundCompletionProjectionTest.setUpClassとMatchCompletionProjectionTest.setUpClassが独立に実行していた同じ_play_deterministic_hanchan()を、functools.cacheでラップしたmodule-local helper_deterministic_completed_match()が返す単一のimmutableCompletedMatchで共有した。mutableなMatchStateは共有していない(CompletedMatchは@dataclass(frozen=True)で、historyもtuple[CompletedRound, ...])。既存のprojection assertions自体は変更していない。3.
tests/test_driver.pyDriverResumeAndEndToEndTest.setUpClassの最初のfull hanchan(from_awaiting_round/first_result)は、genuine multi-round E2E ownerとしてそのまま残した。2本目のfull hanchan(start_round()後からの実行)は削除し、test_same_seed_selectors_and_resume_point_produce_same_result側でdeterministic terminal position(West 4, dealer NORTH)から、start_round()後からresumeの2つの短い経路を作り、completed result equalityとhistory equalityを確認する形にした。test-only helper
_match_at_position()を追加し、RoundPosition/Windをimportした。明示的に変更しないもの
test_round_evidence_completion.DriverDeliveryTest.test_a_full_hanchan_delivers_each_completed_round_exactly_onceは今回変更していない。round-evidence deliveryのexactly once / order / timing / multi-round integrationの明示的なfull-hanchan ownerとして維持する。Execution shape
4 duplicate full-hanchan executionsを削減した。wall-clockの固定閾値はacceptance criteriaにしていない(runner varianceのため)。
Preserved contract owners
run_hanchan()completion:test_driver.DriverResumeAndEndToEndTest.test_completes_a_deterministic_multi_round_hanchan(setUpClassのfull hanchanをそのまま使用)test_driver.DriverResumeAndEndToEndTest.test_same_seed_selectors_and_resume_point_produce_same_result(terminal positionからの短い比較へ変更、contractは維持)on_delivery=Nonebackward compatibility:test_driver_delivery.BackwardCompatibilityTest.test_on_delivery_none_matches_pre_existing_behavior(terminal positionからの短い比較へ変更、contractは維持)RoundCompletionFact/MatchCompletionFactprojection from a real completed match/history:test_round_completion.RoundCompletionProjectionTest/MatchCompletionProjectionTest(共有fixtureへ変更、assertion自体は無変更)test_round_evidence_completion.DriverDeliveryTest.test_a_full_hanchan_delivers_each_completed_round_exactly_once(無変更)Verification
ローカル環境にPython 3.14が無く(
pyproject.tomlはrequires-python = ">=3.14,<3.15"で、production codeがPEP 758のunparenthesized except構文とPEP 649のdeferred annotation評価に依存しているため、Python 3.11–3.13ではimportできない)、focused testの実行自体はローカルで完了できなかった。代わりに次を実施した。py_compile)ruff format --check ./ruff check .(全体、pass)CompletedMatch/CompletedRoundが@dataclass(frozen=True)でtuple historyを持つことをsource側で確認、run_hanchanのon_delivery省略時デフォルトがNoneであることをsource側で確認、既存の_match_at_position()/terminal position patternが同modules内の既存testで確立済みであることを確認)GitHub Actions full suite(
python -m unittest discover -s tests -v --durations 30、実際のPython 3.14.7環境)で実測した。このPRのCIは green(1449 tests, OK)。Before(現在のmain,
16b5949, run 76の実測値)test_driver_delivery.BackwardCompatibilityTest.test_on_delivery_none_matches_pre_existing_behaviortest_round_evidence_completion.DriverDeliveryTest.test_a_full_hanchan_delivers_each_completed_round_exactly_oncetest_round_evidence_completion.DriverDeliveryTest.test_the_same_seed_and_selectors_yield_the_same_delivered_valuestest_round_evidence_completion.BackwardCompatibilityTest.test_the_new_callback_changes_no_existing_observable_behaviortest_round_evidence_completion.BackwardCompatibilityTest.test_without_any_callback_the_result_is_unchangedtest_round_evidence_completion.DriverDeliveryTest.test_viewer_order_is_deterministic_for_every_deliverysetUpClassの隠れたcost(--durationsには現れない、#54本文の実測より):test_driver.DriverResumeAndEndToEndTest.setUpClass~36.9s(2 full hanchan)test_round_completion.MatchCompletionProjectionTest.setUpClass~18.35stest_round_completion.RoundCompletionProjectionTest.setUpClass~18.28s(2クラス合計 ~36.6s、独立な2 full hanchan)After(このPR,
757f68c, run 77の実測値)test_round_evidence_completion.DriverDeliveryTest.test_a_full_hanchan_delivers_each_completed_round_exactly_once(無変更、明示的owner)test_driver.DriverResumeAndEndToEndTest.test_same_seed_selectors_and_resume_point_produce_same_result(新規に可視化。旧2本目full hanchanのsetUpClass隠れcostが、terminal positionからの2つの短いrunとして--durationsに直接現れる形へ変わった)test_round_evidence_completion系(無変更)test_round_evidence_completion.DriverDeliveryTest.test_viewer_order_is_deterministic_for_every_delivery(無変更)test_on_delivery_none_matches_pre_existing_behaviorは上位30件から完全に消えた(旧35.435s → 0.122s未満)setUpClassの残存cost:test_driver.DriverResumeAndEndToEndTest.setUpClass: ~36.9s のまま残存(genuine multi-round E2E ownerとして意図的に維持)test_round_completion: 2クラスで1回のfull hanchan(~18.3s相当)を共有するため、独立2回実行分の隠れcostのうち約半分を除去self-reviewでblockingな問題は見つからなかったため、Ready for reviewへ進める。mergeはユーザーの明示的な承認を待つ。