Skip to content

fix: visual-impact-policy-trusted の trusted-side re-derivation で forged-self-consistent artifact bypass を fail-closed に修正する - #2094

Merged
squne121 merged 4 commits into
mainfrom
worktree-issue-2091-trusted-side-rederivation
Aug 11, 2026
Merged

squne121 merged 4 commits into
mainfrom
worktree-issue-2091-trusted-side-rederivation

Conversation

@squne121

@squne121 squne121 commented Aug 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Issue 調査: visual-impact-policy-trusted の base-locked evaluator が untrusted producer の自己申告 affected_surfaces を re-derive せず、forged-self-consistent artifact で bypass可能 #2090 の調査結果(verify_trusted_artifact() の producer 自己申告 affected_surfaces 受容 bypass、evidence: {} coherent forgery bypass、load_registry_text() の missing-ref-object/missing-file 混同)を実装として反映する。
  • verify_trusted_artifact() を拡張し、trusted side で独立に取得・再計算した base_sha/PR body digest/changed-path digest/base-head registry blob sha/policy_version のいずれかと producer 自己申告 decision を突合するロジックを追加した。
  • evidence: {}(digest claim なし)の coherent forgery は、trusted_rederivation の有無に関わらず常に拒否する(surface_id が正しくても拒否)。
  • resolve_trusted_minimum() を新設し、TS-compiler graph walk(resolve_visual_impact.mjs/Node)を一切使わず、meta-policy path / global invalidator / direct producer・contract path / registry-union mapping deletion / coverage-root boundary の 5 シグナルのみで trusted side から affected surfaces を独立に粗く再計算し、producer の過小申告(affected_surfaces: [] forgery を含む)を検出する。
  • load_registry_text() に MissingRefObjectError を追加し、commit object 不存在(shallow checkout 等)を、file 不存在(正当な bootstrap ケース)と区別して fail-closed にした。
  • .github/workflows/visual-impact-trusted-consumer.yml に、live base_sha 取得・PR body 取得・git diff/git show(候補 PR head の checkout やコード実行は一切行わない、静的データ読み取りのみ)による changed-path/registry の trusted-side独立取得ステップを追加した。

Linked Issue(関連する Issue 番号)

本 PR が close する実装 Issue と、調査結果の正本として参照する research Issue は次の通り。
Closes #2091
Refs #2090

Acceptance Criteria

  • AC1: verify_trusted_artifact() が producer 自己申告に加え、trusted side で独立再計算した値(base_sha/changed-path digest/registry blob sha/policy_version)と突合するロジックを持つ
  • AC2: affected_surfaces: [] を含む forged decision が ok=False として拒否される(test_affected_surfaces_empty_forgery_rejected)
  • AC3: evidence: {} coherent forgery が ok=False として拒否される(test_evidence_empty_coherent_forgery_rejected)
  • AC4: load_registry_text() が missing-ref-object と missing-file を区別し、前者を fail-closed にする(test_missing_ref_object_fail_closed)
  • AC5: 真に visual impact が無い PR の affected_surfaces: [] が引き続き PASS する回帰テストが存在する(test_no_visual_impact_empty_surfaces_pass)
  • AC6: docs/dev/visual-impact.schema.json の affected_surfaces に minItems: 1 が追加されていない
  • AC7: adversarial fixture 5 種(AC2/AC3/AC4 相当 + >3000 files incomplete diff + stale base)が追加されている

Verification(検証)

$ rg -n "base_sha" scripts/agent-ops/resolve_visual_impact.py            # AC1: PASS
$ uv run --locked pytest scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py::test_affected_surfaces_empty_forgery_rejected -v   # AC2: PASS
$ uv run --locked pytest scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py::test_evidence_empty_coherent_forgery_rejected -v   # AC3: PASS
$ uv run --locked pytest scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py::test_missing_ref_object_fail_closed -v             # AC4: PASS
$ uv run --locked pytest scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py::test_no_visual_impact_empty_surfaces_pass -v        # AC5: PASS
$ rg -c "minItems" docs/dev/visual-impact.schema.json   # AC6: 0件(exit 1、追加していないことを確認)
$ uv run --locked pytest scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py -v   # AC7: 26 passed

追加で実行した repository gate(すべて PASS):

