Files
whetstone_DSL/editor/tests/step882_test.cpp
Bill 0282e7ebb7 Sprint 65: Parallel Pair Upgrades and Queue Optimization — Steps 879-888
Implements priority-aware pair-upgrade queue with starvation prevention:
- PairUpgradeQueue: enqueue/dequeue/getActive sorted by priority (step 879)
- UpgradePriorityPolicy: critical/revenue/coverage/experimental classes (step 880)
- ParallelDispatchOptimizer: schedule N pairs with blocked-pair constraints (step 881)
- StarvationPrevention: detect and promote starved pairs (step 882)
- QueueHealthScorer: stall-rate-based health scoring (step 883)
- RetryBackoffStrategy: exponential backoff with max-attempts guard (step 884)
- whetstone_enqueue_pair_upgrade MCP tool (step 885)
- whetstone_get_upgrade_queue MCP tool with priority sorting (step 886)
- UpgradeQueueObservabilityPanel: snapshot model for queue visibility (step 887)
- Sprint65IntegrationSummary (step 888)

All 10 steps passing (94 tests). Routing rule: critical-tier regressions
preempt all experimental upgrades.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 18:58:04 -07:00

52 lines
2.0 KiB
C++

// Step 882: Starvation prevention mechanism (10 tests)
#include "graduation/StarvationPrevention.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(below_threshold_not_at_risk);
auto e=StarvationPrevention::assess("py->cpp",3,5);
C(!e.atRisk,"not risk");P();}
void t2(){T(at_threshold_at_risk);
auto e=StarvationPrevention::assess("py->cpp",5,5);
C(e.atRisk,"risk");P();}
void t3(){T(above_threshold_at_risk);
auto e=StarvationPrevention::assess("py->cpp",8,5);
C(e.atRisk,"risk");P();}
void t4(){T(at_risk_promoted);
auto e=StarvationPrevention::assess("py->cpp",5,5);
C(e.promoted,"promoted");P();}
void t5(){T(not_at_risk_not_promoted);
auto e=StarvationPrevention::assess("py->cpp",2,5);
C(!e.promoted,"not promoted");P();}
void t6(){T(pair_id_set);
auto e=StarvationPrevention::assess("rust->go",3,5);
C(e.pairId=="rust->go","pairId");P();}
void t7(){T(wait_cycles_stored);
auto e=StarvationPrevention::assess("py->cpp",7,5);
C(e.waitCycles==7,"cycles");P();}
void t8(){T(count_at_risk_zero);
std::vector<StarvationRiskEntry> v={
StarvationPrevention::assess("a",2,5),
StarvationPrevention::assess("b",3,5)};
C(StarvationPrevention::countAtRisk(v)==0,"zero");P();}
void t9(){T(count_at_risk_nonzero);
std::vector<StarvationRiskEntry> v={
StarvationPrevention::assess("a",6,5),
StarvationPrevention::assess("b",2,5)};
C(StarvationPrevention::countAtRisk(v)==1,"one");P();}
void t10(){T(to_json_has_at_risk);
auto e=StarvationPrevention::assess("py->cpp",6,5);
auto j=StarvationPrevention::toJson(e);
C(j.contains("at_risk"),"json");P();}
int main(){
std::cout<<"Step 882: Starvation prevention\n";
t1();t2();t3();t4();t5();t6();t7();t8();t9();t10();
std::cout<<"\nResults: "<<p<<"/"<<(p+f)<<" passed\n";
return f?1:0;
}