Public declaration syntax from forge-rs/crates/forge-contracts/src/telemetry.rs Original source SHA-256: 79c60c491d207d88c22a813f3472bd9ad5f4374cbbc3c4b833d3e6d1fcd82be3 Function bodies and constant values are omitted. This is not the complete implementation. Source line 46 pub const CONTRACT_VERSION: &str; Source line 50 #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct SpanFilter { /// Filter by agent DID. pub agent_did: Option, /// Filter by span name prefix (e.g., "anvil.tool."). pub name_prefix: Option, /// Filter by time range start (inclusive). pub from: Option>, /// Filter by time range end (exclusive). pub to: Option>, /// Filter by organization. pub org_id: Option, /// Filter by department. pub department_id: Option, /// Maximum number of spans to return. pub limit: Option } Source line 75 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CollectedSpan { /// Unique span identifier. pub span_id: String, /// Optional parent span ID. pub parent_span_id: Option, /// The span name (e.g., "anvil.generate", "anvil.tool.invoke"). pub name: String, /// The agent DID that emitted this span. pub agent_did: String, /// Start timestamp. pub started_at: DateTime, /// End timestamp. pub ended_at: Option>, /// Duration in microseconds. pub duration_us: Option, /// Span attributes as key-value pairs. pub attributes: BTreeMap } Source line 103 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct AuditEntry { /// Sequential entry index. pub index: u64, /// The agent DID that created this entry. pub agent_did: String, /// The event kind. pub event_kind: String, /// The event payload as JSON. pub payload: serde_json::Value, /// ISO 8601 timestamp. pub timestamp: DateTime, /// Ed25519 signature (base64-encoded). pub signature: String } Source line 125 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct HealthSummary { /// The scope identifier (org ID, department ID, or team ID). pub scope_id: String, /// The scope type. pub scope_type: HealthScopeType, /// Overall health status for this scope. pub overall_status: HealthStatus, /// Number of agents in each lifecycle state. pub lifecycle_counts: BTreeMap, /// Number of agents at each health level. pub health_counts: HealthCounts, /// Total active agents in this scope. pub total_agents: u32, /// Total tool invocations across all agents. pub total_tool_invocations: u64, /// Total inference calls across all agents. pub total_inference_calls: u64, /// Total tokens consumed across all agents. pub total_tokens: u64, /// Estimated total cost in USD. pub estimated_cost_usd: f64, /// When this summary was last computed. pub computed_at: DateTime } Source line 162 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum HealthScopeType { /// Organization-wide summary. Organization, /// Department-level summary. Department, /// Team-level summary. Team, } Source line 173 #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct HealthCounts { /// Number of agents in Healthy state. pub healthy: u32, /// Number of agents in Degraded state. pub degraded: u32, /// Number of agents in Critical state. pub critical: u32 } Source line 199 #[async_trait] pub trait OrgTelemetryContract: Send + Sync { /// Queries collected spans with filtering. /// /// # Arguments /// /// * `filter` - Criteria for filtering spans. /// /// # Returns /// /// Matching spans ordered by start time. async fn query_spans(&self, filter: SpanFilter) -> ContractResult>; /// Returns the audit trail for an agent. /// /// # Arguments /// /// * `agent_did` - The agent whose audit trail to retrieve. /// * `from_index` - Start reading from this entry index. /// * `limit` - Maximum entries to return. /// /// # Returns /// /// Audit entries in sequential order. async fn get_audit_trail( &self, agent_did: &str, from_index: u64, limit: u32, ) -> ContractResult>; /// Returns the audit trail for an entire organization. /// /// # Arguments /// /// * `org_id` - The organization to query. /// * `from` - Start time (inclusive). /// * `to` - End time (exclusive). /// * `limit` - Maximum entries to return. async fn get_org_audit_trail( &self, org_id: &str, from: DateTime, to: DateTime, limit: u32, ) -> ContractResult>; } Source line 261 #[async_trait] pub trait OrgHealthContract: Send + Sync { /// Returns a health summary for an organizational scope. /// /// # Arguments /// /// * `org_id` - The organization. /// * `scope_type` - The scope level (org, department, or team). /// * `scope_id` - The scope identifier. For `Organization`, this /// is the org ID. For `Department`, the department ID, etc. /// /// # Returns /// /// Aggregated health summary for all agents in the scope. async fn get_health_summary( &self, org_id: &str, scope_type: HealthScopeType, scope_id: &str, ) -> ContractResult; /// Returns health summaries for all departments in an organization. /// /// # Arguments /// /// * `org_id` - The organization to query. /// /// # Returns /// /// One summary per department. async fn get_all_department_health(&self, org_id: &str) -> ContractResult>; /// Returns the health status of a specific agent. /// /// # Arguments /// /// * `agent_did` - The agent to query. async fn get_agent_health(&self, agent_did: &str) -> ContractResult; }