diff --git a/editor/src/ConstrainedTaskitemIntegration.h b/editor/src/ConstrainedTaskitemIntegration.h index 640053c..465cb23 100644 --- a/editor/src/ConstrainedTaskitemIntegration.h +++ b/editor/src/ConstrainedTaskitemIntegration.h @@ -8,6 +8,7 @@ #include #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& 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; - } }; diff --git a/editor/src/ConstraintSchemaFailurePacket.h b/editor/src/ConstraintSchemaFailurePacket.h new file mode 100644 index 0000000..f263859 --- /dev/null +++ b/editor/src/ConstraintSchemaFailurePacket.h @@ -0,0 +1,23 @@ +#pragma once +// Sprint 27 refactor: shared schema-failure packet helper + +#include +#include + +#include "ConstraintViolationDiagnostics.h" + +inline ConstraintDiagnosticPacket makeUnderConstrainedContractPacket( + const std::vector& 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; +} diff --git a/editor/src/PreApplyValidationGate.h b/editor/src/PreApplyValidationGate.h index d1c3ee7..77c11d0 100644 --- a/editor/src/PreApplyValidationGate.h +++ b/editor/src/PreApplyValidationGate.h @@ -9,6 +9,7 @@ #include #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& 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; - } }; diff --git a/progress.md b/progress.md index 832cf2c..90879df 100644 --- a/progress.md +++ b/progress.md @@ -8930,3 +8930,39 @@ notes. - **New tests in this sprint plan:** 112/112 passing - **Phase 27a (524-528):** 56/56 passing - **Phase 27b (529-533):** 56/56 passing + +## Sprint 27 End Refactor Pass (Architecture Compliance) + +Performed a dedicated post-sprint refactor pass to reduce duplication and +re-validate architecture constraints without changing runtime behavior. + +**Refactors applied:** +- `editor/src/ConstraintSchemaFailurePacket.h` + - extracted shared helper `makeUnderConstrainedContractPacket(...)` + - centralized schema-failure diagnostics payload construction +- `editor/src/ConstrainedTaskitemIntegration.h` + - replaced inline schema-failure packet builder with shared helper usage + - removed duplicate private schema-failure implementation +- `editor/src/PreApplyValidationGate.h` + - replaced inline schema-failure packet builder with shared helper usage + - removed duplicate private schema-failure implementation + +**Architecture compliance audit:** +- Header size gate (`<=600` lines): PASS across Sprint 27 modules + - largest audited header: `editor/src/ConstraintViolationDiagnostics.h` (`169` lines) +- `goto` usage in Sprint 27 runtime path: PASS (none) +- Stale TODO markers in Sprint 27 modules: PASS (none) +- Header-only pattern for Sprint 27 additions: PASS + +**Refactor verification run:** +- `cmake --build editor/build-native --target step524_test step525_test step526_test step527_test step528_test step529_test step530_test step531_test step532_test step533_test` - PASS +- `./editor/build-native/step524_test` - PASS (12/12) +- `./editor/build-native/step525_test` - PASS (12/12) +- `./editor/build-native/step526_test` - PASS (12/12) +- `./editor/build-native/step527_test` - PASS (12/12) +- `./editor/build-native/step528_test` - PASS (8/8) +- `./editor/build-native/step529_test` - PASS (12/12) +- `./editor/build-native/step530_test` - PASS (12/12) +- `./editor/build-native/step531_test` - PASS (12/12) +- `./editor/build-native/step532_test` - PASS (12/12) +- `./editor/build-native/step533_test` - PASS (8/8)