Skip to main content

Module middleware

Module middleware 

Source
Expand description

Result-middleware pipeline.

A Middleware is invoked on success after a tool returns, with a mutable reference to the result value. SP-12 ships 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.

Error paths bypass middleware in SP-12 — spec §8 Q4. A future SP can add an on_error hook once a real consumer exists.

Structs§

RedactPathsMiddleware
Redact absolute filesystem paths from tool output. Applies each (pattern, replacement) pair in order to every string leaf in the result. Default construction via with_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 mutation + any internal audit sinks the impl owns.