Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | // lib/reflection/types.ts
// --- SIGNALS ---
export const SIGNALS = {
WINDOW_CHURN: 'WINDOW_CHURN',
FOCUS_STABILITY: 'FOCUS_STABILITY',
LATENCY_SUMMARY: 'LATENCY_SUMMARY',
IDLE_RATIO: 'IDLE_RATIO',
WINDOW_LIFETIME: 'WINDOW_LIFETIME',
} as const;
export type SignalType = (typeof SIGNALS)[keyof typeof SIGNALS];
// --- POLICY NAMES ---
export const POLICY_NAMES = {
THROTTLE_WINDOWS: 'THROTTLE_WINDOWS',
DEFER_ANIMATIONS: 'DEFER_ANIMATIONS',
ADJUST_PREFETCH: 'ADJUST_PREFETCH',
TUNE_FOCUS_TIMEOUT: 'TUNE_FOCUS_TIMEOUT',
} as const;
export type PolicyName = (typeof POLICY_NAMES)[keyof typeof POLICY_NAMES];
export type EvalStatus = 'NORMAL' | 'WARNING' | 'CRITICAL';
export interface IntrospectionSignal {
type: SignalType;
value: number;
timestamp: number;
metadata?: Record<string, any>;
}
// Backwards-compatible alias expected by some modules/tests
export type Signal = IntrospectionSignal;
export interface SignalEvaluator {
signal: SignalType;
slos: { threshold: number; status: EvalStatus }[];
}
// -------------------------
// Reflection Snapshot Type
// -------------------------
export interface ReflectionSnapshot {
timestamp: number;
evaluationCount: number;
appliedDecisions: string[];
metrics: { churn: number; focus: number };
}
// Memory entry used by in-memory buffer
export interface ReflectionMemoryEntry {
sequence: number;
timestamp: number;
evaluation?: EvaluationResult;
decision?: FeedbackDecision;
}
export interface EvaluationResult {
signal: IntrospectionSignal;
status: EvalStatus;
slo: { threshold: number; status: EvalStatus } | null;
timestamp: number;
}
export interface FeedbackDecision {
ts: number;
cause: EvaluationResult[];
action: 'THROTTLE_WINDOWS' | 'DEFER_ANIM' | 'ADJUST_PREFETCH' | 'TUNE_FOCUS_TIMEOUT' | 'NOOP';
params?: Record<string, any>;
mode: 'PROPOSED' | 'DRY_RUN' | 'APPLIED';
}
export interface PolicyAdjustment {
policyName: PolicyName;
newValue: number | boolean;
reason: string;
}
export const ReflectionEvent = {
EVALUATION_PERFORMED: 'EVALUATION_PERFORMED',
} as const;
|