Repository navigation
fix(issue-refinement-loop): critical_external_claims 型不一致を build_loop_state.py の境界投影で解消 - #1278
Conversation
…laims を string[] に投影する build_loop_state.py が REFINEMENT_LOOP_PLAN_V1 の critical_external_claims(ExternalClaim[] object 配列)を LOOP_STATE_V1 schema の string[] へ境界投影せずそのまま転記していたため、schema validation が type mismatch で失敗していた。ExternalClaim.claim テキスト のみを抽出する _project_critical_external_claims() を追加し、投影不能な 要素(非 object item・claim 欠落・空文字・非 string)は silent stringify/drop せず status=invalid + errors[] で fail-closed する。 Closes #1277
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-1278/ The preview will be removed when this PR is closed. |
LOOP_VERDICT_V2verdict: APPROVE レビュー所見(pr-review-judge, self-authored PR のため gh pr review 不可、gh pr comment で代替投稿)
|
敵対的レビュー結果判定: REQUEST_CHANGES 寄り。 PR は draft/open、mergeable、head は 参照した主要コンテキストIssue #1277 は、planner 側の repo schema 上も同じ構図です。 外部仕様照合でも、この解釈は正しいです。JSON Schema の 良い点PR は producer 側を 実装も旧コードの単純 Blocking finding 1:
|
pr-review-judge の REQUEST_CHANGES を反映。build_loop_state.py の _project_critical_external_claims() を ExternalClaim schema (claim/affects/source_hint required, additionalProperties: false, affects は Outcome/InScope/AC/VC/StopCondition の enum, source_hint は string|null) の完全検証に強化し、非 dict item・required keys 欠落・ 未定義 property・claim 非 string/空・affects enum 外・source_hint 型不正 のいずれも fail-closed で errors[] に蓄積するようにした。 critical_external_claims キー自体の欠落も missing_required_field で fail-closed にし、web_research_policy_raw が dict でない場合も traceback を出さず structured error を返すようにした。投影値は claim.strip() で出力する。 テストを 9 件追加し、既存 empty/non-string claim ケースにも errors[] の内容を明示的に assert するよう強化した。
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
verdict: APPROVE
reviewed_head_sha: "4e38d3ac7ad81fc976add743675780008273b633"
merge_ready: false
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers: []
required_auto_actions:
- kind: update_pr_body_hygiene
executor: implementation-worker
skill: open-pr.update_pr
blocking_merge_ready: true
mechanical: true
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files:- .claude/skills/issue-refinement-loop/scripts/build_loop_state.py
- .claude/skills/issue-refinement-loop/tests/test_critical_external_claims_builder_projection.py
- .claude/skills/issue-refinement-loop/tests/test_critical_external_claims_producer_contract.py
allowed_paths: - .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
- .claude/skills/issue-refinement-loop/scripts/build_loop_state.py
- .claude/skills/issue-refinement-loop/schemas/loop_state.schema.json
- .claude/skills/issue-refinement-loop/tests/**
violations: []
note: manual path check confirms all 3 files within Allowed Paths scope.
Findings iteration 1
Previous adversarial review findings on the prior head are resolved in current head 4e38d3a.
P1-1 ExternalClaim full validation: the projection helper checks required keys claim/affects/source_hint, rejects unknown extra keys, checks affects enum membership, and checks source_hint is string or null, each as a distinct structured error.
The required-key set and enum constants were diffed against the ExternalClaim definition in the plan schema and match exactly (required list, additionalProperties false, enum values).
P1-2 missing-field and non-dict handling: a missing claims key now produces a missing_required_field diagnostic and stops (no silent empty-list default). A non-dict policy object now produces an invalid_type diagnostic with no unhandled exception (test asserts no traceback in stderr).
The third prior finding, projected value trimming, is addressed: claim text is stripped both for the decision and for the output value, with a dedicated regression test.
The two new test files add 12 test functions in total (11 in the builder-projection file, 1 in the producer-contract file which bundles several related assertions), exceeding the 7 tests requested previously.
New tests individually cover missing required keys, missing source_hint, invalid affects enum value, unknown extra key, missing claims field, non-dict policy object, and whitespace trimming. Re-ran independently: 20 passed with a web_research plus critical-external-claim filter.
Allowed Paths: git diff shows exactly 3 changed files (the modified builder script and 2 new files under the tests directory). The producer script and both schema files are unchanged, matching the linked issue In Scope, Out of Scope, and Stop Conditions.
All six acceptance criteria verification commands were re-run independently and pass.
CI checks are all green and head sha matches.
No blockers remain.
One hygiene gap: the body lacks the standard heading with per-criterion checkboxes and evidence, using separate sections instead that still map each test to its criterion number.
This is not treated as a blocker since coverage is substantively present, but is flagged as the mechanical hygiene action above, keeping merge readiness false until applied. Draft state itself is not a blocker.
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
verdict: APPROVE
reviewed_head_sha: "4e38d3ac7ad81fc976add743675780008273b633"
merge_ready: true
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files:
- .claude/skills/issue-refinement-loop/scripts/build_loop_state.py
- .claude/skills/issue-refinement-loop/tests/test_critical_external_claims_builder_projection.py
- .claude/skills/issue-refinement-loop/tests/test_critical_external_claims_producer_contract.py
allowed_paths:
- .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
- .claude/skills/issue-refinement-loop/scripts/build_loop_state.py
- .claude/skills/issue-refinement-loop/schemas/loop_state.schema.json
- .claude/skills/issue-refinement-loop/tests/**
violations: []
note: manual path check confirms all 3 files within Allowed Paths scope, unchanged from iteration 1.
Findings iteration 1 follow-up
The hygiene action from the previous review has been applied. Re-fetched the body directly: it now contains the standard heading with per-criterion checkboxes for AC1 through AC6, all checked, each with a short evidence note tying it to the corresponding test.
Head sha is unchanged from the prior review, so only the body edit was re-checked, not the code.
CI note: the automated summary tool reported one failed check due to a same-name duplicate check run collision (a skipped run of the same check name, produced by the review-comment webhook, alongside a later successful rerun of that check after the body edit).
The freshest run of that check name at this head sha (started after the body edit, completed 2026-07-02T11:58:22Z) is a success. Overall mergeable status and merge state are still MERGEABLE and CLEAN, which reflect the current, real check state rather than the stale skipped duplicate.
No blockers remain and no further mechanical fixes are needed. Draft state is not a blocker.
post-merge-cleanup: 完了 (2026-07-02T14:35Z)
実行内容:
人間向け残メモ(本 PR とは無関係の一般メンテナンス):
FOLLOW_UP_MATERIALIZATION_RESULT_V1:
schema_version: 1
materialized_by: post-merge-cleanup
follow_up_issues: []
note_only_observations:
- dedupe_key: "note:squne121/loop-protocol:local-git-maintenance:gone-branches"
source_url: "https://github.com/squne121/loop-protocol/pull/1278"
source_note_id: "1"
summary: "gone:true のローカル branch 15 件と stash 28 件はリポジトリ一般メンテナンス対象(本 PR の cleanup 責務外)。" |
概要
build_loop_state.pyがREFINEMENT_LOOP_PLAN_V1.decisions.web_research_policy.critical_external_claims(ExternalClaim[]object 配列)をLOOP_STATE_V1.web_research_policy.critical_external_claims(string[])へ境界投影せずそのまま転記していたため、非空の claim を含む場合に schema validation が type mismatch で失敗する不具合を解消します。本 PR のマージにより対象 Issue を解決します。Closes #1277
変更内容
build_loop_state.pyに_project_critical_external_claims()を追加し、ExternalClaim.claimのテキストのみをstring[]として投影する境界処理を実装。claim欠落・claimが空文字・claimが非 string)は silent stringify / silent drop せず、status=invalid+errors[]を返す fail-closed 処理とした。plan_refinement_loop.pyの_extract_critical_external_claims())の戻り値型は変更していない(Out of Scope)。schemas/loop_state.schema.jsonのcritical_external_claims定義(string[])は既存のまま変更不要だったため変更していない。_project_critical_external_claims()はExternalClaimschema の完全検証(required keys /additionalProperties: false/affectsenum /source_hint型)を行い、critical_external_claimsキー欠落や非 dict のweb_research_policyも structured diagnostics で fail-closed する。投影値はclaim.strip()を用いる。テスト
test_critical_external_claims_producer_contract.py: producer が引き続きExternalClaim[]object 配列を返すことを確認(AC1)。test_critical_external_claims_builder_projection.py: builder の投影処理(AC2)、実際の planner 出力を使った end-to-end schema validation(AC3)、投影不能要素の fail-closed 拒否(AC4)を確認。web_research関連 regression test・critical_external_claimkeyword 判定 regression test が green であることを確認(AC5, AC6)。受け入れ条件の達成状況
_extract_critical_external_claims())はExternalClaim[]object 配列を維持し、refinement_loop_plan_v1.jsonの schema validation を通過する(producer 契約テストで確認)。build_loop_state.pyはExternalClaim[]をstring[]に投影し、各要素はExternalClaim.claimのテキスト(strip 済み)のみになる。critical_external_claimsを含む実 planner 出力を builder に渡し、生成されたLOOP_STATE_V1がloop_state.schema.jsonの jsonschema 検証を例外なく通過する。claim欠落・空文字・非 string、加えてaffects/source_hint欠落・enum 外・型不正・余剰 property)は silent stringify / silent drop せずstatus=invalid+errors[]で fail-closed する。web-research-routing.mdの有無判定ロジックが投影後のstring[]に対して regression していない(-k web_researchgreen)。-k critical_external_claimgreen)。検証コマンド結果
web_research関連 regression を実行し 2 件 pass。uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -q -k "web_research"uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_plan_refinement_loop.py -q -k "critical_external_claim"Allowed Paths 準拠(変更ファイル一覧)
.claude/skills/issue-refinement-loop/scripts/build_loop_state.py(変更).claude/skills/issue-refinement-loop/tests/test_critical_external_claims_producer_contract.py(新規).claude/skills/issue-refinement-loop/tests/test_critical_external_claims_builder_projection.py(新規)Allowed Paths 外のファイル変更はありません。
🤖 本 PR は Claude Code により生成されました。