flayer.diagnostics¶
flayer.diagnostics ¶
Safe diagnostic contracts with explicit provider and endpoint boundaries.
BenchmarkLimits
dataclass
¶
BenchmarkLimits(timeout_seconds: float = 3.0, count: int = 3, byte_limit: int = 64 * 1024)
EndpointMeasurement
dataclass
¶
EndpointMeasurement(status: DiagnosticStatus, duration_seconds: float, received_bytes: int = 0, http_status: int | None = None)
Safe metrics exclude response content, credentials, and target identifiers.
EndpointTransport ¶
Bases: Protocol
A measurement implementation enforces supplied limits without emitting raw data.
__call__ ¶
__call__(endpoint: str, timeout_seconds: float, byte_limit: int) -> EndpointMeasurement
Return one bounded HTTP measurement without exposing response payloads.
源代码位于: installed/flayer/diagnostics/benchmark.py
59 60 61 62 63 64 | |
CheckResult
dataclass
¶
CheckResult(name: str, status: DiagnosticStatus, message: str, details: Mapping[str, object] = dict())
One diagnostic observation with details that are sanitized at serialization.
details
class-attribute
instance-attribute
¶
details: Mapping[str, object] = field(default_factory=dict)
AsDict ¶
AsDict() -> dict[str, object]
Return stable JSON-compatible fields without arbitrary raw provider output.
源代码位于: installed/flayer/diagnostics/contracts.py
99 100 101 102 103 104 105 106 107 | |
DiagnosticReport
dataclass
¶
DiagnosticReport(command: str, checks: tuple[CheckResult, ...])
Versioned report whose aggregate outcome never hides failed checks.
Status
property
¶
Status: DiagnosticStatus
Return the most severe result, treating an empty report as unsupported.
ExitCode ¶
ExitCode() -> int
Return zero only when every requested observation succeeds.
源代码位于: installed/flayer/diagnostics/contracts.py
154 155 156 157 | |
AsDict ¶
AsDict() -> dict[str, object]
Expose the report schema and sanitized observations in deterministic order.
源代码位于: installed/flayer/diagnostics/contracts.py
159 160 161 162 163 164 165 166 167 | |
DiagnosticStatus ¶
Bases: str, Enum
Stable outcomes distinguish failure, expired evidence, and missing support.
HealthProbe ¶
Bases: Protocol
An adapter supplies read-only observations without transferring authorization.
__call__ ¶
__call__() -> CheckResult
Perform an adapter-bounded probe and return one structured observation.
源代码位于: installed/flayer/diagnostics/health.py
17 18 19 20 | |
MeasureEndpoint ¶
MeasureEndpoint(endpoint: str, timeout_seconds: float, byte_limit: int) -> EndpointMeasurement
Terminate isolated network work at the deadline, including a stalled DNS resolver.
源代码位于: installed/flayer/diagnostics/benchmark.py
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 | |
ProbeEndpoint ¶
ProbeEndpoint(endpoint: str, timeout_seconds: float = 3.0, transport: EndpointTransport = MeasureEndpoint) -> CheckResult
Check explicit HTTP reachability without pretending it validates guest hardening.
源代码位于: installed/flayer/diagnostics/benchmark.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
RunBenchmark ¶
RunBenchmark(endpoint: str, limits: BenchmarkLimits | None = None, transport: EndpointTransport = MeasureEndpoint) -> tuple[CheckResult, ...]
Measure a fixed count of bounded downloads without inferring upload or tunnel speed.
源代码位于: installed/flayer/diagnostics/benchmark.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
Redact ¶
Redact(value: object, _depth: int = 0) -> object
Recursively redact credential fields and common sensitive text before output.
源代码位于: installed/flayer/diagnostics/contracts.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 | |
EvaluateHealthReport ¶
EvaluateHealthReport(report: Mapping[str, object] | None, max_age_seconds: float = 300, current_time: float | None = None) -> CheckResult
Validate versioned health evidence and separate stale evidence from failed health.
源代码位于: installed/flayer/diagnostics/health.py
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 | |
ProviderStatus ¶
ProviderStatus(observation: Mapping[str, object] | None = None) -> CheckResult
Interpret a supplied generic provider observation without discovering resources.
源代码位于: installed/flayer/diagnostics/health.py
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 | |
RunChecks ¶
RunChecks(probes: Iterable[HealthProbe]) -> tuple[CheckResult, ...]
Collect injected observations and suppress raw exception text on probe failure.
源代码位于: installed/flayer/diagnostics/health.py
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 | |
RuntimeChecks ¶
RuntimeChecks() -> tuple[CheckResult, ...]
Check only supported Python execution; never imply remote infrastructure health.
源代码位于: installed/flayer/diagnostics/health.py
23 24 25 26 27 28 29 30 31 32 33 34 35 | |
RenderJson ¶
RenderJson(report: DiagnosticReport) -> str
Serialize only the versioned public report with deterministic JSON keys.
源代码位于: installed/flayer/diagnostics/reporting.py
8 9 10 11 | |
RenderText ¶
RenderText(report: DiagnosticReport) -> str
Render one safe single-line observation per check without raw details.
源代码位于: installed/flayer/diagnostics/reporting.py
14 15 16 17 18 19 20 21 22 23 24 | |