Skip to content

実装: impl-review-loop の terminal/human-escalation で GitHub human-history を必須化し Project memory-only handoff を防ぐ #2880

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "impl-review-loop が Step 2 gate 閉鎖・max_iterations・human_escalation 等で停止するとき、既存 Human-history v1 で GitHub の source Issue/PR に durable な人間向け履歴を残してから user-facing final を返し、Claude Code Project memory だけに停止状態を残す memory-only handoff を防ぐ"
change_kind: code
dedupe_key: "impl-review-loop:terminal-human-history-required:memory-only-handoff-prevention:v1"

Parent Issue

none

Parent Goal Ref

Current Validated Scope

  • .claude/skills/impl-review-loop/steps/step-5-feedback-and-termination.md、step-2-verification.md、context-protocol-and-guardrails.md の手順書。
  • .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py の _validate_human_history_identity matrix と _HUMAN_HISTORY_REASONS の最小拡張。
  • .claude/skills/impl-review-loop/tests/ 配下の既存 human-history test 追従と新規 test 1 件。
  • 新しい publisher / schema / wrapper / gate は作らない。

Remaining Parent Gaps

なし

Background

PR #2876(Issue #2872)の impl-review-loop で AC9(runtime verification)が UNAVAILABLE のまま Step 2 の current-head gate を通過できず、Step 4 pr-reviewer を起動せずに人間へ判断を返して終了した。このとき停止状態を Claude Code の Project memory にだけ書き、GitHub の source Issue/PR に durable な人間向け履歴を残さないまま user-facing completion を返した。OWNER は #2876 (comment) で「プロジェクトメモリに保存されても困ります。GitHubにコメントとして残してほしい」「再発防止策を検討してIssueを起票してほしい」と明示要求している。関連 OWNER review: #2876 (comment) 。

既存の Human-history v1 と publish_termination_report.py::publish_human_history()(既存 issue_comment.publish controlled lane)はあったが、現行コードには次の gap がある(起票時点の HEAD で確認)。

  • step-5-feedback-and-termination.md の Human-history matrix は pre-PR-binding / binding-validation / post-PR-binding / post-PR-head-drift / conflict-resolution の 5 origin のみ。Step 2 gate が閉じて Step 4/5 に到達しない停止(VC_ADJUDICATION_RESULT_V1.blocking == true、AC/runtime blocker、UNAVAILABLE)、max_iterations 到達、human_escalation に対応する phase が無い。
  • 同ファイルの「終了処理(max_iterations)」「終了処理(human_escalation)」は raw gh issue comment の本文テンプレートで、Human-history v1 の identity / idempotent create-PATCH-noop / readback を使っていない。
  • step-2-verification.md 表の blocking == true 行は「Step 5 へ。rerun / REQUEST_CHANGES / human escalation を判定」とだけ書き、GitHub history の記録を要求しない。
  • Project memory を canonical workflow history / handoff / completion evidence として使ってはならないという規約が impl-review-loop の docs に存在しない。
  • 実装本体は .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py(_validate_human_history_identity、publish_human_history、--human-history-request-file)。

先行実装 #1908 は完了済みで再実装しない。本 Issue はその matrix を停止系の経路へ最小拡張する。

Outcome

impl-review-loop の terminal / human-escalation 停止経路(Step 2 gate 閉鎖による停止、max_iterations、human_escalation)が、既存 Human-history v1 で GitHub history(create / PATCH / noop + readback)を完了してから user-facing final を返す状態にする。成果物は、拡張された publish_termination_report.py の matrix、更新された impl-review-loop 手順書 3 本、Project memory が canonical history の代替でないことを固定する regression test であり、完了条件は下記 AC の VC がすべて pass することである。

Runtime Verification Applicability

decision: not_applicable
reason: >-
  matrix 検証ロジックの拡張・手順書・unit test の変更のみで、静的検証(pytest)で完結する。実 GitHub への投稿は fake publisher / 既存 controlled lane の test double で検証し、live 投稿は本 Issue の AC に含めない。

