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>
46 lines
2.0 KiB
C++
46 lines
2.0 KiB
C++
// Step 877: Cost telemetry integration in metrics stack (8 tests)
|
|
#include "graduation/CostTelemetryIntegration.h"
|
|
#include <iostream>
|
|
static int p=0,f=0;
|
|
#define T(n) { std::cout << " " << #n << "... "; }
|
|
#define P() { std::cout << "PASS\n"; ++p; }
|
|
#define F(m) { std::cout << "FAIL: " << m << "\n"; ++f; }
|
|
#define C(c,m) if(!(c)){F(m);return;}
|
|
|
|
void t1(){T(make_record);
|
|
auto r=CostTelemetryIntegration::make("py->cpp","balanced",0.5f,0.4f);
|
|
C(r.pairId=="py->cpp","pairId");P();}
|
|
void t2(){T(cost_error_computed);
|
|
auto r=CostTelemetryIntegration::make("py->cpp","balanced",0.5f,0.4f);
|
|
C(std::abs(r.costError-0.1f)<0.001f,"error");P();}
|
|
void t3(){T(over_budget_flag);
|
|
auto r=CostTelemetryIntegration::make("py->cpp","balanced",1.2f,0.4f);
|
|
C(r.overBudget,"over");P();}
|
|
void t4(){T(not_over_budget);
|
|
auto r=CostTelemetryIntegration::make("py->cpp","balanced",0.8f,0.5f);
|
|
C(!r.overBudget,"not over");P();}
|
|
void t5(){T(record_and_count);
|
|
CostTelemetryIntegration cti;
|
|
cti.record(CostTelemetryIntegration::make("py->cpp","balanced",0.5f,0.4f));
|
|
cti.record(CostTelemetryIntegration::make("rust->go","cheap",1.5f,0.3f));
|
|
C(cti.overBudgetCount()==1,"count");P();}
|
|
void t6(){T(average_cost_error);
|
|
CostTelemetryIntegration cti;
|
|
cti.record(CostTelemetryIntegration::make("py->cpp","balanced",0.5f,0.3f));
|
|
cti.record(CostTelemetryIntegration::make("py->cpp","balanced",0.7f,0.5f));
|
|
C(std::abs(cti.averageCostError()-0.2f)<0.001f,"avg");P();}
|
|
void t7(){T(empty_avg_zero);
|
|
CostTelemetryIntegration cti;
|
|
C(cti.averageCostError()==0.0f,"zero");P();}
|
|
void t8(){T(to_json_has_cost_error);
|
|
auto r=CostTelemetryIntegration::make("py->cpp","balanced",0.5f,0.4f);
|
|
auto j=CostTelemetryIntegration::toJson(r);
|
|
C(j.contains("cost_error"),"json");P();}
|
|
|
|
int main(){
|
|
std::cout<<"Step 877: Cost telemetry integration\n";
|
|
t1();t2();t3();t4();t5();t6();t7();t8();
|
|
std::cout<<"\nResults: "<<p<<"/"<<(p+f)<<" passed\n";
|
|
return f?1:0;
|
|
}
|