Skip to content

実装: issue-refinement-loop の terminal contract を LOOP_HANDOFF_RESULT_V1.status: impl_ready に固定する #628

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#626"
goal_ref: "issue-refinement-loop の terminal contract を LOOP_HANDOFF_RESULT_V1.status: impl_ready に固定し、人間の追加 Y なしで impl-review-loop intake gate を通過できる状態にする"
change_kind: workflow

Parent Issue

#626

Parent Goal Ref

  • Goal: issue-refinement-loop → impl-review-loop 遷移を追加の人間 Y なしで自動完了させる(スキル間 handoff contract 欠落の統合修正)
  • Desired Destination: /issue-refinement-loop <N> は追加オプションなしで、成功時に LOOP_HANDOFF_RESULT_V1.status: impl_ready を返す。template / metadata / marker / contract-snapshot hygiene を deterministic fixer SubAgent に委譲し、main は marker のみ保持する。

Current Validated Scope

  • .claude/skills/issue-refinement-loop/SKILL.md — terminal contract を LOOP_HANDOFF_RESULT_V1.status: impl_ready に明示し、LOOP_HANDOFF_RESULT_V1 marker 出力を termination step の必須出力として定義する
  • .claude/skills/issue-refinement-loop/references/termination-policy.md — implementation_ready 遷移条件と LOOP_HANDOFF_RESULT_V1 schema を SSOT 化し、auto-fixable な hygiene 種別(template_hygiene / metadata_hygiene / known_marker_fix / stale_state_label_cleanup / contract_snapshot_materialization)を deterministic fixer SubAgent へ委譲する contract を追加する
  • .claude/skills/issue-refinement-loop/schemas/loop_handoff_result_v1.json — LOOP_HANDOFF_RESULT_V1 JSON schema を追加し、marker 出力の machine-readable validation を可能にする(ディレクトリが存在しない場合は新規作成)
  • .claude/skills/issue-refinement-loop/tests/test_loop_handoff_result.py — LOOP_HANDOFF_RESULT_V1 schema validation および hygiene 委譲 routing を検証するテストを追加する

Remaining Parent Gaps

  • child-1: issue_kind allowlist / normalization の単一 SSOT 集約(別 Issue)
  • child-3: pr-review-judge / pr-reviewer の merge_ready / required_auto_actions 追加(別 Issue)
  • child-4: implementation-worker の IMPLEMENTATION_WORKER_REQUEST_V2 mode 追加(別 Issue)
  • child-5: impl-review-loop の終了条件を APPROVE && merge_ready && required_auto_actions == [] に統一(別 Issue)
  • child-6: AUTONOMY_POLICY_V1 共通 policy / result schema 追加(別 Issue)
  • child-7: 回帰テスト追加(別 Issue)

Outcome

issue-refinement-loop が成功終了時に LOOP_HANDOFF_RESULT_V1.status: impl_ready を HTML comment + fenced YAML marker として出力する contract が termination-policy.md に SSOT 化され、LOOP_HANDOFF_RESULT_V1 JSON schema が追加されて pytest で validate されている状態。

終了不変条件(Non-negotiable Terminal Invariant)

LOOP_HANDOFF_RESULT_V1.status: impl_ready は、以下の 全条件 を満たす場合のみ出力する。1つでも欠けた場合は human_judgment_required または blocked とし、impl_ready を出力してはならない。

  • 最新有効な CONTRACT_REVIEW_RESULT_V1.status が go である
  • go snapshot が現在の Issue body hash と一致する(fresh)
  • go snapshot より後に有効な request_changes / blocked contract-review がない
  • title prefix と required phase label が存在するか、deterministic auto-fix の evidence(before / after / comment_url)が添付されている
  • required template metadata が存在するか、deterministic auto-fix の evidence が添付されている
  • auto_fixes.required と auto_fixes.skipped が空である(repair 後)。auto_fixes の各要素には kind / executor / result / evidence(before, after, comment_url)が必要。result: skipped や evidence 欠落の場合は impl_ready を禁止する。
  • blockers が空である
  • routing_action が run_impl_review_loop である

In Scope

  • termination-policy.md に LOOP_HANDOFF_RESULT_V1 schema(status: impl_ready | human_judgment_required | blocked / routing_action / contract_review / metadata / auto_fixes / blockers / permissions / generated_at)を SSOT として追加する
  • SKILL.md の Step 5 (Termination) を更新し、approved 終了時に LOOP_HANDOFF_RESULT_V1 marker を必須出力として定義する
  • impl_ready の定義(title prefix / phase/implementation label 不足のみで停止しない状態)を termination-policy.md で明示する
  • template hygiene / metadata hygiene / known marker fix / stale state label cleanup / contract snapshot materialization の 5 種 hygiene を deterministic fixer SubAgent に委譲する contract(routing 定義のみ)を termination-policy.md に追加する。fixer SubAgent の実装本体は本 Issue のスコープ外とし、別 Issue で対応する。
  • scope / goal / AC の意味変更時は human_judgment_required で停止する routing を明記する
  • LOOP_HANDOFF_RESULT_V1 JSON schema ファイル(schemas/loop_handoff_result_v1.json)を追加する
  • schema validation を検証する pytest テストを追加する
  • LOOP_HANDOFF_RESULT_V1 の contract_review フィールドは status(go | blocked)と gate_result(fresh_go | missing_go | stale_go | invalidated_by_request_changes | blocked)を分離する。既存 SSOT の CONTRACT_REVIEW_RESULT_V1.status: go | blocked と衝突しない設計にする。

