Skip to content

実装: issue-contract-review の BLOCKED 結果を review-issue / issue-author / edit-issue に接続し、refinement 中に contract 不備を修正可能にする #492

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "244"
goal_ref: "issue-contract-review が検出する VC preflight / Runtime Verification Applicability / Issue body validator 不備を、issue-refinement-loop 本体ではなく review-issue・issue-author・edit-issue 側で修正可能な structured feedback として扱えるようにする"
change_kind: workflow
depends_on:
  - "327"
  - "329"
  - "456"
related:
  - "456"

Parent Issue

#244

Parent Goal Ref

  • Goal: GitHub Issue body が validator / preflight script により機械検証され、AI agent は failing rule + minimal_context + fix_hint だけで修正できる状態にする。
  • Desired Destination: issue-refinement-loop は薄い orchestration のまま、review-issue / issue-author / edit-issue が issue-contract-review 相当の deterministic result を consume し、impl-review-loop 着手時の CONTRACT_REVIEW_RESULT_V1 status: blocked を前段で潰せる。

Current Validated Scope

  • .claude/skills/issue-contract-review/scripts/ に contract_readiness_check.py を追加し、mutation-free で ISSUE_CONTRACT_READINESS_RESULT_V1 を返す helper を実装する。
  • review-issue / issue-reviewer.md が contract readiness result を needs-fix blocker として consume する。
  • issue-author.md が AC3/AC4 の blocker payload から本文修正を生成できる authoring rule を持つ。
  • edit-issue が mutation 前に contract readiness check を fail-closed で実行する。
  • #327 / #329 成果物(validate_issue_body.py / baseline_vc_preflight.py)を helper から参照する。

