hyperlane-plugin-timeout 23.3.1

A per-route and global request deadline budget plugin for the Hyperlane framework with X-Request-Timeout clamping, Context RequestDeadline propagation, timeout_future async helper, and 504 Gateway Timeout enforcement.
Documentation
# AGENTS.md — `hyperlane-plugin-timeout`

Concise engineering and iteration guidelines for `hyperlane-plugin-timeout` (`plugin/timeout/`).
Global rules live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md), [`../README.md`](../README.md), and `~/.agents/skills/rust-standards/SKILL.md`.

## Scope & Module Boundaries

- **Role**: Global and per-prefix monotonic request deadline budgets (`RequestDeadline`), `X-Request-Timeout` tighten-only clamping, cooperative `timeout_future`, and `504` conversion hooks.
- **Dependencies**: Internal `hyperlane`; external `lombok-macros`.
- **Layout**: `src/{lib,const,enum,fn,impl,static,struct}.rs` (`TIMEOUT_PLUGIN` stays `pub(crate)`); tests in `tests/`.

## Core Iteration Invariants

- **Hook contract & order**: `TimeoutRequestHook` (`#[hyperlane::request_middleware(-112)]`) and `TimeoutResponseHook` (`#[hyperlane::response_middleware(82)]`) MUST stay transparent (`Status::Continue`) when unconfigured; response order `82` runs BEFORE `TracingResponseHook` (`90`) so exported spans observe `504` conversions.
- **Longest-prefix rules & `0` streaming exemption**: Sort normalized `prefix_timeouts` longest-prefix first on segment boundaries; effective budget `0` disables deadlines completely (omits `RequestDeadline` and ignores client header) for SSE/WebSocket/streaming routes.
- **Tighten-only client clamping**: When `honor_client_header` is true and `base_ms > 0`, `parse_timeout_header_ms` accepts `"5000"`/`"500ms"`/`"5s"` (rejecting `0`) and clamps `base_ms.min(client_ms)` so clients can never extend server budgets.
- **Monotonic cooperative timing**: Track deadlines via monotonic `std::time::Instant`; `timeout_future` passes through when no deadline exists, fails immediately when `remaining().is_zero()`, and formats `x-timeout-remaining-ms` without heap allocations.

## Code & Documentation Standards

- Follow `rust-standards`: pure 9-keyword filenames, 3-section `mod.rs`, centralized imports in `src/lib.rs` and `tests/mod.rs`, `pub(crate)` struct fields with `lombok-macros` accessors (no `self.field`), explicit types on all `let`/closure bindings, zero `#[allow]`/`unwrap()`/`expect()`/`panic!()`, `pub` before `pub(crate)` in `const.rs`/`static.rs`, strict `Cargo.toml` dependency order, and comment-free tests in `tests/`.
- Keep all code, comments, docs, and commits pure English. Update `plugin/timeout/README.md` (and `plugin/README.md` / root `README.md` if hook order or public surface changes) in the same commit.

## Local Verification

```sh
cargo run -p hyperlane-cli -- fmt --check
cargo clippy -p hyperlane-plugin-timeout --all-features --all-targets -- -D warnings
cargo test -p hyperlane-plugin-timeout --all-features
python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py .
python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py .
```