ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
validate.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include "reusex/core/stage_contract.hpp"
7
8#include <map>
9#include <optional>
10#include <string>
11#include <string_view>
12#include <vector>
13
14namespace reusex {
15class ProjectDB;
16}
17
18namespace reusex::core {
19
22
25 std::string check;
26 std::string message;
34 std::string hint;
39 std::string artifact;
44 std::vector<std::string> commands;
45};
46
49 std::vector<ValidationIssue> issues;
50
52 bool ok() const;
53 size_t error_count() const;
54 size_t warning_count() const;
55};
56
57// ── Individual checks (each appends to `out`) ──────────────────────────────
58// These are read-only. Split out so they can be unit-tested in isolation.
59
63 std::vector<ValidationIssue> &out);
64
67 std::vector<ValidationIssue> &out);
68
71 std::vector<ValidationIssue> &out);
72
76 std::vector<ValidationIssue> &out);
77
80
81// ── Stage input contracts (#222, consolidated in #246) ─────────────────────
82// Each pipeline stage consumes a known set of named clouds/tables and produces
83// another. That table lives in ONE place — core/stage_contract.hpp, mirrored in
84// prose by docs/CONTRACTS.md — and the functions below are generic interpreters
85// of it, not a second copy. `rux validate --stage <name>` and the refusal path
86// of `pipeline::run_stage()` are the same code, so a missing/misaligned
87// prerequisite fails identically whichever door the user came through.
88//
89// `PipelineStage`, `parse_pipeline_stage()`, `to_string()` and
90// `pipeline_stage_names()` come from <reusex/core/stage_contract.hpp>, included
91// above.
92
98using ArtifactOverrides = std::map<std::string, std::string, std::less<>>;
99
104 std::vector<ValidationIssue> &out,
105 const ArtifactOverrides &overrides = {});
106
109 const ArtifactOverrides &overrides = {});
110
111} // namespace reusex::core
ValidationReport validate_project(const ProjectDB &db)
Run every check and aggregate the findings.
ValidationReport validate_stage(const ProjectDB &db, PipelineStage stage, const ArtifactOverrides &overrides={})
Run check_stage_inputs for a single stage and aggregate the findings.
PipelineStage
Pipeline stages that have an input contract.
void check_orphaned_passports(const ProjectDB &db, std::vector< ValidationIssue > &out)
Material passports not referenced by any instance_materials link.
void check_stage_inputs(const ProjectDB &db, PipelineStage stage, std::vector< ValidationIssue > &out, const ArtifactOverrides &overrides={})
Assert that stage's input clouds/tables exist in db and are index-aligned, per the contract in core/s...
std::map< std::string, std::string, std::less<> > ArtifactOverrides
Runtime substitutions for artifact names, for the flags that let a stage be pointed at a differently-...
Definition validate.hpp:98
void check_sibling_cloud_sizes(const ProjectDB &db, std::vector< ValidationIssue > &out)
Parallel/sibling clouds (cloud, labels, normals, planes, rooms, instances) whose point counts disagre...
void check_dangling_instance_materials(const ProjectDB &db, std::vector< ValidationIssue > &out)
instance_materials rows whose instance row or passport is missing.
void error(fmt::format_string< Args... > format, Args &&...args)
Definition logging.hpp:100
ValidationSeverity
Severity of a single validation finding.
Definition validate.hpp:21
void check_instances_without_label_defs(const ProjectDB &db, std::vector< ValidationIssue > &out)
instances rows with no corresponding label_definitions entry.
One problem discovered by a validation check.
Definition validate.hpp:24
std::string message
Human-readable description.
Definition validate.hpp:26
std::vector< std::string > commands
The same resolution as hint, as an ordered list of commands rather than prose.
Definition validate.hpp:44
std::string check
Machine-readable check id (e.g. "orphaned_passport").
Definition validate.hpp:25
std::string artifact
The pipeline artifact this issue is about, when it is about one; empty otherwise.
Definition validate.hpp:39
ValidationSeverity severity
Definition validate.hpp:27
std::string hint
What the user should run to fix it, or empty when there is no mechanical resolution.
Definition validate.hpp:34
Aggregate result of running all validation checks over a project.
Definition validate.hpp:48
std::vector< ValidationIssue > issues
Definition validate.hpp:49
bool ok() const
True when no error-severity issue was found.