1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//! Core vocabulary and execution engine for Wardline.
//!
//! Wardline evaluates guardrails inline and synchronously, in the caller's
//! request path: a check returns a blocking verdict *before* an action is
//! taken or an LLM response is released. No queue, no separate service, no
//! async runtime — a blocked action never happens rather than being detected
//! shortly after it did.
//!
//! | Type | Role |
//! |---|---|
//! | [`Guard`] | One check. The trait you implement. |
//! | [`Verdict`] | What a guard decided: allow, block, or modify. |
//! | [`GuardError`] | Why a guard reached no decision at all. |
//! | [`FailPolicy`] | What the pipeline does about that failure. |
//! | [`Context`] | Per-request metadata and the deadline. |
//! | [`Deadline`] | A cooperative wall-clock bound. |
//! | [`Pipeline`] | An ordered list of guards, run in place. |
//! | [`Trace`] | The bounded record of what each guard did. |
//! | [`Metrics`] | Optional per-guard counters (allow/block/error/panic). |
//!
//! The key distinction: [`Verdict::Block`] means the guard said *no*;
//! [`GuardError`] means it said *nothing*. Failures are resolved by the
//! failing guard's own [`FailPolicy`], which defaults to
//! [`FailPolicy::FailClosed`], so a broken guard doesn't silently stop
//! guarding.
//!
//! [`Pipeline::evaluate`] runs guards in order, stops at the first block, and
//! returns the decision together with its [`Trace`] — so a caller can log
//! *why* something was refused, not just that it was. A panic inside a guard
//! becomes [`GuardError::Panicked`] and is resolved through that guard's
//! [`FailPolicy`]; it never unwinds past the caller.
//!
//! Enable the `tracing` feature to emit a `wardline.evaluate` span and a
//! `wardline.guard` span per check, including an error event when a guard
//! panics. Without that feature this crate still depends on nothing outside
//! `std`. See `AGENTS.md` for the architectural invariants.
//!
//! # Example
//!
//! ```
//! use wardline_core::{Context, Guard, GuardError, Verdict};
//!
//! struct NoProfanity;
//!
//! impl Guard for NoProfanity {
//! type Input = str;
//! type Output = ();
//!
//! fn check(&self, input: &str, _ctx: &Context) -> Result<Verdict, GuardError> {
//! if input.contains("darn") {
//! return Ok(Verdict::block("profanity detected"));
//! }
//! Ok(Verdict::Allow)
//! }
//!
//! fn name(&self) -> &'static str {
//! "no_profanity"
//! }
//! }
//!
//! let ctx = Context::new();
//! assert_eq!(NoProfanity.check("hello there", &ctx), Ok(Verdict::Allow));
//! assert!(NoProfanity.check("well darn", &ctx).is_ok_and(|v| v.is_block()));
//! ```
pub use ;
pub use Deadline;
pub use GuardError;
pub use Guard;
pub use ;
pub use ;
pub use FailPolicy;
pub use ;
pub use Verdict;