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>
65 lines
3.4 KiB
C++
65 lines
3.4 KiB
C++
// Step 876: whetstone_estimate_porting_cost MCP tool (8 tests)
|
|
#include "MCPServer.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(tool_registered);
|
|
MCPServer srv;
|
|
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/list"},{"params",{}}});
|
|
bool found=false;
|
|
for(auto& t:r["result"]["tools"]) if(t["name"]=="whetstone_estimate_porting_cost") found=true;
|
|
C(found,"tool found");P();}
|
|
|
|
void t2(){T(no_pair_id_fails);
|
|
MCPServer srv;
|
|
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",nlohmann::json::object()}}}});
|
|
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
|
|
C(!res["success"].get<bool>(),"fail");P();}
|
|
|
|
void t3(){T(valid_pair_succeeds);
|
|
MCPServer srv;
|
|
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",{{"pair_id","py->cpp"}}}}}});
|
|
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
|
|
C(res["success"].get<bool>(),"success");P();}
|
|
|
|
void t4(){T(tier_field_present);
|
|
MCPServer srv;
|
|
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",{{"pair_id","py->cpp"}}}}}});
|
|
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
|
|
C(res.contains("tier"),"tier");P();}
|
|
|
|
void t5(){T(total_cost_present);
|
|
MCPServer srv;
|
|
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",{{"pair_id","py->cpp"}}}}}});
|
|
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
|
|
C(res.contains("total_cost"),"total");P();}
|
|
|
|
void t6(){T(high_loc_high_compute);
|
|
MCPServer srv;
|
|
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",{{"pair_id","py->cpp"},{"lines_of_code",5000},{"ambiguity_score",0.9}}}}}});
|
|
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
|
|
C(res["tier"]=="high","high");P();}
|
|
|
|
void t7(){T(low_loc_low_tier);
|
|
MCPServer srv;
|
|
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",{{"pair_id","py->cpp"},{"lines_of_code",10},{"ambiguity_score",0.0}}}}}});
|
|
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
|
|
C(res["tier"]=="low","low");P();}
|
|
|
|
void t8(){T(pair_id_in_response);
|
|
MCPServer srv;
|
|
auto r=srv.handleRequest({{"jsonrpc","2.0"},{"id",1},{"method","tools/call"},{"params",{{"name","whetstone_estimate_porting_cost"},{"arguments",{{"pair_id","rust->go"}}}}}});
|
|
auto res=nlohmann::json::parse(r["result"]["content"][0]["text"].get<std::string>());
|
|
C(res["pair_id"]=="rust->go","pair_id");P();}
|
|
|
|
int main(){
|
|
std::cout<<"Step 876: whetstone_estimate_porting_cost\n";
|
|
t1();t2();t3();t4();t5();t6();t7();t8();
|
|
std::cout<<"\nResults: "<<p<<"/"<<(p+f)<<" passed\n";
|
|
return f?1:0;
|
|
}
|