agentleFS
d-o-hubd-o-hub/do-harness/.agents/skills/fail-closed-proxy/SKILL.md

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".

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
  1. Very specific:

    Forward: only on Allow via POST to upstream.

    line 30
  2. Very specific:

    Keep AppState in its own module when server.rs nears 450 LOC.

    line 56

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. Decide via ProxyMediator::decide(&call); on Err, convert to Deny { reason: "mediator error: ..." }. Never allow on error.
  2. Count the decision (allow/deny, plus mediator_errors on Err) before any I/O.
  3. Audit best-effort: append Allow/Deny to the hash-chained JSONL log; on append failure increment audit_write_failures and keep the decision.
  4. Forward only on Allow via POST to 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 of ProxyMetrics (bearer token when metrics_token is set).
  • POST /mcp/tools/call — the deprecated flat mediation route; every response carries Deprecation: true and, with mcp-surface, Link: </mcp>; rel="successor-version".
  • POST /mcp — the MCP Streamable HTTP ingress, mounted at /mcp only with the mcp-surface feature (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 shared AppState.
  • Build routers with create_router_with_state(state) so tests can clone the metrics handle before moving state in.
  • Keep AppState in its own module when server.rs nears 450 LOC.

Tests (at least these)

  • 403 on invalid params (non-object params).
  • 502 on unreachable upstream with upstream_failures == 1.
  • Allow/deny counting plus /metrics snapshot 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 is Deny, not a forwarded call.
  • deny_unknown_fields on config and call types for forward compatibility.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.