Expand description
Result-middleware pipeline.
A Middleware is invoked after a tool returns, with a mutable reference
to the egress value. SP-12 shipped one built-in (RedactPathsMiddleware)
to demonstrate the shape; the v3 brief’s full suite (pii_redact,
source_device_tag, compress, audit_log, rate_shape) is deferred.
Two hooks (SP-observability-completeness-v1 Axis A):
on_result— the SUCCESS path, and theExecutionFailedexit (whose wire shape is aToolResultResponse { success: false, result }, i.e. a result Value).on_error— theResponse::Errorpath (InvalidArgs/InternalError), whose wire shape is a baremessage: String+ optionaldetails. Default no-op; security-sensitive middleware override it. Before this SP, error paths bypassed middleware entirely (SP-12 §8 Q4) — that let a tool’s failure text (an arg echo, a panic message naming a patient) reach the LLM unredacted, a real PHI leak.
Structs§
- Redact
Paths Middleware - Redact absolute filesystem paths from tool output. Applies each
(pattern, replacement)pair in order to every string leaf in the result. Default construction viawith_home_default()redacts$HOME/...paths — a low-effort demonstration of the pattern, not a comprehensive PII scrubber.
Traits§
- Middleware
- A result-rewriting hook. Must be deterministic and side-effect-free
beyond the
result/ error mutation + any internal audit sinks the impl owns.