fail-closed-proxy
Skill1 starsChanged 30 days agoMITView on GitHub
Build fail-closed HTTP tool-call mediation (decide, audit, forward) with observability counters. Use when adding a proxy endpoint that must deny on invalid params, governance denial, or mediator error, forward only on allow, and expose audit/metrics evidence. Triggers: "proxy", "fail-closed", "tool-call mediation", "guardian", "audit log", "proxy metrics".
In this repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- codacy-analysis-cliSkill
- codacy-cloud-cliSkill
- codacy-code-reviewSkill
- configure-codacy-cloudSkill
- configure-codacySkill
- crates-io-name-checkSkill
- event-modelerSkill
- harnessSkill
- htn-plannerSkill
- issue-to-prSkill
- move-only-decompositionSkill
- nested-build-isolationSkill
- npm-github-publishSkill
- pr-triageSkill
- setup-coverageSkill
- skill-creatorSkill
- skill-distillerSkill
- spike-runnerSkill
- tokio-performanceSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 30
Forward: only on Allow via POST to upstream.
- Very specific: line 56
Keep AppState in its own module when server.rs nears 450 LOC.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill 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
Guides
See references/heuristics.md for distilled heuristics.
Fail-Closed Proxy Skill
Purpose
Ship an HTTP sidecar that mediates tool calls with deny-by-default semantics plus audit and metrics evidence. Decisions never depend on observability.
Method: Decide-Audit-Forward
- Decide via
ProxyMediator::decide(&call); onErr, convert toDeny { reason: "mediator error: ..." }. Never allow on error. - Count the decision (
allow/deny, plusmediator_errorsonErr) before any I/O. - Audit best-effort: append
Allow/Denyto the hash-chained JSONL log; on append failure incrementaudit_write_failuresand keep the decision. - Forward only on
AllowviaPOSTto upstream; map outcomes to status:Deny->403, upstream send/read failure ->502+upstream_failures, body read ->upstream_ok.
Routes
GET /health— liveness probe (200 only while the mediator is initialized; 503 degraded).GET /metrics— JSON snapshot ofProxyMetrics(bearer token whenmetrics_tokenis set).POST /mcp/tools/call— the deprecated flat mediation route; every response carriesDeprecation: trueand, withmcp-surface,Link: </mcp>; rel="successor-version".POST /mcp— the MCP Streamable HTTP ingress, mounted at/mcponly with themcp-surfacefeature (the flat route keeps precedence for its exact path).
Both mediation routes sit behind the optional ingress_token bearer check, applied
after routing so an unauthenticated request never reaches mediation, audit, or the
upstream; a rejected request moves no counter and writes no audit record. There is
intentionally no POST / alias.
Counters (ProxyMetrics)
allow, deny, mediator_errors, upstream_ok, upstream_failures,
audit_write_failures, stub_decisions (decisions taken with agt-governance
off). Expose via GET /metrics; counters never change routing.
State Sharing
- Hold
metrics: Arc<ProxyMetrics>inside sharedAppState. - Build routers with
create_router_with_state(state)so tests can clone the metrics handle before moving state in. - Keep
AppStatein its own module whenserver.rsnears 450 LOC.
Tests (at least these)
403on invalid params (non-objectparams).502on unreachable upstream withupstream_failures == 1.- Allow/deny counting plus
/metricssnapshot keys. - Audit chain: allow then deny appends verify via
AuditLog::verify.
Gotchas
- Audit failure must not flip the decision — count it, return the original.
- Validate
params: non-object JSON isDeny, not a forwarded call. deny_unknown_fieldson config and call types for forward compatibility.
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.

