Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
health_result.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstdint>
5#include <optional>
6#include <string>
7#include <string_view>
8#include <vector>
9
40
42inline constexpr std::string_view kSchemaV1 = "pulp.gpu-health-result.v1";
43inline constexpr std::uint32_t kVersionV1 = 1;
45inline constexpr std::string_view kSchema = "pulp.gpu-health-result.v2";
46inline constexpr std::uint32_t kVersion = 2;
47
49inline constexpr std::array kEvidenceCodes{
50 std::string_view{"gpu.adapter.fail"},
51 std::string_view{"gpu.adapter.null"},
52 std::string_view{"gpu.adapter.pass"},
53 std::string_view{"gpu.adapter.unavailable"},
54 std::string_view{"gpu.adapter.unverified"},
55 std::string_view{"gpu.compute.fail"},
56 std::string_view{"gpu.compute.pass"},
57 std::string_view{"gpu.compute.unavailable"},
58 std::string_view{"gpu.compute.unverified"},
59 std::string_view{"gpu.configuration.fail"},
60 std::string_view{"gpu.configuration.pass"},
61 std::string_view{"gpu.configuration.unavailable"},
62 std::string_view{"gpu.configuration.unverified"},
63 std::string_view{"gpu.content.fail"},
64 std::string_view{"gpu.content.pass"},
65 std::string_view{"gpu.content.unavailable"},
66 std::string_view{"gpu.content.unverified"},
67 std::string_view{"gpu.device_state.fail"},
68 std::string_view{"gpu.device_state.pass"},
69 std::string_view{"gpu.device_state.unavailable"},
70 std::string_view{"gpu.device_state.unverified"},
71 std::string_view{"gpu.pipeline_create.fail"},
72 std::string_view{"gpu.pipeline_create.pass"},
73 std::string_view{"gpu.pipeline_create.unavailable"},
74 std::string_view{"gpu.pipeline_create.unverified"},
75 std::string_view{"gpu.readback.fail"},
76 std::string_view{"gpu.readback.pass"},
77 std::string_view{"gpu.readback.unavailable"},
78 std::string_view{"gpu.readback.unverified"},
79 std::string_view{"gpu.render.fail"},
80 std::string_view{"gpu.render.pass"},
81 std::string_view{"gpu.render.unavailable"},
82 std::string_view{"gpu.render.unverified"},
83 std::string_view{"gpu.shader_compile.fail"},
84 std::string_view{"gpu.shader_compile.pass"},
85 std::string_view{"gpu.shader_compile.unavailable"},
86 std::string_view{"gpu.shader_compile.unverified"},
87 std::string_view{"gpu.submit.fail"},
88 std::string_view{"gpu.submit.pass"},
89 std::string_view{"gpu.submit.unavailable"},
90 std::string_view{"gpu.submit.unverified"},
91 std::string_view{"gpu_compute_adapter_acquired"},
92 std::string_view{"gpu_compute_adapter_identity_unverified"},
93 std::string_view{"gpu_compute_device_lost"},
94 std::string_view{"gpu_compute_execution_failed"},
95 std::string_view{"gpu_compute_initialization_unavailable"},
96 std::string_view{"gpu_compute_not_built"},
97 std::string_view{"gpu_compute_oracle_mismatch"},
98 std::string_view{"gpu_compute_oracle_passed"},
99 std::string_view{"render_not_requested"},
100 std::string_view{"renderer3d_adapter_unavailable"},
101 std::string_view{"renderer3d_blank_output"},
102 std::string_view{"renderer3d_content_floor_passed"},
103 std::string_view{"renderer3d_not_compiled"},
104 std::string_view{"renderer3d_setup_failed"},
105 std::string_view{"renderer3d_readback_completed"},
106 std::string_view{"renderer3d_readback_failed"},
107 std::string_view{"renderer3d_render_completed"},
108 std::string_view{"renderer3d_submit_completed"},
109 std::string_view{"skia_graphite_content_floor_passed"},
110 std::string_view{"skia_graphite_content_mismatch"},
111 std::string_view{"skia_graphite_frame_failed"},
112 std::string_view{"skia_graphite_readback_completed"},
113 std::string_view{"skia_graphite_render_completed"},
114 std::string_view{"skia_graphite_unavailable"},
115 std::string_view{"wgsl.async_uncaptured_error"},
116};
117
118constexpr bool is_known_evidence_code(std::string_view code) {
119 for (const auto candidate : kEvidenceCodes)
120 if (candidate == code) return true;
121 return false;
122}
123
131
145
148
151
154
159 std::optional<std::string> backend;
160 std::optional<std::string> name;
161 std::optional<std::string> vendor;
162 std::optional<std::string> architecture;
163 std::optional<std::string> device;
164};
165
171 std::optional<bool> command_submitted;
172 std::optional<bool> readback_completed;
173 std::optional<bool> pixel_output_produced;
174 std::optional<bool> content_floor_passed;
175 std::optional<bool> compute_initialized;
176 std::optional<bool> compute_oracle_passed;
177 std::optional<bool> device_lost;
178 std::optional<std::uint64_t> non_transparent_pixel_count;
179 std::optional<std::uint64_t> distinct_color_count;
180 std::optional<std::uint64_t> rgba_fingerprint;
181};
182
191
204
207 std::string schema{ kSchema };
208 std::uint32_t version = kVersion;
209 std::string run_id;
212 std::string measured_at_utc;
213 bool render_requested = true;
216 std::vector<ProbeEvidence> probes;
217 std::vector<std::string> recommendations;
218};
219
221std::string_view to_string(Verdict value);
222std::string_view to_string(Stage value);
223std::string_view to_string(AdapterClass value);
224std::string_view to_string(HealthState value);
225std::string_view to_string(IdentityStatus value);
226
228std::optional<Verdict> verdict_from_string(std::string_view value);
229std::optional<Stage> stage_from_string(std::string_view value);
230std::optional<AdapterClass> adapter_class_from_string(std::string_view value);
231std::optional<HealthState> health_state_from_string(std::string_view value);
232std::optional<IdentityStatus> identity_status_from_string(std::string_view value);
233
239bool validate(const HealthResult& result, std::string* error = nullptr);
240
244std::string to_json(const HealthResult& result, bool pretty = false);
245
250std::optional<HealthResult> from_json(std::string_view json,
251 std::string* error = nullptr);
252
253} // namespace pulp::tooling::gpu_health
Definition gpu_fwd.hpp:31
Bounded, typed evidence returned by Pulp GPU health diagnostics.
Definition health_provider.hpp:8
std::optional< HealthState > health_state_from_string(std::string_view value)
bool validate(const HealthReadResult &result, std::string *error=nullptr)
Validates bounds and cross-field claims that JSON Schema cannot express, including percentile derivat...
HealthState
Aggregate device state derived from required probe evidence.
Definition health_result.hpp:150
@ lost
Definition health_result.hpp:150
@ failed
Definition health_result.hpp:150
@ healthy
Definition health_result.hpp:150
@ unverified
Definition health_result.hpp:150
std::optional< Verdict > verdict_from_string(std::string_view value)
Parse an exact canonical enum spelling; unknown text returns std::nullopt.
constexpr std::array kEvidenceCodes
Canonical diagnostic-code registry shared by result v1/v2, CLI, MCP, and agents.
Definition health_result.hpp:49
std::optional< HealthResult > from_json(std::string_view json, std::string *error=nullptr)
Parse only the v1 closed shape and apply validate() before returning a value.
std::string_view to_string(MeasurementStatus value)
constexpr std::uint32_t kVersionV1
Definition health_result.hpp:43
IdentityStatus
Authenticity state for the optional native adapter identity fields.
Definition health_result.hpp:153
@ unavailable
Definition health_result.hpp:153
@ authentic
Definition health_result.hpp:153
@ unavailable
Definition health_read_result.hpp:20
@ unverified
Definition health_read_result.hpp:20
@ unknown
Definition health_read_result.hpp:25
constexpr std::uint32_t kVersion
Definition health_result.hpp:46
std::optional< AdapterClass > adapter_class_from_string(std::string_view value)
Verdict
Four-state outcome that keeps missing or inconclusive evidence out of pass.
Definition health_result.hpp:125
@ pass
Requested work completed and satisfied its oracle.
Definition health_result.hpp:126
@ unverified
Evidence exists but is insufficient to support a verdict.
Definition health_result.hpp:129
@ fail
Requested work completed and failed a measured assertion.
Definition health_result.hpp:127
std::optional< IdentityStatus > identity_status_from_string(std::string_view value)
std::string to_json(const HealthReadResult &result, bool pretty=false)
constexpr bool is_known_evidence_code(std::string_view code)
Definition health_result.hpp:118
constexpr std::string_view kSchema
Active schema identity emitted by new GPU-health runs.
Definition health_result.hpp:45
constexpr std::string_view kSchemaV1
Historical closed schema identity accepted when parsing stored v1 results.
Definition health_result.hpp:42
std::optional< Stage > stage_from_string(std::string_view value)
Stage
Ordered semantic stage described by one EvidenceEvent.
Definition health_result.hpp:133
@ device_state
Definition health_result.hpp:143
@ compute
Definition health_result.hpp:142
@ adapter
Definition health_result.hpp:135
@ content
Definition health_result.hpp:141
@ readback
Definition health_result.hpp:140
@ submit
Definition health_result.hpp:139
@ configuration
Definition health_result.hpp:134
@ shader_compile
Definition health_result.hpp:136
@ pipeline_create
Definition health_result.hpp:137
AdapterClass
Adapter class proven by native identity, never inferred from backend alone.
Definition health_result.hpp:147
@ hardware
Definition health_result.hpp:147
@ unknown
Definition health_result.hpp:147
@ software
Definition health_result.hpp:147
@ null_adapter
Definition health_result.hpp:147
Native adapter identity. Missing optional fields represent absent evidence.
Definition health_result.hpp:156
std::optional< std::string > name
Definition health_result.hpp:160
std::optional< std::string > backend
Definition health_result.hpp:159
std::optional< std::string > device
Definition health_result.hpp:163
std::optional< std::string > vendor
Definition health_result.hpp:161
AdapterClass classification
Definition health_result.hpp:158
std::optional< std::string > architecture
Definition health_result.hpp:162
IdentityStatus status
Definition health_result.hpp:157
One globally ordered stage observation with a registered diagnostic code.
Definition health_result.hpp:184
Stage stage
Definition health_result.hpp:186
std::string detail
Definition health_result.hpp:189
Verdict verdict
Definition health_result.hpp:187
std::uint32_t sequence
Definition health_result.hpp:185
std::string code
Definition health_result.hpp:188
Closed versioned aggregate returned by the GPU health diagnostic.
Definition health_result.hpp:206
std::string schema
Definition health_result.hpp:207
std::string measured_at_utc
UTC wall-clock time captured immediately before active probe execution.
Definition health_result.hpp:212
Verdict verdict
Definition health_result.hpp:214
std::vector< ProbeEvidence > probes
Definition health_result.hpp:216
std::uint32_t version
Definition health_result.hpp:208
HealthState health_state
Definition health_result.hpp:215
std::string run_id
Definition health_result.hpp:209
bool render_requested
Definition health_result.hpp:213
std::vector< std::string > recommendations
Definition health_result.hpp:217
Evidence and aggregate verdict for one independently executed probe.
Definition health_result.hpp:193
ProbeMeasurements measurements
Definition health_result.hpp:201
bool required
Whether this probe contributes to the top-level verdict.
Definition health_result.hpp:198
std::string probe_id
Definition health_result.hpp:194
Verdict verdict
Definition health_result.hpp:199
std::vector< EvidenceEvent > events
Definition health_result.hpp:202
AdapterIdentity adapter
Definition health_result.hpp:200
Optional measurements produced by one probe.
Definition health_result.hpp:170
std::optional< bool > compute_oracle_passed
Definition health_result.hpp:176
std::optional< bool > readback_completed
Definition health_result.hpp:172
std::optional< std::uint64_t > rgba_fingerprint
Definition health_result.hpp:180
std::optional< bool > compute_initialized
Definition health_result.hpp:175
std::optional< std::uint64_t > non_transparent_pixel_count
Definition health_result.hpp:178
std::optional< bool > content_floor_passed
Definition health_result.hpp:174
std::optional< bool > pixel_output_produced
Definition health_result.hpp:173
std::optional< bool > command_submitted
Definition health_result.hpp:171
std::optional< std::uint64_t > distinct_color_count
Definition health_result.hpp:179
std::optional< bool > device_lost
Definition health_result.hpp:177