Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#813"
goal_ref: "context-mode MCP を Claude Code に段階的導入し、大出力を扱う read-only 調査補助として運用する"
change_kind: workflowParent Issue
Parent Goal Ref
#813 の目標「context-mode MCP を Claude Code に段階的導入し、大出力を扱う read-only 調査補助として運用する」に対し、#827 は ctx_fetch_and_index を CTX_FETCH_STRICT=1 と network negative test で隔離し、fetch tool が安全に使えるか使用禁止かを artifact で証明する child 4 である。
mcp__context-mode__ctx_fetch_and_index は #856(PR MERGED)により committed project policy で明示 deny 済みだが、#827 はその deny を維持したまま CTX_FETCH_STRICT=1 が runtime effective であることと URL policy matrix の block 動作を artifact で証明する責務を持つ。これが完了するまで ctx_fetch_and_index は通常運用で使わない。
Current Objective
ctx_fetch_and_index を local / private network への fetch 経路として悪用できないよう、committed deny を維持しつつ CTX_FETCH_STRICT=1 が runtime effective であることを artifact で証明し、URL policy matrix / adversarial cases / mutation test を含む network negative test suite を整備する。
Current Validated Scope
調査完了(2026-06-12)。#856 で mcp__context-mode__ctx_fetch_and_index は project-shared plugin 上に registered され、.claude/settings.json の permissions.deny に明示設定済み(PR MERGED)。context-mode version は v1.0.162 を前提とするが、#827 artifact に version / package path hash / fetched_at を再記録し、1.0.161 との混在を防ぐ。
#827 の実装変更対象:
.claude/artifacts/context-mode/**(fetch-strict negative test artifact、policy snapshot)scripts/test_context_mode_fetch_strict.py(settings.json 構造化 parse / effective strict probe script)tests/context_mode/test_fetch_strict_policy.py(URL policy matrix / adversarial cases / mutation test)tests/context_mode/test_fetch_strict_artifact.py(artifact schema / redaction / stale guard)docs/dev/agent-ops/context-mode-fetch-policy.md(通常利用条件、禁止条件、prompt injection 扱い、cache/purge、実装: context-mode の persistence / purge / ELv2 notice policy を docs 化する #828 依存記録)
upstream context-mode の fetch policy / cache / storage semantics の変更があった場合は Stop Conditions を参照する。
Background
context-mode upstream の README では CTX_FETCH_STRICT=1 により loopback / RFC1918 / ULA などの private network を block できると説明しているが、strict は「追加安全策」であり既定安全ではない(loopback / RFC1918 / ULA は strict なしでは local dev/internal fetch 用に許可される設計)。
loop-protocol の用途では外部 URL fetch は必須ではないため、初期導入では ctx_fetch_and_index を deny したまま、strict が runtime effective であることを負例テストで証明する方針とする。
ctx_fetch_and_index の安全性は「設定上 CTX_FETCH_STRICT が存在する」だけでは証明できない。context-mode process に環境変数が伝達されているか、cache hit で fetch 経路を迂回していないか、redirect/DNS rebinding で private network に到達していないかを artifact で示す必要がある。
#856 で mcp__context-mode__ctx_fetch_and_index は deny 済みだが、runtime probe が必要な場合は commit されない local probe profile のみで一時許可し、probe_profile_committed: false / deny_restored: true を artifact に記録してから deny を復元する。
Outcome
committed deny を維持したまま、CTX_FETCH_STRICT=1 が runtime effective policy として artifact 化され、URL policy matrix(loopback / RFC1918 / ULA / link-local / metadata endpoint variants / adversarial cases)の block 動作が hermetic fixture / stub で証明される。artifact は context_mode_fetch_strict_negative_test_v1 schema を満たし、raw body / credential / token-like value / placeholder を含まない。次の実装者が #827 本文だけを読んで安全な negative test 実装に着手できる。
In Scope
- committed project policy で
mcp__context-mode__ctx_fetch_and_indexが deny のままであることを settings.json 構造化 parse で検証する CTX_FETCH_STRICT=1が設定上だけでなく effective policy として artifact に記録されること(ctx_fetch_strict_configured: true/ctx_fetch_strict_effective: true)- URL classification matrix による negative test(loopback / localhost / RFC1918 / ULA / link-local / metadata endpoint variants)
- adversarial cases(redirect-to-private / DNS-to-private / IPv6-mapped IPv4 / numeric IPv4 / URL credentials / non-http(s) scheme)を fixture / stub で検証する
- loopback trap server を使う場合は block 前に socket 接続されないこと(
server_hit_count: 0) - CI での allowed public URL smoke は classifier-only に限定し、manual network smoke を分離する
CONTEXT_MODE_DIRを isolated temp/root で使い、TTL/cache 汚染を防ぐ(ttl: 0またはforce: true相当)- artifact schema
context_mode_fetch_strict_negative_test_v1の定義と validation(null / pending / unknown /<...>placeholder / raw body / credential を fail とする) - mutation test(
CTX_FETCH_STRICT無効化 / deny entry 除去 / private range blocklist 緩和のいずれかが検出されること) - fetch strict 固有の cleanup proof(isolation + post-test purge)
docs/dev/agent-ops/context-mode-fetch-policy.md作成(通常利用条件、禁止条件、prompt injection 扱い、cache/purge、実装: context-mode の persistence / purge / ELv2 notice policy を docs 化する #828 への依存)- context_mode_version / package path hash / fetched_at を 実装: context-mode ctx_fetch_and_index を CTX_FETCH_STRICT=1 と network negative test で隔離する #827 artifact に再記録する
Out of Scope
- committed
.claude/settings.json上でmcp__context-mode__ctx_fetch_and_indexを allow に変更すること - private / link-local / metadata endpoint への実 network request を送ること
- CI での実 public URL fetch を必須化すること(classifier-only smoke に限定)
- 全体の persistence / purge / ELv2 policy ドキュメント(実装: context-mode の persistence / purge / ELv2 notice policy を docs 化する #828 の責務)
- context-mode binary / source の repo vendoring
Remaining Parent Gaps
- 実装: context-mode の persistence / purge / ELv2 notice policy を docs 化する #828(child 5): context-mode の persistence / purge / ELv2 notice policy を docs 化する
- upstream context-mode feat-storage-add-snapshot-schema-migration-issue-736 #756(
ctx_executeworktree cwd bug)の解消確認後、build/test/git 権限解放を再判断する - child 6(optional): Codex CLI 別 profile への context-mode 限定導入可否を判断する(child 1〜5 完了後)
Required Skills
- Python 3.x:
scripts/test_context_mode_fetch_strict.py実装(settings.json 構造化 parse、artifact schema validation、effective strict probe) - pytest:
tests/context_mode/test_fetch_strict_policy.py(URL matrix / adversarial / mutation)、tests/context_mode/test_fetch_strict_artifact.py(schema / redaction guard) - bash / shell: hermetic loopback trap server(
server_hit_count: 0確認)、isolatedCONTEXT_MODE_DIRセットアップ - JSON schema:
context_mode_fetch_strict_negative_test_v1artifact schema 定義 - context-mode MCP 設定(実装: Claude Code 実験用 profile に context-mode を導入し version / provenance / doctor を検証する #824 / feat: context-mode を実験用 profile に導入し version / doctor / tools / permission を artifact 化する (#824) #856 参照)
Runtime Verification Applicability
decision: deferred
reason: 実装ターゲットファイル(tests/context_mode/test_fetch_strict_policy.py / test_fetch_strict_artifact.py)が未作成のため、VC は実装前には実行不可。実装完了後に全 AC の pytest / test -f / rg を実行して green を確認する。
deferred_destination: PR の Checks セクションに全 AC の pytest / test -f / rg が green であることを記録し、Draft PR レビュー時に確認する。
deferred_verification_condition: 実装 PR の CI / 手動 VC 実行で全 AC の VC が green(exit 0)になること。
applicable_acs: []
execution_environment:
cli_tools:
- uv
- pytest
auth_required: false
network_required: false
notes: hermetic loopback trap server と isolated CONTEXT_MODE_DIR を使用。実 private network への接続は行わない。fake / synthetic URL のみ使用
skip_conditions:
- context-mode plugin not installed (exit 77)
- test files not yet created (expected collection error at baseline)
fallback_policy:
fallback_success_is_pass: false
notes: skip condition を満たす場合もゼロ件 pass を成功とみなさない
artifact_requirements:
- ".claude/artifacts/context-mode/fetch-strict-negative-test.json (schema: context_mode_fetch_strict_negative_test_v1)"Acceptance Criteria
- AC1:
.claude/settings.json/ permission artifact を構造化 parse し、committed project policy ではmcp__context-mode__ctx_fetch_and_indexがdenyのままであることを検証している。rg文字列一致だけでは不可。 - AC2:
CTX_FETCH_STRICT=1が設定上だけでなく effective policy として artifact に記録されている。ctx_fetch_strict_configured: true/ctx_fetch_strict_effective: trueを含む。 - AC3: loopback / localhost / RFC1918 / ULA / link-local / metadata endpoint variants が block されることを URL policy matrix で検証している。実 private network service には接続しない。
- AC4: redirect-to-private、DNS-to-private、IPv6-mapped IPv4、numeric IPv4、URL credentials、non-http(s) scheme の adversarial cases を fixture / stub で検証している。
- AC5: loopback trap server を使う場合、block 前に socket 接続されないことを
server_hit_count: 0として artifact に記録している。 - AC6: allowed public URL は CI 必須の実 fetch にしない。classifier-only smoke と manual network smoke を分離し、manual smoke の SKIP を PASS 扱いしない。
- AC7:
CONTEXT_MODE_DIRは isolated temp/root を使い、TTL/cache 汚染を防ぐためttl: 0またはforce: true相当を artifact に記録している。 - AC8:
.claude/artifacts/context-mode/fetch-strict-negative-test.jsonが schemacontext_mode_fetch_strict_negative_test_v1を満たし、raw HTML/body、URL credential、token-like value、unredacted home path、null、pending、unknown、<...>placeholder を含まない。 - AC9: mutation test で
CTX_FETCH_STRICT無効化、deny entry 除去、private range blocklist 緩和のいずれかが検出される。 - AC10:
docs/dev/agent-ops/context-mode-fetch-policy.mdに通常利用条件、禁止条件、prompt injection 扱い、cache/purge、実装: context-mode の persistence / purge / ELv2 notice policy を docs 化する #828 への依存関係が記録されている。
Verification Commands
# AC1
$ uv run pytest tests/context_mode/test_fetch_strict_policy.py -v -k "committed_deny"
# AC2
$ uv run pytest tests/context_mode/test_fetch_strict_artifact.py -v -k "effective_strict"
# AC3
$ uv run pytest tests/context_mode/test_fetch_strict_policy.py -v -k "url_policy_matrix"
# AC4
$ uv run pytest tests/context_mode/test_fetch_strict_policy.py -v -k "adversarial"
# AC5
$ uv run pytest tests/context_mode/test_fetch_strict_policy.py -v -k "trap_server"
# AC6
$ uv run pytest tests/context_mode/test_fetch_strict_policy.py -v -k "ci_smoke"
# AC7
$ uv run pytest tests/context_mode/test_fetch_strict_policy.py -v -k "isolation"
# AC8
$ uv run pytest tests/context_mode/test_fetch_strict_artifact.py -v
# AC9
$ uv run pytest tests/context_mode/test_fetch_strict_policy.py -v -k "mutation"
# AC10
$ test -f docs/dev/agent-ops/context-mode-fetch-policy.md
$ uv run pytest tests/context_mode/test_fetch_strict_artifact.py -v -k "fetch_policy_docs"Allowed Paths
.claude/settings.json.claude/hooks/**.claude/artifacts/context-mode/**docs/dev/agent-ops/**scripts/test_context_mode_fetch_strict.pytests/context_mode/test_fetch_strict_policy.pytests/context_mode/test_fetch_strict_artifact.pytests/fixtures/context-mode/**
Stop Conditions
- committed
.claude/settings.json上でmcp__context-mode__ctx_fetch_and_indexを allow に変更する必要が出た場合 - private / link-local / metadata endpoint へ実 network request を送らないと検証できない場合
CTX_FETCH_STRICT=1が設定上は存在するが runtime effective であることを証明できない場合- URL classifier / redirect / DNS resolution を hermetic fixture または controlled probe で検証できない場合
- artifact に raw response body、credential 付き URL、token-like value、unredacted home path、
null、pending、unknown、<...>placeholder が含まれる場合 - public URL smoke test が network unavailable で SKIP されたのに PASS として扱われる場合
- context-mode upstream の fetch policy / cache / storage semantics が変わり、既存 test vector の意味が不明になった場合
Delivery Rule
- 1 Issue = 1 PR
- Draft PR 既定
- child 3(調査: context-mode ctx_execute の worktree cwd 安全性を検証し quarantine 方針を固定する #826)完了後に着手することを推奨(worktree cwd 安全性確認後)
Activity
squne121 commentedon Jun 13, 2026
判定: REQUEST_CHANGES
#827 の方向性は正しいです。
ctx_fetch_and_indexは「read-only」に見えても、外部 URL 取得・HTML/Markdown 化・chunk/index・TTL cache を伴うため、SSRF、metadata endpoint 接触、DNS/redirect 経由の private network 到達、外部コンテンツ由来の prompt injection、index 汚染を同時に扱う必要があります。context-mode upstream もctx_fetch_and_indexを URL fetch/index tool として説明し、TTL cache は既定 24h、保存先 content DB、force/ttl指定を持つと説明しています。(GitHub) (GitHub)ただし、現行 #827 は 「
CTX_FETCH_STRICTという文字列がある」「artifact ファイルがある」「docs ファイルがある」だけで pass し得る契約です。#827 本体は open / comments 0 で、AC は localhost/private/ULA/metadata endpoint 風 URL block と artifact/docs を要求していますが、runtime effective strict、実接続未発生、redirect/DNS rebinding、cache bypass、artifact schema、mutation test を要求していません。主要ブロッカー
Severity | 指摘 | 修正方針 -- | -- | -- High | rg -n "CTX_FETCH_STRICT" は AC1 の検証にならない。設定に文字列があっても、context-mode process に有効化されているとは限らない。 | ctx_fetch_strict_configured: true と ctx_fetch_strict_effective: true を artifact に記録し、設定 source と runtime/probe source を分ける。 High | #856 で ctx_fetch_and_index は project-shared plugin 上に registered され、mcp__context-mode__ctx_fetch_and_index は deny されています。#827 は「deny したままどう negative test するか」を定義していない。 | committed policy は deny 維持。runtime probe が必要なら commit されない local probe profile でのみ一時許可し、probe_profile_committed: false / deny_restored: true を artifact 化する。 High | upstream README 上、loopback / RFC1918 / ULA は既定では local dev/internal fetch 用に許可され、CTX_FETCH_STRICT=1 で追加 block される設計です。つまり strict は「追加安全策」であり、既定安全ではない。 | #827 は “strict が設定された” ではなく “strict により block 判定が実効した” ことを証明する Issue にする。(GitHub) High | private network negative test が薄い。127.0.0.1 / localhost / RFC1918 / ULA だけでは、IPv6-mapped IPv4、numeric IPv4、redirect、DNS rebinding、link-local、cloud metadata variants を逃す。 | URL classification matrix を明示し、redirect/DNS は fixture/stub で検証する。実 private service には接続しない。 High | cache が block 結果を偽装し得る。TTL cache hit なら fetch 経路を通らず、strict block の検証にならない。 | isolated CONTEXT_MODE_DIR、unique URL、ttl: 0 または force: true、post-test purge/cleanup を必須化する。(GitHub) High | artifact が存在確認だけ。#825/#826 で既に null / pending / を見落とす問題が出ている。 | context_mode_fetch_strict_negative_test_v1 schema を作り、null / pending / unknown / <...> / token-like value / raw body を fail にする。 Medium | allowed public URL smoke test を CI で実 network にすると、flaky かつ外部 content prompt injection surface になる。 | CI は classifier/surrogate test に限定。実 public fetch は manual/runtime artifact とし、SKIP は PASS にしない。Claude Code docs も外部 content を取る MCP server の prompt injection risk を警告しています。(Claude API Docs) Medium | fetch result の persistence / purge 手順 が #828 と重複。#828 はまだ open です。 | #827 は fetch strict 固有の cleanup proof に絞り、運用 policy は #828 へ hard-link する。 Medium | Allowed Paths に tests/context_mode/** がない。#824/#825/#826 の convention と違い、まともな pytest schema test を入れると contract 違反になる。 | Allowed Paths に tests/context_mode/test_fetch_strict_policy.py と tests/context_mode/test_fetch_strict_artifact.py を追加する。 Medium | version provenance が #827 で再確認されない。#824/#856 は v1.0.162 前提だが、#880 側 artifact 文脈では 1.0.161 が出ており、継承前提は危険。 | context_mode_version, package path hash, fetched_at を #827 artifact に再記録する。#827 の契約修正案
Acceptance Criteria 差し替え
.claude/settings.json/ permission artifact を構造化 parse し、committed project policy ではmcp__context-mode__ctx_fetch_and_indexがdenyのままであることを検証している。rg文字列一致だけでは不可。CTX_FETCH_STRICT=1が設定上だけでなく effective policy として artifact に記録されている。ctx_fetch_strict_configured: true/ctx_fetch_strict_effective: trueを含む。server_hit_count: 0として記録している。CONTEXT_MODE_DIRは isolated temp/root を使い、TTL/cache 汚染を防ぐためttl: 0またはforce: true相当を記録している。.claude/artifacts/context-mode/fetch-strict-negative-test.jsonが schemacontext_mode_fetch_strict_negative_test_v1を満たし、raw HTML/body、URL credential、token-like value、unredacted home path、null、pending、unknown、<...>placeholder を含まない。CTX_FETCH_STRICT無効化、deny entry 除去、private range blocklist 緩和のいずれかが検出される。[ ] AC10:
docs/dev/agent-ops/context-mode-fetch-policy.mdに通常利用条件、禁止条件、prompt injection 扱い、cache/purge、#828 への依存関係が記録されている。Verification Commands 修正
Allowed Paths 修正
.claude/settings.json.claude/hooks/**.claude/artifacts/context-mode/**docs/dev/agent-ops/**scripts/test_context_mode_fetch_strict.pytests/context_mode/test_fetch_strict_policy.pytests/context_mode/test_fetch_strict_artifact.pytests/fixtures/context-mode/**Stop Conditions 追加
context-mode upstream の fetch policy / cache / storage semantics が変わり、既存 test vector の意味が不明になった場合
実装設計の推奨
fetch-strict-negative-test.jsonは最低限この形にしてください。URL matrix は少なくとも次を含めるべきです。
https://example.com/
配布物・ライセンス面の注意
context-mode は Elastic License 2.0 として提供され、利用・fork・modify・distribute は可能だが、hosted/managed service 化や notice removal は禁止と説明されています。#827 では context-mode の source/binary を repo に vendoring せず、installed package の version/hash/provenance を artifact に残すだけに留めるのが安全です。(GitHub)
GitHub secret scanning は git history だけでなく issue / PR descriptions / comments / discussions / wiki / gists も scan 対象です。fetch strict の canary、URL credential、fake token は本物の provider token 形式に似せず、artifact と PR comment に raw secret-like marker を残さない設計にしてください。(GitHub Docs)
最終提案
#827 はこのまま実装に進めず、まず Issue 契約を上記の形へ更新してください。特に committed deny 維持、effective strict 証明、private network への実接続ゼロ、cache/purge 証明、artifact schema test、mutation test が入るまで merge-ready な実装 Issue ではありません。
## 判定: REQUEST_CHANGES#827 の方向性は正しいです。
ctx_fetch_and_indexは「read-only」に見えても、外部 URL 取得・HTML/Markdown 化・chunk/index・TTL cache を伴うため、SSRF、metadata endpoint 接触、DNS/redirect 経由の private network 到達、外部コンテンツ由来の prompt injection、index 汚染を同時に扱う必要があります。context-mode upstream もctx_fetch_and_indexを URL fetch/index tool として説明し、TTL cache は既定 24h、保存先 content DB、force/ttl指定を持つと説明しています。([GitHub]1) ([GitHub]1)ただし、現行 #827 は 「
CTX_FETCH_STRICTという文字列がある」「artifact ファイルがある」「docs ファイルがある」だけで pass し得る契約です。#827 本体は open / comments 0 で、AC は localhost/private/ULA/metadata endpoint 風 URL block と artifact/docs を要求していますが、runtime effective strict、実接続未発生、redirect/DNS rebinding、cache bypass、artifact schema、mutation test を要求していません。主要ブロッカー
rg -n "CTX_FETCH_STRICT"は AC1 の検証にならない。設定に文字列があっても、context-mode process に有効化されているとは限らない。ctx_fetch_strict_configured: trueとctx_fetch_strict_effective: trueを artifact に記録し、設定 source と runtime/probe source を分ける。ctx_fetch_and_indexは project-shared plugin 上に registered され、mcp__context-mode__ctx_fetch_and_indexは deny されています。#827 は「deny したままどう negative test するか」を定義していない。probe_profile_committed: false/deny_restored: trueを artifact 化する。CTX_FETCH_STRICT=1で追加 block される設計です。つまり strict は「追加安全策」であり、既定安全ではない。127.0.0.1/localhost/ RFC1918 / ULA だけでは、IPv6-mapped IPv4、numeric IPv4、redirect、DNS rebinding、link-local、cloud metadata variants を逃す。CONTEXT_MODE_DIR、unique URL、ttl: 0またはforce: true、post-test purge/cleanup を必須化する。([GitHub]1)null/pending/<placeholder>を見落とす問題が出ている。context_mode_fetch_strict_negative_test_v1schema を作り、null/pending/unknown/<...>/ token-like value / raw body を fail にする。allowed public URL smoke testを CI で実 network にすると、flaky かつ外部 content prompt injection surface になる。fetch result の persistence / purge 手順が #828 と重複。#828 はまだ open です。tests/context_mode/**がない。#824/#825/#826 の convention と違い、まともな pytest schema test を入れると contract 違反になる。tests/context_mode/test_fetch_strict_policy.pyとtests/context_mode/test_fetch_strict_artifact.pyを追加する。context_mode_version, package path hash, fetched_at を #827 artifact に再記録する。#827 の契約修正案
Acceptance Criteria 差し替え
Verification Commands 修正
Allowed Paths 修正
Stop Conditions 追加
実装設計の推奨
fetch-strict-negative-test.jsonは最低限この形にしてください。{ "schema": "context_mode_fetch_strict_negative_test_v1", "issue": "#827", "status": "pass", "generated_at": "ISO-8601", "head_sha": "actual commit sha", "context_mode_version": "actual installed version", "policy": { "ctx_fetch_and_index_committed_permission": "deny", "ctx_fetch_strict_configured": true, "ctx_fetch_strict_effective": true, "probe_profile_committed": false, "deny_restored": true }, "network_safety": { "real_private_network_requests": 0, "resolver_mode": "stubbed", "redirect_mode": "fixture", "loopback_trap_server_hit_count": 0 }, "cases": [ { "name": "loopback_ipv4", "input_url_redacted": "http://127.0.0.1:<PORT>/canary", "expected": "blocked_before_connect", "actual": "blocked_before_connect", "cache_hit": false } ], "cache_and_purge": { "context_mode_dir_isolated": true, "ttl_bypass": true, "purge_or_tmpdir_cleanup_verified": true, "post_cleanup_search_hit_count": 0 }, "redaction": { "raw_response_body_absent": true, "url_credentials_absent": true, "token_like_values_absent": true, "home_paths_redacted": true, "placeholders_absent": true }, "mutation_test": { "strict_disabled_detected": true, "deny_removed_detected": true, "private_blocklist_relaxed_detected": true } }URL matrix は少なくとも次を含めるべきです。
配布物・ライセンス面の注意
context-mode は Elastic License 2.0 として提供され、利用・fork・modify・distribute は可能だが、hosted/managed service 化や notice removal は禁止と説明されています。#827 では context-mode の source/binary を repo に vendoring せず、installed package の version/hash/provenance を artifact に残すだけに留めるのが安全です。([GitHub]1)
GitHub secret scanning は git history だけでなく issue / PR descriptions / comments / discussions / wiki / gists も scan 対象です。fetch strict の canary、URL credential、fake token は本物の provider token 形式に似せず、artifact と PR comment に raw secret-like marker を残さない設計にしてください。([GitHub Docs]3)
最終提案
#827 はこのまま実装に進めず、まず Issue 契約を上記の形へ更新してください。特に committed deny 維持、effective strict 証明、private network への実接続ゼロ、cache/purge 証明、artifact schema test、mutation test が入るまで merge-ready な実装 Issue ではありません。
1: https://github.com/mksglu/context-mode "GitHub - mksglu/context-mode: Context window optimization for AI coding agents. Sandboxes tool output, 98% reduction. 15 platforms · GitHub"
2: https://docs.anthropic.com/en/docs/claude-code/mcp "Connect Claude Code to tools via MCP - Claude Code Docs"
3: https://docs.github.com/en/code-security/secret-scanning/introduction/about-secret-scanning "Secret scanning - GitHub Docs"ody>
判定: REQUEST_CHANGES
#827 の方向性は正しいです。
ctx_fetch_and_indexは「read-only」に見えても、外部 URL 取得・HTML/Markdown 化・chunk/index・TTL cache を伴うため、SSRF、metadata endpoint 接触、DNS/redirect 経由の private network 到達、外部コンテンツ由来の prompt injection、index 汚染を同時に扱う必要があります。context-mode upstream もctx_fetch_and_indexを URL fetch/index tool として説明し、TTL cache は既定 24h、保存先 content DB、force/ttl指定を持つと説明しています。(GitHub) (GitHub)ただし、現行 #827 は 「
CTX_FETCH_STRICTという文字列がある」「artifact ファイルがある」「docs ファイルがある」だけで pass し得る契約です。#827 本体は open / comments 0 で、AC は localhost/private/ULA/metadata endpoint 風 URL block と artifact/docs を要求していますが、runtime effective strict、実接続未発生、redirect/DNS rebinding、cache bypass、artifact schema、mutation test を要求していません。主要ブロッカー
#827 の契約修正案
Acceptance Criteria 差し替え
.claude/settings.json/ permission artifact を構造化 parse し、committed project policy ではmcp__context-mode__ctx_fetch_and_indexがdenyのままであることを検証している。rg文字列一致だけでは不可。CTX_FETCH_STRICT=1が設定上だけでなく effective policy として artifact に記録されている。ctx_fetch_strict_configured: true/ctx_fetch_strict_effective: trueを含む。server_hit_count: 0として記録している。CONTEXT_MODE_DIRは isolated temp/root を使い、TTL/cache 汚染を防ぐためttl: 0またはforce: true相当を記録している。.claude/artifacts/context-mode/fetch-strict-negative-test.jsonが schemacontext_mode_fetch_strict_negative_test_v1を満たし、raw HTML/body、URL credential、token-like value、unredacted home path、null、pending、unknown、<...>placeholder を含まない。CTX_FETCH_STRICT無効化、deny entry 除去、private range blocklist 緩和のいずれかが検出される。[ ] AC10:
docs/dev/agent-ops/context-mode-fetch-policy.mdに通常利用条件、禁止条件、prompt injection 扱い、cache/purge、#828 への依存関係が記録されている。Verification Commands 修正
Allowed Paths 修正
.claude/settings.json.claude/hooks/**.claude/artifacts/context-mode/**docs/dev/agent-ops/**scripts/test_context_mode_fetch_strict.pytests/context_mode/test_fetch_strict_policy.pytests/context_mode/test_fetch_strict_artifact.pytests/fixtures/context-mode/**Stop Conditions 追加
context-mode upstream の fetch policy / cache / storage semantics が変わり、既存 test vector の意味が不明になった場合
実装設計の推奨
fetch-strict-negative-test.jsonは最低限この形にしてください。URL matrix は少なくとも次を含めるべきです。
https://example.com/
配布物・ライセンス面の注意
context-mode は Elastic License 2.0 として提供され、利用・fork・modify・distribute は可能だが、hosted/managed service 化や notice removal は禁止と説明されています。#827 では context-mode の source/binary を repo に vendoring せず、installed package の version/hash/provenance を artifact に残すだけに留めるのが安全です。(GitHub)
GitHub secret scanning は git history だけでなく issue / PR descriptions / comments / discussions / wiki / gists も scan 対象です。fetch strict の canary、URL credential、fake token は本物の provider token 形式に似せず、artifact と PR comment に raw secret-like marker を残さない設計にしてください。(GitHub Docs)
最終提案
#827 はこのまま実装に進めず、まず Issue 契約を上記の形へ更新してください。特に committed deny 維持、effective strict 証明、private network への実接続ゼロ、cache/purge 証明、artifact schema test、mutation test が入るまで merge-ready な実装 Issue ではありません。
## 判定: REQUEST_CHANGES#827 の方向性は正しいです。
ctx_fetch_and_indexは「read-only」に見えても、外部 URL 取得・HTML/Markdown 化・chunk/index・TTL cache を伴うため、SSRF、metadata endpoint 接触、DNS/redirect 経由の private network 到達、外部コンテンツ由来の prompt injection、index 汚染を同時に扱う必要があります。context-mode upstream もctx_fetch_and_indexを URL fetch/index tool として説明し、TTL cache は既定 24h、保存先 content DB、force/ttl指定を持つと説明しています。([GitHub]1) ([GitHub]1)ただし、現行 #827 は 「
CTX_FETCH_STRICTという文字列がある」「artifact ファイルがある」「docs ファイルがある」だけで pass し得る契約です。#827 本体は open / comments 0 で、AC は localhost/private/ULA/metadata endpoint 風 URL block と artifact/docs を要求していますが、runtime effective strict、実接続未発生、redirect/DNS rebinding、cache bypass、artifact schema、mutation test を要求していません。主要ブロッカー
rg -n "CTX_FETCH_STRICT"は AC1 の検証にならない。設定に文字列があっても、context-mode process に有効化されているとは限らない。ctx_fetch_strict_configured: trueとctx_fetch_strict_effective: trueを artifact に記録し、設定 source と runtime/probe source を分ける。ctx_fetch_and_indexは project-shared plugin 上に registered され、mcp__context-mode__ctx_fetch_and_indexは deny されています。#827 は「deny したままどう negative test するか」を定義していない。probe_profile_committed: false/deny_restored: trueを artifact 化する。CTX_FETCH_STRICT=1で追加 block される設計です。つまり strict は「追加安全策」であり、既定安全ではない。127.0.0.1/localhost/ RFC1918 / ULA だけでは、IPv6-mapped IPv4、numeric IPv4、redirect、DNS rebinding、link-local、cloud metadata variants を逃す。CONTEXT_MODE_DIR、unique URL、ttl: 0またはforce: true、post-test purge/cleanup を必須化する。([GitHub]1)null/pending/<placeholder>を見落とす問題が出ている。context_mode_fetch_strict_negative_test_v1schema を作り、null/pending/unknown/<...>/ token-like value / raw body を fail にする。allowed public URL smoke testを CI で実 network にすると、flaky かつ外部 content prompt injection surface になる。fetch result の persistence / purge 手順が #828 と重複。#828 はまだ open です。tests/context_mode/**がない。#824/#825/#826 の convention と違い、まともな pytest schema test を入れると contract 違反になる。tests/context_mode/test_fetch_strict_policy.pyとtests/context_mode/test_fetch_strict_artifact.pyを追加する。context_mode_version, package path hash, fetched_at を #827 artifact に再記録する。#827 の契約修正案
Acceptance Criteria 差し替え
Verification Commands 修正
Allowed Paths 修正
Stop Conditions 追加
実装設計の推奨
fetch-strict-negative-test.jsonは最低限この形にしてください。{ "schema": "context_mode_fetch_strict_negative_test_v1", "issue": "#827", "status": "pass", "generated_at": "ISO-8601", "head_sha": "actual commit sha", "context_mode_version": "actual installed version", "policy": { "ctx_fetch_and_index_committed_permission": "deny", "ctx_fetch_strict_configured": true, "ctx_fetch_strict_effective": true, "probe_profile_committed": false, "deny_restored": true }, "network_safety": { "real_private_network_requests": 0, "resolver_mode": "stubbed", "redirect_mode": "fixture", "loopback_trap_server_hit_count": 0 }, "cases": [ { "name": "loopback_ipv4", "input_url_redacted": "http://127.0.0.1:<PORT>/canary", "expected": "blocked_before_connect", "actual": "blocked_before_connect", "cache_hit": false } ], "cache_and_purge": { "context_mode_dir_isolated": true, "ttl_bypass": true, "purge_or_tmpdir_cleanup_verified": true, "post_cleanup_search_hit_count": 0 }, "redaction": { "raw_response_body_absent": true, "url_credentials_absent": true, "token_like_values_absent": true, "home_paths_redacted": true, "placeholders_absent": true }, "mutation_test": { "strict_disabled_detected": true, "deny_removed_detected": true, "private_blocklist_relaxed_detected": true } }URL matrix は少なくとも次を含めるべきです。
配布物・ライセンス面の注意
context-mode は Elastic License 2.0 として提供され、利用・fork・modify・distribute は可能だが、hosted/managed service 化や notice removal は禁止と説明されています。#827 では context-mode の source/binary を repo に vendoring せず、installed package の version/hash/provenance を artifact に残すだけに留めるのが安全です。([GitHub]1)
GitHub secret scanning は git history だけでなく issue / PR descriptions / comments / discussions / wiki / gists も scan 対象です。fetch strict の canary、URL credential、fake token は本物の provider token 形式に似せず、artifact と PR comment に raw secret-like marker を残さない設計にしてください。([GitHub Docs]3)
最終提案
#827 はこのまま実装に進めず、まず Issue 契約を上記の形へ更新してください。特に committed deny 維持、effective strict 証明、private network への実接続ゼロ、cache/purge 証明、artifact schema test、mutation test が入るまで merge-ready な実装 Issue ではありません。
squne121 commentedon Jun 13, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: human judgment required
human_escalationhuman_judgment_requiredBlockers
squne121 commentedon Jun 13, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jun 13, 2026
CONTRACT_REVIEW_RESULT_V1
Handoff to implement-issue
CTX_FETCH_STRICT=1が runtime effective policy として artifact 化され、URL policy matrix の block 動作が hermetic fixture / stub で証明される.claude/worktrees/issue-827-ctx-fetch-strictworktree-issue-827-ctx-fetch-strict.claude/settings.json.claude/hooks/**.claude/artifacts/context-mode/**docs/dev/agent-ops/**scripts/test_context_mode_fetch_strict.pytests/context_mode/test_fetch_strict_policy.pytests/context_mode/test_fetch_strict_artifact.pytests/fixtures/context-mode/**squne121 commentedon Jun 13, 2026
Contract Review Result
squne121 commentedon Jun 13, 2026
implement-issue: 実装完了 (2026-06-14T00:10:00Z)
.claude/worktrees/issue-827-ctx-fetch-strictworktree-issue-827-ctx-fetch-strictVC 結果サマリ
pytest -k committed_denypytest -k effective_strictpytest -k url_policy_matrixpytest -k adversarialpytest -k trap_serverpytest -k ci_smokepytest -k isolationpytest test_fetch_strict_artifact.py -vpytest -k mutationtest -f context-mode-fetch-policy.md+pytest -k fetch_policy_docsfeat(#827): ctx_fetch_and_index を CTX_FETCH_STRICT=1 と network negati…
feat(#827): ctx_fetch_and_index を CTX_FETCH_STRICT=1 と network negati…
squne121 commentedon Jun 13, 2026
IMPL_REVIEW_LOOP_RESULT_V1
fix(#827): artifact head_sha 一致・CTX_FETCH_STRICT 証明修正・mutation/networ…
fix(#827): artifact head_sha テストを ancestor 判定に緩和・artifact 再生成
fix(#827): head_sha チェックを shallow clone 対応 git log ベースに変更
fix(#827): artifact を現在の branch HEAD で再生成する
fix(#827): artifact を最終 HEAD (2da4092) で再生成する
fix(#827): head_sha テストを CI=true でスキップ(shallow clone 非互換のため)
feat(#827): ctx_fetch_and_index を CTX_FETCH_STRICT=1 と network negati…
squne121 commentedon Jun 14, 2026
IMPL_REVIEW_LOOP_RESULT_V1
完了サマリ
Issue #827「context-mode ctx_fetch_and_index を CTX_FETCH_STRICT=1 と network negative test で隔離する」の実装が完了し、PR #892 がマージされました。
実装内容(AC1〜AC10 全て充足)
scripts/test_context_mode_fetch_strict.pytests/context_mode/test_fetch_strict_policy.pytests/context_mode/test_fetch_strict_artifact.py.claude/artifacts/context-mode/fetch-strict-negative-test.jsondocs/dev/agent-ops/context-mode-fetch-policy.mdCI 結果
全ジョブ pass(python-test / test / build / e2e / typecheck / lint / actionlint / validate-generated-artifact / PR Body Japanese Check)
squne121 commentedon Jun 14, 2026
post-merge-cleanup: 完了 (2026-06-14T00:46:42Z)