Skip to main content

Crate wardline_guards

Crate wardline_guards 

Source
Expand description

Built-in reference guards for Wardline.

Deliberately few and dependency-light: enough to prove the wardline_core::Guard trait works for both general application actions and LLM calls, not a comprehensive guard library. Nothing here pulls in an async runtime or a network client. The classifier adapter is a trait so a downstream crate can wrap Llama Guard or a hosted API without dragging those dependencies into this one.

All text guards use Input = str and Output = String, so they compose in one wardline_core::Pipeline.

TypeRole
RegexBlockGuardBlock on a pattern match.
RegexRedactGuardRewrite matches and return Verdict::Modify.
RateLimitGuardIn-process token bucket, keyed from Context.
PiiGuardBaseline email / phone / SSN detector — not compliance-grade.
PromptInjectionGuardCheap jailbreak-phrase heuristic.
ClassifierAdapterPlug an external model in as a Guard.

Re-exports§

pub use llm::Classification;
pub use llm::ClassifierAdapter;
pub use llm::OutputClassifier;
pub use llm::PromptInjectionGuard;

Modules§

llm
LLM-oriented reference guards and the classifier adapter.

Structs§

PiiGuard
Scans for email, US-ish phone, and SSN-shaped tokens.
RateLimitGuard
In-memory token-bucket limiter, keyed by a string field on Context.
RegexBlockGuard
Blocks the action when pattern matches anywhere in the input.
RegexRedactGuard
Rewrites every match of pattern and returns Verdict::Modify.

Enums§

PiiAction
What PiiGuard does when it finds a match.

Constants§

DEFAULT_MAX_KEYS
Default cap on distinct keys remembered at once.