Repository navigation
feat: 複数ターン anchor を chronology metadata として保持し provenance 分離を impl-review-loop へ伝搬する - #1973
Conversation
…eview-loop へ伝搬する (#1950) trusted OWNER の multi-turn anchor を hard block から advisory route (warn + latest_owner_turn chronology metadata) に変更し、chronology / semantic relation / technical recommendation / mutation authorization の 4 軸分離を 明確化した。owner reaction による material conflict 解決手順を anchor reference に定義した。 impl-review-loop 側は human_context_comment_urls / agent_report_comment_urls を追加入力とし、build_intake_capsule.py に呼び出し元引数のみを origin 判定根拠とする context_inputs (human_supplied / agent_generated / provenance_conflicts) 解決ロジックを additive に追加した。stdout には raw body を含めず、artifact にのみ保存する。preparation / step-1 delegation に provenance-separated context の扱いを明記した。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #1973 closed). |
CI の PR Body Japanese Check が step-1-implementation.md / anchor-comment-handling.md の一部見出し・段落で日本語比率不足を検出したため、 新規追加した英語主体の見出し・段落を日本語表現に是正する。意味・スコープの 変更は行わない。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
impl-review-loop 判定結果Mergeability: Evidence Check:
Blockers: なし Non-blockers(Warnings):
経緯: 初回レビュー(head verdict: APPROVE
reviewed_head_sha: "afe8099bd6fea7e25da9ffaa4b1b909f831fbb02"
blockers: []
warnings:
- "PR body は AC coverage 節に正確な見出し「## 受け入れ条件の達成状況」を含まない(AC 相当情報は「検証コマンド結果」節にあるが見出しテキスト不一致)。既存の直近マージ済み前例(#1959/#1949)と同様に non-blocking として扱う。" |
判定REQUEST_CHANGES。現状のままマージ不可です。 確認時点の head は FindingsP0-1. 既存の fail-closed 判定を
|
…WNER REQUEST_CHANGES OWNER review: #1973 (comment) P0-1: `_apply_multi_turn_candidate_route()` no longer unconditionally overwrites a valid `approved_by_trusted_anchor` or `fail_closed` (schema_invalid/wrong_repo/wrong_issue_number/untrusted_author_association) scope_delta_decision with `warn`. The advisory downgrade now applies only to `fail_closed`/`no_anchor_scope_reframe_v1_payload` AND when retrieval integrity (fetch complete, hash verified, source ranges covered) is fully confirmed via a new `integrity_predicates` keyword arg. `known_context. anchor_reframe` is now computed AFTER routing (from the final status), not before, eliminating the split-brain with the routed decision. P1-5: `_apply_exit_code_mapping()` now also consults `scope_delta_decision.status == "warn"` (in addition to the pre-existing unknown-confidence check) so the multi-turn trusted-owner advisory route surfaces as a CI-visible `warn`/EXIT_WARN instead of silently staying `pass`/EXIT_PASS. P0-2: `build_intake_capsule.py` gains `build_capsule_argv()` (single source of truth for the canonical CLI invocation preparation.md documents) and `validate_step1_dispatch_payload()` (enforceable version of the step-1-implementation.md #1950 AC10 prose: requires technical_recommendation + an evidence reference, and fail-closes when a raw human comment body is embedded verbatim in the worker delegation message). P1-3: the `agent_generated` context-input lane no longer accepts a bare regex marker match anywhere in the comment body. It now requires exactly one top-level fenced block, parses it, and checks the top-level key against a closed `_ALLOWED_AGENT_REPORT_SCHEMA_IDS` allowlist, replacing `structured_marker_present` with `validated_schema_id` / `validation_status` / `validation_errors`. P1-4 (reaction workflow publisher/reader) is intentionally NOT addressed here -- out of scope per Issue #1950's own Stop Conditions; left to the control-plane orchestrator (PR body wording + follow-up Issue). Co-Authored-By: Claude Sonnet 5 <[email protected]>
REQUEST_CHANGES 対応完了(fix_delta, head
|
Summary
ANCHOR_MULTI_TURN_FAIL_CLOSED)から advisory route(status: warn+latest_owner_turnchronology metadata)へ変更し、chronology / semantic relation / technical recommendation / mutation authorization の 4 軸を分離した(AC1)。trusted OWNER 以外の author は従来通り hard block を維持する(AC2)。anchor-comment-handling.mdに定義した(AC3/AC4)。Issue 実装: multi-turn anchor の owner turn を chronology metadata として扱い、reaction decision flow を issue-refinement-loop と impl-review-loop へ導入する #1950 の AC3/AC4 は「手順を Skill / reference に定義する」ことを要求しており、live GitHub reaction API の pagination/principal-resolver 実装コードは要求していない(Issue Out of Scope: 「新しい semantic classifier、decision ledger、独立 schema、publisher は追加しない」と整合)。live reaction API 疎通確認は Issue 本文のRuntime Verification Applicability: deferredの対象のまま。impl-review-loopの intake capsule・preparation・Step 1 delegation へ additive に伝搬した(AC6-AC10)。build_intake_capsule.pyに--human-context-comment-url/--agent-report-comment-urlを追加し、既存の全ページ comment fetch 結果に呼び出し元引数だけを origin 判定根拠として additive に紐付ける(新規 fetch 経路は追加しない)。test_intake_capsule_provenance_e2e.py)で CLI 引数から capsule artifact、preparation routing、Step 1 context binding までを検証した(AC11)。Closes #1950(Issue #1950 In Scope が要求する procedure-level Outcome — advisory route の chronology/authorization 分離、owner reaction 手順の文書化、impl-review-loop への provenance 伝搬 — を完了する変更である。live reaction API 実装は Issue 自身の Out of Scope/Stop Conditions により本 Issue の対象外)
OWNER REQUEST_CHANGES 対応(fix_delta, commit
020095e1)review コメント で指摘された P0/P1 5 件のうち、実装修正が必要な 4 件を fix_delta で解消した。
_apply_multi_turn_candidate_route()がapproved_by_trusted_anchorやschema_invalid/wrong_repo/wrong_issue_numberの既存 fail-closed 判定まで無条件にwarnで上書きしていた(anchor_reframeとの split-brain も発生)integrity_predicatesを明示的に受け取り、approved_by_trusted_anchorは status を保持したままlatest_owner_turnのみ追加。advisory 化(fail_closed → warn)はreason == no_anchor_scope_reframe_v1_payloadかつ retrieval integrity 全 true の場合のみに限定。他の fail_closed 理由は元の decision をそのまま返す。anchor_reframeは route 後の最終 status から計算するよう変更し split-brain を解消--human-context-comment-url等)が canonical preparation command に配線されておらず、test も CLI 呼び出しを手組みしていたbuild_intake_capsule.pyに argv 生成の単一 SSOTbuild_capsule_argv()を追加しpreparation.mdの「0-a」から参照。Step 1 dispatch payload 用の enforcement 関数validate_step1_dispatch_payload()を追加し、technical_recommendation欠落時・raw comment body の直接埋め込み時を fail-closed にagent_generatedlane の「schema validation」が[A-Z][A-Z0-9]*_V\d+の bare regex 一致のみで、引用文中の marker でも通っていた_ALLOWED_AGENT_REPORT_SCHEMA_IDSclosed allowlist 照合に置換。structured_marker_presentをvalidated_schema_id/validation_status/validation_errorsに置換scope_delta_decision.status == warnが wrapper の exit code に反映されず、advisory route の発生が最終status/exit_codeから検出できなかった_apply_exit_code_mapping()にscope_delta_decisionを渡し、status == warnの場合に("warn", EXIT_WARN)を返すよう修正。回帰テストでexit_code == EXIT_WARNを直接検証Closes #1950が完了を宣言しており矛盾P1-4 の follow-up: #1975(
owner reaction 手順を決定論的 reaction reader/principal resolver/drift checker/mutation consumer として実装する、parent #1950)を起票済み。Checks
pnpm typecheckpnpm lintpnpm testpnpm build(全項目を worktree 内で実行し、結果は下記「検証コマンド結果」節を参照)
Schema Change Applicability
schema_changeIMPL_REVIEW_INTAKE_CAPSULE_V1に後方互換な optionalcontext_inputssection を追加し、run_refinement_preflight.py内部のscope_delta_decisiondict に新しいstatus: warn/latest_owner_turnの値・フィールドを追加した(scope_delta_decision自体は JSON schema でadditionalProperties: falseに固定されていない内部 dict であり、専用の named schema ファイルは持たない)。fix_delta でcontext_inputs.agent_generated[].structured_marker_presentをvalidated_schema_id/validation_status/validation_errorsに置換したが、これも同じ non-schema-file 内部 dict の additive/renaming 変更であり、.claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.json(additionalProperties: false)自体は一切変更していない(Allowed Paths 外のため)。Schema Consumer Inventory
変更対象 schema:
IMPL_REVIEW_INTAKE_CAPSULE_V1(.claude/skills/impl-review-loop/scripts/build_intake_capsule.py)before/after 差分:
Consumer 列挙(rg コマンド例と結果):
rg -n "IMPL_REVIEW_INTAKE_CAPSULE_V1" .claude/skillsConsumer 更新状況:
.claude/skills/impl-review-loop/scripts/build_intake_capsule.pycontext_inputsを additive に生成。fix_delta で_validate_agent_report_schema()allowlist 検証を追加).claude/skills/impl-review-loop/steps/preparation.mdcontext_inputs未存在時は従来通り no-op。fix_delta でbuild_capsule_argv()を argv 生成の SSOT として参照するよう明記.claude/skills/impl-review-loop/steps/step-1-implementation.mdtechnical_recommendation/capsule_artifact_path/human_context_comment_ids/agent_report_comment_idsの delegation message binding を追加context_inputsabsent 時は capsule dict に一切キーが増えないため、既存 consumer/test は無変更で動作するCompatibility Decision(互換性判定)
additivebackward_compatiblenoN/Acontext_inputsは新規 optional section であり、呼び出し元が新しい CLI flag を渡さない限り capsule dict に追加キーは一切現れない。既存のrun_refinement_preflight.pyのscope_delta_decisionも、statusに既存 enum 値のwarnを追加使用するのみで、既存キー(status/reason/implementation_go/anchor_author_association等)の型・意味は変更していない。fix_delta のstructured_marker_present→validated_schema_id/validation_status/validation_errors置換はcontext_inputs.agent_generated[]内部フィールドの rename であり、本 PR 内で producer/consumer/test を同時更新済みのため互換性影響はない(外部 consumer は存在しない)。Safety Claim Matrix
ANCHOR_MULTI_TURN_FAIL_CLOSED)を維持するtest_run_preflight_subprocess_multi_turn_ambiguity_non_owner_blocks/test_non_owner_multi_turn_route_is_unaffected_by_owner_advisory_path(PASS)implementation_goをtrueに昇格させない(chronology ≠ authorization)test_trusted_owner_multi_turn_routes_to_advisory_chronology_metadataのassert routed["implementation_go"] is False(PASS)approved_by_trusted_anchor判定・schema_invalid/wrong_repo/wrong_issue_numberの fail_closed 判定は multi-turn advisory route によって上書きされない(fix_delta, P0-1)test_run_preflight_subprocess_heavy_mutation_without_owner_blocks(PASS、無変更)context_inputsの human/agent lane provenance は呼び出し元引数の位置だけで決まり、本文・投稿アカウントから再分類しないtest_cli_human_and_agent_context_urls_resolve_into_artifact_not_stdout(PASS)test_cli_provenance_conflict_same_url_both_lanes_is_fail_closed(PASS)test_cli_human_and_agent_context_urls_resolve_into_artifact_not_stdoutのassert "body" not in ...(PASS)agent_generatedの schema validation は closed allowlist + 単一 top-level block parse であり、引用文中の marker では成立しない(fix_delta, P1-3)_validate_agent_report_schema()回帰テスト(quoted-only marker / non-allowlisted schema / multiple blocks の fail-closed、PASS)build_capsule_argv()を経由して実際に materialize され、prose のみの契約ではない(fix_delta, P0-2)build_capsule_argv()+ subprocess 実行 e2e test(PASS)context_inputs存在時にtechnical_recommendation欠落・raw comment body 直接埋め込みを fail-closed にする(fix_delta, P0-2)validate_step1_dispatch_payload()3 シナリオ回帰テスト(PASS)anchor-comment-handling.mdの「競合(material conflict)発生時の owner reaction 手順」節Runtime Verification Applicability: deferredの対象のまま記載ルール遵守: owner reaction の live API 実装は
Not controlledに明記し、Issue #1950 自身の Out of Scope(新規 publisher 禁止)と整合させた上でCloses #1950の意味を procedure-level Outcome に限定した。PR title / summary で無限定のsafe/completeは使用していない。Runtime Verification Applicability(Issue 本文の動作検証適用範囲をそのまま引用する節)
deferredrgによる文字列存在確認だけでは検証にならない。live GitHub reaction API への疎通確認は本 Issue の Runtime Verification としてはdeferredとし、非破壊の専用 test Issue/comment を用いた実 API 検証は別途 owner 判断で実施する。AC4・AC5・AC11 が要求する mocked subprocess E2E は本 PR の Verification Commands として即時実施済み。実環境未確認である旨を明記する。検証コマンド結果
uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py -v(AC5)uv run --locked pytest .claude/skills/impl-review-loop/tests/test_intake_capsule_provenance_e2e.py -v(AC11)uv run --directory <worktree> pytest .claude/skills/impl-review-loop/tests/ .claude/skills/issue-refinement-loop/tests/(regression)pnpm typecheckpnpm lintpnpm testpnpm builduv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.pyruff check(fix_delta 変更 Python ファイル)rg -nF "chronology metadata" .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py(AC1)rg -nF "heavy_mutation_requires_owner_explicit_decision" .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py(AC2)rg -nF "owner reaction" .claude/skills/issue-refinement-loop/references/anchor-comment-handling.md(AC3)rg -nF "untrusted reaction" .claude/skills/issue-refinement-loop/tests/test_anchor_context_multi_turn_supersession.py(AC4)rg -nF "human_context_comment_urls" .claude/skills/impl-review-loop/SKILL.md(AC6)rg -nF "context_inputs" .claude/skills/impl-review-loop/scripts/build_intake_capsule.py(AC7)rg -nF "provenance_conflict" .claude/skills/impl-review-loop/scripts/build_intake_capsule.py(AC8)rg -nF "treat_as_untrusted_natural_language" .claude/skills/impl-review-loop/steps/preparation.md(AC9)rg -nF "technical_recommendation" .claude/skills/impl-review-loop/steps/step-1-implementation.md(AC10)Allowed Paths Compliance(許可パス準拠の確認)
Issue #1950 の Allowed Paths(9ファイル)に完全一致。fix_delta commit を含め
git diff --name-onlyで確認済み:Notes
anchor_context.pyの semantic classifier /final_candidateselector 追加、新規 decision ledger・schema・publisher の追加、issue-refinement-loop入力契約自体への provenance フィールド追加は Out of Scope(本 Issue の記述通り)。owner reaction workflow の live 実装(reader/publisher/pagination/principal-resolver)も同じ理由で本 Issue の Out of Scope(follow-up: 実装: owner reaction 手順を決定論的 reaction reader/principal resolver/drift checker/mutation consumer として実装する #1975)。