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
// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Policy LLM client trait and minimal message types.
//!
//! Defines the interface used by `zeph-tools` adversarial policy validation,
//! moved here to keep `zeph-tools` decoupled from `zeph-llm`.
use std::future::Future;
use std::pin::Pin;
/// Minimal message type for policy LLM calls.
///
/// Uses a dedicated type rather than importing `zeph-llm::Message` to keep
/// `zeph-common` free of `zeph-*` dependencies.
#[derive(Debug, Clone)]
pub struct PolicyMessage {
/// Role of the message sender.
pub role: PolicyRole,
/// Message content.
pub content: String,
}
/// Role for a [`PolicyMessage`].
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum PolicyRole {
/// System-level instruction.
System,
/// User-level prompt.
User,
}
/// Trait for sending chat messages to the policy LLM.
///
/// Implemented externally (e.g. in `runner.rs` on a newtype wrapping `Arc<AnyProvider>`).
/// `zeph-tools` defines the usage; `zeph-common` defines the contract, keeping both
/// crates decoupled from `zeph-llm`.
pub trait PolicyLlmClient: Send + Sync {
/// Send a sequence of messages and return the assistant's text response.
///
/// # Errors
///
/// Returns `Err(String)` if the LLM call fails (network error, timeout, etc.).
fn chat<'a>(
&'a self,
messages: &'a [PolicyMessage],
) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'a>>;
}