From bb5c59b8d843f81267c435b4efb9add1743fc36e Mon Sep 17 00:00:00 2001 From: Sid Mohan <61345237+sidmohan0@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:19:05 -0800 Subject: [PATCH] Test direct executable entrypoints against directory validation --- .mcp.json | 4 +- .../2026-11-18-directory-validation.md | 115 +++++++++++++++ .../direct-entrypoint-ab-results.json | 135 ++++++++++++++++++ docs/verification/direct-entrypoint-ab.md | 45 ++++++ hooks/hooks.json | 8 +- tests/live/fake_claude.py | 2 +- tests/test_cli_and_plugin.py | 36 ++++- 7 files changed, 336 insertions(+), 9 deletions(-) create mode 100644 docs/verification/2026-11-18-directory-validation.md create mode 100644 docs/verification/direct-entrypoint-ab-results.json create mode 100644 docs/verification/direct-entrypoint-ab.md diff --git a/.mcp.json b/.mcp.json index 227866c..08a0b09 100644 --- a/.mcp.json +++ b/.mcp.json @@ -1,8 +1,8 @@ { "mcpServers": { "guard": { - "command": "sh", - "args": ["${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard", "mcp"], + "command": "${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard", + "args": ["mcp"], "env": { "CLAUDE_PROJECT_DIR": "${CLAUDE_PROJECT_DIR}", "DATAFOG_DATA_DIR": "${DATAFOG_DATA_DIR:-}", diff --git a/docs/verification/2026-11-18-directory-validation.md b/docs/verification/2026-11-18-directory-validation.md new file mode 100644 index 0000000..e4e39f1 --- /dev/null +++ b/docs/verification/2026-11-18-directory-validation.md @@ -0,0 +1,115 @@ +# Directory validation after release 0.2.1 + +Observed 2026-11-18 in the authenticated Claude directory portal. Release +[v0.2.1](https://github.com/DataFog/datafog-claude-plugin/releases/tag/v0.2.1) +was validated at commit `964fe1004bfd5c1188f46990a08d4f15e748c6ca`. +Result: **4 blocking findings, 12 warnings, 21 policy holds; 5 of 7 checks passed**. +This is validation, not submission acceptance, security-scan approval, or publication. + +## Existing entry and migration + +The [existing entry](https://claude.ai/directory/manage/plugins/b9ad3ff1-41bf-4162-9a1b-7feb8a4a6d36?tab=feedback) +remains Needs changes, with the October 5 decision on version 0.1.0 / `7a154b2`. +Its tracked source was saved as tag `v0.2.1`; Code-only listing and auto-publish off +were verified. No contact address is recorded in this public evidence. + +Clicking Resubmit for review failed: the entry lacks a validation report, and the +portal requires withdrawal, repository validation, then recreation from that +report. This supersedes the earlier inference that no migration was needed. +Before withdrawing, the release was validated in the new submission form. Because +that validation exposed hard blockers, the old entry was preserved intact. +Nothing was withdrawn, recreated, accepted for review, or published in the directory. + +The report is visible in the same browser tab at +[Source](https://claude.ai/directory/manage/new/plugin?step=source). +The portal says the form is kept in that tab until it closes. No standalone report +ID, download, or permanent report URL was exposed. The report's GitHub links point +to the exact commit above. Browser accessibility observations recorded the findings; +no screenshot containing unrelated account sidebar data was added to this repository. + +## Blocking findings + +| Code | Report location | Meaning and next action | +| --- | --- | --- | +| `COMMAND_PATH_COMPUTED` | `.` | The validator cannot follow a loader command's path. Its examples include non-root variables, command substitution, glob/brace patterns and inline programs. Expanded detail provides no exact command, line, or narrower field. Ask for the offending source before changing launch behavior. | +| `LOCAL_CODE_HOOK_COMMAND` | `hooks/hooks.json` | Command hooks are refused for this unverified organization. Removing them would remove the plugin's automatic interception. | +| `LOCAL_CODE_MCP_SERVER` | `.mcp.json`, `mcpServers.guard` | Local command-based MCP servers are refused for this unverified organization. A remote server would change the product's local processing design. | +| `LOCAL_CODE_FILE_TYPE` | `engine/datafog_guard/__init__.py` | Executable/restricted file types are refused for this unverified organization. The first identified file is Python source, not an unexplained binary. | + +The three local-code findings explicitly say: + +> Anthropic chooses who is a Verified organization, and there’s no way to ask to become one yet. + +The portal offers no self-service organization verification control in these pages. +GitHub ownership authentication is not evidence of this directory status. + +## All policy holds + +| Code | Count | Reported locations or trigger | +| --- | ---: | --- | +| `HOOK_GRANTS_PERMISSION` | 1 | `hooks/hooks.json`, PreToolUse: can approve a call or change its input. Review the actual bounded permission behavior. | +| `UNREAD_ASSET_REFERENCED` | 4 | Icon path mentioned in `docs/directory-submission.md`, `tests/test_bash_permissions.py`, manifest reached from `scripts/verify-manifests.sh`, and directory-submission document reached from the test. | +| `MCP_FORWARDS_CREDENTIAL_ENV` | 7 | README; readiness doc; host-readiness doc; bash-permissions test; keystore test; late-swap test; aggregate manifest finding combining README with CI Python. The heuristic combines credential-like text with URLs or opaque text; this is not proof of transmission. | +| `COMMAND_SCRIPT_NOT_FOLLOWED` | 1 | `scripts/datafog-guard`: script requires manual path/behavior review. | +| `MCP_SCRIPT_NOT_READ` | 1 | `.mcp.json`, `mcpServers.guard.args`: `sh` launcher requires manual review. | +| `NAME_CONFUSABLE` | 5 | `name` and `author.name` resemble Datadog brand/connector; name also resembles Datadog's plugin. | +| `PUBLISHER_CONFUSABLE` | 2 | GitHub owner DataFog resembles Datadog brand/connector. | + +Credential heuristic details: README combines a Claude docs URL with a Claude config +path; readiness combines a GitHub URL with that path; host-readiness flags the phrase +“pass individual”; the keystore test combines the Secret Service specification URL +with its isolated `secret-tool search`. The two larger test files contain patterns +too complex for the validator. These need source-backed reviewer explanations, +not claims that the scanner has established a leak. + +## All warnings and informational groups + +The 12 warnings comprise: + +- Three `UNKNOWN_KEY` findings: `documentationUrl`, `privacyPolicyUrl`, `supportUrl`. + Each expanded finding says the directory reads it and no action is needed. +- One icon field warning: directory-only metadata, also no action needed. +- Eight `RUNTIME_FETCH_EXEC` findings: README; `bashwrap.py`, `ccperms.py`, + `filtercmd.py`, `plain.py`; `tests/live/fake_claude.py`; bash-permissions and + late-swap tests. The report supplies file locations but no exact matching lines. + Pattern detection in safety checks/tests must be distinguished from execution. + +Informational groups: local stdio MCP does not run on claude.ai; the PNG passed +image validation; interpreter/file-extension mismatches (group count four, with +an aggregate noting five findings and three examples shown); server environment +names outside the directory list (group count four, showing project directory, +data directory and vault directory examples); and existing submission ownership. +These are currently notes, not refusals. The extension examples include +PostToolUse, PreToolUse and SessionStart command strings; do not adopt a new hook +schema without checking released Claude Code compatibility. + +## Support route and unresolved review path + +The existing entry's More actions > Contact Anthropic is an email link to +`directory@anthropic.com`, confirmed using the browser's Copy Email Address action. +No portal reply field was exposed. After explicit user authorization, an email was +sent to this official address on 2026-11-18 asking for the supported migration/review +path and the precise command-path location. No response or approval is yet recorded. +The old entry and validation form remain available for follow-up. + +The official [publishing overview](https://claude.com/docs/directory/publish) +says Anthropic decides Verified designation during review, with no separate +application. [Connector verification](https://claude.com/docs/connectors/verification) +describes automatic escalation for connectors; that is not a self-service mechanism +for this plugin's submitting organization. The actual plugin report blocks entry +before review for local code. Ask the directory team which review/migration path is +supported, and request the precise `COMMAND_PATH_COMPUTED` location. + +The [plugin checklist](https://claude.com/docs/plugins/pre-submission-checklist) +distinguishes blocking direct-command path problems from scripts requiring review. +Local `claude plugin validate` checks manifest structure, not these publisher policy +gates. Neither successful local validation nor a published GitHub release resolves +the directory's organization requirements. + +## Continuation criteria + +Keep release 0.2.1 immutable and preserve local processing. Resume migration only +when a supported publisher/review path is established and blocking validation is +resolved. Then validate the intended immutable release, migrate the old entry as +instructed, complete accurate listing/data handling, submit, and observe approval +before publishing. Existing settings remain Code-only and auto-publish off. diff --git a/docs/verification/direct-entrypoint-ab-results.json b/docs/verification/direct-entrypoint-ab-results.json new file mode 100644 index 0000000..eea664e --- /dev/null +++ b/docs/verification/direct-entrypoint-ab-results.json @@ -0,0 +1,135 @@ +{ + "marketplace": "datafog-readiness-0abb4fc0a159", + "work": "/var/folders/kt/xxfb4y954tbfw5mpmgm4ybq00000gn/T/datafog-installed.t3p3h5qs", + "cases": [ + { + "case": "installed-read", + "version": "2.1.327", + "checks": { + "Read returned markers": true, + "first startup bootstrapped engine": true, + "successful host process": true, + "no sentinel in model tool results": true, + "loaded installed cached plugin": true + }, + "transcript": "/var/folders/kt/xxfb4y954tbfw5mpmgm4ybq00000gn/T/datafog-installed.t3p3h5qs/log/runs/01-installed-read.jsonl" + }, + { + "case": "installed-bash", + "version": "2.1.327", + "checks": { + "Bash returned markers": true, + "successful host process": true, + "no sentinel in model tool results": true, + "loaded installed cached plugin": true + }, + "transcript": "/var/folders/kt/xxfb4y954tbfw5mpmgm4ybq00000gn/T/datafog-installed.t3p3h5qs/log/runs/02-installed-bash.jsonl" + }, + { + "case": "installed-mcp-edit", + "version": "2.1.327", + "checks": { + "MCP edit called": true, + "real value plus suffix on disk": true, + "no marker on disk": true, + "successful host process": true, + "no sentinel in model tool results": true, + "loaded installed cached plugin": true + }, + "transcript": "/var/folders/kt/xxfb4y954tbfw5mpmgm4ybq00000gn/T/datafog-installed.t3p3h5qs/log/runs/03-installed-mcp-edit.jsonl" + }, + { + "case": "installed-mcp-project-boundary", + "version": "2.1.327", + "checks": { + "MCP edit called": true, + "server refused outside project": true, + "outside fixture unchanged": true, + "successful host process": true, + "no sentinel in model tool results": true, + "loaded installed cached plugin": true + }, + "transcript": "/var/folders/kt/xxfb4y954tbfw5mpmgm4ybq00000gn/T/datafog-installed.t3p3h5qs/log/runs/04-installed-mcp-project-boundary.jsonl" + } + ], + "cleanup": [ + { + "step": "uninstall", + "success": true + }, + { + "step": "marketplace-remove", + "success": true + }, + { + "step": "purge-fixture-session", + "success": true + } + ], + "installed": { + "id": "datafog@datafog-readiness-0abb4fc0a159", + "version": "0.2.1", + "scope": "local", + "enabled": true, + "installPath": "/Users/sid/.claude/plugins/cache/datafog-readiness-0abb4fc0a159/datafog/0.2.1", + "installedAt": "2026-11-18T19:17:27.940Z", + "lastUpdated": "2026-11-18T19:17:27.940Z", + "projectPath": "/private/var/folders/kt/xxfb4y954tbfw5mpmgm4ybq00000gn/T/datafog-installed.t3p3h5qs/project", + "mcpServers": { + "guard": { + "command": "${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard", + "args": [ + "mcp" + ], + "env": { + "CLAUDE_PROJECT_DIR": "${CLAUDE_PROJECT_DIR}", + "DATAFOG_DATA_DIR": "${DATAFOG_DATA_DIR:-}", + "DATAFOG_VAULT_DIR": "${DATAFOG_VAULT_DIR:-}", + "DATAFOG_VAULT_KEY": "${DATAFOG_VAULT_KEY:-}" + } + } + }, + "projectEnabled": false, + "hasUserConfig": true + }, + "cache_matches_source": true, + "fresh_bootstrap": true, + "interactive_first_start": true, + "fixture_trust_recorded": true, + "cleanup_verified": true, + "baseline_revision": "964fe1004bfd5c1188f46990a08d4f15e748c6ca", + "candidate_production_sha256": { + ".claude-plugin/marketplace.json": "0921542848f7f5d8aa96770a93c9021d20d8a31e674aae29c3780b7defde6151", + ".claude-plugin/plugin.json": "a804eaeab8e1b483079e8d7915401021b01875fe54ff3b8a79847b0359b57648", + ".mcp.json": "646e5bd13f160e44dff4f28806a53e4effcc6e63ab6e6706b0098d082715e158", + "engine/datafog_guard/__init__.py": "e486296852d8dc74ba7086fef26537074ddd28cca1a96610e9adfdba2a95b4ea", + "engine/datafog_guard/__main__.py": "19a405af122b22e15bd4759ef48350c1b57d802c3ffb37ac9f5e6da7a608af9f", + "engine/datafog_guard/bashwrap.py": "7d711399b49f6a526200fef8ec4ca6f626588f98f84ce6083cea5c00947a8809", + "engine/datafog_guard/ccperms.py": "99a93d82a59f2eed8d9f549a463c62a2ee90b8504a28facf03247900a3aee185", + "engine/datafog_guard/cli.py": "45930b7f694e42e06fbf955ff74cb8927a0bd0f217fa18ea9dca0d1edb78e6f1", + "engine/datafog_guard/config.py": "98440b35d5e03558abdc5796920fc286f2da67d4f2c49dadb84a8c8fc5bddbe8", + "engine/datafog_guard/dependencies.py": "f3aee7c7d9a012922aedf8be72df110ebb922bc4203c8db5568fbdf5e38a4390", + "engine/datafog_guard/engine.py": "9b23f76cc1cdf47ca1d3943c87497f0c957b2bc01839ed736775bd04c7f9b640", + "engine/datafog_guard/errors.py": "d5e2adc7f4da6dec409697d1b35f86ed0e62d596d783eee21a98a5817c4faeda", + "engine/datafog_guard/files.py": "aa1583b1ca84c9f5aa555642f24a397367db6d281ead1cfa272274bad5534faf", + "engine/datafog_guard/filtercmd.py": "141196d30c6ec4523968b1fb02ad800945c96fca4789b0a70fd37620089aae43", + "engine/datafog_guard/hook.py": "cf8e205d96cd41bb8ce9d65db6ba598a6d6bcedc1f052707c308881fcc1eb0a4", + "engine/datafog_guard/log.py": "dc3913d9763c2db69d71f57bb7c6bf8e34dd9f76e8c5e0117c5eaf7eebd26f6f", + "engine/datafog_guard/mcp_server.py": "ac0fe6c88703f5e5c0f8cf2a32a75e918a7ce51f9c04a6a2bb9a4a9a7223a774", + "engine/datafog_guard/plain.py": "d48b94c0bb3b1ee7fd00e4f30f8829f958bbbe76417577af48912cc682db84bb", + "engine/datafog_guard/shapes.py": "6df11350a02391f43437af94593417a0f2405eefa9d05509a1e54b3ad6178635", + "engine/datafog_guard/shellsub.py": "2326384c88e1b601a7094172d997c38d57d6efebabc2853345917592f41df95d", + "engine/datafog_guard/store.py": "81d9bcfd5f354fb68853d84581b893d0fd0fe5680a959dd0614d4019769ae150", + "engine/datafog_guard/stream.py": "f2699c5c3d01b19525afea292c34759030f566356238b0bcb0af717f60022cb4", + "engine/datafog_guard/support.py": "33be91dd33bcce5b814c1ae9746cb71b5dc5786f2e671dd0c2d181e7eb7281ca", + "engine/datafog_guard/vault.py": "ff39ecb3dc287c6dff32ad72fe5825a15e35df6d141db65f18ccc0f0d052d1c5", + "engine/run.py": "c510ca7de991bcd0ad8b19412e4b517a73d60dd964b849a36fae242f44883c47", + "hooks/hooks.json": "bd7408d4baa60043d4da7383c8ee128d0cd71871fb5e33c215be276abd59ed9a", + "pyproject.toml": "eb370c164bd912c4a92551029cfb2c3e0d821964b28d1ef7fbd42f1844b653b0", + "scripts/bootstrap.sh": "916c54191844e614334201084258fab02685aa2485583063ec2dc4caf80b3195", + "scripts/datafog-guard": "c4d5d471711b20429e1c7f252b274f62c1c3d10cde1676009de4a930491081f0", + "scripts/verify-manifests.sh": "6f03cbf9101da54a72f2ec2eed49c08ea26e97a40b946985285524018eeb97af", + "scripts/wrap.sh": "4549077dce3ce12225d65e5197104bb3db67deda0fc0e1125b8d3cf511b1a4e4" + }, + "purpose": "Unreleased direct-executable A/B candidate; portal resolution not yet verified." +} diff --git a/docs/verification/direct-entrypoint-ab.md b/docs/verification/direct-entrypoint-ab.md new file mode 100644 index 0000000..c323e24 --- /dev/null +++ b/docs/verification/direct-entrypoint-ab.md @@ -0,0 +1,45 @@ +# Direct executable entry-point A/B candidate + +Prepared on 2026-11-18 against released baseline `964fe10`, without a version bump +or a new release. This is a narrow experiment for the portal's +`COMMAND_PATH_COMPUTED` finding; passing local tests does not prove that finding +is resolved. The report locates the blocker only at `.`. + +The four hook commands now invoke the quoted +`${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard` executable directly. The MCP command +uses that same path with `args: ["mcp"]`. The existing launcher is unchanged, +tracked executable (`100755`), and starts with `#!/bin/sh`. Bootstrap, dependency +pins, runtime selection, vault behavior, hook failure policy and engine code are +unchanged. Manual commands using `sh` continue to work. + +This names the actual bundled entry point directly rather than making `sh` the +declared executable. It does not conceal the launcher, move its code, or remove +any capability. Nested-script reviewer holds and organization verification remain +separate questions for the portal. + +## Verification + +- Relevant CLI/plugin, hook protocol, MCP and live-driver tests: **208 passed, + 4 skipped** in 24.89 seconds. A new regression executes actual declared + SessionStart and MCP entries from a plugin directory containing spaces. +- Network-enabled cold bootstrap and full simulator tests: **2 passed** in + 18.50 seconds. The simulator now expands `${CLAUDE_PLUGIN_ROOT}` in the command + field as the real host does, as well as in arguments. +- Ruff, `git diff --check`, and strict `claude plugin validate --profile directory` + passed. The local directory profile has fewer checks than the portal. +- Real Claude Code **2.1.327** cached installation: fresh interactive trust/startup, + Read, filtered Bash, marker-aware MCP edit and outside-project MCP refusal all + passed. Every model run loaded the actual installed cache. The cache matched + candidate production hashes. The unique installation/marketplace and generated + fixture host records were removed afterwards. + +[Structured cached-host results and candidate hashes](direct-entrypoint-ab-results.json) +preserve the tested state. The candidate retains version 0.2.1 for isolated A/B +validation only; do not present it as a replacement for the published tag. + +## Required next evidence + +Push the diagnostic branch and validate that exact SHA in the portal. Record +whether `COMMAND_PATH_COMPUTED` disappears, changes, or remains. A local pass is +not grounds to rewrite the launcher internals speculatively or to mark publisher +verification complete. diff --git a/hooks/hooks.json b/hooks/hooks.json index 2371158..6a94934 100644 --- a/hooks/hooks.json +++ b/hooks/hooks.json @@ -6,7 +6,7 @@ "hooks": [ { "type": "command", - "command": "sh \"${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard\" session-start", + "command": "\"${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard\" session-start", "timeout": 300, "onFailure": "block", "statusMessage": "DataFog guard: checking protection" @@ -19,7 +19,7 @@ "hooks": [ { "type": "command", - "command": "sh \"${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard\" hook", + "command": "\"${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard\" hook", "timeout": 30, "onFailure": "block" } @@ -32,7 +32,7 @@ "hooks": [ { "type": "command", - "command": "sh \"${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard\" hook", + "command": "\"${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard\" hook", "timeout": 60, "onFailure": "block" } @@ -45,7 +45,7 @@ "hooks": [ { "type": "command", - "command": "sh \"${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard\" hook", + "command": "\"${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard\" hook", "timeout": 60, "onFailure": "block" } diff --git a/tests/live/fake_claude.py b/tests/live/fake_claude.py index 6cf65fb..eb8f44c 100755 --- a/tests/live/fake_claude.py +++ b/tests/live/fake_claude.py @@ -145,7 +145,7 @@ def execute(self, tool, tool_input): for key, value in (server.get("env") or {}).items(): env[key] = re.sub(r"\$\{(\w+)(?::-([^}]*))?\}", lambda m: self.env.get(m.group(1)) or (m.group(2) or ""), value) - argv = [server["command"]] + [a.replace("${CLAUDE_PLUGIN_ROOT}", self.plugin) for a in server["args"]] + argv = [a.replace("${CLAUDE_PLUGIN_ROOT}", self.plugin) for a in [server["command"], *server["args"]]] requests = [{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}}, {"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "edit_with_markers", "arguments": tool_input}}] diff --git a/tests/test_cli_and_plugin.py b/tests/test_cli_and_plugin.py index e52fe26..5383e3d 100644 --- a/tests/test_cli_and_plugin.py +++ b/tests/test_cli_and_plugin.py @@ -3,8 +3,10 @@ import json import os +import shlex import shutil import subprocess +import sys import pytest from conftest import EMAIL, NOTES, ROOT, assert_no_sentinel, corrupt_vault @@ -177,7 +179,7 @@ def test_every_hook_entry_blocks_on_failure_and_uses_the_launcher(): assert len(groups) == 1 and len(groups[0]["hooks"]) == 1, f"{event}: exactly one hook" entry = groups[0]["hooks"][0] assert entry["type"] == "command" and entry["onFailure"] == "block", event - assert entry["command"].startswith('sh "${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard" ') + assert entry["command"].startswith('"${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard" ') assert entry["timeout"] >= 30 assert hooks["PreToolUse"][0]["matcher"] == "*", "one PreToolUse hook for all tools: only one may rewrite input" assert hooks["PostToolUse"][0]["matcher"] == "*" @@ -193,11 +195,41 @@ def test_manifests(): market = json.loads((ROOT / ".claude-plugin" / "marketplace.json").read_text()) assert market["plugins"][0]["name"] == "datafog" servers = json.loads((ROOT / ".mcp.json").read_text())["mcpServers"] - assert list(servers) == ["guard"] and servers["guard"]["args"][-1] == "mcp" + assert list(servers) == ["guard"] and servers["guard"]["args"] == ["mcp"] + assert servers["guard"]["command"] == "${CLAUDE_PLUGIN_ROOT}/scripts/datafog-guard" from datafog_guard.hook import OWN_MCP_PREFIX assert OWN_MCP_PREFIX == f"mcp__plugin_{plugin['name']}_guard__" +def test_declared_executable_entrypoints_work_with_spaces(box): + plugin = box.tmp / "plugin with spaces" + for name in ("scripts", "engine"): + shutil.copytree(ROOT / name, plugin / name, ignore=shutil.ignore_patterns("__pycache__")) + launcher = plugin / "scripts" / "datafog-guard" + assert launcher.read_text().startswith("#!/bin/sh\n") and os.access(launcher, os.X_OK) + # Route the private interpreter slot to the test interpreter without installing packages. + python = box.data / "venv" / "bin" / "python" + python.parent.mkdir(parents=True) + python.write_text(f'#!/bin/sh\nexec {shlex.quote(sys.executable)} "$@"\n') + python.chmod(0o700) + (python.parent.parent / ".datafog-installed").write_text(f"{CORE_REQUIREMENT} {VAULT_REQUIREMENT}") + env = box.env(CLAUDE_PLUGIN_ROOT=str(plugin)) + hook = json.loads((ROOT / "hooks/hooks.json").read_text())["hooks"]["SessionStart"][0]["hooks"][0]["command"] + result = subprocess.run(["/bin/sh", "-c", hook], input=json.dumps( + {"hook_event_name": "SessionStart", "source": "startup"}).encode(), capture_output=True, + env=env, cwd=box.project, timeout=30) + assert result.returncode == 0 and "DataFog guard: on" in json.loads(result.stdout)["systemMessage"], result.stderr + server = json.loads((ROOT / ".mcp.json").read_text())["mcpServers"]["guard"] + argv = [part.replace("${CLAUDE_PLUGIN_ROOT}", str(plugin)) for part in [server["command"], *server["args"]]] + requests = [{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}}, + {"jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {}}] + result = subprocess.run(argv, input="".join(json.dumps(r) + "\n" for r in requests).encode(), + capture_output=True, env=env, cwd=box.project, timeout=30) + assert result.returncode == 0, result.stderr + replies = [json.loads(line) for line in result.stdout.splitlines()] + assert {tool["name"] for tool in replies[-1]["result"]["tools"]} == {"edit_with_markers", "protection_status"} + + def test_commands_exist_and_purge_cannot_be_invoked_by_the_model(): for name in ("status", "purge", "doctor"): body = (ROOT / "commands" / f"{name}.md").read_text()