Skip to content

fix(hooks): match dry-run MCP writes by action, not by namespace prefix - #219

Open
VxxxlBxxxxv wants to merge 2 commits into
TserenTserenov:mainfrom
VxxxlBxxxxv:fix/dry-run-gate-mcp-namespace-drift
Open

fix(hooks): match dry-run MCP writes by action, not by namespace prefix#219
VxxxlBxxxxv wants to merge 2 commits into
TserenTserenov:mainfrom
VxxxlBxxxxv:fix/dry-run-gate-mcp-namespace-drift

Conversation

@VxxxlBxxxxv

Copy link
Copy Markdown
Contributor

Проблема — namespace drift обходит dry-run gate

dry-run-gate.sh заносил write-инструменты IWE Gateway в whitelist только под legacy-префиксом коннектора mcp__claude_ai_IWE__*. Но один и тот же Gateway (сервер iwe-knowledge, mcp.aisystant.com/mcp) сейчас выдаётся под несколькими префиксами — в зависимости от способа подключения. В результате при активном dry-run sentinel все актуальные write-инструменты проходят сквозь gate.

Четыре namespace одного Gateway:

Namespace Откуда Пример
mcp__claude_ai_IWE__<action> legacy connector «IWE» mcp__claude_ai_IWE__personal_write
mcp__iwe_knowledge_<action> OMP runtime (разделитель _) mcp__iwe_knowledge_personal_write
mcp__iwe-knowledge__<action> project .mcp.json (server id) mcp__iwe-knowledge__personal_write
mcp__claude_ai_https_..._mcp__<action> connector с именем из URL mcp__claude_ai_https_mcp_aisystant_com_mcp__personal_write

Воспроизведение

Sentinel активен → прямой smoke хука с {"tool_name":"mcp__iwe-knowledge__personal_write"}:

  • Ожидалось: exit 2 (blocked)
  • Было: exit 0 (allowed)

Так же протекали dt_write_digital_twin, send_telegram_message, create_repository, run_strategist, run_extractor, capture_trace, personal_delete, personal_purge_source, grant_consent и др. Блокировался только устаревший mcp__claude_ai_IWE__*, которого в текущем рантайме уже нет.

Impact: критично для /audit-installation и ritual smoke-test — агент считает dry-run включённым, но MCP-write действия в текущем namespace выполняются реально (запись personal knowledge, Digital Twin, создание repo, Telegram delivery, strategist run с commit).

Фикс

Сверять IWE-инструменты по действию (суффикс после последнего разделителя), а не по полному имени. Паттерн *_<action> ловит и __<action> (двойной разделитель), и OMP-вариант _<action> — переживает будущие миграции namespace. Вендорские MCP (Gmail/Calendar/Drive/Linear/Railway) остаются на exact-match — их префиксы стабильны. memory/dry-run-contract.md обновлён таблицей дрейфа.

Проверка

Прямой smoke правленого хука (23 проверки, все прошли):

  • BLOCK во всех 4 namespace: personal_write, dt_write_digital_twin, send_telegram_message, run_strategist, create_repository, capture_trace, grant_consent, personal_purge_source.
  • ALLOW без ложных срабатываний на read-only: search, knowledge_search, dt_read_digital_twin, personal_search, personal_reindex_status, knowledge_feedback_stats, agent_status_list, github_status.
  • Vendor exact (Gmail__create_draft, ext-railway__set-variables) → BLOCK.
  • Write → BLOCK; без sentinel → ALLOW.
  • bash -n — синтаксис чист.

Ортогонально открытому #194 (тот же файл, но правит git/cleanup handling, whitelist не трогает).

🤖 Generated with Claude Code

VxxxlBxxxxv and others added 2 commits July 2, 2026 16:04
The dry-run gate whitelisted IWE Gateway write tools only under the legacy
connector prefix `mcp__claude_ai_IWE__*`. The same Gateway (server
`iwe-knowledge`, mcp.aisystant.com/mcp) is now exposed under several other
prefixes depending on how it is connected, so every current write tool slipped
through the gate while a dry-run sentinel was active:

  mcp__claude_ai_IWE__<action>            legacy connector "IWE"
  mcp__iwe_knowledge_<action>             OMP runtime (single-underscore sep)
  mcp__iwe-knowledge__<action>            project .mcp.json (server id)
  mcp__claude_ai_https_..._mcp__<action>  URL-derived connector name

Repro (sentinel active): mcp__iwe-knowledge__personal_write,
dt_write_digital_twin, send_telegram_message, create_repository, run_strategist,
capture_trace, ... all returned exit 0 (allowed) instead of exit 2 (blocked).

Fix: match IWE writes by ACTION (suffix after the last separator) instead of the
full tool name. Pattern `*_<action>` catches both `__<action>` and the OMP
single-underscore `_<action>`, so it survives future namespace migrations.
Vendor MCP tools keep exact-name matching (vendor prefixes are stable).
Contract doc (memory/dry-run-contract.md) updated with the drift table.

Verified: all 4 namespaces block; read-only tools (search, dt_read_*,
*_stats, *_status, agent_status_list) still allowed with no false positives.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
VxxxlBxxxxv added a commit to VxxxlBxxxxv/FMT-exocortex-template that referenced this pull request Jul 6, 2026
…ov#226 fix), CHANGELOG

Доставлено обновлением v2.3.0: repair-pass реставрировал 6 stale runtime-файлов
(последствие частичного обрыва 04.07). dry-run-gate.sh + dry-run-contract.md
восстановлены из PR TserenTserenov#219 (action-match фикс, upstream ещё не влит).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant