71 lines
2.5 KiB
C++
71 lines
2.5 KiB
C++
|
|
// Step 1879 TDD: GR-010 — SemanticCompletionGate enforces meaningful semantic threshold
|
||
|
|
//
|
||
|
|
// ImprovementPromotionGate had a threshold of 0.02 (nearly anything passes) and no
|
||
|
|
// depth tracking. SemanticCompletionGate requires score >= 0.70 and depth <= 5.
|
||
|
|
//
|
||
|
|
// t1: score=0.95, depth=0, humanApproved=false → passed (score >= 0.90 auto-pass)
|
||
|
|
// t2: score=0.75, depth=0, humanApproved=true → passed (human approved)
|
||
|
|
// t3: score=0.50, depth=0, humanApproved=false → NOT passed (below threshold)
|
||
|
|
// t4: score=0.95, depth=6 → NOT passed (depth exceeded)
|
||
|
|
// t5: score=0.75, depth=3, humanApproved=false → NOT passed (needs human approval)
|
||
|
|
|
||
|
|
#include "SemanticCompletionGate.h"
|
||
|
|
#include <iostream>
|
||
|
|
#include <string>
|
||
|
|
|
||
|
|
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(high_score_auto_passes);
|
||
|
|
auto r = SemanticCompletionGate::evaluate(0.95f, 0, false);
|
||
|
|
C(r.passed, "score=0.95 should auto-pass (≥0.90 threshold)");
|
||
|
|
C(r.reason == "accepted", "expected reason=accepted, got " + r.reason);
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t2(){
|
||
|
|
T(human_approved_above_threshold_passes);
|
||
|
|
auto r = SemanticCompletionGate::evaluate(0.75f, 0, true);
|
||
|
|
C(r.passed, "human-approved score=0.75 should pass");
|
||
|
|
C(r.reason == "accepted", "expected reason=accepted");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t3(){
|
||
|
|
T(score_below_threshold_fails);
|
||
|
|
auto r = SemanticCompletionGate::evaluate(0.50f, 0, false);
|
||
|
|
C(!r.passed, "score=0.50 is below 0.70 threshold → should not pass");
|
||
|
|
C(r.reason == "score_below_semantic_threshold",
|
||
|
|
"expected score_below_semantic_threshold, got " + r.reason);
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t4(){
|
||
|
|
T(depth_exceeded_fails);
|
||
|
|
auto r = SemanticCompletionGate::evaluate(0.95f, 6, true);
|
||
|
|
C(!r.passed, "depth=6 exceeds max=5 → should not pass regardless of score");
|
||
|
|
C(r.reason == "max_depth_exceeded",
|
||
|
|
"expected max_depth_exceeded, got " + r.reason);
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t5(){
|
||
|
|
T(mid_score_without_approval_fails);
|
||
|
|
auto r = SemanticCompletionGate::evaluate(0.75f, 3, false);
|
||
|
|
C(!r.passed, "score=0.75 without human approval should not pass (needs approval)");
|
||
|
|
C(r.reason == "human_approval_required",
|
||
|
|
"expected human_approval_required, got " + r.reason);
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
int main(){
|
||
|
|
std::cout<<"Step 1879: GR-010 SemanticCompletionGate semantic threshold enforcement\n";
|
||
|
|
t1();t2();t3();t4();t5();
|
||
|
|
std::cout<<"\nResults: "<<p<<"/"<<(p+f)<<" passed\n";
|
||
|
|
return f?1:0;
|
||
|
|
}
|