$ uv run --locked ruff check .claude/scripts scripts schemas .claude/skills
$ pnpm typecheck
$ pnpm lint
$ pnpm test          # 112 files / 1872 tests passed
$ CI=true pnpm build
$ actionlint .github/workflows/visual-impact-trusted-consumer.yml
$ git diff --check
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py   # 21 passed
$ uv run --locked pytest scripts/agent-ops/tests/test_visual_impact_declaration_parser.py scripts/agent-ops/tests/test_visual_surfaces_schema.py scripts/agent-ops/tests/test_visual_impact_waiver_negative.py scripts/agent-ops/tests/test_visual_impact_declaration_only_never_passes.py scripts/agent-ops/tests/test_visual_impact_baseline_changed_evidence.py scripts/agent-ops/tests/test_visual_impact_waiver_authority.py scripts/agent-ops/tests/test_visual_impact_v2_manifest_seams.py scripts/agent-ops/tests/test_visual_impact_decision_binding.py scripts/agent-ops/tests/test_resolve_visual_impact.py   # 74 passed(regression 無し)

Checks

  • pnpm typecheck
  • pnpm lint
  • pnpm test
  • pnpm build
  • 上記コマンドをすべてローカルで実行し、成功したことを確認した

Allowed Paths Compliance(許可パス遵守)

  • scripts/agent-ops/resolve_visual_impact.py ✅
  • scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py ✅
  • .github/workflows/visual-impact-trusted-consumer.yml ✅
  • docs/dev/visual-impact.schema.json は変更していない(AC6 の minItems 非追加要件をそのまま満たすため無変更)
  • 上記以外のファイルは変更していない(git diff --stat で確認済み)

Schema Change Applicability

  • decision: not_schema_change
  • reason: docs/dev/visual-impact.schema.json(VISUAL_IMPACT_DECISION_V1/VISUAL_IMPACT_DECLARATION_V1 の canonical schema)自体は無変更。verify_trusted_artifact() に追加した trusted_rederivation kwarg はデフォルト None の後方互換追加であり、既存呼び出し元(CLI --mode verify-trusted-artifact の既存フラグ)はそのまま動作する。

Schema Consumer Inventory

N/A(not_schema_change のため)

Visual Impact Declaration(視覚影響申告)

本 PR は UI(DOM/CSS)を変更していないが、scripts/agent-ops/resolve_visual_impact.py と .github/workflows/visual-impact-trusted-consumer.yml が META_POLICY_PATHS(評価器/ポリシー自体のパス)に含まれるため、resolve() の meta_policy_change ルールにより登録済み全 surface が機械的に affected 扱いになる。実際の visual 変更が無いことは component-vrt-report job の実 VRT 実行結果(baseline との差分 0px)で担保される。

schema: VISUAL_IMPACT_DECLARATION_V1
surfaces:
  - surface_id: combat-hud-running
    disposition: verified_unchanged
  - surface_id: combat-hud-critical
    disposition: verified_unchanged

CI Test Performance Decision(CIテストパフォーマンス判定)

CI_TEST_PERFORMANCE_DECISION_V1:
  schema: CI_TEST_PERFORMANCE_DECISION_V1
  issue_number: 2091
  pr_number: null
  decision_scope: ci_change
  changed_paths:
    - scripts/agent-ops/resolve_visual_impact.py
    - scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py
    - .github/workflows/visual-impact-trusted-consumer.yml
  lane_classification:
    fast_static:
      applicable: false
      evidence: []
      required_commands: []
    python_unit:
      applicable: true
      evidence: ["scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py (26 tests, 0.25s)"]
      required_commands: ["uv run --locked pytest scripts/agent-ops/tests/test_visual_impact_trusted_consumer.py -v"]
    contract_artifact:
      applicable: false
      evidence: []
      required_commands: []
    integration:
      applicable: false
      evidence: []
      required_commands: []
  baseline_inputs:
    ci_runtime_baseline_v1_available: false
    run_count: 0
    p50_p95_ready: false
  artifact_consistency:
    ci_test_selection_v1_checked: false
    missing_pytest_args: []
  risk_flags:
    - "visual-impact-trusted-consumer.yml は python-test-plan.json のレーン管理対象外の独立 workflow_run job であり、既存4レーン分類の対象外"
  reviewer_gate:
    approve_allowed: true
    required_evidence:
      - CI_CHECK_RUN_SCOPED
  follow_up_required: []
  • 本 PR は CI 高速化の主張(claim)を行わない(correctness/trust-boundary fix)。既存 python-test レーンへの新規テストは 26 件・0.25 秒で軽微であり、runtime baseline への影響は無視できる。

Safety Claim Matrix

