Skip to content

feat: trusted human contract feedback を controlled editor handoff に接続する - #2623

Merged
squne121 merged 4 commits into
mainfrom
worktree-issue-2620-trusted-human-editor-handoff
Sep 10, 2026
Merged

squne121 merged 4 commits into
mainfrom
worktree-issue-2620-trusted-human-editor-handoff

Conversation

@squne121

@squne121 squne121 commented Sep 10, 2026 •

Copy link
Copy Markdown
Owner

Closes #2620 — trusted human contract feedback を controlled editor handoff へ接続する Issue を解消する。

Summary

preflight.run.with_human_context / contract_update.run.with_human_context の既存 human-context lane に、safe section-bound patch representation が存在しない explicit trusted human_review_directive を検出した場合の新しい eligibility を追加した。構造化 ANCHOR_SCOPE_REFRAME_V1 の scope reframe に該当せず、かつ derived CONTRACT_PATCH_PLAN_V1.operations[] が空の場合でも、preflight / contract_update 自身が controlled transaction を実行せず、writes=0 のまま既存 NEXT_ACTION: issue_editor_required へ route する。

routing の SSOT は decide_rewrite_route.py の新関数 decide_human_review_directive_editor_route() に一本化し、run_refinement_preflight.py の consume_trusted_anchor_contract_patch_plan() はその判定結果だけを consume する ad-hoc な独自分岐を追加しない。eligibility は既存 predicate(authority_category == human_review_directive、explicit directive confidence、with_human_context lane、既存 trusted principal の trust 範囲、anchor/target binding valid)の組み合わせのみで決まり、新しい classifier/heuristic は導入していない。

