Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
VSGraphVerifier.h
Go to the documentation of this file.
1/**
2 * @file VSGraphVerifier.h
3 * @brief Global graph verifier for ATS Visual Script graphs (Phase 21-A).
4 * @author Olympe Engine
5 * @date 2026-03-14
6 *
7 * @details
8 * Stateless global validator that checks the full TaskGraphTemplate for
9 * structural, type-safety and blackboard consistency issues.
10 * Produces a VSVerificationResult with Error/Warning/Info issues.
11 *
12 * C++14 compliant — no std::optional, structured bindings, std::filesystem.
13 */
14
15#pragma once
16
17#include <string>
18#include <vector>
19#include "../TaskSystem/TaskGraphTemplate.h"
20
21namespace Olympe {
22
23// ============================================================================
24// VSVerificationIssue
25// ============================================================================
26
28 Error,
29 Warning,
30 Info
31};
32
35 int nodeID; ///< -1 if not node-specific
36 std::string ruleID; ///< e.g. "E001_NoEntryPoint"
37 std::string message;
38};
39
40// ============================================================================
41// VSVerificationResult
42// ============================================================================
43
45 std::vector<VSVerificationIssue> issues;
46
47 bool HasErrors() const;
48 bool HasWarnings() const;
49 bool IsValid() const; ///< true if no Error issues
50};
51
52// ============================================================================
53// VSGraphVerifier
54// ============================================================================
55
56/**
57 * @class VSGraphVerifier
58 * @brief Stateless global verifier for ATS Visual Script graphs.
59 *
60 * @details
61 * Call VSGraphVerifier::Verify(graph) to run all 14 rules on the graph.
62 * The result contains zero or more VSVerificationIssue entries.
63 *
64 * Rules implemented:
65 * E001 — Exactly one EntryPoint node required
66 * E002 — Dangling node (no exec in or out, except EntryPoint)
67 * E003 — Exec cycle detected (iterative DFS)
68 * E004 — Circular SubGraph reference
69 * E005 — Exec connection references unknown node
70 * E006 — Incompatible data pin types
71 * E007 — Inverted pin direction (output connected to output, or input to input)
72 * E008 — Unknown Blackboard key in GetBBValue/SetBBValue
73 * E009 — Blackboard type mismatch
74 * E010 — Switch node missing switchVariable
75 * E011 — Switch node has duplicate case values
76 * E012 — Switch node has a case with empty pin name
77 * W001 — AtomicTask with empty AtomicTaskID
78 * W002 — Delay with DelaySeconds <= 0
79 * W003 — SubGraph with empty SubGraphPath
80 * W004 — MathOp with empty MathOperator
81 * I001 — Node not reachable from EntryPoint
82 * E040 — Branch/While: Pin mode with empty pin reference
83 * E041 — Branch/While: Variable mode but variable not in blackboard
84 * E042 — Branch/While: Type mismatch between left and right operands
85 * W015 — Branch/While: Const vs Const condition (always true/false — optimisation hint)
86 * W016 — Branch/While: Pin mode selected but no DataConnection for that pin
87 */
89public:
90 /**
91 * @brief Run all verification rules on the given graph.
92 * @param graph The graph to verify (read-only).
93 * @return VSVerificationResult containing all issues found.
94 */
96
97private:
98 // Structural rules
103
104 // Type-safety rules
108
109 // Blackboard rules
112
113 // Switch rules (Phase 22-A)
115
116 // Registry rules (Phase 22-C)
117 // W005 — AtomicTask: taskType not in AtomicTaskUIRegistry (warning, custom tasks may not have UI metadata)
119 // E021 — Branch/While: conditionType not in ConditionRegistry
121 // E023 — MathOp: operation is not a valid math operator
123 // E024 — SubGraph: subGraphPath is empty
125 // E025 — Condition: required parameter missing on Branch/While node
127 // W010 — BBKey type incompatible with node expectations
129
130 // Condition rules (Phase 23-B.4)
131 // E040 — Branch/While: Pin mode selected but pin reference is empty
132 // E041 — Branch/While: Variable mode selected but variable not in blackboard
133 // E042 — Branch/While: Type mismatch between left and right operands
134 // W015 — Branch/While: Const vs Const condition (always true/false)
135 // W016 — Branch/While: Pin mode selected but no DataConnection found for that pin
137
138 // Warning rules
140
141 // Info rules
143
144 // Helpers
145 static void AddIssue(VSVerificationResult& r,
147 int nodeID,
148 const std::string& ruleID,
149 const std::string& message);
150
151 VSGraphVerifier() = delete;
152};
153
154} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Immutable, shareable task graph asset.
Stateless global verifier for ATS Visual Script graphs.
static void CheckDanglingNodes(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckDataPinTypes(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckSubGraphCircular(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckExecCycles(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckBBKeyCompatibility(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckConditionIDs(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckSubGraphPaths(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckEntryPoint(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckReachability(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckConditionParams(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckBlackboardKeys(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckExecPinTypes(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckConditionStructure(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckPinDirections(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckSwitchNodes(const TaskGraphTemplate &g, VSVerificationResult &r)
static void AddIssue(VSVerificationResult &r, VSVerificationSeverity sev, int nodeID, const std::string &ruleID, const std::string &message)
static void CheckNodeParameterWarnings(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckMathOperators(const TaskGraphTemplate &g, VSVerificationResult &r)
static VSVerificationResult Verify(const TaskGraphTemplate &graph)
Run all verification rules on the given graph.
static void CheckAtomicTaskIDs(const TaskGraphTemplate &g, VSVerificationResult &r)
static void CheckBlackboardTypes(const TaskGraphTemplate &g, VSVerificationResult &r)
< Provides AssetID and INVALID_ASSET_ID
VSVerificationSeverity severity
std::string ruleID
e.g. "E001_NoEntryPoint"
int nodeID
-1 if not node-specific
std::vector< VSVerificationIssue > issues
bool IsValid() const
true if no Error issues