Sprint 29: end-of-sprint architecture refactor pass
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "PolicyDecisionUtil.h"
|
||||
|
||||
struct CostPolicyInput {
|
||||
int stepTokens = 0;
|
||||
int workflowTokens = 0;
|
||||
@@ -30,8 +32,7 @@ public:
|
||||
input.workflowTokens > input.workflowTokenCeiling;
|
||||
|
||||
if (!stepOver && !workflowOver) {
|
||||
out.allowed = true;
|
||||
out.action = "allow";
|
||||
setPolicyAction(out.allowed, out.requiresEscalation, out.action, "allow");
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -39,22 +40,18 @@ public:
|
||||
if (workflowOver) out.violations.push_back("workflow_token_ceiling_exceeded");
|
||||
|
||||
if (!input.hasRationale) {
|
||||
out.allowed = false;
|
||||
out.action = "request_rationale";
|
||||
setPolicyAction(out.allowed, out.requiresEscalation, out.action, "request_rationale");
|
||||
return out;
|
||||
}
|
||||
|
||||
// With rationale, require explicit escalation approval for overage execution.
|
||||
if (!input.hasEscalationApproval) {
|
||||
out.allowed = false;
|
||||
out.requiresEscalation = true;
|
||||
out.action = "escalate";
|
||||
setPolicyAction(out.allowed, out.requiresEscalation, out.action, "escalate");
|
||||
return out;
|
||||
}
|
||||
|
||||
out.allowed = true;
|
||||
setPolicyAction(out.allowed, out.requiresEscalation, out.action, "allow");
|
||||
out.requiresEscalation = true;
|
||||
out.action = "allow";
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
27
editor/src/PolicyDecisionUtil.h
Normal file
27
editor/src/PolicyDecisionUtil.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
// Sprint 29 refactor: shared policy decision helpers
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
inline void setEscalateDecision(bool& requiresHumanReview,
|
||||
std::string& decision,
|
||||
std::vector<std::string>& reasons,
|
||||
const std::string& reason) {
|
||||
requiresHumanReview = true;
|
||||
decision = "escalate_review";
|
||||
if (!reason.empty()) reasons.push_back(reason);
|
||||
}
|
||||
|
||||
inline void setPolicyAction(bool& allowed,
|
||||
bool& requiresEscalation,
|
||||
std::string& action,
|
||||
const std::string& nextAction) {
|
||||
action = nextAction;
|
||||
if (nextAction == "allow") {
|
||||
allowed = true;
|
||||
return;
|
||||
}
|
||||
allowed = false;
|
||||
requiresEscalation = (nextAction == "escalate");
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "PolicyDecisionUtil.h"
|
||||
|
||||
struct ReviewGateInput {
|
||||
bool safetyCritical = false;
|
||||
bool securitySensitive = false;
|
||||
@@ -33,17 +35,15 @@ public:
|
||||
}
|
||||
|
||||
if (input.safetyCritical || input.securitySensitive) {
|
||||
out.requiresHumanReview = true;
|
||||
out.decision = "escalate_review";
|
||||
setEscalateDecision(out.requiresHumanReview, out.decision, out.reasons, "");
|
||||
if (input.safetyCritical) out.reasons.push_back("safety_critical_change");
|
||||
if (input.securitySensitive) out.reasons.push_back("security_sensitive_change");
|
||||
return out;
|
||||
}
|
||||
|
||||
if (input.postApplyFailureStreak >= 3) {
|
||||
out.requiresHumanReview = true;
|
||||
out.decision = "escalate_review";
|
||||
out.reasons.push_back("repeated_post_apply_failures");
|
||||
setEscalateDecision(out.requiresHumanReview, out.decision, out.reasons,
|
||||
"repeated_post_apply_failures");
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,7 @@ public:
|
||||
return out;
|
||||
}
|
||||
|
||||
out.requiresHumanReview = true;
|
||||
out.decision = "escalate_review";
|
||||
setEscalateDecision(out.requiresHumanReview, out.decision, out.reasons, "");
|
||||
if (input.highCostOverage) out.reasons.push_back("high_cost_overage");
|
||||
if (input.confidenceScore < 70) out.reasons.push_back("low_confidence");
|
||||
return out;
|
||||
|
||||
36
progress.md
36
progress.md
@@ -9733,3 +9733,39 @@ into phase-level and sprint-level outcomes with closure diagnostics.
|
||||
- **New tests in this sprint plan:** 112/112 passing
|
||||
- **Phase 29a (544-548):** 56/56 passing
|
||||
- **Phase 29b (549-553):** 56/56 passing
|
||||
|
||||
## Sprint 29 End Refactor Pass (Architecture Compliance)
|
||||
|
||||
Performed a dedicated post-sprint refactor pass to reduce policy-guard
|
||||
duplication and re-validate architecture constraints without behavior changes.
|
||||
|
||||
**Refactors applied:**
|
||||
- `editor/src/PolicyDecisionUtil.h`
|
||||
- added shared helpers for policy decision transitions
|
||||
- centralized common escalation/action state assignment logic
|
||||
- `editor/src/ReviewGatePolicyRefinement.h`
|
||||
- switched repeated escalation decision branches to shared helper usage
|
||||
- removed duplicated inline escalation state mutation
|
||||
- `editor/src/CostPolicyGuard.h`
|
||||
- switched repeated action/allow/escalation transitions to shared helper usage
|
||||
- removed duplicated inline action-state assignments
|
||||
|
||||
**Architecture compliance audit:**
|
||||
- Header size gate (`<=600` lines): PASS across Sprint 29 modules
|
||||
- largest audited header: `editor/src/ConstrainedConfidenceCalibrator.h` (`97` lines)
|
||||
- `goto` usage in Sprint 29 runtime path: PASS (none)
|
||||
- Stale TODO markers in Sprint 29 modules: PASS (none)
|
||||
- Header-only pattern for Sprint 29 additions: PASS
|
||||
|
||||
**Refactor verification run:**
|
||||
- `cmake --build editor/build-native --target step544_test step545_test step546_test step547_test step548_test step549_test step550_test step551_test step552_test step553_test` - PASS
|
||||
- `./editor/build-native/step544_test` - PASS (12/12)
|
||||
- `./editor/build-native/step545_test` - PASS (12/12)
|
||||
- `./editor/build-native/step546_test` - PASS (12/12)
|
||||
- `./editor/build-native/step547_test` - PASS (12/12)
|
||||
- `./editor/build-native/step548_test` - PASS (8/8)
|
||||
- `./editor/build-native/step549_test` - PASS (12/12)
|
||||
- `./editor/build-native/step550_test` - PASS (12/12)
|
||||
- `./editor/build-native/step551_test` - PASS (12/12)
|
||||
- `./editor/build-native/step552_test` - PASS (12/12)
|
||||
- `./editor/build-native/step553_test` - PASS (8/8)
|
||||
|
||||
Reference in New Issue
Block a user