← 全部文档 docsen/deployment.md

AIShield — Deployment & Verification

Two deployment modes

Mode What runs When to use
Local (open-source) python -m scanner or npx aishield-mcp-server on your machine Development, private CI, offline environments
Remote (aishield.tools) Cloudflare Named Tunnel → VPS :8450 → api/server.py Multi-tenant SaaS, agent-native discovery

The two modes share the same scanner code and the same rule set. The remote API just wraps the same functions over HTTP; no separate codebase.

Local deployment

# Bare Python (no service)
python -m scanner --file ./mcp-config.json

# As an MCP server (stdio)
npx -y aishield-mcp-server

# As an HTTP API (self-host)
uvicorn api.server:app --port 8450

Remote deployment (reference: production)

The live aishield.tools production instance is deployed via a Cloudflare Named Tunnel:

internet
  ↓  https://aishield.tools/api/v1/...
  Cloudflare Named Tunnel
  ↓  wss
  VPS :8450
  ↓  localhost
  api/server.py (HTTP server)

Do not use pkill -f cloudflared to restart. The tunnel is process-identifiable but not pid-stable across reboots. Stop by PID and restart with the same config.

Deployment verification (three-step)

After any push, always confirm the live instance has caught up. Order matters:

  1. API health — get the deployed commit:
   curl --ssl-no-revoke --tlsv1.3 -H "User-Agent: Mozilla/5.0" \
     https://aishield.tools/api/v1/health

Look for "commit" in the response.

  1. Agent-card — verify what agents actually discover:
   curl -s https://aishield.tools/.well-known/agent-card.json | jq '.service_version, .rules.total'
  1. Live rule count — the only authoritative value:
   curl -s https://aishield.tools/api/v1/health | jq '.rules_breakdown'

rules_breakdown should show {static, generated, radar, total} matching the sum on the deployed commit.

Push discipline

Local state isolation

The scanner never writes to paths that come from the configuration it scans. scripts/prove_isolation.py proves this by:

  1. Patching subprocess.Popen, os.system, subprocess.run to raise on any call
  2. Loading the scanner and running a scan against a malicious-looking config that would normally invoke subprocess
  3. Asserting zero invocations of any spawn function

If the assertion fails, treat it as a security incident — the isolation invariant is broken.

Rollback

The VPS deployment does not use a rollback tool; the rollback path is:

  1. git checkout <previous-commit> locally
  2. bash scripts/_push_batch.py "rollback: revert to <sha>"
  3. Wait for the deployment pipeline (5–10 minutes)
  4. Verify with the three-step check above

来源:docs/en/deployment.md · 由 aishield.tools 直接渲染,零外链依赖