Skip to main content

ValidationReport Class

Report produced by running a ContractRegistry. More...

Declaration

class simaai::neat::ValidationReport { ... }

Included Headers

#include <ValidationReport.h>

Public Constructors Index

ValidationReport ()=default

Construct an empty report. More...

Public Member Functions Index

voidadd_issue (ValidationIssue issue)

Append an issue to the report. More...

voidadd_info (std::string contract_id, std::string code, std::string msg, int node_index=-1, std::string node_kind={}, std::string node_label={})

Append an Info issue. More...

voidadd_warning (std::string contract_id, std::string code, std::string msg, int node_index=-1, std::string node_kind={}, std::string node_label={})

Append a Warning issue. More...

voidadd_error (std::string contract_id, std::string code, std::string msg, int node_index=-1, std::string node_kind={}, std::string node_label={})

Append an Error issue. More...

voidnote_contract_run (std::string id)

Record that a contract id participated in this validation pass. More...

voidset_mode (int mode)

Record which Session mode produced this report (integer to avoid Contract.h include). More...

intmode () const

Mode integer set via set_mode(). More...

const std::vector< ValidationIssue > &issues () const noexcept

All issues collected, in insertion order. More...

const std::vector< std::string > &contracts_run () const noexcept

Ids of all contracts that ran (in evaluation order). More...

boolok () const noexcept

True if the report contains no errors (warnings/info are still allowed). More...

boolhas_errors () const noexcept

True if at least one issue with Error severity is present. More...

std::size_terror_count () const noexcept

Count of Error issues in the report. More...

std::size_twarning_count () const noexcept

Count of Warning issues in the report. More...

std::size_tinfo_count () const noexcept

Count of Info issues in the report. More...

std::stringto_string () const

Render the report as a deterministic, human-readable text block. More...

std::stringto_json () const

Serialize the report as a JSON string (CI/dashboard-friendly). More...

Private Member Attributes Index

intmode_ = 0
std::vector< std::string >contracts_run_
std::vector< ValidationIssue >issues_

Private Static Functions Index

static std::stringjson_escape_ (const std::string &s)

Description

Report produced by running a ContractRegistry.

Aggregates all issues emitted by every contract that was run, plus the list of contract ids that participated. STL-only, CI-friendly, and safe to serialize via to_string() (text) or to_json() (JSON).

See Also

ValidationIssue

See Also

ContractRegistry

Definition at line 82 of file ValidationReport.h.

Public Constructors

ValidationReport()

simaai::neat::ValidationReport::ValidationReport ()
default

Construct an empty report.

Definition at line 85 of file ValidationReport.h.

Public Member Functions

add_error()

void simaai::neat::ValidationReport::add_error (std::string contract_id, std::string code, std::string msg, int node_index=-1, std::string node_kind={}, std::string node_label={})
inline

Append an Error issue.

Definition at line 109 of file ValidationReport.h.

109 void add_error(std::string contract_id, std::string code, std::string msg, int node_index = -1,
110 std::string node_kind = {}, std::string node_label = {}) {
111 add_issue({ValidationSeverity::Error, std::move(contract_id), std::move(code), std::move(msg),
112 node_index, std::move(node_kind), std::move(node_label)});
113 }

add_info()

void simaai::neat::ValidationReport::add_info (std::string contract_id, std::string code, std::string msg, int node_index=-1, std::string node_kind={}, std::string node_label={})
inline

Append an Info issue.

Definition at line 95 of file ValidationReport.h.

95 void add_info(std::string contract_id, std::string code, std::string msg, int node_index = -1,
96 std::string node_kind = {}, std::string node_label = {}) {
97 add_issue({ValidationSeverity::Info, std::move(contract_id), std::move(code), std::move(msg),
98 node_index, std::move(node_kind), std::move(node_label)});
99 }

add_issue()

void simaai::neat::ValidationReport::add_issue (ValidationIssue issue)
inline

Append an issue to the report.

Definition at line 90 of file ValidationReport.h.

91 issues_.push_back(std::move(issue));
92 }

add_warning()

void simaai::neat::ValidationReport::add_warning (std::string contract_id, std::string code, std::string msg, int node_index=-1, std::string node_kind={}, std::string node_label={})
inline

