Skip to content

feat(authoring): ADVISORY-D6 nested-function complexity displacement …#152

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

feat(authoring): ADVISORY-D6 nested-function complexity displacement …#152
Yuu6798 merged 3 commits into
mainfrom
claude/session-termination-protocol-migrate-5od2sz

Conversation

@Yuu6798

@Yuu6798 Yuu6798 commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Completion Summary: D6-closure (ADVISORY-D6)

Phase

D-class closure (残 D6/D7、STATUS.md 次の発行順序 / ROADMAP v0.1.0 exit criteria 前進)。docs/dogfooding_findings_tracker.md D6 = 2026-05-28 real-PR complexity dogfood FINDING-F1。

What Changed

  • authoring/nested_defs.py 新設: count_nested_defs(関数内 nested def の決定論カウント、syntax error は None で fail-silent)+ NestedDefGrowth record
  • hazards.py::detect_d6 新設: verdict 参加の complexity_delta 制約 × in-scope Python diff の nested-def 増加で発火。canonical order は D4 の直後(D1 → D3 → D4 → D6 → I1 → P1 → P2 → S1)
  • target-doctor: _resolve_files_touched_resolve_diff_context に再構成し、D4/D6 が同一 numstat pass を共有。両 rev の blob は新設 git_runtime.blob_text で読み出し(追加/削除ファイルは欠側 0、parse 不能 entry は skip)
  • docs: target_yaml_guide.md Hazard 4 新設、cli_usage.md / json_schema.md / exit_codes.md / doctor_advisory.schema.json に D6 追記、tracker D6 行を解決(D-class 7/8)+ D8 行へ PR fix(ssp): recognise PEP 621 / lockfile dependency sources in pip-audit scan (D8) #151 番号追記(2026-06-11 申し送り消化)

Acceptance Criteria Status

  • detector は advisory surface 契約を維持(severity=info 固定 / verdict・exit code 非参与 / rev 未指定 + git 不在時 silent skip)— Advisory.__post_init__ + 既存 exit-code テスト群で担保
  • detector は純粋関数、diff 由来 context は CLI 層で計算(D4 の files_touched 契約の鏡像)
  • 偽シグナル防止: syntax error 側は entry ごと skip / 増加なし・制約なし・info+ignore 制約では発火しない(negative テストで encode)
  • §23.1 input neutrality 不変(engine / evaluator 無改修、advisor surface のみ)

Tests

  • 追加: tests/authoring/test_nested_defs.py 12 件 / test_hazards.py detect_d6 9 件 / tests/cli/test_target_doctor.py git 統合 5 件(displacement 発火 / 制約なし沈黙 / 増加なし沈黙 / syntax error skip / 新規ファイル 0 起点)
  • 実行結果: 1789 passed, 1 deselected / ruff check . clean

Dogfooding

  • Status: performed
  • Commands: 一時 git repo で nested 化 refactor(process の本体を _collect nested helper へ移動)を作成し、semantic-ci check --target target.yaml --package-root src --baseline-rev <sha>semantic-ci target-doctor --target target.yaml --package-root src --baseline-rev <sha> --candidate-rev HEAD --format human を実走
  • Result: check は PASS(= D6 の騙しが verdict を通過する fail 面の実証)、同一 rev ペアで target-doctorADVISORY-D6 を発火し evidence(nested_defs_added: 1, files: [src/mod.py 0→1])を提示(pass 面)。fail+pass 両方実演パターンに準拠

Files Changed

16 files changed, +694 −49(新規: authoring/nested_defs.py, tests/authoring/test_nested_defs.py)

Deviations from Brief

事前 brief なし(session 内で user が D6 closure を選択、tracker の candidate path (a) を逐語実装)。path (b)(extractor が nested entry を emit する spec 変更)は schema-impacting のため不採用のまま tracker に長期 option として残置。

Open Questions / Deferred

  • D7(extract-method × cyclomatic 微増)は未着手のまま残 1 件(low priority、authoring advice)
  • nested class への displacement は D6 検出範囲外(nested def のみカウント)。発生事例が出たら counter の拡張で対応可能

Next Handoff

merge 後: STATUS.md 次の発行順序から D6 を sweep し 直近 merged へ(wrap-up 時)。残 D-class は D7 のみ。

https://claude.ai/code/session_01BtUNrsnRygJY52xAy5bFRw

claude added 2 commits June 12, 2026 00:45
…detector (D6 closure)

dogfooding_findings_tracker D6 (2026-05-28 real-PR pass FINDING-F1) を
candidate path (a) で解決する。complexity extractor は nested def 境界で
descent を停止する (api_surface parity) ため、関数本体を nested helper に
押し込む refactor は実複雑度不変のまま cyclomatic/cognitive の大幅減を報告
し、complexity_delta lock が vacuous PASS する (D4 の sibling)。

- authoring/nested_defs.py 新設: count_nested_defs (関数内 nested def の
  決定論カウント、syntax error は None で fail-silent) + NestedDefGrowth
- hazards.py detect_d6: verdict 参加 complexity_delta 制約 × in-scope
  Python diff の nested-def 増加で発火。canonical order は D4 の直後
- target-doctor: _resolve_files_touched を _resolve_diff_context に再構成し
  D4/D6 が同一 numstat pass を共有。両 rev の blob を git_runtime.blob_text
  (新設) で読み、追加/削除ファイルは欠側 0、parse 不能 entry は skip
- advisory surface 契約は不変: severity=info 固定、verdict / exit code 非参与、
  --baseline-rev/--candidate-rev 未指定 + git 不在時は silent skip
- docs: target_yaml_guide Hazard 4 新設、cli_usage / json_schema /
  exit_codes / doctor_advisory.schema.json に D6 追記、tracker D6 行を
  解決 (7/8) に更新 + D8 行へ PR #151 番号追記 (2026-06-11 申し送り)
- tests: nested_defs 単体 12 件 + detect_d6 9 件 + CLI git 統合 5 件
  (displacement 発火 / 制約なし沈黙 / 増加なし沈黙 / syntax error skip /
  新規ファイル 0 起点)。全 1789 件 pass / ruff 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: 836d8ccf46

ℹ️ 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/cli/commands/target_doctor.py Outdated
Codex review P2: --package-root 境界を跨ぐ rename で scope 外の側から
nested-def 数を読むと、新たに in-scope 化したファイル (例 lib/helpers.py
→ src/helpers.py) が N → N に見えて D6 を見逃す。extractor は scope 外を
観測しないため、scope 外の側は欠側と同じく 0 として growth を計算する。
into-scope / out-of-scope rename の両方向を CLI 統合テストに encode。

https://claude.ai/code/session_01BtUNrsnRygJY52xAy5bFRw
@Yuu6798 Yuu6798 merged commit 4bdd152 into main Jun 12, 2026
4 checks passed
@Yuu6798 Yuu6798 deleted the claude/session-termination-protocol-migrate-5od2sz branch June 12, 2026 01:05
Yuu6798 pushed a commit that referenced this pull request Jun 12, 2026
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
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