diff --git a/.agents/skills/hyperlane/SKILL.md b/.agents/skills/hyperlane/SKILL.md deleted file mode 100644 index e297cc75..00000000 --- a/.agents/skills/hyperlane/SKILL.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -name: hyperlane -description: 'Use when implementing or debugging the Hyperlane Rust HTTP framework: server routes, lifecycle hooks, Context, request targets, the plugin crates, or the perf harness. Publishing to ltpp.vip uses hyperlane-upload instead.' -license: MIT -metadata: - hermes: - related_skills: [rust-standards, git-standards] ---- - -# Hyperlane workspace standards and workflow - -## Mandatory Standards - -1. Load `rust-standards` before editing any `.rs` or `Cargo.toml` file. Resolve authoritative crate membership and versions from `Cargo.toml` / `cargo metadata --no-deps --format-version 1`. -2. Enforce core `ServerHook` and HTTP wire invariants: - -- `Server::route::(path)` and middleware registrations are synchronous (`&mut Self`; never `.await`). -- `Server::run().await` returns `Result>`; propagate errors and never mask bind failures. -- `ServerHook::new(stream, ctx)` / `handle(self, stream, ctx)` take `stream` first; use `ctx.build_response()` for HEAD-aware serialization; send bytes before returning `Status::Reject`. -- Maintain RFC 9110/9112 wire conformance: bodyless 1xx/204/205/304 handling, bounded chunked decoding, `Expect: 100-continue`, request smuggling rejection, CRLF validation, decompression bomb caps (`64 MiB`), and keep-alive `Context` resets. - -3. Enforce workspace boundaries & visibility: - -- Keep `hyperlane-core` internals (`listener`, `protocol`, `tls`) `pub(crate)` and put wire/transport fixes in `core/src/protocol/`, never in route handlers. -- Keep public struct fields `pub(crate)` with generated `get_*`/`set_*` accessors; keep plugins opt-in and transparent (`Status::Continue`) when unconfigured. -- Register every new publishable plugin in root `Cargo.toml` `[workspace] members` and `.github/workflows/rust.yml` `PACKAGES`. - -4. Keep `hyperlane fmt` layered on `crate-cli`: `hyperlane fmt` MUST invoke `crate_cli::execute_unified_fmt` (Prettier-aligned `.md`/`.yml`/`.json`/`.toml` + derives + `cargo fmt`) first, then Hyperlane attribute normalization and `cargo fmt --all`. - -## Verification Workflow - -Run every gate locally before committing or pushing: - -```sh -cargo run -p hyperlane-cli -- fmt -cargo run -p hyperlane-cli -- fmt -cargo run -p hyperlane-cli -- fmt --check -cargo fmt --all -- --check -cargo clippy --workspace --all-features --all-targets -- -D warnings -cargo test --workspace --all-features -cargo check --release --workspace --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` - -Always exercise real request/response wire bytes for protocol changes and reclaim all task-owned listeners/processes on exit. - -## Release & Downstream Cascade Workflow - -`hyperlane` is **Tier 2** (depends on published `ctares`; consumed by `hyperlane-quick-start`, `commerce-suite`, and `web-frameworks`): - -1. Wait until upstream `ctares` is live on `crates.io`, then upgrade `crate-cli`, `color-output`, `lombok-macros`, and `tokio-broadcast` in root `Cargo.toml`. -2. Bump `[workspace.package].version` and internal `[workspace.dependencies]` pins in root `Cargo.toml`. -3. Run `hyperlane fmt` so `.github/workflows/*.yml` are pre-formatted (preventing CI's `GITHUB_TOKEN` from attempting workflow pushes during `publish`). -4. Validate commit/PR text via `verify_english_only.py`, push/merge to `master`, and wait until `.github/workflows/rust.yml` (`setup`, `check`, `tests`, `clippy`, `build`, `publish`, `release`) finishes green on `crates.io`. -5. Cascade upgrades to Tier 3 (`hyperlane-quick-start`, `commerce-suite`) and Tier 4 (`web-frameworks`). - -## Documentation & Skill Governance - -- Update root `README.md`, `/README.md`, and `plugin/README.md` in the same commit whenever adding/changing crates, plugins, wire invariants, CLI subcommands, or CI jobs. -- Keep `.agents/skills/hyperlane/SKILL.md` and `~/.agents/skills/hyperlane/SKILL.md` synchronized and strictly limited to standards, requirements, and workflows (`<= 160` lines); run `audit_skills.py` and `update_skill_lock.py` after edits. - -## Reference Index - -Consult cached references only as secondary lookup (source and compiler remain authoritative; ltpp.vip uploads use [hyperlane-upload](../hyperlane-upload/SKILL.md)): [Core](references/api-core.md) · [Macros](references/api-macros.md) · [HTTP Types](references/api-type.md) · [Client](references/api-request.md) · [Compression](references/api-compress.md) · [Constants](references/api-constant.md) · [Negotiate](references/plugin-negotiate.md) · [Plugins](references/plugins.md) · [Wire](references/wire-behaviour.md) · [WS](references/hyperlane-plugin-websocket.md) · [SSE](references/sse.md) · [Bench](references/bench.md) · [Release](references/release-bump-flow.md) · [Ownership](references/request-path-ownership.md) · [Visibility](references/field-visibility.md). diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..8e2fb533 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,63 @@ +# AGENTS.md — Hyperlane Architecture & Standards + +Mandatory architectural, engineering, formatting, verification, and documentation governance rules for all contributors and AI coding agents working in `hyperlane`. + +--- + +## 1. Project Architecture + +`hyperlane` is a unified Rust 2024 Cargo workspace (`Cargo.toml`) delivering a cross-platform (Linux, macOS, Windows) multi-protocol asynchronous HTTP server framework (`HTTP/1.x`, `HTTP/2`, `HTTP/3`), standalone HTTP client, procedural macro suite, developer CLI, benchmark harness, and an opt-in plugin ecosystem. + +- **Root-Cause Redesign Over Patchwork**: Fix architectural, protocol, and transport flaws at their source in core and wire layers rather than layering workarounds in route handlers or plugins. + +| Crate / Module | Path | Architectural Responsibility | +| :------------- | :------------- | :----------------------------------------------------------------------------------------- | +| Facade | `src/` | Re-exports server core and procedural macros; contains no protocol or middleware logic. | +| Constants | `constant/` | Zero-dependency canonical HTTP protocol constants shared across the workspace. | +| Compression | `compress/` | Leaf bounded compression codecs and content-encoding negotiation without runtime coupling. | +| Wire Types | `type/` | RFC-compliant HTTP wire types, parsers, builders, and transport primitives. | +| HTTP Client | `request/` | Standalone sync and async HTTP client layered on wire types without server-core coupling. | +| Server Core | `core/` | Multi-protocol async server engine, router, request context, and hook lifecycle. | +| Proc Macros | `macros/` | Procedural attribute macros for routing, lifecycle hooks, and middleware registration. | +| Developer CLI | `cli/` | Workspace formatting, project scaffolding, template management, and watch tooling. | +| Benchmarks | `performance/` | Reproducible native and container throughput, latency, and allocation benchmark harness. | +| Plugin Suite | `plugin/*/` | Opt-in, mutually decoupled framework plugins with zero inter-plugin dependencies. | + +--- + +## 2. Core Engineering Standards + +### 2.1 Protocol, API & Plugin Architecture Standards + +- **Strict Acyclic Layering**: Preserve one-way workspace dependency flow from leaf constants and codecs through wire types to server core, client, facade, and independent plugins. +- **Encapsulation & Visibility**: Keep internal transport, listener, TLS, and protocol modules crate-private, and keep fields on public structs crate-private behind generated accessors. +- **Wire & Lifecycle Contracts**: Keep route and middleware registration synchronous, propagate server bind failures, maintain strict RFC wire and decompression safety bounds, and send response bytes before rejecting downstream pipelines. +- **Opt-In Plugin Transparency**: Every plugin MUST remain inactive and transparent when unconfigured, avoid hook-priority collisions, and be registered in `Cargo.toml` and release CI workflows when publishable. +- **Hygienic Macro Codegen**: Procedural macro expansions MUST use fully qualified crate paths, emit zero `use` statements, and stay free of redundant generated documentation bloat. + +### 2.2 Quality, Tooling & Hygiene Standards + +- **Rust Engineering Standards**: Follow `~/.agents/skills/rust-standards` without exception. +- **Idempotent Unified Formatting**: Keep workspace formatting layered on `crate-cli` via `hyperlane fmt`, `crate fmt`, and `cargo fmt` with double-run idempotency across Rust and repository text formats. +- **Pure English & Git Hygiene**: Keep all code, comments, documentation, commits, and PR text pure English per `~/.agents/skills/git-standards`, and never bypass repository git hooks. +- **Clean Artifacts & Test Hygiene**: Exercise real wire bytes for protocol changes, reclaim all spawned listeners and child processes on exit, and never commit build, certificate, or benchmark outputs. + +--- + +## 3. Governance, Skills & Verification + +Keep human-facing `README.md`, crate `README.md`, and `plugin/README.md` files strictly free of AI/agent governance per `~/.agents/skills/agents-standards`. Project skills are centralized under `~/.agents/skills/`: + +| Skill | Directory | Domain | +| :------------------------ | :----------------------------------------- | :------------------------------------------------------------------ | +| `hyperlane` | `~/.agents/skills/hyperlane` | Hyperlane architecture, server/wire/plugin standards & release flow | +| `agents-standards` | `~/.agents/skills/agents-standards` | `AGENTS.md`, global skill, and `README.md` governance standards | +| `rust-standards` | `~/.agents/skills/rust-standards` | Mandatory Rust module layout, typing, linting & safety gates | +| `git-standards` | `~/.agents/skills/git-standards` | Pure-English commits, hook compliance & branch policy | +| `gh-pr-creation-workflow` | `~/.agents/skills/gh-pr-creation-workflow` | Pull request creation, CI verification & squash-merge delivery | + +### Mandatory Pre-Merge Gate Sequence + +1. **Formatting**: Run `cargo run -p hyperlane-cli -- fmt` twice, then verify zero diffs with `cargo run -p hyperlane-cli -- fmt --check`, `crate fmt --check`, and `cargo fmt --all -- --check`. +2. **Static Analysis & Tests**: Pass `cargo clippy --workspace --all-features --all-targets -- -D warnings`, `cargo test --workspace --all-features`, `cargo check --release --workspace --all-features`, and all gates in `~/.agents/skills/rust-standards`, `~/.agents/skills/agents-standards`, and `~/.agents/skills/git-standards`. +3. **Version Bump & Delivery**: Bump `[workspace.package].version` and internal `[workspace.dependencies]` pins together in `Cargo.toml`, synchronize affected docs (`README.md`, `plugin/README.md`, `AGENTS.md`), and deliver per `~/.agents/skills/git-standards` and `~/.agents/skills/gh-pr-creation-workflow`. diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 40ea13b0..00000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -# CLAUDE.md - -See [README.md](README.md) for workspace overview, crate architecture, quick start, and local verification commands. - -For workspace standards, `ServerHook` and HTTP wire invariants, plugin patterns, `http-request` client usage, and performance benchmarking guides, read [.agents/skills/hyperlane/SKILL.md](.agents/skills/hyperlane/SKILL.md). diff --git a/Cargo.toml b/Cargo.toml index a744062f..4119ca2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "web-programming"] exclude.workspace = true [workspace.package] -version = "23.3.1" +version = "23.3.2" readme = "README.md" edition = "2024" authors = ["root@devhub.vip"] @@ -86,13 +86,13 @@ members = [ ] [workspace.dependencies] -hyperlane = { path = ".", version = "23.3.1" } -http-type = { path = "type", version = "23.3.1" } -hyperlane-core = { path = "core", version = "23.3.1" } -http-request = { path = "request", version = "23.3.1" } -http-compress = { path = "compress", version = "23.3.1" } -http-constant = { path = "constant", version = "23.3.1" } -hyperlane-macros = { path = "macros", version = "23.3.1" } +hyperlane = { path = ".", version = "23.3.2" } +http-type = { path = "type", version = "23.3.2" } +hyperlane-core = { path = "core", version = "23.3.2" } +http-request = { path = "request", version = "23.3.2" } +http-compress = { path = "compress", version = "23.3.2" } +http-constant = { path = "constant", version = "23.3.2" } +hyperlane-macros = { path = "macros", version = "23.3.2" } h3 = "0.0.8" h2 = "0.4.20" diff --git a/README.md b/README.md index f27f7377..1fcc5ca2 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,16 @@ **High-Performance Multi-Protocol Asynchronous Rust HTTP/1.x · HTTP/2 · HTTP/3 Web Framework & Plugin Ecosystem** -[![Crates.io](https://flat.badgen.net/crates/v/hyperlane)][crate] +_Tokio-Powered · Strict RFC 9110/9112 Wire Conformance · 40 Opt-In Zero-Overhead Plugins · Cross-Platform_ + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane)][crate] +[![Crates.io Downloads](https://flat.badgen.net/crates/d/hyperlane)][downloads] [![Docs.rs](https://img.shields.io/docsrs/hyperlane?style=flat-square)][api] -[![Rust CI](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)][ci] +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)][ci] [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) -[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](./LICENSE) -[API Docs][api] · [Quick Start](#quick-start) · [Workspace Architecture](#workspace-architecture) · [Plugin Ecosystem](#opt-in-plugin-ecosystem) · [Benchmarks](#benchmarks) +[API Docs][api] · [Quick Start](#quick-start) · [Workspace Architecture](#workspace-architecture) · [Plugin Ecosystem](./plugin/README.md) · [Benchmarks](#benchmarks) @@ -20,7 +23,7 @@ ## Overview -**Hyperlane** is a high-performance asynchronous Rust web framework built on Tokio. It serves HTTP/1.0, HTTP/1.1, HTTP/2 (`h2c`/`h2`), HTTP/3 (QUIC), WebSocket, Server-Sent Events (SSE), gRPC, JSON-RPC, GraphQL, and Model Context Protocol (MCP) workloads with explicit control over the request and response lifecycle, strict RFC 9110/9112 wire conformance, and 40 opt-in zero-overhead plugins. +**Hyperlane** is a high-performance asynchronous Rust web framework built on Tokio. It serves HTTP/1.0, HTTP/1.1, HTTP/2 (`h2c`/`h2`), HTTP/3 (QUIC), WebSocket, Server-Sent Events (SSE), gRPC, JSON-RPC, GraphQL, and Model Context Protocol (MCP) workloads with explicit lifecycle hooks, strict RFC 9110/9112 wire conformance, and 40 opt-in zero-overhead plugins across Linux, macOS, and Windows. ```mermaid flowchart LR @@ -28,7 +31,7 @@ flowchart LR Facade --> Core["hyperlane-core\nHTTP/1.x · HTTP/2 · HTTP/3 · io_uring"] Facade --> Macros["hyperlane-macros\n#[route] · #[send] · #[hyperlane]"] Core --> Wire["http-type · http-constant · http-compress"] - App --> Plugins["40 Opt-In Plugins\nAudit · Auth · Body Limit · Cache · Canary · Compression · GraphQL · OpenAPI · Tenant ..."] + App --> Plugins["40 Opt-In Plugins\nAuth · Cache · CORS · Gateway · GraphQL · gRPC · OpenAPI · Rate Limit ..."] Plugins --> Client["http-request\nSync & Async H1/H2 Client"] Tooling["hyperlane-cli (hyperlane fmt) · hyperlane-performance"] -.-> Facade ``` @@ -37,7 +40,7 @@ flowchart LR ## Quick Start -Create a binary crate targeting Rust edition 2024 and add `hyperlane`: +Create a Rust edition 2024 binary crate and add `hyperlane`: ```sh cargo new hello-hyperlane @@ -89,51 +92,36 @@ Run `cargo run` and query the endpoint: curl -fsS http://127.0.0.1:3000/ ``` -`#[hyperlane::send]` serializes and flushes the response built by the hook; `Status::Reject` stops the remaining pipeline so downstream hooks do not send a second response. - ---- - -## Capabilities - -| Area | Support | -| :------------------ | :------------------------------------------------------------------------------------------------------------------------------------ | -| **HTTP/1.x** | HTTP/1.0 and HTTP/1.1 over TCP with optional TLS, keep-alive `Context` reset, and bounded chunked decoding | -| **HTTP/2** | Cleartext (`h2c`) with prior knowledge or TLS with ALPN (`h2`) | -| **HTTP/3** | QUIC with TLS (`quinn` + `h3`) | -| **Routing & Hooks** | Synchronous radix routing (`{param:regex}` anchored), typed request/response middleware, and `ServerHook` lifecycle | -| **Realtime & RPC** | WebSocket rooms, WHATWG SSE, raw TCP, gRPC over HTTP/2, JSON-RPC 2.0, and Streamable HTTP MCP | -| **Tooling** | `hyperlane fmt` (delegating to `crate-cli` Prettier-aligned formatting + Hyperlane attribute normalization) and CPU-pinned benchmarks | - -Select the wire protocol per listener via [`ServerConfig`][config]. +`#[hyperlane::send]` serializes and flushes the response built by the hook; `Status::Reject` stops the remaining pipeline so downstream hooks do not send a duplicate response. --- ## Workspace Architecture -All 49 crates share a unified version in root `Cargo.toml` (Rust edition `2024`): +All 49 crates share a unified version in root [`Cargo.toml`](./Cargo.toml) (Rust edition `2024`): ### Core, Wire & Tooling Crates (9) | Crate | Path | Responsibility | | :------------------------------------------------- | :------------- | :------------------------------------------------------------------------------------------------------------------------- | -| [`hyperlane`][api] | `.` (`src/`) | Facade crate re-exporting `hyperlane-core` and `hyperlane-macros` | -| [`hyperlane-core`](./core/README.md) | `core/` | Multi-protocol async server (`HTTP/1.x`, `HTTP/2`, `HTTP/3`), router, `Context`, `ServerHook`, Linux `io_uring` | -| [`hyperlane-macros`](./macros/README.md) | `macros/` | Procedural attribute macros (`#[route]`, `#[hyperlane]`, `#[send]`, `#[host]`, `#[referer]`, etc.) | -| [`http-type`](./type/README.md) | `type/` | RFC 9110/9112 wire parsers/builders, `Request`, `Response`, `Stream`, `Cookie`, `MultipartFormData`, `WebSocket`, `Status` | -| [`http-constant`](./constant/README.md) | `constant/` | Canonical HTTP header, method, status, and symbol constants | -| [`http-compress`](./compress/README.md) | `compress/` | Bounded gzip, deflate, and brotli codecs (`MAX_DECOMPRESSED_BYTES = 64 MiB`) and `Accept-Encoding` negotiation | -| [`http-request`](./request/README.md) | `request/` | Sync & async HTTP/1.1 + HTTP/2 client with pooling, TLS resumption, retries, multipart, and HTTP/SOCKS5 proxies | -| [`hyperlane-cli`](./cli/README.md) | `cli/` | Developer CLI (`hyperlane fmt` layered on `crate-cli`, `watch`, `new`, `template`) | -| [`hyperlane-performance`](./performance/README.md) | `performance/` | Official CPU-pinned native & Docker loadgen and deterministic `alloc-count` benchmark harness | +| [`hyperlane`][api] | `src/` | Facade crate re-exporting `hyperlane-core` and `hyperlane-macros` | +| [`hyperlane-core`](./core/README.md) | `core/` | Multi-protocol async server (`HTTP/1.x`, `HTTP/2`, `HTTP/3`), radix router, `Context`, `ServerHook`, Linux `io_uring` | +| [`hyperlane-macros`](./macros/README.md) | `macros/` | Procedural attribute macros (`#[route]`, `#[hyperlane]`, `#[send]`, `#[host]`, `#[referer]`, middleware registration) | +| [`http-type`](./type/README.md) | `type/` | RFC 9110/9112 wire parsers/builders, `Request`, `Response`, `Stream`, `Cookie`, `WebSocket`, `Status`, concurrent wrappers | +| [`http-constant`](./constant/README.md) | `constant/` | Zero-dependency canonical HTTP header, method, status, MIME, and protocol constants | +| [`http-compress`](./compress/README.md) | `compress/` | Bounded gzip, deflate, and brotli codecs (`64 MiB` cap) and `Accept-Encoding` negotiation | +| [`http-request`](./request/README.md) | `request/` | Standalone sync & async HTTP/1.1 + HTTP/2 client with connection pooling, TLS resumption, retries, and proxy support | +| [`hyperlane-cli`](./cli/README.md) | `cli/` | Developer CLI (`hyperlane fmt`, `watch`, `new`, `template`) | +| [`hyperlane-performance`](./performance/README.md) | `performance/` | Reproducible CPU-pinned native & Docker loadgen and deterministic `alloc-count` benchmark harness | ### Opt-In Plugin Ecosystem (40) -Every plugin is opt-in and transparent (`Status::Continue`) when unconfigured (see [`plugin/README.md`](./plugin/README.md)): +Every plugin is opt-in and transparent (`Status::Continue`) when unconfigured (see the [Plugin Catalog](./plugin/README.md)): | Plugin Crate | Path | Responsibility | | :----------------------------------------------------------------------- | :------------------------ | :--------------------------------------------------------------------------------------------------------------- | | [`hyperlane-plugin-audit`](./plugin/audit/README.md) | `plugin/audit/` | Tamper-evident SHA-256 hash-chained audit trail, bounded ring buffer, pluggable `AuditSink`, header redaction | -| [`hyperlane-plugin-auth`](./plugin/auth/README.md) | `plugin/auth/` | HS256 JWT (`kid` rotation), API key, HTTP Basic, RBAC `AuthPrincipal`, `AuthHook` | +| [`hyperlane-plugin-auth`](./plugin/auth/README.md) | `plugin/auth/` | Pure-Rust HS256 JWT (`kid` rotation), API key, HTTP Basic, RBAC `AuthPrincipal`, `AuthHook` | | [`hyperlane-plugin-body-limit`](./plugin/body_limit/README.md) | `plugin/body_limit/` | Granular global, segment-bounded prefix, and MIME request payload size limits with prebuilt `413` responses | | [`hyperlane-plugin-cache`](./plugin/cache/README.md) | `plugin/cache/` | 64-way sharded bounded cache, single-flight coalescing, `CacheRequestHook`/`CacheResponseHook` | | [`hyperlane-plugin-canary`](./plugin/canary/README.md) | `plugin/canary/` | Feature flags, A/B testing & deterministic `XxHash3_64` basis-point sticky rollouts, `X-Variant` + `Vary` | @@ -175,48 +163,37 @@ Every plugin is opt-in and transparent (`Status::Continue`) when unconfigured (s --- -## Protocol Notes - -These notes describe the current checkout. For behavior of an installed version, see [release notes][releases] and [API documentation][api]. +## Benchmarks -- **Conditional requests**: `Request::matches_if_none_match(current_etag)` performs allocation-free weak ETag comparison (including repeated headers, quoted tags with commas, and `*`). Callers control `304 Not Modified` / `412 Precondition Failed` status selection. -- **HTTP/1.1 request bodies**: `Transfer-Encoding: chunked` is decoded transparently with bounded body limits; chunk extensions and trailers are consumed. -- **Default request errors**: Unparseable or oversized requests emit an empty error response (closing HTTP/1.x connections or completing H2/H3 streams) unless overridden by request-error hooks. +The [performance workflow][perf] runs [`hyperlane-performance`](./performance/README.md) in a CPU-pinned Docker harness comparing baseline and candidate revisions in the same measurement window across `h1`, `h1-tls`, `h2c`, `h2-tls`, `h3`, and deterministic `alloc-count`. --- -## Benchmarks +## Documentation -The [performance workflow][perf] runs the CPU-pinned Docker harness against baseline and candidate revisions in the same measurement window across `h1`, `h1-tls`, `h2c`, `h2-tls`, `h3`, and deterministic `alloc-count`. +- **[API Reference][api]** — Complete rustdoc reference on docs.rs. +- **[Plugin Ecosystem Guide](./plugin/README.md)** — Hook execution order, configuration model, and all 40 official plugins. +- **[Production Starter Template][example]** — Ready-to-run service template (`hyperlane-quick-start`). +- **[Release Notes][releases]** — Version history and protocol migration notes. --- -## Verification & Governance +## Contributing -Before pushing or opening a pull request, run the full local quality gate: +https://github.com/hyperlane-dev/hyperlane/pulls -```sh -cargo run -p hyperlane-cli -- fmt -cargo run -p hyperlane-cli -- fmt -cargo run -p hyperlane-cli -- fmt --check -cargo fmt --all -- --check -cargo clippy --workspace --all-features --all-targets -- -D warnings -cargo test --workspace --all-features -cargo check --release --workspace --all-features -``` +## License -- Engineering standards, wire invariants, module boundaries, and project-specific agent workflows live in [`.agents/skills/hyperlane/SKILL.md`](./.agents/skills/hyperlane/SKILL.md). -- Production starter template: [`hyperlane-quick-start`][example]. +This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details. -## License +## Contact -Hyperlane is distributed under the [MIT License](LICENSE). +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). [api]: https://docs.rs/hyperlane/latest/hyperlane/ [ci]: https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml -[config]: https://docs.rs/hyperlane/latest/hyperlane/struct.ServerConfig.html [crate]: https://crates.io/crates/hyperlane +[downloads]: https://crates.io/crates/hyperlane [example]: https://github.com/hyperlane-dev/hyperlane-quick-start -[issues]: https://github.com/hyperlane-dev/hyperlane/issues [perf]: https://github.com/hyperlane-dev/hyperlane/actions/workflows/perf.yml [releases]: https://github.com/hyperlane-dev/hyperlane/releases diff --git a/cli/AGENTS.md b/cli/AGENTS.md deleted file mode 100644 index 17badf1b..00000000 --- a/cli/AGENTS.md +++ /dev/null @@ -1,33 +0,0 @@ -# AGENTS.md — `hyperlane-cli` - -Concise engineering and iteration guidelines for `hyperlane-cli` (`cli/`). -Global workspace rules live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md) and `~/.agents/skills/rust-standards/SKILL.md`. - -## Scope & Module Boundaries - -- **Role**: Developer CLI (`hyperlane` binary) delivering `hyperlane fmt`, `watch`, `new`, `template`, `help`, and `version`. -- **Dependencies**: `crate-cli`, `tokio`, `notify`, `log`, `thiserror`, `color-output`, `lombok-macros` (do NOT duplicate formatting engines already provided by `crate-cli`). -- **Layout**: Library entry `src/lib.rs`, binary entry `src/main.rs`, modules `command`, `config`, `fmt`, `help`, `logger`, `new`, `template`, `version`, `watch`; tests in `tests/`. - -## Core Iteration Invariants - -- `hyperlane fmt` MUST invoke `crate_cli::execute_unified_fmt` first (Prettier 3.7.4 + Taplo 0.7.0 alignment, `.prettierignore` honoring, no-op file preservation), followed by Hyperlane attribute normalization and `cargo fmt --all`. -- Preserve strict double-run idempotency: running `hyperlane fmt` twice followed by `hyperlane fmt --check` MUST produce zero diffs and exit `0`. -- Keep `new` and `template` scaffolds aligned with current `hyperlane` Rust 2024 APIs (`ServerHook`, `ServerConfig`, `Status`) and `rust-standards` layout rules. -- Ensure `watch` debounces reliably and cleanly terminates spawned child processes on rebuild or exit without leaking processes. - -## Code & Documentation Standards - -- Follow `rust-standards`: pure 9-keyword filenames, 3-section `mod.rs` (zero comments), centralized imports in `src/lib.rs` and `tests/mod.rs`, `pub(crate)` struct fields with `lombok-macros` accessors (no direct `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 `cli/README.md` (and root `README.md` if CLI commands/flags change) in the same commit. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p hyperlane-cli --all-features --all-targets -- -D warnings -cargo test -p hyperlane-cli --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/cli/README.md b/cli/README.md index b1067bb9..44fb4ad2 100644 --- a/cli/README.md +++ b/cli/README.md @@ -1,11 +1,14 @@
+hyperlane-cli logo + # hyperlane-cli -**Hyperlane Developer CLI & Unified Formatter** +**Hyperlane Developer CLI, Project Scaffolding & Unified Formatter** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-cli)](https://crates.io/crates/hyperlane-cli) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-cli?style=flat-square)](https://docs.rs/hyperlane-cli) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-cli)](https://crates.io/crates/hyperlane-cli) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-cli?style=flat-square)](https://docs.rs/hyperlane-cli) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../LICENSE) @@ -17,36 +20,30 @@ ## Overview -Command-line toolchain providing `hyperlane fmt` (delegating to `crate-cli` unified Prettier-aligned formatting followed by Hyperlane attribute normalization), `watch`, `new`, and `template` scaffolding. +`hyperlane-cli` is the official command-line developer toolchain for [`hyperlane`](../README.md), providing deterministic workspace formatting, project/template scaffolding, and live reload workflows. -This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. +## Installation -## Responsibilities & Module Layout +```sh +cargo install hyperlane-cli +``` -- `fmt` — `execute_fmt` running `crate_cli::execute_unified_fmt` first then Hyperlane attribute formatting -- `watch` / `new` / `template` — Live cargo-watch dev loop and project/component scaffolding - -## Installation +## Usage ```sh -cargo add hyperlane-cli +hyperlane new my-service +hyperlane fmt --check +hyperlane watch ``` ## Verification -Run crate-scoped formatting, lint, and test gates from the workspace root: - ```sh cargo run -p hyperlane-cli -- fmt --check cargo clippy -p hyperlane-cli --all-features --all-targets -- -D warnings cargo test -p hyperlane-cli --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details. diff --git a/compress/AGENTS.md b/compress/AGENTS.md deleted file mode 100644 index 2ec22157..00000000 --- a/compress/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `http-compress` - -Concise engineering and iteration guidelines for `http-compress` (`compress/`). -Global workspace rules live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md) and `~/.agents/skills/rust-standards/SKILL.md`. - -## Scope & Module Boundaries - -- **Role**: Bounded gzip, deflate, and brotli HTTP codecs, RFC 9110 `Accept-Encoding` negotiation, and `XxHash3_64` hashing helpers. -- **Dependencies**: Leaf crate (`brotli`, `flate2`, `twox-hash` only). Do NOT depend on `http-type`, `hyperlane-core`, or async runtimes. -- **Layout**: Public `compress` (`Compress`) and `xx_hash3_64`; internal codec modules `brotli`, `deflate`, `gzip`; tests in `tests/`. - -## Core Iteration Invariants - -- Strictly enforce `MAX_DECOMPRESSED_BYTES` (`64 MiB`) across gzip, deflate, and brotli decompression paths; never introduce unbounded `read_to_end` reads or zip-bomb amplification. -- Keep `Compress::from_accept_encoding` zero-allocation with exact integer (`u16`) q-value parsing per RFC 9110 (avoid float rounding drift and respect `q=0` rejections). -- Preserve pre-sized encode/decode output buffers and ensure reusable thread-local codec state is fully reset across invocations. -- Keep `XxHash3_64` hashing deterministic and allocation-free because downstream routing and plugins rely on it on hot paths. - -## Code & Documentation Standards - -- Follow `rust-standards`: pure 9-keyword filenames, 3-section `mod.rs` (zero comments), centralized imports in `src/lib.rs` and `tests/mod.rs`, `pub(crate)` struct fields with `lombok-macros` accessors (no direct `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 `compress/README.md` alongside any public API or codec limit change. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p http-compress --all-features --all-targets -- -D warnings -cargo test -p http-compress --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/compress/README.md b/compress/README.md index 976afbc6..aa893fe1 100644 --- a/compress/README.md +++ b/compress/README.md @@ -1,11 +1,14 @@
+http-compress logo + # http-compress -**Bounded HTTP Compression & Accept-Encoding Negotiation** +**Bounded Gzip, Deflate & Brotli HTTP Compression Codecs** -[![crates.io](https://flat.badgen.net/crates/v/http-compress)](https://crates.io/crates/http-compress) -[![docs.rs](https://img.shields.io/docsrs/http-compress?style=flat-square)](https://docs.rs/http-compress) +[![Crates.io Version](https://flat.badgen.net/crates/v/http-compress)](https://crates.io/crates/http-compress) +[![Docs.rs](https://img.shields.io/docsrs/http-compress?style=flat-square)](https://docs.rs/http-compress) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../LICENSE) @@ -17,13 +20,7 @@ ## Overview -Gzip, deflate, and brotli encoders/decoders with strict decompression bomb caps (`MAX_DECOMPRESSED_BYTES = 64 MiB`) and zero-allocation RFC 9110 `Accept-Encoding` negotiation. - -This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `compress` — `Compress::from_accept_encoding`, `as_str`, and bounded stream codecs +`http-compress` provides bounded HTTP payload compression and decompression codecs (`gzip`, `deflate`, `brotli`) and `Accept-Encoding` negotiation shared by [`hyperlane`](../README.md) servers, clients, and middleware plugins. ## Installation @@ -31,9 +28,18 @@ This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 work cargo add http-compress ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use std::borrow::Cow; +use http_compress::Compress; + +fn compress_payload(payload: &[u8]) -> Cow<'_, [u8]> { + Compress::Gzip.encode(payload, 4096) +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +47,6 @@ cargo clippy -p http-compress --all-features --all-targets -- -D warnings cargo test -p http-compress --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details. diff --git a/constant/AGENTS.md b/constant/AGENTS.md deleted file mode 100644 index 379fb3a4..00000000 --- a/constant/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `http-constant` - -Concise engineering and iteration guidelines for `http-constant` (`constant/`). -Global workspace rules live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md) and `~/.agents/skills/rust-standards/SKILL.md`. - -## Scope & Module Boundaries - -- **Role**: Canonical HTTP header names, methods, status phrases, versions, MIME types, and protocol symbols shared across the workspace. -- **Dependencies**: Zero external or workspace dependencies (`std` only). Do NOT add runtime logic, dynamic allocations, or third-party crates. -- **Layout**: Public `body`, `common`, `content_type_value`, `file_extension`, `header_key`, `header_value`, `http2`, `http_status`, `http_version`, `method`, `path`, `protocol`, `query`, `session`; tests in `tests/`. - -## Core Iteration Invariants - -- Keep all values as exact RFC-compliant `&str`, byte-slice, or `const` primitives with zero runtime initialization cost. -- Place any new wire literal reused across crates here instead of duplicating string literals in `type/`, `core/`, `request/`, or plugins. -- Preserve existing `pub` constant names and exact wire bytes; treat removals or value mutations as breaking changes requiring workspace-wide coordination. -- Order `pub` items strictly before `pub(crate)` and private items in every `const.rs`. - -## Code & Documentation Standards - -- Follow `rust-standards`: pure 9-keyword filenames (`mod.rs`, `const.rs`, `enum.rs`, `struct.rs`, `trait.rs`, `impl.rs`, `fn.rs`, `type.rs`, `static.rs`), 3-section `mod.rs` (zero comments), centralized imports in `src/lib.rs` and `tests/mod.rs`, zero `#[allow]`, strict `Cargo.toml` dependency order, and comment-free tests in `tests/`. -- Keep all code, comments, docs, and commits pure English. Update `constant/README.md` alongside any public module or API change. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p http-constant --all-features --all-targets -- -D warnings -cargo test -p http-constant --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/constant/README.md b/constant/README.md index 6d2848fe..976afbe5 100644 --- a/constant/README.md +++ b/constant/README.md @@ -1,11 +1,14 @@
+http-constant logo + # http-constant -**Shared HTTP Protocol Constants** +**Zero-Dependency Canonical HTTP Protocol Constants** -[![crates.io](https://flat.badgen.net/crates/v/http-constant)](https://crates.io/crates/http-constant) -[![docs.rs](https://img.shields.io/docsrs/http-constant?style=flat-square)](https://docs.rs/http-constant) +[![Crates.io Version](https://flat.badgen.net/crates/v/http-constant)](https://crates.io/crates/http-constant) +[![Docs.rs](https://img.shields.io/docsrs/http-constant?style=flat-square)](https://docs.rs/http-constant) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../LICENSE) @@ -17,13 +20,7 @@ ## Overview -Canonical HTTP header names, methods, status phrases, MIME types, and protocol symbols shared across the entire Hyperlane workspace. - -This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `header` / `method` / `status` / `version` — Zero-allocation `&str` and byte-slice constants +`http-constant` is the zero-dependency leaf crate providing canonical HTTP header keys, header values, status codes, methods, MIME types, file extensions, and HTTP/2 protocol constants across the [`hyperlane`](../README.md) workspace. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 work cargo add http-constant ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use http_constant::{CONTENT_TYPE, APPLICATION_JSON}; + +fn json_header() -> (&'static str, &'static str) { + (CONTENT_TYPE, APPLICATION_JSON) +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p http-constant --all-features --all-targets -- -D warnings cargo test -p http-constant --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details. diff --git a/core/AGENTS.md b/core/AGENTS.md deleted file mode 100644 index d55209b2..00000000 --- a/core/AGENTS.md +++ /dev/null @@ -1,34 +0,0 @@ -# AGENTS.md — `hyperlane-core` - -Concise engineering and iteration guidelines for `hyperlane-core` (`core/`). -Global workspace rules live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md) and `~/.agents/skills/rust-standards/SKILL.md`. - -## Scope & Module Boundaries - -- **Role**: Multi-protocol async HTTP/1.x, HTTP/2 (`h2c`/`h2`), and HTTP/3 (QUIC) server engine with radix/regex routing, `Context`, `ServerHook` lifecycle, and Linux `io_uring` transport. -- **Dependencies**: Internal `http-type` plus `h2`, `http`, `quinn`, `rustls`, `tokio`, `socket2`, `regex`, `inventory`, `lombok-macros`, and Linux-only `io-uring`/`libc`. -- **Layout**: Public `config`, `context`, `error`, `hook`, `route`, `server` (re-exporting `http-type` and `inventory`); `pub(crate)` `listener`, `protocol` (`constants`, `http2`, `http3/{qpack,shard,stream}`, `inline`, `pump`, `request`, `response`, `transport`, `uring`), `tls`; tests in `tests/`. - -## Core Iteration Invariants - -- Keep `listener`, `protocol`, and `tls` strictly `pub(crate)`. Implement all wire and transport fixes inside `core/src/protocol/`, never as workarounds in route handlers or plugins. -- Keep `Server::route::(path)` and middleware registrations synchronous (`&mut Self`; never `.await`). -- `Server::run().await` returns `Result>`; always propagate bind and listener failures rather than swallowing them. -- Preserve `ServerHook::new(stream, ctx)` / `handle(self, stream, ctx)` (`stream` first), `ctx.build_response()` HEAD-aware serialization, and the contract that hooks send wire bytes before returning `Status::Reject`. -- Maintain RFC 9110/9112/9113/9114 invariants across H1/H2/H3/io_uring: bodyless `1xx`/`204`/`205`/`304`, `Expect: 100-continue`, bounded chunked decoding, request smuggling rejection, keep-alive `Context` resets, and zero-alloc `RouteMatcher::try_match_path_into`. -- Exercise real request/response wire bytes for every protocol or transport change, and reclaim all task-owned listeners/sockets before test exit. - -## Code & Documentation Standards - -- Follow `rust-standards`: pure 9-keyword filenames, 3-section `mod.rs` (zero comments), centralized imports in `src/lib.rs` and `tests/mod.rs`, `pub(crate)` struct fields with `lombok-macros` accessors (no direct `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 `core/README.md` (and root `README.md` for protocol changes) in the same commit. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p hyperlane-core --all-features --all-targets -- -D warnings -cargo test -p hyperlane-core --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/core/README.md b/core/README.md index e0b5a5b4..38d5f51b 100644 --- a/core/README.md +++ b/core/README.md @@ -1,11 +1,14 @@
+hyperlane-core logo + # hyperlane-core -**Multi-Protocol Async HTTP Server Core** +**Multi-Protocol Async HTTP/1.x, HTTP/2 & HTTP/3 Server Engine** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-core)](https://crates.io/crates/hyperlane-core) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-core?style=flat-square)](https://docs.rs/hyperlane-core) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-core)](https://crates.io/crates/hyperlane-core) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-core?style=flat-square)](https://docs.rs/hyperlane-core) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../LICENSE) @@ -17,14 +20,7 @@ ## Overview -Tokio-based HTTP/1.x, HTTP/2 (`h2c`/`h2`), and HTTP/3 (QUIC) server engine with radix routing, `Context`, `ServerHook` lifecycle, and Linux `io_uring` transport. - -This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `server` / `route` / `hook` / `context` / `config` / `error` — Public server API and lifecycle traits -- `listener` / `protocol` / `tls` (`pub(crate)`) — Internal wire framers, connection pumps, and transport engines +`hyperlane-core` is the Tokio-powered multi-protocol server runtime at the center of the [`hyperlane`](../README.md) workspace. It drives HTTP/1.0, HTTP/1.1, HTTP/2 (`h2c`/`h2`), HTTP/3 (QUIC), WebSocket, and raw TCP connections with deterministic lifecycle hooks and optional Linux `io_uring` transport. ## Installation @@ -32,9 +28,25 @@ This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 work cargo add hyperlane-core ``` -## Verification +## Usage + +```rust +use hyperlane_core::{Server, ServerConfig, ServerError}; + +async fn start_server() -> Result<(), Box> { + let mut config: ServerConfig = ServerConfig::default(); + config.set_address("127.0.0.1:3000"); -Run crate-scoped formatting, lint, and test gates from the workspace root: + let mut server: Server = Server::default(); + server.server_config(config); + + let control = server.run().await?; + control.wait().await; + Ok(()) +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -42,11 +54,6 @@ cargo clippy -p hyperlane-core --all-features --all-targets -- -D warnings cargo test -p hyperlane-core --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details. diff --git a/macros/AGENTS.md b/macros/AGENTS.md deleted file mode 100644 index bd38ff57..00000000 --- a/macros/AGENTS.md +++ /dev/null @@ -1,33 +0,0 @@ -# AGENTS.md — `hyperlane-macros` - -Concise engineering and iteration guidelines for `hyperlane-macros` (`macros/`). -Global workspace rules live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md) and `~/.agents/skills/rust-standards/SKILL.md`. - -## Scope & Module Boundaries - -- **Role**: Procedural attribute macro crate (`#[route]`, `#[request_middleware]`, `#[response_middleware]`, `#[hyperlane]`, `#[import]`, `#[send]`, `#[try_send]`, `#[flush]`, `#[reject]`, `#[host]`, `#[referer]`, `#[methods]`, request/response/context extractors). -- **Dependencies**: `proc-macro = true` crate depending strictly on `syn`, `quote`, and `proc-macro2` (`hyperlane` and `serde` in `[dev-dependencies]` only). -- **Layout**: Attribute macro modules in `src/` (`closed`, `common`, `context`, `filter`, `flush`, `from_stream`, `hook`, `host`, `hyperlane`, `import`, `inject`, `method`, `referer`, `reject`, `request`, `request_middleware`, `response`, `response_middleware`, `route`, `send`, `stream`, `upgrade`, `version`) exposed via `src/lib.rs`; tests in `tests/`. - -## Core Iteration Invariants - -- Every path emitted inside `quote!` / `quote_spanned!` MUST use fully qualified absolute paths (e.g. `::hyperlane::...`) and ZERO `use` statements (enforced by `verify_no_macro_use.py`). -- Keep macro expansions minimal with zero synthetic doc-comment bloat, clean spans, and actionable `syn::Error` diagnostics on invalid attribute syntax. -- Preserve `inventory` `HookType` submission for `#[route]`, `#[request_middleware]`, and `#[response_middleware]`, and preserve `#[hyperlane(server: Server)]` priority uniqueness validation and deterministic ordering. -- Keep generated handler wrappers aligned with `ServerHook` (`stream: &mut Stream, ctx: &mut Context`), `Status::Continue`/`Status::Reject`, and `ctx.build_response()`. -- Verify both happy-path expansions and malformed-input handling in `tests/` whenever changing macro syntax or codegen. - -## Code & Documentation Standards - -- Follow `rust-standards` (including proc-macro §16 rules): pure 9-keyword filenames, 3-section `mod.rs` (zero comments), centralized imports in `src/lib.rs` and `tests/mod.rs`, explicit types on all `let`/closure bindings, zero `#[allow]`/`unwrap()`/`expect()`/`panic!()`, strict `Cargo.toml` dependency order, and comment-free tests in `tests/`. -- Keep all code, comments, docs, and commits pure English. Update `macros/README.md` alongside any macro attribute or signature change. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p hyperlane-macros --all-features --all-targets -- -D warnings -cargo test -p hyperlane-macros --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/macros/README.md b/macros/README.md index 813e688d..feadf777 100644 --- a/macros/README.md +++ b/macros/README.md @@ -1,11 +1,14 @@
+hyperlane-macros logo + # hyperlane-macros -**Hyperlane Route, Hook & Middleware Proc Macros** +**Procedural Attribute Macros for Hyperlane Routing, Middleware & Hooks** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-macros)](https://crates.io/crates/hyperlane-macros) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-macros?style=flat-square)](https://docs.rs/hyperlane-macros) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-macros)](https://crates.io/crates/hyperlane-macros) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-macros?style=flat-square)](https://docs.rs/hyperlane-macros) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../LICENSE) @@ -17,13 +20,7 @@ ## Overview -Procedural attribute macros (`#[route]`, `#[request_middleware]`, `#[response_middleware]`, `#[hyperlane]`, `#[methods]`, `#[send]`, `#[try_send]`, `#[host]`, `#[referer]`, etc.) eliminating handler boilerplate. - -This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `route` / `hook` / `send` / `filter` — Hygiene-safe attribute macros emitting absolute `::hyperlane::*` paths +`hyperlane-macros` provides hygienic procedural attribute macros for the [`hyperlane`](../README.md) framework. It eliminates boilerplate around route/middleware inventory registration, HTTP method/host/version guards, response flushing, and typed `Context` extraction. ## Installation @@ -31,9 +28,27 @@ This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 work cargo add hyperlane-macros ``` -## Verification +## Usage + +```rust +use hyperlane::{Context, ServerHook, Status, Stream}; + +struct HealthRoute; -Run crate-scoped formatting, lint, and test gates from the workspace root: +impl ServerHook for HealthRoute { + async fn new(_: &mut Stream, _: &mut Context) -> Self { + Self + } + + #[hyperlane::send] + async fn handle(self, stream: &mut Stream, ctx: &mut Context) -> Status { + ctx.get_mut_response().set_body("ok"); + Status::Reject + } +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +56,6 @@ cargo clippy -p hyperlane-macros --all-features --all-targets -- -D warnings cargo test -p hyperlane-macros --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details. diff --git a/performance/AGENTS.md b/performance/AGENTS.md deleted file mode 100644 index 8b081157..00000000 --- a/performance/AGENTS.md +++ /dev/null @@ -1,34 +0,0 @@ -# AGENTS.md — `hyperlane-performance` - -Concise engineering and iteration guidelines for `hyperlane-performance` (`performance/`). -Global workspace rules live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md) and `~/.agents/skills/rust-standards/SKILL.md`. - -## Scope & Module Boundaries - -- **Role**: Official CPU-pinned native and Docker benchmark orchestrator, loadgen, control baseline, and `alloc-count` harness for `h1`, `h1-tls`, `h2c`, `h2-tls`, and `h3`. -- **Dependencies**: Internal `hyperlane` plus `h2`, `h3`, `h3-quinn`, `quinn`, `rustls`, `tokio-rustls`, `tokio`, `serde`/`serde_json`, `toml_edit`. Optional feature: `alloc-count`. -- **Layout**: Library (`certificate`, `config`, `context`, `report`, `runner`), binaries (`src/main.rs`, `src/bin/{server,control,loadgen}/main.rs`), `docker/Dockerfile.perf`, and `tests/`. - -## Core Iteration Invariants - -- Always measure baseline and candidate revisions in the same CPU-pinned window under identical concurrency, duration, and protocol settings; never claim gains from cross-run comparisons. -- Keep the counting global allocator strictly gated behind `--features alloc-count` so default release throughput benchmarks incur zero allocator-tracking overhead. -- Keep native orchestrator behavior synchronized with `docker/Dockerfile.perf` and `.github/workflows/perf.yml`. -- Reclaim all spawned `server`, `control`, and `loadgen` child processes and bound ports on normal exit or error. -- Never commit generated benchmark outputs or ephemeral TLS assets (`certs/`, `results/`, `results2/`). - -## Code & Documentation Standards - -- Follow `rust-standards`: pure 9-keyword filenames, 3-section `mod.rs` (zero comments), centralized imports in `src/lib.rs`, binary roots, and `tests/mod.rs`, `pub(crate)` struct fields with `lombok-macros` accessors (no direct `self.field`), explicit types on all `let`/closure bindings, zero `#[allow]`/`unwrap()`/`expect()`/`panic!()`, strict `Cargo.toml` dependency order, and comment-free tests in `tests/`. -- Keep all code, comments, docs, and commits pure English. Update `performance/README.md` alongside any CLI flag, scenario, or report schema change. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p hyperlane-performance --all-features --all-targets -- -D warnings -cargo test -p hyperlane-performance --all-features -cargo check -p hyperlane-performance --release --features alloc-count -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/performance/README.md b/performance/README.md index ccad231f..d679c1c5 100644 --- a/performance/README.md +++ b/performance/README.md @@ -1,11 +1,14 @@
+hyperlane-performance logo + # hyperlane-performance -**Official Throughput & Allocation Benchmark Harness** +**Multi-Protocol Throughput, Latency & Allocation Benchmark Harness** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-performance)](https://crates.io/crates/hyperlane-performance) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-performance?style=flat-square)](https://docs.rs/hyperlane-performance) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-performance)](https://crates.io/crates/hyperlane-performance) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-performance?style=flat-square)](https://docs.rs/hyperlane-performance) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../LICENSE) @@ -17,13 +20,7 @@ ## Overview -CPU-pinned native and Docker loadgen, control baseline, and allocation-counting benchmark suite verifying Hyperlane wire throughput and latency. - -This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `bench` / `server` — Reproducible HTTP throughput and memory-allocation verification harness +`hyperlane-performance` is the reproducible multi-protocol load generator, control baseline, and allocation-counting benchmark harness for [`hyperlane`](../README.md), measuring HTTP/1.1, HTTP/1.1 TLS, HTTP/2 (`h2c`/`h2`), HTTP/3 (QUIC), and per-request heap allocations. ## Installation @@ -31,9 +28,13 @@ This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 work cargo add hyperlane-performance ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```sh +cargo run --release -p hyperlane-performance -- --help +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +42,6 @@ cargo clippy -p hyperlane-performance --all-features --all-targets -- -D warning cargo test -p hyperlane-performance --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details. diff --git a/plugin/README.md b/plugin/README.md index 8fa834c9..63d89802 100644 --- a/plugin/README.md +++ b/plugin/README.md @@ -1,224 +1,83 @@ -# The hyperlane plugin roadmap - -A plugin is a crate whose hooks are registered into the framework's inventory. -The framework collects every registered hook when a server is built, so a -plugin becomes active by being a dependency of the application. This document -describes the contract a plugin follows, the standards it has to meet, and the -plugins that are planned, in the order they are worth building. - -## The contract - -The mechanism already exists; a plugin does not invent one. - -- **Registration.** A plugin implements `ServerHook` and registers it with the - `#[route]`, `#[request_middleware]` and `#[response_middleware]` attributes. - Each attribute submits a `HookType` to the `inventory`, which is how the - framework finds it. -- **Installation.** `#[hyperlane(server: Server)]` collects every submitted - hook, checks that the explicit orders are unique, sorts by order and - installs them. A plugin therefore needs no registration call of its own. -- **Order.** A hook carries an optional priority. The hooks run in the order - of their priority, from the smallest to the largest, and a hook without a - priority runs before every hook that has one. Two hooks of the same kind may - not claim the same priority. -- **The order of a plugin.** The plugins that answer a request, such as the - cross origin plugin, keep the negative priorities, and an application that - gives its own middlewares positive priorities runs after them. A plugin that - has to mark the answer before it is built, such as the compression plugin, - therefore runs before the middleware of the application that sends it. A - plugin that reports the answer, such as the logger plugin, runs after the - middlewares of the application instead, so that it reports the answer that - was really sent. -- **Configuration.** The registry is fixed at compile time, so a plugin's - settings live in a process wide static, initialised before the server - starts. The pattern is a `OnceLock` behind an `init` and a `get`, and the - `GetOrInit` trait is the shape the application already uses. -- **Use in the application.** `#[import(path)]` brings the plugin's traits - into scope without naming them, so an application talks to a plugin through - its API and not through its internals. -- **Not configured means not in the way.** A hook that is registered but has - no configuration returns `Status::Continue` and does nothing. A plugin that - is a dependency but that the application did not configure must not change - the server's behaviour. - -The last point is the rule that shapes every plugin below: being a dependency -is not the same as being enabled. - -## The standards a plugin has to meet - -The repository's own gate checks every staged `.rs` and `.toml` file, so a -plugin is held to the same rules as the framework. - -- **Layout.** A directory holds the keyword files only: `lib.rs`, `mod.rs`, - `const.rs`, `fn.rs`, `struct.rs`, `enum.rs`, `impl.rs`, `trait.rs`, `type.rs`. - The entry of a crate is `lib.rs`: the module declarations first, then the - `pub use` and `pub(crate) use` re-exports, then the imports. -- **Visibility.** In `const.rs` and `static.rs` the `pub` items come before the - `pub(crate)` ones and the private ones. A `pub` constant needs a reader - outside its own module, which is why a plugin's settings are reached - through an accessor rather than through a public field. -- **Strings.** Every literal lives in `const.rs`. The format string of a - `format!` or a `println!` stays at the call site. -- **No panics.** `panic!`, `.expect()` and `.unwrap()` do not appear in - production code. Errors travel as `Result`. -- **Types.** Every `let` binding and every closure parameter carries its type. -- **Fields.** A field is read through its accessor, never as `self.field`. -- **Documentation.** Every public item carries a doc comment, and a function - that takes or returns something documents it under `# Arguments` and - `# Returns`. -- **No `#[allow]`.** - -## Official plugins in this repository - -| crate | path | hook order (req / resp) | capabilities | -| ---------------------------------- | ------------------------ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `hyperlane-plugin-tracing` | `plugin/tracing` | `-130` / `90` | lock-free 128-bit W3C `traceparent`/`tracestate`, `X-Request-Id`, `Server-Timing`, pluggable `SpanExporter` | -| `hyperlane-plugin-ip-filter` | `plugin/ip_filter` | `-125` / — | anti-spoofing right-to-left proxy peeling (`XFF`/`Forwarded`/`X-Real-IP`), `ClientIp` `Context` attr, `/8` radix IPv4/IPv6 CIDR filter, prebuilt `403` | -| `hyperlane-plugin-logger` | `plugin/logger` | `-120` / `100` | non-blocking buffered console/file logging, Plain/JSON formats, `LogSink` trait, CRLF/ANSI sanitization | -| `hyperlane-plugin-audit` | `plugin/audit` | `-118` / `92` | tamper-evident SHA-256 hash-chained security audit trail, bounded ring buffer, pluggable `AuditSink`, header redaction | -| `hyperlane-plugin-metrics` | `plugin/metrics` | `-115` / `95` | lock-free atomic counters, gauges, latency histograms, Prometheus 0.0.4 `/metrics` scrape endpoint | -| `hyperlane-plugin-timeout` | `plugin/timeout` | `-112` / `82` | global + per-prefix request deadline budgets, `X-Request-Timeout` clamping, `timeout_future`, automatic `504` conversion | -| `hyperlane-plugin-health` | `plugin/health` | `-110` / — | `/healthz`, `/livez`, `/readyz` probes with concurrent async `HealthCheck`, timeouts, snapshot cache, drain flag | -| `hyperlane-plugin-maintenance` | `plugin/maintenance` | `-109` / — | lock-free atomic live `Active`/`ReadOnly`/`Maintenance` mode toggle, path & constant-time bypass tokens, prebuilt `503` | -| `hyperlane-plugin-concurrency` | `plugin/concurrency` | `-108` / `85` | lock-free atomic global + prefix concurrency limiter, AIMD adaptive load shedding, optional `Semaphore` wait queue, RAII `Context` permit, prebuilt `503` | -| `hyperlane-plugin-body-limit` | `plugin/body_limit` | `-106` / — | global, segment-bounded per-prefix & per-MIME request payload limits checking body + `Content-Length`, prebuilt `413` | -| `hyperlane-plugin-security` | `plugin/security` | `-105` / `-75` | prebuilt HSTS/CSP/COOP/COEP/CORP/Referrer headers, stateless HMAC-SHA256 CSRF, host/URI/body/traversal guards, `SecurityRule` | -| `hyperlane-plugin-compression` | `plugin/compression` | `-104` / `-55` | full-duplex bounded request decompression (`br`/`gzip`/`deflate`) + `Accept-Encoding` response negotiation, MIME exclusions, `Vary` merging | -| `hyperlane-plugin-rewrite` | `plugin/rewrite` | `-102` / — | canonical host/HTTPS redirect (`X-Forwarded-Proto`), slash normalization, `O(1)` `XxHash3_64` static table, segment-bounded prefix & compiled regex rules | -| `hyperlane-plugin-cors` | `plugin/cors` | `-100` / `-80` | precompiled zero-alloc CORS headers, exact/suffix/predicate origin matching, credentials safety guard, `OPTIONS` preflight | -| `hyperlane-plugin-tenant` | `plugin/tenant` | `-98` / — | multi-tenant header/subdomain/path isolation, `XxHash3_64` registry, `TenantResolver`, `TenantContext`, prebuilt `400`/`403`/`404` | -| `hyperlane-plugin-rate-limit` | `plugin/rate_limit` | `-95` / — | 64-shard lock-free atomic GCRA & fixed-window limiter, bounded key store, `KeyExtractor`/`RateLimitStore` traits, RFC `RateLimit-*` headers | -| `hyperlane-plugin-circuit-breaker` | `plugin/circuit_breaker` | `-92` / `88` | route/prefix-scoped lock-free atomic sliding-window HTTP circuit breaker (`Closed`/`Open`/`HalfOpen` probe gating), status predicate, prebuilt `503` | -| `hyperlane-plugin-auth` | `plugin/auth` | `-90` / — | pure-Rust HS256 JWT (`kid` rotation), API key, HTTP Basic, RBAC `AuthPrincipal`, extensible async `Authenticator` | -| `hyperlane-plugin-canary` | `plugin/canary` | `-88` / `-68` | feature flags, A/B experiments & deterministic `XxHash3_64` basis-point sticky rollouts, forced overrides, `X-Variant` + `Vary` | -| `hyperlane-plugin-session` | `plugin/session` | `-85` / `-70` | 64-shard bounded `InMemorySessionStore` + pluggable `SessionStore`, HMAC-SHA256 signed cookies, dirty-tracked reads, `regenerate_id()` | -| `hyperlane-plugin-cache` | `plugin/cache` | `-80` / `-65` | 64-shard bounded cache, single-flight stampede coalescing, pluggable `CacheStore`, HTTP `Cache-Control`/`Age`/`X-Cache` | -| `hyperlane-plugin-idempotency` | `plugin/idempotency` | `-78` / `-60` | HTTP `Idempotency-Key` middleware, `XxHash3_64` payload fingerprint (`422`), 64-shard bounded + async store, `InFlight` guard (`409`), zero-copy replay | -| `hyperlane-plugin-multipart` | `plugin/multipart` | `-76` / — | bounded RFC 7578 `multipart/form-data` guard, traversal-proof filename sanitization, magic-byte MIME sniffing, prebuilt `400`/`413`/`415` | -| `hyperlane-plugin-etag` | `plugin/etag` | `-72` / `-58` | strong/weak `XxHash3_64` ETags, zero-alloc `If-None-Match` (`304`) & `If-Match` (`412`) optimistic concurrency via `EtagValidator` | -| `hyperlane-plugin-rpc` | `plugin/rpc` | `-70` / — | JSON-RPC 2.0 `XxHash3_64` router, concurrent batch/notification dispatch, DoS caps, `RpcInterceptor`, `RpcHook` | -| `hyperlane-plugin-grpc` | `plugin/grpc` | `-65` / — | gRPC over HTTP/2 5-byte framing, bounded compression, status codes `0..=16`, `grpc-timeout`, `GrpcInterceptor`, `GrpcHook` | -| `hyperlane-plugin-graphql` | `plugin/graphql` | `-62` / — | zero-external-parser GraphQL over HTTP (`POST`/`GET`), depth/complexity DoS caps, `XxHash3_64` query/mutation resolvers | -| `hyperlane-plugin-problem-details` | `plugin/problem_details` | — / `-62` | RFC 9457 (`application/problem+json`) error response builder and automatic `4xx`/`5xx` normalizer with `2xx`/`3xx` fast path | -| `hyperlane-plugin-mcp` | `plugin/mcp` | `-60` / — | Model Context Protocol Streamable HTTP server, `XxHash3_64` registries, 16-shard TTL sessions, `Origin` guard, `McpHook` | -| `hyperlane-plugin-webhook` | `plugin/webhook` | `-58` / — | inbound HTTP webhook verifier, precomputed-midstate pure-Rust HMAC-SHA256 (Hex/Base64/Stripe), skew guard, 64-shard TTL replay cache | -| `hyperlane-plugin-static-files` | `plugin/static_files` | `-55` / — | traversal-proof static server, `FileExtension` MIME table, 64-shard hot-file cache, `.br`/`.gz` sidecars, `ETag`/`304`, `Range` `206`/`416`, SPA fallback | -| `hyperlane-plugin-openapi` | `plugin/openapi` | `-52` / — | OpenAPI 3.1.0 builder, pre-serialized ETag-cached `/openapi.json` (`304`) & self-contained zero-CDN `/docs` HTML API explorer | -| `hyperlane-plugin-gateway` | `plugin/gateway` | `-50` / — | reverse proxy & API gateway with pooled H1/H2 `http-request`, RR/Weighted/LC/P2C balancing, circuit breaker, lock-free GCRA limiter, `GatewayInterceptor` | -| `hyperlane-plugin-negotiate` | `plugin/negotiate` | explicit | `Accept-Encoding` compression negotiation and conditional `304 Not Modified` strong/weak ETag validation | -| `hyperlane-plugin-shutdown` | `plugin/shutdown` | control hook | graceful shutdown coordinator with `SIGINT`/`SIGTERM` arming, RAII `ShutdownGuard` draining, LIFO async `ShutdownCallback` hooks | -| `hyperlane-plugin-websocket` | `plugin/websocket` | route helper | WebSocket room broadcast with lag recovery, connection lifecycle hooks, and opt-in `WebSocketPlugin` | -| `hyperlane-plugin-sse` | `plugin/sse` | route helper | WHATWG Server-Sent Events framing, CRLF sanitization, 64-shard topic pub/sub, `Last-Event-ID` replay, heartbeats | -| `hyperlane-plugin-mq` | `plugin/mq` | broker | pluggable `MessageBroker` trait and 64-shard `InMemoryBroker` with consumer groups, TTL, retries, $O(\log N)$ deadline heap, DLQ | -| `hyperlane-plugin-env` | `plugin/env` | startup config | zero-dep `.env` parser, layered typed environment loader, redacting `SecretValue` & `HYPERLANE_*` `ServerConfig` builder | -| `hyperlane-plugin-scheduler` | `plugin/scheduler` | background jobs | async interval & 5-field UTC cron job scheduler with lock-free overlap guard, panic isolation, atomic metrics & graceful shutdown | - -## The plugins, in the order they are worth building - -### P0 - the ground every service needs - -| plugin | what it gives | -| --------------------------- | --------------------------------------------------------------------------------------------------------------------------- | -| `hyperlane-plugin-shutdown` | graceful shutdown: the framework already has the control hook, the plugin turns it into "configure it once and it is armed" | -| `hyperlane-plugin-logger` | logging, with a file backend | - -Both are small, and the application already carries a working version of each, -so upstreaming them is a move rather than a rewrite. A service that cannot shut -down cleanly or cannot say what it is doing is not a service yet. - -The logger is in the tree now, and it is published. The shutdown plugin is -not: the signal of the operating system is not framework state, so the plugin -that joined it to the control hook is written again when the need is proven. - -### P1 - what a web service is asked for every day - -| plugin | what it gives | -| ------------------------------- | ------------------------------------------------------------------------ | -| `hyperlane-plugin-cors` | cross origin headers and preflight | -| `hyperlane-plugin-compression` | gzip and brotli on the response | -| `hyperlane-plugin-static-files` | serving files, with the content type table the framework already carries | - -None of the three is in the tree. Their rules are not framework state either, -so they are written where they are needed, and a server that is not Hyperlane -can use the same rules. - -The compression plugin is the cheapest of the three: `http-compress` is -already a dependency and the response builder already honours a -`Content-Encoding` header, so the plugin only has to set the header when the -client asked for it and the body is worth compressing. - -The static file plugin registers a route and no middleware, because the path -the files are served under belongs to the application. The application -registers the route with the pattern the plugin builds, and the answer of a -file is built and sent by the middlewares of the application, like the answer -of any other route. - -### P2 - the data layer - -| plugin | what it gives | -| ----------------------------- | ------------------------------------------------------------------- | -| `hyperlane-plugin-database` | the connection and auto creation traits, with no driver behind them | -| `hyperlane-plugin-postgresql` | the PostgreSQL driver | -| `hyperlane-plugin-mysql` | the MySQL driver | -| `hyperlane-plugin-redis` | the Redis client and its pool | - -The application already has this shape, down to the trait names. The base -crate carries no driver, so it stays small; the driver crates carry theirs, -so they stay large and are published separately. - -### P3 - running a service in production - -| plugin | what it gives | -| ----------------------------- | ------------------------------------------ | -| `hyperlane-plugin-env` | configuration loaded from the environment | -| `hyperlane-plugin-metrics` | counters and timers in a scrapeable format | -| `hyperlane-plugin-rate-limit` | a limit per client or per route | - -### P4 - the rest, when the need is proven - -`hyperlane-plugin-message-queue`, `hyperlane-plugin-jwt`, -`hyperlane-plugin-tracing` and `hyperlane-plugin-multipart`. - -## The shape of a plugin - -``` -plugin// - Cargo.toml - README.md - src/ - lib.rs the entry: module declarations, re-exports, the imports - const.rs every string literal - struct.rs the types - enum.rs the enumerations - trait.rs the traits the application talks to - impl.rs the implementations - fn.rs the free functions - mod.rs a submodule, when the plugin has more than one - tests/ - mod.rs the test entry: the modules and the crate under test -``` - -The entry of a crate is `lib.rs`. A `mod.rs` holds a submodule instead, and -carries the module declarations first, then the `pub use` and `pub(crate) use` -re-exports. Every keyword file below the entry starts with `use super::*;` and -reaches the crate's imports through it, so an import is written once, in the -entry, and never again. - -A plugin declares its dependency on the framework and on nothing else, unless -it carries a driver. Its `Cargo.toml` carries `publish = false` until it is -ready to be published, and it is added to the workspace members, to the -workspace dependencies and to the release job's package list. - -Its public surface is small on purpose: an `init` that takes the -configuration, a `get` that hands the configuration back, and the traits the -application calls. Everything else is private. - -## What is still to decide - -- **Publishing.** The release job names the plugins of this tree, and the - plugins that hold no framework state are published from the crates-dev family - instead, so a server that is not Hyperlane can use the same rules. -- **How much configuration is enough.** Every plugin that needs a setting - needs it set before the server starts, and that is a second thing the - application has to remember. A single configuration entry point would be - better than one per plugin, and it is a decision, not an implementation. +
+ +Hyperlane Plugin Ecosystem logo + +# Hyperlane Plugin Ecosystem + +**40 Opt-In Zero-Overhead Middleware, Protocol & Infrastructure Plugins** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane)](https://crates.io/crates/hyperlane) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane?style=flat-square)](https://docs.rs/hyperlane) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../LICENSE) + +[Workspace Overview](../README.md) · [API Docs](https://docs.rs/hyperlane/latest/) + +
+ +--- + +## Overview + +Hyperlane plugins are standalone opt-in crates that extend [`hyperlane`](../README.md) with production security, observability, traffic shaping, caching, RPC/protocol servers, and operational controls. Every plugin registers its hooks into the framework inventory automatically while remaining completely transparent (`Status::Continue`) until explicitly initialized by the application. + +## Plugin Contract + +- **Automatic Inventory Registration**: Plugins implement `ServerHook` and register via `#[route]`, `#[request_middleware]`, or `#[response_middleware]`; `#[hyperlane(server: Server)]` collects, validates unique explicit priorities, sorts, and installs them automatically. +- **Deterministic Priority Ordering**: Request plugins run from smallest to largest priority (negative priorities run before application middleware; positive priorities run after). Response reporters such as logging, tracing, and metrics run late so they observe the final response. +- **Process-Wide Initialization**: Plugin configuration lives in a process-wide `OnceLock` initialized once before `server.run().await` via `::init(...)`. +- **Opt-In Transparency**: Adding a plugin as a dependency without calling `init(...)` never alters server behavior — unconfigured hooks return `Status::Continue` with zero side effects. + +## Official Plugins (40) + +| Crate | Path | Hook Order (Req / Resp) | Capabilities | +| :---------------------------------------------------------------- | :----------------------- | :---------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`hyperlane-plugin-tracing`](./tracing/README.md) | `plugin/tracing` | `-130` / `90` | Lock-free 128-bit W3C `traceparent`/`tracestate`, `X-Request-Id`, `Server-Timing`, pluggable `SpanExporter` | +| [`hyperlane-plugin-ip-filter`](./ip_filter/README.md) | `plugin/ip_filter` | `-125` / — | Anti-spoofing right-to-left proxy peeling (`XFF`/`Forwarded`/`X-Real-IP`), `ClientIp` `Context` attr, `/8` radix IPv4/IPv6 CIDR filter, prebuilt `403` | +| [`hyperlane-plugin-logger`](./logger/README.md) | `plugin/logger` | `-120` / `100` | Non-blocking buffered console/file logging, Plain/JSON formats, `LogSink` trait, CRLF/ANSI sanitization | +| [`hyperlane-plugin-audit`](./audit/README.md) | `plugin/audit` | `-118` / `92` | Tamper-evident SHA-256 hash-chained security audit trail, bounded ring buffer, pluggable `AuditSink`, header redaction | +| [`hyperlane-plugin-metrics`](./metrics/README.md) | `plugin/metrics` | `-115` / `95` | Lock-free atomic counters, gauges, latency histograms, Prometheus OpenMetrics `/metrics` scrape endpoint | +| [`hyperlane-plugin-timeout`](./timeout/README.md) | `plugin/timeout` | `-112` / `82` | Global + per-prefix request deadline budgets, `X-Request-Timeout` clamping, `timeout_future`, automatic `504` conversion | +| [`hyperlane-plugin-health`](./health/README.md) | `plugin/health` | `-110` / — | `/healthz`, `/livez`, `/readyz` probes with concurrent async `HealthCheck`, timeouts, snapshot cache, drain flag | +| [`hyperlane-plugin-maintenance`](./maintenance/README.md) | `plugin/maintenance` | `-109` / — | Lock-free atomic live `Active`/`ReadOnly`/`Maintenance` mode toggle, path & constant-time bypass tokens, prebuilt `503` | +| [`hyperlane-plugin-concurrency`](./concurrency/README.md) | `plugin/concurrency` | `-108` / `85` | Lock-free atomic global + prefix concurrency limiter, AIMD adaptive load shedding, optional `Semaphore` wait queue, RAII `Context` permit, prebuilt `503` | +| [`hyperlane-plugin-body-limit`](./body_limit/README.md) | `plugin/body_limit` | `-106` / — | Global, segment-bounded per-prefix & per-MIME request payload limits checking body + `Content-Length`, prebuilt `413` | +| [`hyperlane-plugin-security`](./security/README.md) | `plugin/security` | `-105` / `-75` | Prebuilt HSTS/CSP/COOP/COEP/CORP/Referrer headers, stateless HMAC-SHA256 CSRF, host/URI/body/traversal guards, `SecurityRule` | +| [`hyperlane-plugin-compression`](./compression/README.md) | `plugin/compression` | `-104` / `-55` | Full-duplex bounded request decompression (`br`/`gzip`/`deflate`) + `Accept-Encoding` response negotiation, MIME exclusions, `Vary` merging | +| [`hyperlane-plugin-rewrite`](./rewrite/README.md) | `plugin/rewrite` | `-102` / — | Canonical host/HTTPS redirect (`X-Forwarded-Proto`), slash normalization, `O(1)` `XxHash3_64` static table, segment-bounded prefix & regex rules | +| [`hyperlane-plugin-cors`](./cors/README.md) | `plugin/cors` | `-100` / `-80` | Precompiled zero-alloc CORS headers, exact/suffix/predicate origin matching, credentials safety guard, `OPTIONS` preflight | +| [`hyperlane-plugin-tenant`](./tenant/README.md) | `plugin/tenant` | `-98` / — | Multi-tenant header/subdomain/path isolation, `XxHash3_64` registry, `TenantResolver`, `TenantContext`, prebuilt `400`/`403`/`404` | +| [`hyperlane-plugin-rate-limit`](./rate_limit/README.md) | `plugin/rate_limit` | `-95` / — | 64-shard lock-free atomic GCRA & fixed-window limiter, bounded key store, `KeyExtractor`/`RateLimitStore` traits, RFC `RateLimit-*` headers | +| [`hyperlane-plugin-circuit-breaker`](./circuit_breaker/README.md) | `plugin/circuit_breaker` | `-92` / `88` | Route/prefix-scoped lock-free atomic sliding-window HTTP circuit breaker (`Closed`/`Open`/`HalfOpen` probe gating), status predicate, prebuilt `503` | +| [`hyperlane-plugin-auth`](./auth/README.md) | `plugin/auth` | `-90` / — | Pure-Rust HS256 JWT (`kid` rotation), API key, HTTP Basic, RBAC `AuthPrincipal`, extensible async `Authenticator` | +| [`hyperlane-plugin-canary`](./canary/README.md) | `plugin/canary` | `-88` / `-68` | Feature flags, A/B experiments & deterministic `XxHash3_64` basis-point sticky rollouts, forced overrides, `X-Variant` + `Vary` | +| [`hyperlane-plugin-session`](./session/README.md) | `plugin/session` | `-85` / `-70` | 64-shard bounded `InMemorySessionStore` + pluggable `SessionStore`, HMAC-SHA256 signed cookies, dirty-tracked reads, `regenerate_id()` | +| [`hyperlane-plugin-cache`](./cache/README.md) | `plugin/cache` | `-80` / `-65` | 64-shard bounded cache, single-flight stampede coalescing, pluggable `CacheStore`, HTTP `Cache-Control`/`Age`/`X-Cache` | +| [`hyperlane-plugin-idempotency`](./idempotency/README.md) | `plugin/idempotency` | `-78` / `-60` | HTTP `Idempotency-Key` middleware, `XxHash3_64` payload fingerprint (`422`), 64-shard bounded + async store, `InFlight` guard (`409`), zero-copy replay | +| [`hyperlane-plugin-multipart`](./multipart/README.md) | `plugin/multipart` | `-76` / — | Bounded RFC 7578 `multipart/form-data` guard, traversal-proof filename sanitization, magic-byte MIME sniffing, prebuilt `400`/`413`/`415` | +| [`hyperlane-plugin-etag`](./etag/README.md) | `plugin/etag` | `-72` / `-58` | Strong/weak `XxHash3_64` ETags, zero-alloc `If-None-Match` (`304`) & `If-Match` (`412`) optimistic concurrency via `EtagValidator` | +| [`hyperlane-plugin-rpc`](./rpc/README.md) | `plugin/rpc` | `-70` / — | JSON-RPC 2.0 `XxHash3_64` router, concurrent batch/notification dispatch, DoS caps, `RpcInterceptor`, `RpcHook` | +| [`hyperlane-plugin-grpc`](./grpc/README.md) | `plugin/grpc` | `-65` / — | gRPC over HTTP/2 5-byte framing, bounded compression, status codes `0..=16`, `grpc-timeout`, `GrpcInterceptor`, `GrpcHook` | +| [`hyperlane-plugin-graphql`](./graphql/README.md) | `plugin/graphql` | `-62` / — | Zero-external-parser GraphQL over HTTP (`POST`/`GET`), depth/complexity DoS caps, `XxHash3_64` query/mutation resolvers | +| [`hyperlane-plugin-problem-details`](./problem_details/README.md) | `plugin/problem_details` | — / `-62` | RFC 9457 (`application/problem+json`) error response builder and automatic `4xx`/`5xx` normalizer with `2xx`/`3xx` fast path | +| [`hyperlane-plugin-mcp`](./mcp/README.md) | `plugin/mcp` | `-60` / — | Model Context Protocol Streamable HTTP server, `XxHash3_64` registries, 16-shard TTL sessions, `Origin` guard, `McpHook` | +| [`hyperlane-plugin-webhook`](./webhook/README.md) | `plugin/webhook` | `-58` / — | Inbound HTTP webhook verifier, precomputed-midstate pure-Rust HMAC-SHA256 (Hex/Base64/Stripe), skew guard, 64-shard TTL replay cache | +| [`hyperlane-plugin-static-files`](./static_files/README.md) | `plugin/static_files` | `-55` / — | Traversal-proof static server, `FileExtension` MIME table, 64-shard hot-file cache, `.br`/`.gz` sidecars, `ETag`/`304`, `Range` `206`/`416`, SPA fallback | +| [`hyperlane-plugin-openapi`](./openapi/README.md) | `plugin/openapi` | `-52` / — | OpenAPI 3.1.0 builder, pre-serialized ETag-cached `/openapi.json` (`304`) & self-contained zero-CDN `/docs` HTML API explorer | +| [`hyperlane-plugin-gateway`](./gateway/README.md) | `plugin/gateway` | `-50` / — | Reverse proxy & API gateway with pooled H1/H2 `http-request`, RR/Weighted/LC/P2C balancing, circuit breaker, lock-free GCRA limiter, `GatewayInterceptor` | +| [`hyperlane-plugin-negotiate`](./negotiate/README.md) | `plugin/negotiate` | Explicit | `Accept-Encoding` compression negotiation and conditional `304 Not Modified` strong/weak ETag validation | +| [`hyperlane-plugin-shutdown`](./shutdown/README.md) | `plugin/shutdown` | Control hook | Graceful shutdown coordinator with `SIGINT`/`SIGTERM` arming, RAII `ShutdownGuard` draining, LIFO async `ShutdownCallback` hooks | +| [`hyperlane-plugin-websocket`](./websocket/README.md) | `plugin/websocket` | Route helper | WebSocket room broadcast with lag recovery, connection lifecycle hooks, and opt-in `WebSocketPlugin` | +| [`hyperlane-plugin-sse`](./sse/README.md) | `plugin/sse` | Route helper | WHATWG Server-Sent Events framing, CRLF sanitization, 64-shard topic pub/sub, `Last-Event-ID` replay, heartbeats | +| [`hyperlane-plugin-mq`](./mq/README.md) | `plugin/mq` | Broker | Pluggable `MessageBroker` trait and 64-shard `InMemoryBroker` with consumer groups, TTL, retries, deadline heap, DLQ | +| [`hyperlane-plugin-env`](./env/README.md) | `plugin/env` | Startup config | Zero-dep `.env` parser, layered typed environment loader, redacting `SecretValue` & `HYPERLANE_*` `ServerConfig` builder | +| [`hyperlane-plugin-scheduler`](./scheduler/README.md) | `plugin/scheduler` | Background jobs | Async interval & 5-field UTC cron job scheduler with lock-free overlap guard, panic isolation, atomic metrics & graceful shutdown | + +## License + +This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details. + +## Contact + +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/audit/AGENTS.md b/plugin/audit/AGENTS.md deleted file mode 100644 index 794432cb..00000000 --- a/plugin/audit/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-audit` - -Concise engineering and iteration guidelines for `hyperlane-plugin-audit` (`plugin/audit/`). -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**: Tamper-evident SHA-256 hash-chained security audit trail with bounded `InMemoryAuditSink`, pluggable `AuditSink`, header redaction, and `AuditRequestHook`/`AuditResponseHook`. -- **Dependencies**: Internal `hyperlane`; external `serde`, `serde_json`, `lombok-macros`. -- **Layout**: `src/{lib,const,fn,impl,static,struct,trait}.rs` (`AUDIT_PLUGIN`, `AuditSha256`, and hook helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `AuditRequestHook` (`#[hyperlane::request_middleware(-118)]`) and `AuditResponseHook` (`#[hyperlane::response_middleware(92)]`) MUST stay transparent (`Status::Continue`) when `AUDIT_PLUGIN` is unconfigured and MUST NOT collide with sibling plugin priorities. -- **Atomic hash-chain serialization**: Read `last_hash`, compute `AuditSha256` over `sequence|timestamp_ms|prev_hash|method|path|status_code|actor|action|request_id`, and update `last_hash` inside a single `Mutex` critical section; keep field order/delimiter identical to `compute_record_hash` and `verify_audit_chain`. -- **Mandatory redaction**: Always redact configured `redact_headers` (defaulting to `Authorization` and `Cookie`, matched case-insensitively) to `"[REDACTED]"`. -- **Filter precedence & ring-buffer hygiene**: Evaluate `mutations_only`, then `exclude_prefixes`, then `include_prefixes` on segment boundaries; clamp `InMemoryAuditSink` capacity `>= 1` and drop evicted records outside the lock. - -## 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/audit/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-audit --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-audit --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/audit/README.md b/plugin/audit/README.md index 2ed8ef61..db9e0545 100644 --- a/plugin/audit/README.md +++ b/plugin/audit/README.md @@ -1,11 +1,55 @@ +
+ +hyperlane-plugin-audit logo + # hyperlane-plugin-audit -Tamper-evident SHA-256 hash-chained security audit trail middleware for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**Tamper-Evident SHA-256 Hash-Chained Security Audit Trail Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-audit)](https://crates.io/crates/hyperlane-plugin-audit) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-audit?style=flat-square)](https://docs.rs/hyperlane-plugin-audit) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-audit/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-audit` records tamper-evident SHA-256 hash-chained HTTP security audit trails for [`hyperlane`](../../README.md) services (hook order `-118` / `92`). Like all Hyperlane plugins, it is opt-in and transparent (`Status::Continue`) until initialized. + +## Installation + +```sh +cargo add hyperlane-plugin-audit +``` + +## Usage + +```rust +use hyperlane_plugin_audit::{AuditConfig, AuditPlugin}; + +fn setup_audit() { + AuditPlugin::init(AuditConfig::default()); +} +``` + +## Verification + +```sh +cargo run -p hyperlane-cli -- fmt --check +cargo clippy -p hyperlane-plugin-audit --all-features --all-targets -- -D warnings +cargo test -p hyperlane-plugin-audit --all-features +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. -## Features +## Contact -- Cryptographic SHA-256 hash chaining (`prev_hash` -> `entry_hash`) with `verify_audit_chain()`. -- Automatic redaction of sensitive headers (`Authorization`, `Cookie`, and custom names). -- Method and path prefix filtering (`mutations_only`, `include_prefixes`, `exclude_prefixes`). -- Bounded `InMemoryAuditSink` ring buffer plus pluggable `AuditSink` trait. -- Opt-in and transparent (`Status::Continue`) when unconfigured (`-118` / `92`). +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/auth/AGENTS.md b/plugin/auth/AGENTS.md deleted file mode 100644 index ccfead3c..00000000 --- a/plugin/auth/AGENTS.md +++ /dev/null @@ -1,33 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-auth` - -Concise engineering and iteration guidelines for `hyperlane-plugin-auth` (`plugin/auth/`). -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**: Pure-Rust HS256 JWT (`kid` rotation), API key, HTTP Basic, RBAC `AuthPrincipal`, extensible `Authenticator` (`authenticate` + `authenticate_sync`), and `AuthHook`. -- **Dependencies**: Internal `hyperlane`; external `serde`, `serde_json`, `lombok-macros`. Keep crypto primitives dependency-free. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait,type}.rs` (`AUTH_PLUGIN`, `HmacSha256Key`, stack JSON/claim visitors stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `AuthHook` (`#[hyperlane::request_middleware(-90)]`) MUST return `Status::Continue` when `AUTH_PLUGIN` is unconfigured or the path is exempt; fail closed with prebuilt `401`/`403` wire bytes before returning `Status::Reject`. -- **Algorithm pinning & MAC-before-decode**: Require 3 non-empty JWT segments, pin `alg == "HS256"` (reject `none` and all others), and verify HMAC-SHA256 via `constant_time_eq` before parsing payload JSON. -- **Duplicate claim rejection**: Custom `JwtClaimsVisitor` MUST reject duplicate standard claims (`sub`/`iss`/`aud`/`exp`/`nbf`/`iat`/`jti`/`roles`, including `null` duplicates) and enforce required `sub`. -- **Constant-time verification & crypto vectors**: Scan API keys and Basic passwords using `constant_time_eq` without early exit; keep `aarch64` HW SHA-256 bit-identical to software SHA-256 and covered by RFC 4231 test vectors. -- **Sync fast path**: Built-in authenticators implement `authenticate_sync` to avoid `Box::pin` allocations; `CompositeAuthenticator` falls through only on `MissingCredentials`. - -## 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/auth/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-auth --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-auth --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/auth/README.md b/plugin/auth/README.md index 723f3dc7..8b27ea7b 100644 --- a/plugin/auth/README.md +++ b/plugin/auth/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-auth logo + # hyperlane-plugin-auth -**Authentication & Identity Guard Plugin** +**Pure-Rust HS256 JWT, API Key, HTTP Basic & RBAC Authentication Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-auth)](https://crates.io/crates/hyperlane-plugin-auth) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-auth?style=flat-square)](https://docs.rs/hyperlane-plugin-auth) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-auth)](https://crates.io/crates/hyperlane-plugin-auth) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-auth?style=flat-square)](https://docs.rs/hyperlane-plugin-auth) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-auth/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-auth/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in authentication middleware supporting Bearer/JWT/API-key extraction, principal attachment into `Context` attributes, and fail-closed rejection. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `trait` / `impl` — Opt-in `OnceLock` configuration, authenticator trait, and `ServerHook` guard +`hyperlane-plugin-auth` provides pure-Rust authentication and role-based access control (RBAC) middleware for [`hyperlane`](../../README.md) services (hook order `-90`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,18 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-auth ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use std::sync::Arc; +use hyperlane_plugin_auth::{AuthConfig, AuthPlugin, Authenticator}; + +fn setup_auth(authenticator: Arc) { + AuthPlugin::init(AuthConfig::default(), authenticator); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +47,6 @@ cargo clippy -p hyperlane-plugin-auth --all-features --all-targets -- -D warning cargo test -p hyperlane-plugin-auth --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/body_limit/AGENTS.md b/plugin/body_limit/AGENTS.md deleted file mode 100644 index 1af2e86c..00000000 --- a/plugin/body_limit/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-body-limit` - -Concise engineering and iteration guidelines for `hyperlane-plugin-body-limit` (`plugin/body_limit/`). -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, segment-bounded per-prefix, and per-MIME request payload size guard with prebuilt `413 Payload Too Large` wire rejection. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct}.rs` (`BODY_LIMIT_PLUGIN` and parsing helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `BodyLimitHook` (`#[hyperlane::request_middleware(-106)]`) runs BEFORE `CompressionRequestHook` (`-104`) so wire limits apply before decompression; return `Status::Continue` when unconfigured and flush prebuilt `413` bytes before returning `Status::Reject`. -- **Strict precedence**: Sort both `prefix_rules` and `mime_rules` descending by length; resolve strictly as longest segment-bounded path prefix > longest ASCII case-insensitive base MIME prefix (stripped at `;`) > `default_max_bytes`. -- **Unlimited sentinel**: `effective_limit == 0` MUST yield `Allow { limit_bytes: 0 }` to support per-route opt-out. -- **Dual size validation**: Check both buffered body length and parsed `Content-Length` (when `check_content_length` is enabled) to block spoofed oversized headers on zero-alloc hot paths. - -## 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/body_limit/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-body-limit --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-body-limit --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/body_limit/README.md b/plugin/body_limit/README.md index 1197d34d..ae569ec7 100644 --- a/plugin/body_limit/README.md +++ b/plugin/body_limit/README.md @@ -1,24 +1,55 @@ +
+ +hyperlane-plugin-body-limit logo + # hyperlane-plugin-body-limit -Zero-allocation granular request payload size guard for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**Granular Global, Path-Prefix & MIME Request Payload Size Limiter Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-body-limit)](https://crates.io/crates/hyperlane-plugin-body-limit) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-body-limit?style=flat-square)](https://docs.rs/hyperlane-plugin-body-limit) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-body-limit/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-body-limit` enforces zero-allocation request body size limits globally, per path prefix, and per MIME type for [`hyperlane`](../../README.md) servers (hook order `-106`). It is opt-in and transparent (`Status::Continue`) when unconfigured. -## Features +## Installation -- Global default body cap plus longest-prefix segment-bounded path overrides (including `0` = unlimited). -- Case-insensitive MIME media-type prefix overrides (for example `application/json` vs `multipart/`). -- Checks both buffered body length and declared `Content-Length`. -- Prebuilt `413 Payload Too Large` HTTP wire response buffer (zero allocations on reject). -- Opt-in and transparent (`Status::Continue`) when unconfigured (`#[hyperlane::request_middleware(-106)]`). +```sh +cargo add hyperlane-plugin-body-limit +``` -## Quick Start +## Usage ```rust use hyperlane_plugin_body_limit::{BodyLimitConfig, BodyLimitPlugin}; -BodyLimitPlugin::init( - BodyLimitConfig::default() - .with_default_max_bytes(1024 * 1024) - .with_prefix_limit("/upload", 32 * 1024 * 1024) - .with_mime_limit("application/json", 256 * 1024), -); +fn setup_body_limit() { + BodyLimitPlugin::init(BodyLimitConfig::default()); +} +``` + +## Verification + +```sh +cargo run -p hyperlane-cli -- fmt --check +cargo clippy -p hyperlane-plugin-body-limit --all-features --all-targets -- -D warnings +cargo test -p hyperlane-plugin-body-limit --all-features ``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. + +## Contact + +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/cache/AGENTS.md b/plugin/cache/AGENTS.md deleted file mode 100644 index b1ca1d6b..00000000 --- a/plugin/cache/AGENTS.md +++ /dev/null @@ -1,33 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-cache` - -Concise engineering and iteration guidelines for `hyperlane-plugin-cache` (`plugin/cache/`). -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**: 64-way cache-line-aligned bounded memory cache (`ShardedMemoryCache`), single-flight stampede coalescing, pluggable `CacheStore`, and HTTP response caching hooks. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,fn,impl,static,struct,trait,type}.rs` (`CACHE_PLUGIN`, shard/entry/wire internals stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `CacheRequestHook` (`#[hyperlane::request_middleware(-80)]`, returns `Status::Reject` after sending HIT bytes) and `CacheResponseHook` (`#[hyperlane::response_middleware(-65)]`, always `Status::Continue`) MUST stay transparent when `CACHE_PLUGIN` is unconfigured. -- **Exact sharded accounting**: Keep `CACHE_SHARD_COUNT = 64` aligned shards with exact `entry_count`, `total_bytes`, and `min_expires_at_ms` atomic updates across insert/update/remove/evict/purge. -- **RFC cacheability & auth safety**: Cache only `GET`/`HEAD` `200 OK` within `max_entry_bytes` with `Vary != "*"` and cacheable `Cache-Control`; bypass `Authorization`/`Cookie` (when `bypass_authenticated`) and `no-store`/`no-cache`/`private`/`max-age=0`; strip `X-Cache` and `Age` prior to storage. -- **HTTP/1.1 wire-cache & `HEAD` safety**: Never emit lazy prebuilt wire for bodyless statuses (`1xx`/`204`/`205`/`304`) or `Content-Encoding`/`Transfer-Encoding` responses; always emit an empty body on `HEAD` hits. -- **Single-flight wakeup safety**: In `get_or_load`, register `slot.notify.notified()` before checking `slot.result`, and write `slot.result` before removing the inflight slot and calling `notify_waiters()`. - -## 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/cache/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-cache --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-cache --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/cache/README.md b/plugin/cache/README.md index c234ff71..811dcdf0 100644 --- a/plugin/cache/README.md +++ b/plugin/cache/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-cache logo + # hyperlane-plugin-cache -**Response & Keyed In-Memory Cache Plugin** +**64-Way Sharded Bounded HTTP Response & In-Memory Cache Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-cache)](https://crates.io/crates/hyperlane-plugin-cache) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-cache?style=flat-square)](https://docs.rs/hyperlane-plugin-cache) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-cache)](https://crates.io/crates/hyperlane-plugin-cache) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-cache?style=flat-square)](https://docs.rs/hyperlane-plugin-cache) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-cache/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-cache/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in HTTP response caching middleware with TTL eviction, cache-key customization, and safe-method cache controls. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `trait` / `impl` — Cache store trait, TTL configuration, and response caching hooks +`hyperlane-plugin-cache` provides high-concurrency HTTP response caching with single-flight stampede coalescing for [`hyperlane`](../../README.md) applications (hook order `-80` / `-65`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-cache ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_cache::{CacheConfig, CachePlugin}; + +fn setup_cache() { + CachePlugin::init(CacheConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-cache --all-features --all-targets -- -D warnin cargo test -p hyperlane-plugin-cache --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/canary/AGENTS.md b/plugin/canary/AGENTS.md deleted file mode 100644 index e6a7a138..00000000 --- a/plugin/canary/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-canary` - -Concise engineering and iteration guidelines for `hyperlane-plugin-canary` (`plugin/canary/`). -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**: Feature flags, A/B experiments, and deterministic `XxHash3_64` basis-point sticky rollouts (`CanaryPlugin`, `CanaryDecision`, `CanaryRequestHook`, `CanaryResponseHook`). -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,fn,impl,static,struct}.rs` (`CANARY_PLUGIN`, `CompiledExperiment`, and cookie/prefix/vary helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `CanaryRequestHook` (`#[hyperlane::request_middleware(-88)]`) and `CanaryResponseHook` (`#[hyperlane::response_middleware(-68)]`) MUST stay transparent (`Status::Continue`) when `CANARY_PLUGIN` is unconfigured; response order `-68` MUST precede `CacheResponseHook` (`-65`) so `Vary` is set before caching. -- **Deterministic bucketing stability**: `bucket_basis_points` hashes `experiment || 0xFF || subject` via `XxHash3_64` modulo `10_000`; never alter the separator or hash algorithm without a coordinated breaking release. -- **Identity & prefix precedence**: Longest segment-bounded prefix wins; resolve identity strictly as `override_header` > `sticky_header` > `sticky_cookie` (zero-alloc scan) > request `path`. -- **Weight clamping & `Vary` hygiene**: Drop `weight_bps == 0` arms, saturate cumulative weights at `10_000` (falling through to `default_variant`), and merge `sticky_header` 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/canary/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-canary --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-canary --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/canary/README.md b/plugin/canary/README.md index 958b7ad5..8a91f165 100644 --- a/plugin/canary/README.md +++ b/plugin/canary/README.md @@ -1,11 +1,55 @@ +
+ +hyperlane-plugin-canary logo + # hyperlane-plugin-canary -Deterministic feature-flag, A/B testing, and progressive canary rollout middleware for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**Feature Flags, A/B Testing & Deterministic Sticky Canary Rollout Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-canary)](https://crates.io/crates/hyperlane-plugin-canary) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-canary?style=flat-square)](https://docs.rs/hyperlane-plugin-canary) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-canary/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-canary` implements deterministic progressive rollouts, feature flags, and multi-arm A/B experiments for [`hyperlane`](../../README.md) services (hook order `-88` / `-68`). It is opt-in and transparent (`Status::Continue`) when unconfigured. + +## Installation + +```sh +cargo add hyperlane-plugin-canary +``` + +## Usage + +```rust +use hyperlane_plugin_canary::{CanaryConfig, CanaryPlugin}; + +fn setup_canary() { + CanaryPlugin::init(CanaryConfig::default()); +} +``` + +## Verification + +```sh +cargo run -p hyperlane-cli -- fmt --check +cargo clippy -p hyperlane-plugin-canary --all-features --all-targets -- -D warnings +cargo test -p hyperlane-plugin-canary --all-features +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. -## Features +## Contact -- Deterministic `XxHash3_64` `0..10_000` basis-point sticky bucketing by header, cookie, or path. -- Forced QA/ops override header (`X-Canary-Override`). -- Longest-prefix route scoping with weighted multi-arm experiments. -- Injects `CanaryDecision` into `Context` and emits `X-Variant` + `Vary` response headers. -- Opt-in and transparent (`Status::Continue`) when unconfigured (`-88` / `-68`). +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/circuit_breaker/AGENTS.md b/plugin/circuit_breaker/AGENTS.md deleted file mode 100644 index af1e4326..00000000 --- a/plugin/circuit_breaker/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-circuit-breaker` - -Concise engineering and iteration guidelines for `hyperlane-plugin-circuit-breaker` (`plugin/circuit_breaker/`). -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**: Route/prefix-scoped lock-free atomic sliding-window HTTP circuit breaker (`Closed`/`Open`/`HalfOpen` CAS probe gating, custom status predicate, prebuilt `503` wire responses). -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,type}.rs` (`CIRCUIT_BREAKER_PLUGIN`, `CompiledBreaker`, `WindowBucket`, `FastDiv64`, probe inner stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `CircuitBreakerRequestHook` (`#[hyperlane::request_middleware(-92)]`, flushes prebuilt `503` + `Retry-After` before `Status::Reject` when open) and `CircuitBreakerResponseHook` (`#[hyperlane::response_middleware(88)]`, always `Status::Continue`) MUST remain transparent when unconfigured. -- **Zero-alloc lock-free `Closed` path**: Keep `try_admit` stack-only (`BreakerPermit::Closed { slot_idx }`) with zero clock reads or heap allocations; scan sliding-window buckets only on failures. -- **Leak-proof RAII `HalfOpen` probe guard**: `HalfOpenProbeGuard` MUST release `half_open_in_flight` exactly once via atomic completion flag even when a handler panics, disconnects, or returns early `Status::Reject`. -- **CAS state transitions & recovery reset**: Transition `Open -> HalfOpen` on cooldown expiry, `HalfOpen -> Open` on any failed probe, and `HalfOpen -> Closed` with `reset_window()` once `half_open_success_threshold` is met so stale failures cannot immediately re-trip. - -## 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/circuit_breaker/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-circuit-breaker --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-circuit-breaker --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/circuit_breaker/README.md b/plugin/circuit_breaker/README.md index cdfe53e5..9820d5ae 100644 --- a/plugin/circuit_breaker/README.md +++ b/plugin/circuit_breaker/README.md @@ -1,11 +1,14 @@
+hyperlane-plugin-circuit-breaker logo + # hyperlane-plugin-circuit-breaker **Lock-Free Sliding-Window HTTP Circuit Breaker Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-circuit-breaker)](https://crates.io/crates/hyperlane-plugin-circuit-breaker) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-circuit-breaker?style=flat-square)](https://docs.rs/hyperlane-plugin-circuit-breaker) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-circuit-breaker)](https://crates.io/crates/hyperlane-plugin-circuit-breaker) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-circuit-breaker?style=flat-square)](https://docs.rs/hyperlane-plugin-circuit-breaker) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) @@ -17,14 +20,7 @@ ## Overview -Opt-in request (`-92`) and response (`88`) middleware providing route/prefix-scoped HTTP circuit breaking backed by lock-free atomic sliding-window ring buffers, configurable response status failure predicates (default `5xx`), `Closed -> Open -> HalfOpen` atomic probe gating with RAII probe-slot guards, and prebuilt zero-allocation `503 Service Unavailable` + `Retry-After` wire responses. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `enum` / `impl` — `BreakerRule`, `CircuitBreakerConfig`, `CircuitState`, `CircuitBreakerEngine`, `CircuitBreakerPlugin`, `CircuitBreakerRequestHook` (`-92`), and `CircuitBreakerResponseHook` (`88`) -- `fn` — Monotonic ring-bucket math, prefix boundary matching, and default `5xx` failure predicate +`hyperlane-plugin-circuit-breaker` protects [`hyperlane`](../../README.md) endpoints against cascading downstream failures using a lock-free atomic sliding-window state machine (hook order `-92` / `88`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -32,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-circuit-breaker ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_circuit_breaker::{CircuitBreakerConfig, CircuitBreakerPlugin}; + +fn setup_circuit_breaker() { + CircuitBreakerPlugin::init(CircuitBreakerConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -42,10 +46,6 @@ cargo clippy -p hyperlane-plugin-circuit-breaker --all-features --all-targets -- cargo test -p hyperlane-plugin-circuit-breaker --all-features ``` -## Documentation & Governance - -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/compression/AGENTS.md b/plugin/compression/AGENTS.md deleted file mode 100644 index 0749d567..00000000 --- a/plugin/compression/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# 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 . -``` diff --git a/plugin/compression/README.md b/plugin/compression/README.md index c4818ac3..88e6ad9d 100644 --- a/plugin/compression/README.md +++ b/plugin/compression/README.md @@ -1,10 +1,55 @@ +
+ +hyperlane-plugin-compression logo + # hyperlane-plugin-compression -Full-duplex opt-in compression middleware for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**Full-Duplex Bounded Request Decompression & Response Compression Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-compression)](https://crates.io/crates/hyperlane-plugin-compression) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-compression?style=flat-square)](https://docs.rs/hyperlane-plugin-compression) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-compression/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-compression` delivers full-duplex HTTP compression middleware for [`hyperlane`](../../README.md) services (hook order `-104` / `-55`), combining bounded inbound decompression with negotiated outbound compression. It is opt-in and transparent (`Status::Continue`) when unconfigured. + +## Installation + +```sh +cargo add hyperlane-plugin-compression +``` + +## Usage + +```rust +use hyperlane_plugin_compression::{CompressionConfig, CompressionPlugin}; + +fn setup_compression() { + CompressionPlugin::init(CompressionConfig::default()); +} +``` + +## 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 +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. -## Features +## Contact -- Bounded request body decompression (`gzip`, `deflate`, `br`) with configurable max decompressed size (`413`) and unsupported codec rejection (`415`). -- Automatic `Accept-Encoding` response negotiation (`br`, `gzip`, `deflate`) respecting `min_body_bytes`, `Cache-Control: no-transform`, and incompressible MIME exclusions. -- Deduplicated `Vary: Accept-Encoding` merging. -- Opt-in and transparent (`Status::Continue`) when unconfigured (`-104` / `-55`). +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/concurrency/AGENTS.md b/plugin/concurrency/AGENTS.md deleted file mode 100644 index 8c60a9ba..00000000 --- a/plugin/concurrency/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-concurrency` - -Concise engineering and iteration guidelines for `hyperlane-plugin-concurrency` (`plugin/concurrency/`). -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**: Lock-free atomic global and per-prefix in-flight concurrency limiter with AIMD adaptive load shedding, optional `Semaphore` wait queue, RAII `Context` permits, and prebuilt `503` wire responses. -- **Dependencies**: Internal `hyperlane` (uses re-exported Tokio `Semaphore`/`timeout`); external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct}.rs` (`CONCURRENCY_PLUGIN`, limiter/permit internals, and prefix/AIMD helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `ConcurrencyRequestHook` (`#[hyperlane::request_middleware(-108)]`, sheds with prebuilt `503` + `Status::Reject`) and `ConcurrencyResponseHook` (`#[hyperlane::response_middleware(85)]`, releases permit and returns `Status::Continue`) MUST remain transparent when unconfigured. -- **Exactly-once RAII permit release**: `ConcurrencyPermitInner::release_once` MUST guard release atomically (`released.swap(true, ...)`) so explicit release and `Drop` on early `Status::Reject`/panic/disconnect never leak or double-decrement slots. -- **Atomic partial-acquire rollback**: If global acquisition succeeds while prefix acquisition fails or times out, always decrement `global_in_flight` and drop any held global semaphore permit before returning `Err`. -- **Zero-semaphore fast path & AIMD bounds**: Allocate Tokio `Semaphore` queues only when `wait_timeout_ms > 0`; clamp AIMD `effective_limit` within `[min_limit.max(1).min(max_in_flight), max_in_flight]` and `decrease_percent` within `1..=99`. - -## 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/concurrency/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-concurrency --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-concurrency --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/concurrency/README.md b/plugin/concurrency/README.md index bd7d0027..236f2205 100644 --- a/plugin/concurrency/README.md +++ b/plugin/concurrency/README.md @@ -1,11 +1,14 @@
+hyperlane-plugin-concurrency logo + # hyperlane-plugin-concurrency **Lock-Free In-Flight Concurrency Limiter & Adaptive Load-Shedding Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-concurrency)](https://crates.io/crates/hyperlane-plugin-concurrency) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-concurrency?style=flat-square)](https://docs.rs/hyperlane-plugin-concurrency) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-concurrency)](https://crates.io/crates/hyperlane-plugin-concurrency) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-concurrency?style=flat-square)](https://docs.rs/hyperlane-plugin-concurrency) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) @@ -17,14 +20,7 @@ ## Overview -Opt-in request (`-108`) and response (`85`) middleware enforcing lock-free atomic global and per-route-prefix in-flight concurrency caps, AIMD latency-driven adaptive load shedding, optional bounded wait queues via `tokio::sync::Semaphore`, prebuilt `503 Service Unavailable` + `Retry-After` wire responses, and leak-proof RAII `ConcurrencyPermit` guards stored in Hyperlane `Context` attributes (`ATTR_CONCURRENCY_PERMIT`) that release automatically on early `Status::Reject`, panics, or dropped connections. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `enum` / `impl` — `ConcurrencyConfig`, `PrefixConcurrencyLimit`, `AdaptiveShedConfig`, `ConcurrencyLimiter`, `ConcurrencyPermit`, `ConcurrencyPlugin`, `ConcurrencyRequestHook` (`-108`), and `ConcurrencyResponseHook` (`85`) -- `fn` — Segment-boundary prefix normalization, lock-free atomic CAS slot acquisition, and EWMA/AIMD limit updates +`hyperlane-plugin-concurrency` bounds active in-flight requests globally and per route prefix for [`hyperlane`](../../README.md) services (hook order `-108` / `85`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -32,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-concurrency ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_concurrency::{ConcurrencyConfig, ConcurrencyPlugin}; + +fn setup_concurrency() { + ConcurrencyPlugin::init(ConcurrencyConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -42,10 +46,6 @@ cargo clippy -p hyperlane-plugin-concurrency --all-features --all-targets -- -D cargo test -p hyperlane-plugin-concurrency --all-features ``` -## Documentation & Governance - -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/cors/AGENTS.md b/plugin/cors/AGENTS.md deleted file mode 100644 index b5778135..00000000 --- a/plugin/cors/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-cors` - -Concise engineering and iteration guidelines for `hyperlane-plugin-cors` (`plugin/cors/`). -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**: Precompiled zero-allocation CORS policy engine (`CorsConfig`, `AllowOrigin`, `CompiledCors`), preflight `OPTIONS` short-circuiting, credentials safety guard, and `Vary` merging. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,type}.rs` (`CORS_PLUGIN`, fast preflight, host parsing, and header validation helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `CorsRequestHook` (`#[hyperlane::request_middleware(-100)]`, short-circuits preflight `OPTIONS` with `204` + `Status::Reject`) and `CorsResponseHook` (`#[hyperlane::response_middleware(-80)]`, re-applies headers if cleared and returns `Status::Continue`) MUST stay transparent when unconfigured. -- **Fetch spec credentials guard**: Never emit `Access-Control-Allow-Origin: *` when `allow_credentials == true` (reflect validated origin instead), and always emit `Vary: Origin` whenever origin varies (`!is_any_wildcard`). -- **CRLF rejection & safe non-mirroring**: Reject control bytes (`< 0x20` except `\t`, and `0x7f`) in configured headers, reflected `Origin`, and mirrored `Access-Control-Request-Headers`; invalid configured `allow_headers` MUST NOT silently fall back to mirroring arbitrary client headers. -- **Strict suffix authority boundaries**: `AllowOrigin::Suffix` matches only extracted authority host (supporting IPv6 `[...]`), ensuring `.svc.local` matches `svc.local` and `*.svc.local` while rejecting `evilsvc.local`. - -## 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/cors/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-cors --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-cors --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/cors/README.md b/plugin/cors/README.md index e6f721c3..4b0cffeb 100644 --- a/plugin/cors/README.md +++ b/plugin/cors/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-cors logo + # hyperlane-plugin-cors -**RFC-Compliant CORS Middleware Plugin** +**Zero-Allocation Precompiled RFC-Compliant CORS Middleware Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-cors)](https://crates.io/crates/hyperlane-plugin-cors) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-cors?style=flat-square)](https://docs.rs/hyperlane-plugin-cors) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-cors)](https://crates.io/crates/hyperlane-plugin-cors) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-cors?style=flat-square)](https://docs.rs/hyperlane-plugin-cors) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-cors/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-cors/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in Cross-Origin Resource Sharing hook handling preflight `OPTIONS`, origin allowlists, credentials, exposed headers, and max-age policies. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `enum` / `impl` — Origin/method/header policy builders and preflight short-circuit hook +`hyperlane-plugin-cors` adds zero-allocation Cross-Origin Resource Sharing (CORS) policy enforcement and preflight handling to [`hyperlane`](../../README.md) services (hook order `-100` / `-80`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-cors ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_cors::{CorsConfig, CorsPlugin}; + +fn setup_cors() { + CorsPlugin::init(CorsConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-cors --all-features --all-targets -- -D warning cargo test -p hyperlane-plugin-cors --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/env/AGENTS.md b/plugin/env/AGENTS.md deleted file mode 100644 index f37a75e6..00000000 --- a/plugin/env/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-env` - -Concise engineering and iteration guidelines for `hyperlane-plugin-env` (`plugin/env/`). -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**: Zero-external-dependency `.env` parser, layered typed environment loader, redacting `SecretValue`, and `HYPERLANE_*` `ServerConfig` builder. -- **Dependencies**: Internal `hyperlane` ONLY (zero external dependencies). -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct}.rs` (`ENV_PLUGIN` and parser helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Startup-only / zero runtime hooks**: Register NO `ServerHook` or middleware in this crate; keep per-request overhead strictly zero while providing optional `OnceLock` `EnvPlugin::{init, get}` access. -- **Unconditional secret redaction**: `SecretValue` MUST NOT derive `Debug` or print raw secrets in `Debug`/`Display` (always emit `"[REDACTED]"`); raw access is strictly via `.expose()`. -- **`.env` quoting & interpolation semantics**: Keep single-quoted values strictly literal, unescape double-quoted values before `${VAR}` interpolation, strip inline `" #"` comments on unquoted values, resolve prior `.env` keys before OS env vars, and enforce `[A-Za-z_][A-Za-z0-9_]*` keys (after optional `export `). -- **`ServerConfig` validation**: `ADDRESS` overrides `HOST`+`PORT`, TLS activates only when both `TLS_CERT` and `TLS_KEY` are present, `PROTOCOL` accepts only `http1|http2|http3`, and errors report the full prefixed key name. - -## 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/env/README.md` (and `plugin/README.md` / root `README.md` if public surface or env keys change) in the same commit. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p hyperlane-plugin-env --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-env --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/env/README.md b/plugin/env/README.md index fce81c64..c5ecc81e 100644 --- a/plugin/env/README.md +++ b/plugin/env/README.md @@ -1,10 +1,56 @@ +
+ +hyperlane-plugin-env logo + # hyperlane-plugin-env -Zero-dependency `.env` parser, layered environment loader, redacting `SecretValue`, and `HYPERLANE_*` `ServerConfig` builder for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**Zero-Dependency `.env` Parser, Typed Config Loader & `ServerConfig` Builder Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-env)](https://crates.io/crates/hyperlane-plugin-env) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-env?style=flat-square)](https://docs.rs/hyperlane-plugin-env) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-env/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-env` loads layered environment configuration, parses `.env` files, protects secrets in logs, and builds Hyperlane `ServerConfig` instances directly from `HYPERLANE_*` environment variables for [`hyperlane`](../../README.md) services. + +## Installation + +```sh +cargo add hyperlane-plugin-env +``` + +## Usage + +```rust +use hyperlane_plugin_env::EnvPlugin; + +fn setup_env() { + let plugin: EnvPlugin = EnvPlugin::new(); + EnvPlugin::init(plugin); +} +``` + +## Verification + +```sh +cargo run -p hyperlane-cli -- fmt --check +cargo clippy -p hyperlane-plugin-env --all-features --all-targets -- -D warnings +cargo test -p hyperlane-plugin-env --all-features +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. -## Features +## Contact -- Parses `.env` files with single/double quotes, escapes, `export`, comments, and `${VAR}` interpolation. -- Builds Hyperlane `ServerConfig` directly from `HYPERLANE_ADDRESS`/`HOST`/`PORT`, `NODELAY`, `TTL`, `PROTOCOL`, and `TLS_CERT`/`TLS_KEY`. -- Typed extraction (`get_parse`, `get_bool`, `get_duration`, `require_string`) and redacting `SecretValue`. -- Zero per-request middleware overhead. +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/etag/AGENTS.md b/plugin/etag/AGENTS.md deleted file mode 100644 index 0e50c53c..00000000 --- a/plugin/etag/AGENTS.md +++ /dev/null @@ -1,31 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-etag` - -Concise engineering and iteration guidelines for `hyperlane-plugin-etag` (`plugin/etag/`). -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**: Automatic strong/weak `XxHash3_64` ETag generation, zero-allocation `If-None-Match` (`304 Not Modified`), and optimistic-concurrency `If-Match` (`412 Precondition Failed`) via `EtagValidator`. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait}.rs` (`ETAG_PLUGIN` and stack ETag/prefix helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `EtagRequestHook` (`#[hyperlane::request_middleware(-72)]`, flushes prebuilt `412` before `Status::Reject`) and `EtagResponseHook` (`#[hyperlane::response_middleware(-58)]`, always `Status::Continue`) MUST stay transparent when unconfigured; `-58` MUST run after `CacheResponseHook` (`-65`) and before `CompressionResponseHook` (`-55`). -- **RFC 9110 §13.1.1 strong `If-Match` comparison**: `matches_if_match_strong` MUST reject weak tags (`W/...`) on either side; `"*"` succeeds iff a current entity ETag exists; evaluate only on mutating methods (`!GET && !HEAD && !OPTIONS`) when `enforce_if_match` and `validator` are active. -- **Handler ETag preservation & `304` body clearing**: Apply only to `GET`/`HEAD` `2xx` non-bodyless responses, keep handler-supplied `ETag` intact, format generated ETags in fixed stack buffers (`[u8; 18]`/`[u8; 20]`), and clear the response body on `304 Not Modified`. - -## 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/etag/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-etag --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-etag --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/etag/README.md b/plugin/etag/README.md index 84ca9fa0..7d914f35 100644 --- a/plugin/etag/README.md +++ b/plugin/etag/README.md @@ -1,10 +1,55 @@ +
+ +hyperlane-plugin-etag logo + # hyperlane-plugin-etag -Opt-in automatic ETag and HTTP conditional request middleware for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**Automatic Strong/Weak ETag & HTTP Conditional Request Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-etag)](https://crates.io/crates/hyperlane-plugin-etag) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-etag?style=flat-square)](https://docs.rs/hyperlane-plugin-etag) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-etag/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-etag` automates entity tag generation and RFC 9110 conditional request evaluation (`304 Not Modified` and `412 Precondition Failed`) for [`hyperlane`](../../README.md) endpoints (hook order `-72` / `-58`). It is opt-in and transparent (`Status::Continue`) when unconfigured. + +## Installation + +```sh +cargo add hyperlane-plugin-etag +``` + +## Usage + +```rust +use hyperlane_plugin_etag::{EtagConfig, EtagPlugin}; + +fn setup_etag() { + EtagPlugin::init(EtagConfig::default()); +} +``` + +## Verification + +```sh +cargo run -p hyperlane-cli -- fmt --check +cargo clippy -p hyperlane-plugin-etag --all-features --all-targets -- -D warnings +cargo test -p hyperlane-plugin-etag --all-features +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. -## Features +## Contact -- Fast stack-formatted strong (`""`) and weak (`W/""`) `XxHash3_64` ETags. -- Zero-allocation `If-None-Match` -> `304 Not Modified` on `GET`/`HEAD` responses. -- RFC 9110 §13.1.1 `If-Match` optimistic concurrency enforcement (`412 Precondition Failed`) via pluggable `EtagValidator`. -- Opt-in and transparent (`Status::Continue`) when unconfigured (`-72` / `-58`). +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/gateway/AGENTS.md b/plugin/gateway/AGENTS.md deleted file mode 100644 index 6f32639c..00000000 --- a/plugin/gateway/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-gateway` - -Concise engineering and iteration guidelines for `hyperlane-plugin-gateway` (`plugin/gateway/`). -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**: Reverse proxy and API gateway backed by pooled `http-request` with RR/Weighted/LC/P2C balancing, per-upstream circuit breaking, lock-free GCRA rate limiting, and `GatewayInterceptor`. -- **Dependencies**: Internal `hyperlane`, `http-request`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait}.rs` (`GATEWAY_PLUGIN`, `CompiledRoute`, `UpstreamRuntime`, `TokenBucket`, `FastModU64` stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `GatewayHook` (`#[hyperlane::request_middleware(-50)]`) MUST return `Status::Continue` when unconfigured or unmatched, and send the upstream/error response before returning `Status::Reject` on matched routes. -- **Bidirectional RFC 9110 hop-by-hop stripping**: Strip standard hop-by-hop headers (`Connection`, `Keep-Alive`, `Proxy-*`, `TE`, `Trailer`, `Transfer-Encoding`, `Upgrade`), `Connection`-nominated header tokens, `Content-Length`, and inbound `Host` (preserving `X-Forwarded-Host` and appending `peer_ip` to `X-Forwarded-For`). -- **Route matching & pre-dispatch gating**: Sort routes by descending `normalized_prefix.len()` then `normalized_host.is_some()` with segment-bounded matching; enforce GCRA `TokenBucket` (`429`), `max_body_size` (`413`), and upstream health (`503`) before invoking `GatewayInterceptor::before_forward` or upstream I/O. -- **Atomic upstream accounting & O(1) LB**: Wrap `send_async().await` with `active_conns` tracking, open upstream circuits on transport errors (`502`) or `502..=504` responses, and keep inline `UpstreamRuntime` arrays, `FastModU64`, `weighted_ring`, and P2C selection allocation-free. - -## 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/gateway/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-gateway --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-gateway --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/gateway/README.md b/plugin/gateway/README.md index a4209d1d..3fbbc556 100644 --- a/plugin/gateway/README.md +++ b/plugin/gateway/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-gateway logo + # hyperlane-plugin-gateway -**Reverse Proxy & API Gateway Plugin** +**Reverse Proxy & API Gateway Plugin with Load Balancing & Upstream Resilience** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-gateway)](https://crates.io/crates/hyperlane-plugin-gateway) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-gateway?style=flat-square)](https://docs.rs/hyperlane-plugin-gateway) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-gateway)](https://crates.io/crates/hyperlane-plugin-gateway) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-gateway?style=flat-square)](https://docs.rs/hyperlane-plugin-gateway) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-gateway/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-gateway/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in reverse proxy and API gateway backed by pooled `http-request` with load balancing, circuit breaking, token-bucket rate limiting, and RFC 9110 hop-by-hop header stripping. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `trait` / `impl` — Upstream pools, health/circuit breakers, and `GatewayHook` +`hyperlane-plugin-gateway` turns a [`hyperlane`](../../README.md) server into a high-throughput reverse proxy and API gateway over pooled [`http-request`](../../request/README.md) HTTP/1.1 and HTTP/2 connections (hook order `-50`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-gateway ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_gateway::{GatewayConfig, GatewayPlugin}; + +fn setup_gateway() { + GatewayPlugin::init(GatewayConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-gateway --all-features --all-targets -- -D warn cargo test -p hyperlane-plugin-gateway --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/graphql/AGENTS.md b/plugin/graphql/AGENTS.md deleted file mode 100644 index e1c0cfdd..00000000 --- a/plugin/graphql/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-graphql` - -Concise engineering and iteration guidelines for `hyperlane-plugin-graphql` (`plugin/graphql/`). -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**: Zero-external-parser GraphQL over HTTP (`POST`/`GET`) engine with depth/complexity DoS caps, `XxHash3_64` query/mutation resolver registries, sub-field projection, and `GraphqlHook`. -- **Dependencies**: Internal `hyperlane`; external `serde`, `serde_json`, `lombok-macros` (keep parser free of external parser crates). -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait}.rs` (`GRAPHQL_PLUGIN`, recursive descent parser, and `project_selection` stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `GraphqlHook` (`#[hyperlane::request_middleware(-62)]`) MUST match `config.endpoint` (default `"/graphql"`) exactly, return `Status::Continue` when unconfigured or on other paths, and send JSON bytes before returning `Status::Reject`. -- **Three-tier parser DoS caps**: Enforce `query.len() <= max_query_bytes` before parsing, and enforce `max_depth >= 1` (covering both nested selection sets and nested list/object input values) plus total `max_fields >= 1`. -- **GraphQL-over-HTTP method rules**: Disallow mutations on `GET` (`allow_mutation = false`), and return HTTP `405 Method Not Allowed` for unsupported methods. -- **Strict projection & partial-error semantics**: Strip unrequested object/array keys via `project_selection`, emit keys using `FieldSelection::response_key()` (alias over name), and return per-field `null` + `errors` for resolver failures while returning `data: None` on syntax/DoS/method violations. - -## 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/graphql/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-graphql --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-graphql --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/graphql/README.md b/plugin/graphql/README.md index cb9fb43d..ef703e0e 100644 --- a/plugin/graphql/README.md +++ b/plugin/graphql/README.md @@ -1,11 +1,56 @@ +
+ +hyperlane-plugin-graphql logo + # hyperlane-plugin-graphql -Zero-external-parser GraphQL over HTTP plugin for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**Zero-External-Parser GraphQL over HTTP Server Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-graphql)](https://crates.io/crates/hyperlane-plugin-graphql) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-graphql?style=flat-square)](https://docs.rs/hyperlane-plugin-graphql) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-graphql/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-graphql` embeds a zero-external-parser GraphQL over HTTP (`POST`/`GET`) engine directly into [`hyperlane`](../../README.md) services (hook order `-62`). It is opt-in and transparent (`Status::Continue`) when unconfigured. + +## Installation + +```sh +cargo add hyperlane-plugin-graphql +``` + +## Usage + +```rust +use hyperlane_plugin_graphql::{GraphqlConfig, GraphqlPlugin}; + +fn setup_graphql() { + let plugin: GraphqlPlugin = GraphqlPlugin::new(GraphqlConfig::default()); + GraphqlPlugin::init(plugin); +} +``` + +## Verification + +```sh +cargo run -p hyperlane-cli -- fmt --check +cargo clippy -p hyperlane-plugin-graphql --all-features --all-targets -- -D warnings +cargo test -p hyperlane-plugin-graphql --all-features +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. -## Features +## Contact -- Zero-dependency recursive-descent GraphQL query/mutation parser supporting aliases, arguments, variables, and sub-field projection. -- Configurable query byte cap, nesting depth cap, and field complexity cap against DoS queries. -- `XxHash3_64` query and mutation resolver registries (`with_query` / `with_mutation`). -- Supports `POST` JSON and read-only `GET ?query=...` per GraphQL-over-HTTP. -- Opt-in and transparent (`Status::Continue`) when unconfigured (`#[hyperlane::request_middleware(-62)]`). +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/grpc/AGENTS.md b/plugin/grpc/AGENTS.md deleted file mode 100644 index cb42bc7f..00000000 --- a/plugin/grpc/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-grpc` - -Concise engineering and iteration guidelines for `hyperlane-plugin-grpc` (`plugin/grpc/`). -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**: gRPC over HTTP/2 5-byte length-prefixed framing (`GrpcFrame`), bounded compression, status codes `0..=16` (`GrpcStatus`), `grpc-timeout`, `GrpcInterceptor`, `GrpcRouter`, and `GrpcHook`. -- **Dependencies**: Internal `hyperlane`, `http-compress`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait,type}.rs` (`GRPC_PLUGIN`, SWAR encoder, and stack wire helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `GrpcHook` (`#[hyperlane::request_middleware(-65)]`) MUST stay transparent (`Status::Continue`) when unconfigured or when `Content-Type` is not gRPC; reject non-`POST` gRPC requests with HTTP `405` and return HTTP `200` + `content-type: application/grpc` + `grpc-status` before `Status::Reject`. -- **5-byte LPM framing & bomb limits**: Validate `len >= 5`, `flag <= 1`, `declared_len <= max_message_size` (`ResourceExhausted`), complete payload, known encoding when `flag == 1` (`Unimplemented`), post-decompression `decoded.len() <= max_message_size`, and `decode_many` `max_frames`. -- **Media-type & header injection safety**: `is_grpc_content_type` MUST accept only `application/grpc`, `+suffix`, or `;params`; `percent_encode_grpc_message` (8-byte SWAR) MUST uppercase-percent-encode bytes outside `0x20..=0x7E` plus `%`. -- **Timeout & hot-path invariants**: `parse_grpc_timeout` accepts `<1..8 ASCII digits>` and maps expiry to `GrpcStatus::DeadlineExceeded`; preserve small-router linear scan (`<= 4` methods), in-place 5-byte header prepend, and stack fast-path OK wire serialization. - -## 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/grpc/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-grpc --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-grpc --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/grpc/README.md b/plugin/grpc/README.md index 99b1e075..e96f20cd 100644 --- a/plugin/grpc/README.md +++ b/plugin/grpc/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-grpc logo + # hyperlane-plugin-grpc -**gRPC over HTTP/2 Plugin** +**gRPC over HTTP/2 Framing, Routing & Trailer Status Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-grpc)](https://crates.io/crates/hyperlane-plugin-grpc) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-grpc?style=flat-square)](https://docs.rs/hyperlane-plugin-grpc) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-grpc)](https://crates.io/crates/hyperlane-plugin-grpc) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-grpc?style=flat-square)](https://docs.rs/hyperlane-plugin-grpc) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-grpc/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-grpc/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in gRPC framing and dispatch over Hyperlane HTTP/2 with 5-byte length-prefixed frames, bounded compression, gRPC status codes `0..=16`, and `grpc-timeout`. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `trait` / `impl` — `GrpcHook`, codec helpers, and trailer status mapping +`hyperlane-plugin-grpc` brings gRPC over HTTP/2 wire framing, service method routing, deadline parsing, and interceptor hooks to [`hyperlane`](../../README.md) servers (hook order `-65`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,18 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-grpc ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_grpc::{GrpcConfig, GrpcPlugin, GrpcRouter}; + +fn setup_grpc() { + let router: GrpcRouter = GrpcRouter::default(); + GrpcPlugin::init(GrpcConfig::default(), router); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +47,6 @@ cargo clippy -p hyperlane-plugin-grpc --all-features --all-targets -- -D warning cargo test -p hyperlane-plugin-grpc --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/health/AGENTS.md b/plugin/health/AGENTS.md deleted file mode 100644 index b1ad9f9e..00000000 --- a/plugin/health/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-health` - -Concise engineering and iteration guidelines for `hyperlane-plugin-health` (`plugin/health/`). -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**: `/healthz`, `/livez`, and `/readyz` Kubernetes/orchestrator probes with concurrent async `HealthCheck` execution, per-probe timeouts, snapshot TTL caching, lock-free drain flag, and `HealthHook`. -- **Dependencies**: Internal `hyperlane`; external `serde`, `serde_json`, `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait,type}.rs` (`HEALTH_PLUGIN` and join/wire helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `HealthHook` (`#[hyperlane::request_middleware(-110)]`) runs BEFORE `MaintenanceHook` (`-109`) and `RateLimitHook` (`-95`) so probes survive maintenance/throttling; stay transparent (`Status::Continue`) when unconfigured and send wire bytes before `Status::Reject` on matched probe paths. -- **Liveness vs. draining separation**: `/livez` MUST always return `200 OK` (reporting `"draining":true` when draining) without executing dependency checks; `/readyz` and `/healthz` immediately short-circuit to `503` while draining; `mark_draining()`/`clear_draining()` MUST invalidate the snapshot cache. -- **Concurrent panic-isolated probes**: `HealthChecksJoin` catches panics around both `check.check()` and every `poll(cx)` (`Down`, preserving probe registration order), allocates timers lazily only on `Poll::Pending`, and enforces `check_timeout_ms.max(1)`. -- **Aggregation & wire fast path**: Aggregate strictly as `Down > Degraded > Up` (only `Down` maps to `503`), always emit `Cache-Control: no-store`, restrict prebuilt HTTP/1.1 wire fast paths to `!is_head && HTTP/1.1 && empty headers`, and still set response status on `Context` for downstream metrics/logging. - -## 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/health/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-health --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-health --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/health/README.md b/plugin/health/README.md index 78938906..10a95c86 100644 --- a/plugin/health/README.md +++ b/plugin/health/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-health logo + # hyperlane-plugin-health -**Liveness & Readiness Health Probe Plugin** +**Kubernetes Liveness, Readiness & Startup Health Probe Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-health)](https://crates.io/crates/hyperlane-plugin-health) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-health?style=flat-square)](https://docs.rs/hyperlane-plugin-health) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-health)](https://crates.io/crates/hyperlane-plugin-health) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-health?style=flat-square)](https://docs.rs/hyperlane-plugin-health) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-health/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-health/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in `/healthz` and `/readyz` probe middleware aggregating pluggable async dependency checks with structured JSON status replies. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `trait` / `impl` — `HealthCheck` trait, probe registry, and `HealthHook` +`hyperlane-plugin-health` serves `/healthz`, `/livez`, and `/readyz` probe endpoints with concurrent async dependency checks and graceful drain signaling for [`hyperlane`](../../README.md) services (hook order `-110`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,18 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-health ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_health::{HealthConfig, HealthPlugin, HealthRegistry}; + +fn setup_health() { + let registry: HealthRegistry = HealthRegistry::default(); + HealthPlugin::init(HealthConfig::default(), registry); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +47,6 @@ cargo clippy -p hyperlane-plugin-health --all-features --all-targets -- -D warni cargo test -p hyperlane-plugin-health --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/idempotency/AGENTS.md b/plugin/idempotency/AGENTS.md deleted file mode 100644 index c62da601..00000000 --- a/plugin/idempotency/AGENTS.md +++ /dev/null @@ -1,33 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-idempotency` - -Concise engineering and iteration guidelines for `hyperlane-plugin-idempotency` (`plugin/idempotency/`). -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**: HTTP `Idempotency-Key` middleware with 64-bit request payload fingerprinting, 64-shard bounded `InMemoryIdempotencyStore` + pluggable async `IdempotencyStore`, in-flight conflict guarding, and zero-copy replay. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait,type}.rs` (`IDEMPOTENCY_PLUGIN` and internal wire/shard helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `IdempotencyRequestHook` (`#[hyperlane::request_middleware(-78)]`, sends `400`/`409`/`422`/replayed bytes before `Status::Reject`) and `IdempotencyResponseHook` (`#[hyperlane::response_middleware(-60)]`, after `ProblemDetailsHook` `-62`, always `Status::Continue`) MUST remain transparent when unconfigured. -- **Scoped key & strict validation**: Namespace keys as `"{METHOD}|{path}|{trimmed_key}"`, validate non-empty printable ASCII (`0x20..0x7F`, `<= max_key_len`), and reject missing/invalid keys on segment-bounded `require_key_prefixes` with prebuilt `400`. -- **Fingerprint & conflict semantics**: Same key + mismatched fingerprint MUST return `422` (even while `InFlight`), same key + matching fingerprint while `InFlight` MUST return `409` + `Retry-After: 1`, and completed matches emit `idempotent-replayed: true`. -- **Leak-proof RAII `InFlight` cleanup**: `IdempotencyInFlightGuard::drop` releases unsettled slots via `store.release_on_drop` on early exit/panic; `release_sync` MUST only remove `InFlight` entries and never evict `Completed` entries. -- **Safe caching & wire fallback**: Do not cache `5xx` unless `cache_server_errors == true`, release slots when body exceeds `max_body_bytes` or `max_bytes`, and fall back from prebuilt wire to `Response::build()` on unsafe headers, `Content-Encoding`/`Transfer-Encoding`, or `text/event-stream`. - -## 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/idempotency/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-idempotency --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-idempotency --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/idempotency/README.md b/plugin/idempotency/README.md index 38322877..34f17c53 100644 --- a/plugin/idempotency/README.md +++ b/plugin/idempotency/README.md @@ -1,11 +1,14 @@
+hyperlane-plugin-idempotency logo + # hyperlane-plugin-idempotency **HTTP `Idempotency-Key` Replay & Concurrent Duplicate Guard Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-idempotency)](https://crates.io/crates/hyperlane-plugin-idempotency) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-idempotency?style=flat-square)](https://docs.rs/hyperlane-plugin-idempotency) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-idempotency)](https://crates.io/crates/hyperlane-plugin-idempotency) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-idempotency?style=flat-square)](https://docs.rs/hyperlane-plugin-idempotency) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) @@ -17,14 +20,7 @@ ## Overview -Opt-in request (`-78`) and response (`-60`) middleware enforcing `Idempotency-Key` semantics for HTTP mutation methods (`POST`/`PUT`/`PATCH`/`DELETE`): single-pass `XxHash3_64` `(method, path, body)` request fingerprinting (`422 Unprocessable Entity` on payload mismatch), 64-way sharded bounded `InMemoryIdempotencyStore` plus pluggable async `IdempotencyStore` trait, atomic `InFlight` duplicate locking (`409 Conflict`) with RAII panic/drop cleanup, and zero-copy prebuilt response replay stamped with `Idempotent-Replayed: true`. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `enum` / `trait` / `impl` — `IdempotencyConfig`, `IdempotencyStore`, `InMemoryIdempotencyStore`, `StoredIdempotentResponse`, `IdempotencyPlugin`, `IdempotencyRequestHook` (`-78`), and `IdempotencyResponseHook` (`-60`) -- `fn` — Zero-allocation `XxHash3_64` request fingerprinting, shard hashing, and wire replay construction +`hyperlane-plugin-idempotency` guards mutating [`hyperlane`](../../README.md) endpoints against duplicate retries using `Idempotency-Key` payload fingerprinting, in-flight locking, and response replay (hook order `-78` / `-60`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -32,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-idempotency ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_idempotency::{IdempotencyConfig, IdempotencyPlugin}; + +fn setup_idempotency() { + IdempotencyPlugin::init(IdempotencyConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -42,10 +46,6 @@ cargo clippy -p hyperlane-plugin-idempotency --all-features --all-targets -- -D cargo test -p hyperlane-plugin-idempotency --all-features ``` -## Documentation & Governance - -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/ip_filter/AGENTS.md b/plugin/ip_filter/AGENTS.md deleted file mode 100644 index f40ba316..00000000 --- a/plugin/ip_filter/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-ip-filter` - -Concise engineering and iteration guidelines for `hyperlane-plugin-ip-filter` (`plugin/ip_filter/`). -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**: Anti-spoofing right-to-left trusted-proxy IP extraction (`X-Forwarded-For`, RFC 7239 `Forwarded`, `X-Real-IP`), `ClientIp` `Context` injection, `/8` CSR radix IPv4/IPv6 CIDR filtering, and prebuilt `403` rejection. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct}.rs` (`IP_FILTER_PLUGIN` and internal parsers/radix helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `IpFilterHook` (`#[hyperlane::request_middleware(-125)]`, immediately after `TracingRequestHook` `-130`) MUST stay transparent (`Status::Continue`) when unconfigured, inject `ATTR_CLIENT_IP` before exempt checks, and flush prebuilt `403` bytes before returning `Status::Reject` on denial. -- **Anti-spoofing proxy peeling**: Ignore ALL forwarding headers unless the direct `peer_ip` matches `trusted_proxies`; peel `X-Forwarded-For` / `Forwarded` strictly right-to-left capped by `max_trusted_hops.max(1)`, stopping at the first untrusted or invalid token to block forged leftmost entries. -- **IPv4-mapped IPv6 canonicalization**: Always canonicalize `::ffff:a.b.c.d` (and `::ffff:0:0/96` prefixes `>= /96`) to `IpAddr::V4` so IPv4 rules cannot be bypassed via mapped IPv6 addresses. -- **Denylist precedence & strict IPv4 parsing**: Denylist ALWAYS overrides allowlist, missing `peer_ip` fails closed when `!allowlist.is_empty()`, and `parse_ipv4_or_port_fast` MUST reject leading zeros (`"01"`) to prevent octal-IP spoofing. - -## 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/ip_filter/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-ip-filter --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-ip-filter --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/ip_filter/README.md b/plugin/ip_filter/README.md index 2baa59b9..beeacf3a 100644 --- a/plugin/ip_filter/README.md +++ b/plugin/ip_filter/README.md @@ -1,11 +1,14 @@
+hyperlane-plugin-ip-filter logo + # hyperlane-plugin-ip-filter -**Zero-Allocation Client IP Extraction & Radix CIDR Allowlist/Denylist Plugin** +**Anti-Spoofing Client IP Extraction & Radix CIDR Allowlist/Denylist Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-ip-filter)](https://crates.io/crates/hyperlane-plugin-ip-filter) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-ip-filter?style=flat-square)](https://docs.rs/hyperlane-plugin-ip-filter) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-ip-filter)](https://crates.io/crates/hyperlane-plugin-ip-filter) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-ip-filter?style=flat-square)](https://docs.rs/hyperlane-plugin-ip-filter) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) @@ -17,14 +20,7 @@ ## Overview -Opt-in request middleware (order `-125`) resolving the true client IP from `Stream::get_peer_addr` with anti-spoofing right-to-left hop peeling across trusted proxies (`X-Forwarded-For`, RFC 7239 `Forwarded`, and `X-Real-IP`), injecting `ClientIp` into Hyperlane `Context` (`ATTR_CLIENT_IP`), and enforcing zero-allocation `/8` radix-indexed IPv4/IPv6 CIDR allowlists and denylists with IPv4-mapped IPv6 canonicalization (`::ffff:a.b.c.d`) and prebuilt rejection wire responses. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `enum` / `impl` — `IpNet`, `CidrTable`, `ClientIp`, `IpFilterConfig`, `CompiledIpFilter`, `IpFilterPlugin`, and `IpFilterHook` (`-125`) -- `fn` — Zero-allocation right-to-left proxy peeling, IPv4-mapped IPv6 canonicalization, and RFC 7239 `Forwarded` parsing +`hyperlane-plugin-ip-filter` extracts verified client IPs behind trusted proxies and enforces zero-allocation IPv4/IPv6 CIDR allowlists and denylists for [`hyperlane`](../../README.md) services (hook order `-125`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -32,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-ip-filter ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_ip_filter::{IpFilterConfig, IpFilterPlugin}; + +fn setup_ip_filter() { + IpFilterPlugin::init(IpFilterConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -42,10 +46,6 @@ cargo clippy -p hyperlane-plugin-ip-filter --all-features --all-targets -- -D wa cargo test -p hyperlane-plugin-ip-filter --all-features ``` -## Documentation & Governance - -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/logger/AGENTS.md b/plugin/logger/AGENTS.md deleted file mode 100644 index 50f38871..00000000 --- a/plugin/logger/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-logger` - -Concise engineering and iteration guidelines for `hyperlane-plugin-logger` (`plugin/logger/`). -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**: Non-blocking buffered console/file logger (`LoggerPlugin`, `LoggerConfig`, `LogFormat::Plain`/`Json`, `LogSink`) implementing `log::Log` with `RequestLogger`/`ResponseLogger` hooks. -- **Dependencies**: Internal `hyperlane`; external `log`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait}.rs` (`CONFIG`, `WRITER_TX`, `DROPPED_RECORDS`, and SWAR sanitizers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `RequestLogger` (`#[hyperlane::request_middleware(-120)]`) and `ResponseLogger` (`#[hyperlane::response_middleware(100)]`, outermost response hook) MUST short-circuit with zero timing/formatting cost and return `Status::Continue` when `CONFIG` is unset or `!log_enabled!(Level::Info)`. -- **Log-forging & JSON escaping sanitization**: Escape `\r`, `\n`, `0x1b`, and control characters in plain logs (plus `"`/`\`/`\t` in JSON logs) via SWAR fast-path scanners to prevent CRLF log forging, ANSI escape injection, and broken JSON lines. -- **Non-blocking bounded writer**: Enqueue file writes via bounded `try_send` (`sync_channel`) to the background `"hyperlane-logger"` writer thread so request threads never block on disk I/O, tracking drops in `DROPPED_RECORDS` and preserving synchronous `Log::flush` ack barriers. -- **Ordered global initialization**: Install `log::set_logger(&LoggerPlugin)` BEFORE storing `WRITER_TX`/`CONFIG` and call `set_max_level` last, failing cleanly on duplicate init or foreign loggers. - -## 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/logger/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-logger --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-logger --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/logger/README.md b/plugin/logger/README.md index 3338482a..91b5bd75 100644 --- a/plugin/logger/README.md +++ b/plugin/logger/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-logger logo + # hyperlane-plugin-logger -**Sanitized Console & File Logger Plugin** +**Non-Blocking Buffered Console & File Request/Response Logger Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-logger)](https://crates.io/crates/hyperlane-plugin-logger) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-logger?style=flat-square)](https://docs.rs/hyperlane-plugin-logger) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-logger)](https://crates.io/crates/hyperlane-plugin-logger) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-logger?style=flat-square)](https://docs.rs/hyperlane-plugin-logger) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-logger/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-logger/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in structured request and application logger with CRLF/ANSI injection sanitization and configurable output sinks. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `enum` / `trait` / `impl` — Sanitized log formatters, file/console sinks, and lifecycle hooks +`hyperlane-plugin-logger` provides non-blocking, sanitized request and response access logging to console, rotating files, or custom sinks for [`hyperlane`](../../README.md) applications (hook order `-120` / `100`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-logger ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_logger::{LoggerConfig, LoggerPlugin}; + +fn setup_logger() -> Result<(), String> { + LoggerPlugin::init(LoggerConfig::default()) +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-logger --all-features --all-targets -- -D warni cargo test -p hyperlane-plugin-logger --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/maintenance/AGENTS.md b/plugin/maintenance/AGENTS.md deleted file mode 100644 index ab557cd4..00000000 --- a/plugin/maintenance/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-maintenance` - -Concise engineering and iteration guidelines for `hyperlane-plugin-maintenance` (`plugin/maintenance/`). -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**: Lock-free atomic live `Active`/`ReadOnly`/`Maintenance` traffic gate with path/prefix exemptions, constant-time bypass tokens, prebuilt `503` wire responses, and `MaintenanceHook`. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct}.rs` (`MAINTENANCE_PLUGIN` and comparison/prefix helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `MaintenanceHook` (`#[hyperlane::request_middleware(-109)]`) MUST run right AFTER `HealthHook` (`-110`) so probes remain reachable during maintenance; stay transparent (`Status::Continue`) when unconfigured and flush prebuilt `503` wire bytes before returning `Status::Reject`. -- **Single-atomic `Active` fast path**: Store live `MaintenanceMode` in `AtomicU8` (`Acquire`/`Release`) so `Active` traffic incurs zero locks and zero heap allocations while allowing instant runtime mode switches. -- **Safe-method `ReadOnly` & segment-bounded exemptions**: In `ReadOnly`, allow only `GET`/`HEAD`/`OPTIONS` unless matched by exact exempt path, segment-bounded exempt prefix, or valid bypass token. -- **Constant-time bypass token verification**: Compare the trimmed bypass header value against ALL configured non-empty tokens without early exit (`#[inline(never)]` + `black_box`) to avoid secret-byte and token-position timing leaks. - -## 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/maintenance/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-maintenance --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-maintenance --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/maintenance/README.md b/plugin/maintenance/README.md index 39905b40..e10d18b1 100644 --- a/plugin/maintenance/README.md +++ b/plugin/maintenance/README.md @@ -1,25 +1,55 @@ +
+ +hyperlane-plugin-maintenance logo + # hyperlane-plugin-maintenance -Lock-free atomic maintenance and read-only mode middleware for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**Lock-Free Live Maintenance & Read-Only Mode Gate Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-maintenance)](https://crates.io/crates/hyperlane-plugin-maintenance) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-maintenance?style=flat-square)](https://docs.rs/hyperlane-plugin-maintenance) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-maintenance/latest/) -## Features +
-- Single atomic load on the `Active` fast path (zero allocations, zero locks). -- Instant zero-restart live transitions between `Active`, `ReadOnly` (blocks non-safe HTTP methods), and `Maintenance`. -- Exact path exemptions, segment-bounded prefix exemptions, and constant-time secret header token bypasses. -- Prebuilt `503 Service Unavailable` wire buffers with configurable `Retry-After` and JSON/text payloads. -- Transparent (`Status::Continue`) when unconfigured (`#[hyperlane::request_middleware(-109)]`). +--- -## Quick Start +## Overview + +`hyperlane-plugin-maintenance` enables zero-restart live switching between `Active`, `ReadOnly`, and `Maintenance` traffic modes for [`hyperlane`](../../README.md) servers (hook order `-109`). It is opt-in and transparent (`Status::Continue`) when unconfigured. + +## Installation + +```sh +cargo add hyperlane-plugin-maintenance +``` + +## Usage ```rust -use hyperlane_plugin_maintenance::{MaintenanceConfig, MaintenanceMode, MaintenancePlugin}; +use hyperlane_plugin_maintenance::{MaintenanceConfig, MaintenancePlugin}; + +fn setup_maintenance() { + MaintenancePlugin::init(MaintenanceConfig::default()); +} +``` -let plugin = MaintenancePlugin::init( - MaintenanceConfig::default() - .with_exempt_paths(["/healthz", "/readyz"]) - .with_bypass_tokens("X-Maintenance-Bypass", ["ops-secret"]), -); +## Verification -plugin.set_mode(MaintenanceMode::ReadOnly); +```sh +cargo run -p hyperlane-cli -- fmt --check +cargo clippy -p hyperlane-plugin-maintenance --all-features --all-targets -- -D warnings +cargo test -p hyperlane-plugin-maintenance --all-features ``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. + +## Contact + +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/mcp/AGENTS.md b/plugin/mcp/AGENTS.md deleted file mode 100644 index 41ad3727..00000000 --- a/plugin/mcp/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-mcp` - -Concise engineering and iteration guidelines for `hyperlane-plugin-mcp` (`plugin/mcp/`). -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**: Streamable HTTP Model Context Protocol (`2025-03-26`) server with `XxHash3_64` tool/resource/prompt registries (`McpRegistry`), 16-shard bounded TTL sessions, `Origin` DNS-rebinding guard, and `McpHook`. -- **Dependencies**: Internal `hyperlane`; external `serde`, `serde_json`, `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,type}.rs` (`MCP_PLUGIN` and JSON visitor/session internals stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `McpHook` (`#[hyperlane::request_middleware(-60)]`) MUST return `Status::Continue` when unconfigured or when `path != endpoint`, and flush response bytes before returning `Status::Reject` on the MCP endpoint. -- **Streamable HTTP security & method guards**: Reject disallowed `Origin` headers with `403` when `allowed_origins` is non-empty (case-insensitive; absent `Origin` allowed for non-browser clients), allow only `POST`/`DELETE` (`405` otherwise), enforce `max_body_size` (`413`), and map `DELETE` to `close_session` (`204`/`404`). -- **Correlation-ID-preserving JSON-RPC parsing**: Keep single-pass `McpRpcRequestVisitor` draining non-string `name`/`uri` fields as `None` so `-32602 Invalid params` echoes the original `"id"`, and return `202 Accepted` for notifications. -- **16-shard bounded high-entropy sessions & list cache invalidation**: Enforce `max_sessions` via CAS after expired purges (returning `503`/`-32603` when saturated), return `404` on unknown/expired `Mcp-Session-Id` for non-`initialize` calls, and replace `tools_list_cache`/`resources_list_cache`/`prompts_list_cache` on every `register_*` mutation. - -## 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/mcp/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-mcp --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-mcp --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/mcp/README.md b/plugin/mcp/README.md index eb236057..de2c164d 100644 --- a/plugin/mcp/README.md +++ b/plugin/mcp/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-mcp logo + # hyperlane-plugin-mcp -**Model Context Protocol (MCP) Server Plugin** +**Streamable HTTP Model Context Protocol (MCP) Server Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-mcp)](https://crates.io/crates/hyperlane-plugin-mcp) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-mcp?style=flat-square)](https://docs.rs/hyperlane-plugin-mcp) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-mcp)](https://crates.io/crates/hyperlane-plugin-mcp) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-mcp?style=flat-square)](https://docs.rs/hyperlane-plugin-mcp) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-mcp/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-mcp/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in Streamable HTTP Model Context Protocol server with tools/resources/prompts registries, `Mcp-Session-Id` management, and `Origin` DNS-rebinding protection. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `fn` / `impl` — `McpHook`, JSON-RPC session handling, and tool/resource/prompt registries +`hyperlane-plugin-mcp` embeds a Streamable HTTP Model Context Protocol (MCP) server directly into [`hyperlane`](../../README.md) services (hook order `-60`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,18 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-mcp ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_mcp::{McpPlugin, McpRegistry, McpServerConfig}; + +fn setup_mcp() { + let registry: McpRegistry = McpRegistry::default(); + McpPlugin::init(McpServerConfig::default(), registry); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +47,6 @@ cargo clippy -p hyperlane-plugin-mcp --all-features --all-targets -- -D warnings cargo test -p hyperlane-plugin-mcp --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/metrics/AGENTS.md b/plugin/metrics/AGENTS.md deleted file mode 100644 index 447a4836..00000000 --- a/plugin/metrics/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-metrics` - -Concise engineering and iteration guidelines for `hyperlane-plugin-metrics` (`plugin/metrics/`). -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**: Lock-free atomic `Counter`, `Gauge`, and latency `Histogram` metrics registry with Prometheus OpenMetrics 0.0.4 `/metrics` scrape endpoint and `MetricsRequestHook`/`MetricsResponseHook`. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,fn,impl,static,struct}.rs` (`METRICS_PLUGIN` and exposition formatting helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `MetricsRequestHook` (`#[hyperlane::request_middleware(-115)]`) and `MetricsResponseHook` (`#[hyperlane::response_middleware(95)]`) MUST stay transparent (`Status::Continue`) when unconfigured. -- **Self-scrape isolation & `in_flight` integrity**: Intercept `config.endpoint` BEFORE incrementing `in_flight` or setting `ATTR_METRICS_STARTED_AT`, returning `Status::Reject` after sending `200` (`Cache-Control: no-store`, empty body on `HEAD`) or `401`; record completion in `MetricsResponseHook` ONLY when `ATTR_METRICS_STARTED_AT` exists so scrapes never skew totals or underflow `in_flight`. -- **Lock-free observation & finite histogram bounds**: Keep `Counter`/`Gauge`/`Histogram` observations completely lock-free (IEEE-754 CAS `atomic_f64_add`); filter non-finite bounds in `Histogram::new` and ignore non-finite samples in `observe`. -- **Constant-time scrape auth & lock-skipping render**: Verify optional `Authorization: Bearer ` via `constant_time_eq`, and preserve `Acquire`/`Release` `custom_*_count` fast checks so `render_prometheus` skips custom `RwLock` acquisitions when empty. - -## 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/metrics/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-metrics --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-metrics --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/metrics/README.md b/plugin/metrics/README.md index c3750afe..141e2373 100644 --- a/plugin/metrics/README.md +++ b/plugin/metrics/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-metrics logo + # hyperlane-plugin-metrics -**Prometheus & Runtime Metrics Plugin** +**Lock-Free Atomic Prometheus & OpenMetrics Observability Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-metrics)](https://crates.io/crates/hyperlane-plugin-metrics) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-metrics?style=flat-square)](https://docs.rs/hyperlane-plugin-metrics) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-metrics)](https://crates.io/crates/hyperlane-plugin-metrics) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-metrics?style=flat-square)](https://docs.rs/hyperlane-plugin-metrics) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-metrics/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-metrics/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in HTTP request counters, latency histograms, in-flight gauges, and Prometheus text-format scrape endpoint hook. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `trait` / `impl` — Lock-free metric collectors and scrape handler +`hyperlane-plugin-metrics` instruments [`hyperlane`](../../README.md) servers with lock-free atomic HTTP request counters, in-flight gauges, latency histograms, and a Prometheus OpenMetrics `/metrics` scrape endpoint (hook order `-115` / `95`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-metrics ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_metrics::{MetricsConfig, MetricsPlugin}; + +fn setup_metrics() { + MetricsPlugin::init(MetricsConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-metrics --all-features --all-targets -- -D warn cargo test -p hyperlane-plugin-metrics --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/mq/AGENTS.md b/plugin/mq/AGENTS.md deleted file mode 100644 index fdd20892..00000000 --- a/plugin/mq/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-mq` - -Concise engineering and iteration guidelines for `hyperlane-plugin-mq` (`plugin/mq/`). -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**: Pluggable async `MessageBroker` trait and 64-shard `InMemoryBroker` with consumer groups, visibility timeouts, retries, TTL expiration, and dead-letter queues (`.dlq`). -- **Dependencies**: External `lombok-macros` only (`tokio` in `[dev-dependencies]`). Keep this crate decoupled from `hyperlane` HTTP core. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait,type}.rs` (`MQ_PLUGIN` and sharding/topic broker internals stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Broker service model**: Register NO `ServerHook` HTTP middleware; expose process-wide `MqPlugin::{init, init_with_broker, get}` alongside standalone `InMemoryBroker::new`. -- **Packed `receipt_id` & lock-free topic routing**: Keep `receipt_id` packing `topic_id` (upper 24 bits) + monotonic `seq` (lower 40 bits) so `ack`/`nack` locate `TopicBroker` in O(1) without a global receipt table. -- **All-or-nothing fan-out backpressure**: Verify `queue.len() < max_len` across ALL subscribed consumer groups before enqueuing to any group (`MqError::QueueFull` must never leave partial fan-out) and share one `Arc` across `>= 2` groups. -- **Visibility deadline compaction & TTL vs. DLQ semantics**: Compact settled monotonic deadlines whenever `deadlines.len() > total_in_flight * 2 + 64` so pinned deliveries cannot leak memory; drop TTL-expired messages silently (never dead-letter), requeue lease timeouts to the front, explicit `nack(_, true)` to the back, and route exhausted retries or `nack(_, false)` to DLQ. - -## 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/mq/README.md` (and `plugin/README.md` / root `README.md` if public surface changes) in the same commit. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p hyperlane-plugin-mq --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-mq --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/mq/README.md b/plugin/mq/README.md index 27fc36ae..7326d268 100644 --- a/plugin/mq/README.md +++ b/plugin/mq/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-mq logo + # hyperlane-plugin-mq -**Async Message Queue & Broker Plugin** +**Async Message Queue & Sharded In-Memory Broker Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-mq)](https://crates.io/crates/hyperlane-plugin-mq) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-mq?style=flat-square)](https://docs.rs/hyperlane-plugin-mq) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-mq)](https://crates.io/crates/hyperlane-plugin-mq) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-mq?style=flat-square)](https://docs.rs/hyperlane-plugin-mq) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-mq/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-mq/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in async `MessageBroker` trait and `InMemoryBroker` with consumer groups, message TTL, visibility timeouts, bounded retries, and dead-letter queues (DLQ). - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `fn` / `impl` — Broker abstraction, consumer group scheduling, and DLQ tracking +`hyperlane-plugin-mq` supplies an asynchronous `MessageBroker` abstraction and a 64-shard `InMemoryBroker` with consumer groups, visibility timeouts, retries, and dead-letter queues for [`hyperlane`](../../README.md) services. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-mq ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_mq::{MqConfig, MqPlugin}; + +fn setup_mq() { + MqPlugin::init(MqConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-mq --all-features --all-targets -- -D warnings cargo test -p hyperlane-plugin-mq --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/multipart/AGENTS.md b/plugin/multipart/AGENTS.md deleted file mode 100644 index 053814cb..00000000 --- a/plugin/multipart/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-multipart` - -Concise engineering and iteration guidelines for `hyperlane-plugin-multipart` (`plugin/multipart/`). -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**: Bounded RFC 7578 `multipart/form-data` parser (`MultipartPlugin`, `ParsedMultipart`, `UploadedFile`), traversal-proof filename sanitization, magic-byte MIME sniffing, and `MultipartHook`. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct}.rs` (`MULTIPART_PLUGIN` and framing helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `MultipartHook` (`#[hyperlane::request_middleware(-76)]`) MUST return `Status::Continue` with zero allocations when unconfigured or when `Content-Type` is not `multipart/form-data`, and flush prebuilt `400`/`413`/`415` wire bytes before `Status::Reject` on parse/policy errors. -- **Pre-parse resource caps**: Check `max_total_bytes` BEFORE boundary scanning, then enforce `max_parts`, `max_files`, `max_file_bytes`, and `max_field_bytes` (`0` disables a cap), mapping limits to `413`, `DisallowedMime` to `415`, and framing errors to `400`. -- **Traversal-proof filename sanitization**: `sanitize_filename` strips directory prefixes (`/` and `\`), control chars, `:`, and `\0`, trims leading/trailing `.` (blocking `.`/`..`/dotfiles), caps length to 128 chars, and falls back to `"upload"`. -- **Magic-byte sniffing & RFC 7578 strictness**: When `sniff_mime` is enabled, override client-declared `Content-Type` with magic-byte detection (`PNG`/`JPEG`/`GIF`/`WEBP`/`PDF`/`ZIP`/`GZIP`) BEFORE `allowed_mime_prefixes` checks; reject empty/`> 70`-byte boundaries, missing `name`, missing `\r\n\r\n`, missing closing `--boundary--`, and non-UTF-8 text fields. - -## 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/multipart/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-multipart --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-multipart --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/multipart/README.md b/plugin/multipart/README.md index ca225d70..d24e55ea 100644 --- a/plugin/multipart/README.md +++ b/plugin/multipart/README.md @@ -1,10 +1,55 @@ +
+ +hyperlane-plugin-multipart logo + # hyperlane-plugin-multipart -Bounded, traversal-proof RFC 7578 `multipart/form-data` upload parser and guard for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**Bounded Traversal-Proof RFC 7578 Multipart Upload Parser & Guard Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-multipart)](https://crates.io/crates/hyperlane-plugin-multipart) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-multipart?style=flat-square)](https://docs.rs/hyperlane-plugin-multipart) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-multipart/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-multipart` parses and validates RFC 7578 `multipart/form-data` file uploads with strict part limits, filename sanitization, and magic-byte MIME verification for [`hyperlane`](../../README.md) services (hook order `-76`). It is opt-in and transparent (`Status::Continue`) when unconfigured. + +## Installation + +```sh +cargo add hyperlane-plugin-multipart +``` + +## Usage + +```rust +use hyperlane_plugin_multipart::{MultipartConfig, MultipartPlugin}; + +fn setup_multipart() { + MultipartPlugin::init(MultipartConfig::default()); +} +``` + +## Verification + +```sh +cargo run -p hyperlane-cli -- fmt --check +cargo clippy -p hyperlane-plugin-multipart --all-features --all-targets -- -D warnings +cargo test -p hyperlane-plugin-multipart --all-features +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. -## Features +## Contact -- Enforces `max_total_bytes`, `max_parts`, `max_files`, `max_file_bytes`, and `max_field_bytes`. -- Strips directory traversal (`../`, `\`, control characters) from client-supplied filenames. -- Magic-byte MIME sniffing (`PNG`, `JPEG`, `GIF`, `WEBP`, `PDF`, `ZIP`, `GZIP`) with MIME allowlist enforcement. -- Stores validated `ParsedMultipart` in `Context`; zero-overhead bypass for non-multipart requests (`#[hyperlane::request_middleware(-76)]`). +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/negotiate/AGENTS.md b/plugin/negotiate/AGENTS.md deleted file mode 100644 index 199cb898..00000000 --- a/plugin/negotiate/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-negotiate` - -Concise engineering and iteration guidelines for `hyperlane-plugin-negotiate` (`plugin/negotiate/`). -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**: Explicit response middlewares for `Accept-Encoding` compression negotiation (`CompressMiddleware`) and conditional `304 Not Modified` ETag validation (`ConditionalMiddleware`, `EntityTag`). -- **Dependencies**: Internal `hyperlane`, `http-compress`; zero external dependencies. -- **Layout**: `src/{lib,const,fn,impl,static,struct}.rs` (`pub use struct`; `const`/`fn`/`static` stay `pub(crate)`); tests in `tests/negotiate/`. - -## Core Iteration Invariants - -- **Explicit manual registration only**: Do NOT attach `#[hyperlane::response_middleware]` auto-registration; callers opt in explicitly via `server.response_middleware::()` and `ConditionalMiddleware`. -- **No double-compression & RFC 9110 guards**: `CompressMiddleware` only marks `Content-Encoding` (never writes to stream); always skip bodyless statuses (`1xx`/`204`/`205`/`304`), bodies `< min_length`, existing `Content-Encoding`, `Cache-Control: no-transform`, and `text/event-stream`; extend `Vary` via `add_header` without duplicating `Accept-Encoding` or clobbering `*`. -- **Safe conditional `304` handling**: `ConditionalMiddleware` MUST act ONLY on `GET`/`HEAD` and `200..300` non-bodyless responses (never converting `4xx`/`5xx` to `304` on `If-None-Match: *`), preserve app-supplied `ETag`, clear body on `304`, and keep metadata headers intact. -- **Bit-exact XXH3 & RFC 9110 ETag/OWS parity**: Keep `xxhash3_64_oneshot` (including `aarch64` NEON path) bit-identical to streaming `http_compress::XxHash3_64`, validate strong ETags strictly, and trim only HTTP OWS (`SP`/`HTAB`) in fast `If-None-Match` matching. - -## 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/negotiate/README.md` (and `plugin/README.md` / root `README.md` if public surface changes) in the same commit. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p hyperlane-plugin-negotiate --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-negotiate --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/negotiate/README.md b/plugin/negotiate/README.md index 203bb23a..5946b692 100644 --- a/plugin/negotiate/README.md +++ b/plugin/negotiate/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-negotiate logo + # hyperlane-plugin-negotiate -**Content-Encoding & Conditional 304 Plugin** +**Explicit `Accept-Encoding` Compression & Conditional `304` Negotiation Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-negotiate)](https://crates.io/crates/hyperlane-plugin-negotiate) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-negotiate?style=flat-square)](https://docs.rs/hyperlane-plugin-negotiate) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-negotiate)](https://crates.io/crates/hyperlane-plugin-negotiate) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-negotiate?style=flat-square)](https://docs.rs/hyperlane-plugin-negotiate) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-negotiate/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-negotiate/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in `CompressMiddleware` (`Accept-Encoding` negotiation + `Vary`) and `ConditionalMiddleware` (strong `ETag` generation + `304 Not Modified`). - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `impl` — `CompressMiddleware`, `CompressConfig`, and `ConditionalMiddleware` +`hyperlane-plugin-negotiate` provides explicit response content-coding negotiation and conditional `304 Not Modified` entity-tag middleware for [`hyperlane`](../../README.md) applications. It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-negotiate ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_negotiate::{CompressConfig, CompressMiddleware}; + +fn setup_negotiate() -> Result<(), String> { + CompressMiddleware::init(CompressConfig::default()) +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-negotiate --all-features --all-targets -- -D wa cargo test -p hyperlane-plugin-negotiate --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/openapi/AGENTS.md b/plugin/openapi/AGENTS.md deleted file mode 100644 index 95865844..00000000 --- a/plugin/openapi/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# 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 . -``` diff --git a/plugin/openapi/README.md b/plugin/openapi/README.md index a822d53a..bc0161e8 100644 --- a/plugin/openapi/README.md +++ b/plugin/openapi/README.md @@ -1,10 +1,55 @@ +
+ +hyperlane-plugin-openapi logo + # hyperlane-plugin-openapi -OpenAPI 3.1.0 specification builder and zero-allocation interactive docs plugin for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**OpenAPI 3.1.0 Spec Builder & Zero-CDN Interactive API Docs Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-openapi)](https://crates.io/crates/hyperlane-plugin-openapi) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-openapi?style=flat-square)](https://docs.rs/hyperlane-plugin-openapi) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-openapi/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-openapi` builds OpenAPI 3.1.0 specifications programmatically and serves pre-serialized `/openapi.json` alongside a self-contained zero-CDN `/docs` HTML API explorer for [`hyperlane`](../../README.md) services (hook order `-52`). It is opt-in and transparent (`Status::Continue`) when unconfigured. + +## Installation + +```sh +cargo add hyperlane-plugin-openapi +``` + +## Usage + +```rust +use hyperlane_plugin_openapi::{OpenApiConfig, OpenApiPlugin}; + +fn setup_openapi() { + OpenApiPlugin::init(OpenApiConfig::default()); +} +``` + +## 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 +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. -## Features +## Contact -- Fluent OpenAPI 3.1.0 builder (`OpenApiSpec`, `OpenApiOperation`, `OpenApiParameter`, `OpenApiResponse`). -- Pre-serialized JSON wire response with strong `XxHash3_64` ETag and prebuilt `304 Not Modified` reply. -- Self-contained zero-CDN interactive HTML explorer served at `/docs`. -- Opt-in and transparent (`Status::Continue`) when unconfigured (`#[hyperlane::request_middleware(-52)]`). +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/problem_details/AGENTS.md b/plugin/problem_details/AGENTS.md deleted file mode 100644 index 7ce75e7b..00000000 --- a/plugin/problem_details/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-problem-details` - -Concise engineering and iteration guidelines for `hyperlane-plugin-problem-details` (`plugin/problem_details/`). -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**: RFC 9457 (`application/problem+json; charset=utf-8`) error response builder (`ProblemDetails`) and automatic `4xx`/`5xx` normalizer (`ProblemDetailsPlugin`, `ProblemDetailsHook`). -- **Dependencies**: Internal `hyperlane`; external `serde`, `serde_json`, `lombok-macros`. -- **Layout**: `src/{lib,const,fn,impl,static,struct}.rs` (`PROBLEM_DETAILS_PLUGIN` stays `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `ProblemDetailsHook` (`#[hyperlane::response_middleware(-62)]`) MUST run BEFORE `IdempotencyResponseHook` (`-60`), `MetricsResponseHook` (`95`), and `ResponseLogger` (`100`) and always return `Status::Continue` (transparent when unconfigured). -- **Zero-overhead `2xx`/`3xx` fast path & no clobbering**: Return `false` immediately when `!auto_normalize || status < 400`; for `>= 400`, never overwrite responses already carrying `application/problem+json` or any non-empty non-`text/plain` body. -- **Default `5xx` detail masking**: Redact raw plain-text details (`detail: None`) on `status >= 500` whenever `mask_server_error_details` is true (default) to prevent internal error leakage, while preserving trimmed UTF-8 `4xx` plain-text details. -- **RFC 9457 payload contract**: Emit `application/problem+json; charset=utf-8` with `type`, `title`, `status`, optional `detail`/`instance` (omitted when `None`), and deterministic `BTreeMap` `extensions`. - -## 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/problem_details/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-problem-details --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-problem-details --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/problem_details/README.md b/plugin/problem_details/README.md index 28fb5de4..da96e0d3 100644 --- a/plugin/problem_details/README.md +++ b/plugin/problem_details/README.md @@ -1,11 +1,55 @@ +
+ +hyperlane-plugin-problem-details logo + # hyperlane-plugin-problem-details -RFC 9457 (`application/problem+json`) error response builder and automatic normalizer for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**RFC 9457 (`application/problem+json`) Error Normalizer & Builder Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-problem-details)](https://crates.io/crates/hyperlane-plugin-problem-details) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-problem-details?style=flat-square)](https://docs.rs/hyperlane-plugin-problem-details) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-problem-details/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-problem-details` standardizes HTTP error responses as RFC 9457 `application/problem+json` payloads for [`hyperlane`](../../README.md) services (response hook order `-62`). It is opt-in and transparent (`Status::Continue`) when unconfigured. + +## Installation + +```sh +cargo add hyperlane-plugin-problem-details +``` + +## Usage + +```rust +use hyperlane_plugin_problem_details::{ProblemDetailsConfig, ProblemDetailsPlugin}; + +fn setup_problem_details() { + ProblemDetailsPlugin::init(ProblemDetailsConfig::default()); +} +``` + +## Verification + +```sh +cargo run -p hyperlane-cli -- fmt --check +cargo clippy -p hyperlane-plugin-problem-details --all-features --all-targets -- -D warnings +cargo test -p hyperlane-plugin-problem-details --all-features +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. -## Features +## Contact -- Zero-overhead single-comparison fast path on `2xx`/`3xx` responses. -- Automatically converts empty or plain-text `4xx`/`5xx` responses into RFC 9457 JSON with `type`, `title`, `status`, `detail`, and `instance`. -- Masks internal `5xx` error text by default to prevent sensitive error leakage. -- Fluent `ProblemDetails` builder with custom JSON extension fields. -- Opt-in and transparent (`Status::Continue`) when unconfigured (`#[hyperlane::response_middleware(-62)]`). +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/rate_limit/AGENTS.md b/plugin/rate_limit/AGENTS.md deleted file mode 100644 index 2a8cceaa..00000000 --- a/plugin/rate_limit/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-rate-limit` - -Concise engineering and iteration guidelines for `hyperlane-plugin-rate-limit` (`plugin/rate_limit/`). -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**: 64-way sharded lock-free atomic GCRA and fixed-window rate limiter (`ShardedRateLimiter`), bounded key store, pluggable `KeyExtractor`/`RateLimitStore`, RFC `RateLimit-*` headers, and `RateLimitHook`. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait,type}.rs` (`RATE_LIMIT_PLUGIN`, `FastDiv64`, and shard bucket internals stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `RateLimitHook` (`#[hyperlane::request_middleware(-95)]`) MUST stay transparent (`Status::Continue`) when unconfigured; attach RFC `ratelimit-{limit,remaining,reset}` headers when `include_headers` is true and send `429` + `Retry-After` (`>= 1`s) before `Status::Reject` on denial. -- **64-shard read-lock atomic hot path**: Keep existing keys on shard read-locks with lock-free CAS mutations (GCRA TAT in ns; packed `(window_id, count)` FixedWindow CAS with 2-word overflow fallback) and Granlund-Montgomery `FastDiv64`. -- **Active-debt eviction protection**: `is_entry_live` MUST retain entries with live quota debt (`primary > now_ns` for GCRA; `entry_win == current_win` for FixedWindow) plus `last_seen_step_ns` slack so `purge_expired()` and eviction never enable eviction-based rate-limit bypass. -- **Fail-closed `max_keys` & anti-spoofing default**: Fail closed (`429`) if `key_count >= max_keys` persists after expiry purges; default `RateLimitPlugin::init` uses `ClientIpKeyExtractor::new(false)` (never trusting spoofable `X-Forwarded-For` unless explicitly enabled) with a direct unboxed `fast_store` path. - -## 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/rate_limit/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-rate-limit --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-rate-limit --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/rate_limit/README.md b/plugin/rate_limit/README.md index 1feeec2d..d6cd70e4 100644 --- a/plugin/rate_limit/README.md +++ b/plugin/rate_limit/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-rate-limit logo + # hyperlane-plugin-rate-limit -**Token-Bucket & Sliding-Window Rate Limiter Plugin** +**64-Shard Lock-Free Atomic GCRA & Fixed-Window Rate Limiter Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-rate-limit)](https://crates.io/crates/hyperlane-plugin-rate-limit) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-rate-limit?style=flat-square)](https://docs.rs/hyperlane-plugin-rate-limit) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-rate-limit)](https://crates.io/crates/hyperlane-plugin-rate-limit) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-rate-limit?style=flat-square)](https://docs.rs/hyperlane-plugin-rate-limit) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-rate-limit/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-rate-limit/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in per-key HTTP rate limiting middleware returning RFC-compliant `429 Too Many Requests` and `Retry-After` headers. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `trait` / `impl` — Key extractors, bucket limiters, and `RateLimitHook` +`hyperlane-plugin-rate-limit` enforces high-concurrency per-client and per-route request quotas for [`hyperlane`](../../README.md) services (hook order `-95`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-rate-limit ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_rate_limit::{RateLimitPlugin, RateLimitPolicy}; + +fn setup_rate_limit() { + RateLimitPlugin::init(RateLimitPolicy::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-rate-limit --all-features --all-targets -- -D w cargo test -p hyperlane-plugin-rate-limit --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/rewrite/AGENTS.md b/plugin/rewrite/AGENTS.md deleted file mode 100644 index 23a8707a..00000000 --- a/plugin/rewrite/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-rewrite` - -Concise engineering and iteration guidelines for `hyperlane-plugin-rewrite` (`plugin/rewrite/`). -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**: Zero-allocation URL normalization, canonical HTTPS/host redirects, `O(1)` exact table rewrites, segment-bounded prefix rules, and compiled regex rewrites (`RewritePlugin`, `RewriteHook`). -- **Dependencies**: Internal `hyperlane`; external `regex`, `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,type}.rs` (`REWRITE_PLUGIN` and fast-regex/SWAR helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `RewriteHook` (`#[hyperlane::request_middleware(-102)]`) MUST return `Status::Continue` when unconfigured or after mutating `Request::path`, and flush wire bytes before returning `Status::Reject` on redirects. -- **Strict evaluation order & single-hop redirects**: Evaluate strictly as (1) canonical HTTPS/host redirect (combining scheme + host in 1 hop; honoring `X-Forwarded-Proto`/`Forwarded` only when `trust_forwarded_proto` is true), (2) slash normalization, (3) exact map, (4) longest segment-bounded prefix, (5) regex rules in order. -- **CRLF/NUL header safety**: Reject `\r`, `\n`, `\0` at compile time (`RewriteError::UnsafeLocation`) and re-validate dynamic redirect locations against RFC 9110 bytes before stack wire emission. -- **Attribute, query & fast-regex parity**: Preserve original path under `ATTR_ORIGINAL_PATH` on internal rewrites, preserve query strings on redirects unless target contains `?` or `preserve_query == false`, and keep `try_compile_fast_regex` strictly equivalent to full `Regex`. - -## 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/rewrite/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-rewrite --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-rewrite --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/rewrite/README.md b/plugin/rewrite/README.md index 4109b8da..c916672d 100644 --- a/plugin/rewrite/README.md +++ b/plugin/rewrite/README.md @@ -1,11 +1,14 @@
+hyperlane-plugin-rewrite logo + # hyperlane-plugin-rewrite -**High-Performance HTTP URL Rewrite & Redirect Middleware Plugin** +**Zero-Allocation HTTP URL Rewrite, Normalization & Redirect Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-rewrite)](https://crates.io/crates/hyperlane-plugin-rewrite) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-rewrite?style=flat-square)](https://docs.rs/hyperlane-plugin-rewrite) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-rewrite)](https://crates.io/crates/hyperlane-plugin-rewrite) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-rewrite?style=flat-square)](https://docs.rs/hyperlane-plugin-rewrite) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) @@ -17,14 +20,7 @@ ## Overview -Opt-in request middleware (order `-102`) providing canonical host & HTTPS upgrade redirects (`X-Forwarded-Proto` and RFC 7239 `Forwarded` aware), duplicate-slash collapsing, trailing-slash normalization (`Strip`/`Enforce`), `O(1)` `XxHash3_64` static exact redirect/rewrite tables, segment-bounded prefix strip/rewrite rules, and precompiled regex rules supporting both short-circuit HTTP redirects (`301`/`302`/`307`/`308`) and internal `Request::set_path` rewrites. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `enum` / `impl` — `RewriteConfig`, `RedirectStatus`, `RewriteAction`, `TrailingSlashMode`, `CompiledRewrite`, `RewritePlugin`, and `RewriteHook` (`-102`) -- `fn` — Zero-allocation duplicate-slash check, host/proto extraction, CRLF-safe `Location` assembly, and segment-boundary prefix matching +`hyperlane-plugin-rewrite` provides canonical host/HTTPS enforcement, trailing-slash normalization, and fast URL rewrites/redirects for [`hyperlane`](../../README.md) services (hook order `-102`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -32,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-rewrite ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_rewrite::{RewriteConfig, RewriteError, RewritePlugin}; + +fn setup_rewrite() -> Result<&'static RewritePlugin, RewriteError> { + RewritePlugin::init(RewriteConfig::default()) +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -42,10 +46,6 @@ cargo clippy -p hyperlane-plugin-rewrite --all-features --all-targets -- -D warn cargo test -p hyperlane-plugin-rewrite --all-features ``` -## Documentation & Governance - -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/rpc/AGENTS.md b/plugin/rpc/AGENTS.md deleted file mode 100644 index 11b48d59..00000000 --- a/plugin/rpc/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-rpc` - -Concise engineering and iteration guidelines for `hyperlane-plugin-rpc` (`plugin/rpc/`). -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**: JSON-RPC 2.0 `XxHash3_64` router (`RpcRouter`), zero-spawn concurrent batch/notification dispatch, payload/batch caps, `RpcInterceptor`, and `RpcHook`. -- **Dependencies**: Internal `hyperlane`; external `serde`, `serde_json`, `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait,type}.rs` (`RPC_PLUGIN`, cached error wires, and prepared-call internals stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `RpcHook` (`#[hyperlane::request_middleware(-70)]`) MUST return `Status::Continue` when unconfigured or when `path != endpoint`, and flush response wire bytes before returning `Status::Reject` on the RPC endpoint. -- **Transport & DoS caps before parsing**: Enforce `POST` (`405`), `body.len() <= max_body_size` (`413`) before JSON deserialization, and `batch.len() <= max_batch_size` (`-32600`) without invoking handlers. -- **JSON-RPC 2.0 & notification conformance**: Require `jsonrpc == "2.0"` and non-empty `method`, reject duplicate object keys, suppress responses for missing/`null` `id` notifications (HTTP `204 No Content` for single or all-notification batches), and distinguish `-32700` Parse Error vs `-32600` Invalid Request (including `[]`). -- **Interceptor order & zero-spawn batching**: Invoke `RpcInterceptor::before_call` after envelope validation and BEFORE method lookup; preserve input ordering across concurrent `poll_fn` batch futures. - -## 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/rpc/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-rpc --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-rpc --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/rpc/README.md b/plugin/rpc/README.md index 4f84dfbe..f04c1a41 100644 --- a/plugin/rpc/README.md +++ b/plugin/rpc/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-rpc logo + # hyperlane-plugin-rpc -**JSON-RPC 2.0 Server Plugin** +**JSON-RPC 2.0 Async Method Router & Concurrent Batch Server Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-rpc)](https://crates.io/crates/hyperlane-plugin-rpc) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-rpc?style=flat-square)](https://docs.rs/hyperlane-plugin-rpc) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-rpc)](https://crates.io/crates/hyperlane-plugin-rpc) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-rpc?style=flat-square)](https://docs.rs/hyperlane-plugin-rpc) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-rpc/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-rpc/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in JSON-RPC 2.0 method router supporting batch execution, notifications, strict payload/batch size caps, and `RpcHook`. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `trait` / `impl` — Method registry, batch dispatcher, and `RpcHook` +`hyperlane-plugin-rpc` adds a specification-compliant JSON-RPC 2.0 HTTP server with async method routing, batch dispatch, and DoS limits to [`hyperlane`](../../README.md) services (hook order `-70`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,18 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-rpc ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_rpc::{RpcConfig, RpcPlugin, RpcRouter}; + +fn setup_rpc() { + let router: RpcRouter = RpcRouter::default(); + RpcPlugin::init(RpcConfig::default(), router); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +47,6 @@ cargo clippy -p hyperlane-plugin-rpc --all-features --all-targets -- -D warnings cargo test -p hyperlane-plugin-rpc --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/scheduler/AGENTS.md b/plugin/scheduler/AGENTS.md deleted file mode 100644 index 96603755..00000000 --- a/plugin/scheduler/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-scheduler` - -Concise engineering and iteration guidelines for `hyperlane-plugin-scheduler` (`plugin/scheduler/`). -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**: Background async interval and 5-field UTC cron job scheduler (`Scheduler`, `SchedulerHandle`, `CronMask`, `JobHandler`, `JobMetrics`) with overlap protection and panic isolation. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,struct,trait}.rs` (no `static.rs`; internal runner helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Standalone background model**: Register NO `ServerHook` middleware or process-wide `OnceLock` singleton; tasks start explicitly via `Scheduler::start() -> SchedulerHandle` and drain cleanly on `SchedulerHandle::shutdown().await`. -- **Task panic isolation**: Execute every tick inside an inner `tokio::spawn` and await its `JoinHandle` so panicking jobs increment `metrics.panics` without killing the scheduler loop. -- **Lock-free overlap guard**: When `skip_if_running` is true, acquire `in_flight` via `compare_exchange(false, true, AcqRel, Acquire)` (incrementing `metrics.skipped` on contention) and unconditionally store `false` (`Release`) after completion, error, or panic. -- **UTC 5-field cron & interval validation**: Reject `Duration::ZERO` (`SchedulerError::ZeroInterval`), step `0`, out-of-range fields, and `start > end`; map weekday `7 -> 0` (Sunday); keep O(1) bitmask + Hinnant UTC matching and strictly future `:00`-aligned `next_unix_secs_after` search bounded to 1 leap year. - -## 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/scheduler/README.md` (and `plugin/README.md` / root `README.md` if public surface changes) in the same commit. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p hyperlane-plugin-scheduler --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-scheduler --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/scheduler/README.md b/plugin/scheduler/README.md index 1a1fdde9..20cccf27 100644 --- a/plugin/scheduler/README.md +++ b/plugin/scheduler/README.md @@ -1,10 +1,56 @@ +
+ +hyperlane-plugin-scheduler logo + # hyperlane-plugin-scheduler -Background async interval and 5-field cron job scheduler for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**Background Async Interval & 5-Field UTC Cron Job Scheduler Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-scheduler)](https://crates.io/crates/hyperlane-plugin-scheduler) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-scheduler?style=flat-square)](https://docs.rs/hyperlane-plugin-scheduler) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-scheduler/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-scheduler` runs reliable background async interval and 5-field UTC cron jobs inside [`hyperlane`](../../README.md) services with lock-free overlap protection, panic isolation, and graceful shutdown. + +## Installation + +```sh +cargo add hyperlane-plugin-scheduler +``` + +## Usage + +```rust +use hyperlane_plugin_scheduler::{Scheduler, SchedulerHandle}; + +fn start_scheduler() -> SchedulerHandle { + let scheduler: Scheduler = Scheduler::default(); + scheduler.start() +} +``` + +## Verification + +```sh +cargo run -p hyperlane-cli -- fmt --check +cargo clippy -p hyperlane-plugin-scheduler --all-features --all-targets -- -D warnings +cargo test -p hyperlane-plugin-scheduler --all-features +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. -## Features +## Contact -- Fixed-interval (`add_interval_job`) and 5-field UTC cron (`add_cron_job`, including `@hourly`/`@daily`/`@weekly`/`@monthly`) schedules. -- Lock-free `AtomicBool` overlap protection (`skip_if_running`). -- Isolated Tokio task execution so job panics never terminate the scheduler loop. -- Lock-free atomic `JobMetrics` counters (`runs`, `successes`, `failures`, `panics`, `skipped`) and graceful `shutdown().await`. +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/security/AGENTS.md b/plugin/security/AGENTS.md deleted file mode 100644 index 84b01270..00000000 --- a/plugin/security/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-security` - -Concise engineering and iteration guidelines for `hyperlane-plugin-security` (`plugin/security/`). -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**: Prebuilt security response headers (HSTS/CSP/COOP/COEP/CORP/Referrer), stateless HMAC-SHA256 CSRF protection, host/URI/body/traversal request guards, and pluggable `SecurityRule`. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros` (pure-Rust crypto, zero external crypto crates). -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait}.rs` (`SECURITY_PLUGIN` and internal crypto/header helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `SecurityRequestHook` (`#[hyperlane::request_middleware(-105)]`, flushes rejection bytes before `Status::Reject`) and `SecurityResponseHook` (`#[hyperlane::response_middleware(-75)]`, always `Status::Continue`) MUST stay transparent when unconfigured. -- **Header hardening before inspection**: Apply compiled RFC 9110-validated security headers BEFORE `inspect_request` so error replies are hardened too; never overwrite handler-supplied headers (`!contains_key`), and strip `X-Powered-By` when enabled. -- **Guard precedence & traversal coverage**: Enforce URI length (`414`) -> body length (`413`) -> `has_path_traversal` (`400`, catching `..`, percent-encoded `%2e`/`%2E`, `\`/`%5c`, and `\0`/`%00`) -> case-insensitive `Host` allowlist (`400`) -> CSRF (`403`) -> custom `SecurityRule`s. -- **Constant-time stateless CSRF**: Exempt safe methods (`GET`/`HEAD`/`OPTIONS`/`TRACE`) and exact `exempt_paths`; verify header/cookie token equality and `.<64-hex-mac>` via constant-time comparison and precomputed HMAC-SHA256 midstates with standard test vector coverage. - -## 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/security/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-security --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-security --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/security/README.md b/plugin/security/README.md index a28245a1..0f6d4bf5 100644 --- a/plugin/security/README.md +++ b/plugin/security/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-security logo + # hyperlane-plugin-security -**HTTP Security Headers & CSRF Guard Plugin** +**Zero-Allocation HTTP Security Headers, Stateless CSRF & Request Hardening Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-security)](https://crates.io/crates/hyperlane-plugin-security) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-security?style=flat-square)](https://docs.rs/hyperlane-plugin-security) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-security)](https://crates.io/crates/hyperlane-plugin-security) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-security?style=flat-square)](https://docs.rs/hyperlane-plugin-security) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-security/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-security/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in security middleware injecting CSP, HSTS, `X-Content-Type-Options`, `X-Frame-Options`, `Referrer-Policy`, and origin/CSRF protections. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `enum` / `trait` / `impl` — Security policy presets and response header hook +`hyperlane-plugin-security` hardens [`hyperlane`](../../README.md) applications with prebuilt browser security headers, stateless HMAC-SHA256 CSRF protection, and request-level traversal/host guards (hook order `-105` / `-75`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-security ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_security::{SecurityConfig, SecurityPlugin}; + +fn setup_security() { + SecurityPlugin::init(SecurityConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-security --all-features --all-targets -- -D war cargo test -p hyperlane-plugin-security --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/session/AGENTS.md b/plugin/session/AGENTS.md deleted file mode 100644 index 102b98bb..00000000 --- a/plugin/session/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-session` - -Concise engineering and iteration guidelines for `hyperlane-plugin-session` (`plugin/session/`). -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**: 64-shard bounded `InMemorySessionStore`, pluggable `SessionStore`, HMAC-SHA256 signed cookies, dirty-tracked `SessionHandle`, and `SessionRequestHook`/`SessionResponseHook`. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,fn,impl,static,struct,trait,type}.rs` (`SESSION_PLUGIN`, seed/seq statics, and `SessionFxHashMap` stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `SessionRequestHook` (`#[hyperlane::request_middleware(-85)]`) and `SessionResponseHook` (`#[hyperlane::response_middleware(-70)]`) MUST remain transparent (`Status::Continue`) when `SESSION_PLUGIN` is unconfigured. -- **Dirty-tracked zero-write reads**: Short-circuit `persist_from_context` via `SessionHandleInner::dirty` (`AtomicBool`) without locking `Mutex` on clean reads — zero store writes and no redundant `Set-Cookie`. -- **Session-fixation & cookie signing defense**: Never adopt unverified, tampered, unknown, or expired client session IDs (always mint a fresh 128-bit hex ID); on `regenerate_id()`, delete `previous_id` before saving the new ID; on `destroy()`, clear with `Max-Age=0`; verify HMAC-SHA256 signatures in constant time and reject invalid RFC 6265 cookie bytes. -- **Bounded 64-shard store & sync fast path**: Maintain 64 cache-line-aligned shards enforcing atomic `max_sessions` with lazy expiration and expired-entry purges; keep `fast_store` unboxed for in-memory sessions. - -## 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/session/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-session --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-session --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/session/README.md b/plugin/session/README.md index 0726c123..1e2e3616 100644 --- a/plugin/session/README.md +++ b/plugin/session/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-session logo + # hyperlane-plugin-session -**Signed Cookie & Pluggable Session Store Plugin** +**64-Shard Bounded Session Store & HMAC-SHA256 Signed Cookie Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-session)](https://crates.io/crates/hyperlane-plugin-session) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-session?style=flat-square)](https://docs.rs/hyperlane-plugin-session) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-session)](https://crates.io/crates/hyperlane-plugin-session) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-session?style=flat-square)](https://docs.rs/hyperlane-plugin-session) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-session/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-session/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in HTTP session management with signed/encrypted cookies, pluggable async stores, and automatic rotation/expiration. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `trait` / `impl` — `SessionStore` trait, cookie signer, and `SessionHook` +`hyperlane-plugin-session` provides high-concurrency session state management with optional HMAC-SHA256 signed cookies, dirty-tracked zero-write reads, and pluggable stores for [`hyperlane`](../../README.md) services (hook order `-85` / `-70`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-session ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_session::{SessionConfig, SessionPlugin}; + +fn setup_session() { + SessionPlugin::init(SessionConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-session --all-features --all-targets -- -D warn cargo test -p hyperlane-plugin-session --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/shutdown/AGENTS.md b/plugin/shutdown/AGENTS.md deleted file mode 100644 index 49969222..00000000 --- a/plugin/shutdown/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-shutdown` - -Concise engineering and iteration guidelines for `hyperlane-plugin-shutdown` (`plugin/shutdown/`). -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**: Graceful shutdown coordinator (`ShutdownCoordinator`, `ShutdownGuard`, `ShutdownCallback`, `ShutdownReport`) integrating `SIGINT`/`SIGTERM` arming with Hyperlane's `ServerControlHook`. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,fn,impl,static,struct,trait,type}.rs` (`SHUTDOWN_PLUGIN` and sharding helpers stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Control-hook lifecycle model**: Register NO request/response `ServerHook` middleware; wire shutdown via `arm_signals(control)` / `execute_shutdown(Some(control))` and explicit RAII `enter() -> Option`. -- **32-way packed atomic shards & race-free drain**: Keep 32 `#[repr(align(128))]` shards packing `SHUTDOWN_BIT` + in-flight count; `enter()` MUST roll back and wake `drained_notify` after `fence(SeqCst)` if `SHUTDOWN_BIT` is already set, `trigger()` MUST set `SHUTDOWN_BIT` on all shards before `shards_armed = true`, and drain MUST call `notified.enable()` + `fence(SeqCst)` before checking `in_flight() == 0`. -- **LIFO callbacks before server stop**: Drain up to `drain_timeout_ms`, run `ShutdownCallback`s in strict LIFO order with per-callback `callback_timeout_ms.max(1)` bounds, and invoke `control.shutdown().await` last. -- **Cross-platform signal parity**: Keep `SIGTERM` guarded for Unix targets while preserving `ctrl_c()` (`SIGINT`) and manual `trigger()` across all platforms. - -## 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/shutdown/README.md` (and `plugin/README.md` / root `README.md` if public surface changes) in the same commit. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p hyperlane-plugin-shutdown --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-shutdown --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/shutdown/README.md b/plugin/shutdown/README.md index 3660b5b3..03453395 100644 --- a/plugin/shutdown/README.md +++ b/plugin/shutdown/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-shutdown logo + # hyperlane-plugin-shutdown -**Graceful Shutdown & Connection Drain Plugin** +**Graceful Shutdown Coordinator, OS Signal Arming & Request Drain Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-shutdown)](https://crates.io/crates/hyperlane-plugin-shutdown) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-shutdown?style=flat-square)](https://docs.rs/hyperlane-plugin-shutdown) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-shutdown)](https://crates.io/crates/hyperlane-plugin-shutdown) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-shutdown?style=flat-square)](https://docs.rs/hyperlane-plugin-shutdown) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-shutdown/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-shutdown/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in OS signal listener and graceful drain coordinator rejecting new traffic while finishing in-flight requests within a bounded timeout. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `trait` / `impl` — Drain state machine, signal hooks, and shutdown callbacks +`hyperlane-plugin-shutdown` coordinates OS signal handling (`SIGINT`/`SIGTERM`), lock-free in-flight request draining, and ordered cleanup callbacks for [`hyperlane`](../../README.md) services. ## Installation @@ -31,9 +28,18 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-shutdown ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_shutdown::{ShutdownConfig, ShutdownCoordinator, ShutdownPlugin}; + +fn setup_shutdown() { + let coordinator: ShutdownCoordinator = ShutdownCoordinator::new(ShutdownConfig::default()); + ShutdownPlugin::init(coordinator); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +47,6 @@ cargo clippy -p hyperlane-plugin-shutdown --all-features --all-targets -- -D war cargo test -p hyperlane-plugin-shutdown --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/sse/AGENTS.md b/plugin/sse/AGENTS.md deleted file mode 100644 index d5df9ab4..00000000 --- a/plugin/sse/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-sse` - -Concise engineering and iteration guidelines for `hyperlane-plugin-sse` (`plugin/sse/`). -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**: WHATWG Server-Sent Events framing (`SseEvent`, `SseStream`), CRLF sanitization, 64-shard sparse topic pub/sub (`SseHub`), `Last-Event-ID` replay, and shared staggered heartbeats. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,type}.rs` (`SSE_PLUGIN`, coalesce buffer pool, and ring/wheel internals stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Route-helper model**: Register NO global request/response `ServerHook` middleware; handlers subscribe via `SseHub::subscribe` and drive streams with `SseStream::serve_subscription`. -- **WHATWG CRLF-safe framing**: Strip `\r`, `\n`, `\0` from `comment`/`id`/`event` fields, split `data` on `\r\n`/`\n`/`\r` into separate `data:` lines terminated by `\n\n`, and emit `Content-Type: text/event-stream; charset=utf-8`, `Cache-Control: no-cache`, and `x-accel-buffering: no`. -- **Sparse zero-idle-ring scaling**: Keep 64 cache-line-aligned shards enforcing atomic `max_topics`, zero heap bytes on drained/idle `SseTopicRing`, lazy wire caching in `SharedSseEvent`, and ephemeral topic eviction on `SseSubscription::drop`. -- **Wakeup, replay & heartbeat invariants**: Enable `Notified` before re-polling `try_pop` (zero lost wakeups), keep monotonic `Last-Event-ID` binary-search replay bounded to `replay_capacity`, coalesce bursts via cancellation-safe pooled buffers, use shared phase-staggered `SseHeartbeatWheel` timers, tolerate `Lagged`, and mark `stream.set_closed(true)` on channel close. - -## 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/sse/README.md` (and `plugin/README.md` / root `README.md` if public surface changes) in the same commit. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p hyperlane-plugin-sse --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-sse --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/sse/README.md b/plugin/sse/README.md index d401dec4..a5cd3a29 100644 --- a/plugin/sse/README.md +++ b/plugin/sse/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-sse logo + # hyperlane-plugin-sse -**WHATWG Server-Sent Events (SSE) Plugin** +**WHATWG Server-Sent Events (SSE) Streaming & Topic Pub/Sub Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-sse)](https://crates.io/crates/hyperlane-plugin-sse) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-sse?style=flat-square)](https://docs.rs/hyperlane-plugin-sse) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-sse)](https://crates.io/crates/hyperlane-plugin-sse) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-sse?style=flat-square)](https://docs.rs/hyperlane-plugin-sse) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-sse/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-sse/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in SSE streaming with CRLF-safe event framing, topic pub/sub, `Last-Event-ID` bounded replay buffers, and periodic heartbeats. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `fn` / `impl` — Topic hub, replay ring buffer, and SSE response streaming +`hyperlane-plugin-sse` delivers WHATWG-compliant Server-Sent Events streaming, topic pub/sub fan-out, heartbeats, and `Last-Event-ID` replay buffers for [`hyperlane`](../../README.md) routes. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-sse ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_sse::{SseConfig, SsePlugin}; + +fn setup_sse() { + SsePlugin::init(SseConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-sse --all-features --all-targets -- -D warnings cargo test -p hyperlane-plugin-sse --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/static_files/AGENTS.md b/plugin/static_files/AGENTS.md deleted file mode 100644 index 42241f22..00000000 --- a/plugin/static_files/AGENTS.md +++ /dev/null @@ -1,33 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-static-files` - -Concise engineering and iteration guidelines for `hyperlane-plugin-static-files` (`plugin/static_files/`). -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**: Traversal-proof static file server with MIME lookup (`FileExtension`), 64-shard hot-file cache, `.br`/`.gz` precompressed sidecars, `ETag`/`304`, RFC 9110 `Range` (`206`/`416`), SPA fallback, and `StaticFilesHook`. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,fn,impl,static,struct,type}.rs` (`STATIC_FILES_PLUGIN` and cache/range internals stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `StaticFilesHook` (`#[hyperlane::request_middleware(-55)]`) MUST return `Status::Continue` when unconfigured, on non-`GET`/`HEAD`, outside mount prefix, or when an asset is missing/unsafe, and send bytes before `Status::Reject` when served. -- **Dual-layer traversal & symlink defense**: Reject NUL/`%00`, backslashes, `..`, malformed `%` escapes, non-UTF-8 paths, and dotfiles (unless `allow_dotfiles == true`) lexically, AND verify `canonicalize(...).starts_with(&canonical_root)` for BOTH target files and `.br`/`.gz` sidecars before reading. -- **Sidecar negotiation & `Vary`**: Select `br` > `gzip` > `raw` per `Accept-Encoding` (honoring `q=0`), preserve the uncompressed asset MIME `Content-Type`, and always emit `Content-Encoding` + `Vary: Accept-Encoding` for sidecars. -- **ETag/`304` precedence & `Range` handling**: Check strong `ETag` (`If-None-Match` -> `304`, empty body) BEFORE `Range`; serve single byte ranges with `206` (`Content-Range: bytes start-end/total`, empty body on `HEAD`) and reject invalid/multi-range specs with `416` (`Content-Range: bytes */total`). -- **Bounded 64-shard cache & wire fast path**: Enforce `max_file_cache_bytes` and `max_cache_bytes`; use lazy prebuilt HTTP/1.1 wires only when response headers are empty, reason phrase is default, and no `Range` header is present. - -## 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/static_files/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-static-files --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-static-files --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/static_files/README.md b/plugin/static_files/README.md index 41ff2b62..155fc54b 100644 --- a/plugin/static_files/README.md +++ b/plugin/static_files/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-static-files logo + # hyperlane-plugin-static-files -**Path-Safe Static File Server Plugin** +**Traversal-Proof Static File Server, Precompressed Sidecars & `Range` Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-static-files)](https://crates.io/crates/hyperlane-plugin-static-files) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-static-files?style=flat-square)](https://docs.rs/hyperlane-plugin-static-files) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-static-files)](https://crates.io/crates/hyperlane-plugin-static-files) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-static-files?style=flat-square)](https://docs.rs/hyperlane-plugin-static-files) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-static-files/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-static-files/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in static asset serving with canonical path-traversal rejection, MIME detection, range/ETag support, and precompressed asset negotiation. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `fn` / `impl` — Canonical directory resolver and `StaticFilesHook` +`hyperlane-plugin-static-files` serves static assets safely and rapidly from [`hyperlane`](../../README.md) servers with canonical path-traversal defense, hot-file caching, precompressed sidecars, and HTTP byte ranges (hook order `-55`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-static-files ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_static_files::{StaticFilesConfig, StaticFilesPlugin}; + +fn setup_static_files() -> Result<&'static StaticFilesPlugin, String> { + StaticFilesPlugin::init(StaticFilesConfig::new("./public")) +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-static-files --all-features --all-targets -- -D cargo test -p hyperlane-plugin-static-files --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/tenant/AGENTS.md b/plugin/tenant/AGENTS.md deleted file mode 100644 index 454870cf..00000000 --- a/plugin/tenant/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-tenant` - -Concise engineering and iteration guidelines for `hyperlane-plugin-tenant` (`plugin/tenant/`). -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**: Multi-tenant isolation via header/subdomain/path extraction, `XxHash3_64` static registry, pluggable `TenantResolver`, `TenantContext` injection, and prebuilt `400`/`403`/`404` rejections (`TenantHook`). -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait}.rs` (`TENANT_PLUGIN` stays `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `TenantHook` (`#[hyperlane::request_middleware(-98)]`) MUST stay transparent (`Status::Continue`) when unconfigured or on `exempt_prefixes`, attach `TenantContext` (`ATTR_TENANT_CONTEXT`) on resolution, and flush prebuilt `400`/`404`/`403` wire bytes before returning `Status::Reject` on errors. -- **Deterministic extraction & lookup order**: Check segment-bounded `exempt_prefixes` first, then extract strictly in order: (1) configured header (default `x-tenant-id`), (2) single-label `Host` subdomain before `.base_domain` (case-insensitive, port stripped, nested dots rejected), (3) path segment after `path_prefix`, (4) `default_tenant`; resolve via static registry then `TenantResolver`. -- **Strict tenant ID validation**: Enforce `is_valid_tenant_id` (`1..=64` ASCII `[a-zA-Z0-9_-]`) on every extracted identifier before lookup. -- **Suspended tenant isolation**: Always fail closed with prebuilt `403 Forbidden` whenever a static or dynamic tenant resolves to `TenantStatus::Suspended`. - -## 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/tenant/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-tenant --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-tenant --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/tenant/README.md b/plugin/tenant/README.md index 89f32f4b..41cc6f3d 100644 --- a/plugin/tenant/README.md +++ b/plugin/tenant/README.md @@ -1,11 +1,55 @@ +
+ +hyperlane-plugin-tenant logo + # hyperlane-plugin-tenant -Multi-tenant resolution and isolation middleware for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**Zero-Allocation Multi-Tenant Resolution & Isolation Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-tenant)](https://crates.io/crates/hyperlane-plugin-tenant) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-tenant?style=flat-square)](https://docs.rs/hyperlane-plugin-tenant) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-tenant/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-tenant` resolves and validates tenant identity across headers, subdomains, and path prefixes for multi-tenant [`hyperlane`](../../README.md) services (hook order `-98`). It is opt-in and transparent (`Status::Continue`) when unconfigured. + +## Installation + +```sh +cargo add hyperlane-plugin-tenant +``` + +## Usage + +```rust +use hyperlane_plugin_tenant::{TenantConfig, TenantPlugin}; + +fn setup_tenant() { + TenantPlugin::init(TenantConfig::default()); +} +``` + +## Verification + +```sh +cargo run -p hyperlane-cli -- fmt --check +cargo clippy -p hyperlane-plugin-tenant --all-features --all-targets -- -D warnings +cargo test -p hyperlane-plugin-tenant --all-features +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. -## Features +## Contact -- Extracts tenant identifiers from `X-Tenant-Id` header, Host subdomains (`.example.com`), or path prefixes (`/t//...`). -- Static `XxHash3_64` tenant directory plus pluggable `TenantResolver` trait. -- Prebuilt `400`, `403`, and `404` wire responses for missing, suspended, and unknown tenants. -- Attaches `TenantContext` to Hyperlane `Context`. -- Opt-in and transparent (`Status::Continue`) when unconfigured (`#[hyperlane::request_middleware(-98)]`). +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/timeout/AGENTS.md b/plugin/timeout/AGENTS.md deleted file mode 100644 index fb03c36c..00000000 --- a/plugin/timeout/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# 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 . -``` diff --git a/plugin/timeout/README.md b/plugin/timeout/README.md index 7045d9d3..c8c59c9c 100644 --- a/plugin/timeout/README.md +++ b/plugin/timeout/README.md @@ -1,11 +1,55 @@ +
+ +hyperlane-plugin-timeout logo + # hyperlane-plugin-timeout -Global and per-route request deadline budgets for [Hyperlane](https://github.com/hyperlane-dev/hyperlane). +**Global & Per-Route Request Deadline Budget & `504` Timeout Plugin** + +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-timeout)](https://crates.io/crates/hyperlane-plugin-timeout) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-timeout?style=flat-square)](https://docs.rs/hyperlane-plugin-timeout) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) +[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) +[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) + +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-timeout/latest/) + +
+ +--- + +## Overview + +`hyperlane-plugin-timeout` enforces global and per-prefix request deadline budgets with automatic `504 Gateway Timeout` conversion for [`hyperlane`](../../README.md) services (hook order `-112` / `82`). It is opt-in and transparent (`Status::Continue`) when unconfigured. + +## Installation + +```sh +cargo add hyperlane-plugin-timeout +``` + +## Usage + +```rust +use hyperlane_plugin_timeout::{TimeoutConfig, TimeoutPlugin}; + +fn setup_timeout() { + TimeoutPlugin::init(TimeoutConfig::default()); +} +``` + +## 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 +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. -## Features +## Contact -- Longest-prefix route timeout overrides with optional `0` (disabled) exemption for streaming routes. -- Optional `X-Request-Timeout` header clamping (clients may tighten but never extend server budgets). -- Attaches `RequestDeadline` to `Context` for handlers and exposes `timeout_future(ctx, fut)`. -- Automatic `504 Gateway Timeout` conversion when deadlines expire before response serialization. -- Opt-in and transparent (`Status::Continue`) when unconfigured (`-112` / `82`). +For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip). diff --git a/plugin/tracing/AGENTS.md b/plugin/tracing/AGENTS.md deleted file mode 100644 index 2136b778..00000000 --- a/plugin/tracing/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-tracing` - -Concise engineering and iteration guidelines for `hyperlane-plugin-tracing` (`plugin/tracing/`). -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**: Lock-free 128-bit W3C Trace Context (`traceparent`/`tracestate`), `X-Request-Id` correlation, `Server-Timing`, pluggable `SpanExporter`, and outermost `TracingRequestHook`/`TracingResponseHook`. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`. -- **Layout**: `src/{lib,const,fn,impl,static,struct,trait}.rs` (`TRACING_PLUGIN`, `TRACE_SEQ`/`TRACE_SEED`, and thread-local `LOCAL_TRACE_SEQ` stay `pub(crate)`); tests in `tests/`. - -## Core Iteration Invariants - -- **Hook contract & order**: `TracingRequestHook` (`#[hyperlane::request_middleware(-130)]`, outermost request hook) and `TracingResponseHook` (`#[hyperlane::response_middleware(90)]`) MUST remain transparent (`Status::Continue`) when unconfigured. -- **W3C Trace Context conformance**: Enforce exact 55-byte `vv-<32hex>-<16hex>-<2hex>` format, reject version `0xff`, non-hex bytes, and all-zero `trace_id`/`parent_span_id`, lowercase hex, preserve `tracestate`, and always mint a fresh non-zero local `span_id`. -- **Contention-free ID generation & stack formatting**: Claim disjoint 24-bit per-thread sequence blocks (`LOCAL_TRACE_SEQ`) mixed with SplitMix64 + process seed to avoid cross-core atomic contention; keep `format_traceparent_stack` (55B) and `format_server_timing_stack` (128B) heap-free. -- **Early correlation seeding & keep-alive reuse**: Emit `traceparent` and `X-Request-Id` on entry before downstream short-circuits, restore if cleared on exit, recycle unique `Arc` slots in place, and skip `Instant::now()` when `!emit_server_timing && exporters.is_empty()`. - -## 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/tracing/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-tracing --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-tracing --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/tracing/README.md b/plugin/tracing/README.md index ef8d3fda..60f93644 100644 --- a/plugin/tracing/README.md +++ b/plugin/tracing/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-tracing logo + # hyperlane-plugin-tracing -**Distributed Trace Context & Request-ID Plugin** +**Lock-Free W3C Trace Context, `X-Request-Id` & `Server-Timing` Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-tracing)](https://crates.io/crates/hyperlane-plugin-tracing) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-tracing?style=flat-square)](https://docs.rs/hyperlane-plugin-tracing) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-tracing)](https://crates.io/crates/hyperlane-plugin-tracing) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-tracing?style=flat-square)](https://docs.rs/hyperlane-plugin-tracing) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-tracing/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-tracing/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in W3C `traceparent` propagation, correlation request-ID generation, and per-request span lifecycle hooks. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `trait` / `impl` — W3C trace parser/injector and `TracingHook` +`hyperlane-plugin-tracing` propagates W3C Trace Context (`traceparent`/`tracestate`), generates lock-free 128-bit trace IDs, stamps `X-Request-Id` and `Server-Timing` headers, and exports `SpanRecord` spans for [`hyperlane`](../../README.md) services (hook order `-130` / `90`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-tracing ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_tracing::TracingPlugin; + +fn setup_tracing() { + TracingPlugin::init_default(); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-tracing --all-features --all-targets -- -D warn cargo test -p hyperlane-plugin-tracing --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/webhook/AGENTS.md b/plugin/webhook/AGENTS.md deleted file mode 100644 index 1c3dfb3b..00000000 --- a/plugin/webhook/AGENTS.md +++ /dev/null @@ -1,32 +0,0 @@ -# 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 . -``` diff --git a/plugin/webhook/README.md b/plugin/webhook/README.md index f6a2beeb..d3882e15 100644 --- a/plugin/webhook/README.md +++ b/plugin/webhook/README.md @@ -1,11 +1,14 @@
+hyperlane-plugin-webhook logo + # hyperlane-plugin-webhook -**Inbound HTTP Webhook HMAC-SHA256 Verification & Replay-Defense Plugin** +**Constant-Time HMAC-SHA256 Webhook Verification & Replay-Defense Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-webhook)](https://crates.io/crates/hyperlane-plugin-webhook) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-webhook?style=flat-square)](https://docs.rs/hyperlane-plugin-webhook) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-webhook)](https://crates.io/crates/hyperlane-plugin-webhook) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-webhook?style=flat-square)](https://docs.rs/hyperlane-plugin-webhook) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) @@ -17,14 +20,7 @@ ## Overview -Opt-in request middleware (order `-58`) providing inbound HTTP webhook verification directly on Hyperlane `Request::get_body()`: zero-allocation precomputed-midstate pure-Rust FIPS 180-4 SHA-256 & RFC 4231 HMAC-SHA256 with constant-time signature checks (`Hex`, `Base64`, and Stripe-style `t=...,v1=...` timestamped schemes), per-route secret rotation, timestamp skew window enforcement, a 64-shard bounded TTL replay-nonce cache, and verified `WebhookEvent` metadata injected into `Context` attributes (`ATTR_WEBHOOK_EVENT`). - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `enum` / `impl` — `HmacSha256Key`, `WebhookSecret`, `WebhookEndpoint`, `WebhookConfig`, `WebhookEvent`, `WebhookVerifier`, `WebhookPlugin`, and `WebhookHook` (`-58`) -- `fn` — Streaming FIPS 180-4 SHA-256, RFC 4231 HMAC-SHA256, constant-time byte equality, stack-allocated Hex/Base64 decoding, and Stripe signature header parsing +`hyperlane-plugin-webhook` authenticates inbound HTTP webhooks using pure-Rust precomputed-midstate HMAC-SHA256 signatures, timestamp skew guards, and a 64-shard replay cache for [`hyperlane`](../../README.md) services (hook order `-58`). It is opt-in and transparent (`Status::Continue`) when unconfigured. ## Installation @@ -32,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-webhook ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_webhook::{WebhookConfig, WebhookPlugin}; + +fn setup_webhook() { + WebhookPlugin::init(WebhookConfig::default()); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -42,10 +46,6 @@ cargo clippy -p hyperlane-plugin-webhook --all-features --all-targets -- -D warn cargo test -p hyperlane-plugin-webhook --all-features ``` -## Documentation & Governance - -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/plugin/websocket/AGENTS.md b/plugin/websocket/AGENTS.md deleted file mode 100644 index 34479fbb..00000000 --- a/plugin/websocket/AGENTS.md +++ /dev/null @@ -1,33 +0,0 @@ -# AGENTS.md — `hyperlane-plugin-websocket` - -Concise engineering and iteration guidelines for `hyperlane-plugin-websocket` (`plugin/websocket/`). -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**: Room-based WebSocket broadcast engine (`WebSocket`, `WebSocketPlugin`, `WebSocketConfig`, `BroadcastType`) with sparse 64-shard scaling, lag recovery, and per-connection `ServerHook` lifecycle callbacks. -- **Dependencies**: Internal `hyperlane`; external `lombok-macros`, `tokio-broadcast`. -- **Layout**: `src/{lib,const,enum,fn,impl,static,struct,trait,type}.rs` (`WEBSOCKET_PLUGIN`, coalesce pool, and sparse hub internals stay `pub(crate)`); tests in `tests/{broadcast_type,websocket,websocket_map}/`. - -## Core Iteration Invariants - -- **Route-helper lifecycle model**: Register NO global request/response `ServerHook` middleware; route handlers drive connections via `WebSocket::run(WebSocketConfig)` with `connected_hook`, `request_hook`, `sended_hook`, and `closed_hook`. -- **Symmetric room keys & `Unknown` safety**: Keep `PointToPoint(a, b)` canonically sorted (`"ptp---"`), `PointToGroup(g)` as `"ptg--"`, and ensure `Unknown` closes `stream` cleanly without panicking; keep keys `<= 64B` stack-formatted. -- **Zero-idle-ring sparse hub + legacy coexistence**: Keep the 64-shard `SparseWsHub` at 0 heap bytes per idle/drained `WsRoomRing`, auto-evict empty rooms on subscription drop, isolate legacy `BroadcastMap` receivers in `#[cold] Box::pin(run_legacy_connection)`, and preserve `Clone` snapshot semantics. -- **Frame-once RFC 6455 & UTF-8 boundary parity**: Pre-frame broadcasts once into shared `Arc<[u8]>` matching `WebSocketFrame::create_frame_list` byte-for-byte (text `0x01` for valid UTF-8, binary `0x02` otherwise, never splitting multi-byte UTF-8 sequences across continuation frames). -- **Exactly-once `closed_hook` & cleanup**: Always invoke `closed_hook` once (`closed_called` guard) with cleared `response.body`, broadcast any farewell payload it writes, drop subscriptions, unsubscribe empty legacy channels, and mark `stream.set_closed(true)`. - -## 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/websocket/README.md` (and `plugin/README.md` / root `README.md` if public surface changes) in the same commit. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p hyperlane-plugin-websocket --all-features --all-targets -- -D warnings -cargo test -p hyperlane-plugin-websocket --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/plugin/websocket/README.md b/plugin/websocket/README.md index 6d35d0b9..25b263df 100644 --- a/plugin/websocket/README.md +++ b/plugin/websocket/README.md @@ -1,15 +1,18 @@
+hyperlane-plugin-websocket logo + # hyperlane-plugin-websocket -**Room-Based WebSocket Broadcast Plugin** +**Room-Based WebSocket Broadcast & Lifecycle Management Plugin** -[![crates.io](https://flat.badgen.net/crates/v/hyperlane-plugin-websocket)](https://crates.io/crates/hyperlane-plugin-websocket) -[![docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-websocket?style=flat-square)](https://docs.rs/hyperlane-plugin-websocket) +[![Crates.io Version](https://flat.badgen.net/crates/v/hyperlane-plugin-websocket)](https://crates.io/crates/hyperlane-plugin-websocket) +[![Docs.rs](https://img.shields.io/docsrs/hyperlane-plugin-websocket?style=flat-square)](https://docs.rs/hyperlane-plugin-websocket) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../../LICENSE) -[Workspace Overview](../../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-websocket/latest/) +[Workspace Overview](../../README.md) · [Plugin Catalog](../README.md) · [API Docs](https://docs.rs/hyperlane-plugin-websocket/latest/)
@@ -17,13 +20,7 @@ ## Overview -Opt-in WebSocket upgrade, room-keyed broadcast maps, ping/pong lifecycle hooks, and bounded frame/message reassembly. - -This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `struct` / `static` / `impl` — `WebSocketConfig`, room broadcast manager, and lifecycle hooks +`hyperlane-plugin-websocket` provides room-based WebSocket fan-out broadcasting, slow-consumer lag recovery, and connection lifecycle management for [`hyperlane`](../../README.md) applications. ## Installation @@ -31,9 +28,17 @@ This crate is a member of the [`hyperlane`](../../README.md) unified Rust 2024 w cargo add hyperlane-plugin-websocket ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use hyperlane_plugin_websocket::WebSocketPlugin; + +fn setup_websocket() { + WebSocketPlugin::init_default(); +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -41,11 +46,6 @@ cargo clippy -p hyperlane-plugin-websocket --all-features --all-targets -- -D wa cargo test -p hyperlane-plugin-websocket --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../../.agents/skills/hyperlane/SKILL.md`](../../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. diff --git a/request/AGENTS.md b/request/AGENTS.md deleted file mode 100644 index ccb0be8f..00000000 --- a/request/AGENTS.md +++ /dev/null @@ -1,33 +0,0 @@ -# AGENTS.md — `http-request` - -Concise engineering and iteration guidelines for `http-request` (`request/`). -Global workspace rules live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md) and `~/.agents/skills/rust-standards/SKILL.md`. - -## Scope & Module Boundaries - -- **Role**: Sync and Tokio-async HTTP/1.1 + HTTP/2 client (`HttpClient`, `HttpClientBuilder`, `RequestBuilder`, `HttpResponse`) with keep-alive pooling, TLS session resumption, custom PEM roots, retries, form/multipart uploads, and HTTP/SOCKS5 proxies. -- **Dependencies**: Internal `http-type` plus `h2`, `http`, `bytes`, `rustls`, `tokio-rustls`, `webpki-roots`, `serde`/`serde_json`, `lombok-macros`. Do NOT depend on `hyperlane-core`. -- **Layout**: Public `client`, `common`, `request`, `response`; `pub(crate)` `pool`, `protocol`, `tls`; internal `utils`; tests in `tests/`. - -## Core Iteration Invariants - -- Keep `pool`, `protocol`, and `tls` internals `pub(crate)`; expose capabilities cleanly through `HttpClient`, `RequestBuilder`, and `HttpResponse`. -- Maintain feature and error parity across sync and async transports as well as HTTP/1.1 and HTTP/2 (`h2`) paths. -- Enforce RFC 9110/3986 redirect safety: bound redirect hops, detect loops, and strip sensitive headers (`Authorization`, `Cookie`) on cross-origin redirects. -- Preserve multi-`Set-Cookie` headers, single-pass chunked/compressed decoding (bounded by `http-compress` limits), and zero-copy response body helpers. -- Avoid global lock contention or per-request wall-clock sweep churn in the 16-stripe keep-alive connection pool. - -## Code & Documentation Standards - -- Follow `rust-standards`: pure 9-keyword filenames, 3-section `mod.rs` (zero comments), centralized imports in `src/lib.rs` and `tests/mod.rs`, `pub(crate)` struct fields with `lombok-macros` accessors (no direct `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 `request/README.md` alongside any public API or client behavior change. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p http-request --all-features --all-targets -- -D warnings -cargo test -p http-request --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/request/README.md b/request/README.md index a9ef3c06..ddded6b8 100644 --- a/request/README.md +++ b/request/README.md @@ -1,11 +1,14 @@
+http-request logo + # http-request -**Sync & Async HTTP/1.1 + HTTP/2 Client** +**Standalone Sync & Async HTTP/1.1 & HTTP/2 Client** -[![crates.io](https://flat.badgen.net/crates/v/http-request)](https://crates.io/crates/http-request) -[![docs.rs](https://img.shields.io/docsrs/http-request?style=flat-square)](https://docs.rs/http-request) +[![Crates.io Version](https://flat.badgen.net/crates/v/http-request)](https://crates.io/crates/http-request) +[![Docs.rs](https://img.shields.io/docsrs/http-request?style=flat-square)](https://docs.rs/http-request) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../LICENSE) @@ -17,15 +20,7 @@ ## Overview -Ergonomic HTTP client supporting reusable [`HttpClient`] instances (keep-alive pooling enabled by default, base URL resolution, default headers, Bearer/Basic auth, timeouts, retries, proxies, and custom PEM roots) alongside per-request [`RequestBuilder`] helpers (`send`, `send_async`, `try_body_json`, multipart/form uploads) and [`HttpResponse`] inspection methods (`error_for_status`, `content_type`, `content_length`, `location`, `text_strict`, `set_cookies`). - -This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `client` — Reusable [`HttpClient`] and [`HttpClientBuilder`] with shared connection pooling, base URLs, default headers, auth helpers, timeouts, retries, proxies, and custom roots -- `request` / `pool` / `protocol` / `tls` — Sync and Tokio-async HTTP/1.1 + HTTP/2 transports, 16-stripe keep-alive pools, RFC 9110/3986 redirect handling with credential stripping, and single-pass chunked/compressed decoding -- `response` — [`HttpResponse`] wire parser, zero-copy in-place decoding, multi-`Set-Cookie` preservation, and typed body/header helpers +`http-request` is the standalone synchronous and asynchronous HTTP/1.1 and HTTP/2 client in the [`hyperlane`](../README.md) workspace, built directly on [`http-type`](../type/README.md) with zero server-core coupling. ## Installation @@ -33,9 +28,19 @@ This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 work cargo add http-request ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use http_request::RequestBuilder; + +fn build_get_client() -> RequestBuilder { + let mut builder: RequestBuilder = RequestBuilder::new(); + builder.get("https://example.com/"); + builder +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -43,11 +48,6 @@ cargo clippy -p http-request --all-features --all-targets -- -D warnings cargo test -p http-request --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details. diff --git a/type/AGENTS.md b/type/AGENTS.md deleted file mode 100644 index b54ca3c7..00000000 --- a/type/AGENTS.md +++ /dev/null @@ -1,34 +0,0 @@ -# AGENTS.md — `http-type` - -Concise engineering and iteration guidelines for `http-type` (`type/`). -Global workspace rules live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md) and `~/.agents/skills/rust-standards/SKILL.md`. - -## Scope & Module Boundaries - -- **Role**: RFC 9110/9112 wire parsers and builders (`Request`, `Response`, `Stream`, `Body`, `Cookie`, `WebSocketFrame`, `Status`, `HttpStatus`, `Method`, `ContentType`, `FileExtension`) plus concurrent/hash utility wrappers. -- **Dependencies**: Internal `http-compress` and `http-constant` plus serialization/Tokio utilities. Do NOT depend on `hyperlane-core` or `http-request`. -- **Layout**: Public wire and type modules re-exported via `src/lib.rs` (along with `http-compress`, `http-constant`, `serde_json`, `tokio`); `pub(crate)` `chunked` (`fill_chunked_body`); tests in `tests/`. - -## Core Iteration Invariants - -- Maintain strict RFC 9110/9112 wire conformance: reject CRLF injection, invalid header names/values, and conflicting `Content-Length`/`Transfer-Encoding` request smuggling vectors. -- Keep `Transfer-Encoding: chunked` decoding strictly bounded (`fill_chunked_body`) while consuming chunk extensions and trailers cleanly. -- Preserve `HEAD`-aware and bodyless (`1xx`, `204`, `205`, `304`) serialization in `Response::build_wire` without breaking fast-path `200 OK` formatting. -- Keep `Request::matches_if_none_match` allocation-free for strong/weak ETag lists (repeated headers, quoted commas, and `*`). -- Preserve zero-init stack-buffer and SWAR hot paths (`Stream::fill_http_from_stream`, single-pass header parsing) without unsound `MaybeUninit` reads or regressions in real wire tests. -- Keep all fields on `pub` structs `pub(crate)` with generated `lombok-macros` accessors (`get_*`/`get_mut_*`/`set_*`). - -## Code & Documentation Standards - -- Follow `rust-standards`: pure 9-keyword filenames, 3-section `mod.rs` (zero comments), centralized imports in `src/lib.rs` and `tests/mod.rs`, explicit types on all `let`/closure bindings, zero `#[allow]`/`unwrap()`/`expect()`/`panic!()`/`self.field`, `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 `type/README.md` alongside any wire invariant or public API change. - -## Local Verification - -```sh -cargo run -p hyperlane-cli -- fmt --check -cargo clippy -p http-type --all-features --all-targets -- -D warnings -cargo test -p http-type --all-features -python3 ~/.agents/skills/rust-standards/scripts/staged_file_gate.py . -python3 ~/.agents/skills/rust-standards/scripts/verify_dep_order.py . -``` diff --git a/type/README.md b/type/README.md index c6010814..5bba11a3 100644 --- a/type/README.md +++ b/type/README.md @@ -1,11 +1,14 @@
+http-type logo + # http-type -**RFC 9110/9112 HTTP Wire Types & Builders** +**RFC-Compliant HTTP Wire Types, Parsers, Builders & Concurrent Primitives** -[![crates.io](https://flat.badgen.net/crates/v/http-type)](https://crates.io/crates/http-type) -[![docs.rs](https://img.shields.io/docsrs/http-type?style=flat-square)](https://docs.rs/http-type) +[![Crates.io Version](https://flat.badgen.net/crates/v/http-type)](https://crates.io/crates/http-type) +[![Docs.rs](https://img.shields.io/docsrs/http-type?style=flat-square)](https://docs.rs/http-type) +[![CI Status](https://img.shields.io/github/actions/workflow/status/hyperlane-dev/hyperlane/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/hyperlane-dev/hyperlane/actions/workflows/rust.yml) [![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../LICENSE) @@ -17,14 +20,7 @@ ## Overview -Wire-accurate `Request`, `Response`, `Stream`, `Cookie`, `MultipartFormData`, `WebSocket`, `Status`, and `RequestConfig` with CRLF/smuggling rejection and HEAD-aware response serialization. - -This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 workspace. All plugin crates are opt-in and transparent (`Status::Continue`) when unconfigured. - -## Responsibilities & Module Layout - -- `request` / `response` — Wire parsers, builders, `matches_if_none_match`, and framing invariants -- `stream` / `websocket` / `cookie` / `multipart` — Transport stream wrappers and structured payload codecs +`http-type` defines the core HTTP wire types, parsers, builders, WebSocket frames, and concurrency helpers shared across [`hyperlane`](../README.md) servers, clients, and plugins. ## Installation @@ -32,9 +28,20 @@ This crate is a member of the [`hyperlane`](../README.md) unified Rust 2024 work cargo add http-type ``` -## Verification +## Usage -Run crate-scoped formatting, lint, and test gates from the workspace root: +```rust +use http_type::{HttpStatus, Response}; + +fn build_ok_response() -> Response { + let mut response: Response = Response::default(); + response.set_status_code(HttpStatus::Ok.code()); + response.set_body("ok"); + response +} +``` + +## Verification ```sh cargo run -p hyperlane-cli -- fmt --check @@ -42,11 +49,6 @@ cargo clippy -p http-type --all-features --all-targets -- -D warnings cargo test -p http-type --all-features ``` -## Documentation & Governance - -- Update this `README.md` alongside any public API, plugin contract, or module-boundary change. -- Project standards and release workflows live in [`../.agents/skills/hyperlane/SKILL.md`](../.agents/skills/hyperlane/SKILL.md). - ## License This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details.