# AGENTS.md — `hyperlane-plugin-compression`
Concise engineering and iteration guidelines for `hyperlane-plugin-compression` (`plugin/compression/`).
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**: Full-duplex bounded request decompression (`br`/`gzip`/`deflate`) and `Accept-Encoding` response compression negotiation with MIME exclusions and `Vary` merging.
- **Dependencies**: Internal `hyperlane`, `http-compress`; external `lombok-macros`.
- **Layout**: `src/{lib,const,fn,impl,static,struct}.rs` (`COMPRESSION_PLUGIN` and MIME/header helpers stay `pub(crate)`); tests in `tests/`.
## Core Iteration Invariants
- **Hook contract & order**: `CompressionRequestHook` (`#[hyperlane::request_middleware(-104)]`) MUST run AFTER `BodyLimitHook` (`-106`), and `CompressionResponseHook` (`#[hyperlane::response_middleware(-55)]`) MUST run AFTER `CacheResponseHook` (`-65`) and `EtagResponseHook` (`-58`). Both return `Status::Continue` when unconfigured.
- **Bounded request decompression**: Reject unknown `Content-Encoding` with prebuilt `415`, enforce `decoded.len() <= max_decompressed_bytes` with prebuilt `413` (`Status::Reject`), and after decoding remove `Content-Encoding` and sync `Content-Length`.
- **Response skip guards**: Never compress bodyless statuses (`1xx`/`204`/`304`), bodies below `min_body_bytes`, responses already carrying `Content-Encoding`, `Cache-Control: no-transform`, or excluded media types (`image/`, `video/`, `audio/`, `font/`, compressed archives, `text/event-stream`).
- **Negotiation & `Vary` hygiene**: Fall back across enabled codecs (`br`/`gzip`/`deflate`) per `Accept-Encoding`, and merge `Accept-Encoding` into `Vary` without duplicating tokens or overriding `*`.
## 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/compression/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-compression --all-features --all-targets -- -D warnings
cargo test -p hyperlane-plugin-compression --all-features
python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py .
python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py .
```