Claim Implemented? Not controlled Evidence Follow-up
producer 自己申告の affected_surfaces: [] を trusted-side 独立再計算で拒否する yes resolve_trusted_minimum() は meta-policy/global-invalidator/direct-producer/mapping-deletion/coverage-boundary のみを判定し、TS-compiler transitive import graph(resolve_visual_impact.mjs)経由でのみ到達可能な surface の過小申告はこの trusted-side 独立検証だけでは検出できない test_affected_surfaces_empty_forgery_rejected PASS #2093
evidence: {} coherent forgery を拒否する yes N/A test_evidence_empty_coherent_forgery_rejected PASS N/A
load_registry_text() の missing-ref-object を fail-closed にする yes N/A test_missing_ref_object_fail_closed, test_missing_ref_object_never_silently_empty_registry_in_resolve PASS N/A
真に visual impact が無い PR の affected_surfaces: [] PASS を維持する yes N/A test_no_visual_impact_empty_surfaces_pass PASS N/A
stale base_sha を拒否する yes N/A test_stale_base_rejected PASS(live base_sha の trusted-side取得は workflow 内 gh api 呼び出しに依存する) N/A
3,000 files 上限・incomplete diff を fail-closed にする yes N/A test_incomplete_changed_paths_rejected PASS(実運用の workflow では REST files API でなく local git diff --name-status を使うため 3,000 件上限自体を設計上回避している) N/A
component-VRT CheckRun の App identity/conclusion の live API 再照合 no 本 PR のスコープでは未実装(Issue #2091 In Scope が「実装可能なら実装、範囲超過なら follow-up」と許容) Issue #2091 In Scope 3rd bullet #2093
full-SHA pinned reusable workflow への移行 no 本 PR のスコープ外(#2090 で要否検討事項として残されていた) Issue #2091 Notes for Reviewer #2093

記載ルール遵守: 本 PR の Summary / title では無限定の safe / read-only / sandboxed / isolated / complete を使用していない。主張は「trusted side で独立に取得・再計算した値との突合」という実装済みの境界に限定している。

Not controlled(制御外事項)

  • TS-compiler transitive import graph 経由でのみ到達可能な surface の trusted-side 独立検証(resolve_visual_impact.mjs の Node/TS 解析を trust boundary に持ち込む設計は本 PR に含まない)
  • component-VRT CheckRun の App identity / conclusion の live Checks API 再照合
  • full-SHA pinned reusable workflow への移行

Follow-up

Notes

squne121 and others added 2 commits August 11, 2026 19:07
…ed-self-consistent artifact bypass を fail-closed に修正する (#2091)

verify_trusted_artifact() を拡張し、affected_surfaces の自己申告受容(bypass1)と
evidence: {} coherent forgery(bypass2)を trusted side からの独立再計算・digest突合で
拒否するようにした。load_registry_text() は commit object 不存在(shallow checkout 等)
と file 不存在を区別し、前者を fail-closed にした(AC4)。resolve_trusted_minimum() が
TS-compiler graph walk なしで meta-policy/global-invalidator/direct-producer/
mapping-deletion/coverage-boundary の各シグナルを trusted side で再計算する。

Refs #2090
@github-actions

Copy link
Copy Markdown
Contributor

Preview URL

✅ verified live assets: https://squne121.github.io/loop-protocol/pr-2094/

The preview will be removed when this PR is closed.

squne121 and others added 2 commits August 11, 2026 19:32
)

meta_policy_change判定によりVISUAL_IMPACT_DECLARATION_V1が必須になったため
PR bodyへ追加したが、body編集単体はsynchronizeイベントを発火しないため
visual-impact-policyジョブが古いスナップショットのまま失敗していた。
新しいPR body内容をCIに取り込むための空コミット。
@squne121

Copy link
Copy Markdown
Owner Author

pr-review-judge 結果: APPROVE

reviewed_head_sha: 712733874d9c80957081b1fc488b25c8e0e04bce

AC1〜AC7 を live diff・独立 pytest 実行(26 tests PASS)・関連 regression 9 file(74 tests)・Allowed Paths gate・required CI(6件 SUCCESS)で検証。blocker なし。

blockers: []
warnings: []

@squne121
squne121 marked this pull request as ready for review August 11, 2026 10:52
@squne121
squne121 merged commit a137e92 into main Aug 11, 2026
38 checks passed
@squne121
squne121 deleted the worktree-issue-2091-trusted-side-rederivation branch August 11, 2026 11:00
squne121 added a commit that referenced this pull request Aug 12, 2026
…トリガー (#2099)

visual-impact-policy job のログにより、空 surfaces:[] では meta_policy_change で
affected 扱いになった combat-hud-critical / combat-hud-running の各エントリが
missing 判定されることが判明した(PR #2094 の既存前例パターンに合わせ、両
surface に disposition: verified_unchanged を明示)。component-vrt-report job の
実 VRT 実行結果(baseline diff 0px)がこの申告の evidence として機能する。
コード変更は含まない。
squne121 added a commit that referenced this pull request Aug 13, 2026
…ility の trusted-side 独立検証を追加する (#2144)

* feat: visual-impact-policy-trusted に TS import graph transitive reachability の trusted-side 独立検証を追加 (#2099)

candidate PR head を checkout/materialize せず、既にfetch済みのgit commit
objectを `git ls-tree`/`git cat-file` で読むだけの base-locked な static
import resolver (`resolve_trusted_transitive_graph()`) を追加し、
`resolve_trusted_minimum()` の trusted 5シグナルに transitive reachability
チェックを追加した (Issue #2099 AC1/AC2)。absolute path / `..` escape /
symlink escape / `/` 始まり specifier は単一の confined resolver で
一貫して拒否し (AC3)、per-file/total bytes・file count・import-hop depth・
wall-clock time それぞれに個別 fail-closed reason code を持つ resource
bound を実装した (AC4)。transitive-only な変更を検出する adversarial
fixture を追加し、`affected_surfaces: []` を forge した producer decision
を trusted-side で確実に reject することを end-to-end で検証する (AC5)。

`.github/workflows/visual-impact-trusted-consumer.yml` の trusted input
取得における `|| true` fail-open を除去し (AC6)、`git show`/`git diff` の
missing-path と genuine plumbing failure を区別する failure taxonomy を
`read_git_blob_at_ref()` として実装した (AC7)。TypeScript dependency の
trusted-side bootstrap は「Node dependency を一切持ち込まない」設計を
採用し、既存の pnpm/npm/npx 禁止 regression と自然に整合する (AC8)。

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* chore: PR本文へ VISUAL_IMPACT_DECLARATION_V1 を追加した再検証トリガー (#2099)

meta_policy_change fail-safe が正しく検出した VISUAL_IMPACT_DECLARATION_V1 欠落
(PR review comment #2144 (comment))
を修正するため PR body を更新した。visual-impact-policy job は
github.event.pull_request.body をイベントトリガー時点の値で評価するため、
本 empty commit で新規 synchronize イベントを発火し、更新済み body で
再評価させる。コード変更は含まない。

* chore: VISUAL_IMPACT_DECLARATION_V1 に verified_unchanged エントリを追加した再検証トリガー (#2099)

visual-impact-policy job のログにより、空 surfaces:[] では meta_policy_change で
affected 扱いになった combat-hud-critical / combat-hud-running の各エントリが
missing 判定されることが判明した(PR #2094 の既存前例パターンに合わせ、両
surface に disposition: verified_unchanged を明示)。component-vrt-report job の
実 VRT 実行結果(baseline diff 0px)がこの申告の evidence として機能する。
コード変更は含まない。

* fix: trusted transitive graph walker の CSS 削除バイパス・素の相対URL・無制限git・plumbing誤分類を修正 (#2099)

PR #2144 レビュー fix_delta (iteration 2, human REQUEST_CHANGES) への対応:

- P1-1: CSS `url()` のターゲットが候補ヘッドで削除/存在しない場合、これまで
  サイレントにグラフから消えていたのを `unresolvable_static_import` として
  fail-closed に報告するよう修正。`resolve_trusted_minimum()` はこれを
  `trusted_transitive_unknown_impact` として affected surface に反映するため、
  偽の `affected_surfaces: []` を検出できる。
- P1-2: CSS `url()`/`@import` の素の相対指定子(`./` プレフィックスなし、
  例 `bg.png`)を JS/TS のバブ import 分類器と区別する
  `_trusted_is_css_relative_specifier()` を新設し、CSS 専用の確認済み
  resolver 経路へルーティング。
- P1-3: TrustedGraphWalker/`git_ls_tree()`/`read_git_blob_at_ref()` の
  git subprocess 呼び出しに、検証全体で共有される単一の絶対デッドラインから
  導出した `timeout=` を付与。スタールした git プロセスが wall-clock
  上限を超えて無期限にブロックすることを防止。
- P1-4: `git ls-tree` / `git cat-file` の真の plumbing 失敗を
  resource-bound-exceeded と区別する新しい `TrustedGitPlumbingError` を
  導入し、`trusted_transitive_git_plumbing_error:*` という別個の理由コード
  として最終判定に反映(Issue #2099 AC7 の 3 分類維持)。

新規リグレッションテスト 10 件を追加(28/28 既存+新規 pass、visual-impact
consumer/schema 76/76 pass、ruff check/format 通過)。

Co-Authored-By: Claude Sonnet 5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
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.

実装: visual-impact-policy-trusted の trusted-side re-derivation で forged-self-consistent artifact bypass を fail-closed に修正する

1 participant