Append a Warning issue.

Definition at line 102 of file ValidationReport.h.

102 void add_warning(std::string contract_id, std::string code, std::string msg, int node_index = -1,
103 std::string node_kind = {}, std::string node_label = {}) {
104 add_issue({ValidationSeverity::Warning, std::move(contract_id), std::move(code), std::move(msg),
105 node_index, std::move(node_kind), std::move(node_label)});
106 }

contracts_run()

const std::vector< std::string > & simaai::neat::ValidationReport::contracts_run ()
inline noexcept

Ids of all contracts that ran (in evaluation order).

Definition at line 136 of file ValidationReport.h.

136 const std::vector<std::string>& contracts_run() const noexcept {
137 return contracts_run_;
138 }

error_count()

std::size_t simaai::neat::ValidationReport::error_count ()
inline noexcept

Count of Error issues in the report.

Definition at line 155 of file ValidationReport.h.

155 std::size_t error_count() const noexcept {
156 std::size_t n = 0;
157 for (const auto& i : issues_)
158 if (i.severity == ValidationSeverity::Error)
159 ++n;
160 return n;
161 }

has_errors()

bool simaai::neat::ValidationReport::has_errors ()
inline noexcept

True if at least one issue with Error severity is present.

Definition at line 146 of file ValidationReport.h.

146 bool has_errors() const noexcept {
147 for (const auto& i : issues_) {
148 if (i.severity == ValidationSeverity::Error)
149 return true;
150 }
151 return false;
152 }

info_count()

std::size_t simaai::neat::ValidationReport::info_count ()
inline noexcept

Count of Info issues in the report.

Definition at line 173 of file ValidationReport.h.

173 std::size_t info_count() const noexcept {
174 std::size_t n = 0;
175 for (const auto& i : issues_)
176 if (i.severity == ValidationSeverity::Info)
177 ++n;
178 return n;
179 }

issues()

const std::vector< ValidationIssue > & simaai::neat::ValidationReport::issues ()
inline noexcept

All issues collected, in insertion order.

Definition at line 132 of file ValidationReport.h.

132 const std::vector<ValidationIssue>& issues() const noexcept {
133 return issues_;
134 }

mode()

int simaai::neat::ValidationReport::mode ()
inline

Mode integer set via set_mode().

Definition at line 125 of file ValidationReport.h.

125 int mode() const {
126 return mode_;
127 }

note_contract_run()

void simaai::neat::ValidationReport::note_contract_run (std::string id)
inline

Record that a contract id participated in this validation pass.

Definition at line 116 of file ValidationReport.h.

116 void note_contract_run(std::string id) {
117 contracts_run_.push_back(std::move(id));
118 }

ok()

bool simaai::neat::ValidationReport::ok ()
inline noexcept

True if the report contains no errors (warnings/info are still allowed).

Definition at line 141 of file ValidationReport.h.

141 bool ok() const noexcept {
142 return !has_errors();
143 }

set_mode()

void simaai::neat::ValidationReport::set_mode (int mode)
inline

Record which Session mode produced this report (integer to avoid Contract.h include).

Definition at line 121 of file ValidationReport.h.

121 void set_mode(int mode) {
122 mode_ = mode;
123 }

to_json()

std::string simaai::neat::ValidationReport::to_json ()
inline

Serialize the report as a JSON string (CI/dashboard-friendly).

Definition at line 210 of file ValidationReport.h.

