Skip to content

実装: materializerのAllowed Paths正規化をcontract snapshotと統一する #1653

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "ISSUE_SCOPE_SNAPSHOT_V1 materializer と contract snapshot publisher が、同一 Allowed Paths を Markdown 表現に依存せず同じ fingerprint として扱う"
change_kind: code

Parent Issue

none

Parent Goal Ref

  • Goal: materializer の live contract 検証を fail-closed のまま、canonical contract parser と同じ Allowed Paths 正規化規則へ統一する。
  • Desired Destination: backtick 付き・なしの同一 Allowed Paths が同じ SHA-256 となり、既存の有効な contract snapshot を不必要に拒否しない。

Current Validated Scope

  • Issue 実装: protected TEST_VERDICT execution artifact producer を追加する #1646 で、contract snapshot publisher は backtick を除去して allowed_paths_normalized_sha256 を計算した。
  • materialize_issue_scope_snapshot.py の _allowed_paths() は Markdown code span を保持したため、同一7パスが別ハッシュとなり allowed_paths_fingerprint_mismatch で fail-closed した。
  • fail-closed の拒否自体は正しい。修正対象は Markdown 表現の正規化差だけである。

Remaining Parent Gaps

なし

Outcome

materializer が canonical contract-review の Allowed Paths extractor / normalizer と同じ結果を使用し、Markdown code span の有無で fingerprint が変わらない。実際に異なるパス、unsafe path、空の Allowed Paths は従来どおり拒否する。

In Scope

  • materialize_issue_scope_snapshot.py の Allowed Paths 抽出を canonical extractor と整合させる。
  • backtick 付き・なしの同一 Allowed Paths が同じ hash で accepted となる単体テストを追加する。
  • 異なる Allowed Paths hash が引き続き拒否される回帰を固定する。

Out of Scope

Acceptance Criteria

  • AC1: backtick 付きの Allowed Paths を含む live Issue body で、materializer が canonical publisher と同じ normalized hash を計算する。
  • AC2: backtick なしの同一 Allowed Paths は AC1 と同じ hash になり、同一 fingerprint の contract snapshot を受理する。
  • AC3: 正規化後に異なる Allowed Paths を持つ contract snapshot は、従来どおり allowed_paths_fingerprint_mismatch で拒否する。
  • AC4: unsafe path または空の Allowed Paths を受理しない既存 fail-closed 挙動を維持する。

Verification Commands

# AC1
$ uv run --locked pytest scripts/agent-guards/tests/test_materialize_issue_scope_snapshot.py -q
# AC2
$ uv run --locked pytest scripts/agent-guards/tests/test_materialize_issue_scope_snapshot.py -q
# AC3
$ uv run --locked pytest scripts/agent-guards/tests/test_materialize_issue_scope_snapshot.py -q
# AC4
$ uv run --locked pytest scripts/agent-guards/tests/test_materialize_issue_scope_snapshot.py -q

Allowed Paths

  • scripts/agent-guards/materialize_issue_scope_snapshot.py
  • scripts/agent-guards/tests/test_materialize_issue_scope_snapshot.py

Runtime Verification Applicability

decision: not_applicable
reason: fixture-based unit tests validate parser and hash parity without external runtime execution.

Required Design References

  • docs/dev/agent-runtime-ops.md
  • docs/dev/workflow.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • contract snapshot publisher の trust / two-phase publish 変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Scope Collision

