Skip to content

test(coverage-registry): freshness テストの予算を実作業量に合わせ 30秒張り付きの偽赤を解消 (#2397) - #2658

Merged
j5ik2o merged 1 commit into
mainfrom
fix-2397-registry-freshness-timeout
Aug 8, 2026
Merged

test(coverage-registry): freshness テストの予算を実作業量に合わせ 30秒張り付きの偽赤を解消 (#2397)#2658
j5ik2o merged 1 commit into
mainfrom
fix-2397-registry-freshness-timeout

Conversation

@j5ik2o

@j5ik2o j5ik2o commented Aug 8, 2026

Copy link
Copy Markdown
Member

症状

tests/unit/gen-coverage-registry.test.ts の freshness テストが、無関係な PR の CI で落ちる

PR 患部 実測時間 制限 余裕
#2618 amadeus-state.ts--user-input trim 30514 ms 30000 ms -514 ms
#2646 amadeus-lib.ts の presence 列挙 30006 ms 30000 ms -6 ms

両方とも再実行でコード変更なしに green。同一 run の兄弟テストも同じ帯にいる:

--check freshness diff > clean temp tree: --check exits 0            [26054 ms]
committed coverage registry is fresh (the live CI ratchet)           [12806 ms]

wall-clock drift レポートも同ファイルを恒常的に large と測っている:

tests/unit/gen-coverage-registry.test.ts: declared=medium measured=large (137.8s)

機序

--check freshness diff の各テストは

  1. 出荷ツリーのサブツリー3本を cpSync で temp へコピー(buildTempTree
  2. その temp ツリーに対してジェネレータを2回 spawn(genInto = ベースライン生成、checkAgainst = 検査)

を行う。これは数十秒かかる実作業で、ハングでも無限ループでもない。CI ランナーはローカルより数倍遅く(本 repo のローカル実測ではファイル全体 34 tests で 18.3 秒、CI では当該2件だけで 26s / 30.5s)、スイート既定の 30 秒はこの作業量に対して余裕がゼロだった。

つまり制限が実作業を下回っていただけで、負荷のわずかな揺れが赤に直結する構造になっていた。

修正

重い3テストに、実作業量に見合う予算を明示的に与える。

const FRESHNESS_DIFF_TIMEOUT_MS = 120_000;

3件それぞれの test(...) 第3引数として渡し、理由(実測値と2件の実害)をコメントに残した。スイート既定(30秒)は他のテストに対して変えていない。

落ちる実証

予算が実際に効いていることを確認するため、FRESHNESS_DIFF_TIMEOUT_MS を一時的に 200 へ絞って実行:

3 fail   ← 当該3テストがタイムアウトで落ちる

復元後: 34 pass / 0 fail。注入 → 赤 → 復元 → 残渣ゼロ(git status --porcelain が対象1ファイルのみ)を1セットで実施。

検証(各コマンド単独実行、exit code を個別に取得)

  • bun test tests/unit/gen-coverage-registry.test.ts --timeout 120000 → 0(34 pass / 0 fail、18.26s)
  • bun run typecheck → 0

この修正が #2397 に対して何を閉じるか

#2397 が追う「coverage job 限定で毎回別のテストが落ちる」回転のうち、本セッションで2回再現した1本を機序特定のうえ塞ぐ。回転の他のメンバー(t224 / t427 / t99)については PR #2593 が fixture コピー経路のリトライ・件数検証・診断を入れており、そちらは別機序。

Refs #2397


Note

Low Risk
Test-only timeout and comment changes; no production or coverage tool behavior changes.

Overview
Stops flakey CI failures on the coverage registry freshness ratchet tests by giving the three heaviest cases an explicit 120s per-test timeout instead of the suite default 30s.

Those tests copy three shipped subtrees into a temp tree and spawn gen-coverage-registry twice each, which routinely runs 26–30+ seconds on CI with no headroom under 30s (e.g. unrelated PRs timing out by a few ms). A comment documents the measured CI times and links #2397. The lighter “missing committed registry” case is unchanged; other tests in the file still use the default timeout.

Reviewed by Cursor Bugbot for commit 69e4338. Configure here.

Summary by CodeRabbit

  • テスト
    • CIで高負荷な鮮度差分テストに120秒のタイムアウトを設定し、タイムアウトによる失敗を防止しました。

Each of these copies three shipped subtrees and spawns the generator
twice, which costs tens of seconds -- 26.1s and 30.5s measured on CI
against the suite's 30s default. A budget with no headroom is a coin
flip, and it came up tails on two unrelated PRs: #2618 at 30514ms and
#2646 at 30006ms, six milliseconds over, both green on rerun with no
code change.

The work is not pathological; the ceiling was set below it. Give the
three heavy tests one sized to what they actually do.

Refs #2397
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

鮮度差分関連の高負荷な --check テストに、共通の120秒タイムアウトを追加しました。

Changes

Coverage registry テスト

Layer / File(s) Summary
共通タイムアウトの適用
tests/unit/gen-coverage-registry.test.ts
FRESHNESS_DIFF_TIMEOUT_MS を120秒で定義し、クリーンな一時ツリー、監査イベント注入、サブコマンド注入の3件のテストに適用しました。

Estimated code review effort: 1 (Trivial) | ~5分

Possibly related PRs

  • amadeus-dlc/amadeus#2165: 同じテストファイルのカバレッジレジストリ検証を変更しています。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed タイトルは、freshness テストのタイムアウト調整による CI の偽失敗解消という主要変更を具体的に示しています。

Comment @coderabbitai help to get the list of available commands.

@j5ik2o
j5ik2o merged commit 633c60f into main Aug 8, 2026
16 checks passed
@j5ik2o
j5ik2o deleted the fix-2397-registry-freshness-timeout branch August 8, 2026 19:25
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