Skip to content

feat(authoring): ADVISORY-D7 extract-method cyclomatic false-FAIL det…#153

Merged
Yuu6798 merged 4 commits into
mainfrom
claude/session-termination-protocol-migrate-5od2sz
Jun 12, 2026
Merged

feat(authoring): ADVISORY-D7 extract-method cyclomatic false-FAIL det…#153
Yuu6798 merged 4 commits into
mainfrom
claude/session-termination-protocol-migrate-5od2sz

Conversation

@Yuu6798

@Yuu6798 Yuu6798 commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Completion Summary: D7-closure (ADVISORY-D7)

Phase

D-class closure 最終 (STATUS.md 次の発行順序 / ROADMAP v0.1.0 exit criterion「D 全解決/waive」充足)。docs/dogfooding_findings_tracker.md D7 = 2026-05-28 real-PR complexity dogfood FINDING-F2。本 PR で D-class 8/8 全解決

What Changed

  • authoring/nested_defs.pycount_visible_defs 追加: extract_python_complexity に委譲して extractor の emission 規則との parity drift を構造的に排除 + VisibleDefGrowth record
  • hazards.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: _DiffContextvisible_def_growth 追加、blob 1 回取得で nested/visible 両カウント(_def_counts_at)。out-of-scope 側 0 / syntax error skip の D6 契約を共有
  • advisory envelope を advisory-2 に bump(compatibility policy: 使用中 enum への値追加は bump 必須。D6 の in-place 追加分も本 bump に畳む)
  • docs: guide Hazard 5 新設(refactor パターン別 metric 選択表、D6/D7 = 相補ペア)、cli_usage / json_schema(v1→v2 diff 行含む)/ exit_codes / schema enum に D7 追記、tracker D7 行を解決 + 8/8 完了宣言

Acceptance Criteria Status

  • advisory surface 契約維持(severity=info / verdict・exit code 非参与 / rev 未指定 + git 不在で silent skip)
  • detector は純粋関数、diff context は CLI 層計算(D4/D6 契約の鏡像)
  • allowance は実際の net helper 数 +N と比較(<= 3 / tolerance: N / equals N が増加を被覆する場合は沈黙、budget < helper count は発火)
  • 関数のファイル間移動(net 0)では発火しない — 総和 delta と整合する aggregate 比較
  • §23.1 input neutrality 不変(engine / evaluator 無改修)

Tests

  • 追加: 可視 def counter 6 件 / detect_d7 16 件(net-zero relocation / tolerance 予算化 / budget<helper count 発火 / equals=net 沈黙 / equals×tolerance 非適用 含む)/ CLI git 統合 4 件(extract-method 発火 / cognitive 沈黙 / 抽出なし沈黙 / D6+D7 同時発火)
  • 実行結果: 1817 passed, 1 deselected / ruff check . + ruff format --check . clean

Dogfooding

  • Status: performed
  • Commands: 一時 git repo で faithful extract-method refactor(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 再実行
  • Result: cyclomatic lock は FAIL(D7 が文書化する構造的 false-FAIL を実機再現)、target-doctorADVISORY-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

  • Codex P2 ×4 対応済み: net visible-def growth + tolerance 尊重 = e3a3c2c、advisory-1→advisory-2 schema bump = 85183e2、allowance vs 実 net helper 数比較 = 3341d62
  • D6 側の growth は per-file のまま(nested def は総和に算術寄与しないため aggregate 化の根拠が D7 と異なる。発火は advisory のみで保守的に許容)

Next 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

…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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/semantic_ci_code/authoring/hazards.py
Comment thread src/semantic_ci_code/authoring/hazards.py Outdated
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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/semantic_ci_code/schemas/doctor_advisory.schema.json
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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/semantic_ci_code/authoring/hazards.py Outdated
…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
@Yuu6798 Yuu6798 merged commit 405c2b1 into main Jun 12, 2026
5 checks passed
@Yuu6798 Yuu6798 deleted the claude/session-termination-protocol-migrate-5od2sz branch June 12, 2026 01:45
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.

2 participants