ranvier
Core Rust module for first users to build typed decision flows, run canonical examples, and connect HTTP adapters.
Versioning
0.43.00.42.xstablereleasedranvier/Cargo.toml [workspace.package.version]Artifacts
ranvier-core crates.io 0.43.0 releasedranvier-macros crates.io 0.43.0 releasedranvier-runtime crates.io 0.43.0 releasedranvier-http crates.io 0.43.0 releasedranvier-std crates.io 0.43.0 releasedranvier-guard crates.io 0.43.0 releasedranvier-audit crates.io 0.43.0 releasedranvier-compliance crates.io 0.43.0 releasedranvier-inspector crates.io 0.43.0 releasedranvier-openapi crates.io 0.43.0 releasedranvier-test crates.io 0.43.0 releasedranvier crates.io 0.43.0 releasedCan do now
- Define typed decision flows with Axon/Transition/Outcome contracts, explicit Bus wiring, and `Never` error type for infallible pipelines. 69 maintained examples covering all 12 crates. `try_outcome!` macro converts `Result<T, E>` to `Outcome` with early return for ergonomic error handling in transitions, and `Outcome::from_result()` / `Outcome::and_then()` / `Outcome::map_fault()` combinators enable functional composition.
- Run protocol-agnostic core circuits through HTTP ingress adapters with dynamic routing, request extractors, lifecycle controls, middleware composition, and per-path policy overrides. `QueryParams` is automatically injected into Bus from URI query strings with typed extraction via `get_parsed::<T>()`. `RouteGroup` scopes shared path prefixes and guards with up to 2-level nesting, `post_json_out` provides bodyless POSTโJSON endpoints, and `PageParams`/`Paginated<T>` offer built-in pagination with automatic clamping.
- Apply HTTP security/policy stacks with `ranvier-guard` crate (15 Guards: Cors, AccessLog, SecurityHeaders, IpFilter, RateLimit, Compression, RequestSizeLimit, RequestId, Auth, ContentType, Timeout, Idempotency + advanced feature: Decompression, ConditionalRequest, Redirect) โ pipeline-first middleware visible in Schematic, with `HttpIngress::guard()` auto-wiring, per-route `guards![]` composition, `GuardIntegration` trait for BusโHTTP bridging, RateLimitGuard bucket TTL with stale bucket lazy cleanup, and TrustedProxies XFF anti-spoofing with trusted proxy chain validation. `CorsGuard::permissive()` provides a one-line CORS configuration for development environments.
- Generate OpenAPI docs and Swagger UI from request/response contracts via `ranvier-openapi`. `post_typed::<T>()` auto-captures request body JSON Schema via schemars, and path parameters (`:id`) are auto-documented as OpenAPI parameters.
- Serve static directories and SPA fallback with expanded MIME support (18 types), ETag-based 304 Not Modified, directory index, immutable cache detection, pre-compressed serving (.br/.gz priority), Range request support (206 Partial Content), and render Askama HTML templates via feature-gated `TemplateResponse<T>`.
- Handle WebSocket/SSE real-time flows and inject connection/session context into Bus.
- Build LLM-as-Transition pipelines for AI classification, content moderation, and policy enforcement.
- Write in-process HTTP integration tests with `TestApp/TestRequest/TestResponse` and runtime path assertions with `AxonTestKit`/`Timeline`.
- Store and query traces with `ranvier-inspector` TraceStore (VecDeque ring buffer with configurable TTL), secure endpoints with BearerAuth (release build warning for unauthenticated Inspector), and route alerts via AlertHook/AlertDispatcher.
- Run session/job/persistence patterns and resume faulted workflows from checkpoints with PersistenceStore and compensation hooks.
- Validate API compatibility and detect structural drift with cargo-semver-checks and schematic diff/policy CLI commands.
- Monitor per-node metrics (throughput, latency percentiles, error rate), inspect in-transit payloads, manage dead letters, set conditional breakpoints, and detect stalled nodes through the built-in Inspector REST + WebSocket server. DebugControl uses parking_lot::Mutex + AtomicBool/AtomicU8 for panic safety. Extract execution lineage from stored traces (`GET /api/v1/lineage/:trace_id`) and structurally diff two traces (`GET /api/v1/traces/diff?a=&b=`) to reveal path divergence, outcome differences, and latency deltas.
- Register JSON Schema on circuit nodes via `.with_input_schema::<T>()` builder API or `#[transition(schema)]` macro attribute. Inspector serves schema-enriched route metadata (`GET /api/v1/routes`), relays HTTP requests into running circuits (`POST /api/v1/relay`), and generates empty templates or random sample payloads from schema (`POST /api/v1/routes/schema`, `POST /api/v1/routes/sample`).
- Configure production infrastructure with `RanvierConfig` (`ranvier.toml` + env overrides + profile system), structured logging (`init_logging()` with JSON/pretty/compact), and optional TLS via `rustls`.
- Return RFC 7807 Problem Details error responses with `ProblemDetail`/`IntoProblemDetail`, retry faulted transitions with `RetryPolicy` (fixed/exponential backoff) via `Axon::then_with_retry()`, enforce execution time limits with `Axon::then_with_timeout()`, and recover from transition panics via `Axon::catch_unwind()` converting panics to `Outcome::Fault`.
- Provide quantitative performance baselines with criterion micro-benchmarks (Axon latency, Bus operations, Transition chains) and Axum/Actix-web comparison servers.
- Demonstrate real-world patterns through three reference applications: Todo API (CRUD + JWT auth), Chat Server (multi-room WebSocket), and E-commerce Order Pipeline (4-stage Saga compensation + audit trail + multi-tenancy).
- Automate version migration with `ranvier migrate --from 0.20 --to 0.25` for import path replacement, crate dependency swaps. TOML-based migration rules (text_replace, rename_import, warn) with --dry-run mode.
- Export Prometheus exposition metrics from Inspector `/metrics` endpoint, auto-initialize OTLP TracerProvider via TelemetryConfig, log HTTP requests with AccessLogGuard path redaction, persist audit events to PostgreSQL with PostgresAuditSink hash-chain integrity, rotate audit logs with FileAuditSink (BySize/ByDate/ByBoth policies), auto-register OpenAPI SecurityScheme (bearerAuth) with ProblemDetail (RFC 7807) error responses, build Merkle audit trees over event batches with `MerkleAuditSink` (feature-gated `merkle`) โ SHA-256 binary tree, `MerkleProof` inclusion proofs, pluggable `AnchorService` for external root anchoring โ and compose audit logging into Axon chains with `AuditLog<S>` Transition (pass-through with non-blocking sink writes, `AuditAction`/`AuditActor` typed events). Safe dynamic SQL `QueryBuilder` patterns are documented through cookbook/example/app-local helpers rather than a public `ranvier-db` crate.
- Understand framework design philosophy through PHILOSOPHY.md ('Opinionated Core, Flexible Edges' principle) and architecture decision rationale via DESIGN_PRINCIPLES.md (ADR format covering Paradigm Test, Tower Separation, and Opinionated Core enforcement).
- Implement authentication via Transition-based (Bus context, Schematic visualization) or Tower integration (AsyncAuthorizeRequest) approaches, with auth-comparison guide covering 7-feature table, benchmarks, decision tree, and migration paths.
- Define inline pipeline steps with `Axon::then_fn()` closure-based Transitions and inject type-safe HTTP request bodies via `post_typed::<T>()` / `put_typed::<T>()` / `patch_typed::<T>()` with `Axon::typed::<In, E>()` typed-input pipelines โ automatic JSON deserialization with compile-time type guarantees. `post_json()` / `put_json()` / `patch_json()` provide JSON body deserialization without requiring `JsonSchema` derive, and `Axon::execute_simple()` eliminates the `&()` argument for `Res=()` pipelines.
- Diagnose pipeline faults with `TransitionErrorContext` โ automatically injected into Bus on `Outcome::Fault` with pipeline name, transition label, and zero-based step index.
- Write concise pipeline tests with `ranvier-test` crate: `TestBus` fluent builder, `TestAxon` single-call executor, and `assert_outcome_ok!` / `assert_outcome_err!` assertion macros with optional value inspection closures.
- Build streaming pipelines with `StreamingTransition` trait producing `Stream<Item>` instead of single `Outcome`. `StreamingAxon` runtime type, `Axon::then_stream()` / `then_stream_with_timeout()` terminal builders, SSE HTTP endpoints via `post_sse()` / `post_sse_typed()`, stream timeouts (init/idle/total), `TestAxon::run_stream()` + `assert_stream_items!` for testing, `#[streaming_transition]` macro for boilerplate-free definition, and `StreamingAxon::map_items()` for per-item stream transforms (PII filtering, token counting, format conversion).
Current limitations
No active limitation items.
Product boundaries
- Token/claim-to-role mapping for inspector auth headers is not built into core runtime and depends on deployment gateway policy.
deployment-gateway
Verification commands
cargo check --workspacecargo run -p typed-state-treecargo run -p routing-params-democargo test -p ranvier-httpcargo test -p ranvier-http --test test_app_healthcargo test -p ranvier-http --features validationcargo run -p ranvier-http --example validation_struct_level --features validationcargo test -p ranvier-guard --features advancedcargo test -p ranvier-openapicargo check -p openapi-democargo test -p ranvier-httpcargo check -p static-spa-democargo test -p ranvier-httpcargo check -p websocket-ingress-democargo test -p ranvier-inspectorcargo test --workspace./scripts/m119_examples_smoke.ps1./scripts/m131_inspector_quickview_smoke.ps1./scripts/m131_schematic_diff_policy_smoke.ps1./scripts/m131_fullstack_embedded_smoke.ps1cargo test -p ranvier-runtime timeline_assertion_works_in_integration_testcargo run -p ecosystem-seaorm-democargo run -p ecosystem-diesel-democargo run -p ecosystem-redis-democargo run -p ecosystem-nats-democargo run -p ecosystem-meilisearch-democargo check -p session-patterncargo test -p ranvier-inspector metrics stallcargo test -p ranvier-inspector breakpoint payloadcargo check -p guard-democargo check -p guard-integration-democargo check -p auth-jwt-role-demoReferences
ranvier/README.md