Repository navigation
実装: agent-retrospective に Claude Code・Claude-GPT・repository・GitHub・Web の deterministic source adapter を実装する - #2269
Conversation
…b の deterministic source adapter を実装する (#2236) ADR 0007 と agent_retrospective_run/v1 schema(PR #2266)に整合する CollectorResult (observation/private_evidence の dual-channel)契約で5 source の collector 関数を 実装した。各 collector は source_status/reason_code を独立に返し、typed operational failure のみを fail-independent に吸収する(プログラマバグは run-level fatal として 伝播)。repository adapter は base_sha のみを anchor とし main を再解決しない。 Claude-GPT adapter は PR #2222 の hook-event sink を authority とする。GitHub adapter は Link header pagination + endpoint/page 単位 provenance を持つ。Web adapter は https-only・credential-bearing URL 拒否・private/metadata address 拒否・redirect 再検証の SSRF 防御境界を実装する。private_evidence/observation は secret・raw local path を _scrub() で一律除去する(AC9)。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-2269/ The preview will be removed when this PR is closed. |
結論
P0 — Web SSRF 防御が DNS rebinding / TOCTOU で迂回できる現在は 攻撃者管理ドメインが「pre-check では public IP → 実接続時には さらに 修正必須です。 P1 —
|
… 動的import, resolver programmer bug, GitHub 403/429分類, secret/pathスクラブ強化) 人間 REQUEST_CHANGES (issuecomment-5355112663, reviewed_head_sha 9f2f599) の fix_delta を反映する。 - Web adapter: resolve→validate→connect を単一の `_resolve_pinned_ip` に一体化し、 検証済み IP を `fetch`/`default_https_fetch` まで貫通させることで DNS rebinding/TOCTOU を解消。`default_https_fetch` は urllib opener chain を経由 しない直接ソケット実装へ変更し、`https_proxy`/`http_proxy` 環境変数を一切 参照しない。redirect は hop ごとに同じ境界検証+resolve を再適用する。 - `_load_transport_log_module()`: `exec_module()` 前に `sys.modules` へ登録する 標準 recipe に修正し、Python 3.12 の dataclass 文字列アノテーション解決に 伴う `AttributeError` を解消。real transport_log.py を通す回帰テストを追加。 - `_resolve_pinned_ip`: resolver 呼び出しの catch を `socket.gaierror`/`OSError` のみに限定し、resolver のプログラマバグ(KeyError 等)が `dns_resolution_failed` に誤変換されず run-level fatal として伝播するよう 修正。poison test を追加。 - GitHub adapter: `_classify_github_status()` で 403/429 を status/Retry-After/X-RateLimit-Remaining/エラーボディで分類し `rate_limited` と `permission_denied` を分離。`default_github_fetch_page()` ( `gh api --include` + `X-GitHub-Api-Version` pin) を production 実装として 追加。 - AC9: `_ABS_PATH_RE` を `/tmp/`・`/mnt/`・`/var/`・`/workspace/` と埋め込み 出現にも対応させ、`_safe_diagnostic_text()` の fail-closed allowlist validator を通さない限り diagnostics に自由形式テキスト(str(exc)/stderr 全文)を保持しない設計に変更。 - 推奨 hardening: Claude Code / Claude-GPT adapter は malformed 行が valid evidence と共存する場合 `complete` でなく `partial` (`malformed_response`) を返すよう修正。 regression matrix: DNS rebinding + proxy-env, real transport_log.py dynamic load on Python 3.12, resolver programmer-error propagation, 403/429/rate-header matrix, /tmp・/mnt・embedded path/Authorization leak 検出, valid+malformed runtime evidence の非対称解消 -- すべて追加テストで確認済み(54 tests pass)。 Issue #2236, PR #2269 追加コミット。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
impl-review-loop PR レビュー結果(iteration 1)Mergeability
Evidence Check人間 REQUEST_CHANGES(#2269 (comment) 、reviewed_head_sha 9f2f599)で指摘された P0(SSRF DNS rebinding/TOCTOU)・P1x5(transport_log.py 動的 import、resolver blanket except、GitHub 403/429分類、GitHub production transport 不在、AC9 secret/path 非流出)・推奨 hardening は、現在の head
Blockers
Non-blockers
verdict: REQUEST_CHANGES
reviewed_head_sha: "342178d29f4ae67ea20fc7329fb0b9542cf3ca58"
blockers:
- "PR body Checks/検証コマンド結果 section is stale: reports pre-fix commit 9f2f599e counts (27 new / 74 passed total) rather than post-fix commit 342178d2 actual counts (54 in test_collect_snapshot.py / 101 in full scripts/tests/ dir), and does not document that this head resolves the human REQUEST_CHANGES (P0 SSRF DNS-rebinding/TOCTOU, P1x5). Update PR body to reflect current head's actual verification evidence before this can be treated as merge-ready."
warnings: [] |
Summary
.claude/skills/agent-retrospective/scripts/collect_snapshot.pyを新規追加し、Claude Code・Claude-GPT・repository・GitHub・Web の5 source について独立した collector 関数(collect_claude_code_source/collect_claude_gpt_source/collect_repository_source/collect_github_source/collect_web_source)を実装した(実装: agent-retrospective に Claude Code・Claude-GPT・repository・GitHub・Web の deterministic source adapter を実装する #2236, 導入: Claude-GPT運用ログの継続的レトロスペクティブと改善提案を行う agent-retrospective Skill を確立する #2192 Child 3)。CollectorResult(observation/private_evidenceの dual-channel)を返す。observationはagent_retrospective_run/v1のsource_observationに schema 適合し、private_evidenceは raw normalized records・provenance・diagnostics を保持する invocation-private channel(本 Issue のスコープでは永続化しない)。source_status(complete|partial|unavailable|blocked)と source-specificreason_codeを各 adapter が独立に計算する。typed operational failure(timeout・接続エラー等)のみを_AdapterOperationalErrorとして吸収し、programmer bug(KeyError等)は catch せず run-level fatal として伝播する。Link: rel="next"header に基づく pagination を実装し、endpoint/page 単位の provenance(status・Link・etag・completeness)をprivate_evidenceに記録する。base_sha(40-char full SHA)のみを anchor とし、git ls-tree -r -z --full-tree <base_sha>相当のコマンドのみを実行、mainを内部で再解決しない。completeと判定しない。診断は既存scripts/claude-gpt/transport_log.pyのevaluate_transport_log()(reqId相関ロジック)を再利用する。private_evidence/observationは共通の_scrub()により、secret-shaped key(token/secret/password/authorization/credential/api_key/cookie 等)と絶対ローカルパス文字列(/home/...等)・Authorization-header-shaped 文字列を一律で除去する。.claude/skills/agent-retrospective/scripts/tests/test_collect_snapshot.pyを新規追加(54 test、全 hermetic fixture ベース、live API/git/web 呼び出しなし)。追加コミット(人間 REQUEST_CHANGES 対応, head 342178d)
人間レビュー #2269 (comment) (REQUEST_CHANGES、reviewed_head_sha
9f2f599e)の P0/P1 指摘に対して以下を修正した:_resolve_pinned_ipに一体化し、検証済み IP をfetch/default_https_fetchまで貫通させることで DNS rebinding/TOCTOU を解消。default_https_fetchは urllib opener chain を経由しない直接ソケット実装へ変更し、https_proxy/http_proxy環境変数を一切参照しない。redirect は hop ごとに同じ境界検証+resolve を再適用する。_load_transport_log_module()をexec_module()前にsys.modulesへ登録する標準 recipe に修正し、dataclass 文字列アノテーション解決に伴うAttributeErrorを解消。real transport_log.py を通す回帰テストを追加。_resolve_pinned_ipの resolver 呼び出しの catch をsocket.gaierror/OSErrorのみに限定し、resolver のプログラマバグ(KeyError 等)がdns_resolution_failedに誤変換されず run-level fatal として伝播するよう修正。poison test を追加。_classify_github_status()で 403/429 を status/Retry-After/X-RateLimit-Remaining/エラーボディで分類しrate_limitedとpermission_deniedを分離。default_github_fetch_page()(gh api --include+X-GitHub-Api-Versionpin)を production 実装として追加。_ABS_PATH_REを/tmp/・/mnt/・/var/・/workspace/と埋め込み出現にも対応させ、_safe_diagnostic_text()の fail-closed allowlist validator を通さない限り diagnostics に自由形式テキスト(str(exc)/stderr 全文)を保持しない設計に変更。completeでなくpartial(malformed_response)を返すよう修正。Checks
pnpm typecheck-- 成功(tsc --noEmitエラーなし。本 PR は TS/JS ファイルを一切変更していない)pnpm lint-- 未実行(本 PR は Python-only の変更であり Allowed Paths に TS/JS ファイルを含まない)pnpm test-- 未実行(同上)pnpm build-- 未実行(同上)uv run ruff check .claude/skills/agent-retrospective/scripts/collect_snapshot.py .claude/skills/agent-retrospective/scripts/tests/test_collect_snapshot.py-- All checks passeduv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_collect_snapshot.py-- 54 passed(head342178d2時点、REQUEST_CHANGES 対応の回帰テスト追加を含む)uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/-- 101 passed(test_collect_snapshot.py54 +test_validate_retrospective_schema.py47、同ディレクトリ合計)検証コマンド結果(Verification Commands, Issue #2236)
head
342178d29f4ae67ea20fc7329fb0b9542cf3ca58時点で再実行し確認済み:Runtime Verification Applicability
tmp_path上のログ・注入git_runner/fetch_page/fetch/resolver)で検証しており、live GitHub/Web/git 呼び出しは一切行っていない。live 呼び出しを伴う実地検証は Child 6(live smoke)の責務。Schema Change Applicability
not_schema_change.claude/skills/agent-retrospective/schemas/agent_retrospective_run_v1.schema.jsonは変更していない(Issue 実装: agent-retrospective に Claude Code・Claude-GPT・repository・GitHub・Web の deterministic source adapter を実装する #2236 のスコープ通り、schema そのものは Child 2 で確定済み)。本 PR は同 schema のsource_observationに適合するobservationdict を生成するロジックのみを追加する。Schema Consumer Inventory
N/A(
not_schema_changeのため)。Visual Impact Declaration(視覚影響申告)
N/A(UI/DOM/CSS 変更を含まない)。
Safety Claim Matrix
blockedを返すtest_given_ssrf_boundary_violation_when_collected_then_web_ssrf_boundary_blocks[...non_https_scheme][...credential_bearing_url][...private_or_metadata_address_rejected](169.254.169.254 含む)test_given_dns_rebinding_resolver_when_collected_then_web_ssrf_boundary_resolves_once_and_pins_connect_ip/test_given_dns_rebinding_fixture_when_default_https_fetch_pins_connect_ip_then_second_resolution_never_occurstest_given_redirect_to_private_address_when_collected_then_web_ssrf_boundary_revalidates_redirect_hoptest_given_oversized_response_when_collected_then_web_ssrf_boundary_blocks_response_sizedefault_https_fetch()は直接ソケット実装でread()のみを行い DOM/JS 実行機構を一切持たないdefault_https_fetch(timeout=10.0)の time-based 挙動)default_https_fetch()のtimeoutパラメータは実装済みだが、実タイムアウト発火は live network 依存でありハーメティックテストの対象外dns_resolution_failedに誤変換されず run-level fatal として伝播するtest_given_resolver_programmer_bug_when_collected_then_web_ssrf_boundary_propagates_not_dns_resolution_failedrate_limitedとpermission_deniedに正しく分離するtest_given_github_403_429_status_when_collected_then_rate_limited_vs_permission_denied_classified(7 parametrize)private_evidence/observationは secret-shaped key・絶対ローカルパス(/home・/tmp・/mnt・/var・/workspace埋め込み含む)・Authorization-header-shaped 文字列を含まない-k private_evidence_no_secret_leak12 test PASS-k fail_independent_typed_vs_programmer_error3 test PASS(1つは KeyError の非吸収を確認)mainを内部で再解決しないtest_given_explicit_base_sha_when_collected_then_repository_base_sha_anchor_used_exclusively(呼び出し引数にmain/HEADが含まれないことを assert)Notes
.claude/skills/agent-retrospective/)の source adapter 実装。永続化・index 統合・Skill/SubAgent 呼び出し統合・ETag conditional GET・live smoke は Out of Scope(Child 4/5/6 が担当)。