In Scope

  • publish_termination_report.py: _validate_human_history_identity の matrix と _HUMAN_HISTORY_REASONS に、impl-review-loop の停止系 phase terminal-stop(target は bound PR があれば pull_request、無ければ source Issue)と reason step2_gate_blocked / max_iterations / human_escalation を最小追加する。既存 5 origin の挙動と identity key set は変更しない。
  • step-5-feedback-and-termination.md: Human-history matrix に上記停止経路を追記し、「終了処理(max_iterations)」「終了処理(human_escalation)」の raw gh issue comment テンプレートを Human-history v1 publish(identity / create-PATCH-noop / readback)へ置換する。
  • step-2-verification.md: blocking == true 行で、Step 5 へ進む前または停止時に GitHub history publication を必須とする旨を追記する。
  • context-protocol-and-guardrails.md: 「Project memory は canonical durable workflow history / handoff / completion evidence ではない。terminal 停止では GitHub history publication の readback 完了前に user-facing final を返さない」「publication 失敗は terminal report に含め、memory write を成功扱いにしない」を明記する。
  • publication は raw transcript / credential / local absolute path を含めず、source Issue/PR binding を維持する。
  • test: 既存 test_human_history_identity.py / test_human_history_phase_routing.py の追従と、新規 .claude/skills/impl-review-loop/tests/test_terminal_human_history_required.py。.github/ci/python-test-plan.json の targets には .claude/skills/impl-review-loop/tests/ が既に登録されているため、同ディレクトリ配下の新規 test は追加登録なしで収集される(実装時に python-test-plan.json の整合を確認し、別ディレクトリへ置く場合のみ targets 登録が必要)。

Out of Scope

Acceptance Criteria

  • AC1: _validate_human_history_identity が ("impl-review-loop", "terminal-stop", "issue" | "pull_request") と reason step2_gate_blocked / max_iterations / human_escalation を受理し、未知 reason・不正 target 組合せ・既存 5 origin の旧組合せ違反は従来どおり拒否する。
  • AC2: terminal-stop の identity / render / publish が、既存 publish_human_history() 経由で create / PATCH / noop の各 decision と readback を行い、同一 identity の再投稿が noop になる(idempotent)。
  • AC3: step-5-feedback-and-termination.md の「終了処理(max_iterations)」「終了処理(human_escalation)」が raw gh issue comment ではなく Human-history v1 publish を参照し、matrix に Step 2 gate 閉鎖停止が追記されている。
  • AC4: step-2-verification.md の blocking == true 行が GitHub history publication を要求する。
  • AC5: context-protocol-and-guardrails.md が「Project memory は canonical durable workflow history / handoff / completion evidence ではない」と publication 失敗時の扱い(terminal report に含め、memory write を成功扱いにしない)を明記する。
  • AC6: regression test が、terminal 停止で GitHub history publication の readback 成功なしに user-facing final を許す手順(memory-only success / handoff)を拒否することを固定する。
  • AC7: publication 失敗(publisher エラー / readback 不一致)が terminal report の失敗として扱われ、成功扱いにならないことを test で固定する。
  • AC8: 投稿本文に raw transcript / credential / local absolute path が混入せず、source Issue/PR binding が維持されることを test で固定する(既存の public-safe 検証の再利用)。
  • AC9: 既存 human-history test(identity / phase routing / conflict taxonomy)が引き続き pass する。

Verification Commands

# AC1
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_terminal_human_history_required.py::test_terminal_stop_matrix_accepts_known_reasons_and_rejects_unknown -q

# AC2
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_terminal_human_history_required.py::test_terminal_stop_publish_is_idempotent_create_patch_noop_with_readback -q

# AC3
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_terminal_human_history_required.py::test_step5_termination_procedures_use_human_history_not_raw_gh_comment -q

# AC4
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_terminal_human_history_required.py::test_step2_blocking_row_requires_github_history_publication -q

# AC5
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_terminal_human_history_required.py::test_guardrails_declare_project_memory_not_canonical_history -q

# AC6
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_terminal_human_history_required.py::test_memory_only_handoff_is_rejected -q

# AC7
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_terminal_human_history_required.py::test_publication_failure_is_terminal_failure_not_success -q

# AC8
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_terminal_human_history_required.py::test_terminal_history_is_public_safe_and_source_bound -q

# AC9
# baseline-expect: pass
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_human_history_identity.py .claude/skills/impl-review-loop/tests/test_human_history_phase_routing.py .claude/skills/impl-review-loop/tests/test_human_history_conflict_taxonomy.py -q

標準品質ゲート(pnpm typecheck / pnpm lint / pnpm test / pnpm build、uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py)は PR 前に別途実行する。

Allowed Paths

  • .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py
  • .claude/skills/impl-review-loop/steps/step-5-feedback-and-termination.md
  • .claude/skills/impl-review-loop/steps/step-2-verification.md
  • .claude/skills/impl-review-loop/steps/context-protocol-and-guardrails.md
  • .claude/skills/impl-review-loop/tests/test_terminal_human_history_required.py
  • .claude/skills/impl-review-loop/tests/test_human_history_identity.py
  • .claude/skills/impl-review-loop/tests/test_human_history_phase_routing.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • 新しい publisher / schema / wrapper / gate の追加が不可避と判明した場合
  • Human-history v1 の identity key set / marker 形式の変更が必要になった場合

Required Skills

なし

Required Design References

Delivery Rule

  • 1 Issue = 1 PR。専用 worktree で作業し、Draft PR を既定とする。

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Oct 2, 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