PR review fix (このコミット、authoritative human review: #2623 (comment) への対応) で以下4件を修正した:

  1. _decide_human_review_directive_editor_route() 内の classify_scope_delta_authority() 呼び出しへ known_context["investigation_derived_path_literals"] を転送していなかった P1 blocker を修正(実装: operator-selected human context の scope reframe を自動継続し scope expansion stop を撤去する #2086 の architecture/workflow scope-expansion directive の boundary clear が、この route では production 経路で never fire だった)。
  2. _decide_human_review_directive_editor_route() が issue_editor_required を返す直前に、既存 fetch_current() primitive を使った genuine fresh readback を追加し、evidence 構築時点から handoff 判定までの TOCTOU window を閉じた(構造化 scope-reframe lane の run_trusted_anchor_iteration_zero() が既に持つ保護と同じ形)。
  3. ImportError・classifier 例外・fresh readback transport failure という integrity/environment failure を、genuine ineligibility(None、既存 fallback へフォールスルー)と区別し、既存の status: "invalid" / disposition: {...} 語彙(_decision_kind == "invalid" 分岐と同一形状)を reason_code だけ変えて再利用する形で fail-closed にした。新しい schema/key-set は追加していない。
  4. reviewer_feedback_url の実際の伝搬範囲を調査した結果、_bounded_contract_update_handoff() の canonical contract_update projection には含まれず、root/main thread は自身が contract_update.run.with_human_context 呼び出し時に渡した anchor URL(--anchor-comment-url / --human-context-comment-url)を Step 4 issue-editor への reviewer_feedback_url として再利用していることを確認した。schema 変更は不要と判断し、SKILL.md / references/loop-state.md の記述を実装の実態に一致するよう修正した(doc-only fix、詳細は Notes 参照)。

さらに SKILL.md の contract_update.status 記述が実装済みの5値目(handoff_required)を反映していなかった P2 も修正した。

受け入れ条件の達成状況

  • AC1: safe section-bound patch representation が存在しない explicit trusted human_review_directive(authority_category == human_review_directive かつ explicit directive かつ with_human_context かつ trusted principal かつ same-target/provenance/anchor binding valid)を検出した場合、preflight.run.with_human_context / contract_update.run.with_human_context は controlled transaction を自ら実行せず、writes=0 のまま既存 NEXT_ACTION: issue_editor_required を返す。route input には同一 target issue と canonical reviewer_feedback_url が含まれる。根拠: decide_rewrite_route.py の decide_human_review_directive_editor_route() と run_refinement_preflight.py の _decide_human_review_directive_editor_route()。test_preflight_run_with_anchor.py::test_ac1_ac6_explicit_human_review_directive_reaches_next_action_production_reachable が production-reachable path 経由で contract_update.writes == 0 / apply_transaction 呼び出し0回を検証(PASS)。
  • AC2: 既存の section-bound patch representation を安全に生成できない valid な explicit trusted human directive でも、新しい patch plan を捏造せず AC1 の issue_editor_required に到達する。根拠: test_decide_rewrite_route_human_review_directive.py(29/29 PASS)が operations: [] のまま handoff することを検証。
  • AC3: untrusted human context、invalid anchor、target issue/anchor URL/body の mismatch、provenance 不一致は fail-closed のまま writes=0 であり issue_editor_required route を選ばない。根拠: test_ac3_untrusted_author_association_never_escalates_production_reachable / test_ac3_anchor_body_mismatch_never_escalates が status == "no_change" / writes == 0 を明示検証(PASS、test_preflight_run_with_anchor.py 内)。
  • AC4: 曖昧な自由文または既存 predicate の組み合わせで trusted explicit human_review_directive と判定できない入力は fail-closed のまま writes=0 であり、自動 body rewrite も issue_editor_required への到達も行わない。根拠: test_ac4_ambiguous_prose_only_directive_never_escalates_production_reachable / test_ac4_not_human_context_lane_never_escalates(PASS、同ファイル内)。
  • AC5: 既存 CONTRACT_PATCH_PLAN_V1 scope-reframe full-rewrite route および既存 section-bound / freeform exact allowed-path-delta route の validation と fail-closed behavior は regression しない。根拠: test_scope_delta_authority_e2e.py(5/5 PASS、本 PR では未変更のまま regression 確認)および test_ac5_regression_non_empty_operations_freeform_directive_stays_ordinary_patch_route(PASS)。
  • AC6(runtime-verification: true): focused deterministic tests が helper/callback 単体テストに加え、real run_preflight() の production-reachable path から result/stdout の NEXT_ACTION: issue_editor_required に到達し、preflight 自体の mutation 回数が0回であることを確認する。AC3/AC4 の negative case も fixture callback で検証し、raw GitHub mutation・新規 E2E/live GitHub harness は追加していない。根拠: test_preflight_run_with_anchor.py -k "production_reachable or issue_editor_required"(6/6 PASS)。詳細は ## Runtime Verification Evidence セクション参照。

Checks

  • uv run pytest .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py — PASS (50/50)
  • uv run pytest .claude/skills/issue-refinement-loop/tests/test_decide_rewrite_route_human_review_directive.py — PASS (29/29)
  • uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_delta_authority_e2e.py — PASS (5/5、regression、未変更)
  • uv run pytest .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py -k "production_reachable or issue_editor_required" — PASS (6/6)
  • uv run pytest .claude/skills/issue-refinement-loop/tests/(skill 全体の回帰確認) — 2089 passed, 3 failed。3 件は本 PR が未変更の test_command_registry.py における sandbox 環境固有の uv_version_mismatch(_resolve_trusted_executable の pinned uv version check)で、本 PR 変更前の HEAD (43f8f07c) でも同一の 3 件が同じ理由で失敗することを git stash で作った同一 worktree のクリーンなベースラインに対して再実行し確認済み(本変更と無関係)。
  • SKILL.md は 500 行のまま(既存段落の in-place 編集のみで新規行を追加していないため、既存の 500 行制約を維持)。
  • pnpm typecheck/lint/test/build は本 Issue の Allowed Paths(.claude/skills/issue-refinement-loop/ 配下の Python/Markdown のみ)に該当する変更がないため未実行。TS/JS 側のファイルは一切変更していない。

Allowed Paths 遵守

Issue #2620 の Allowed Paths は以下7ファイルです(gh issue view 2620 --json body の ## Allowed Paths セクション参照)。

  • .claude/skills/issue-refinement-loop/SKILL.md(契約許可パス)
  • .claude/skills/issue-refinement-loop/references/loop-state.md(契約許可パス)
  • .claude/skills/issue-refinement-loop/scripts/decide_rewrite_route.py(契約許可パス)
  • .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py(契約許可パス)
  • .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py(契約許可パス)
  • .claude/skills/issue-refinement-loop/tests/test_scope_delta_authority_e2e.py(契約許可パス)
  • .claude/skills/issue-refinement-loop/tests/test_decide_rewrite_route_human_review_directive.py(契約許可パス)

本 PR の実際の変更ファイル(gh pr diff --name-only 2623 で確認)は以下6ファイルであり、いずれも上記 Allowed Paths の部分集合です。Allowed Paths 外のファイルは変更していません。

  • .claude/skills/issue-refinement-loop/SKILL.md(許可済み変更パス)
  • .claude/skills/issue-refinement-loop/references/loop-state.md(許可済み変更パス)
  • .claude/skills/issue-refinement-loop/scripts/decide_rewrite_route.py(許可済み変更パス)
  • .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py(許可済み変更パス)
  • .claude/skills/issue-refinement-loop/tests/test_decide_rewrite_route_human_review_directive.py(許可済み変更パス)
  • .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py(許可済み変更パス)

.claude/skills/issue-refinement-loop/tests/test_scope_delta_authority_e2e.py は Allowed Paths に含まれますが、本 PR では変更不要でした(既存 regression を PASS のまま維持、## Checks 参照)。

Schema Change Applicability

  • decision: not_schema_change
  • reason: 既存の CONTRACT_PATCH_PLAN_V1 / SCOPE_DELTA_AUTHORITY_EVIDENCE_V1 等のスキーマ定義ファイル・キー集合は一切変更していない。新規 dataclass(HUMAN_REVIEW_DIRECTIVE_EDITOR_ROUTE_STATE_V1)は decide_rewrite_route.py 内部の純粋関数の入力型であり、永続化・wire format のスキーマではない。integrity/environment failure の区別(finding 3)は _decision_kind == "invalid" 分岐が既に使っている status: "invalid" / disposition: {...} 語彙を再利用しているだけであり、新しい key/value を schema へ追加していない。reviewer_feedback_url(finding 4)についても新規 schema key の追加を避け、root/main thread 側の既存手持ち値の再利用に留めた。

Schema Consumer Inventory

N/A(not_schema_change のため対象外)

Safety Claim Matrix

本 PR は .claude/skills/issue-refinement-loop/ 配下の control-plane routing ロジックを変更するため safety-sensitive パスに該当する。以下に具体的な安全性主張を示す。

Claim Implemented? Not controlled Evidence Follow-up
preflight / contract_update はこの新 route でも controlled transaction(edit_issue_txn.py / issue-editor SubAgent の直接起動)を一切実行しない(writes=0) yes - run_refinement_preflight.py の _decide_human_review_directive_editor_route() は rewrite_route を返すのみで apply_transaction 等の mutation callback を一切呼ばない。test_ac1_ac6_explicit_human_review_directive_reaches_next_action_production_reachable が実 run_preflight() 経由で contract_update.writes == 0 / apply_transaction 呼び出し回数 0 を検証 -
eligibility 判定は既存 predicate の組み合わせのみで、新しい classifier/heuristic・OWNER-only 専用ポリシーを導入していない yes - decide_human_review_directive_editor_route() は caller-supplied facts の論理積のみを評価する(decide_rewrite_route.py 内、新規正規表現・自由文解析なし)。既存の classify_scope_delta_authority() / _resolve_scope_delta_source_kind() を fresh に呼び出すだけ -
investigation_derived_path_literals は producer(_validate_investigation_evidence_transport())が既に validate 済みの値をそのまま転送するだけで、この route 自身は新しい validation/normalization を行わない yes - _decide_human_review_directive_editor_route() の classify_scope_delta_authority() 呼び出しに known_context.get("investigation_derived_path_literals") を追加しただけ。test_finding1_investigation_derived_path_literals_forwarded_reaches_issue_editor_required / test_finding1_regression_without_investigation_derived_path_literals_stays_fail_closed が production-reachable に forwarding の有無での分岐を検証 -
issue_editor_required の handoff は、evidence 構築時点から判定直前までの間に anchor comment が変化していないことを fresh readback で確認してからのみ authorize される(TOCTOU 非依存) yes - _decide_human_review_directive_editor_route() は eligible 判定後に fetch_current() を呼び、body/identity が一致しない場合は None(既存 fallback)を返す。test_finding2_fresh_readback_drifted_anchor_fails_closed_to_none / test_finding2_fresh_readback_drifted_identity_fails_closed_to_none / test_finding2_missing_fetch_current_callback_fails_closed_to_none(unit level)と test_finding2_anchor_drift_at_fresh_readback_fails_closed_production_reachable(production-reachable)で検証。unchanged anchor では handoff が維持されることも calls["fetch_current"] >= 1 の呼び出し確認込みで検証(test_finding2_fresh_readback_unchanged_anchor_authorizes_handoff、および positive fixture 各種) -
ImportError・classifier 例外・fresh readback transport failure は genuine ineligibility(None)に化けず、既存語彙を再利用した fail-closed status: "invalid" として区別される(writes == 0) yes - test_finding3_broken_import_returns_distinguishable_environment_failure / test_finding3_classifier_exception_returns_distinguishable_environment_failure / test_finding3_fresh_readback_transport_failure_returns_distinguishable_environment_failure(unit level、monkeypatch で強制発生)と test_finding3_environment_failure_propagates_through_production_consumer(production consumer 境界を跨いでも failure が re-collapse しないことを検証) -
handoff payload は canonical reviewer_feedback_url(anchor comment URL)のみを伝搬し、raw anchor body を reviewer_feedback_text として転送しない yes - test_ac1_consumer_reaches_issue_editor_required_for_freeform_explicit_directive が result["reviewer_feedback_url"] == _ANCHOR_URL かつ != _ANCHOR_BODY を検証(今回追加の fresh-readback fixture 込みで再検証済み) -
reviewer_feedback_url は canonical contract_update 出力へ新規伝搬されず、root/main thread が自身の既知 anchor URL を再利用する設計であることをドキュメントが正確に記述する yes - _bounded_contract_update_handoff() のソースを直接確認し、reviewer_feedback_url を projection しないことを確認した上で SKILL.md / references/loop-state.md を実装の実態に一致するよう修正(コード変更なし、doc-only) -
untrusted principal / invalid anchor binding / target mismatch / ambiguous directive は全て既存の fail-closed のまま(issue_editor_required へ昇格しない) yes - test_ac3_untrusted_author_association_never_escalates_production_reachable / test_ac3_anchor_body_mismatch_never_escalates(status == "no_change" / writes == 0 まで明示検証に強化) / test_ac4_ambiguous_prose_only_directive_never_escalates_production_reachable / test_ac4_not_human_context_lane_never_escalates の negative matrix で検証 -
既存の section-bound patch route・既存の approved scope-reframe full-rewrite route は regression しない yes - test_scope_delta_authority_e2e.py(5/5、未変更)および test_ac5_regression_non_empty_operations_freeform_directive_stays_ordinary_patch_route / 既存 test_negative_1〜6 が回帰なしを確認 -
実際の Issue body mutation の実行(edit_issue_txn.py 起動判断)は本 PR のスコープ外であり root/main thread 側の責務のまま変更しない not_controlled 実装なし(意図的に out of scope、#2620 Out of Scope 節参照) 本 PR は routing 判定のみを追加し、preflight / contract_update 自身が issue-editor SubAgent や edit_issue_txn.py を起動するコードパスは追加していない #2619

Notes

  • Source: 実装: Contract Snapshot publish の transport round-trip と PATCH reconciliation を修正する #2619 の refinement で発見された control-plane gap(実装: trusted human contract feedback を controlled editor handoff に接続する #2620 Background 参照)。実装: Contract Snapshot publish の transport round-trip と PATCH reconciliation を修正する #2619 の Contract Snapshot transport/PATCH reconciliation とは独立した narrow follow-up。
  • Architecture: control-plane(preflight / contract_update)は routing 判定のみを行い writes=0 を維持する。実際の Issue body mutation は既存 issue-editor SubAgent と既存 edit_issue_txn.py controlled transaction に委譲する(root/main thread の責務、本 PR のスコープ外)。
  • routing SSOT は decide_rewrite_route.py に一本化しており、run_refinement_preflight.py にのみ ad-hoc な分岐を追加して二重化する実装にはしていない(今回の fix_delta でも decide_rewrite_route.py 自体は変更せず、run_refinement_preflight.py 側の呼び出し・facts 収集のみを修正した)。
  • eligibility 判定に新しい heuristic/classifier を導入していない。既存 human_review_directive predicate の trust 範囲(OWNER/MEMBER/COLLABORATOR を含む)をそのまま使い、実装: trusted human contract feedback を controlled editor handoff に接続する #2620 固有の OWNER-only ポリシーは作らない。
  • 実装: Contract Snapshot publish の transport round-trip と PATCH reconciliation を修正する #2619 との分離は維持しており、実装: Contract Snapshot publish の transport round-trip と PATCH reconciliation を修正する #2619 の Contract Snapshot transport/PATCH reconciliation は本 PR に取り込んでいない。
  • Allowed Paths 適合: 変更ファイルは Issue 実装: trusted human contract feedback を controlled editor handoff に接続する #2620 の Allowed Paths(SKILL.md / references/loop-state.md / scripts/decide_rewrite_route.py / scripts/run_refinement_preflight.py / 3 つの test ファイル)のうち SKILL.md / references/loop-state.md / scripts/run_refinement_preflight.py / tests/test_preflight_run_with_anchor.py / tests/test_decide_rewrite_route_human_review_directive.py の5ファイルを変更した(scripts/decide_rewrite_route.py と tests/test_scope_delta_authority_e2e.py はこの fix_delta では変更不要だった)。
  • finding 4(reviewer_feedback_url handoff continuity)の判断: 実装の最小解が既存コードだけで成立するかを先に調査し、成立すると判断した(schema 変更を回避)。根拠: root/main thread は contract_update.run.with_human_context を呼び出す際に既に canonical anchor URL(--anchor-comment-url = --human-context-comment-url)を自分自身の引数として保有しており、_bounded_contract_update_handoff() のソースを確認した結果、この値を canonical contract_update projection へ新規伝搬する実装にはなっていない(status/disposition/writes/iterations/final_readback/fresh_preflight/fresh_review/fresh_readiness/reason_code のみ)ことを確認した。よって NEXT_ACTION: issue_editor_required 受信時、root/main thread は自分が渡した anchor URL をそのまま Step 4 issue-editor の reviewer_feedback_url として再利用すればよく、新規 schema key の追加は不要と判断した。Stop Condition には該当しない(doc-only fix)。

Runtime Verification Evidence

Runtime Verification Applicability: immediate(applicable_acs: AC1, AC6)。全ての Verification Command は実 production code path(run_preflight() → consume_trusted_anchor_contract_patch_plan() → decide_rewrite_route.decide_human_review_directive_editor_route())を通過して実行し、SKIP(exit 77)・fallback 経由の成功は一切なかった。head 7c15a87c での再実行結果:

  • AC1/AC6 positive fixture: NEXT_ACTION: issue_editor_required(stdout・result["next_action"] 双方)、contract_update.writes == 0(mutation 回数 0)、apply_transaction callback 呼び出し回数 0、かつ fetch_current callback 呼び出し回数 >= 1(fresh readback が実際に実行されたことを確認、finding 2)。
  • finding 1 positive fixture(investigation_derived_path_literals 転送あり): 同一の NEXT_ACTION: issue_editor_required / writes == 0 を production 経路で確認。同 fixture から investigation_derived_path_literals を除いた negative 変異では next_action != issue_editor_required のまま(既存 実装: Codex issue-creator / issue-editor を分離し controlled mutation route を検証する #1952 fail-closed lock は regression なし)。
  • finding 2 negative fixture(fresh readback 時点で anchor body が drift): next_action != issue_editor_required、writes == 0、かつ fetch_current が実際に呼ばれた上で drift を検出したことを確認(stale snapshot だけを根拠に handoff しないことの直接証拠)。
  • finding 3 negative fixture(ImportError / classifier 例外 / fresh readback transport failure、monkeypatch で強制発生): いずれも status: "invalid" / disposition.disposition: "invalid" / 固有 reason_code(human_review_directive_route_import_failed / _classifier_error / _fresh_readback_failed)/ writes == 0 を確認し、genuine ineligibility の None とは異なる結果であることを検証。production consumer 境界を跨いでも同じ failure が維持されることも確認。
  • AC3 negative fixture(untrusted author association): next_action != issue_editor_required、mutation 回数 0、status == "no_change" / writes == 0 まで明示確認。
  • AC4 negative fixture(曖昧な自由文、bullet directive なし): next_action != issue_editor_required、mutation 回数 0。
  • PASS/FAIL/SKIP summary: 上記 Checks セクションの通り全 PASS、SKIP 0 件(本 PR 変更分)。skill 全体回帰の 3 件 FAIL は本変更前の同一 HEAD でも再現するサンドボックス環境固有の uv_version_mismatch であり、本 PR の変更と無関係。
    🤖 Generated with Claude Code

…する (#2620)

preflight/contract_update の human-context lane で、既存の section-bound
patch derivation でも表現不能で、かつ既存 scope-reframe full-rewrite route
にも該当しない explicit trusted human_review_directive を検出した場合に、
writes=0 のまま既存 NEXT_ACTION: issue_editor_required へ route する新しい
eligibility を追加する。

- decide_rewrite_route.py: 新しい SSOT 関数
  decide_human_review_directive_editor_route() を追加。既存 predicate
  (authority_category/directive_confidence/with_human_context/anchor
  binding/same-target binding/operations_empty) の組み合わせのみで判定し、
  新しい classifier/heuristic は導入しない。
- run_refinement_preflight.py:
  consume_trusted_anchor_contract_patch_plan() に、構造化
  ANCHOR_SCOPE_REFRAME_V1 が不在(_decision_kind == "absent") かつ
  derived operations[] が空の場合の新しい分岐を追加。
  scope_delta_authority_evidence を classify_scope_delta_authority() で
  fresh に再分類し、SSOT へ facts だけを渡す。canonical
  reviewer_feedback_url (anchor comment URL) を伝搬し、raw anchor body は
  転送しない。
- SKILL.md / loop-state.md: issue_editor_required の到達条件ドキュメントを
  「承認済み scope reframe + empty operations[] 限定」から、#2620 の
  explicit trusted human_review_directive route を含む記述へ更新。
- テスト: test_decide_rewrite_route_human_review_directive.py (新規) で
  SSOT ユニットテスト + consumer 直接呼び出しテスト、
  test_preflight_run_with_anchor.py に実 run_preflight() 経由の
  production-reachable E2E (AC1/AC6 positive、AC3/AC4 negative) を追加。

Runtime Verification Applicability: immediate (AC1, AC6)。全 VC は実
production code path (run_preflight -> consume_trusted_anchor_contract_
patch_plan -> decide_human_review_directive_editor_route) を通過して PASS。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #2623 closed).

@squne121

Copy link
Copy Markdown
Owner Author

PR Review Verdict (Step 4, impl-review-loop)

Mergeability: mergeable=MERGEABLE, mergeStateStatus=CLEAN (confirmed live by control-plane at reviewed_head_sha).

Evidence Check:

  • Routing SSOT centralized in decide_rewrite_route.py::decide_human_review_directive_editor_route(); run_refinement_preflight.py only assembles facts and consumes the SSOT decision (no duplicated ad-hoc routing).
  • Eligibility reuses only pre-existing predicates (authority_category == human_review_directive, explicit directive, with_human_context, trusted-principal predicate, same-target/provenance/anchor binding) — no new classifier/heuristic, no 実装: trusted human contract feedback を controlled editor handoff に接続する #2620-specific OWNER-only policy.
  • writes=0 / no direct edit_issue_txn.py or issue-editor invocation on the new route (verified via grep + test assertions on apply_transaction call count).
  • Canonical reviewer_feedback_url propagated; raw anchor body never used as reviewer_feedback_text.
  • AC6 production-reachable path independently exercised (real run_preflight() → consume_trusted_anchor_contract_patch_plan() → SSOT), not helper-only; no fallback-only PASS.
  • AC3/AC4 negative matrices confirmed non-escalating, writes=0.
  • AC5 regression: existing routes/tests unchanged (test_scope_delta_authority_e2e.py diff is empty).
  • Out-of-Scope items (raw GitHub mutation route, edit_issue_txn.py, new schema/classifier/security subsystem, 実装: Contract Snapshot publish の transport round-trip と PATCH reconciliation を修正する #2619 transport/PATCH reconciliation) untouched.
  • Closes #2620 present; Runtime Verification Evidence section is a redacted summary only.
  • Independent full relevant test run at this exact head: 73 passed (3 target test files) + 4 passed (-k "production_reachable or issue_editor_required").
  • Required CI: all green at this head (python-test, lint, build, test, typecheck, validate-generated-artifact), after a bounded rerun cleared an unrelated flaky timing test.

Blockers: none.

Non-blockers:

  • PR is currently Draft — not a blocker per Delivery Rule policy; left for human final-merge judgment per this Issue's completion condition (PR merge itself is out of scope for this loop).
verdict: APPROVE
reviewed_head_sha: "43f8f07c06d65f04e71eb58bac98767e81c21886"
blockers: []
warnings:
  - "PR is Draft (isDraft=true) — not a blocker; noted for control-plane routing awareness only."

@squne121

Copy link
Copy Markdown
Owner Author

結論

REQUEST CHANGES です。PR #2623 の方向性自体は良く、既存の issue-editor / controlled transaction を再利用し、preflight 側に新しい mutation plane や過剰な security harness を増やしていない点は妥当です。PR は現在 Draft で、head 43f8f07... は mergeable、既存レビューコメントでは APPROVE・CI green とされています。

ただし敵対的に production caller chain を追うと、2件はマージ前に直したい実動作上の blocker があります。特に #2086 で既に解決したはずの autonomous human-context workflow を一部再び止める経路があります。

Findings

  1. BLOCKER / P1 — investigation_derived_path_literals を consumer-side 再分類へ渡しておらず、実装: operator-selected human context の scope reframe を自動継続し scope expansion stop を撤去する #2086 の主要ユースケースが再び到達不能です。

    実装: operator-selected human context の scope reframe を自動継続し scope expansion stop を撤去する #2086 は「人間が high-level な scope expansion を指示し、exact path は read-only investigation で agent が導出する」ことを明示的に許可し、exact section patch が作れない場合は issue_editor_required に送る契約です。

    実際、既存 classify_scope_delta_authority() は investigation_derived_path_literals を受け取り、それによって expands_allowed_paths boundary を解除できる設計です。 Planner 側も known_context["investigation_derived_path_literals"] を classifier に転送しています。

    ところが feat: trusted human contract feedback を controlled editor handoff に接続する #2623 で追加した _decide_human_review_directive_editor_route() の「fresh re-classification」は、

    classify_scope_delta_authority(evidence_list, target_issue_number=..., expected_repo=..., base_issue_body_sha256=...)

    までで、investigation_derived_path_literals を渡していません。

    したがって、planner では contract_update_required だった authority が consumer で human_escalation に戻り、route_action == contract_update_required predicate が落ちます。その後 issue_editor_required になりません。

    しかも現行 SKILL.md はまさに「実装: operator-selected human context の scope reframe を自動継続し scope expansion stop を撤去する #2086 の investigation 後にも operations が空なら issue_editor_required に進む」と記述しています。実装とSSOTドキュメントが逆です。

    修正は小さくて十分です。 consumer-side reclassification に upstream ですでに検証済みの known_context.get("investigation_derived_path_literals") をそのまま渡し、human-context scope expansion + investigation-derived exact paths + operations=[] → issue_editor_required / writes=0 の production-reachable regression を1本追加してください。新規schemaやsecurity harnessは不要です。

  2. BLOCKER / P1 — 新しい freeform route は「fresh readback」を実際にはしておらず、anchor TOCTOU を見逃します。

    実装: trusted human contract feedback を controlled editor handoff に接続する #2620 は route 入口で target/anchor binding と fresh precondition/readback を要求しています。root/main thread はその後 canonical feedback URL を issue-editor に渡す契約です。

    しかし新分岐は _decide_human_review_directive_editor_route() を呼び、成功するとそこで即 return します。fetch_current() が定義・使用される既存 path より前です。

    helper 内で「fresh」と呼んでいるものは、同じ known_context evidence を classifier に再入力しているだけです。GitHub の comment/Issue を再取得してはいません。anchor_binding_ok も、既に手元にある evidence_primary.body_sha256 と渡された anchor_body の比較です。

    対照的に既存 実装: 回帰: approved scope reframe に patch operations が無い場合、contract_update を再試行せず issue_editor_required へ route する #2048 scope-reframe route は、empty-operation の full rewrite 判定前に fetch_current() し、fresh anchor を normalize_trusted_anchor_iteration_zero() で再検証しています。

    これはsecurityよりworkflow correctnessの問題です。最初のsnapshot取得後にコメントが編集された場合、古い directive を根拠に issue_editor_required を発行し、その後 issue-editor は同じURLから変更後の別内容を読む可能性があります。

    GitHub公式REST APIは comment ID 単位の再取得で body、updated_at、author_association、html_url 等を取得できるので、新しい仕組みは不要です。([GitHub Docs]1) 既存 fetch_current callbackを新ルートでもroute決定直前に一度使うのが最小です。

  3. HIGH — integrity/error と「本当に該当しない」が全部 None に潰され、no_change に化け得ます。

    helper は ImportError も classifier の任意例外も return None にしています。またbinding mismatchも最終的にrouteなしの None です。 Callerは None なら既存経路へfall-throughします。

    empty operationsかつstructured deltaなしなら、既存 run_trusted_anchor_iteration_zero() は普通の status: no_change を返します。 さらに6 gateが通れば _bounded_contract_update_handoff() はそれを proven_no_change の正常結果として扱えます。

    これは 実装: 回帰: approved scope reframe に patch operations が無い場合、contract_update を再試行せず issue_editor_required へ route する #2048 でわざわざ invalid と absent を分離した設計思想と逆行しています。既存 structured route はrouter import failureを environment_failure として区別しています。新routeも最低限 not_applicable / invalid / environment_failure / issue_editor_required を区別すべきです。

    現在のAC3テストも「rewrite_route is None」「status != handoff_required」しか確認しておらず、本当に fail-closed したことを検証していません。

  4. HIGH — reviewer_feedback_url は内部consumer resultには存在しますが、root/main thread向けのcanonical handoffから消えます。

    新helperは確かに reviewer_feedback_url を返しています。 しかし直後の _bounded_contract_update_handoff() は handoff_required を status/disposition/reason_code/... だけにprojectionし、URLを捨てています。

    canonical refinement_preflight_result/v1.contract_update schemaにも reviewer_feedback_url はなく additionalProperties: false です。 stdout projectionにもURLは出ません。一方、SKILL.md は「handoff payload は canonical reviewer_feedback_url を含む」と明記しています。

    現状でもroot agentが直前のcommand引数を覚えていれば動きますが、それは「payload propagation」ではありません。restart/recoveryやmachine consumerには弱いです。実装: trusted human contract feedback を controlled editor handoff に接続する #2620 AC1を文字通り満たすならURLをcanonical resultまで運ぶ必要があります。schema変更を避けたいなら、逆にIssue/SKILLを「callerが直前に渡したcanonical anchor URLを再利用する」と明文化して、payload伝搬という主張を削る方が軽量です。

  5. P2 — SKILL.md のstatus契約が自己矛盾しています。

    同じ説明箇所で contract_update.status は applied/no_change/rebased/failed の「4値のみ」と書かれています。 実装とschemaは既に第5の値 handoff_required を正式に持っています。

    Agent向けSKILLの機械的な分岐説明なので、単なる文章ミスとして放置しない方がいいです。

Web調査を踏まえた設計評価

既存 issue-editor / edit_issue_txn.py を継続利用する方針は維持すべきです。GitHub CLI自身が gh issue edit --body-file を正式に提供しているため、現在の「candidate bodyをファイル化→controlled mutation」という境界に技術的な不足はありません。(GitHub CLI) またClaude Code公式もproject-level subagentを .claude/agents/ で定義し、独立context・専用tool accessを持つ専門workerへ委譲する設計を正式にサポートしています。(Claude)

したがって、新しいapproval service、permission plane、publisher、署名、追加ハーネス等は入れないのが適切です。今回必要なのは既存データを正しく結線するだけです。

マージ判断

現headはまだマージ非推奨です。 最低でも Finding 1(investigation_derived_path_literals forwarding)と Finding 2(route直前のfresh anchor readback) は直すべきです。Finding 3も同時に直せば、#2623の目的である「人間の明示directiveを黙って落とさない」という価値がかなり堅くなります。

既存APPROVEは、simple explicit directiveケースについては妥当ですが、#2086とのcompositionとTOCTOU境界まで追えていないと判断します。

@squne121
squne121 marked this pull request as ready for review September 10, 2026 11:16
@squne121

Copy link
Copy Markdown
Owner Author

推奨は、#2620 の既存 Task / PR #2623 をそのまま継続し、対象コメントを fix_delta として次の impl-review-loop iteration に投入することです。新規 Issue・新規 PR・新規 worktree を作る局面ではありません。PR は現在も open / Draft、head は 43f8f07c...、mergeable です。

対象 OWNER コメントは、同一 head に対する先行 APPROVE より後に投稿された REQUEST CHANGES で、最低限 Finding 1 の investigation_derived_path_literals forwarding と Finding 2 の本物の fresh anchor readback をマージ前 blocker としています。Finding 3 も同時修正推奨です。したがって、先行 APPROVE を終了根拠にせず、修正後 head に対する fresh verification + fresh PR review を必須にするのが適切です。

また、このコメントは PR Conversation の human review feedback なので、Issue #2620 の human_context_comment_urls に無理に流すより、impl-review-loop が定義している fix_delta.blockers + fix_delta.pr_review_comment_url として implementation-worker に渡すのが自然です。Skill 自体も REQUEST_CHANGES → Step 1 の際にこの形を定義しています。 Finding 4については、#2620 が schema/key-set変更を Stop Condition にしているため、レビュー指摘を理由に安易に canonical schema を拡張させない方がよいです。まず Allowed Paths 内で既存契約を維持した最小解を探し、それが不可能なら Stop Condition として扱わせます。

そのまま Claude Code に投入するプロンプトです。

既存 Task の Issue #2620 / PR #2623 を継続してください。これは新規 Task ではなく、既存 PR に対する review fix iteration です。

Target Issue:
#2620

Existing PR:
#2623

今回の authoritative human review / fix_delta:
#2623 (comment)

.claude/skills/impl-review-loop をオーケストレーターとして使用し、この review feedback を反映した実装 → 独立検証 → PR review のループを、マージ直前の状態まで人間承認なしで自律実行してください。

重要:

最初に live Issue #2620、live PR #2623、対象 OWNER コメント、現在の diff / head / CI / review state、および .claude/skills/impl-review-loop と関連 skill/reference を読み直し、対象コメントを repository facts と照合して serialized fix_delta を作成してください。

少なくとも以下を fix_delta として処理してください。

  1. P1 blocker: investigation_derived_path_literals の consumer-side forwarding

_decide_human_review_directive_editor_route() が行う classify_scope_delta_authority() の再分類に、upstream で既に validation 済みの

known_context.get("investigation_derived_path_literals")

を既存 classifier contract に従って渡してください。

planner では contract_update_required だった authority が consumer-side reclassification で human_escalation に戻る composition regression を解消してください。

必ず production-reachable regression を追加し、

human-context scope expansion

  • investigation-derived exact paths
  • operations == []
    → NEXT_ACTION: issue_editor_required
    → preflight writes == 0

を実 production caller chain から確認してください。

新規 classifier、heuristic、security harness、approval service は追加しないでください。

  1. P1 blocker: freeform route の genuine fresh readback

現実装の「同じ known_context evidence をもう一度 classifier に入れるだけ」の処理を fresh readback とみなさないでください。

新しい freeform issue_editor_required route の最終判定直前に、既存の fresh-readback primitive / fetch_current() と、既存 scope-reframe route が使用している normalization / binding 再検証の仕組みを調査して再利用してください。

snapshot 取得後に anchor comment が編集された場合に、古い directive のまま issue_editor_required を発行してはいけません。

少なくとも regression で以下を確認してください。

  • unchanged fresh anchor → eligibility を満たせば issue_editor_required
  • anchor body / identity / binding が fresh readback で変化 → fail-closed
  • mismatch 時 writes == 0
  • stale snapshot を根拠に handoff しない

新しい GitHub access layer や別 mutation plane は作らず、既存 readback path を再利用してください。

  1. HIGH: None による integrity failure の normal no_change 化を防止

現在 _decide_human_review_directive_editor_route() が、

  • ImportError
  • classifier exception
  • invalid/binding failure
  • genuinely not applicable

を広く None に潰している箇所を調査してください。

既存 #2048 等の fail-closed semantics と整合するよう、少なくとも意味論上

  • not_applicable
  • invalid / fail_closed
  • environment_failure
  • issue_editor_required

を区別し、integrity/environment failure が普通の no_change / proven_no_change に化けないようにしてください。

ただし #2620 の固定 schema/key-set を安易に増やしてはいけません。既存 result/disposition/reason_code 等で表現可能かを先に調査し、最小変更にしてください。

negative tests は単に rewrite_route is None や status != handoff_required を確認するだけでは不足です。期待する fail-closed reason/disposition と writes=0 を検証してください。

  1. HIGH: reviewer_feedback_url handoff continuity

対象レビューが指摘している、

internal consumer result には reviewer_feedback_url があるが _bounded_contract_update_handoff() / canonical projection で消える

という点を production caller chain で確認してください。

ここでは #2620 の Out of Scope / Stop Conditions を優先し、canonical schema の新規キー追加を最初の解決策にしないでください。

まず、

  • 既存 Allowed Paths
  • 既存 schema
  • root/main thread の既存 anchor URL ownership
  • issue-editor の既存 issue_number + reviewer_feedback_url input

だけで、URL continuity を正しく保証または契約上明確化できる最小解がないか調査してください。

Allowed Paths 外変更、固定 schema/key-set/type contract の変更が本当に不可避なら、勝手に scope expansion せず Issue #2620 の Stop Condition として明示してください。

ただしその判断を行う前に、既存実装で解決できる経路を十分確認してください。

  1. P2: SKILL.md status contract

.claude/skills/issue-refinement-loop/SKILL.md 内で contract_update.status を
applied/no_change/rebased/failed の4値のみと説明している箇所と、
既存 handoff_required
との自己矛盾を修正してください。

Agent routing contract なので、実装・schemaの実値と正確に一致させてください。

実装方針:

SubAgent orchestration は必須です。

Step 1:
implementation-worker SubAgent に、対象 OWNER comment を正規化した serialized fix_delta と technical recommendation を渡して修正を委譲してください。

SubAgent を起動しただけで次へ進まず、必ず作業完了を待って IMPLEMENT_RESULT_V1 を取得・検証してください。
未完了の SubAgent を残したまま verification へ進まないでください。

Step 2:
current head に対して test-runner SubAgent を独立起動し、完了まで待ってください。
implementation-worker の自己申告だけを verification evidence にしないでください。

少なくとも Issue #2620 の Verification Commands を再実行してください。

  • uv run pytest .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py
  • uv run pytest .claude/skills/issue-refinement-loop/tests/test_decide_rewrite_route_human_review_directive.py
  • uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_delta_authority_e2e.py
  • uv run pytest .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py -k "production_reachable or issue_editor_required"

さらに変更内容に応じた focused regression と、実行可能な relevant issue-refinement-loop regression suite を実施してください。

runtime verification は helper-only PASS では不可です。
real run_preflight() production-reachable path から検証し、fallback-only success は FAIL としてください。

Step 4:
verification が current-head gate を満たした後に pr-reviewer SubAgent を fresh に起動してください。
必ず completion を待ち、修正後 head SHA に束縛された fresh verdict を取得してください。

Step 5:
route_loop_verdict_v2() の normative routing に従ってください。

REQUEST_CHANGES の場合:

  • fresh blockers を次 iteration の fix_delta に変換
  • implementation-worker に再委譲
  • 完了を待つ
  • verification を再実行
  • 完了を待つ
  • pr-reviewer を再実行
  • 完了を待つ

というループを、人間承認を挟まず継続してください。

SubAgent の launch receipt、task id、存在確認だけを completion とみなさないでください。
各 SubAgent の終端 result を実際に待ってから state transition してください。
子 SubAgent がさらに SubAgent を起動した場合も、必要な child work が完了していることを確認してから親 result を確定してください。

PR branch に必要な commit を作成して push し、PR #2623 自体を更新してください。
別 PR を作らないでください。

PR body の Checks / Runtime Verification Evidence / Safety Claim Matrix 等が変更後の実装と不整合になった場合は、実際の最新 evidence に合わせて更新してください。以前の head 43f8f07c... の test/review evidence を、新しい head の証拠として再利用しないでください。

required CI が起動した場合は current head の結果を確認してください。修正可能な failure は承認を求めず loop 内で修正してください。既知の flaky failure は根拠を確認した上で既存 workflow policy に従った bounded retry のみ許可します。

通常の warning、advisory artifact missing、Draft status、SubAgent の human_review_required: true 自己申告だけでは停止しないでください。

停止するのは live Issue / skill の hard Stop Condition が実際に成立した場合だけです。特に:

の場合のみ停止し、具体的 evidence を出してください。

完了条件は、修正後の最新 PR head に対して、

  • requested P1 blockers が解消
  • applicable HIGH/P2 findings が解消または reviewer が non-blocking と明示
  • relevant tests PASS
  • runtime production-reachable verification PASS
  • required CI green
  • fresh pr-reviewer verdict == APPROVE
  • blockers == []
  • live mergeability が impl-review-loop の approved route 条件を満たす

状態です。

そこまで到達したらマージはせず停止し、最後に以下だけを簡潔に報告してください。

  • final head SHA
  • 実施した主要修正
  • test / runtime verification / CI 結果
  • fresh reviewer verdict
  • unresolved warnings があればその内容
  • merge-ready; human final merge only であること

途中の通常判断について人間承認を求めず、SubAgent を使用し、その完了を待ちながら最後までループを実行してください。

この形なら、今回のレビューを「別作業」ではなく PR #2623 の次の fix_delta iteration として扱えるため、既存 impl-review-loop の設計に最も沿います。

Test and others added 3 commits September 10, 2026 20:49
…h_literals 転送漏れ・TOCTOU・integrity failure 区別を修正する

PR #2623 OWNER review fix_delta:
- classify_scope_delta_authority() 呼び出しへ known_context["investigation_derived_path_literals"]
  を転送し、architecture/workflow scope expansion directive の boundary clear が
  production 経路で機能するようにする (finding 1)
- _decide_human_review_directive_editor_route() が issue_editor_required を返す直前に
  fetch_current() による fresh readback を行い、TOCTOU window を閉じる (finding 2)
- ImportError・classifier 例外・fresh readback failure を genuine ineligibility (None) と
  区別し、既存の status: invalid / disposition 語彙を再利用して fail-closed にする (finding 3)
- reviewer_feedback_url の実際の伝搬範囲 (root/main thread が自身の anchor URL を再利用する)
  に合わせて SKILL.md / loop-state.md の記述を修正する (finding 4)
- contract_update.status の実際の5値 (handoff_required 含む) に SKILL.md の記述を合わせる (finding 5)

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: trusted human contract feedback を controlled editor handoff に接続する

1 participant