Skip to content

fix(issue-refinement-loop): trusted scope directive を planner に束縛する - #2083

Merged
squne121 merged 18 commits into
mainfrom
worktree-issue-2055-planner-binding
Aug 13, 2026
Merged

squne121 merged 18 commits into
mainfrom
worktree-issue-2055-planner-binding

Conversation

@squne121

@squne121 squne121 commented Aug 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

#2055 の control-plane 修正を、fresh authoritative contract snapshot と既存 PR #2083 の current head に束縛して更新する。

  • trusted scope-preserving OWNER directive は、raw no_scope_signal でも canonical planner の contract_update_required と anchor-bound CONTRACT_PATCH_PLAN_V1 に到達する。
  • expected_contract_fingerprint は authoritative producer から YAML single-quoted scalar 内の bounded strict JSON mapping として出力し、shared parser がその一形式だけを authority mapping に復号する。
  • このコミットは producer transport に合わせて test_controlled_issue_metadata_exec.py の consumer fixture を更新する。production parser、producer、consumer は変更しない。
  • fresh authoritative snapshot: 実装: pnpm test の Vitest result cache を無効化して canonical executor の write-path deadlock を解消する #2055 (comment)

レビュー指摘への対応(2026-08-12)

OWNER の REQUEST_CHANGES コメント(#2083 (comment) )で指摘された P1×3 / P2×1 に対し、current head b88cdb53… で対応した。

  • P1-1(parser の raw-syntax 検証が authority-bearing node に非束縛): contract_review_result_parser.py の _canonical_single_quoted_json_scalar()(whole-block regex 検索)を廃止。PyYAML path は yaml.compose() の node tree を CONTRACT_REVIEW_RESULT_V1 → expected_contract_fingerprint の exact node path で辿り、その scalar node の style が single-quoted であることを直接確認する(sibling decoy / block-scalar decoy / duplicate key はいずれも reject)。fallback path も同じ indent/path 文脈に限定した state machine に変更。sibling decoy・block-scalar decoy・duplicate key の regression test を PyYAML / forced-fallback 両方に追加。
  • P1-2(falsey evidence が iteration-N で fail-open): plan_refinement_loop.py の scope_delta_authority_evidence presence 判定を、value の truthiness ではなく key の存在(既に外側 if で確認済み)に基づく triggered=True(無条件)に修正し、iteration-zero 分岐と semantics を統一。{} / None / [] / "" の falsey evidence が not_triggered に落ちないことを確認する negative regression test(4パターン parametrize)を追加。既存 fixture の非production形式 body_sha256 も実 sha256 形式に修正。
  • P1-3(fresh authoritative snapshot と main の drift): main(b6a69ebf…、fix(loop): main drift evidence を再束縛する (#2102) #2118 反映後)を再度 merge して BEHIND を解消。merge は conflict なし。旧 snapshot #5259538842 の base_sha_at_snapshot(8d754126…)はもはや fresh ではないため、この PR body の証跡は新しい current-head 検証結果に置き換える(新規 issue-contract-review snapshot の再生成は telemetry advisory であり、本 PR の merge readiness は live Issue 実装: pnpm test の Vitest result cache を無効化して canonical executor の write-path deadlock を解消する #2055 の AC/VC 再検証と required CI で判断する)。
  • P2(overlap advisory の false-negative): 旧 snapshot の declared_path_overlap.disjoint: true は誤りで、PR fix(contract-review): RVA 欠落を fail-closed に統一 #2070(open, draft, worktree-issue-2040-implementation-issue-runtime-verificatio)が ensure_contract_snapshot.py / contract_review_result_parser.py / test_contract_snapshot_author_binding.py / test_ensure_contract_snapshot.py / test_scope_signal_guard_lane_split.py で changed paths が重複する。merge order: fix(issue-refinement-loop): trusted scope directive を planner に束縛する #2083 を先に確定し、fix(contract-review): RVA 欠落を fail-closed に統一 #2070 はその後 rebase する。「overlap なし」を merge-safety evidence として使用しない。

#2055 Outcome(成果)

provenance block を維持したまま、trusted scope-preserving OWNER directive と canonical single-quoted strict JSON fingerprint transport を atomic に維持する。node_modules/.vite/vitest/**/results.json の write provenance は未確認であり、製品 Vitest cache fix、--no-cache、cache 操作、fresh reproduction、provenance の昇格は含まない。

受け入れ条件の達成状況

  • AC1 / AC7: confirmed .pytest_cache/v/cache/nodeids evidence と unconfirmed Vitest result-cache 仮説を混同せず、provenance block を維持した。
  • AC2: trusted directive が planner の contract_update_required と anchor-bound patch plan を生成する回帰を保持した。
  • AC3–AC6: producer / parser / direct consumer / authority postcondition の canonical scalar transport を同一 PR で維持し、今回の fixture もその形式に同期した。
  • AC8: Python control-plane の Ruff 検証を通過し、lint exception は追加していない。

Checks

current head (b88cdb53bee48de332e31bf67928b9cc714fdee0) は OWNER REQUEST_CHANGES の P1-1/P1-2 修正コミット(905b8a55)の上に、main(b6a69ebf…、#2118 反映後)を再 merge して BEHIND を解消したもの。いずれの merge も conflict なし。P1-1/P1-2 の diff は Allowed Paths 内 4 ファイルに限定(git diff --name-status origin/main HEAD で確認済み、全 11 changed files が Allowed Paths 内)。

current head で再実行した検証結果(すべて再実行済み、旧 head の結果を流用しない):

  • AC2: uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py — PASS (65)
  • AC4: uv run pytest .claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py — PASS (83)
  • AC5: uv run pytest .claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.py — PASS (39)
  • AC3: uv run pytest .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py — PASS (116)
  • AC6 / pr-review-only: uv run pytest -m github_live .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot_fingerprint_patch.py — 前回 head で PASS (2)。current head での再実行は fresh independent PR review 内で実施
  • AC7: uv run pytest .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py — PASS (16)
  • AC1: uv run pytest scripts/agent-guards/tests/test_materialize_issue_scope_snapshot.py — PASS (21)
  • AC8: uv run --locked ruff check .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py .claude/skills/issue-contract-review/scripts/contract_review_result_parser.py .claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py — PASS
  • fixture 全体: uv run pytest scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py — PASS (66)

required CI(typecheck / lint / test / build / python-test / validate-generated-artifact)は current head に対して評価中/評価済み。visual-impact-policy-trusted は required status check contexts に含まれず、既知の tracked infra issue(#2076)として non-blocking。

Schema Change Applicability

この変更は authoritative fingerprint transport の schema change である。

- decision: schema_change

Allowed Paths 遵守

  • OWNER REQUEST_CHANGES 対応コミット(905b8a55)の actual changed path: .claude/skills/issue-contract-review/scripts/contract_review_result_parser.py、.claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py、.claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py、.claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py
  • PR 全体の actual changed paths:
    • .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
    • .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py
    • .claude/skills/issue-contract-review/scripts/contract_review_result_parser.py
    • .claude/skills/issue-contract-review/tests/test_contract_review_result_parser.py
    • .claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py
    • .claude/skills/impl-review-loop/scripts/build_intake_capsule.py
    • .claude/skills/impl-review-loop/tests/test_ensure_contract_snapshot.py
    • .claude/skills/impl-review-loop/tests/test_contract_snapshot_author_binding.py
    • .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py
    • scripts/agent-guards/tests/test_materialize_issue_scope_snapshot.py
    • scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py
  • Allowed Paths gate と controlled executor lane で検証する。package.json、tests/vitest-test-discovery-policy.test.ts、実装: repair_action candidate を controlled Issue transaction へ自動適用する main control-plane consumer を追加する #2039、canonical executor、CI workflow、runtime guard は変更していない。

Schema Consumer Inventory

このスキーマ変更の consumer と同期内容は次のとおり。

before: noncanonical fingerprint transport は authority mapping に採用しない。

after: canonical single-quoted strict JSON scalar だけを authority mapping に採用する。

Consumer ファイル 更新有無 備考
ensure_contract_snapshot.py 既存変更を維持 canonical producer
contract_review_result_parser.py 既存変更を維持 strict decoder の SSOT
build_intake_capsule.py 既存変更を維持 direct consumer
test_contract_snapshot_author_binding.py 既存変更を維持 authority postcondition
test_ensure_contract_snapshot.py 既存変更を維持 producer regression
test_build_intake_capsule.py 既存変更を維持 consumer regression
test_controlled_issue_metadata_exec.py single-quoted strict JSON scalar に同期 canonical snapshot consumer fixture

Safety Claim Matrix

本文で扱う safety claim とこの PR が制御しない範囲は次のとおり。

Claim Implemented? Not controlled Evidence Follow-up
canonical fingerprint transport だけを authority mapping に渡す yes 製品 cache 修正、cache 操作、fresh reproduction、provenance 昇格 AC3–AC6 の検証結果と current-head CI #2039 の製品スコープ
trusted OWNER directive を planner に束縛する yes canonical executor、CI workflow、runtime guard AC2 の回帰検証 #2055 の required CI 評価

Provenance Status(provenance の確認状態)

  • source_ref、run_identity、main_sha、command_id、human-context anchor_url、exact results.json path、failure code は同一 immutable authoritative run に未束縛である。
  • provenance は unconfirmed のままであり、この PR は製品 cache 修正の根拠にしない。

Notes

fresh authoritative snapshot と unconfirmed provenance の境界を維持し、本文更新によって製品 Vitest cache fix を追加しない。

CI_TEST_PERFORMANCE_DECISION_V1:
  schema: CI_TEST_PERFORMANCE_DECISION_V1
  issue_number: 2055
  pr_number: 2083
  decision_scope: review_only
  changed_paths: Python control-plane と regression tests
  lane_classification:
    fast_static: {applicable: true, evidence: Ruff PASS と diff check PASS}
    python_unit: {applicable: true, evidence: focused/full fixture と Issue VC PASS}
    contract_artifact: {applicable: true, evidence: producer-parser-consumer contract tests}
    integration: {applicable: false, evidence: product runtime workflow dependency paths は未変更}
  reviewer_gate:
    approve_allowed: false
    required_evidence: [CI_CHECK_RUN_SCOPED, fresh independent PR review]

この変更は対象 Issue を完了させる: Closes #2055

@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #2083 closed).

@squne121
squne121 marked this pull request as ready for review August 11, 2026 12:06
@squne121

Copy link
Copy Markdown
Owner Author

結論

REQUEST_CHANGES 相当です。PR #2083 は現状の HEAD a053be84… のままでは merge 不可と判断します。 CI 自体は当該 HEAD で green ですが、authority/parser 境界に P1 級の欠陥があり、加えて authoritative snapshot と main が既に drift しています。PR 本文自身も approve_allowed: false と fresh independent review を要求しています。

  1. P1 Blocker — canonical fingerprint の raw-syntax 検証が、authority-bearing YAML node に束縛されていません。 _canonical_single_quoted_json_scalar() は YAML document 全体に対して「2-space indent の expected_contract_fingerprint:」を regex 検索し、見つけた payload を _decode_producer_json_scalars() が CONTRACT_REVIEW_RESULT_V1.expected_contract_fingerprint に上書きします。つまり「見つけた single-quoted scalar が本当にその field だったか」を確認していません。

    例えば概念的に次が通り得ます。

CONTRACT_REVIEW_RESULT_V1:
  status: go
  ...
  expected_contract_fingerprint: {"noncanonical":"flow"}

DECOY:
  expected_contract_fingerprint: '<valid 7-key fingerprint JSON>'

PyYAML は上側を flow mapping として読みますが、後段 regex は DECOY 側の canonical-looking scalar を発見し、その値で authority field を置換できます。block scalar の本文に同じ2-space行を置くケースや、同名 YAML key を canonical/noncanonical の2形式で重複させるケースも同系統です。fallback parser も最後に同じ _decode_producer_json_scalars() を通るため、PyYAML 固有ではありません。これは Issue #2055 AC3/AC4 の「その canonical transport だけ」「flow mapping / nested mapping / duplicate key は fail-closed」という契約に直接反します。

YAML 仕様では scalar style は presentation detail であり、mapping key は一意である必要があります。PyYAML は yaml.compose() で MappingNode / ScalarNode、style、start_mark / end_mark を取得できます。したがって regex ではなく CONTRACT_REVIEW_RESULT_V1 → expected_contract_fingerprint という exact node path を compose tree 上で特定し、その scalar node 自身が single-quoted style か確認する実装が適切です。fallback は同じ path/indentation を認識する小さな state machine にし、YAML key 重複も reject すべきです。 ([yaml.org]1) 現在の strict JSON 部分の size/depth 制限、object_pairs_hook による JSON duplicate-key reject、parse_constant による NaN/Infinity reject は妥当なので維持してください。 ([Python documentation]2)

  1. P1 Blocker — falsey な authority evidence が iteration-N だけ fail-open します。 PR の変更箇所は、既に "scope_delta_authority_evidence" in known_context を確認しているにもかかわらず、triggered=bool(_raw_triggered or known_context.get(...)) としています。このため raw delta が no-op で evidence が {} / [] / "" / None の場合、authority sidecar が存在するのに triggered=False になります。 classify_scope_delta_authority(..., triggered=False) は既存テスト上 route.action=not_triggered、implementation_allowed=True です。

    さらに同じ関数の iteration-zero branch は、key presence を見たら無条件に triggered=True としており、現在の2経路で fail-closed semantics が一致していません。 修正は単純で、この branch に入った時点で triggered=True とするのが自然です。少なくとも {}, None, [], "" を raw no_scope_signal と組み合わせ、not_triggered に落ちない negative regression が必要です。今回追加された positive test はこの境界を検証しておらず、しかも body_sha256: "sha256:trusted-directive" という production schema と異なる fixture を使っています。

  2. P1 Merge Gate — 「fresh authoritative snapshot」と current-head CI はもう fresh ではありません。 PR 本文は HEAD a053be84… と base 6b93dbc4…、snapshot #5259538842 を fresh evidence としています。 しかしその snapshot の base_sha_at_snapshot は 8d754126… です。 現在の main は fix(loop): main drift evidence を再束縛する (#2102) #2118 の merge により b6a69ebf… まで進んでいます。 実際、current main と PR HEAD は diverged / 13 ahead / 1 behind です。

    これは単なる「最新 main を取り込んだ方がよい」という話ではありません。ensure_contract_snapshot.py 自身が authoritative GO の再利用条件として base_ref と base_sha_at_snapshot が fresh live base と一致することを要求しています。 したがって repository 自身の authority semantics に従えば、#5259538842 を今なお fresh evidence と扱えません。しかも fix(loop): main drift evidence を再束縛する (#2102) #2118 は plan_refinement_loop.py の production routing を変更しています。current main を取り込み、AC2 targeted test、parser/producer/consumer tests、full Python/required CI を再実行し、新しい contract snapshot と review binding を取り直す必要があります。

  3. P2 — concurrent PR overlap の evidence が false-negative です。 #5259538842 は declared_path_overlap.disjoint: true / overlapping_prs: [] としていますが、その inventory 自体に PR fix(contract-review): RVA 欠落を fail-closed に統一 #2070 が存在します。 fix(contract-review): RVA 欠落を fail-closed に統一 #2070 は現在も open/draft で、ensure_contract_snapshot.py、contract_review_result_parser.py、test_contract_snapshot_author_binding.py、test_ensure_contract_snapshot.py、test_scope_signal_guard_lane_split.py など、fix(issue-refinement-loop): trusted scope directive を planner に束縛する #2083 の Allowed Paths / changed paths と複数重複しています。 advisory check なので単独 blocker ではありませんが、「overlapなし」を merge-safety evidence に使用してはいけません。fix(issue-refinement-loop): trusted scope directive を planner に束縛する #2083 を先に確定して fix(contract-review): RVA 欠落を fail-closed に統一 #2070 をその後 rebase するなど、merge order を明示すべきです。

なお、以前 #2055 の hard predecessor とされていた PR #2104 は現在は merge 済みなので、それ自体はもう blocker ではありません。 一方、GitHub 上の #2083 には現時点で submitted review が 0件です。PR 自身が fresh independent PR review を必須 evidence にしているため、この repository-side gate も未充足です。

修正後に要求したい再検証

最優先は P1-1 の sibling decoy、block-scalar decoy、YAML-level duplicate expected_contract_fingerprint を PyYAML / forced fallback の双方に追加し、build_intake_capsule と verify_snapshot_authority_postcondition まで end-to-end で missing_go / reject になることを固定することです。同時に P1-2 の falsey evidence matrix を追加し、current main を取り込んだ新 HEAD で Issue #2055 の全 VC と required CI を再実行、新しい base_sha_at_snapshot を持つ snapshot を生成してください。

現時点のレビュー判定は REQUEST_CHANGES: P1×3, P2×1 です。 特に P1-1 は AC4 の canonical-transport guarantee そのものを回避できるため、テスト追加だけではなく parser 実装の path-aware 化が必要です。外部 commenter は現在の exact trusted-publisher allowlist により直接 authority を取得できないため P0 までは上げませんが、control-plane 契約としては merge blocker です。

P1-1: contract_review_result_parser.py の
_canonical_single_quoted_json_scalar が YAML block 全体への正規表現検索で
expected_contract_fingerprint の exact node path に束縛されておらず、
sibling decoy / block scalar decoy / duplicate key で authority を
乗っ取れる欠陥を修正。PyYAML path は yaml.compose() で
CONTRACT_REVIEW_RESULT_V1.expected_contract_fingerprint の exact node を
特定して single-quoted style を検証し、fallback path も同じ構造化パース
文脈内で raw scalar を判定する state machine に変更。duplicate key は
両path で SimpleYamlParseError により reject する。

P1-2: plan_refinement_loop.py の scope_delta_authority 呼び出しで
`triggered=bool(_raw_triggered or known_context.get("scope_delta_authority_evidence"))`
が、外側の if で presence 確認済みにもかかわらず evidence 値の
truthiness に依存し、falsy evidence({}/None/[]/"")+no-op raw delta で
fail-open していた欠陥を修正。iteration-zero 分岐と同じ
triggered=True(無条件)に統一。

回帰テストとして sibling decoy / block-scalar decoy / duplicate key
(PyYAML path・forced fallback path 両方)、および falsy evidence 4パターンの
not_triggered 非該当 negative regression test を追加。既存
"sha256:trusted-directive" fixture も本物の 64-hex sha256 形式に修正。
@squne121
squne121 merged commit f23ec00 into main Aug 13, 2026
23 of 24 checks passed
@squne121
squne121 deleted the worktree-issue-2055-planner-binding branch August 13, 2026 10:00
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.

実装: pnpm test の Vitest result cache を無効化して canonical executor の write-path deadlock を解消する

1 participant