210 std::string to_json() const {
211 std::ostringstream oss;
212 oss << "{";
213 oss << "\"ok\":" << (ok() ? "true" : "false") << ",";
214 oss << "\"mode\":" << mode_ << ",";
215 oss << "\"errors\":" << error_count() << ",";
216 oss << "\"warnings\":" << warning_count() << ",";
217 oss << "\"info\":" << info_count() << ",";
218
219 // contracts_run
220 oss << "\"contracts_run\":[";
221 for (std::size_t i = 0; i < contracts_run_.size(); ++i) {
222 if (i)
223 oss << ",";
224 oss << "\"" << json_escape_(contracts_run_[i]) << "\"";
225 }
226 oss << "],";
227
228 // issues
229 oss << "\"issues\":[";
230 for (std::size_t i = 0; i < issues_.size(); ++i) {
231 if (i)
232 oss << ",";
233 const auto& it = issues_[i];
234 oss << "{";
235 oss << "\"severity\":\"" << json_escape_(::simaai::neat::to_string(it.severity)) << "\",";
236 oss << "\"contract_id\":\"" << json_escape_(it.contract_id) << "\",";
237 oss << "\"code\":\"" << json_escape_(it.code) << "\",";
238 oss << "\"message\":\"" << json_escape_(it.message) << "\",";
239 oss << "\"node_index\":" << it.node_index << ",";
240 oss << "\"node_kind\":\"" << json_escape_(it.node_kind) << "\",";
241 oss << "\"node_label\":\"" << json_escape_(it.node_label) << "\"";
242 oss << "}";
243 }
244 oss << "]";
245
246 oss << "}";
247 return oss.str();
248 }

to_string()

std::string simaai::neat::ValidationReport::to_string ()
inline

Render the report as a deterministic, human-readable text block.

Definition at line 184 of file ValidationReport.h.

184 std::string to_string() const {
185 std::ostringstream oss;
186 oss << (ok() ? "OK" : "FAILED") << " (errors=" << error_count()
187 << ", warnings=" << warning_count() << ", info=" << info_count() << ")\n";
188
189 for (const auto& i : issues_) {
190 oss << "- [" << ::simaai::neat::to_string(i.severity) << "] "
191 << (i.contract_id.empty() ? "<contract?>" : i.contract_id);
192
193 if (!i.code.empty())
194 oss << " {" << i.code << "}";
195
196 if (i.node_index >= 0) {
197 oss << " @node[" << i.node_index << "]";
198 if (!i.node_kind.empty())
199 oss << ":" << i.node_kind;
200 if (!i.node_label.empty())
201 oss << " [" << i.node_label << "]";
202 }
203
204 oss << ": " << i.message << "\n";
205 }
206 return oss.str();
207 }

warning_count()

std::size_t simaai::neat::ValidationReport::warning_count ()
inline noexcept

Count of Warning issues in the report.

Definition at line 164 of file ValidationReport.h.

164 std::size_t warning_count() const noexcept {
165 std::size_t n = 0;
166 for (const auto& i : issues_)
167 if (i.severity == ValidationSeverity::Warning)
168 ++n;
169 return n;
170 }

Private Member Attributes

contracts_run_

std::vector<std::string> simaai::neat::ValidationReport::contracts_run_

Definition at line 294 of file ValidationReport.h.

294 std::vector<std::string> contracts_run_;

issues_

std::vector<ValidationIssue> simaai::neat::ValidationReport::issues_

Definition at line 295 of file ValidationReport.h.

295 std::vector<ValidationIssue> issues_;

mode_

int simaai::neat::ValidationReport::mode_ = 0

Definition at line 293 of file ValidationReport.h.

293 int mode_ = 0;

Private Static Functions

json_escape_()

std::string simaai::neat::ValidationReport::json_escape_ (const std::string & s)
inline static

Definition at line 251 of file ValidationReport.h.

251 static std::string json_escape_(const std::string& s) {
252 std::string out;
253 out.reserve(s.size() + 16);
254 for (char c : s) {
255 switch (c) {
256 case '\\':
257 out += "\\\\";
258 break;
259 case '"':
260 out += "\\\"";
261 break;
262 case '\b':
263 out += "\\b";
264 break;
265 case '\f':
266 out += "\\f";
267 break;
268 case '\n':
269 out += "\\n";
270 break;
271 case '\r':
272 out += "\\r";
273 break;
274 case '\t':
275 out += "\\t";
276 break;
277 default:
278 // Control chars -> escape as \u00XX
279 if (static_cast<unsigned char>(c) < 0x20) {
280 const char* hex = "0123456789abcdef";
281 out += "\\u00";
282 out += hex[(c >> 4) & 0xF];
283 out += hex[c & 0xF];
284 } else {
285 out += c;
286 }
287 break;
288 }
289 }
290 return out;
291 }

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.