# AGENTS.md — `hyperlane-plugin-openapi`
Concise engineering and iteration guidelines for `hyperlane-plugin-openapi` (`plugin/openapi/`).
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**: OpenAPI `3.1.0` specification builder (`OpenApiSpec`, `OpenApiPlugin`), pre-serialized ETag-cached `/openapi.json` (`304`), self-contained zero-CDN `/docs` explorer, and `OpenapiHook`.
- **Dependencies**: Internal `hyperlane`; external `serde`, `serde_json`, `lombok-macros`.
- **Layout**: `src/{lib,const,fn,impl,static,struct}.rs` (`OPENAPI_PLUGIN` and HTML rendering helpers stay `pub(crate)`); tests in `tests/`.
## Core Iteration Invariants
- **Hook contract & order**: `OpenapiHook` (`#[hyperlane::request_middleware(-52)]`) MUST stay transparent (`Status::Continue`) when unconfigured or on non-matching paths/methods, and send prebuilt wire bytes before `Status::Reject` on `spec_path` and optional `docs_path`.
- **Startup pre-serialization & zero-alloc serving**: Serialize the OpenAPI `3.1.0` JSON, compute its strong quoted `XxHash3_64` ETag, and prebuild `spec_wire`, `spec_not_modified_wire` (`304`), and `docs_wire` once in `OpenApiPlugin::new`.
- **Deterministic spec & ETag stability**: Keep `paths`, `responses`, and `content` maps backed by `BTreeMap` and normalize HTTP methods to trimmed lowercase so output JSON and ETags are deterministic across runs.
- **Zero-CDN HTML escaping**: Keep `render_docs_html` self-contained with zero external CDN links and escape `title`, `version`, and `spec_path` via `html_escape` (`&`, `<`, `>`, `"`, `'`) to prevent XSS/attribute injection.
## 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/openapi/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-openapi --all-features --all-targets -- -D warnings
cargo test -p hyperlane-plugin-openapi --all-features
python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py .
python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py .
```