Sprint 27: end-of-sprint architecture refactor pass
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "ConstraintViolationDiagnostics.h"
|
||||
#include "ConstraintSchemaFailurePacket.h"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -38,7 +39,7 @@ public:
|
||||
auto validation = TypedTaskitemContractSchema::parseAndValidate(request.taskitemJson);
|
||||
if (!validation.valid) {
|
||||
result.schemaErrors = validation.errors;
|
||||
result.diagnostics = schemaFailurePacket(validation.errors);
|
||||
result.diagnostics = makeUnderConstrainedContractPacket(validation.errors);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -66,21 +67,4 @@ public:
|
||||
result.executed = result.diagnostics.ok;
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
static ConstraintDiagnosticPacket schemaFailurePacket(
|
||||
const std::vector<std::string>& errors) {
|
||||
ConstraintDiagnosticPacket packet;
|
||||
packet.ok = false;
|
||||
packet.recommendedAction = "escalate";
|
||||
for (const auto& error : errors) {
|
||||
packet.violations.push_back({
|
||||
"under_constrained_contract",
|
||||
"Taskitem contract failed schema validation",
|
||||
error,
|
||||
false
|
||||
});
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
};
|
||||
|
||||
23
editor/src/ConstraintSchemaFailurePacket.h
Normal file
23
editor/src/ConstraintSchemaFailurePacket.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
// Sprint 27 refactor: shared schema-failure packet helper
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ConstraintViolationDiagnostics.h"
|
||||
|
||||
inline ConstraintDiagnosticPacket makeUnderConstrainedContractPacket(
|
||||
const std::vector<std::string>& errors) {
|
||||
ConstraintDiagnosticPacket packet;
|
||||
packet.ok = false;
|
||||
packet.recommendedAction = "escalate";
|
||||
for (const auto& error : errors) {
|
||||
packet.violations.push_back({
|
||||
"under_constrained_contract",
|
||||
"Taskitem contract failed schema validation",
|
||||
error,
|
||||
false
|
||||
});
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "ConstraintViolationDiagnostics.h"
|
||||
#include "ConstraintSchemaFailurePacket.h"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -37,7 +38,7 @@ public:
|
||||
|
||||
auto schema = TypedTaskitemContractSchema::parseAndValidate(taskitemJson);
|
||||
if (!schema.valid) {
|
||||
result.diagnostics = schemaFailurePacket(schema.errors);
|
||||
result.diagnostics = makeUnderConstrainedContractPacket(schema.errors);
|
||||
return result;
|
||||
}
|
||||
result.contract = schema.contract;
|
||||
@@ -111,20 +112,4 @@ private:
|
||||
}
|
||||
return violations.empty() ? "proceed" : "retry";
|
||||
}
|
||||
|
||||
static ConstraintDiagnosticPacket schemaFailurePacket(
|
||||
const std::vector<std::string>& errors) {
|
||||
ConstraintDiagnosticPacket packet;
|
||||
packet.ok = false;
|
||||
packet.recommendedAction = "escalate";
|
||||
for (const auto& error : errors) {
|
||||
packet.violations.push_back({
|
||||
"under_constrained_contract",
|
||||
"Taskitem contract failed schema validation",
|
||||
error,
|
||||
false
|
||||
});
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user