SCML
CLAUDE.md0 starsChanged 26 days agoApache-2.0View on GitHub
Trust-aware context mediation middleware for securing agentic AI / RAG systems. Spec: TrustMediator_PRD (1).docx (PRD v1.0) — the single source of truth for requirements. Amended by PRD_v1.1_ADDENDUM.md (proposed), which adds what v1.0 cannot express: storage-vs-harm ASR (§14.2a), an enforcement-coverage KPI (§14.2b), the classifier training/eval protocol that §6.3 omitted (§6.3a), and acceptance criteria for the production NFRs (§16). It lowers no v1.0 target. New IDs start at FR-MI-06, FR-PE-06, FR-SC-06 — FR-MI-05 (quarantine review) and FR-PE-05 (rate limiting) are v1.0's and…
- Reads credentials
- Installs packages
In this repository4 other files it gives its agents.
- kpi-reportSkill
- run-evalSkill
- session-endSkill
- session-startSkill
The file
We split this CLAUDE.md into the rules it gives an agent
10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Ask before installing system packages, changing dependencies, pushing, or spending money (paid LLM runs).
- Very specific: line 25
Test env prefix (the local .env sets production mode, docker-only hostnames and a real API key, all of which break bare test runs):
- Very specific: line 33
Run API locally: .venv/bin/python -m uvicorn trust_mediator.api.app:app --reload --port 8000 (docs at /docs)
- Very specific: line 37
Use python -m <tool>, not .venv/bin/<tool>: the venv was created at an older path, so its console-script shebangs are broken (the …
- Very specific: line 46
All config via env: every tunable goes through TRUST_MEDIATOR_* env vars in trust_mediator/config.py (pydantic-settings).
- Very specific: line 47
Audit everything: every mediation decision and every control-plane action emits an audit event (SHA-256 hash chain).
- Distinctive: line 75
No sandboxed tool executor (PRD §11) — tool execution stays in the host app
- Very specific: line 87
InjecAgent (1054 external cases): all five §14.2 KPIs pass, but no_tool_policy is 100.0% ASR: tool policy is the *entire* defence, and the …
- Distinctive: line 89
§6.3 detection: no backend reaches FR-SC-07 (AUC 0.85).
- Distinctive: line 90
Never tune against the in-house memory-poisoning corpus.
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
TrustMediator
Trust-aware context mediation middleware for securing agentic AI / RAG systems.
Spec: TrustMediator_PRD (1).docx (PRD v1.0) — the single source of truth for requirements.
Amended by PRD_v1.1_ADDENDUM.md (proposed), which adds what v1.0 cannot express:
storage-vs-harm ASR (§14.2a), an enforcement-coverage KPI (§14.2b), the classifier
training/eval protocol that §6.3 omitted (§6.3a), and acceptance criteria for the
production NFRs (§16). It lowers no v1.0 target. New IDs start at FR-MI-06,
FR-PE-06, FR-SC-06 — FR-MI-05 (quarantine review) and FR-PE-05 (rate limiting)
are v1.0's and unaffected.
Working in this repo
- Start of session:
/session-start <role>(printsPROGRESS.md, names the role, picks one item fromfeature_list.json). End:/session-end. PROGRESS.md— current state + newest-first session log.feature_list.json— the backlog;passes: trueonly with evidence that reproduces.docs/DECISIONS.md— ADRs (active / superseded / rejected; never delete). Every decision gets one.FROZEN.md— completed evidence (result files, corpora, policies, specs) with sha256. A PreToolUse hook blocks edits to these paths. If a frozen file looks wrong, report it; don't fix it.- New benchmark runs go to new, versioned files (
benchmarks/results/v2/<testbed>_<YYYY-MM-DD>.{md,json}), never over a committed baseline (ADR-0001). Use/run-eval. - Module-specific rules live in
.claude/rules/*.mdand load when you touch matching paths. Read the relevant one before changing a module. - Files are the source of truth. If code and docs disagree, stop and ask. Mark anything uncertain
[UNVERIFIED]. - Ask before installing system packages, changing dependencies, pushing, or spending money (paid LLM runs).
Commands
Test env prefix (the local .env sets production mode, docker-only hostnames and a real API key, all of which break bare test runs):
DATABASE_URL="" TRUST_MEDIATOR_ENV=development REDIS_URL="" TRUST_MEDIATOR_API_KEYS="" TRUST_MEDIATOR_ADMIN_API_KEYS="" TRUST_MEDIATOR_ALLOW_INSECURE_HTTP=false
- Unit + integration tests:
.venv/bin/python -m pytest tests/ -q(expect 875 passed with the[grpc]extra installed; integration tests needDATABASE_URLblank → SQLite fallback, or the docker-compose Postgres running) - TypeScript client tests:
cd clients/typescript && npm test(expect 25 passed; runnpm install && npm run buildfirst) - Benchmarks:
.venv/bin/python -m benchmarks.cli --testbed memory_poisoning(seebenchmarks/README.md; the CLI pins its own env and DB, so it needs no env prefix) - Load/latency:
.venv/bin/python -m benchmarks.load(§8.1/§8.2 NFRs; same self-pinning env) - Lint:
.venv/bin/python -m ruff check trust_mediator/ tests/ - Run API locally:
.venv/bin/python -m uvicorn trust_mediator.api.app:app --reload --port 8000(docs at /docs) - Full stack:
docker compose up -d(service on :8000, Postgres, Redis) - Frozen hashes:
scripts/check_frozen.sh
Use python -m <tool>, not .venv/bin/<tool>: the venv was created at an older path, so its console-script shebangs are broken (the interpreter symlink still works). On Windows the venv is .venv\Scripts\python.exe; run the same -m commands, or use WSL.
Architecture rules — do not violate
Details, history and the tests that pin each rule are in .claude/rules/.
- Core invariant (PRD §5.2): data labelled
untrusted_dataorrisky_externalmay inform content but must NEVER enter the control path or authorise a tool call. Preserve this in any refactor. - Fail policy (PRD §9): side-effect operations (tool execution, memory writes, outbound responses) fail CLOSED on mediator error; only low-risk reads may fail open, and every fail-open must be audit-logged.
- Taint propagation: derived values inherit the most restrictive label of their inputs (
TrustLabel.most_restrictive). - All config via env: every tunable goes through
TRUST_MEDIATOR_*env vars intrust_mediator/config.py(pydantic-settings). Never hardcode thresholds, URLs, or keys. - Audit everything: every mediation decision and every control-plane action emits an audit event (SHA-256 hash chain). New decision points and admin routes must log. →
rules/audit.md - A classifier that cannot score raises
ClassifierUnavailable; it never returns 0.0. Async callers usescan_async. →rules/scanner.md - Every
/v1route takesAuthDep,CallerDeporAdminDep; control-plane writes takeAdminDep. Tenant is key-bound, never client-supplied. →rules/api-auth.md - A malformed policy must never widen authority; FR-OR-02 data-flow rules are per tenant and deny by default. →
rules/policy.md - Never classify a mediation verdict inline; the core install is the client SDK;
__all__is the public API contract. →rules/clients.md - Tool-output sanitization is an inbound rewrite, not an egress verdict (FR-OR-03). →
rules/output-sanitizer.md - The mediator never reads agent memory to decide authorisation. →
rules/memory-integrity.md - Traceability convention: cite PRD requirement IDs (FR-/NFR-) in module docstrings and test names, as existing code does.
Layout
trust_mediator/modules/— the 8 PRD components (ingress, trust_router, injection_scanner, tool_policy, memory_integrity, output_redaction, audit_log, policy_store), one package each;output_redaction/also holds the FR-OR-03sanitizer.py(inbound tool-output rewrite)trust_mediator/core/pipeline.py— wires the modules; the object API + SDK adapters usetrust_mediator/client.py— the client SDK (SCMLClient/AsyncSCMLClient); seerules/clients.mdfor the response shapesscml/— thin alias package sofrom scml import SCMLClientworks; re-exportstrust_mediatorand adds no second implementationclients/typescript/— zero-dependency Node/TS client mirroring the Python SDK method-for-method;npm packproduces the offline-installable tarballtrust_mediator/api/— FastAPI app, routers mirror PRD §10.2 endpoints; gRPC inapi/grpc/policies/— declarative YAML policy;defaultagent is deny-all by designbenchmarks/— testbeds (InjecAgent, AgentDojo, memory poisoning), load, soak, classifier eval; results inbenchmarks/results/tests/unit/per module,tests/integration/test_pipeline_e2e.pyend-to-enddocs/recovery/— Phase 0 analysis (2026-10-15) and the original ranked backlog;docs/DEPLOY_VPS.md— production runbook
Known gaps vs PRD (backlog — don't claim these exist)
Full text: rules/infra.md (TLS, secrets, audit overflow), rules/policy.md (per-agent policy), rules/benchmarks.md.
SCANNER_BACKEND=onnxfalls back to heuristic (no trained DeBERTa model shipped)- AgentDojo covers all four suites but only two attacks of seventeen. Do not describe AgentDojo coverage as complete.
- No sandboxed tool executor (PRD §11) — tool execution stays in the host app
PUT /v1/policystill replaces the whole document; per-agentPUT /v1/policy/agents/{id}is the routine path- TLS is supported but no shipped deployment except
docker-compose.prod.yml(Caddy) terminates TLS; Postgres, Redis and Kafka connections are plaintext - Secrets:
<VAR>_FILEsources exist; only API keys rotate live - Audit overflow is recorded (
audit_gap), not prevented; no spill-to-disk - Soak availability (100.000%) is in-process only, not a production uptime SLO
Measured state (PRD §14.2) — do not overstate
Full numbers, caveats and what has already been tried and rejected: rules/benchmarks.md. Headlines, each of which must be quoted with its caveat:
- Memory poisoning: 20.8% storage ASR vs < 10% target — §14.2 NOT met. Harm 18.8% pessimistic. Report both.
- InjecAgent (1054 external cases): all five §14.2 KPIs pass, but
no_tool_policyis 100.0% ASR: tool policy is the entire defence, and the injection scanner detects 0 of 1054. - AgentDojo: ASR 29.0% → 7.3% (949 attacked cases) for 19% of benign utility (74.2% → 59.8%). Quote benign utility, never attacked. CaMeL is better on both axes.
- §6.3 detection: no backend reaches FR-SC-07 (AUC 0.85). Best: affordance detector 0.779 (no-go), LLM 0.72 (also fails latency).
- Never tune against the in-house memory-poisoning corpus. Classifier work trains on external data and evaluates against the in-house corpus as held-out, never the reverse.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