Remaining Parent Gaps

  • #456: VC_SINGLE_COMMAND_GUARDRAIL の body-authoring.md SSOT 移設(本 Issue では重複定義しない)。
  • PR body validator(実装: PR body contract validator を追加する #469)は本 Issue の対象外。
  • issue-contract-review の go | blocked | human_judgment 意味論変更は本 Issue の外。

Outcome

issue-refinement-loop 実行中に issue-contract-review 相当の deterministic blocker が review-issue → issue-author → edit-issue の通常経路で修正される。結果として、implementation Issue が approved になった直後に /impl-review-loop <issue> を実行しても、VC preflight / Runtime Verification Applicability / Issue body validator 不備だけを理由に preparation BLOCKED にならない状態で、contract_readiness_check.py が存在し fixture tests が PASS している。

In Scope

  • .claude/skills/issue-contract-review/scripts/contract_readiness_check.py を新規追加する。
    • 入力: --issue <N> または --body-file <path>
    • 出力: ISSUE_CONTRACT_READINESS_RESULT_V1 JSON(status、body_sha256、source_checks[]、errors[]、minimal_context[]、fix_hint)
    • GitHub comment / label / branch / worktree を作らない(mutation-free)。
    • validate_issue_body.py のエラー結果を統合する。
    • baseline_vc_preflight.py の blocked / human_judgment 結果を統合する。
    • Runtime Verification Applicability decision: immediate の必須 field 不足を検出する。
    • 仕様:
      • --mode static(既定): VC 構文・section・schema のみを静的検証する。edit-issue pre-mutation guard の既定。GitHub 認証・VC 実行・ネットワーク不要。
      • --mode execute: baseline_vc_preflight.py を呼び出して VC を実行する。issue-contract-review 互換用。
    • Status mapping contract を実装する:
      • validate_issue_body.py の LPxxx errors → needs_fix
      • baseline_vc_preflight.py の compound_command_disallowed → needs_fix
      • baseline_vc_preflight.py の no commands / extraction error(本文構造起因)→ needs_fix
      • baseline_vc_preflight.py の env/tool missing / regression gate fails → human_judgment
      • baseline_vc_preflight.py の human_judgment → human_judgment(絶対に潰さない)
    • 出力仕様: ISSUE_CONTRACT_READINESS_RESULT_V1 JSON(schema, status, body_sha256, source_checks[], errors[], minimal_context[], fix_hint)
    • source_checks[] は各 checker の実行結果(name, schema, status, exit_code)を含む
    • errors[] の各要素は rule_id, severity, source_check, category, section, line_start, line_end, minimal_context, fix_hint, autofixable を持つ
  • .claude/skills/issue-contract-review/scripts/tests/fixtures/ に issue412_contract_blocked.md / issue412_contract_go.md を追加する。
  • review-issue / .claude/agents/issue-reviewer.md を更新し、contract readiness result を REVIEW_ISSUE_RESULT_V1 の needs-fix 理由に転写する(判定ロジックは再実装しない)。
  • .claude/agents/issue-author.md の <!-- VC_SINGLE_COMMAND_GUARDRAIL --> 参照セクションが contract_readiness_check.py の診断結果を body-authoring.md の SSOT へ誘導できるよう確認・更新する(詳細 VC authoring rule は body-authoring.md 正本に委譲するため、issue-author.md に新規ルールを追加しない)。
  • .claude/skills/edit-issue/ を更新し、Issue body mutation 前に contract_readiness_check.py --mode static を fail-closed で実行する。status: go 以外の場合は gh issue edit を実行しない。human_judgment も go と同等に扱わない(fail-closed)。
  • .claude/skills/create-issue/references/body-authoring.md の contract readiness 参照を追記する(#456 の VC_SINGLE_COMMAND_GUARDRAIL SSOT と重複定義しない)。

Out of Scope

  • issue-refinement-loop に contract preflight 判定ロジックを追加すること。
  • impl-review-loop の preparation 条件を緩和すること。
  • issue-contract-review の BLOCKED / human_judgment / go の意味論変更。
  • GitHub comment 投稿、label mutation、branch / worktree 作成。
  • PR body validator の変更(実装: PR body contract validator を追加する #469 の scope)。
  • #412 の secure-secret-boundary 実装本体。
  • VC_SINGLE_COMMAND_GUARDRAIL の SSOT 移設(実装: VC_SINGLE_COMMAND_GUARDRAIL を issue-author 直書きから body-authoring 正本へ移設する #456 の scope)。
  • issue-refinement-loop/SKILL.md / impl-review-loop/SKILL.md への判定ロジック追加。
  • issue-author.md に contract_readiness_check.py の診断ルールを直書きすること(body-authoring.md 正本に委譲)。

Acceptance Criteria

  • AC1: contract_readiness_check.py または同等 helper が存在し、--body-file 入力で GitHub 非依存に ISSUE_CONTRACT_READINESS_RESULT_V1 JSON を返す。
  • AC2: result は schema: "ISSUE_CONTRACT_READINESS_RESULT_V1"、status、body_sha256、source_checks[]、errors[](各要素に rule_id, severity, source_check, category, section, line_start, line_end, minimal_context, fix_hint, autofixable)、fix_hint、minimal_context[] を含む。
  • AC3: baseline_vc_preflight.py が返す compound_command_disallowed / unexpected_pass / invalid preflight-scope / human_judgment が contract readiness result に lossless に写像される。
  • AC4: Runtime Verification Applicability decision: immediate で applicable_acs / execution_environment / skip_conditions / fallback_policy / artifact_requirements の不足が needs_fix として検出される。
  • AC5: review-issue は contract readiness result を consume し、needs-fix verdict に含める。ただし判定ロジックを prose で再実装しない。
  • AC6: issue-author の <!-- VC_SINGLE_COMMAND_GUARDRAIL --> 参照セクションが contract readiness feedback を body-authoring.md SSOT に誘導する形になっている(新規 VC authoring rule を issue-author.md に直書きしていない)。
  • AC7: edit-issue は mutation 前に contract readiness check を実行し、error が残る body を GitHub に書き込まない。
  • AC8: 実装: Claude Code / GitHub Actions の Secret 到達面を上流で制限する secure-secret-boundary を導入する #412 相当 blocked fixture で、compound VC、unexpected pass、regression gate 誤分類、Runtime Verification Applicability 不足が検出される。
  • AC9: 実装: Claude Code / GitHub Actions の Secret 到達面を上流で制限する secure-secret-boundary を導入する #412 相当 fixed fixture で status: go になる。
  • AC10: issue-refinement-loop/SKILL.md と impl-review-loop/SKILL.md に新しい判定ロジックを追加していないことを test または grep で確認する。
  • AC11: contract_readiness_check.py の pytest が pnpm test または CI の必須ジョブで実行される。
  • AC12: --body-file + --mode static モードは GitHub token / gh auth / network に依存せず実行できる。
  • AC13: result JSON は checkin 済み JSON Schema または golden fixture で strict に検証される(unknown top-level key は tests で reject される)。

Verification Commands

# AC1
$ test -f .claude/skills/issue-contract-review/scripts/contract_readiness_check.py

# AC2
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-contract-review/scripts/tests/ -q -k "contract_readiness_result_v1_schema"

# AC3
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-contract-review/scripts/tests/ -q -k "compound_command_disallowed or unexpected_pass or preflight_scope or contract_readiness"

# AC4
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-contract-review/scripts/tests/ -q -k "runtime_verification_applicability or applicable_acs or contract_readiness"

# AC5
$ rg -n "ISSUE_CONTRACT_READINESS_RESULT_V1" .claude/skills/review-issue/ .claude/agents/issue-reviewer.md

# AC6
# preflight-scope: pr_review_only
$ rg -n "VC_SINGLE_COMMAND_GUARDRAIL" .claude/agents/issue-author.md

# AC7
$ rg -n "contract_readiness_check" .claude/skills/edit-issue/

# AC8
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-contract-review/scripts/tests/ -q -k "issue412"

# AC9
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-contract-review/scripts/tests/ -q -k "contract_go_fixture"

# AC10
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-contract-review/scripts/tests/ -q -k "no_logic_in_orchestration_skills"

# AC11
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-contract-review/scripts/tests/ -q -k "contract_readiness"

# AC12
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-contract-review/scripts/tests/ -q -k "no_network_required or static_mode"

# AC13
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-contract-review/scripts/tests/ -q -k "golden_fixture or schema_strict"

$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

Allowed Paths

.claude/skills/issue-contract-review/scripts/
.claude/skills/issue-contract-review/scripts/tests/
.claude/skills/issue-contract-review/scripts/tests/fixtures/
.claude/skills/issue-contract-review/SKILL.md
.claude/skills/review-issue/
.claude/agents/issue-reviewer.md
.claude/agents/issue-author.md
.claude/skills/edit-issue/
.claude/skills/create-issue/references/body-authoring.md

issue-refinement-loop / impl-review-loop は原則 Allowed Paths に入れない。どうしても reference map だけ更新が必要な場合は、別 Issue か、AC10 を満たす範囲の comment-only/reference-only 変更に限定する。

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • issue-refinement-loop または impl-review-loop に判定ロジックを追加しないと達成できないと判明した場合
  • issue-contract-review の既存 go | blocked | human_judgment 意味論を変更する必要が出た場合
  • GitHub comment / label / branch / worktree mutation が helper 実行に必要になる場合
  • 実装: VC_SINGLE_COMMAND_GUARDRAIL を issue-author 直書きから body-authoring 正本へ移設する #456 の SSOT 移設と衝突し、VC authoring rule の正本を二重定義する必要が出た場合
  • review-issue が deterministic checker の結果を再解釈しないと routing できない場合
  • 実装: Claude Code / GitHub Actions の Secret 到達面を上流で制限する secure-secret-boundary を導入する #412 固有実装に踏み込む必要が出た場合

Runtime Verification Applicability

decision: immediate
applicable_acs:
  - AC1
  - AC2
  - AC3
  - AC4
  - AC5
  - AC6
  - AC7
  - AC8
  - AC9
  - AC10
  - AC11
  - AC12
  - AC13
execution_environment:
  cli_tools:
    - python3
    - uv
    - rg
    - pnpm
  auth_required: false
  network_required: false
skip_conditions:
  - "local repository checkout が存在しない場合は SKIP ではなく environment blocked として扱う"
  - "fixture 入力テストは GitHub 認証なしで実行できること"
fallback_policy:
  fallback_success_is_pass: false
  notes: "grep だけで orchestration 層非変更を確認する場合も、contract readiness helper の fixture tests が PASS しない限り成功扱いにしない"
artifact_requirements:
  - ".claude/skills/issue-contract-review/scripts/tests/fixtures/issue412_contract_blocked.md"
  - ".claude/skills/issue-contract-review/scripts/tests/fixtures/issue412_contract_go.md"
  - "contract_readiness_check.py JSON output"
  - "pytest output for contract_readiness tests"

Required Skills

  • Python(argparse / json / subprocess)
  • pytest(fixture / parametrize)

Scope Delta(任意)

N/A

Activity

  1. added
    enhancement
    phase/implementation
    agent/implementer
    on May 29, 2026
  2. squne121 commented on May 29, 2026

    @squne121
    OwnerAuthor

    create-issue transaction partial-failure

    Issue: #492
    Failure stage: label-readback
    Message: label read-back mismatch

    Requested:

    Failure context:
    matching_issue_numbers=[492]
    issue_number=492

    Recovery hint: label-readback failed for #492.
    Manual re-apply command (idempotent: yes):
    gh issue edit 492 --repo squne121/loop-protocol --add-label
    Verify:
    gh issue view 492 --repo squne121/loop-protocol --json labels

    Please recover deterministically before re-running the create issue transaction.

  3. squne121 commented on May 29, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES / 現状のまま実装開始は危険

    #492 の狙い自体は妥当です。issue-contract-review の BLOCKED を impl-review-loop まで持ち越さず、review-issue / issue-author / edit-issue の refinement 中に修正可能にする、という接続点は親Issue #244の「validator/preflight の機械結果と minimal_context だけで AI が修正できる状態にする」方針と整合しています。(GitHub)

    ただし、現行案は #456 未解決、VC parser 仕様、Runtime Verification Applicability の即時検証、baseline preflight の status semantics を甘く見ています。このままだと「BLOCKED を解消する仕組み」ではなく、「BLOCKED を別名の needs_fix に詰め替えるだけの層」になります。


    致命的問題

    1. #456 と SSOT が衝突している

    #492 は issue-author に AC3/AC4 修正ルールを追加するとしつつ、#456 の SSOT には踏み込まない、としています。これは危険です。#456 はまさに VC authoring rule を .claude/skills/create-issue/references/body-authoring.md に集約し、issue-author.md から詳細ルールを排除するためのIssueです。(GitHub)

    さらに現状の body-authoring.md にはまだ && echo PASS || echo FAIL や pipe を含む例が残っており、baseline preflight の「単一コマンド」前提と矛盾しています。(GitHub)

    修正要求: #492 は depends_on: 456 に格上げするか、少なくとも issue-author には詳細な VC authoring rule を置かず、contract_readiness_check.py の診断結果を body-authoring SSOT に誘導するだけにしてください。issue-author.md に新しい規則を直接増やすと、#452/#456 で既に指摘された「SubAgent 定義が運用設計書化する」問題を再発させます。(GitHub)


    2. #492 自身の Verification Commands が契約違反になり得る

    #327 の validator は fenced bash の VC を要求し、#329 の baseline preflight も ## Verification Commands 配下の fenced bash block からコマンドを抽出する設計です。(GitHub)

    一方、#492 の Verification Commands は indented code block 風で、全コマンドが fenced bash ではありません。また |、複数行、! rg ...、python - <<'PY' 系の構造が混在しており、baseline preflight の compound-command 検出では blocked になり得ます。(GitHub)

    修正要求: #492 の本文自体を先に修正してください。各 VC は fenced bash、1 AC につき単一コマンド、# AC<N> marker を明示、pipe/heredoc/compound shell を避ける必要があります。自分自身が通らない契約を実装Issueにしないでください。


    3. AC4 の immediate runtime-field 検証は既存 validator では足りない

    #492 は Runtime Verification Applicability decision: immediate の場合に applicable_acs / execution_environment / skip_conditions / fallback_policy / artifact_requirements 欠落を needs_fix にする、としています。(GitHub)

    しかし既存 validate_issue_body.py の LP020 は、主に section/decision と deferred 用フィールドを見ており、immediate 用の具体フィールド完全性までは検査していません。(GitHub)

    修正要求: contract_readiness_check.py 側で AC4 専用の parser/check を明示実装してください。validate_issue_body.py の LP020 に依存すると false negative が出ます。診断は最低限、rule_id, section, field, line_start, minimal_context, fix_hint, autofixable=true を持つべきです。


    4. blocked を機械的に needs_fix へ写像すると壊れる

    #329/#354 の経緯では、blocked と human_judgment の優先順位・保持が重要な論点でした。特に「blocked と human_judgment が混在した場合に human_judgment が勝つ」バグがレビューで指摘され、blocked 優先に直されています。(GitHub)

    #492 の go | needs_fix | human_judgment への集約は、baseline preflight の blocked category を潰しやすいです。例えば compound_command_disallowed は本文修正で直せるため needs_fix でよい一方、環境依存・command not found・timeout・retrieval/extraction error は本文修正では直らない場合があります。pytest の exit code 5 “No tests collected” のように、preflight 側で意味づけされる終了コードもあります。(GitHub)

    修正要求: mapping table をIssue本文に追加してください。最低限、次を分けるべきです。

    source | category | readiness status | 理由 -- | -- | -- | -- validate_issue_body error | LPxxx | needs_fix | 本文修正可能 baseline preflight | compound_command_disallowed | needs_fix | VC記述修正で解消可能 baseline preflight | no commands / extraction error | needs_fix または human_judgment | 本文構造起因なら needs_fix、parser仕様外なら human_judgment baseline preflight | env/tool missing | human_judgment | 本文修正だけでは解消不能 baseline preflight | regression gate fails | human_judgment | 実装・環境・依存不備の可能性 baseline preflight | human_judgment | human_judgment | 絶対に潰さない

    5. 「mutation-free helper」が VC 実行の副作用を無視している

    #492 は helper を mutation-free としていますが、baseline preflight は subprocess.run(..., shell=False) で実際にコマンドを実行します。shell=False は shell injection 面では有利ですが、実行対象コマンド自体の filesystem/network 副作用を消すものではありません。Python 公式ドキュメントでも subprocess.run() は外部プロセス実行 API であり、shell の既定は false です。(GitHub)

    修正要求: contract_readiness_check.py に mode を分けてください。

    --mode static     VC構文・section・schemaだけを見る。edit-issue pre-mutation の既定。
    --mode execute    baseline_vc_preflight.py を実行する。issue-contract-review 互換用。
    

    edit-issue の pre-mutation guard で arbitrary VC を実行する設計は危険です。最低でも allowlist、timeout、cwd固定、環境変数制限、network禁止方針、実行ログの minimal_context 制限が必要です。


    高品質化のための具体設計

    1. 出力 schema を固定する

    #244 は「AI が failing rule + minimal_context から修正できる」ことを親方針にしています。(GitHub) そのため #492 の ISSUE_CONTRACT_READINESS_RESULT_V1 は prose contract ではなく、JSON Schema か golden fixture で固定すべきです。JSON Schema は JSON document の validation vocabularies を定義する標準仕様として使えます。(json-schema.org)

    推奨形:

    {
      "schema": "ISSUE_CONTRACT_READINESS_RESULT_V1",
      "status": "go",
      "body_sha256": "sha256:...",
      "source_checks": [
        {
          "name": "validate_issue_body",
          "schema": "loop_body_lint/v1",
          "status": "pass",
          "exit_code": 0
        }
      ],
      "errors": [],
      "minimal_context": [],
      "fix_hint": null
    }
    

    errors[] は string 配列では不十分です。最低限、rule_id, severity, source_check, category, section, line_start, line_end, minimal_context, fix_hint, autofixable を持たせてください。


    2. edit-issue への接続位置を明確化する

    GitHub CLI の gh issue edit は --body-file で本文ファイルを読み込めます。(GitHub CLI) 現行 edit-issue は body backup → body生成 → guard → gh issue edit --body-file の流れです。(GitHub)

    #492 の guard はこの既存 guard の直前または同一段に入れるべきです。

    generate NEW_BODY
    run guard-issue-body.py
    run contract_readiness_check.py --body-file NEW_BODY --mode static
    if status != go: abort before gh issue edit
    gh issue edit --body-file NEW_BODY
    

    human_judgment を edit-issue で許可するかは明文化が必要です。fail-closed なら go 以外は拒否です。human_judgment を通すなら、それは fail-closed ではありません。


    3. CI 追加を AC に入れる

    #367 では、validator tests が CI に入っていないことが blocker として指摘されました。(GitHub) #492 でも同じ失敗を避ける必要があります。

    追加すべき AC:

    AC11: contract_readiness_check.py の pytest が CI の必須ジョブで実行される。
    AC12: --body-file mode は GitHub token / gh auth / network に依存しない。
    AC13: result JSON は schema/golden fixture で strict に検証される。
    

    fixture 設計への要求

    #492 は #412 を blocked/go fixture に使う方針ですが、#412 は secret boundary 実装Issueであり、secret 値・hash・base64・comment dumping などを明示的に out-of-scope にしています。(GitHub)

    fixture は #412 の全文コピーではなく、契約構造だけを抽出した synthetic fixture にしてください。必要なのは secret 実装ではなく、次の contract anti-pattern です。

    • immediate RVA fields 欠落

    • fenced bash ではない VC

    • compound VC

    • AC/VC marker 不一致

    • baseline preflight の blocked

    • validate_issue_body の LPxxx error

    • human_judgment を潰さない mixed result


    推奨する #492 本文修正

    #492 に次を追記すると実装品質が上がります。

    ### Status mapping contract
    

    contract_readiness_check.py MUST preserve source status and category.
    It MUST NOT collapse baseline human_judgment into needs_fix.
    It MUST map only body-author-fixable categories to needs_fix.

    • validate_issue_body errors -> needs_fix
    • baseline compound_command_disallowed -> needs_fix
    • baseline missing/extraction error caused by malformed issue body -> needs_fix
    • baseline env/tool/runtime failure -> human_judgment
    • baseline human_judgment -> human_judgment

    Execution mode

    • --mode static: default for edit-issue; no VC execution.
    • --mode execute: may invoke baseline_vc_preflight.py; intended for issue-contract-review compatibility.

    Schema stability

    Result JSON MUST be validated by a checked-in JSON Schema or strict golden fixtures.
    Unknown top-level keys are rejected in tests.


    最終判断

    実装方針は正しいですが、現Issueは 仕様境界がまだ粗い です。特に #456 との SSOT 衝突、#492 自身の VC 契約違反、immediate RVA 検証の不足、baseline preflight status の lossy mapping は blocker です。

    このIssueは、実装開始前に少なくとも次を直すべきです。

    1. 実装: VC_SINGLE_COMMAND_GUARDRAIL を issue-author 直書きから body-authoring 正本へ移設する #456 を依存関係に格上げ、または issue-author への詳細ルール追加を撤回。

    2. 実装: issue-contract-review の BLOCKED 結果を review-issue / issue-author / edit-issue に接続し、refinement 中に contract 不備を修正可能にする #492 の Verification Commands を fenced bash + single command + AC marker に修正。

    3. blocked/human_judgment/needs_fix mapping table を明文化。

    4. --mode static と --mode execute を分離。

    5. result schema / golden fixture / CI gate を AC に追加。

    6. immediate Runtime Verification Applicability の必須フィールド検査を新 helper の明示責務にする。

    ## 判定: REQUEST_CHANGES / 現状のまま実装開始は危険

    #492 の狙い自体は妥当です。issue-contract-review の BLOCKED を impl-review-loop まで持ち越さず、review-issue / issue-author / edit-issue の refinement 中に修正可能にする、という接続点は親Issue #244の「validator/preflight の機械結果と minimal_context だけで AI が修正できる状態にする」方針と整合しています。([GitHub]1)

    ただし、現行案は #456 未解決、VC parser 仕様、Runtime Verification Applicability の即時検証、baseline preflight の status semantics を甘く見ています。このままだと「BLOCKED を解消する仕組み」ではなく、「BLOCKED を別名の needs_fix に詰め替えるだけの層」になります。


    致命的問題

    1. #456 と SSOT が衝突している

    #492 は issue-author に AC3/AC4 修正ルールを追加するとしつつ、#456 の SSOT には踏み込まない、としています。これは危険です。#456 はまさに VC authoring rule を .claude/skills/create-issue/references/body-authoring.md に集約し、issue-author.md から詳細ルールを排除するためのIssueです。([GitHub]1)

    さらに現状の body-authoring.md にはまだ && echo PASS || echo FAIL や pipe を含む例が残っており、baseline preflight の「単一コマンド」前提と矛盾しています。([GitHub]2)

    修正要求: #492 は depends_on: 456 に格上げするか、少なくとも issue-author には詳細な VC authoring rule を置かず、contract_readiness_check.py の診断結果を body-authoring SSOT に誘導するだけにしてください。issue-author.md に新しい規則を直接増やすと、#452/#456 で既に指摘された「SubAgent 定義が運用設計書化する」問題を再発させます。([GitHub]3)


    2. #492 自身の Verification Commands が契約違反になり得る

    #327 の validator は fenced bash の VC を要求し、#329 の baseline preflight も ## Verification Commands 配下の fenced bash block からコマンドを抽出する設計です。([GitHub]4)

    一方、#492 の Verification Commands は indented code block 風で、全コマンドが fenced bash ではありません。また |、複数行、! rg ...、python - <<'PY' 系の構造が混在しており、baseline preflight の compound-command 検出では blocked になり得ます。([GitHub]1)

    修正要求: #492 の本文自体を先に修正してください。各 VC は fenced bash、1 AC につき単一コマンド、# AC<N> marker を明示、pipe/heredoc/compound shell を避ける必要があります。自分自身が通らない契約を実装Issueにしないでください。


    3. AC4 の immediate runtime-field 検証は既存 validator では足りない

    #492 は Runtime Verification Applicability decision: immediate の場合に applicable_acs / execution_environment / skip_conditions / fallback_policy / artifact_requirements 欠落を needs_fix にする、としています。([GitHub]1)

    しかし既存 validate_issue_body.py の LP020 は、主に section/decision と deferred 用フィールドを見ており、immediate 用の具体フィールド完全性までは検査していません。([GitHub]5)

    修正要求: contract_readiness_check.py 側で AC4 専用の parser/check を明示実装してください。validate_issue_body.py の LP020 に依存すると false negative が出ます。診断は最低限、rule_id, section, field, line_start, minimal_context, fix_hint, autofixable=true を持つべきです。


    4. blocked を機械的に needs_fix へ写像すると壊れる

    #329/#354 の経緯では、blocked と human_judgment の優先順位・保持が重要な論点でした。特に「blocked と human_judgment が混在した場合に human_judgment が勝つ」バグがレビューで指摘され、blocked 優先に直されています。([GitHub]6)

    #492 の go | needs_fix | human_judgment への集約は、baseline preflight の blocked category を潰しやすいです。例えば compound_command_disallowed は本文修正で直せるため needs_fix でよい一方、環境依存・command not found・timeout・retrieval/extraction error は本文修正では直らない場合があります。pytest の exit code 5 “No tests collected” のように、preflight 側で意味づけされる終了コードもあります。([GitHub]7)

    修正要求: mapping table をIssue本文に追加してください。最低限、次を分けるべきです。

    source category readiness status 理由
    validate_issue_body error LPxxx needs_fix 本文修正可能
    baseline preflight compound_command_disallowed needs_fix VC記述修正で解消可能
    baseline preflight no commands / extraction error needs_fix または human_judgment 本文構造起因なら needs_fix、parser仕様外なら human_judgment
    baseline preflight env/tool missing human_judgment 本文修正だけでは解消不能
    baseline preflight regression gate fails human_judgment 実装・環境・依存不備の可能性
    baseline preflight human_judgment human_judgment 絶対に潰さない

    5. 「mutation-free helper」が VC 実行の副作用を無視している

    #492 は helper を mutation-free としていますが、baseline preflight は subprocess.run(..., shell=False) で実際にコマンドを実行します。shell=False は shell injection 面では有利ですが、実行対象コマンド自体の filesystem/network 副作用を消すものではありません。Python 公式ドキュメントでも subprocess.run() は外部プロセス実行 API であり、shell の既定は false です。([GitHub]7)

    修正要求: contract_readiness_check.py に mode を分けてください。

    --mode static     VC構文・section・schemaだけを見る。edit-issue pre-mutation の既定。
    --mode execute    baseline_vc_preflight.py を実行する。issue-contract-review 互換用。
    

    edit-issue の pre-mutation guard で arbitrary VC を実行する設計は危険です。最低でも allowlist、timeout、cwd固定、環境変数制限、network禁止方針、実行ログの minimal_context 制限が必要です。


    高品質化のための具体設計

    1. 出力 schema を固定する

    #244 は「AI が failing rule + minimal_context から修正できる」ことを親方針にしています。([GitHub]8) そのため #492 の ISSUE_CONTRACT_READINESS_RESULT_V1 は prose contract ではなく、JSON Schema か golden fixture で固定すべきです。JSON Schema は JSON document の validation vocabularies を定義する標準仕様として使えます。([json-schema.org]9)

    推奨形:

    {
      "schema": "ISSUE_CONTRACT_READINESS_RESULT_V1",
      "status": "go",
      "body_sha256": "sha256:...",
      "source_checks": [
        {
          "name": "validate_issue_body",
          "schema": "loop_body_lint/v1",
          "status": "pass",
          "exit_code": 0
        }
      ],
      "errors": [],
      "minimal_context": [],
      "fix_hint": null
    }

    errors[] は string 配列では不十分です。最低限、rule_id, severity, source_check, category, section, line_start, line_end, minimal_context, fix_hint, autofixable を持たせてください。


    2. edit-issue への接続位置を明確化する

    GitHub CLI の gh issue edit は --body-file で本文ファイルを読み込めます。(GitHub CLI) 現行 edit-issue は body backup → body生成 → guard → gh issue edit --body-file の流れです。([GitHub]11)

    #492 の guard はこの既存 guard の直前または同一段に入れるべきです。

    generate NEW_BODY
    run guard-issue-body.py
    run contract_readiness_check.py --body-file NEW_BODY --mode static
    if status != go: abort before gh issue edit
    gh issue edit --body-file NEW_BODY
    

    human_judgment を edit-issue で許可するかは明文化が必要です。fail-closed なら go 以外は拒否です。human_judgment を通すなら、それは fail-closed ではありません。


    3. CI 追加を AC に入れる

    #367 では、validator tests が CI に入っていないことが blocker として指摘されました。([GitHub]12) #492 でも同じ失敗を避ける必要があります。

    追加すべき AC:

    AC11: contract_readiness_check.py の pytest が CI の必須ジョブで実行される。
    AC12: --body-file mode は GitHub token / gh auth / network に依存しない。
    AC13: result JSON は schema/golden fixture で strict に検証される。
    

    fixture 設計への要求

    #492 は #412 を blocked/go fixture に使う方針ですが、#412 は secret boundary 実装Issueであり、secret 値・hash・base64・comment dumping などを明示的に out-of-scope にしています。([GitHub]13)

    fixture は #412 の全文コピーではなく、契約構造だけを抽出した synthetic fixture にしてください。必要なのは secret 実装ではなく、次の contract anti-pattern です。

    • immediate RVA fields 欠落
    • fenced bash ではない VC
    • compound VC
    • AC/VC marker 不一致
    • baseline preflight の blocked
    • validate_issue_body の LPxxx error
    • human_judgment を潰さない mixed result

    推奨する #492 本文修正

    #492 に次を追記すると実装品質が上がります。

    ### Status mapping contract
    
    `contract_readiness_check.py` MUST preserve source status and category.
    It MUST NOT collapse baseline `human_judgment` into `needs_fix`.
    It MUST map only body-author-fixable categories to `needs_fix`.
    
    - validate_issue_body errors -> needs_fix
    - baseline compound_command_disallowed -> needs_fix
    - baseline missing/extraction error caused by malformed issue body -> needs_fix
    - baseline env/tool/runtime failure -> human_judgment
    - baseline human_judgment -> human_judgment
    
    ### Execution mode
    
    - `--mode static`: default for `edit-issue`; no VC execution.
    - `--mode execute`: may invoke `baseline_vc_preflight.py`; intended for issue-contract-review compatibility.
    
    ### Schema stability
    
    Result JSON MUST be validated by a checked-in JSON Schema or strict golden fixtures.
    Unknown top-level keys are rejected in tests.

    最終判断

    実装方針は正しいですが、現Issueは 仕様境界がまだ粗い です。特に #456 との SSOT 衝突、#492 自身の VC 契約違反、immediate RVA 検証の不足、baseline preflight status の lossy mapping は blocker です。

    このIssueは、実装開始前に少なくとも次を直すべきです。

    1. 実装: VC_SINGLE_COMMAND_GUARDRAIL を issue-author 直書きから body-authoring 正本へ移設する #456 を依存関係に格上げ、または issue-author への詳細ルール追加を撤回。
    2. 実装: issue-contract-review の BLOCKED 結果を review-issue / issue-author / edit-issue に接続し、refinement 中に contract 不備を修正可能にする #492 の Verification Commands を fenced bash + single command + AC marker に修正。
    3. blocked/human_judgment/needs_fix mapping table を明文化。
    4. --mode static と --mode execute を分離。
    5. result schema / golden fixture / CI gate を AC に追加。
    6. immediate Runtime Verification Applicability の必須フィールド検査を新 helper の明示責務にする。
  4. squne121 commented on May 30, 2026

    @squne121
    OwnerAuthor

    Contract Review: BLOCKED (2026-05-30T00:07:00Z)

    CONTRACT_REVIEW_RESULT_V1:
      status: blocked
      generated_at: "2026-05-30T00:07:00Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/492
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: false
          vc_failed_as_expected: 2
          vc_passed_unexpectedly: 1
          vc_unrunnable: 1
          vc_expected_pass: 5
          vc_skipped: 0
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
        worktree_branch_collision: clear
      next_action: propose_refinement_loop
      blocked_reasons:
        - "AC1: contract_readiness_check.py が存在しないため file_not_found_unrunnable (blocked). test -f または # preflight-scope: runtime_only マーカーが必要"
        - "AC2, AC4, AC8-AC13: 新規 pytest キーワードで exit 5 (no tests collected) → regression_gate/blocked. 実装前は存在しないテストのため # preflight-scope: runtime_only マーカーが必要"
        - "AC6: VC_SINGLE_COMMAND_GUARDRAIL が既に issue-author.md に存在 → unexpected_pass/blocked. 実装前から pass するため VC を再設計する必要あり(例: 直書き禁止の確認 VC に変更)"

    不足項目

    AC VC category 問題 修正方法
    AC1 uv run python3 contract_readiness_check.py ... file_not_found_unrunnable スクリプトが未存在 → 実行エラー $ test -f .claude/skills/issue-contract-review/scripts/contract_readiness_check.py に変更、または # preflight-scope: runtime_only を追加
    AC2, AC4, AC8〜AC13 uv run pytest ... -k "<new_keyword>" regression_gate/blocked 新規テストキーワードが存在しない (exit 5) 各コマンドの直前に # preflight-scope: runtime_only を追加
    AC6 rg -n "VC_SINGLE_COMMAND_GUARDRAIL" .claude/agents/issue-author.md unexpected_pass 文字列が既に存在するため baseline で pass VC を「直書きされていないこと」の確認に変更、例: $ test ! -f .claude/agents/issue-author.md ← 存在はするので別の "absence" チェックに変更すべき

    AC6 VC 再設計の推奨

    AC6 の意図は「issue-author.md に新規 VC authoring rule が直書きされていないこと」を確認すること。しかし現行 VC は VC_SINGLE_COMMAND_GUARDRAIL タグの存在を確認するだけで、それが既に存在するため baseline で pass してしまいます。

    推奨 VC:

    # AC6
    # preflight-scope: pr_review_only
    $ rg -c "compound_command_disallowed|unexpected_pass|regression_gate_misclassified" .claude/agents/issue-author.md

    (PR レビュー時に「直書きルールがないこと」を確認する形に変更)

    推奨アクション

    issue-refinement-loop を起動し、以下の VC 修正を行ってください:

    1. AC1 VC: test -f .claude/skills/issue-contract-review/scripts/contract_readiness_check.py に変更
    2. AC2, AC4, AC8〜AC13: 各 pytest -k コマンドの直前に # preflight-scope: runtime_only を追加
    3. AC6 VC: # preflight-scope: pr_review_only マーカーを追加するか、"absence of new rules" を確認する形に再設計
  5. squne121 commented on May 30, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-05-30T00:14:30Z)

    • Outcome: issue-refinement-loop 実行中に issue-contract-review 相当の deterministic blocker が review-issue → issue-author → edit-issue の通常経路で修正される。contract_readiness_check.py が存在し fixture tests が PASS している。
    • Acceptance Criteria: AC1〜AC13(全 13 項目)
    • Verification Commands: test -f / pytest -k (runtime_only) / rg / pnpm typecheck/lint/test/build
    • Allowed Paths: .claude/skills/issue-contract-review/scripts/, .claude/skills/review-issue/, .claude/agents/issue-reviewer.md, .claude/agents/issue-author.md, .claude/skills/edit-issue/, .claude/skills/create-issue/references/body-authoring.md
    • Worktree: .claude/worktrees/issue-492-issue-contract-review-blocked-review-iss
    • Branch: worktree-issue-492-issue-contract-review-blocked-review-iss
    • VC preflight: baseline fail = 3, 想定外 pass = 0, 実行不可 = 0, skipped = 10, regression gate pass = 4
    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-05-30T00:14:30Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/492
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 3
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 4
          vc_skipped: 10
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings: []
  6. squne121 commented on May 30, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-05-30T00:26:54Z)

    • PR: feat(#492): add contract_readiness_check.py and wire into review-issue / edit-issue #497
    • Worktree: .claude/worktrees/issue-492-issue-contract-review-blocked-review-iss
    • Branch: worktree-issue-492-issue-contract-review-blocked-review-iss
    • Verification: 4/4 PASS (typecheck/lint/test/build) + 18 pytest PASS
    • contract_readiness_check.py: 新規作成 (--mode static / --mode execute)
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
  7. added a commit that references this issue on May 30, 2026
  8. squne121 commented on May 30, 2026

    @squne121
    OwnerAuthor

    implement-issue: PR #497 レビューフィードバック修正完了 (2026-05-30T00:49:49Z)

    6ブロッカーすべて修正しました。

    修正内容

    B1 & B4 (--mode preflight-static + operator sync):

    • --mode preflight-static を static のエイリアスとして追加
    • compound_operators を baseline_vc_preflight.py と同期(<, >, <<< 追加)
    • review-issue/SKILL.md / issue-reviewer.md を --mode preflight-static 使用に更新

    B2 (structured_blockers):

    • REVIEW_ISSUE_RESULT_V1 に structured_blockers フィールド追加(machine-readable errors[])
    • blocking_issues は人間向け fix_hint 文字列、structured_blockers は構造体のまま

    B3 (issue-author repair contract):

    • body-authoring.md に「Issue-Author Repair Contract by Blocker Category」セクション追加

    B5 (non-assertive AC3 tests):

    • test_contract_readiness.py に synthetic preflight JSON を渡す unit test 5件追加

    B6 (Safety Claim Matrix):

  9. added 2 commits that reference this issue on May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions