/** * Reality Score System - Hallucination Detection via Testability * * Core insight: The more testable/verifiable an edit is, the more "real" it is. * High reality score = grounded in verifiable facts * Low reality score = potentially hallucinated * * This scoring system works even without running full RL tournaments - * it provides instant feedback on whether an edit is likely to be real. */ /** * Reality score breakdown for an edit operation */ export interface RealityScore { /** Overall reality score 0-100 (higher = more real/testable) */ total: number; /** Individual component scores */ components: { /** Does the target file exist? (0-20) */ fileExists: number; /** Does the old_string content actually exist in the file? (0-25) */ contentMatch: number; /** Will the resulting code be syntactically valid? (0-20) */ syntaxValid: number; /** Are imports/dependencies real and resolvable? (0-15) */ importsValid: number; /** Can we run a quick test to verify? (0-20) */ testable: number; }; /** Confidence level based on what we could verify */ confidence: 'high' | 'medium' | 'low'; /** Potential hallucination indicators */ warnings: string[]; /** What tests/checks passed */ passed: string[]; /** What tests/checks failed */ failed: string[]; } /** * Edit operation to score */ export interface EditOperation { filePath: string; oldString: string; newString: string; replaceAll?: boolean; } /** * Score an edit operation for reality/testability */ export declare function scoreEditReality(edit: EditOperation): RealityScore; /** * Quick reality check - returns true if edit is likely real, false if potentially hallucinated */ export declare function quickRealityCheck(edit: EditOperation): { isReal: boolean; reason: string; }; /** * Get a human-readable summary of the reality score */ export declare function formatRealityScore(score: RealityScore): string; /** * Score threshold recommendations */ export declare const REALITY_THRESHOLDS: { /** Edits below this score should be rejected */ REJECT: number; /** Edits below this score need human review */ REVIEW: number; /** Edits at or above this score can proceed automatically */ AUTO_APPROVE: number; }; /** * Edit outcome for RL feedback */ export interface EditOutcome { /** Timestamp of the edit */ timestamp: number; /** File that was edited */ filePath: string; /** Reality score at time of edit */ realityScore: number; /** Confidence level */ confidence: 'high' | 'medium' | 'low'; /** Did the edit succeed without issues? */ success: boolean; /** Was there a build error after? */ buildError?: boolean; /** Was there a test failure after? */ testFailure?: boolean; /** Was the edit reverted? */ reverted?: boolean; /** Time until outcome was determined (ms) */ outcomeDelayMs?: number; } /** * RL feedback statistics */ export interface RLFeedbackStats { /** Total edits tracked */ totalEdits: number; /** Success rate by confidence level */ successRates: { high: { total: number; success: number; rate: number; }; medium: { total: number; success: number; rate: number; }; low: { total: number; success: number; rate: number; }; }; /** Average score for successful edits */ avgSuccessScore: number; /** Average score for failed edits */ avgFailureScore: number; /** Optimal threshold (where success rate crosses 80%) */ optimalThreshold: number; /** Score distribution */ scoreDistribution: { '0-25': number; '26-50': number; '51-75': number; '76-100': number; }; } /** * Record an edit outcome for RL learning */ export declare function recordEditOutcome(outcome: EditOutcome): void; /** * Record a successful edit */ export declare function recordSuccessfulEdit(filePath: string, score: RealityScore, outcomeDelayMs?: number): void; /** * Record a failed edit (build error, test failure, revert) */ export declare function recordFailedEdit(filePath: string, score: RealityScore, reason: 'build_error' | 'test_failure' | 'reverted' | 'other'): void; /** * Calculate RL feedback statistics */ export declare function calculateRLStats(): RLFeedbackStats; /** * Get RL feedback recommendation for current session */ export declare function getRLRecommendation(): string; /** * Clear RL feedback buffer (for testing or reset) */ export declare function clearRLFeedback(): void; //# sourceMappingURL=realityScore.d.ts.map