# `rho middleware`

## Purpose

`rho middleware` provides policy hooks between core actions.

It is how Rho handles approval, notification, and policy extensions without pushing those concerns into every command.

## Responsibilities

- inspect structured requests
- decide whether approval is required
- call adapters such as Telegram
- run middleware plugins such as audit, approval, and notification
- do audit logging of everything by default
- record decisions
- hand deterministic outcomes back to `rho run`, `rho messages`, or other commands

## Preserve From The Old System

- transport-agnostic approval middleware
- host-side policy outside the agent
- request-bound approvals rather than blanket trust

## Simplify

- middleware consumes typed manifests, not arbitrary text
- middleware is an adapter point, not the owner of execution semantics
- one approval model first
- middleware is not agentic / LLM accessible
- middleware is easily extensible with pre, post and other paradigms and abilities to register and unregister middleware in different orders

## Built-In Plugin Shape

Middleware should support built-in and optional plugins.

Initial plugin candidates:

- `audit`
- `approval`
- `telegram`

See:

- [rho-audit.md](/Users/madhavajay/dev/rho/main/docs/architecture/rho-audit.md)
- [rho-telegram.md](/Users/madhavajay/dev/rho/main/docs/architecture/rho-telegram.md)
