ForgeHealth
Swift ForgeHealth library product.
Swift ForgeHealth library product.
Package contract
| Field | Value |
|---|---|
| Language | swift |
| Source version | Swift package source snapshot |
| Manifest | forge-swift/Package.swift |
| Source files | 5 |
| Evidence | Source reference; registry publication and runtime conformance are separate checks |
Import boundary
import ForgeHealthUse a source checkout or your verified private registry. Manifest coordinates identify the package; they do not establish that a public registry release exists.
Source reference
Download package reference JSON. Each original source file and generated declaration artifact has its own SHA-256 digest. Function bodies and constant values are omitted from downloads. These are source declaration inventories, not compiler-resolved rustdoc, TypeDoc, DocC, or Dokka output. Private modules can contain public declarations that are not reachable through the package boundary; consult the entry point before importing.
Events.swift
Read declaration text · 9 declaration entries
public struct LifecycleEvent: Codable, Sendable
public let from: LifecycleState
/// The state after the transition.
public let to: LifecycleState
/// When the transition occurred.
public let timestamp: Timestamp
/// Optional reason for the transition.
public let reason: String?
/// The agent DID (if available).
public let agentDid: String?
public init(
from: LifecycleState,
to: LifecycleState,
timestamp: Timestamp;
public let to: LifecycleState
/// When the transition occurred.
public let timestamp: Timestamp
/// Optional reason for the transition.
public let reason: String?
/// The agent DID (if available).
public let agentDid: String?
public init(
from: LifecycleState,
to: LifecycleState,
timestamp: Timestamp;
public let timestamp: Timestamp
/// Optional reason for the transition.
public let reason: String?
/// The agent DID (if available).
public let agentDid: String?
public init(
from: LifecycleState,
to: LifecycleState,
timestamp: Timestamp;
public let reason: String?
/// The agent DID (if available).
public let agentDid: String?
public init(
from: LifecycleState,
to: LifecycleState,
timestamp: Timestamp;
public let agentDid: String?
public init(
from: LifecycleState,
to: LifecycleState,
timestamp: Timestamp;
public init(
from: LifecycleState,
to: LifecycleState,
timestamp: Timestamp;
public static func from(
transition: LifecycleTransition,
reason: String?;
public func toForgeEvent() -> ForgeEventLifecycle.swift
Read declaration text · 19 declaration entries
public enum LifecycleState: String, Codable, Sendable, Hashable, CaseIterable
public var validTransitions: [LifecycleState]
public var isTerminal: Bool
public var isOperational: Bool
public var description: String
public struct LifecycleTransition: Codable, Sendable
public let from: LifecycleState
/// The state after the transition.
public let to: LifecycleState
/// The UTC timestamp when the transition occurred.
public let timestamp: Timestamp
public init(from: LifecycleState, to: LifecycleState, timestamp: Timestamp)
public let to: LifecycleState
/// The UTC timestamp when the transition occurred.
public let timestamp: Timestamp
public init(from: LifecycleState, to: LifecycleState, timestamp: Timestamp)
public let timestamp: Timestamp
public init(from: LifecycleState, to: LifecycleState, timestamp: Timestamp)
public init(from: LifecycleState, to: LifecycleState, timestamp: Timestamp)
public enum LifecycleError: Error, Sendable, Equatable
public var errorDescription: String?
public final class LifecycleManager: @unchecked Sendable
public init()
public var state: LifecycleState
public func transition(to target: LifecycleState) throws -> LifecycleTransition
public func canTransition(to target: LifecycleState) -> Bool
public func validTransitions() -> [LifecycleState]
public func history() -> [LifecycleTransition]Monitoring.swift
Read declaration text · 22 declaration entries
public struct HealthThresholds: Codable, Sendable, Equatable
public var degradedErrorCount: UInt64
/// Maximum error count before critical status.
public var criticalErrorCount: UInt64
/// Minimum tool success rate for healthy status (0.0 to 1.0).
public var minToolSuccessRate: Double
/// Minimum tool success rate for degraded (below this is critical) (0.0 to 1.0).
public var criticalToolSuccessRate: Double
/// Maximum error rate before degraded status (0.0 to 1.0).
public var degradedErrorRate: Double
/// Maximum error rate before critical status (0.0 to 1.0).
public var criticalErrorRate: Double
/// Creates thresholds with sensible defaults.
public init(
degradedErrorCount: UInt64;
public var criticalErrorCount: UInt64
/// Minimum tool success rate for healthy status (0.0 to 1.0).
public var minToolSuccessRate: Double
/// Minimum tool success rate for degraded (below this is critical) (0.0 to 1.0).
public var criticalToolSuccessRate: Double
/// Maximum error rate before degraded status (0.0 to 1.0).
public var degradedErrorRate: Double
/// Maximum error rate before critical status (0.0 to 1.0).
public var criticalErrorRate: Double
/// Creates thresholds with sensible defaults.
public init(
degradedErrorCount: UInt64;
public var minToolSuccessRate: Double
/// Minimum tool success rate for degraded (below this is critical) (0.0 to 1.0).
public var criticalToolSuccessRate: Double
/// Maximum error rate before degraded status (0.0 to 1.0).
public var degradedErrorRate: Double
/// Maximum error rate before critical status (0.0 to 1.0).
public var criticalErrorRate: Double
/// Creates thresholds with sensible defaults.
public init(
degradedErrorCount: UInt64;
public var criticalToolSuccessRate: Double
/// Maximum error rate before degraded status (0.0 to 1.0).
public var degradedErrorRate: Double
/// Maximum error rate before critical status (0.0 to 1.0).
public var criticalErrorRate: Double
/// Creates thresholds with sensible defaults.
public init(
degradedErrorCount: UInt64;
public var degradedErrorRate: Double
/// Maximum error rate before critical status (0.0 to 1.0).
public var criticalErrorRate: Double
/// Creates thresholds with sensible defaults.
public init(
degradedErrorCount: UInt64;
public var criticalErrorRate: Double
/// Creates thresholds with sensible defaults.
public init(
degradedErrorCount: UInt64;
public init(
degradedErrorCount: UInt64;
public final class HealthMonitor: @unchecked Sendable
public init(thresholds: HealthThresholds;
public var profile: HealthProfile
public func recordToolInvocation(success: Bool;
public func recordInference(tokens: UInt64)
public func recordError()
public func recordLifecycleTransition()
public func recordTaskStarted()
public func recordTaskCompleted()
public func recordGenerationSuccess()
public func recordGenerationFailure()
public func updateResources(cpu: Double, memory: UInt64)
public func updateUptime(_ seconds: UInt64)
public func checkHealth() -> HealthStatusProfile.swift
Read declaration text · 31 declaration entries
public struct HealthProfile: Codable, Sendable, Equatable
public var createdAt: Timestamp
/// Total uptime of the agent in seconds.
public var uptimeSeconds: UInt64
/// Total number of tool invocations.
public var toolInvocations: UInt64
/// Total number of successful tool invocations.
public var toolSuccesses: UInt64
/// Total number of failed tool invocations.
public var toolFailures: UInt64
/// Total number of inference calls.
public var inferenceCalls: UInt64
/// Total tokens consumed across all inference calls.
public var totalTokens: UInt64
/// Total number of errors encountered.
public var errorCount: UInt64
/// Total number of lifecycle transitions.
public var lifecycleTransitions: UInt64
/// Current CPU usage as a percentage (0.0 to 100.0).
public var cpuUsagePercent: Double
/// Current memory usage in bytes.
public var memoryUsageBytes: UInt64
/// Number of currently active (in-flight) tasks.
///
/// Incremented by `recordTaskStarted`, decremented by `recordTaskCompleted`.
/// This gauge can reach zero and will not go below zero (saturating subtraction).
public var activeTasks: UInt32
public var uptimeSeconds: UInt64
/// Total number of tool invocations.
public var toolInvocations: UInt64
/// Total number of successful tool invocations.
public var toolSuccesses: UInt64
/// Total number of failed tool invocations.
public var toolFailures: UInt64
/// Total number of inference calls.
public var inferenceCalls: UInt64
/// Total tokens consumed across all inference calls.
public var totalTokens: UInt64
/// Total number of errors encountered.
public var errorCount: UInt64
/// Total number of lifecycle transitions.
public var lifecycleTransitions: UInt64
/// Current CPU usage as a percentage (0.0 to 100.0).
public var cpuUsagePercent: Double
/// Current memory usage in bytes.
public var memoryUsageBytes: UInt64
/// Number of currently active (in-flight) tasks.
///
/// Incremented by `recordTaskStarted`, decremented by `recordTaskCompleted`.
/// This gauge can reach zero and will not go below zero (saturating subtraction).
public var activeTasks: UInt32
/// Total number of tasks completed during the agent's lifetime.
///
public var toolInvocations: UInt64
/// Total number of successful tool invocations.
public var toolSuccesses: UInt64
/// Total number of failed tool invocations.
public var toolFailures: UInt64
/// Total number of inference calls.
public var inferenceCalls: UInt64
/// Total tokens consumed across all inference calls.
public var totalTokens: UInt64
/// Total number of errors encountered.
public var errorCount: UInt64
/// Total number of lifecycle transitions.
public var lifecycleTransitions: UInt64
/// Current CPU usage as a percentage (0.0 to 100.0).
public var cpuUsagePercent: Double
/// Current memory usage in bytes.
public var memoryUsageBytes: UInt64
/// Number of currently active (in-flight) tasks.
///
/// Incremented by `recordTaskStarted`, decremented by `recordTaskCompleted`.
/// This gauge can reach zero and will not go below zero (saturating subtraction).
public var activeTasks: UInt32
/// Total number of tasks completed during the agent's lifetime.
///
/// This counter is monotonically increasing.
public var completedTasks: UInt64
public var toolSuccesses: UInt64
/// Total number of failed tool invocations.
public var toolFailures: UInt64
/// Total number of inference calls.
public var inferenceCalls: UInt64
/// Total tokens consumed across all inference calls.
public var totalTokens: UInt64
/// Total number of errors encountered.
public var errorCount: UInt64
/// Total number of lifecycle transitions.
public var lifecycleTransitions: UInt64
/// Current CPU usage as a percentage (0.0 to 100.0).
public var cpuUsagePercent: Double
/// Current memory usage in bytes.
public var memoryUsageBytes: UInt64
/// Number of currently active (in-flight) tasks.
///
/// Incremented by `recordTaskStarted`, decremented by `recordTaskCompleted`.
/// This gauge can reach zero and will not go below zero (saturating subtraction).
public var activeTasks: UInt32
/// Total number of tasks completed during the agent's lifetime.
///
/// This counter is monotonically increasing.
public var completedTasks: UInt64
/// Current error rate as a fraction (0.0 to 1.0).
///
public var toolFailures: UInt64
/// Total number of inference calls.
public var inferenceCalls: UInt64
/// Total tokens consumed across all inference calls.
public var totalTokens: UInt64
/// Total number of errors encountered.
public var errorCount: UInt64
/// Total number of lifecycle transitions.
public var lifecycleTransitions: UInt64
/// Current CPU usage as a percentage (0.0 to 100.0).
public var cpuUsagePercent: Double
/// Current memory usage in bytes.
public var memoryUsageBytes: UInt64
/// Number of currently active (in-flight) tasks.
///
/// Incremented by `recordTaskStarted`, decremented by `recordTaskCompleted`.
/// This gauge can reach zero and will not go below zero (saturating subtraction).
public var activeTasks: UInt32
/// Total number of tasks completed during the agent's lifetime.
///
/// This counter is monotonically increasing.
public var completedTasks: UInt64
/// Current error rate as a fraction (0.0 to 1.0).
///
/// Computed as `errors / (errors + successes)` across all generation calls.
public var errorRate: Double
public var inferenceCalls: UInt64
/// Total tokens consumed across all inference calls.
public var totalTokens: UInt64
/// Total number of errors encountered.
public var errorCount: UInt64
/// Total number of lifecycle transitions.
public var lifecycleTransitions: UInt64
/// Current CPU usage as a percentage (0.0 to 100.0).
public var cpuUsagePercent: Double
/// Current memory usage in bytes.
public var memoryUsageBytes: UInt64
/// Number of currently active (in-flight) tasks.
///
/// Incremented by `recordTaskStarted`, decremented by `recordTaskCompleted`.
/// This gauge can reach zero and will not go below zero (saturating subtraction).
public var activeTasks: UInt32
/// Total number of tasks completed during the agent's lifetime.
///
/// This counter is monotonically increasing.
public var completedTasks: UInt64
/// Current error rate as a fraction (0.0 to 1.0).
///
/// Computed as `errors / (errors + successes)` across all generation calls.
public var errorRate: Double
/// Average latency of completed operations in milliseconds.
public var avgLatencyMs: Double
public var totalTokens: UInt64
/// Total number of errors encountered.
public var errorCount: UInt64
/// Total number of lifecycle transitions.
public var lifecycleTransitions: UInt64
/// Current CPU usage as a percentage (0.0 to 100.0).
public var cpuUsagePercent: Double
/// Current memory usage in bytes.
public var memoryUsageBytes: UInt64
/// Number of currently active (in-flight) tasks.
///
/// Incremented by `recordTaskStarted`, decremented by `recordTaskCompleted`.
/// This gauge can reach zero and will not go below zero (saturating subtraction).
public var activeTasks: UInt32
/// Total number of tasks completed during the agent's lifetime.
///
/// This counter is monotonically increasing.
public var completedTasks: UInt64
/// Current error rate as a fraction (0.0 to 1.0).
///
/// Computed as `errors / (errors + successes)` across all generation calls.
public var errorRate: Double
/// Average latency of completed operations in milliseconds.
public var avgLatencyMs: Double
/// Tool invocation success rate as a fraction (0.0 to 1.0).
///
public var errorCount: UInt64
/// Total number of lifecycle transitions.
public var lifecycleTransitions: UInt64
/// Current CPU usage as a percentage (0.0 to 100.0).
public var cpuUsagePercent: Double
/// Current memory usage in bytes.
public var memoryUsageBytes: UInt64
/// Number of currently active (in-flight) tasks.
///
/// Incremented by `recordTaskStarted`, decremented by `recordTaskCompleted`.
/// This gauge can reach zero and will not go below zero (saturating subtraction).
public var activeTasks: UInt32
/// Total number of tasks completed during the agent's lifetime.
///
/// This counter is monotonically increasing.
public var completedTasks: UInt64
/// Current error rate as a fraction (0.0 to 1.0).
///
/// Computed as `errors / (errors + successes)` across all generation calls.
public var errorRate: Double
/// Average latency of completed operations in milliseconds.
public var avgLatencyMs: Double
/// Tool invocation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all tool invocations.
public var toolSuccessRate: Double
public var lifecycleTransitions: UInt64
/// Current CPU usage as a percentage (0.0 to 100.0).
public var cpuUsagePercent: Double
/// Current memory usage in bytes.
public var memoryUsageBytes: UInt64
/// Number of currently active (in-flight) tasks.
///
/// Incremented by `recordTaskStarted`, decremented by `recordTaskCompleted`.
/// This gauge can reach zero and will not go below zero (saturating subtraction).
public var activeTasks: UInt32
/// Total number of tasks completed during the agent's lifetime.
///
/// This counter is monotonically increasing.
public var completedTasks: UInt64
/// Current error rate as a fraction (0.0 to 1.0).
///
/// Computed as `errors / (errors + successes)` across all generation calls.
public var errorRate: Double
/// Average latency of completed operations in milliseconds.
public var avgLatencyMs: Double
/// Tool invocation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all tool invocations.
public var toolSuccessRate: Double
/// Generation success rate as a fraction (0.0 to 1.0).
///
public var cpuUsagePercent: Double
/// Current memory usage in bytes.
public var memoryUsageBytes: UInt64
/// Number of currently active (in-flight) tasks.
///
/// Incremented by `recordTaskStarted`, decremented by `recordTaskCompleted`.
/// This gauge can reach zero and will not go below zero (saturating subtraction).
public var activeTasks: UInt32
/// Total number of tasks completed during the agent's lifetime.
///
/// This counter is monotonically increasing.
public var completedTasks: UInt64
/// Current error rate as a fraction (0.0 to 1.0).
///
/// Computed as `errors / (errors + successes)` across all generation calls.
public var errorRate: Double
/// Average latency of completed operations in milliseconds.
public var avgLatencyMs: Double
/// Tool invocation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all tool invocations.
public var toolSuccessRate: Double
/// Generation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all generation calls.
public var generationSuccessRate: Double
public var memoryUsageBytes: UInt64
/// Number of currently active (in-flight) tasks.
///
/// Incremented by `recordTaskStarted`, decremented by `recordTaskCompleted`.
/// This gauge can reach zero and will not go below zero (saturating subtraction).
public var activeTasks: UInt32
/// Total number of tasks completed during the agent's lifetime.
///
/// This counter is monotonically increasing.
public var completedTasks: UInt64
/// Current error rate as a fraction (0.0 to 1.0).
///
/// Computed as `errors / (errors + successes)` across all generation calls.
public var errorRate: Double
/// Average latency of completed operations in milliseconds.
public var avgLatencyMs: Double
/// Tool invocation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all tool invocations.
public var toolSuccessRate: Double
/// Generation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all generation calls.
public var generationSuccessRate: Double
/// Timestamp of the last profile update.
public var lastUpdated: Timestamp
public var activeTasks: UInt32
/// Total number of tasks completed during the agent's lifetime.
///
/// This counter is monotonically increasing.
public var completedTasks: UInt64
/// Current error rate as a fraction (0.0 to 1.0).
///
/// Computed as `errors / (errors + successes)` across all generation calls.
public var errorRate: Double
/// Average latency of completed operations in milliseconds.
public var avgLatencyMs: Double
/// Tool invocation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all tool invocations.
public var toolSuccessRate: Double
/// Generation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all generation calls.
public var generationSuccessRate: Double
/// Timestamp of the last profile update.
public var lastUpdated: Timestamp
/// Internal counter for generation successes (used to compute rates).
private var generationSuccesses: UInt64
/// Internal counter for generation failures (used to compute rates).
private var generationFailures: UInt64
public var completedTasks: UInt64
/// Current error rate as a fraction (0.0 to 1.0).
///
/// Computed as `errors / (errors + successes)` across all generation calls.
public var errorRate: Double
/// Average latency of completed operations in milliseconds.
public var avgLatencyMs: Double
/// Tool invocation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all tool invocations.
public var toolSuccessRate: Double
/// Generation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all generation calls.
public var generationSuccessRate: Double
/// Timestamp of the last profile update.
public var lastUpdated: Timestamp
/// Internal counter for generation successes (used to compute rates).
private var generationSuccesses: UInt64
/// Internal counter for generation failures (used to compute rates).
private var generationFailures: UInt64
/// Creates a new health profile with zeroed counters and the given creation time.
public init()
public var errorRate: Double
/// Average latency of completed operations in milliseconds.
public var avgLatencyMs: Double
/// Tool invocation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all tool invocations.
public var toolSuccessRate: Double
/// Generation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all generation calls.
public var generationSuccessRate: Double
/// Timestamp of the last profile update.
public var lastUpdated: Timestamp
/// Internal counter for generation successes (used to compute rates).
private var generationSuccesses: UInt64
/// Internal counter for generation failures (used to compute rates).
private var generationFailures: UInt64
/// Creates a new health profile with zeroed counters and the given creation time.
public init()
public var avgLatencyMs: Double
/// Tool invocation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all tool invocations.
public var toolSuccessRate: Double
/// Generation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all generation calls.
public var generationSuccessRate: Double
/// Timestamp of the last profile update.
public var lastUpdated: Timestamp
/// Internal counter for generation successes (used to compute rates).
private var generationSuccesses: UInt64
/// Internal counter for generation failures (used to compute rates).
private var generationFailures: UInt64
/// Creates a new health profile with zeroed counters and the given creation time.
public init()
public var toolSuccessRate: Double
/// Generation success rate as a fraction (0.0 to 1.0).
///
/// Computed as `successes / total` across all generation calls.
public var generationSuccessRate: Double
/// Timestamp of the last profile update.
public var lastUpdated: Timestamp
/// Internal counter for generation successes (used to compute rates).
private var generationSuccesses: UInt64
/// Internal counter for generation failures (used to compute rates).
private var generationFailures: UInt64
/// Creates a new health profile with zeroed counters and the given creation time.
public init()
public var generationSuccessRate: Double
/// Timestamp of the last profile update.
public var lastUpdated: Timestamp
/// Internal counter for generation successes (used to compute rates).
private var generationSuccesses: UInt64
/// Internal counter for generation failures (used to compute rates).
private var generationFailures: UInt64
/// Creates a new health profile with zeroed counters and the given creation time.
public init()
public var lastUpdated: Timestamp
/// Internal counter for generation successes (used to compute rates).
private var generationSuccesses: UInt64
/// Internal counter for generation failures (used to compute rates).
private var generationFailures: UInt64
/// Creates a new health profile with zeroed counters and the given creation time.
public init()
public init()
public mutating func recordToolInvocation(success: Bool;
public mutating func recordInference(tokens: UInt64)
public mutating func recordError()
public mutating func recordLifecycleTransition()
public mutating func updateResources(cpu: Double, memory: UInt64)
public mutating func updateUptime(_ seconds: UInt64)
public mutating func recordTaskStarted()
public mutating func recordTaskCompleted()
public mutating func recordGenerationSuccess()
public mutating func recordGenerationFailure()
public var averageTokensPerCall: Double?Reporting.swift
Read declaration text · 10 declaration entries
public enum HealthStatus: Sendable, Equatable
public var description: String
public struct HealthReport: Sendable
public let profile: HealthProfile
/// The current lifecycle state.
public let lifecycleState: LifecycleState
/// The assessed health status.
public let status: HealthStatus
/// When this report was generated.
public let generatedAt: Timestamp
/// Creates a new health report.
///
/// - Parameters:
/// - profile: The current health profile.
/// - lifecycleState: The current lifecycle state.
/// - status: The assessed health status.
public init(profile: HealthProfile, lifecycleState: LifecycleState, status: HealthStatus)
public let lifecycleState: LifecycleState
/// The assessed health status.
public let status: HealthStatus
/// When this report was generated.
public let generatedAt: Timestamp
/// Creates a new health report.
///
/// - Parameters:
/// - profile: The current health profile.
/// - lifecycleState: The current lifecycle state.
/// - status: The assessed health status.
public init(profile: HealthProfile, lifecycleState: LifecycleState, status: HealthStatus)
public let status: HealthStatus
/// When this report was generated.
public let generatedAt: Timestamp
/// Creates a new health report.
///
/// - Parameters:
/// - profile: The current health profile.
/// - lifecycleState: The current lifecycle state.
/// - status: The assessed health status.
public init(profile: HealthProfile, lifecycleState: LifecycleState, status: HealthStatus)
public let generatedAt: Timestamp
/// Creates a new health report.
///
/// - Parameters:
/// - profile: The current health profile.
/// - lifecycleState: The current lifecycle state.
/// - status: The assessed health status.
public init(profile: HealthProfile, lifecycleState: LifecycleState, status: HealthStatus)
public init(profile: HealthProfile, lifecycleState: LifecycleState, status: HealthStatus)
public var isHealthy: Bool
public func generateHealthReport(
lifecycle: LifecycleManager,
monitor: HealthMonitor
) -> HealthReport