Skip to content

Fix: cross-review fix結果 resolved_threads が int だと merge-fix が TypeError で落ちる問題の堅牢化 (#25) - #26

Merged
takemi-ohama merged 5 commits into
mainfrom
fix/PLAN25-merge-fix-count-normalize
Jun 9, 2026
Merged

Fix: cross-review fix結果 resolved_threads が int だと merge-fix が TypeError で落ちる問題の堅牢化 (#25)#26
takemi-ohama merged 5 commits into
mainfrom
fix/PLAN25-merge-fix-count-normalize

Conversation

@takemi-ohama

Copy link
Copy Markdown
Contributor

Summary

変更内容

1. state.py(後方互換で受理を寛容化)

  • _count() 正規化ヘルパを追加(int / list / None いずれも件数 int に正規化、bool は除外)
  • cmd_merge_fixdeferred / rejected / resolved_threads_count() 経由に変更
  • deferred ループに isinstance(list) ガードを追加(int 混入時の 'int' object is not iterable を防止)

2. ドキュメント整合(そもそも int を書きにくくする)

  • docs/02-fix-and-rotation.md: 戻り値スキーマに「resolved_threads/deferred/rejected
    必ず list、件数(int) を書かない」注意書きを追加
  • docs/01-state-and-review.md L75: fix結果側は list・state.json 側は len()(int) と区別して記述

Test plan

  • _count() を int / list / tuple / None / bool / 空list で正規化検証(全て期待値一致)
  • python3 -c ast.parse 構文チェック / claude plugin validate 通過(警告は既存・無関係)
  • (レビュー観点) int を書いた fix-pr<PR>-result.jsonmerge-fix がクラッシュしないこと
  • (レビュー観点) list の場合に従来どおり件数が state.json に保存されること(回帰なし)

issue #25 対応。
- state.py: _count() 正規化ヘルパを追加し cmd_merge_fix の
deferred/rejected/resolved_threads を int/list/None いずれも受理に変更
- state.py: deferred ループに isinstance(list) ガードを追加(int 混入時の
'int' object is not iterable を防止)
- docs/01・docs/02: fix結果側は list・state.json側は len()のint であることを
矛盾なく明記し「件数(int)を書かない」注意書きを追加
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@takemi-ohamatakemi-ohama left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

🤖 cross-review | round 1 | gemini | APPROVE

PLAN25 の仕様に沿って、intlist の混在に対する堅牢化とドキュメントの明確化が適切に実装されていることを確認しました。

@takemi-ohamatakemi-ohama left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

🤖 cross-review | round 1 | codex | REQUEST_CHANGES

バグ修正対象の int 入力を固定する回帰テストを追加してください。

Comment threadplugins/ndf/skills/cross-review/scripts/state.py
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@takemi-ohama

Copy link
Copy Markdown
ContributorAuthor

fix round 1/8 対応サマリ

codex review (REQUEST_CHANGES) の指摘 1 件に対応しました。

重要度件数
critical0
major0
minor1
nit0
  • 対応: 1 件 / deferred: 0 件 / rejected: 0 件
  • 対応内容: _count() の int/list 正規化に対する回帰テストを tests/test_state_merge_fix.py に追加。_count() 単体テスト (int/list/tuple/None/空list/bool=False/想定外型) + cmd_merge_fix 結合テスト (resolved_threads/deferred/rejected が int でも TypeError を出さず件数保存・deferred ループ非クラッシュ・list 時の deferred_nits 展開) を検証。
  • テスト結果: pytest 32 passed
  • commit: 1322177

resolve 済み thread: PRRT_kwDOSII3uc6IL6Pt

@takemi-ohamatakemi-ohama left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

🤖 cross-review | round 2 | gemini | REQUEST_CHANGES

PLAN25 の目的である TypeError: object of type 'int' has no len() クラッシュの修正として、正規化ヘルパー _count の導入と型ガードは非常に適切です。
一方で、LLM の出力揺らぎ(スキーマ違反)に対する堅牢性をさらに高めるため、以下のエッジケースへの対応を追加することを提案します。

  • deferred の要素が辞書でない(文字列など)場合の展開時 TypeError の回避
  • 数値が文字列("3")として出力された場合の考慮

Comment threadplugins/ndf/skills/cross-review/scripts/state.py
Comment threadplugins/ndf/skills/cross-review/scripts/state.py Outdated

@takemi-ohamatakemi-ohama left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

🤖 cross-review | round 2 | codex | APPROVE

修正必須の指摘はありません。

gemini round2 指摘対応:
- [major] cmd_merge_fix の deferred 展開ループに isinstance(d, dict) ガードを
追加し、文字列リスト等が混入しても TypeError を出さずスキップする
- [minor] _count() で数値文字列 ("3" 等) を int に正規化 (isdigit で非負整数のみ)
- 上記2件の回帰テストを test_state_merge_fix.py に追加
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@takemi-ohama

Copy link
Copy Markdown
ContributorAuthor

fix round2 対応サマリ

gemini round2 の指摘2件に対応しました (commit cd95be0)。

重要度内容対応
major / 堅牢性cmd_merge_fix の deferred 展開ループに dict ガード追加 (文字列リスト等で TypeError: 'str' object is not a mapping を防止)修正 + 回帰テスト追加
minor / 堅牢性_count() で数値文字列 ("3" 等) を許容 (isdigit() で非負整数のみ)修正 + 回帰テスト追加
  • 対応件数: major=1 / minor=1 (deferred=0, rejected=0)
  • 追加テスト: test_merge_fix_deferred_non_dict_elements_are_skipped_count parametrize に数値文字列ケース追加
  • pytest: tests/test_state_merge_fix.py 41 passed / cross-review 全体 93 passed
  • 対応した2 thread は Resolve 済み

@Reviewer 再レビューをお願いします。

@takemi-ohamatakemi-ohama left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

🤖 cross-review | round 3 | gemini | APPROVE

差分を確認しました。修正すべき点はありません。

@takemi-ohamatakemi-ohama left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

🤖 cross-review | round 3 | codex | REQUEST_CHANGES

deferred の不正要素をスキップする場合、state に保存する件数も実際に保持した deferred nit と一致させてください。

Comment threadplugins/ndf/skills/cross-review/scripts/state.py Outdated
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@takemi-ohama

Copy link
Copy Markdown
ContributorAuthor

fix round3 対応サマリ

codex round3 (REQUEST_CHANGES) の指摘 1 件に対応しました (commit 04c9d58)。

重要度件数
critical0
major1
minor0
nit0
  • 対応: 1 件 / deferred: 0 件 / rejected: 0 件
  • 対応内容 (major / 正確性): cmd_merge_fixdeferred を dict 要素のみへ正規化 (_deferred_nits) してから fix dict を組み立て、rounds[].fix["deferred"] に正規化後件数 (len(_deferred_nits)) を保存。後段の deferred_nits 展開ループも同じ _deferred_nits を走査するため、保存件数と実展開件数が一致するようになりました。resolved_threads / rejected は後段ループが無いため _count() を維持。
  • テスト: 回帰テスト test_merge_fix_deferred_count_matches_expanded_nits 追加 + 既存テストの期待値を整合 (保存件数=dict件数) に更新。pytest tests/test_state_merge_fix.py 42 passed / cross-review 全体 94 passed。
  • 対応 thread (PRRT_kwDOSII3uc6IMLGS) は Resolve 済み。

@Reviewer 再レビューをお願いします。

@takemi-ohamatakemi-ohama left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

🤖 cross-review | round 4 | codex | REQUEST_CHANGES

deferred の int 後方互換が state の保存件数で失われているため、ラウンドサマリと fix 結果の整合を保つ修正が必要です。

Comment threadplugins/ndf/skills/cross-review/scripts/state.py Outdated

@takemi-ohamatakemi-ohama left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

🤖 cross-review | round 4 | gemini | APPROVE

LLM出力の揺らぎ(空白の混入やリストの欠落)に対するいくつかのエッジケースのカバーをインラインで提案します。

Comment threadplugins/ndf/skills/cross-review/scripts/state.py
Comment threadplugins/ndf/skills/cross-review/scripts/state.py Outdated
Comment threadplugins/ndf/skills/cross-review/scripts/state.py Outdated
@takemi-ohama

Copy link
Copy Markdown
ContributorAuthor

/ndf:fix round 4/8 対応サマリ

commit: e35b9d4be65933fe3ccc4696470672c78e439912

対応件数: 4 件 (major=1 / minor=3 / critical=0 / nit=0)

統一設計 (round3/round4 の対立を両立)

rounds[].fix["deferred"] の保存件数を単一整合ルールに統一しました:

  • deferredlist / dict (構造化データ) → deferred_nits へ展開する dict 要素の件数 (len(_deferred_nits))
  • deferredint / 数値文字列 (per-item を失った劣化表現) → _count() の値 (件数を失わない / 展開不能なので nits は空)
  • それ以外 → 0

→ mixed list は dict 件数 (round3 懸念解消)、int は件数保持 (round4 懸念解消) を両立。

変更内容

_count() 判定順序: bool→0 / int→そのまま / dict→1 / list,tuple→len / str(strip後isdigit)→int / その他→0

テスト

tests/test_state_merge_fix.py 更新 — pytest 48 passed (cross-review 全体 100 passed)。

@takemi-ohamatakemi-ohama left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

🤖 cross-review | round 5 | gemini | APPROVE

_count() の単一 dict フォールバックや前後空白の strip 処理、および deferred の件数保存・展開の統一ルールが正しく実装されており、網羅的なテストも追加されていることを確認しました。エッジケースへの対応として十分に堅牢です。

@takemi-ohamatakemi-ohama left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

🤖 cross-review | round 5 | codex | APPROVE

修正必須の重複しない指摘はありません。

@takemi-ohama
takemi-ohama merged commit 6c47515 into mainJun 9, 2026
@takemi-ohama
takemi-ohama deleted the fix/PLAN25-merge-fix-count-normalize branch August 14, 2026 04:00
Sign up for freeto 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

@takemi-ohama