Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "issue-refinement-loop の Step 0f structural repair producer に known_scalars/source_spans の実抽出を配線し、derivation 可能な missing section が不要に human_judgment_required へ落ちる wiring gap を解消する"
change_kind: codeParent Issue
なし(単独改善。#2426 で発現した producer wiring gap の恒久修正)
Parent Goal Ref
- Goal: issue-refinement-loop の Step 0f preflight が、derivation 可能な missing section を不要に blocked/human_judgment_required にせず、fail-closed 不変条件を維持したまま自動導出を機能させる
- Desired Destination: N/A(単独改善のため parent scope なし)
Current Validated Scope
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.pyに、parent Issue body / current Issue body / trusted anchor comment からknown_scalars/source_spansを assemble する新規関数を追加し、build_structural_repair_bundle()呼び出し(7381 行目付近、現状known_scalars/source_spans引数を一切渡していない)へ配線する.claude/skills/issue-refinement-loop/scripts/repair_issue_contract.pyの既存 derivation 関数(template_value_exact/source_span_exact/derived_scalar_exact、1009-1016 行目付近)を再利用する(新規 derivation 種別は追加しない)source_span_exact.authority_kindの既存 closed enum(parent_issue/owner_anchor/design_reference、repair_issue_contract.py:1205および両 schema)にcurrent_issue(same-body heading alias relocation 専用)を additive extension として追加する.claude/skills/issue-refinement-loop/tests/に positive/negative regression fixture を追加する
Remaining Parent Gaps
- なし
Outcome
run_refinement_preflight.py の Step 0f producer が current Issue body から source_spans(## Proposed Allowed Paths → ## Allowed Paths の closed heading alias relocation のみ、current_issue authority_kind 経由)を実際に抽出し、known_scalars(特に parent_issue)は current Issue body の Machine-Readable Contract / ## Parent Issue heading / trusted anchor comment から解決して build_structural_repair_bundle() に供給するようになり、現在の Issue 本文の semantic-equivalent セクション(## Proposed Allowed Paths → ## Allowed Paths の closed heading alias)から自動導出可能な missing section が auto_apply_safe または source_span_exact として分類されること、かつ fail-closed 不変条件(下記 AC 参照)を後退させないことを、追加した regression test(positive/negative fixture)で確認できる状態。parent Issue body の内容そのものを source_spans の source として assemble することは本 Issue のスコープではない(known_scalars/parent_issue の scalar 解決に限り parent Issue body 相当の source を current-body 経由で扱う)。
同一 Issue 本文内の別セクションを source とするケースは、既存の source_span_exact.authority_kind enum(parent_issue / owner_anchor / design_reference)ではカバーされない(current main 確認済み)ため、current_issue を same-body・closed-heading-alias 専用の additive extension として追加する。これは一般的な Issue-body authority ではなく、下記 AC4 の条件をすべて満たす場合にのみ有効になる狭い契約とする。
Runtime Verification Applicability
- decision: not_applicable
- reason: 本 Issue の変更は producer 関数の純粋 Python ロジック(body/anchor comment のテキスト解析と derivation bundle 生成)であり、pytest による静的検証のみで完結するため
In Scope
run_refinement_preflight.pyへのknown_scalars/source_spansassemble 関数の新規追加、およびbuild_structural_repair_bundle()呼び出しへの配線。source_spansの source は current Issue body のみとし、parent Issue body / trusted anchor comment content からのsource_spansassembly は行わない(known_scalars/parent_issueの scalar 解決に限り、それらを source として使用する)- parent issue number 等の scalar 抽出は既存
derived_scalar_exact判定ロジックを再利用し、parent_issueの解決値をknown_scalarsのparent-issueとmachine-readable-contract.parent_issueの両方の consumer field-id へ供給する source_span_exact.authority_kindの closed enum(Python:repair_issue_contract.pyの_SOURCE_SPAN_AUTHORITY_KINDS、schema:schemas/repair_issue_contract_result_v1.schema.jsonとschemas/refinement_preflight_result_v1.schema.jsonの両方)にcurrent_issueを additive extension として追加する。current_issueは以下をすべて満たす場合のみ有効:source_object_kind == issue_body- source issue == target issue(同一 Issue)
- source body の digest が
original_body_sha256と一致 - closed heading alias table の exact match
- alias section が本文中に exactly once のみ存在
- canonical heading が現在の本文で欠落している
- alias section の内容が canonical heading へ byte-exact コピーされる
- distinct な candidate が複数存在する場合は conflict(fail-closed)
## Proposed Allowed Paths→## Allowed Pathsのみを含む、closed / one-way / exact heading string の alias マッピングテーブルの追加(fuzzy/substring/semantic matching は行わない。他の見出しペアは含めない)known_scalars/parent_issueの scalar 解決において複数 source candidate(current body MRC / current body## Parent Issueheading / trusted anchor comment)がある場合、assembler 側で candidate bytes の exact dedup を行い、distinct bytes が1種類のみなら1候補に畳む(_classify_missing_field()の既存multiple_source_conflict判定ロジック自体は変更しない。distinct bytes が2種類以上の場合は引き続き conflict として扱われる)。source_spansは source が current body 一つのみのため、この dedup はsource_spansには適用されない- human-context / agent-report / unlabeled anchor comment の分類は、
run_refinement_preflight.pyの既存 canonical lane(_resolve_scope_delta_source_kind()等、361-462 行目付近)をそのまま再利用する。新規の trusted-anchor 判定ロジックは追加しない - 上記実装に対する positive/negative regression test を新規追加する(
.claude/skills/issue-refinement-loop/tests/配下、focused 単位でファイル分割する) - 既存の
.claude/skills/issue-refinement-loop/tests/全 suite 実行を Verification Commands 上の baseline merge blocker から advisory(PR review 時の broad regression check)へ変更する(current main で本 Issue のスコープと無関係な pre-existing failure が 3 件存在し、実行時間も約 5 分半かかるため。詳細は Notes for Reviewer 参照)
Out of Scope
repair_issue_contract.pyの derivation model(template_value_exact/source_span_exact/derived_scalar_exact)自体の新規追加(既存 3 種のみを再利用する。ただし上記source_span_exact.authority_kindへのcurrent_issueadditive extension は本 Issue の In Scope である — 既存 derivation 種別の枠組み自体は変更しない)- override policy(anchor comment が missing heading 名を明示的に言及しているかどうかの判定基準)自体の変更
#2426の個別 issue 本文の追加編集(既に手動 contract normalization で個別解決済み)- Step 0f 以外の preflight step の変更
## Proposed Allowed Paths→## Allowed Paths以外の heading alias ペアの追加- 既存の
test_command_registry.py::TestAuthorityTransportPrivilegedExecutorRealSubprocessDispatch系の pre-existing failure(本 Issue のスコープと無関係)の修正
Acceptance Criteria
- AC1:
run_refinement_preflight.pyに、current Issue body(known_scalars の parent_issue 解決は current body MRC / current body## Parent Issueheading / trusted anchor comment からも)から known_scalars / source_spans(source_spans は current-body の heading alias relocation のみ)を assemble する新規関数が実装され、build_structural_repair_bundle() 呼び出しへ配線されている - AC2:
parent_issueの解決値がknown_scalarsのparent-issueとmachine-readable-contract.parent_issueの両方の consumer field-id へ供給される - AC3:
source_span_exact.authority_kindにcurrent_issueが追加され、Python 側_SOURCE_SPAN_AUTHORITY_KINDSと両 schema(repair_issue_contract_result_v1.schema.json/refinement_preflight_result_v1.schema.json)の enum が一致している - AC4:
current_issueauthority は、In Scope に列挙した全条件(same issue / body digest 一致 / closed alias exact match / alias exactly once / canonical heading missing / byte-exact copy / 複数候補時は conflict)を満たす場合にのみ有効になる(positive/negative fixture で確認) - AC5: heading alias は
Proposed Allowed Paths -> Allowed Pathsの closed / one-way の mapping のみで、CommonMark heading normalization 後の case-insensitive exact match(fuzzy/substring/semantic matching は行わない)(negative fixture で確認) - AC6: parent_issue が存在し、current body に heading alias 経由の semantic source が存在し、trusted current-owner reframe が存在するが canonical template heading の一部が欠落しているケースで、不要な
human_judgment_requiredにならずauto_apply_safeまたはsource_span_exactに分類される(positive fixture で確認) - AC7: source authority がないケース、source が複数競合(distinct bytes)するケース、agent-only anchor(human origin と推定されない)のケース、unlabeled anchor のケース、malformed Machine-Readable Contract のケースでは、いずれも fail-closed のまま
human_judgment_required(または既存の block 分類)を維持する(negative fixture で確認) - AC8: unknown issue_kind / template resolution error / checker internal error / authority conflict は引き続き block として扱われる(既存 negative fixture の回帰がないことを確認)
- AC9:
repair_issue_contract.pyに新規 derivation 種別(template_value_exact/source_span_exact/derived_scalar_exact以外)・新規 structural schema model を追加していない(source_span_exact.authority_kindへのcurrent_issueadditive extension を除く)ことを diff で確認する - AC10: 本 Issue で新規追加した positive/negative regression test(focused test file)が PASS する
Verification Commands
- 本 Issue で新規追加する focused regression test(
run_refinement_preflight.pyの production 経路を通し、build_structural_repair_bundle()へ渡される kwargs または最終structural_repair_actionを観測する behavioral test)が PASS することを確認する。実装前はこのテストファイルが存在しないため、このコマンドは baseline で fail する:
# AC1
# AC2
# AC3
# AC4
# AC5
# AC6
# AC7
# AC8
# AC9
# AC10
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_structural_repair_known_scalars_wiring.py -v- 既存 derivation 種別の定義が repair_issue_contract.py に引き続き存在することを確認する regression invariant(新規種別を追加していないことの diff 確認補助。既存 3 種は current main でも既に存在するため baseline で PASS するのが正しい):
# AC9
# baseline-expect: pass
$ rg -n -e DERIVATION_TEMPLATE_VALUE_EXACT -e DERIVATION_SOURCE_SPAN_EXACT -e DERIVATION_DERIVED_SCALAR_EXACT .claude/skills/issue-refinement-loop/scripts/repair_issue_contract.py- 対象ディレクトリ
.claude/skills/issue-refinement-loop/tests/全 suite の broad regression check(PR review 時のみ実行、baseline preflight では skip)。current main で本 Issue と無関係な pre-existing failure が 3 件(test_command_registry.py::TestAuthorityTransportPrivilegedExecutorRealSubprocessDispatch系)存在するため、merge 基準は「zero failure」ではなく「main baseline と比較して new failure = 0」とする:
# AC1
# AC2
# AC3
# AC4
# AC5
# AC6
# AC7
# AC8
# AC9
# AC10
# preflight-scope: pr_review_only
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -vAllowed Paths
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py.claude/skills/issue-refinement-loop/scripts/repair_issue_contract.py.claude/skills/issue-refinement-loop/schemas/repair_issue_contract_result_v1.schema.json.claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.json.claude/skills/issue-refinement-loop/tests/
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合(ただし
source_span_exact.authority_kindへのcurrent_issueadditive extension は In Scope 内であり Stop Condition の対象外) - 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
なし
Required Design References
- .claude/skills/issue-refinement-loop/SKILL.md
- docs/dev/agent-skill-boundaries.md
Scope Delta(該当時のみ記載)
N/A
Delivery Rule
1 Issue = 1 PRを原則とする- worktree を新規作成して作業する(main を直接汚さない)
- Draft PR を既定とする
Notes for Reviewer
- Scope Collision (C1, advisory):
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.pyと.claude/skills/issue-refinement-loop/tests/は多数の OPEN Issue(実装: issue-refinement-loop で scope_collision_check/v1 を消費する #2406, 実装: preflight.run の GH_CONFIG_DIR を command-scoped に伝播する #2403, 実装: route_canonical_step2_result() に verified failure_class ベースの operator intervention route を追加する #2397, 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393, 実装: reviewer transport の command_registry.py に --validate サブコマンドを追加する #2152, 実装: SHA-bound evidence index と command fingerprint budget で再読・重複調査・wait polling による context churn を抑制する #2052, 実装: owner reaction 手順を決定論的 reaction reader/principal resolver/drift checker/mutation consumer として実装する #1975, 実装: 両review loopの人間向けGitHub作業履歴をphase-awareに整理し推奨理由を記録する #1908, 実装: docs/dev/schema-governance.md に REVIEW_COMPACT_INTERMEDIATE_VALIDATION_RESULT_V1 を登録し command_registry.py に phase_state.build.review を追加する #1829, 実装: test(review-compact): Consumer Inventory の taxonomy parity テストを追加する #1812, 実装: fix(replay-taxonomy): readiness rule_id/category を deterministic_domain_key taxonomy に正規化する #1810, 実装:scope_rollup.runをskill_runtime_execのsiblingexactprofileへ統合する #1601, 実装: run_refinement_preflight.py の結果に decisions フィールドを出力しSKILL.mdとのSSOT乖離を解消する #1556, 実装: reviewer_claim_replay.py の taxonomy に RDR001 / VCP_COMMAND_NOT_ALLOWED を追加し parent_replay_binding.py に C9 evidence 経路を追加する #1555, 実装: issue-refinement-loop の SubAgent 起動を planner-declared launch plan に制限する #1288, 実装: fix(issue-refinement-loop): no-human-approval autonomy mode を loop state routing に明示する #1007, 実装: issue-refinement-loop の preflight result から LOOP_STATE を生成する route wrapper を追加し CLI/schema 迷走を防ぐ #1006, feat(agent-ops): issue-contract-fixer SubAgent を追加し、LLM rewrite 前に deterministic contract repair を完了させる #998, feat(issue-refinement-loop): LOOP_ITERATION_CAPSULE_V1 を導入し、raw body / raw log の main context 流入を禁止する #997, 実装: issue-refinement-loop の rewrite routing が既存 blocker contract を consume して non-body-author-fixable blocker を早期停止できるようにする #944, test: scope_signal_guard termination の publisher-level 回帰テストを追加する #926, 実装: decide_rewrite_route.py に --print-schema / --example-input / --from-file を追加し入力 state 契約を self-describe 可能にする #917, 実装: plan_refinement_loop の fail_closed reason code exhaustiveness invariant をテストする(#661 follow-up) #667, 実装: plan_refinement_loop の _extract_missing_contract_keys を PyYAML 不在時に fail-closed にする(#661 follow-up) #666 等)と Allowed Paths が重複する。これは同一ファイルが巨大(9000 行超)で多数の独立した改善が並行進行しているためであり、本 Issue の変更内容(Step 0f producer への known_scalars/source_spans 配線)自体はこれら Issue の scope と意味的に独立している。non_conflict_reason: 本 Issue はbuild_structural_repair_bundle()呼び出し箇所(7381 行目付近)とその直前の assemble ロジックに限定した追加であり、他 Issue が扱う decisions フィールド出力・SubAgent launch plan・reviewer taxonomy 等とは editing region が異なる。実装着手時にgit diffで衝突が顕在化した場合は Scope Delta として記録する。 - 本 Issue は
docs/dev/current-focus.mdの M4 milestone boundary の外側にある issue-refinement-loop 自体のツール改善であり、Fix scope は.claude/skills/issue-refinement-loop/に閉じている - Background で言及した関連 Issue: 実装: Claude-GPT を既存 Latitude project に接続し Native Claude Code と runtime source を識別可能にする #2426(このギャップが実際に発現したケース。実装: Claude-GPT を既存 Latitude project に接続し Native Claude Code と runtime source を識別可能にする #2426 自体は今回すでに手動 contract normalization で個別解決済みであり、本 Issue はそれとは別の恒久修正)
- 2026-08-31 の issue-refinement-loop 実行で
canonical_step2_route: step_5_operator_intervention_required(failure_class: contract_readiness_human_judgment)により一度 human escalation したため(termination report)、readiness 起因の3件の blocker を current main の実測に基づき解消した:- C5 (AC/VC 番号アライメント fail): Acceptance Criteria に
AC1〜AC10の明示番号を付与し、Verification Commands に# AC...marker を対応させた。 Command exceeded timeout: 旧 VC のpytest .claude/skills/issue-refinement-loop/tests/ -vは実測 約5分43秒かかり checker の timeout budget を超過していた。また current main で本 Issue と無関係な pre-existing failure(test_command_registry.py::TestAuthorityTransportPrivilegedExecutorRealSubprocessDispatch系3件)が既に存在することを確認した。full suite 実行は# preflight-scope: pr_review_onlyとして baseline merge blocker から外し、PR review 時の advisory regression check(merge 基準は「main baseline との差分で new failure = 0」)へ変更した。新規追加する focused test(test_structural_repair_known_scalars_wiring.py、AC1-10 対応)を baseline merge blocker とした。Command unexpectedly passed [missing_annotation]: 旧 VC のgrep -n "known_scalars=None" ...は、production コードがknown_scalarsをNoneと明記せず単に引数省略しているため、current main(未修正状態)でも既に no-match(exit 1)であり "修正の証拠" として機能しない broken VC だった(uv run --locked rg -e DERIVATION_...の方は既存3種の存在確認という regression invariant として意図通り baseline PASS するため# baseline-expect: passを付与した)。broken grep VC は削除し、production path 経由の kwargs /structural_repair_actionを直接観測する behavioral test(上記 focused test)へ置換した。
- C5 (AC/VC 番号アライメント fail): Acceptance Criteria に
- heading-equivalence マッピングは
Proposed Allowed Paths -> Allowed Pathsのみに限定した(他の見出しペアは対象外)。 current_issueauthority の追加は.claude/skills/issue-refinement-loop/schemas/repair_issue_contract_result_v1.schema.jsonと.claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.jsonの enum 変更を伴うため、両ファイルを Allowed Paths に追加した。- Scope narrowing (2026-09-01): PR feat: issue-refinement-loop の structural repair producer に known_scalars/source_spans の実抽出を配線する #2469 の human reviewer による REQUEST_CHANGES(comment)の推奨(選択肢1)を受け、Outcome / In Scope / AC1 を実装が実際に行っている「current-body + parent scalar assembly」(
known_scalars/parent_issueは current body MRC / current body## Parent Issueheading / trusted anchor comment から解決、source_spansは current body のProposed Allowed Paths→Allowed Pathsheading alias relocation のみ)に狭めた。owner 判断として、実インシデント 実装: Claude-GPT を既存 Latitude project に接続し Native Claude Code と runtime source を識別可能にする #2426 を閉じるために必要なのはこの範囲のみであり、parent Issue body の追加 fetch や多元 source からのsource_spansassembly machinery は個人開発前提では費用対効果が低いため、追加実装を求めず契約を実装に合わせて narrow した。あわせて AC5 の「exact」の定義を、実装が使用しているリポジトリ既存の casefold() ベースの heading 検出慣行(CommonMark heading normalization 後の case-insensitive exact match)に一致させる形へ修正した(実装側の変更は行わない)。
Activity
squne121 commentedon Aug 31, 2026
結論
判定:
REQUEST_CHANGESです。#2431 の狙い自体は妥当です。現在の production Step 0f は
build_structural_repair_bundle()を呼んでいるものの、実際にknown_scalars/source_spansを渡していません。そのため #995 / PR #2206 で実装済みのsource_span_exact/derived_scalar_exactが、本番経路ではほぼ活用されません。これは確かに wiring gap です。ただし #2431 は、中心ユースケースである **「current Issue body の
Proposed Allowed PathsをAllowed Pathsとして byte-exact 再利用する」ことと、「既存 derivation model/schema は変更しない」**ことを同時に要求しており、現行契約では両立しません。#2431 自身には現時点でコメントがなく、後続の owner clarification もありません。したがって以下は current Issue body と main の実装契約を基準にしたレビューです。
P0 — current Issue body を
source_span_exactにできる authority が存在しないこれは実装前に直すべき blocker です。
現行
repair_issue_contract.pyがsource_span_exactで許す authority は、parent_issueowner_anchordesign_referenceだけです。
current_issueはありません。しかもこれは単なる Python 側のチェックではなく、
structural_repair_action/v1の JSON Schema 側でも同じ closed enum です。一方 #2431 は、
を
source_span_exactで自動導出することを明示的な Outcome / AC にしています。したがって現状のまま実装すると、実装者には次のどれかしかありません。
owner_anchorと偽って provenance を作るdesign_referenceと偽る1/2 は特に避けるべきです。PR #2206 では authority 不明の source span が
auto_apply_safeになる問題が実際に P0 として指摘され、現在の厳密な authority enum に修正された経緯があります。つまり現在の制約は偶然ではありません。推奨修正
新しい derivation mode は不要です。既存
source_span_exactにcurrent_issueauthority を1種類だけ additive に追加するのが一番単純です。ただし
current_issueは一般的な「Issue 本文は全部 authoritative」という意味にはせず、source_object_kind == issue_bodyoriginal_body_sha256という same-body heading relocation 専用にすればよいです。
これはセキュリティ機構の追加ではなく、実際に既にある文字列を同じ Issue 内で見出し名だけ正規化するための provenance 表現です。
その場合、Allowed Paths に少なくとも両 structural schema を追加する必要があります。
そして Out of Scope / Stop Conditions は「新規 derivation mode は禁止。ただし
source_span_exact.authority_kindへのcurrent_issueadditive extension は許可」に変更するのがよいです。P1 —
known_scalarsの key 契約が Issue 本文では不足しているparent_issueを抽出すれば十分、ではありません。Machine-Readable Contract の missing key を修復するとき、producer は内部的に、
という synthetic field ID に変換します。したがって MRC の
parent_issueに必要なのは、です。
現行 validator も、
parent-issueparent_issuemachine-readable-contract.parent_issueを別 key として認識しています。
#2431 の「parent issue number 等の scalar 抽出」という記述だけでは、実装者が、
だけ作ってしまう可能性があります。この場合
## Parent Issueは直せても MRC のparent_issueはhuman_review_requiredのままです。推奨
AC に明記してください。
ここは schema 拡張不要です。
P1 — 複数 source を素直に列挙すると、同値でも conflict になる
現在の
_classify_missing_field()はsource_spans[field_id]が list で 2件以上なら内容を見る前にmultiple_source_conflictにします。#2431 は一度に、
を assemble しようとしています。
例えば parent と owner anchor に同じ
Allowed Pathsが byte-exact に書かれていても、単純に2件渡せば block されます。推奨
classifier を緩める必要はありません。assembler 側で、
としてください。
同値 candidate の代表 provenance を選ぶだけなら、
など固定順で構いません。
重要なのは、内容が違う source に priority を付けて勝手に片方を採用しないことです。異なる内容なら従来どおり human review に落とせばよいです。owner reframe による上書きを実現したいなら、それは既存 override policy の仕事であって、この assembler に新しい supersession policy を作るべきではありません。
P1 — 「trusted anchor」の判定をもう一つ実装してはいけない
このリポジトリにはすでに、anchor が human context なのか agent report なのかを判定する canonical lane があります。
現行
_resolve_scope_delta_source_kind()は、human_context_comment_urlsに明示された URLだけissue_commentgenerated_by_agentgenerated_by_agentとしています。
これは #2431 の、
という AC とほぼ完全に一致しています。
GitHub の comment object 自体にも
user,author_association,updated_atはありますが、既存 control-plane が明示的な human/agent lane を authority としている以上、ここでauthor_association == OWNERのような別判定を追加すると authority が二重化します。GitHub の標準 Issue/comment API が現在の body/comment snapshot とauthor_association/updated_atを返すこと自体は確認できます。([GitHub Docs]1)推奨
assembler は「trusted 判定」をしないでください。
既存 preflight で確定済みの、
を再利用するだけで十分です。
これなら新しい permission gate、署名、ledger、history fetch は一切不要です。
P1 — 現在の Verification Command は修正前から PASS する
#2431 は修正確認として、
grep -n "known_scalars=None" \ .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.pyを提示しています。
しかし現在の production call は
known_scalars=Noneと書いているのではなく、引数自体を省略しています。つまりこの grep は今の broken main でも「何も見つからない」ので、修正の証明になりません。
これは明確に Verification Command を差し替えるべきです。
推奨
grep ではなく behavioral test にします。
最低限、
相当を production-shaped fixture で確認してください。
さらに最終的に、
まで見る方が、引数配線だけの test より強いです。
P1 — 「tests/ 全件 PASS」を merge blocker にするのはこの Issue では重すぎる
#2431 は
.claude/skills/issue-refinement-loop/tests/全体 PASS を AC にしています。一方、直近の structural-repair consumer PR #2400 は同じ test directory 全体を実行し、1829 passed / 4 failed、その4件を clean main でも再現する pre-existing failure / flaky live smoke と記録していました。
もちろん現在の main で既に直っている可能性はあります。しかし、#2431 のような純粋な producer wiring 修正を「巨大 suite が完全ゼロ fail であること」に依存させるのは、個人開発では費用対効果が悪いです。
推奨 gate
merge blocker は例えば以下で十分です。
全 directory は、
程度の advisory regression check に下げるのを勧めます。
なお consumer/mutation 側は PR #2400 ですでに single mutation、stale guard、readback、fresh validation まで実装されています。#2431 で新しい GitHub mutation harness を作る必要はありません。
P2 — heading equivalence は「semantic matching」ではなく closed alias に限定する
#2431 の「semantic-equivalent」という表現は少し危険です。
CommonMark が定義するのは heading や fenced code の構文であって、「Proposed Allowed Paths」と「Allowed Paths」が意味的に同じ、という概念ではありません。ATX heading は最大3 space indent、fenced code は backtick/tilde などかなり細かい構文があります。([CommonMark仕様]2)
現行 producer はすでに fence-aware parsing を持っています。PR #2206 も CommonMark H2 / fenced code を扱うことを設計要件にしています。
したがって新しい assembler で雑な regex parser や fuzzy matching を追加するのは逆効果です。
推奨初期 alias
まず実インシデントで必要になったものだけでよいです。
追加ルールは、
だけにしてください。
LLM による「似た見出し」判定、substring、Levenshtein、言語変換などは不要です。
GitHub Issue Forms でも
label、value、placeholderは別概念で、valueは prefill、placeholderは空欄時の表示にすぎません。現在の exact/placeholder distinction を維持すべきです。([GitHub Docs]3)P2 — provenance は body/comment digest だけ足せば十分
source_span_exactはsource_revisionや source span/digest を要求しています。ここで body edit history の取得、timeline ledger、署名などを追加する必要はありません。
実用上は、
で十分です。
補助的に
updated_atを記録してもよいですが、candidate authority は実際に読んだ bytes の SHA-256 に結び付ける方が明快です。GitHub API の Issue/comment は current snapshot とupdated_atを返すので、追加の history API を引く理由はありません。([GitHub Docs]4)parent Issue のみ必要時に1 fetch、current Issue と anchor は preflight が既に持つ snapshot を再利用する設計を推奨します。
修正後の #2431 はこういう契約がよい
実装着手前に Issue を次の方向へ reframe するのが最も小さいです。
source_span_exact.authority_kindにcurrent_issueを additive 追加する。current_issueは same-body exact heading alias relocation 専用とする。known_scalarsの consumer key mapping、特にmachine-readable-contract.parent_issueを明記する。Proposed Allowed Paths → Allowed Pathsだけの closed map。grep known_scalars=NoneVC を production-shaped behavioral test に置換する。この形なら #2431 の本来の目的である「人間承認が不要なケースまで Step 0f が止まってしまう問題」だけを解決でき、consumer、GitHub mutation、安全ハーネス、意味推論エンジンへスコープを広げずに済みます。
特に PR #2206 → PR #2400 で producer / controlled consumer は既にかなり作り込まれています。#2431 で必要なのは新しい仕組みではなく、source assembly と current-body provenance を正しく埋める最後の狭い配線です。
squne121 commentedon Aug 31, 2026
issue-refinement-loop 終了報告
anchor comment: #2431 (comment)
Step 2 review(
run_root_review_pipeline.py produce)の結果、canonical_step2_route: step_5_operator_intervention_required(failure_class: contract_readiness_human_judgment)に確定しました。これは Issue 本文の書き換えでは解消しない、Verification Commands 実行環境(VC のタイムアウト・想定外の baseline pass)に起因する readiness 問題であり、issue-refinement-loopの Step 4(Rewrite)へは進まず、operator 判断が必要な状態として停止します。検出された blocker
AC1,AC2のような明示的な番号が付与されていないため、check_issue_contract.pyの AC/VC 番号照合が失敗しています。uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -v— 対象ディレクトリのテストスイートが大きいため)が checker 実行の timeout budget を超過しました。grep -n "known_scalars=None" ...またはrg -n -e DERIVATION_...のいずれか)が baseline で予期せず pass しました。これは Issue が「未実装」を前提として書いている VC が、実は現在の main で既に条件を満たしている可能性を示唆します。# baseline-expect: passアノテーション追加、または Issue の Current Validated Scope 記述の見直しが必要です。推奨される次のアクション(人間判断が必要)
known_scalars/source_spansが現状 None 固定のままか(Outcome の前提が現在も成立しているか)をrun_refinement_preflight.pyで確認してください。前提が崩れている場合は Issue の Outcome/AC を更新する必要があります。AC1.,AC2.等の明示番号を付与し、C5 チェックを解消してください。squne121 commentedon Aug 31, 2026
推奨は、今回の
human_escalationをそのまま人間へ返すのではなく、Claude Code 自身を operator として明示的に権限付与し、readiness blocker を解消してから同じ anchor でissue-refinement-loopに再入場させることです。今回の3 blocker は性質がかなり違います。
issue-refinement-loopsuite 用の 420 秒 static policy が既にありますが、policy 登録は.../tests -v、実装: issue-refinement-loop の structural repair producer に known_scalars/source_spans の実抽出を配線する #2431 は.../tests/ -vなので exact match を外しています。さらに、この full suite は PR feat: structural repair actionをcontrolled consumerへ接続する #2400 でも 1829 passed / 4 pre-existing failures だったため、focused tests を merge gate、full suite を PR-review advisory にする方が合理的です。rgは実装前から通って当然です。またknown_scalars=Nonegrep は production call が引数自体を省略しているため、broken main の検証になっていません。production call が実際にknown_scalars/source_spansを渡していないこと自体は main で確認できます。加えて、readiness だけ直して終わりではありません。anchor の本質的な P0、つまり
current_issueauthority が Python と schema の双方に存在しないのに、Issue が current body からのsource_span_exactを要求している矛盾も解消する必要があります。現在の authority enum はparent_issue / owner_anchor / design_referenceのみです。以下をそのまま Claude Code に渡すのがよいです。
対象リポジトリ:
https://github.com/squne121/loop-protocol
対象 Issue:
#2431
refinement の anchor:
#2431 (comment)
直前の termination report:
#2431 (comment)
目的
Issue #2431 の
issue-refinement-loopがcanonical_step2_route: step_5_operator_intervention_requiredで停止した状態を解消してください。
今回の依頼では、前回 Step 5 が要求した operator intervention をあなた自身に委譲します。
人間への追加承認要求は不要です。
まず停止原因を current
mainと canonical checker の実装から再検証し、Issue 本文で解消できる readiness 問題を修正してください。その後、同じ anchor comment を human context としてissue-refinement-loopに再入場し、Issue が実装可能な契約として approve/proceed できるところまで refinement loop を継続してください。これは Issue refinement 作業です。#2431 の実装コードを書いたり実装 PR を作成したりはしないでください。
最重要方針
前回の
step_5_operator_intervention_requiredという routing 結果自体は尊重してください。
ただし、その意味を「必ず実ユーザーへ質問しなければならない」と解釈しないでください。
今回のユーザー指示が operator intervention の実施権限をあなたへ与えています。
したがって、
は人間承認なしで進めて構いません。
一方、以下だけは停止してください。
SubAgent 必須
最初に、少なくとも以下の read-only SubAgent を並列に起動してください。
SubAgent A: codebase / contract investigator
current
mainを対象に以下を確認させてください。.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py.claude/skills/issue-refinement-loop/scripts/repair_issue_contract.py.claude/skills/issue-refinement-loop/schemas/repair_issue_contract_result_v1.schema.json.claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.json.claude/skills/review-issue/scripts/check_issue_contract.py.claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py.claude/skills/issue-refinement-loop/SKILL.md関連 Issue / PR:
確認事項:
build_structural_repair_bundle()call が現在known_scalars/source_spansを渡しているか。source_span_exact.authority_kindの current enum。current_issueauthority の有無。_classify_missing_field()が複数source_spansをどう扱うか。SubAgent は mutation してはいけません。
SubAgent B: Verification/readiness investigator
Issue #2431 の Verification Commands を 1本ずつ current main で評価させてください。
特に以下を確認してください。
unexpected_passなのか。baseline-expectannotation の有無。preflight-scopeannotation の有無。特に次を確認してください。
現行 static timeout policy が
uv run --locked pytest .claude/skills/issue-refinement-loop/tests -vに対して 420 秒を持つ一方、Issue #2431 が
uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -vのように末尾
/を含むため exact-match policy を外していないか。また、
rg -n -e DERIVATION_TEMPLATE_VALUE_EXACT ...は既存3 derivation mode の存在を確認する regression invariant なので、baseline で PASS するのが正常ではないか確認してください。
SubAgent は mutation してはいけません。
SubAgent C: independent Issue contract reviewer
anchor comment 5477623277 と current main の実装を読み、#2431 を実装可能な self-consistent contract にする最小 patch を提案させてください。
特に、
を確認してください。
SubAgent は mutation してはいけません。
JOIN BARRIER
上記 SubAgent 全員の完了を必ず待ってください。
一部 SubAgent が background 実行中の状態で Issue mutation を開始してはいけません。
「バックグラウンド実行中なので後で確認する」で作業を終了してはいけません。
全結果を join してから main thread で判断してください。
SubAgent からさらに nested SubAgent を起動させないでください。
推奨する判断
以下は current main / anchor comment から見て強く推奨される方向です。ただし、実際の current main を確認した結果が異なる場合は current evidence を優先してください。
1. C5 AC/VC numbering を修正する
Acceptance Criteria の各 checkbox に明示的な
AC1AC2を付けてください。
Verification Commands 側も canonical VC grammar が要求する
# AC...marker を付け、AC と VC の参照集合を一致させてください。複数 AC を1 command が検証する場合は、checker がサポートしている grouped AC marker を使用してください。
番号は単に付けるのではなく、「その VC がどの AC を検証しているか」が正しく対応するようにしてください。
2. broken grep VC を behavioral verification に置換する
現在の
grep -n "known_scalars=None" ...を「修正後に grep が空なら成功」とみなす verification として残さないでください。
production call は broken main でも
known_scalars=Noneと明記しておらず、引数を省略しているだけなので、この grep は wiring fix の証拠になりません。代わりに production-shaped pytest で、
run_refinement_preflightproduction path を通すbuild_structural_repair_bundle()へ渡された kwargs を観測する、または最終structural_repair_actionを観測するknown_scalarsが期待値を持つsource_spansが期待値を持つことを確認してください。
より望ましい最終 assertion は、
missing canonical Allowed Paths+
current body に Proposed Allowed Pathsから、
structural_repair_action.items[...]が
disposition == auto_apply_safederivation == source_span_exactになることです。
新規 regression test file の名前は、実際の既存 test organization を確認した上で決めてください。
3. baseline で PASS する invariant VC を正しく annotation する
既存3 derivation mode が増えていないことを確認する
rgのように、修正前から PASS することが正常な regression gate は、canonical syntax に従い command の直前に
# baseline-expect: passを付けてください。
「unexpected pass を消すためだけ」に何でも annotation してはいけません。
その command が本当に baseline PASS を期待する invariant check であることを確認したものだけ対象にしてください。
4. full suite を baseline readiness の blocker にしない
.claude/skills/issue-refinement-loop/tests/全件を baseline refinement 時に毎回走らせる設計は避けてください。推奨:
.claude/skills/issue-refinement-loop/testssuite → PR review 時の broad regression checkfull suite を Verification Commands に残す場合は、canonical grammar に従って
# preflight-scope: pr_review_onlyとして baseline preflight では skip させることを第一候補にしてください。
さらに full suite command を残すなら、repository の static timeout policy と exact match する canonical command textを使ってください。無意味に global timeout を引き上げないでください。
現在の static policy が
tests -vを登録しており Issue がtests/ -vなら、末尾 slash を除去する方向を優先してください。ただし focused suite の方が品質/コスト比が高いなら、full suite は advisory regression check としてください。
PR #2400 で full suite に pre-existing / flaky failure が存在した履歴も考慮し、
「full suite zero failure」
ではなく必要に応じて
「main baseline と比較して new failure = 0」
へ契約を修正してください。
5. anchor comment の P0 を必ず解消する
readiness blocker だけ直して anchor の本質的 blocker を放置してはいけません。
Issue #2431 は現在、
current Issue body の
## Proposed Allowed Pathsを
## Allowed Pathsとして
source_span_exactで byte-exact 再利用することを主要ユースケースにしています。一方 current implementation の
source_span_exact.authority_kindがparent_issueowner_anchordesign_referenceのみで
current_issueを持たないなら、この Issue 契約は自己矛盾しています。その場合、Issue #2431 を次の方向へ reframe してください。
derivation mode
既存3種類
template_value_exactsource_span_exactderived_scalar_exactは維持。
新しい derivation mode は追加しない。
authority
既存
source_span_exact.authority_kindにcurrent_issueを additive extension として追加することを In Scope にする。
ただし
current_issueを一般的な Issue-body authority にしてはいけません。same-body exact heading relocation 専用として、少なくとも次を契約化してください。
source_object_kind == issue_bodyoriginal_body_sha256と一致6. schema scope を修正する
current_issueauthority を additive に追加する必要があるなら、少なくとも以下を Allowed Paths に追加してください。.claude/skills/issue-refinement-loop/schemas/repair_issue_contract_result_v1.schema.json.claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.jsonOut of Scope / Stop Conditions も、
「schema は一切変更禁止」
ではなく、
「新規 derivation mode / 新規 structural schema model は禁止。ただし既存
source_span_exact.authority_kindへのcurrent_issueadditive extension は許可」という契約にしてください。
Python enum と両 schema enum が一致する AC / VC を設けてください。
7. known_scalars の consumer field-id を明示する
parent_issuescalar を解決するとき、単に
parent-issueだけ供給して終わらないことを AC に明記してください。
少なくとも current consumer contract を確認して、
parent-issuemachine-readable-contract.parent_issueなど必要な consumer field-id へ同じ validated scalar を供給してください。
実際に
parent_issue/parent-issue/ MRC synthetic field-id のどれが必要かは current implementation を確認して確定してください。8. source candidate dedup は assembler 側で行う
current classifier が
source_spans[field_id]の list が2件以上なら内容比較前に
multiple_source_conflictへ落とす契約を維持する場合、classifier を緩めないでください。
assembler 側で、
としてください。
異なる内容の source に priority を付けて勝手に片方を採用してはいけません。
同値 source の代表 provenance を選ぶ固定順は deterministic であれば構いません。
9. trusted anchor 判定を再実装しない
assembler 内で
author_association == OWNERなどを使った新しい trusted-anchor 判定を作らないでください。
既存 preflight/control-plane の
classification を再利用してください。
既に取得済みの
human_context_comment_urlsagent_report_comment_urls等を source assembly の入力として使ってください。
新しい permission gate / signature / ledger / history API は不要です。
10. heading equivalence は closed alias に限定する
「semantic equivalent」という曖昧な fuzzy matching は実装契約から排除してください。
初期 alias は実インシデントに必要な
Proposed Allowed Paths -> Allowed Pathsだけを第一候補としてください。
ルール:
11. provenance は実際に読んだ bytes へ束縛する
source provenance は current implementation の schema と整合させてください。
少なくとも body/comment の実 bytes に対する SHA-256 等、producer が実際に読んだ snapshot に bind してください。
新しい audit ledger や body edit history fetch は作らないでください。
Issue 本文 mutation
SubAgent の join 後、上記 evidence を基に Issue #2431 本文を更新してください。
可能なら repository の canonical controlled Issue update path を使ってください。
ただし、今回の operator intervention が canonical patch-plan consumer では表現できず、それ自体が refinement を永久停止させる場合は、Issue #2431 に限定して GitHub CLI/API による body update を使用して構いません。
その場合も、
してください。
同じ body に対する無意味な繰り返し mutation はしないでください。
Mutation 後の deterministic validation
最低限、current canonical entrypoint を使って以下を確認してください。
check_issue_contract.py相当で C1〜C11 を確認unexpected_pass [missing_annotation]が残っていないpr_review_onlyにした場合は baseline で skipped/go になるreadiness artifact が出る場合は summary だけでなく command-level evidence を確認してください。
issue-refinement-loop へ再入場
readiness blocker を解消したら、同じ anchor:
#2431 (comment)
を human context として、
issue-refinement-loopを再度実行してください。ここでも人間承認は不要です。
canonical executor / skill contract を使い、手書きで routing を再実装しないでください。
Step 2 の
canonical_step2_routeを routing authority としてください。step_4→ 自動 rewrite を継続step_2_5→ semantic review / 後続 canonical flow を継続既に今回解決を委譲された
のような Issue-body-expressible 原因で再度止まった場合は、人間へ戻さず自動修正して再実行してください。
ただし、本当に
が確認された場合だけ停止してください。
品質基準
個人趣味開発であるため、形式的な harness 強化そのものを目的にしないでください。
優先順位:
新しい permission framework、ledger、signature system、generic semantic matching engine、GitHub mutation frameworkを作る方向へ広げないでください。
完了条件
次のすべてを満たすまで作業を終了しないでください。
最終報告
最後に簡潔に以下を報告してください。
operator_intervention_requiredになった3 blocker の正確な原因canonical_step2_route人間への「次にこれを実行してください」という handoff で終わらず、権限内で実行可能な作業はすべて現在のセッション内で完了してください。
この方針なら、checker/harness 自体を緩めるのではなく、#2431 の Verification Contract が現行 checker と噛み合っていない部分を直した上で、本来の anchor review を refinement loop に処理させる流れになります。
squne121 commentedon Aug 31, 2026
issue-refinement-loop 再入場・完了報告
anchor: #2431 (comment)
前回 termination report: #2431 (comment)
前回
canonical_step2_route: step_5_operator_intervention_required(failure_class: contract_readiness_human_judgment)で停止した readiness blocker を、current main の実測に基づき解消し、Issue 本文を更新しました。解消した3件の blocker
AC1〜AC10を明示付与し、Verification Commands 側に対応する bare# AC<N>marker を配置。deterministic checker でC5_ac_vc_number_alignment: passを確認。pytest .claude/skills/issue-refinement-loop/tests/ -v(実測 約5分43秒、かつ本 Issue と無関係な pre-existing failure 3件を含む)を# preflight-scope: pr_review_onlyとして baseline blocker から advisory へ変更。baseline ではskippedに分類されることを確認済み。grep known_scalars=NoneVC を削除し、production 経路(build_structural_repair_bundle()への kwargs 供給)を直接観測する focused behavioral test(test_structural_repair_known_scalars_wiring.py、未実装のため baseline では fail)へ置換。既存 derivation 種別の存在確認 VC(rg -e DERIVATION_...)には# baseline-expect: passを付与。主な reframe 内容
source_span_exact.authority_kind(現状parent_issue/owner_anchor/design_referenceの3値。current main で確認済み)に、same-body heading alias relocation 専用のcurrent_issueを additive extension として追加することを In Scope 化(Python enum + 両 schema ファイル、8条件の狭い契約として明記)。known_scalarsのparent_issue解決値をparent-issue/machine-readable-contract.parent_issueの両 consumer field-id へ供給することを AC2 として明記。_classify_missing_field()のmultiple_source_conflict判定自体は変更しないことを明記。Proposed Allowed Paths -> Allowed Pathsの closed / one-way / exact string のみに限定。_resolve_scope_delta_source_kind()等の canonical lane を再利用し、新規判定ロジックを追加しないことを明記。schemas/repair_issue_contract_result_v1.schema.json/schemas/refinement_preflight_result_v1.schema.jsonを追加。SubAgent 調査結果(要約)
3件の read-only SubAgent(コードベース/契約調査、Verification Commands 実測、独立契約レビュー)が current main を実地検証し、上記の reframe 内容が実装(
repair_issue_contract.py、run_refinement_preflight.py、両 schema)と整合することを確認しました。全 SubAgent はファイル・GitHub への mutation を一切行っていません。実行した focused verification
contract_readiness_check.py --mode preflight-static:status: gocheck_c5_ac_vc_alignment():passguard-issue-body.py(edit_issue_txn.py内部 pre-mutation guard):all_passed: truerun_root_review_pipeline.py produce)再実行:deterministic_checks全13項目pass/n/a、findings: []、structured_blockers: []、VERDICT: approve、NEXT_ACTION: proceedfull suite の扱い
# preflight-scope: pr_review_onlyにより baseline merge blocker から除外し、PR review 時の advisory regression check(merge 基準: 「main baseline との差分で new failure = 0」)とした。current main には本 Issue と無関係な pre-existing failure 3件(test_command_registry.py::TestAuthorityTransportPrivilegedExecutorRealSubprocessDispatch系)が存在することを実測で確認済み。最終 canonical_step2_route
step_2_5(Step 2.5 semantic design review の applicability 判定へ進み、semantic_review_trigger.pyの結果semantic_review_applicable: false〈explicit signal なし〉のため Step 2.5 をスキップし、Step 4.5 → 承認終了)。Issue #2431 の最終本文
authoritative readback で
body_sha256: sha256:5628e39fadb56fbdaea07cb7cb88f46e65156ea7cbe18d37be5c1ef552c2e6e1を確認済み(edit_issue_txn.pyの post-mutation readback と、独立したgh apireadback の両方で一致)。残 blocker
なし。deterministic review は
findings: []/structured_blockers: []/VERDICT: approve。この loop 実行についての注記(重要)
この refinement loop は Issue 本文の改善のみを目的としたものであり、実装コードの変更・実装 PR の作成・
impl-review-loopへの自動 handoff は行っていません(呼び出し元の明示的な指示により、LOOP_HANDOFF_RESULT_V1marker の出力とrun_root_transition()の実行を意図的に省略しています)。Issue #2431 はcontract review(issue-contract-review)とimpl-review-loopへの着手が今後必要な、実装可能な状態に到達したという位置づけです。squne121 commentedon Aug 31, 2026
implement-issue: 実装完了 (2026-08-31T12:57:07Z)
.claude/worktrees/issue-2431-known-scalars-wiringworktree-issue-2431-known-scalars-wiringsqune121 commentedon Aug 31, 2026
impl-review-loop: 完了 (2026-08-31T14:05:00Z)
impl-review-loop: 完了 (2026-08-31T14:05:00Z)
fix: current_issue source_span の line range と forged provenance を修正する (…
squne121 commentedon Aug 31, 2026
impl-review-loop: 完了 (2026-09-01T22:57:00Z)
impl-review-loop: 完了 (2026-09-01T22:57:00Z)
feat: issue-refinement-loop の structural repair producer に known_scal…