Out of Scope

  • child-1: issue_kind allowlist / normalization の SSOT 集約
  • child-3 〜 child-7 のスコープ(pr-review-judge / implementation-worker / impl-review-loop 終了条件 / AUTONOMY_POLICY_V1 / 回帰テスト)
  • issue-contract-review / check_issue_contract.py の変更
  • plan_refinement_loop.py のロジック変更
  • --no-human-approval / --prepare-impl-ready / --auto-prepare 等の新規ユーザー向けオプション追加
  • CLI permission mode(bypassPermissions / --dangerously-skip-permissions)の変更
  • 実際の deterministic fixer SubAgent の実装(contract / routing の定義のみ)
  • deterministic fixer SubAgent の実装本体(agent 定義ファイル、tools/disallowedTools frontmatter、実行ロジック等)。本 Issue は routing contract 定義のみ。

Acceptance Criteria

  • AC1: issue-refinement-loop の approved 終了時に LOOP_HANDOFF_RESULT_V1 marker が出力され、status: impl_ready が含まれる経路が termination-policy.md に定義されている
  • AC2: impl_ready の定義(title prefix / phase/implementation label 不足のみで停止しない状態)が termination-policy.md に SSOT として記載されている
  • AC3: LOOP_HANDOFF_RESULT_V1 JSON schema ファイルが schemas/loop_handoff_result_v1.json に存在し、status enum に impl_ready | human_judgment_required | blocked が含まれる
  • AC4: scope / goal / AC の意味変更時は status: human_judgment_required / routing_action: ask_human で停止する routing が termination-policy.md に記載されている
  • AC5: template hygiene / metadata hygiene / known marker fix / stale state label cleanup / contract snapshot materialization の 5 種 hygiene を deterministic fixer SubAgent に委譲し、auto_fixed | human_judgment_required | blocked の machine-readable result のみを main に返す contract が定義されている
  • AC6: LOOP_HANDOFF_RESULT_V1 marker は HTML comment + fenced YAML(<!-- LOOP_HANDOFF_RESULT_V1 --> 直後に ```yaml ブロック)形式で出力されることが termination-policy.md に規定されている
  • AC7: LOOP_HANDOFF_RESULT_V1 schema validation を検証する pytest テストが追加され、以下の 8 routing パターンで PASS する:(1) fresh_go + metadata ready + no blockers → impl_ready、(2) missing contract go → blocked / human_judgment_required、(3) stale go(body 更新後)→ impl_ready 禁止、(4) valid request_changes after go → impl_ready 禁止、(5) title prefix/phase label missing + auto-fix evidence あり → impl_ready 可、(6) title prefix/phase label missing + fixer unavailable → impl_ready 禁止、(7) scope/goal/AC 意味変更 → human_judgment_required、(8) blocker あり → blocked

Verification Commands

# AC1 / AC6
$ rg -n "LOOP_HANDOFF_RESULT_V1" .claude/skills/issue-refinement-loop/references/termination-policy.md
# AC2
$ rg -n "impl_ready" .claude/skills/issue-refinement-loop/references/termination-policy.md
# AC3
$ test -f .claude/skills/issue-refinement-loop/schemas/loop_handoff_result_v1.json
# AC4
$ rg -n "human_judgment_required" .claude/skills/issue-refinement-loop/references/termination-policy.md
# AC5
$ rg -n "auto_fixed|deterministic fixer" .claude/skills/issue-refinement-loop/references/termination-policy.md
# AC6
$ rg -n "HTML comment|fenced YAML|LOOP_HANDOFF_RESULT_V1" .claude/skills/issue-refinement-loop/references/termination-policy.md
# AC7(8-pattern routing test)
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_loop_handoff_result.py -v -k "fresh_go or missing_go or stale_go or request_changes or auto_fix_evidence or fixer_unavailable or scope_change or blocker_exists"

Runtime Verification Applicability

  • applicability: not_applicable
  • decision: not_applicable
  • reason: 本 Issue は SKILL.md / termination-policy.md / JSON schema / pytest テストの追加(workflow docs / schema ファイル)であり、実行時の issue-refinement-loop 呼び出しによる runtime 挙動検証は本 Issue のスコープ外。VC の pytest(test_loop_handoff_result.py)は実装後の schema 構造検証であり、baseline では file-not-found の expected baseline fail となる。

Allowed Paths

  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/references/termination-policy.md
  • .claude/skills/issue-refinement-loop/schemas/loop_handoff_result_v1.json
  • .claude/skills/issue-refinement-loop/tests/test_loop_handoff_result.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • Python / pytest(JSON schema validation)
  • YAML / JSON schema(LOOP_HANDOFF_RESULT_V1 schema 定義)

Scope Delta(任意)

N/A

Delivery Rule

Activity

  1. added
    enhancement
    phase/implementation
    on Jun 3, 2026
  2. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    [create-issue] post-create ready tuple validation 結果: ready_tuple PASSED(title prefix 正常、phase/implementation label 付与済み)。template_guard が '## Verification Commands' 欠落と報告したが、セクションは body 70行目に存在する(fenced code block パース上の false positive の可能性が高い)。手動修正は不要。

  3. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES

    #628 は方向性自体は妥当ですが、#626 の child-2 としては契約だけ増やして実効ゲートを満たしたように見せる危険なIssueです。現状のままだと「LOOP_HANDOFF_RESULT_V1.status: impl_ready を出す仕様」は追加されても、親Issueが求める「追加の人間Yなしで impl-review-loop intake gate を通過できる状態」までは保証されません。#628 自身も deterministic fixer SubAgent の実装、issue-contract-review、check_issue_contract.py、plan_refinement_loop.py を Out of Scope に置いており、検証も rg と schema/test file の存在確認に寄っています。これは #626 の「proseだけでapprove不可、fixtureで before fail / after pass を示す」方針と噛み合っていません。([GitHub]1)

    主要ブロッカー

    1. impl_ready の定義が実装可能状態を保証していない

    #626 の到達点は、issue本文が実装可能、metadata/labels が正規化済み、fresh な CONTRACT_REVIEW_RESULT_V1.status: go snapshot があり、impl-review-loop intake gate が追加承認なしで通る状態です。#628 はその一部を schema 化しますが、実際の fixer 実行や intake gate 連携を範囲外にしているため、impl_ready が単なる marker 文字列になり得ます。([GitHub]1)

    修正すべきです。impl_ready は少なくとも次を全て満たす場合だけ許可してください。

    status: impl_ready
    routing_action: run_impl_review_loop
    contract_review:
      status: go
      gate_result: fresh_go
      body_sha256_matches_current_issue_body: true
    metadata:
      title_prefix_ready: true
      phase_label_ready: true
    auto_fixes:
      required: []
      skipped: []
    blockers: []
    permissions:
      unavailable: []

    どれか1つでも欠けるなら human_judgment_required か blocked に落とすべきです。

    2. contract_review.status の enum 設計が既存SSOTと衝突している

    #628 は contract_review.status に go | missing | stale | request_changes のような状態を入れようとしていますが、既存の termination policy では CONTRACT_REVIEW_RESULT_V1.status は go|blocked で、human judgment は next_action 側で表現する設計です。ここで request_changes を status に混ぜると、既存 gate の語彙と新markerの語彙が壊れます。([GitHub]2)

    推奨はこうです。

    contract_review:
      status: go | blocked
      gate_result: fresh_go | missing_go | stale_go | invalidated_by_request_changes | blocked
      latest_comment_url: string
      generated_at: string
      body_sha256: string

    JSON Schema の enum は固定値集合を表すため、ここは曖昧な自然言語ではなく厳密に分離した enum にするべきです。([JSON Schema]3)

    3. deterministic fixer SubAgent が「存在しない契約」になっている

    #628 は title prefix、phase label、contract snapshot freshness、template metadata、marker format などを deterministic fixer SubAgent に委譲すると書いていますが、その SubAgent 実装は Out of Scope です。親 #626 は「新規 SubAgent 追加は過剰で、既存 implementation-worker を repair executor として使う」方向を明記しています。つまり #628 は親方針とズレています。([GitHub]1)

    #611 の前例では read-only runner として .claude/agents/scope-rollup-runner.md を作り、tools、mutation禁止、marker hash、fallback を明示しています。#628 の fixer は書き込みを伴う可能性が高いので、#611 と同じ read-only 設計を雑に流用すると破綻します。([GitHub]4)

    修正案は2択です。

    1. 実装: issue-refinement-loop の terminal contract を LOOP_HANDOFF_RESULT_V1.status: impl_ready に固定する #628 を schema + routing contract + tests only に縮小し、「fixer 実装は別Issue」と明記する。
    2. 実装: issue-refinement-loop の terminal contract を LOOP_HANDOFF_RESULT_V1.status: impl_ready に固定する #628 に既存 implementation-worker への IMPLEMENTATION_WORKER_REQUEST_V2 発行・結果受理・再検証まで含める。

    現状の「fixerに委譲するが fixer は作らない」は不可です。

    4. 検証が弱い。rg では親Issueの失敗を防げない

    #628 の Verification Commands は rg と test file 存在確認が中心で、impl_ready の誤発火を検出できません。#626 は、handoff/hygiene failure を再現する fixture、修正後に pass する fixture、machine-readable TEST_VERDICT を要求しています。([GitHub]1)

    最低限、次の routing test が必要です。

    1. fresh go + metadata ready + no blockers
       => status=impl_ready, routing_action=run_impl_review_loop
    
    2. missing contract go
       => status=blocked または human_judgment_required
       => routing_action != run_impl_review_loop
    
    3. stale go: issue body updated after go
       => impl_ready 禁止
    
    4. valid request_changes after go
       => impl_ready 禁止
    
    5. title prefix / phase label missing but deterministic auto-fix applied with evidence
       => impl_ready 可
    
    6. title prefix / phase label missing and fixer unavailable
       => impl_ready 禁止
    
    7. scope / goal / AC semantic change required
       => human_judgment_required
    
    8. blocker exists
       => blocked
    

    #564 が入れた fail-only intake gate は「missing/stale go を自動で都合よく進めない」ための安全境界です。#628 はこれを marker 追加で迂回しないようにする必要があります。([GitHub]5)

    5. #627 の失敗パターンを再発させる

    #627 では Closes #589 欠落や BEHIND が recommendations / follow-up 側に落ち、merge-ready 判定の周辺で hygiene が曖昧になったことが #626 の問題意識になっています。GitHub の closing keyword は PR description や commit message が default branch に入ることで issue を閉じる公式機能なので、これは単なる好みではなく配布物の実運用に効く hygiene です。([GitHub]6)

    #628 でも同じく、auto-fixable な metadata / marker / snapshot freshness が auto_fixes.skipped や follow_up_issue_requests に落ちる設計だと失敗します。impl_ready の前提として、required auto action は全て適用済みでなければなりません。

    auto_fixes:
      - kind: phase_label
        executor: implementation-worker
        result: auto_fixed
        evidence:
          before: ...
          after: ...
          comment_url: ...

    result: skipped や evidence 欠落があるなら impl_ready 禁止です。

    #628 に入れるべき修正文

    Issue本文に次を追加するのが妥当です。

    Non-negotiable terminal invariant:
    
    `LOOP_HANDOFF_RESULT_V1.status: impl_ready` MUST NOT be emitted unless all of the following are true:
    
    - latest valid `CONTRACT_REVIEW_RESULT_V1.status` is `go`
    - the `go` snapshot is fresh for the current issue body hash
    - no later valid `request_changes` / blocked contract-review result invalidates the snapshot
    - title prefix and required phase labels are present, or deterministic auto-fix evidence is attached
    - required template metadata is present, or deterministic auto-fix evidence is attached
    - marker format is schema-valid
    - `auto_fixes.required` and `auto_fixes.skipped` are empty after repair
    - `blockers` is empty
    - `routing_action` is `run_impl_review_loop`
    
    If any condition fails, status MUST be `human_judgment_required` or `blocked`, never `impl_ready`.

    さらに、contract_review.status には missing/stale/request_changes を混ぜず、別フィールドにしてください。

    contract_review:
      status: go | blocked
      gate_result: fresh_go | missing_go | stale_go | invalidated_by_request_changes | blocked

    実装・配布物観点の品質バー

    Claude Code の subagent は frontmatter で tools、disallowedTools、model、permissionMode、maxTurns などを定義できますが、skills 側の allowed-tools は事前承認であって利用可能ツールの完全制限ではありません。したがって #628 が fixer 実行まで扱うなら、prose ではなく agent frontmatter、settings/hooks、narrow matcher、deny rule で実際に制限する必要があります。hooks の deny は bypass permissions 下でもブロックでき、逆に allow は deny rule を迂回できないため、安全境界は hooks/settings に寄せるべきです。([Claude API Docs]7)

    最終結論

    #628 は 「契約SSOTを追加するIssue」としてなら有用ですが、現在の書き方では #626 の child-2 として過大な成果を主張しています。修正方針は明確です。

    • impl_ready を厳密な terminal invariant にする。
    • contract_review.status と gate reason を分離する。
    • deterministic fixer を Out of Scope にするなら、実装: issue-refinement-loop の terminal contract を LOOP_HANDOFF_RESULT_V1.status: impl_ready に固定する #628 のゴールも schema/routing tests までに縮小する。
    • fixer まで含めるなら、既存 implementation-worker 経由の repair request / result / revalidation を実装範囲に入れる。
    • rg ではなく stale/missing/request_changes/metadata/fixer unavailable の negative tests を入れる。

    この修正なしでPR化すると、#564 で作った fail-only gate を marker 名だけで空洞化する可能性が高いです。

  4. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    人間からのコメントです。
    intake gate
    deterministic fixer SubAgent
    prose
    enum (schema の文脈で人間向け文章では分かりやすい日本語に置き換えてほしい)
    mutation
    handoff
    hygiene failure
    stale
    auto-fixable
    snapshot freshness
    上記、認知負荷が高い言葉の用語を追加し、textlintで出力では日本語に置換する追加Issueを起票してほしい。

  5. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    #628 (comment)

    直接の GitHub 起票権限はないため、gh issue create 用の起票文を作成しました。
    根拠: #628 は intake gate / deterministic fixer SubAgent / handoff contract / hygiene / auto-fixable / stale / contract snapshot を人間向け説明文に含んでおり、今回の用語追加対象と一致します。([GitHub]1) 既存の .textlintrc は prh に .textlint/prh.yml を接続済みで、lint:prose は docs / README / .claude/**/*.md などを対象にしています。([GitHub]2) また #599 でも「用語登録・日本語置換登録」は別 Issue と明記されています。([GitHub]3)

    gh issue create \
      --repo squne121/loop-protocol \
      --title "実装: AI運用用語の日本語置換辞書を textlint prh に追加する" \
      --label "enhancement" \
      --label "phase/implementation" \
      --body-file /tmp/issue-ai-ops-terms-prh.md

    /tmp/issue-ai-ops-terms-prh.md:

    ## Machine-Readable Contract
    
    ```yaml
    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: "#628"
    goal_ref: "AI運用・スキル間連携の人間向け文章に出る高認知負荷語を textlint prh で日本語置換できるようにし、Issue / PR / docs の説明負荷を下げる"
    change_kind: docs

    Parent Issue

    Refs #628

    Parent Goal Ref

    • Goal: issue-refinement-loop / impl-review-loop 周辺の人間向け説明文に出る高認知負荷語を、用語辞書と textlint prh で日本語へ寄せる
    • Desired Destination: Issue / PR / docs / .claude/**/*.md の人間向け文章で、高認知負荷な英語運用語が textlint により日本語表現へ誘導される。schema / script / machine-readable token / YAML key / JSON key は置換対象外として保持される。

    Background

    #628 の文脈では、intake gate / deterministic fixer SubAgent / prose / enum / mutation / handoff / hygiene failure / stale / auto-fixable / snapshot freshness などが人間向け説明文に出現している。

    これらは AI 運用・契約・schema 周辺では意味があるが、人間が Issue / PR / docs を読む際の認知負荷が高い。既存の .textlint/prh.yml には trivially-pass や baseline fail/pass などの VC 周辺標準用語の置換ルールが存在するため、同じ方式で人間向け文章の表記を日本語へ誘導する。

    Outcome

    .textlint/prh.yml に AI 運用用語の日本語置換ルールが追加され、pnpm run lint:prose 実行時に対象語が日本語表現へ置換提案される状態。

    In Scope

    • .textlint/prh.yml に以下の置換ルールを追加する

      • intake gate -> 受け入れ判定

      • deterministic fixer SubAgent -> 決定的修正サブエージェント

      • prose -> 人間向け文章

      • enum -> 許容値

        • ただし schema / JSON Schema / YAML / code / inline code / fenced code block 内の enum は置換対象外
        • 人間向け文章で schema の enum を説明している場合のみ、日本語として 許容値 を使う
      • mutation -> 本文更新

      • handoff -> 引き渡し

      • hygiene failure -> 整備不備

      • stale -> 古い状態

      • auto-fixable -> 自動修正可能

      • snapshot freshness -> スナップショット鮮度

    • 既存の trivially-pass / baseline fail / baseline pass ルールと同じ粒度で specs を追加し、prh rule load 時に置換例が検証されるようにする

    • 人間向け文章だけを対象にするため、machine-readable token は置換対象外であることをコメントで明記する

    • 必要なら .textlint/prh.yml 内に AI ops terminology のセクションを追加する

    Out of Scope

    Acceptance Criteria

    • AC1: .textlint/prh.yml に AI ops terminology 相当のセクションが追加される

    • AC2: 以下の入力が textlint prh により期待する日本語へ置換提案される

      • intake gate -> 受け入れ判定
      • deterministic fixer SubAgent -> 決定的修正サブエージェント
      • prose -> 人間向け文章
      • enum -> 許容値
      • mutation -> 本文更新
      • handoff -> 引き渡し
      • hygiene failure -> 整備不備
      • stale -> 古い状態
      • auto-fixable -> 自動修正可能
      • snapshot freshness -> スナップショット鮮度
    • AC3: enum は人間向け文章での置換対象として扱い、schema / code / YAML / JSON の literal token は置換対象外であることが .textlint/prh.yml のコメントまたは specs で明示される

    • AC4: 追加ルールには specs が含まれ、少なくとも代表的な from/to が prh load 時に検証される

    • AC5: pnpm run lint:prose が PASS する

    • AC6: 実装: issue-refinement-loop の terminal contract を LOOP_HANDOFF_RESULT_V1.status: impl_ready に固定する #628 の用語群を含む短い fixture または一時ファイルに対して、textlint --fix 相当で期待する日本語置換が確認できる

    • AC7: inline code / fenced code block / machine-readable token を不用意に置換しないことを確認する

    Verification Commands

    # AC1 / AC2
    rg -n "AI ops terminology|受け入れ判定|決定的修正サブエージェント|人間向け文章|許容値|本文更新|引き渡し|整備不備|古い状態|自動修正可能|スナップショット鮮度" .textlint/prh.yml
    
    # AC4
    rg -n "from: intake gate|from: deterministic fixer SubAgent|from: prose|from: enum|from: mutation|from: handoff|from: hygiene failure|from: stale|from: auto-fixable|from: snapshot freshness" .textlint/prh.yml
    
    # AC5
    pnpm run lint:prose
    
    # AC6 / AC7
    cat > /tmp/ai-ops-terms.md <<'EOF'
    intake gate
    deterministic fixer SubAgent
    prose
    enum
    mutation
    handoff
    hygiene failure
    stale
    auto-fixable
    snapshot freshness
    
    `enum`
    
    ```json
    {
      "enum": ["impl_ready", "blocked"]
    }

    EOF

    pnpm exec textlint --config .textlintrc /tmp/ai-ops-terms.md
    pnpm exec textlint --config .textlintrc --fix /tmp/ai-ops-terms.md
    cat /tmp/ai-ops-terms.md

    
    ## Allowed Paths
    
    - `.textlint/prh.yml`
    - `.textlintrc` only if a minimal option adjustment is required to avoid unsafe code-block replacement
    - `package.json` only if a narrow verification script is required
    
    ## Stop Conditions
    
    - schema / code / script token の rename が必要になる場合
    - `.textlint/prh.yml` だけでは inline code / fenced code block の誤置換を安全に防げない場合
    - `prh.yml` 分割や imports 導入が必要になる場合
    - #628 の contract 内容そのものの再設計が必要になる場合
    - Allowed Paths 外の変更が必要になる場合
    
    ## Runtime Verification Applicability
    
    ```yaml
    applicability: not_applicable
    decision: not_applicable
    reason: "本 Issue は textlint prh の用語置換辞書追加であり、アプリケーション runtime 挙動には影響しない。検証は lint:prose と textlint fixture で完結する。"
    

    Delivery Rule

    
    補足: `textlint-rule-prh` は `rulePaths` で `prh.yml` を読み込み、`--fix` に対応しています。:contentReference[oaicite:3]{index=3} ただし `enum` のような schema literal は誤置換リスクが高いので、この Issue では「人間向け文章だけ対象、機械可読トークンは保持」を AC と Stop Conditions に入れるのが重要です。
    ::contentReference[oaicite:4]{index=4}
    

    直接の GitHub 起票権限はないため、gh issue create 用の起票文を作成しました。
    根拠: #628 は intake gate / deterministic fixer SubAgent / handoff contract / hygiene / auto-fixable / stale / contract snapshot を人間向け説明文に含んでおり、今回の用語追加対象と一致します。([GitHub]1) 既存の .textlintrc は prh に .textlint/prh.yml を接続済みで、lint:prose は docs / README / .claude/**/*.md などを対象にしています。([GitHub]2) また #599 でも「用語登録・日本語置換登録」は別 Issue と明記されています。([GitHub]3)

    gh issue create \
      --repo squne121/loop-protocol \
      --title "実装: AI運用用語の日本語置換辞書を textlint prh に追加する" \
      --label "enhancement" \
      --label "phase/implementation" \
      --body-file /tmp/issue-ai-ops-terms-prh.md

    /tmp/issue-ai-ops-terms-prh.md:

    ## Machine-Readable Contract
    
    ```yaml
    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: "#628"
    goal_ref: "AI運用・スキル間連携の人間向け文章に出る高認知負荷語を textlint prh で日本語置換できるようにし、Issue / PR / docs の説明負荷を下げる"
    change_kind: docs

    Parent Issue

    Refs #628

    Parent Goal Ref

    • Goal: issue-refinement-loop / impl-review-loop 周辺の人間向け説明文に出る高認知負荷語を、用語辞書と textlint prh で日本語へ寄せる
    • Desired Destination: Issue / PR / docs / .claude/**/*.md の人間向け文章で、高認知負荷な英語運用語が textlint により日本語表現へ誘導される。schema / script / machine-readable token / YAML key / JSON key は置換対象外として保持される。

    Background

    #628 の文脈では、intake gate / deterministic fixer SubAgent / prose / enum / mutation / handoff / hygiene failure / stale / auto-fixable / snapshot freshness などが人間向け説明文に出現している。

    これらは AI 運用・契約・schema 周辺では意味があるが、人間が Issue / PR / docs を読む際の認知負荷が高い。既存の .textlint/prh.yml には trivially-pass や baseline fail/pass などの VC 周辺標準用語の置換ルールが存在するため、同じ方式で人間向け文章の表記を日本語へ誘導する。

    Outcome

    .textlint/prh.yml に AI 運用用語の日本語置換ルールが追加され、pnpm run lint:prose 実行時に対象語が日本語表現へ置換提案される状態。

    In Scope

    • .textlint/prh.yml に以下の置換ルールを追加する

      • intake gate -> 受け入れ判定

      • deterministic fixer SubAgent -> 決定的修正サブエージェント

      • prose -> 人間向け文章

      • enum -> 許容値

        • ただし schema / JSON Schema / YAML / code / inline code / fenced code block 内の enum は置換対象外
        • 人間向け文章で schema の enum を説明している場合のみ、日本語として 許容値 を使う
      • mutation -> 本文更新

      • handoff -> 引き渡し

      • hygiene failure -> 整備不備

      • stale -> 古い状態

      • auto-fixable -> 自動修正可能

      • snapshot freshness -> スナップショット鮮度

    • 既存の trivially-pass / baseline fail / baseline pass ルールと同じ粒度で specs を追加し、prh rule load 時に置換例が検証されるようにする

    • 人間向け文章だけを対象にするため、machine-readable token は置換対象外であることをコメントで明記する

    • 必要なら .textlint/prh.yml 内に AI ops terminology のセクションを追加する

    Out of Scope

    Acceptance Criteria

    • AC1: .textlint/prh.yml に AI ops terminology 相当のセクションが追加される

    • AC2: 以下の入力が textlint prh により期待する日本語へ置換提案される

      • intake gate -> 受け入れ判定
      • deterministic fixer SubAgent -> 決定的修正サブエージェント
      • prose -> 人間向け文章
      • enum -> 許容値
      • mutation -> 本文更新
      • handoff -> 引き渡し
      • hygiene failure -> 整備不備
      • stale -> 古い状態
      • auto-fixable -> 自動修正可能
      • snapshot freshness -> スナップショット鮮度
    • AC3: enum は人間向け文章での置換対象として扱い、schema / code / YAML / JSON の literal token は置換対象外であることが .textlint/prh.yml のコメントまたは specs で明示される

    • AC4: 追加ルールには specs が含まれ、少なくとも代表的な from/to が prh load 時に検証される

    • AC5: pnpm run lint:prose が PASS する

    • AC6: 実装: issue-refinement-loop の terminal contract を LOOP_HANDOFF_RESULT_V1.status: impl_ready に固定する #628 の用語群を含む短い fixture または一時ファイルに対して、textlint --fix 相当で期待する日本語置換が確認できる

    • AC7: inline code / fenced code block / machine-readable token を不用意に置換しないことを確認する

    Verification Commands

    # AC1 / AC2
    rg -n "AI ops terminology|受け入れ判定|決定的修正サブエージェント|人間向け文章|許容値|本文更新|引き渡し|整備不備|古い状態|自動修正可能|スナップショット鮮度" .textlint/prh.yml
    
    # AC4
    rg -n "from: intake gate|from: deterministic fixer SubAgent|from: prose|from: enum|from: mutation|from: handoff|from: hygiene failure|from: stale|from: auto-fixable|from: snapshot freshness" .textlint/prh.yml
    
    # AC5
    pnpm run lint:prose
    
    # AC6 / AC7
    cat > /tmp/ai-ops-terms.md <<'EOF'
    intake gate
    deterministic fixer SubAgent
    prose
    enum
    mutation
    handoff
    hygiene failure
    stale
    auto-fixable
    snapshot freshness
    
    `enum`
    
    ```json
    {
      "enum": ["impl_ready", "blocked"]
    }

    EOF

    pnpm exec textlint --config .textlintrc /tmp/ai-ops-terms.md
    pnpm exec textlint --config .textlintrc --fix /tmp/ai-ops-terms.md
    cat /tmp/ai-ops-terms.md

    
    ## Allowed Paths
    
    - `.textlint/prh.yml`
    - `.textlintrc` only if a minimal option adjustment is required to avoid unsafe code-block replacement
    - `package.json` only if a narrow verification script is required
    
    ## Stop Conditions
    
    - schema / code / script token の rename が必要になる場合
    - `.textlint/prh.yml` だけでは inline code / fenced code block の誤置換を安全に防げない場合
    - `prh.yml` 分割や imports 導入が必要になる場合
    - #628 の contract 内容そのものの再設計が必要になる場合
    - Allowed Paths 外の変更が必要になる場合
    
    ## Runtime Verification Applicability
    
    ```yaml
    applicability: not_applicable
    decision: not_applicable
    reason: "本 Issue は textlint prh の用語置換辞書追加であり、アプリケーション runtime 挙動には影響しない。検証は lint:prose と textlint fixture で完結する。"
    

    Delivery Rule

    
    補足: `textlint-rule-prh` は `rulePaths` で `prh.yml` を読み込み、`--fix` に対応しています。:contentReference[oaicite:3]{index=3} ただし `enum` のような schema literal は誤置換リスクが高いので、この Issue では「人間向け文章だけ対象、機械可読トークンは保持」を AC と Stop Conditions に入れるのが重要です。
    ::contentReference[oaicite:4]{index=4}
    
  6. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-06-03T10:22:44Z)

    Issue: #628 — 実装: issue-refinement-loop の terminal contract を LOOP_HANDOFF_RESULT_V1.status: impl_ready に固定する

    • Outcome: issue-refinement-loop が成功終了時に LOOP_HANDOFF_RESULT_V1.status: impl_ready を HTML comment + fenced YAML marker として出力する contract が termination-policy.md に SSOT 化され、LOOP_HANDOFF_RESULT_V1 JSON schema が追加されて pytest で validate されている状態。
    • Acceptance Criteria:
      • AC1: termination-policy.md に LOOP_HANDOFF_RESULT_V1 marker の status: impl_ready 経路が定義されている
      • AC2: impl_ready の定義が termination-policy.md に SSOT として記載されている
      • AC3: schemas/loop_handoff_result_v1.json が存在し status enum に impl_ready | human_judgment_required | blocked を含む
      • AC4: scope/goal/AC 変更時に human_judgment_required / routing_action: ask_human で停止する routing が記載されている
      • AC5: 5種 hygiene の fixer 委譲 contract(routing 定義のみ)が定義されている
      • AC6: LOOP_HANDOFF_RESULT_V1 marker が <!-- LOOP_HANDOFF_RESULT_V1 --> + fenced YAML 形式で規定されている
      • AC7: pytest テストが 8 routing パターンで PASS する
    • Verification Commands: 7コマンド(全て expected baseline fail → go)
    • Allowed Paths:
      • .claude/skills/issue-refinement-loop/SKILL.md
      • .claude/skills/issue-refinement-loop/references/termination-policy.md
      • .claude/skills/issue-refinement-loop/schemas/loop_handoff_result_v1.json
      • .claude/skills/issue-refinement-loop/tests/test_loop_handoff_result.py
    • Worktree: .claude/worktrees/issue-628-terminal-contract-loop-handoff
    • Branch: worktree-issue-628-terminal-contract-loop-handoff
    • VC preflight: baseline fail = 7, 想定外 pass = 0, 実行不可 = 0
    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-03T10:22:44Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/628
      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: 7
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 0
          vc_skipped: 0
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings: []
  7. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    implement-issue 完了

    IMPLEMENT_RESULT_V1:
      status: ok
      generated_at: "2026-06-03T10:35:00Z"
      generated_by: implement-issue
      issue_url: https://github.com/squne121/loop-protocol/issues/628
      pr_url: https://github.com/squne121/loop-protocol/pull/635
      worktree: .claude/worktrees/issue-628-terminal-contract-loop-handoff
      branch: worktree-issue-628-terminal-contract-loop-handoff
      verification:
        typecheck: pass
        lint: pass
        test:
          passed: 339
          failed: 0
          files: 17
        build: pass
      allowed_paths_compliance: true
      warnings: []
      errors: []

    変更ファイル(すべて Allowed Paths 内):

    • .claude/skills/issue-refinement-loop/SKILL.md — Step 5 に LOOP_HANDOFF_RESULT_V1 marker 出力を追記
    • .claude/skills/issue-refinement-loop/references/termination-policy.md — LOOP_HANDOFF_RESULT_V1 SSOT セクションを追加
    • .claude/skills/issue-refinement-loop/schemas/loop_handoff_result_v1.json — 新規作成(JSON Schema)
    • .claude/skills/issue-refinement-loop/tests/test_loop_handoff_result.py — 新規作成(8 パターン pytest)

    AC7 テスト結果: uv run pytest test_loop_handoff_result.py -v 8/8 PASS

  8. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    impl-review-loop 完了報告

    結果: APPROVE(iteration 2 で承認)

    PR: #635

    ループ履歴

    iteration ステップ 結果
    0 Implementation OK(worktree 作成・実装・PR 起票)
    0 Verification PASS(AC1〜AC7 全合格、pnpm 全合格)
    0 PR Review REQUEST_CHANGES(PR body セクション不足)
    1 PR body 修正 Schema Change Applicability / Safety Claim Matrix 追加
    1 PR Review REQUEST_CHANGES(PR Body Japanese Check 失敗)
    2 PR body 修正 Closes/Refs 行を日本語セクションに統合
    2 PR Review APPROVE

    実装内容

    • termination-policy.md: LOOP_HANDOFF_RESULT_V1 schema(status: impl_ready | human_judgment_required | blocked)、5 種 hygiene 委譲 contract、routing ルールを SSOT 追加
    • schemas/loop_handoff_result_v1.json: JSON Schema ファイル追加(contract_review.status/gate_result 分離設計)
    • SKILL.md: Step 5 を更新し approved 終了時の LOOP_HANDOFF_RESULT_V1 marker 出力を必須化
    • tests/test_loop_handoff_result.py: 8 routing パターンの pytest テスト追加(全合格)
    IMPL_REVIEW_LOOP_RESULT_V1:
      status: approved
      issue_number: 628
      pr_url: https://github.com/squne121/loop-protocol/pull/635
      iterations_used: 2
      termination_reason: approved
  9. added a commit that references this issue on Jun 3, 2026
  10. squne121 commented on Jun 3, 2026

    @squne121
    OwnerAuthor

    修正完了: 6 件のブロッカーを解消

    PR #635 (commit 19ccbf9) で全 6 件のブロッカーを対応済み。

    B1 — スキーマルートのラッパー形式修正

    スキーマルートを LOOP_HANDOFF_RESULT_V1 キー配下にラップ(additionalProperties: false)し、実際のマーカー形状と一致させた。

    B2 — impl_ready 不変条件を allOf if/then で強制

    status: impl_ready は以下をすべて要求するよう変更: routing_action: run_impl_review_loop、contract_review.gate_result: fresh_go、contract_review.status: go、blockers: maxItems 0、permissions.unavailable: maxItems 0、auto_fixes.skipped: maxItems 0。

    B3 — 否定テストの追加

    _base_impl_ready() をラッパー形式に更新。7 件の否定テストを追加し、無効な impl_ready ペイロードが jsonschema.ValidationError を発生させることを検証: missing_go / stale_go / invalidated_by_request_changes / non-empty blockers / non-empty auto_fixes.skipped / ask_human routing / non-empty permissions.unavailable。

    全 15 テスト通過(既存 8 件 + 新規否定テスト 7 件)。

    B4 — auto_fixes に集約 result フィールドを追加

    auto_fixes に result フィールド(enum: ["auto_fixed", "human_judgment_required", "blocked"])を追加。termination-policy.md のスキーマ記述も更新済み。

    B5 — executor の enum 制約追加・新規 SubAgent 型の廃止

    executor フィールドを enum: ["implementation-worker"] に制約。termination-policy.md の "deterministic fixer SubAgent" 参照を全て "implementation-worker (repair mode)" に変更。

    B6 — ネストされたフェンス付きコードブロックの修正

    termination-policy.md の外側フェンスを 4 バッククォートに変更。SKILL.md の "2 行セット" を "HTML comment と fenced YAML block の 2 要素" に修正。

    検証結果

    • pnpm typecheck: pass
    • pnpm lint: pass
    • pnpm test: 339 passed (17 files)
    • pnpm build: pass
    • uv run pytest test_loop_handoff_result.py: 15 passed
  11. added a commit that references this issue on Jun 3, 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

    enhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions