API Reference: Safety¶
This section provides technical documentation for the safety modules, automatically generated from the source code.
Analyzer¶
safety.analyzer
¶
Classes¶
Finding
¶
Bases: BaseModel
Cryptographically signed finding package.
Source code in src/safety/analyzer.py
ModelArmor
¶
Simulates GCP Model Armor / Safety Guardrails. Sanitizes agent output before it reaches the consensus layer.
Source code in src/safety/analyzer.py
Functions¶
sanitize_finding(finding)
¶
Surgically redacts secrets and adds safety metadata.
Source code in src/safety/analyzer.py
VertexAIAnalyzer
¶
Hardened Agentic Analyzer using Vertex AI (Gemini) for incident root-cause analysis. Supports both research simulation and production GCP modes with exponential backoff.
Source code in src/safety/analyzer.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
Functions¶
analyze_logs(logs, mode='simulate')
¶
Analyzes logs to detect incidents and propose remediation.
Source code in src/safety/analyzer.py
fetch_and_analyze(query, log_source, limit=100, mode='simulate')
¶
Fetches logs using the injected LogSourcePort and processes them.
Source code in src/safety/analyzer.py
sign_finding(finding)
¶
Signs the finding using the agent's private RSA key.
Source code in src/safety/analyzer.py
Functions¶
Voting¶
safety.voting
¶
Classes¶
ValidationError
¶
Bases: Exception
Custom exception with context for validation failures.
Source code in src/safety/voting.py
VotingValidator
¶
Validates agent signatures against a registered public key list to verify a quorum threshold has been reached.
Source code in src/safety/voting.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
Functions¶
register_agent(agent_id, public_key_pem)
¶
Registers an authorized agent with its public key.
Source code in src/safety/voting.py
verify_quorum(proposal, signatures)
¶
Verifies that a majority of registered agents signed the proposal.
Source code in src/safety/voting.py
Functions¶
Safety Gate¶
safety.safety_gate
¶
Classes¶
ActionProposal
¶
Bases: BaseModel
Schema for a remediation proposal.
Source code in src/safety/safety_gate.py
GateResult
¶
Bases: BaseModel
Rich result object for safety evaluations.
Source code in src/safety/safety_gate.py
SafetyConfig
¶
Bases: BaseSettings
Deterministic safety boundaries. Loads from environment variables with SAFETY_ prefix.
Source code in src/safety/safety_gate.py
SafetyGate
¶
Deterministic Safety Validation Gate. Enforces resource quotas, cost limits, and operational restrictions.
Source code in src/safety/safety_gate.py
Functions¶
evaluate(raw_proposal)
¶
Validates a proposal against resource, operational, and cost boundaries.
Source code in src/safety/safety_gate.py
Functions¶
Remediator¶
safety.remediator
¶
Classes¶
DryRunRemediator
¶
Bases: ActuationPort
Verified actuator that checks voting quorum and safety gates before 'execution'.
Source code in src/safety/remediator.py
Functions¶
apply_patch(target, operation, params)
¶
Implements the ActuationPort interface.
process_proposal(finding, signatures)
¶
Verifies and processes a remediation proposal based on agent quorum.
Source code in src/safety/remediator.py
verify_remediation_signatures(finding, agent_sigs)
¶
Enforces cryptographic signature validation. Fails closed if the payload has not achieved quorum verification.
Source code in src/safety/remediator.py
Functions¶
Runtime Security¶
safety.security
¶
Classes¶
RuntimeSecurity
¶
Verifies cryptographic identity of agents.
Source code in src/safety/security.py
Functions¶
check_freshness(timestamp, max_age_seconds=60)
¶
verify_runtime_attestation(attestation_report, signature)
¶
Verifies that the runtime attestation report was signed by the trusted platform (e.g. simulated TPM or Cloud HSM). NOTE: In production, the public key should be fetched from GCP Secret Manager or a KMS-backed Identity Provider with automated rotation enabled.