# AGENTS.md — `hyperlane-plugin-webhook`
Concise engineering and iteration guidelines for `hyperlane-plugin-webhook` (`plugin/webhook/`).
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**: Inbound HTTP webhook verifier with precomputed-midstate pure-Rust HMAC-SHA256 (`Hex`/`Base64`/`StripeTimestamped`), timestamp skew guard, 64-shard TTL replay cache, and `WebhookHook`.
- **Dependencies**: Internal `hyperlane`; external `lombok-macros` (zero external crypto crates).
- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,type}.rs` (`WEBHOOK_PLUGIN` and cache/hasher internals stay `pub(crate)`); tests in `tests/`.
## Core Iteration Invariants
- **Hook contract & order**: `WebhookHook` (`#[hyperlane::request_middleware(-58)]`) MUST return `Status::Continue` when unconfigured or on unmatched paths, inject `WebhookEvent` (`ATTR_WEBHOOK_EVENT`) on valid requests, and flush prebuilt `401`/`409`/`413` wire bytes before `Status::Reject` on failure.
- **Constant-time raw-body HMAC & secret redaction**: Sign raw `Request::get_body()` via precomputed ipad/opad midstates (keeping AArch64 `sha2` SIMD and scalar paths bit-identical with RFC 4231 test vectors); check ALL configured secrets and Stripe `v1=` candidates via `constant_time_eq` without early break; redact `Debug` output on `WebhookSecret` and `HmacSha256Key`.
- **Authenticate before replay insertion**: Match longest segment-bounded prefix, then strictly evaluate: body cap (`413`) -> signature parse (`401`) -> timestamp skew (`401`) -> HMAC verification (`401`) -> replay-cache insert (`409`). Never mutate the 64-shard domain-separated replay cache on unauthenticated requests.
- **Uniform error oracle resistance**: Collapse all signature/timestamp errors into one prebuilt `401` wire buffer, skip `SystemTime::now()` when neither replay TTL nor skew checks are enabled, and compute dynamic timestamps in end-to-end tests rather than hardcoding stale timestamps.
## 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/webhook/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-webhook --all-features --all-targets -- -D warnings
cargo test -p hyperlane-plugin-webhook --all-features
python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py .
python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py .
```