Delivery Rule

  • 1 Issue = 1 PR。
  • 実装着手前に fresh CONTRACT_REVIEW_RESULT_V1 status: go を取得する。
  • normal commit / push のみを使用し、force push、hook disable、guard bypass を行わない。

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jul 19, 2026
  2. squne121 commented on Jul 24, 2026

    @squne121
    OwnerAuthor

    #1675 で再現した追加証跡

    #1675 の Scope Repair で、Allowed Paths の同一内容に対して次の2つの parser 差異を確認しました。

    1. backtick+注釈付き bullet は publisher 側と materializer 側の正規化が異なり、allowed_paths_fingerprint_mismatch になった。
    2. ## Allowed Paths 内の非 bullet 説明文は publisher が path として hash する一方、materializer は無視し、同じく allowed_paths_fingerprint_mismatch になった。

    最終的に、Allowed Paths section を raw bullet のみ(説明文・heading は Notes 等へ移動)にする必要がありました。#1675 の fresh snapshot はこの修復を束縛しています: 5073264037, 5073290928, 5073319352。

    期待する修正は canonical parser の共有または完全一致であり、bare bullet / backtick+suffix / section 内 explanatory prose / heading の回帰テストと、異なる path・unsafe path・空 section の fail-closed 維持を含めてください。

    allowed-paths-parser-evidence-1675

  3. squne121 commented on Jul 26, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-26T14:42:59Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1653
      body_sha256: "sha256:9b92ceefafdc743184a7279921c9d8213e59e57b1909c60dad71a96c70812105"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:9b92ceefafdc743184a7279921c9d8213e59e57b1909c60dad71a96c70812105","source_provenance":{"source_type":"github_api","body_file":null}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":2,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_materialize_issue_scope_snapshot.py -q","command_hash":"sha256:cf83b124f91d222b946d05458010d2cedddae20d10586e7ee73f5a4c4856b330","execution_key_hash":"sha256:9eba13e2ce3a6efa7a414f52256e6934b4002962aa72481eceb1c57dac4ee439","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["..................                                                       [100%]","18 passed in 0.07s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":246,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC2","line":2,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_materialize_issue_scope_snapshot.py -q","command_hash":"sha256:cf83b124f91d222b946d05458010d2cedddae20d10586e7ee73f5a4c4856b330","execution_key_hash":"sha256:1fc31912450a5b4cb28324d222b8523eb310af4bc02211127980cacff3821eaa","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["..................                                                       [100%]","18 passed in 0.06s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":247,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC3","line":2,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_materialize_issue_scope_snapshot.py -q","command_hash":"sha256:cf83b124f91d222b946d05458010d2cedddae20d10586e7ee73f5a4c4856b330","execution_key_hash":"sha256:aad11b741d4a208ea34b87b02cfe2bc86db086f833c67e5c094f97b7c976dfb1","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["..................                                                       [100%]","18 passed in 0.06s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":248,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC4","line":2,"raw_command":"uv run --locked pytest scripts/agent-guards/tests/test_materialize_issue_scope_snapshot.py -q","command_hash":"sha256:cf83b124f91d222b946d05458010d2cedddae20d10586e7ee73f5a4c4856b330","execution_key_hash":"sha256:9ec54bc2a233d76221a97c9ff4b1c9a4edcd7d57c2c146bbc1a29d5cf8b08af7","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["..................                                                       [100%]","18 passed in 0.07s"],"stdout_truncated":false,"stdout_original_line_count":3,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":241,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null}]
        declared_path_overlap: {"schema":"declared_path_overlap/v1","advisory":true,"blocking":false,"decision":"advisory_only","disjoint":true,"overlapping_prs":[],"inventory":{"schema":"OPEN_PR_INVENTORY_V1","repo":"squne121/loop-protocol","state":"open","base_ref":"main","base_sha":"36be5ec23dc0043f0b412777e73dfef8e63aa335","draft_policy":"include_drafts","prs":[{"number":1528,"title":"feat(cleanup): 同一実行内の branch-only fallback を追加","base_ref_name":"main","head_ref_name":"worktree-issue-1403-post-merge-cleanup-dedicated-branch-forc","head_ref_oid":"b29007580ae225eb9676c7f32c878ee2bb9ccaa9","is_draft":false,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1528","changed_files_count_graphql":4},{"number":1787,"title":"fix(claude): issue-reviewer compact output hook を追加","base_ref_name":"main","head_ref_name":"worktree-issue-1754-issue-reviewer-subagent-prose-canonical-","head_ref_oid":"8819d4e00b995655fb82f5b066130fb33977c3db","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1787","changed_files_count_graphql":10},{"number":1798,"title":"実装: build_request.py を provider-aware にし、Gemini/AGY/auto の request contract を正しく生成・検証する","base_ref_name":"main","head_ref_name":"worktree-issue-1692-build-request-py-provider-aware-gemini-a","head_ref_oid":"6d4949e4c178dbccc4a429a69cb2d74259860125","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1798","changed_files_count_graphql":7},{"number":1801,"title":"実装: review-issue の structured_blockers を compact_review_result.py の REVIEW_ISSUE_RESULT_V1 スキーマに一致させる (#1791)","base_ref_name":"main","head_ref_name":"worktree-issue-1791-review-issue-structured-blockers-compact","head_ref_oid":"62d5e0e0599872e297959ca3c76abbfddda260b1","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/1801","changed_files_count_graphql":3}],"fetched_count":4,"totalCount":4,"has_next_page":false,"complete":true,"saturated":false,"limit":200,"page_count":1,"inventory_digest":"sha256:35273b7bc5b0bbec72dbc35c73e269a2168836fe53f030e9259c2bc64ad3c7e4","errors":[]},"inventory_digest_extended":"sha256:17e049ee25b8843459ad1ad463b04c7d33fe7d6d1ff20ed24150c615e9207502","errors":[],"note":"changed-file 名の単純な重なりのみを証明する advisory check。3-way merge・hunk 競合・rename/delete 競合は評価しない(実 Git merge 競合の判定は Issue #1792 の PAIRWISE_MERGE_OBSERVATION_V1 producer の責務)。単独では blocking にしない。disjoint は tri-state(true/false/null)— 観測が不完全な場合は null。"}
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: {"issue_number":1653,"contract_source_kind":"issue_comment","contract_source_id":"5083966587","contract_body_sha256":"sha256:9b92ceefafdc743184a7279921c9d8213e59e57b1909c60dad71a96c70812105","allowed_paths_normalized_sha256":"719fedc32fd4277079faaf1205876e5b8c7466804b5b89aeff47557dc354f991","base_ref":"main","base_sha_at_snapshot":"36be5ec23dc0043f0b412777e73dfef8e63aa335"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions