feat(authoring): ADVISORY-D7 extract-method cyclomatic false-FAIL det…#153
Conversation
…ector (D7 closure) dogfooding_findings_tracker D7 (2026-05-28 real-PR pass FINDING-F2) を candidate path (a)+(b) 両方で解決し、D-class を 8/8 全解決にする (ROADMAP v0.1.0 exit criterion 'D 全解決/waive' 充足)。 complexity_delta.cyclomatic は extractor 可視関数の総和 delta で、各関数は base 1 から始まるため、faithful な extract-method refactor は分岐を完全 保存しても総和が必ず +1/関数 微増する。primary_kind=refactor が cyclomatic ≤ 0 を宣言すると、まさに承認したい refactor で構造的に false-FAIL する。cognitive は抽出で下がる側の metric。 - nested_defs.py に count_visible_defs 追加: extract_python_complexity に 委譲して emission 規則との parity drift を構造的に排除 + VisibleDefGrowth - hazards.py detect_d7: refactor kind × cyclomatic 増加禁止 shape (≤0 / <1 / equals ≤0 / within_range [·, ≤0]) × 可視 def 増加で発火。 ≤3 等の許容幅つき lock は対象外 (false-FAIL trap でないため)。 canonical order は D6 の直後 - target-doctor: _DiffContext に visible_def_growth 追加、blob 1 回取得で nested/visible 両カウントを計算 (_def_counts_at)。out-of-scope 側 0 / syntax error skip の D6 契約をそのまま共有 - docs: guide Hazard 5 新設 (refactor パターン別 metric 選択表、D6/D7 は 相補ペア)、cli_usage / json_schema / exit_codes / schema enum に D7 追記、 tracker D7 行を解決 + 8/8 完了宣言 - tests: 可視 def counter 6 件 + detect_d7 9 件 + CLI git 統合 4 件 (extract-method 発火 / cognitive 沈黙 / 抽出なし沈黙 / D6+D7 同時発火)。 全 1810 件 pass / ruff check + format clean https://claude.ai/code/session_01BtUNrsnRygJY52xAy5bFRw
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1854d5da1e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex review P2 ×2 対応: - net growth: complexity_delta.cyclomatic は extracted state 全体の総和 delta のため、ファイル間の関数移動 (+1/-1) は相殺されて lock は通る。 per-file 正のみで発火すると誤 advisory → aggregate (net) 比較に変更。 pure relocation で沈黙 / 部分 shrinkage 込み net 正で発火をテスト encode - tolerance: evaluator は lt/le/within_range に tolerance を適用する (le: observed <= expected + tol)。'<= 0, tolerance: 1' は +1 を既に 予算化しているので増加禁止 shape ではない → +1 が violate する条件 (le: expected+tol < 1 / lt: <= 1 / within_range: high+tol < 1) に変更。 equals は evaluator が tolerance 非適用のため従来通り expected <= 0。 予算化 3 形 / 不足 tolerance / equals+tolerance をテスト encode https://claude.ai/code/session_01BtUNrsnRygJY52xAy5bFRw
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e3a3c2cd7e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex review P2 対応: compatibility policy (docs/json_schema.md) は使用中 envelope の enum 値追加に schema version bump を要求する。advisory-1 の advisories[].code enum へ in-place 追加していた ADVISORY-D6 (PR #152、 未リリース main 上) / ADVISORY-D7 を advisory-2 として発行し直す。 producer 定数 / schema const / cli help / docs (json_schema 本文 + version 履歴表に v1→v2 diff 行) / test assert を同時更新 (tests/discipline/test_json_schema_version_sync.py が producer↔docs 同期を enforce)。 https://claude.ai/code/session_01BtUNrsnRygJY52xAy5bFRw
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85183e27aa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…rowth Codex review P2 対応: '+1 が violate するか' の判定では '<= 0, tolerance: 1' (1 helper 分の予算) が 2 helper 抽出 (+2) を suppress して しまうが、評価は observed=+2 で依然 structural false-FAIL する。 _forbids_cyclomatic_increase を _rejects_cyclomatic_delta(constraint, net) に置き換え、net_added を先に計算してから「実際の +net を reject する lock」だけを flag する。equals は net と一致すれば予算化扱いで沈黙。 budget < helper count で発火 / budget が helper count を被覆で沈黙 / equals=net で沈黙 をテスト encode、message と docs も +N 比較の表現に同期。 https://claude.ai/code/session_01BtUNrsnRygJY52xAy5bFRw
Completion Summary: D7-closure (ADVISORY-D7)
Phase
D-class closure 最終 (
STATUS.md 次の発行順序/ ROADMAP v0.1.0 exit criterion「D 全解決/waive」充足)。docs/dogfooding_findings_tracker.mdD7 = 2026-05-28 real-PR complexity dogfood FINDING-F2。本 PR で D-class 8/8 全解決。What Changed
authoring/nested_defs.pyにcount_visible_defs追加:extract_python_complexityに委譲して extractor の emission 規則との parity drift を構造的に排除 +VisibleDefGrowthrecordhazards.py::detect_d7新設: refactor kind × in-scope diff の可視 def net 増加 +N × 「+N を reject する」complexity_delta.cyclomatic制約(tolerance含め evaluator semantics を逐語 mirror)で発火。canonical order は D6 の直後target-doctor:_DiffContextにvisible_def_growth追加、blob 1 回取得で nested/visible 両カウント(_def_counts_at)。out-of-scope 側 0 / syntax error skip の D6 契約を共有advisory-2に bump(compatibility policy: 使用中 enum への値追加は bump 必須。D6 の in-place 追加分も本 bump に畳む)cli_usage/json_schema(v1→v2 diff 行含む)/exit_codes/ schema enum に D7 追記、tracker D7 行を解決 + 8/8 完了宣言Acceptance Criteria Status
<= 3/tolerance: N/equals Nが増加を被覆する場合は沈黙、budget < helper count は発火)Tests
detect_d716 件(net-zero relocation / tolerance 予算化 / budget<helper count 発火 / equals=net 沈黙 / equals×tolerance 非適用 含む)/ CLI git 統合 4 件(extract-method 発火 / cognitive 沈黙 / 抽出なし沈黙 / D6+D7 同時発火)ruff check .+ruff format --check .cleanDogfooding
processから_keepを module-level 抽出、全分岐保存)を作成し、semantic-ci check --target target.yaml --package-root src --baseline-rev <sha>(cyclomatic ≤ 0)→semantic-ci target-doctor ... --format human→ target をcomplexity_delta.cognitiveに書き換えてcheck再実行target-doctorがADVISORY-D7を発火(evidence:visible_defs_added: 1,src/mod.py 1→2)、guide 推奨どおり cognitive に替えると同一 refactor が PASS(fail+pass 両方実演 + 推奨 metric の実証)Files Changed
初版 15 files +566 −65、レビュー対応 3 commit(net growth + tolerance / advisory-2 bump / net-aware allowance)
Deviations from Brief
事前 brief なし(session 内で user が継続タスクを委任、tracker candidate paths (a)+(b) を逐語実装)。
Open Questions / Deferred
e3a3c2c、advisory-1→advisory-2 schema bump =85183e2、allowance vs 実 net helper 数比較 =3341d62Next Handoff
merge 後: STATUS.md の Phase / 次の発行順序 から D-class closure を sweep(wrap-up 時)。v0.1.0 exit criteria の D 項目は完了、残る軸は Phase X-2 実行(別 session)と H-5 申し送り P3。
https://claude.ai/code/session_01BtUNrsnRygJY52xAy5bFRw