Skip to main content

tf_types/generated/
agent_contract.rs

1// GENERATED by `tf-schema codegen --target rust` — DO NOT EDIT BY HAND.
2
3#![allow(unused_imports, non_camel_case_types, non_snake_case, clippy::all)]
4
5use serde::{Deserialize, Serialize};
6use super::*;
7
8/// Single action declaration.
9#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
10pub struct Action {
11    pub name: ActionName,
12    pub risk: RiskClass,
13    #[serde(skip_serializing_if = "Option::is_none", default)]
14    pub proof: Option<ProofLevel>,
15    #[serde(skip_serializing_if = "Option::is_none", default)]
16    pub approval: Option<ApprovalRequirement>,
17    /// Human-readable purpose of the action.
18    #[serde(skip_serializing_if = "Option::is_none", default)]
19    pub description: Option<String>,
20    /// Glob patterns or @target-set references the action may target.
21    #[serde(skip_serializing_if = "Option::is_none", default)]
22    pub allow_targets: Option<Vec<String>>,
23    /// Glob patterns or @target-set references the action must not target.
24    #[serde(skip_serializing_if = "Option::is_none", default)]
25    pub deny_targets: Option<Vec<String>>,
26    /// Glob patterns matching caller actor URIs that MAY invoke this action. Empty / omitted means 'every authenticated actor is allowed' (subject to deny_actors and other guard rules). The matcher checks both the cryptographic actor URI (tf:actor:process:key/<thumbprint>) and the self-claimed peer_hint URI when present.
27    #[serde(skip_serializing_if = "Option::is_none", default)]
28    pub allow_actors: Option<Vec<String>>,
29    /// Glob patterns matching caller actor URIs that MUST NOT invoke this action. Overrides allow_actors. The matcher checks both the cryptographic actor URI and the self-claimed peer_hint URI.
30    #[serde(skip_serializing_if = "Option::is_none", default)]
31    pub deny_actors: Option<Vec<String>>,
32    /// Inline JSON Schema describing the parameters this action accepts.
33    #[serde(skip_serializing_if = "Option::is_none", default)]
34    pub parameters: Option<serde_json::Value>,
35    /// Hint that this action can be inverted by its counterpart.
36    #[serde(skip_serializing_if = "Option::is_none", default)]
37    pub reversible: Option<bool>,
38    /// Structured danger categories; AI agents MUST escalate on destructive / irreversible / financial / security-sensitive tags.
39    #[serde(skip_serializing_if = "Option::is_none", default)]
40    pub danger_tags: Option<Vec<DangerTag>>,
41    /// Named gates that must hold before this action may run.
42    #[serde(skip_serializing_if = "Option::is_none", default)]
43    pub pre_conditions: Option<Vec<String>>,
44    /// If reversible is false, a note on how the action can be undone out-of-band (e.g. via VCS).
45    #[serde(skip_serializing_if = "Option::is_none", default)]
46    pub reversal_note: Option<String>,
47}
48
49/// Declarative contract that makes a TrustForge-enabled codebase legible and safe for AI agents. See TF-0006.
50#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
51pub struct AgentContract {
52    /// Version of the agent-contract schema itself.
53    pub contract_version: AgentContract_ContractVersion,
54    /// TrustForge spec revision this contract conforms to.
55    pub spec_version: String,
56    /// Project identifier used in logs and contract references.
57    pub project: String,
58    /// The TrustForge trust domain this project belongs to.
59    #[serde(skip_serializing_if = "Option::is_none", default)]
60    pub trust_domain: Option<TrustDomain>,
61    /// Pointers to companion manifests.
62    #[serde(skip_serializing_if = "Option::is_none", default)]
63    pub references: Option<AgentContract_References>,
64    /// Named glob lists, reusable in action rules.
65    #[serde(skip_serializing_if = "Option::is_none", default)]
66    pub target_sets: Option<std::collections::BTreeMap<String, Vec<String>>>,
67    /// Declared actions this project allows agents to perform.
68    #[serde(skip_serializing_if = "Option::is_none", default)]
69    pub actions: Option<Vec<Action>>,
70    /// Actions this project forbids outright.
71    #[serde(skip_serializing_if = "Option::is_none", default)]
72    pub forbidden: Option<Vec<Forbidden>>,
73    /// Connections to MCP tools, ProofRPC services, and test commands.
74    #[serde(skip_serializing_if = "Option::is_none", default)]
75    pub integrations: Option<AgentContract_Integrations>,
76    /// Profiles this project claims.
77    #[serde(skip_serializing_if = "Option::is_none", default)]
78    pub conformance: Option<AgentContract_Conformance>,
79}
80
81/// Profiles this project claims.
82#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
83pub struct AgentContract_Conformance {
84    /// Claimed conformance profiles.
85    #[serde(skip_serializing_if = "Option::is_none", default)]
86    pub profiles: Option<Vec<String>>,
87}
88
89/// Version of the agent-contract schema itself.
90#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
91pub enum AgentContract_ContractVersion {
92    #[serde(rename = "1")]
93    V1,
94}
95
96/// Connections to MCP tools, ProofRPC services, and test commands.
97#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
98pub struct AgentContract_Integrations {
99    /// MCP tool integration descriptors.
100    #[serde(skip_serializing_if = "Option::is_none", default)]
101    pub mcp_tools: Option<Vec<serde_json::Value>>,
102    /// ProofRPC service integration descriptors.
103    #[serde(skip_serializing_if = "Option::is_none", default)]
104    pub proofrpc_services: Option<Vec<serde_json::Value>>,
105    /// Shell commands that exercise the project's tests.
106    #[serde(skip_serializing_if = "Option::is_none", default)]
107    pub test_commands: Option<Vec<String>>,
108}
109
110/// Pointers to companion manifests.
111#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
112pub struct AgentContract_References {
113    /// Path to the project's threat-model manifest.
114    #[serde(skip_serializing_if = "Option::is_none", default)]
115    pub threat_model: Option<String>,
116    /// Policy backend in use by this project.
117    #[serde(skip_serializing_if = "Option::is_none", default)]
118    pub policy_engine: Option<serde_json::Value>,
119    /// Standard actions library identifier, e.g. tf-actions-std@1.
120    #[serde(skip_serializing_if = "Option::is_none", default)]
121    pub actions_library: Option<String>,
122}
123
124/// Forbidden action entry.
125#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
126pub struct Forbidden {
127    pub action: ActionName,
128    /// Why this action is forbidden.
129    #[serde(skip_serializing_if = "Option::is_none", default)]
130    pub reason: Option<String>,
131}