proofborne_core/tool.rs
1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4/// JSON-schema-described tool visible to providers.
5#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
6#[serde(rename_all = "camelCase")]
7pub struct ToolDefinition {
8 /// Stable tool name.
9 pub name: String,
10 /// Concise behavior and boundary description.
11 pub description: String,
12 /// JSON Schema for arguments.
13 pub input_schema: Value,
14 /// Runtime risk class, never inferred from an untrusted description.
15 pub action_class: ActionClass,
16}
17
18/// Structured provider-requested tool call.
19#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
20#[serde(rename_all = "camelCase")]
21pub struct ToolCall {
22 /// Provider call identifier.
23 pub id: String,
24 /// Registered tool name.
25 pub name: String,
26 /// Schema-validated arguments.
27 pub arguments: Value,
28 /// Contract criteria whose proof obligations justify this action.
29 #[serde(default, skip_serializing_if = "Vec::is_empty")]
30 pub obligation_ids: Vec<String>,
31}
32
33/// Structured runtime result returned to the provider.
34#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
35#[serde(rename_all = "camelCase")]
36pub struct ToolResult {
37 /// Original call identifier.
38 pub call_id: String,
39 /// Tool name.
40 pub name: String,
41 /// Whether invocation succeeded.
42 pub success: bool,
43 /// Public/redacted output.
44 pub output: Value,
45 /// Evidence node produced by the runtime.
46 #[serde(skip_serializing_if = "Option::is_none")]
47 pub evidence_id: Option<uuid::Uuid>,
48}
49
50/// Runtime-owned action classification.
51#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
52#[serde(rename_all = "snake_case")]
53pub enum ActionClass {
54 /// Reads workspace data without executing a process.
55 Read,
56 /// Runs diagnostics or tests that may create ignored artifacts.
57 Diagnose,
58 /// Modifies workspace files.
59 WorkspaceWrite,
60 /// Runs an arbitrary local process or shell.
61 Execute,
62 /// Accesses an external network service beyond the selected model provider.
63 Network,
64 /// Requests a budgeted child session and may merge a reviewed workspace handoff.
65 Delegate,
66 /// Destructive, credential, or out-of-workspace action.
67 Sensitive,
68}