Adds cost modeling and budget enforcement for transpilation runs: - PortingCostModel: LOC + ambiguity → compute/review/total cost + tier (step 869) - ReviewEffortEstimator: ambiguity/risk → minutes + complexity label (step 870) - ComputeCostEstimator: prior run history → avg duration/tokens (step 871) - MultiPlanAlternativeGenerator: cheap/balanced/rigorous profiles (step 872) - BudgetPolicyEnforcer: approve/requires_token/rejected decisions (step 873) - CostQualityTradeoffReport: efficiency-based plan recommendation (step 874) - whetstone_plan_transpilation_run MCP tool (step 875) - whetstone_estimate_porting_cost MCP tool (step 876) - CostTelemetryIntegration: cost error tracking + over-budget count (step 877) - Sprint64IntegrationSummary (step 878) All 10 steps passing (94 tests). Policy: over-budget plans require explicit reviewer approval token. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
49 lines
1.7 KiB
C++
49 lines
1.7 KiB
C++
#pragma once
|
|
// Step 874: Cost-vs-quality tradeoff report generator.
|
|
#include <string>
|
|
#include <vector>
|
|
#include <nlohmann/json.hpp>
|
|
|
|
struct TradeoffEntry {
|
|
std::string profile;
|
|
float cost = 0.0f;
|
|
float quality = 0.0f;
|
|
float efficiency = 0.0f; // quality / cost
|
|
};
|
|
|
|
struct CostQualityReport {
|
|
std::string pairId;
|
|
std::vector<TradeoffEntry> entries;
|
|
std::string recommendedProfile;
|
|
};
|
|
|
|
class CostQualityTradeoffReport {
|
|
public:
|
|
static CostQualityReport generate(const std::string& pairId,
|
|
const std::vector<std::pair<std::string,float>>& planCosts,
|
|
const std::vector<std::pair<std::string,float>>& planQualities) {
|
|
CostQualityReport r;
|
|
r.pairId = pairId;
|
|
float bestEff = -1.0f;
|
|
for (size_t i = 0; i < planCosts.size() && i < planQualities.size(); ++i) {
|
|
TradeoffEntry e;
|
|
e.profile = planCosts[i].first;
|
|
e.cost = planCosts[i].second;
|
|
e.quality = planQualities[i].second;
|
|
e.efficiency = (e.cost > 0.0f) ? e.quality / e.cost : 0.0f;
|
|
r.entries.push_back(e);
|
|
if (e.efficiency > bestEff) { bestEff = e.efficiency; r.recommendedProfile = e.profile; }
|
|
}
|
|
return r;
|
|
}
|
|
|
|
static nlohmann::json toJson(const CostQualityReport& r) {
|
|
nlohmann::json arr = nlohmann::json::array();
|
|
for (const auto& e : r.entries)
|
|
arr.push_back({{"profile", e.profile}, {"cost", e.cost},
|
|
{"quality", e.quality}, {"efficiency", e.efficiency}});
|
|
return {{"pair_id", r.pairId}, {"entries", arr},
|
|
{"recommended_profile", r.recommendedProfile}};
|
|
}
|
|
};
|