Skip to content

実装: VC contract lint を Issue 作成・編集時に前倒しして ACN マーカー誤記を早期検出する #839

Closed

Description

@squne121

背景

impl-review-loop #824 の作業で、Issue 本文の VC マーカーが # ACN — description 形式で書かれており、baseline_vc_preflight.py が AC_UNKNOWN として分類した。これにより issue-contract-review 段階で human_judgment が発生し、Issue 本文を手動修正する手戻りが生じた。

目的

gh issue create / gh issue edit 実行時(または Issue 作成後の webhook トリガー)に VC の ACN マーカー形式・preflight-scope marker の構文を lint し、誤記を早期検出する。

現状

  • baseline_vc_preflight.py は issue-contract-review(着手直前)で実行される
  • ACN マーカーの誤記(# ACN — description 等)は実行時に初めて検出される
  • 手戻りコスト: Issue 本文編集 → issue-contract-review 再実行

提案

  • Issue 作成・編集時に VC lint を実行するスクリプトを追加
  • lint 対象: # ACN マーカー形式、# preflight-scope: marker の有効値(pr_review_only / runtime_only)
  • 実行経路候補: pre-create hook / CI check / gh issue edit wrapper

Acceptance Criteria

  • AC1: validate_issue_body.py の LP016 を修正し、# AC1 系マーカーの suffix 付き誤記(:, :, -, —, 空白説明)をエラー検出する。
  • AC2: # preflight-scope: の未知値・空値・末尾ノイズをエラー検出し、gh issue create / gh issue edit 経路で status=failure, failure_stage=issue-body-validate による fail-closed にする。
  • AC3: create_issue_txn.py と edit-path で同一 validator (validate_issue_body.py) を使用し、mutate 前に validation 失敗で処理を停止する。
  • AC4: AC marker / preflight-scope parser を共通化する helper(vc_contract_syntax)を導入し、baseline_vc_preflight.py と整合させる。
  • AC5: loop_body_lint/v1 的な機械可読結果を status, errors[], rule_id, severity, line_start, line_end, fix_hint, body_sha256 形式で出力する。
  • AC6: # ACN — description / # AC1: description / # AC1:description / # AC1 - description / # AC1 description を LP016 error として検出し、同じ fixture で baseline_vc_preflight.py の回帰も固定する。

Verification Commands

# AC1
$ uv run python3 .claude/skills/create-issue/scripts/validate_issue_body.py --body-file ./.tmp/issue_body.md
# AC2
$ uv run python3 .claude/skills/create-issue/scripts/validate_issue_body.py --body-file ./.tmp/issue_body.md
# AC3
$ uv run python3 .claude/skills/create-issue/scripts/validate_issue_body.py --body-file ./.tmp/issue_body.md
# AC4
$ uv run python3 .claude/skills/create-issue/scripts/validate_issue_body.py --body-file ./.tmp/issue_body.md
# AC5
$ uv run python3 .claude/skills/create-issue/scripts/validate_issue_body.py --body-file ./.tmp/issue_body.md
# AC6
$ uv run python3 .claude/skills/create-issue/scripts/validate_issue_body.py --body-file ./.tmp/issue_body.md

Outcome

  • validate_issue_body.py に AC marker / preflight-scope の誤記検出を統一的に実装し、gh issue create / gh issue edit の事前 gate として適用する。
  • # AC1 などの AC marker 仕様と # preflight-scope 仕様を同一の parser helper に集約し、validator drift を排除する。
  • validation 失敗時は mutation を停止し、Issue を手戻りさせない運用にする。

Allowed Paths

  • .claude/skills/create-issue/scripts/validate_issue_body.py
  • .claude/skills/create-issue/scripts/tests/test_validate_issue_body.py
  • .claude/skills/edit-issue/scripts/guard-issue-body.py
  • .claude/skills/edit-issue/tests/test_guard_issue_body.py
  • .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py
  • .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py
  • .claude/skills/issue-contract-review/scripts/vc_contract_syntax.py

Runtime Verification Applicability

decision: not_applicable

参考

Activity

  1. added
    enhancement
    phase/research
    on Jun 13, 2026
  2. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES

    #839 の問題設定は正しいです。#824 で # ACN — description 型の VC marker 誤記が issue-contract-review 時点まで残り、human_judgment に落ちた、という再発防止としては妥当です。#839 自体にも「Issue 作成・編集時、または issue-created webhook で前倒し lint する」という意図が明記されています。

    ただし、現状の #839 は Issue としての切り方がまだ甘い。新規 script を増やす話に見えますが、repo にはすでに create_issue_txn.py -> validate_issue_body.py の pre-mutation validator があり、create_issue_txn.py は GitHub mutation 前に issue body validation を fail-closed 実行しています。 ここへ寄せずに別 lint を足すと、baseline_vc_preflight.py / validate_issue_body.py / 新規 lint の 3 系統で VC grammar が drift します。

    確認できた根拠

    baseline_vc_preflight.py の AC marker parser は # AC1 または # AC1: の単独行だけを受け付ける実装です。# AC1 — description は marker として解釈されません。 一方で validate_issue_body.py 側の LP016 は「description suffix を検出する」と説明しているのに、実装は # AC1: desc のような colon + suffix だけを検出し、今回の # AC1 — desc を取り逃がします。 さらに LP010 の VC 側 AC 抽出は #\s+AC(\d+) なので、壊れた # AC1 — desc でも AC 番号だけは拾えてしまい、AC⇔VC mismatch では検出されません。

    # preflight-scope: についても、現行 baseline_vc_preflight.py は valid 値 pr_review_only / runtime_only なら skip/go にしますが、未知値は human_judgment に落とすだけです。つまり #839 の AC2 は妥当ですが、作成・編集時点で error にする専用 rule がまだ必要です。

    関連Issueを見ると、これは孤立事故ではありません。#840 は #824 で test -s が human_judgment 化した件を扱っており、#841 は scope-rollup の machine-readable marker 欠落を fail-closed にすべき件です。どちらも「自然言語っぽい証跡を後段で人間判定に落としてしまう」同系統の欠陥です。 #835 / PR #851 も、readiness result を READINESS_FORWARDING_PAYLOAD_V1 として producer/consumer 契約化する方向で修正されています。

    Blockers

    1. 「新規 lint script 追加」が主語だと危険
      既存の validate_issue_body.py が pre-write hook として使われています。実装: VC contract lint を Issue 作成・編集時に前倒しして ACN マーカー誤記を早期検出する #839 は「新規 script」ではなく、validate_issue_body.py の LP016 強化、preflight-scope rule 追加、共通 VC grammar helper 抽出を主語にするべきです。

    2. AC1 が狭すぎる
      # ACN — description だけでは足りません。少なくとも # AC1: desc, # AC1:desc, # AC1 - desc, # AC1 — desc, # AC1 desc をまとめて error にする必要があります。現状 LP016 は colon 形式しか検出しません。

    3. AC3 の「valid VC」が曖昧
      baseline_vc_preflight.py は # AC1: も許容していますが、実装: VC contract lint を Issue 作成・編集時に前倒しして ACN マーカー誤記を早期検出する #839 は # ACN と書いています。canonical を # AC<N> のみへ絞るのか、legacy として # AC<N>: を許すのかを明文化してください。ここを曖昧にすると parser drift が残ります。

    4. edit 経路の受け入れ条件がない
      GitHub CLI は gh issue create と gh issue edit の両方で --body-file を持っています。したがって create だけでなく edit wrapper にも validator を必ず挟めます。([GitHub CLI]1) (GitHub CLI) 実装: VC contract lint を Issue 作成・編集時に前倒しして ACN マーカー誤記を早期検出する #839 の AC は --body-file lint 単体に寄っていて、gh issue edit --body-file 前でブロックする AC がありません。

    5. webhook / GitHub Actions は primary gate にならない
      GitHub Actions の issues event は opened / edited で走らせられますが、これは「作成・編集後」に走る backstop です。作成前に mutation を止める primary gate は local wrapper / transaction helper 側に置くべきです。([GitHub Docs]3)

    6. 出力 contract がない
      実装: issue-refinement-loop Step 4 の static readiness forwarding を consumer 契約込みで定義する #835 / PR docs: add readiness forwarding contracts #851 の流れを見ると、agent が消費するには status, errors[], rule_id, line_start, line_end, fix_hint, body_sha256 を持つ machine-readable JSON/YAML が必要です。実装: VC contract lint を Issue 作成・編集時に前倒しして ACN マーカー誤記を早期検出する #839 は検出対象だけを定義しており、consumer contract が不足しています。

    推奨する実装方針

    実装は validate_issue_body.py を強化し、VC grammar を共通化する 方向に寄せるべきです。baseline_vc_preflight.py を直接 import して実行系まで巻き込むのは避け、AC marker / preflight-scope marker の純粋 parser だけを shared helper に切り出してください。

    推奨ファイル構成:

    .claude/skills/create-issue/scripts/validate_issue_body.py
    .claude/skills/issue-contract-review/scripts/vc_contract_syntax.py   # 新規 shared helper
    .claude/skills/create-issue/scripts/tests/test_vc_contract_lint.py
    .claude/skills/edit-issue/SKILL.md
    .claude/skills/issue-refinement-loop/tests/test_readiness_forwarding_contract.py
    

    rule はこう切るのが妥当です。

    LP016:
      name: vc_ac_marker_must_be_bare
      severity: error
      valid:
        - "# AC1"
      invalid:
        - "# AC1: description"
        - "# AC1:description"
        - "# AC1 - description"
        - "# AC1 — description"
        - "# AC1 description"
    
    LP018:
      name: vc_preflight_scope_invalid
      severity: error
      valid_values:
        - pr_review_only
        - runtime_only
    
    LP019:
      name: vc_preflight_scope_unattached
      severity: error
      condition: "preflight-scope marker must immediately precede a VC command inside ```bash block"

    gh 連携は 3 層にしてください。GitHub CLI extension として配る場合、GitHub CLI extensions は custom command として実装でき、拡張 repo は gh- prefix と root executable を必要とします。([GitHub Docs]4) ただし、この repo 内ではまず既存 transaction helper / skill wrapper に組み込む方が低コストです。

    # create primary gate
    uv run python3 .claude/skills/create-issue/scripts/validate_issue_body.py --body-file "$body_file"
    gh issue create --body-file "$body_file" ...
    
    # edit primary gate
    uv run python3 .claude/skills/create-issue/scripts/validate_issue_body.py --body-file "$body_file"
    gh issue edit "$issue" --body-file "$body_file" ...

    GitHub Actions は backstop としてだけ使います。

    on:
      issues:
        types: [opened, edited]

    この workflow は invalid issue に contract/invalid label を付ける、または lint result comment を投稿する用途に留めるべきです。作成前ブロックはできません。

    #839 の修正版AC案

    ## Acceptance Criteria
    
    - [ ] AC1: `validate_issue_body.py --body-file <file>` が `# AC1 — description` / `# AC1: description` / `# AC1:description` / `# AC1 - description` / `# AC1 description` を `LP016` error として検出する。
    - [ ] AC2: `# AC1` の単独 marker と、その直後または同 block 内の `$ <single command>` は pass する。
    - [ ] AC3: `# preflight-scope: pr_review_only` / `# preflight-scope: runtime_only` は pass する。
    - [ ] AC4: `# preflight-scope: invalid` / empty value / trailing token / unattached marker は `LP018` または `LP019` error として検出する。
    - [ ] AC5: `create_issue_txn.py` は invalid body で `gh issue create` を呼ぶ前に `status=failure, failure_stage=issue-body-validate` で停止する。
    - [ ] AC6: edit-issue wrapper は `gh issue edit --body-file` を呼ぶ前に同じ validator を実行し、invalid body で mutation しない。
    - [ ] AC7: lint result は `loop_body_lint/v1` の `status`, `errors[]`, `rule_id`, `severity`, `line_start`, `line_end`, `fix_hint`, `body_sha256` を含む。
    - [ ] AC8: `baseline_vc_preflight.py` と `validate_issue_body.py` の AC marker / preflight-scope grammar が同一 fixture で検証され、parser drift が起きない。
    - [ ] AC9: linter は VC command を実行しない。`subprocess.run` は validator 実行以外で呼ばれないことを focused test で固定する。

    結論

    #839 は採用。ただし、そのまま実装すると「遅延検出を前倒しする」目的の半分しか満たしません。修正方針は、新規 lint script 追加ではなく、既存 pre-write validator の grammar 強化 + edit wrapper 統合 + Actions backstop + machine-readable result contract です。特に LP016 の現在実装が今回の — suffix を捕まえない点は即修正対象です。

  3. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor
    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: "https://github.com/squne121/loop-protocol/issues/839#issuecomment-4698190478"
        generated_at: "2026-06-13T10:01:00Z"
        body_sha256: "1d6ba56760a9a9fd46d2b49bcc929c0eedc0831fa36871f7f24586ee68774390"
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: auto_fixed
        required:
          - kind: template_hygiene
            executor: implementation-worker
            result: applied
            evidence:
              before: "issue body lacked required sections"
              after: "## Acceptance Criteria / ## Verification Commands / ## Outcome"
              comment_url: "https://github.com/squne121/loop-protocol/issues/839#issuecomment-4698190478"
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: "2026-06-13T10:01:00Z"
      checked_body_sha256: "sha256:1d6ba56760a9a9fd46d2b49bcc929c0eedc0831fa36871f7f24586ee68774390"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []

    更新内容の反映を完了し、issue の必須セクション欠落(C3/C4/C8)を解消しました。run_refinement_preflight は warn -> proceed_with_notes で遷移し、check_issue_contract は approve を返しています。

  4. added
    phase/implementation
    and removed
    phase/research
    on Jun 13, 2026
  5. changed the title [-]chore: VC contract lint を Issue 作成・編集時に前倒しして ACN マーカー誤記を早期検出する[/-] [+]実装: VC contract lint を Issue 作成・編集時に前倒しして ACN マーカー誤記を早期検出する[/+] on Jun 13, 2026
  6. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: REQUEST_CHANGES

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      issue_number: 839
      pr_url: "https://github.com/squne121/loop-protocol/pull/867"
      pr_number: 867
      head_sha: "94378ee6f148b3953d0115b8c7a19a3053c9d49f"
      status: request_changes
      iteration: 1
      blockers:
        - "ci_verdict_summary failed due to skipped checks: Issue Body Japanese Check (retrospective), PR Review Japanese Check (retrospective), Issue Comment Japanese Check (retrospective), deploy-main, cleanup-pr"
      follow_up_issue_requests: []
      required_auto_actions: []
      merge_ready: false
      termination_reason: null
      fix_delta:
        iteration: 1
        blockers:
          - "ci_verdict_summary failed due to skipped checks in ci_verdict_summary.py"
        pr_review_comment_url: "https://github.com/squne121/loop-protocol/pull/867#pullrequestreview-4491314438"
        test_failures:
          - "ci_verdict_summary.py exit 10; failed_checks includes skipped items"
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations: []
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

    enhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions