praxis_policy_core/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 Praxis Contributors
3
4// PPE Core library root.
5//
6// Pure Rust plugin runtime with no FFI, WASM, or PyO3 dependencies.
7// Provides the PolicyEngine, 5-phase executor, hook registry,
8// unified config parser, and all core types.
9//
10// # Modules
11//
12// - [`plugin`] — Plugin trait, PluginRef, PluginMetadata, PluginConfig
13// - [`hooks`] — HookType (open string registry), payload/result traits
14// - [`executor`] — 5-phase execution engine (sequential → transform → audit → concurrent → fire_and_forget)
15// - [`engine`] — PolicyEngine lifecycle and hook dispatch
16// - [`registry`] — PluginInstanceRegistry and HookRegistry
17// - [`config`] — Unified YAML configuration parsing
18// - [`factory`] — Plugin factory registry for config-driven instantiation
19// - [`context`] — PluginContext (local_state + global_state)
20// - [`audit`] — AuditHandler, the observation-only verdict sink
21// - [`decision`] — DecisionLog, the executor's record of a pipeline run
22// - [`effect`] — irreversible external acts, recorded write-ahead
23// - [`cmf`] — Common Message Format (Message, ContentPart, enums)
24// - [`identity`] — IdentityResolve hook family (subject / client /
25// workload resolution from raw credentials)
26// - [`delegation`] — TokenDelegate hook family (outbound credential
27// minting for downstream calls)
28// - [`elicitation`] — Elicitation hook family (human-in-the-loop:
29// approval, confirmation, step-up, …)
30// - [`error`] — Error types, violations, and result types
31
32//! The plugin runtime: engine, executor, hook registry, and config parser.
33//!
34//! Pure Rust with no FFI, WASM, or Python bindings. Plugins register against
35//! named hooks and the executor dispatches them in five phases, reading every
36//! scheduling decision from trusted config rather than from the plugin.
37
38/// What the engine asserts on a request and a response, as headers.
39pub mod assertions;
40/// Observation-only sinks that see each pipeline verdict.
41pub mod audit;
42/// The Common Message Format: messages, content parts, and read-only views.
43pub mod cmf;
44/// YAML configuration parsing for plugins, routes, and policies.
45pub mod config;
46/// Per-plugin state carried across hook invocations.
47pub mod context;
48/// What each plugin did to a request, and how the pipeline ruled on it.
49pub mod decision;
50/// The token delegation hook and its payload.
51pub mod delegation;
52/// Irreversible external effects and the write-ahead log that records them.
53pub mod effect;
54/// The elicitation hook, for out-of-band human approval.
55pub mod elicitation;
56/// Plugin lifecycle and hook dispatch.
57pub mod engine;
58/// Plugin errors and policy violations.
59pub mod error;
60/// Five-phase plugin dispatch.
61pub mod executor;
62/// Typed request attributes that plugins read and write.
63pub mod extensions;
64/// Config-driven plugin construction.
65pub mod factory;
66/// A plugin that panics, errors, or hangs on demand. Requires `test-util`.
67#[cfg(any(test, feature = "test-util"))]
68pub mod fault_testing;
69/// Hook types, payloads, and the handler traits.
70pub mod hooks;
71/// Host-provided services and the carriers that lend them to a plugin.
72pub mod host;
73/// The outbound-HTTP seam. Types and a trait; PPE performs no HTTP itself.
74pub mod http;
75/// Which IP addresses an outbound policy call must not reach. The shared
76/// range table; a transport enforces it where it dials.
77pub mod http_addr;
78/// The generic-HTTP hook family: its two names, its payload, and its hook type.
79pub mod http_hook;
80/// The path a route matches on, normalized the way the gateway's own
81/// router normalizes it and never percent-decoded.
82pub mod http_path;
83/// Retry policy for outbound HTTP, keyed to whether a repeat is safe.
84pub mod http_retry;
85/// A scripted `HttpTransport` for tests, including the failure paths a
86/// mock server cannot produce. Requires the `test-util` feature.
87#[cfg(any(test, feature = "test-util"))]
88pub mod http_testing;
89/// The identity resolution hook and its payload.
90pub mod identity;
91/// The `Plugin` trait and its trusted configuration.
92pub mod plugin;
93/// Curated re-exports for plugin authors.
94pub mod prelude;
95/// Plugin instance and hook registries.
96pub mod registry;
97/// Secret material: providers, the declared values bound to them, and the
98/// handles consumers read through.
99pub mod secrets;
100/// Captures emitted diagnostics for tests that assert on them.
101#[cfg(test)]
102mod trace_capture;
103/// Config visitors, which let a dialect compile its own route blocks at load time.
104pub mod visitor;