import { z } from 'zod'; declare const ContextCountsSchema: z.ZodObject<{ code: z.ZodNumber; string: z.ZodNumber; comment: z.ZodNumber; regex: z.ZodNumber; unknown: z.ZodNumber; }, "strip", z.ZodTypeAny, { string: number; code: number; unknown: number; regex: number; comment: number; }, { string: number; code: number; unknown: number; regex: number; comment: number; }>; export type ContextCounts = z.infer; declare const RuleMetricSchema: z.ZodObject<{ /** * Number of times this rule's pattern matched an added line. Includes matches * in non-code contexts (strings, comments) that are recorded as telemetry but * do NOT produce violations. Use `contextCounts.code` for violation count. */ triggerCount: z.ZodNumber; /** Number of times this rule was suppressed via totem-ignore */ suppressCount: z.ZodNumber; /** ISO timestamp of last trigger */ lastTriggeredAt: z.ZodNullable; /** ISO timestamp of last suppression */ lastSuppressedAt: z.ZodNullable; /** Tracks where regex rules fire: code, string, comment, regex, or unknown context */ contextCounts: z.ZodOptional>; /** * Number of lint runs that loaded and evaluated this rule (mmnto-ai/totem#1483). * Incremented once per rule per `totem lint` / `totem review` invocation * regardless of how many matches fire, so `totem doctor` can distinguish a * rule that never ran from a rule that ran many times with zero matches. * Defaults to 0 for pre-#1483 rule-metrics.json files; grows monotonically * and never resets. ADR-088 Phase 1 Layer 4 substrate for stale-rule * detection. */ evaluationCount: z.ZodDefault; }, "strip", z.ZodTypeAny, { triggerCount: number; suppressCount: number; lastTriggeredAt: string | null; lastSuppressedAt: string | null; evaluationCount: number; contextCounts?: { string: number; code: number; unknown: number; regex: number; comment: number; } | undefined; }, { triggerCount: number; suppressCount: number; lastTriggeredAt: string | null; lastSuppressedAt: string | null; contextCounts?: { string: number; code: number; unknown: number; regex: number; comment: number; } | undefined; evaluationCount?: number | undefined; }>; export type RuleMetric = z.infer; declare const RuleMetricsFileSchema: z.ZodObject<{ version: z.ZodLiteral<1>; /** Map of lessonHash → metrics */ rules: z.ZodRecord; /** ISO timestamp of last suppression */ lastSuppressedAt: z.ZodNullable; /** Tracks where regex rules fire: code, string, comment, regex, or unknown context */ contextCounts: z.ZodOptional>; /** * Number of lint runs that loaded and evaluated this rule (mmnto-ai/totem#1483). * Incremented once per rule per `totem lint` / `totem review` invocation * regardless of how many matches fire, so `totem doctor` can distinguish a * rule that never ran from a rule that ran many times with zero matches. * Defaults to 0 for pre-#1483 rule-metrics.json files; grows monotonically * and never resets. ADR-088 Phase 1 Layer 4 substrate for stale-rule * detection. */ evaluationCount: z.ZodDefault; }, "strip", z.ZodTypeAny, { triggerCount: number; suppressCount: number; lastTriggeredAt: string | null; lastSuppressedAt: string | null; evaluationCount: number; contextCounts?: { string: number; code: number; unknown: number; regex: number; comment: number; } | undefined; }, { triggerCount: number; suppressCount: number; lastTriggeredAt: string | null; lastSuppressedAt: string | null; contextCounts?: { string: number; code: number; unknown: number; regex: number; comment: number; } | undefined; evaluationCount?: number | undefined; }>>; }, "strip", z.ZodTypeAny, { version: 1; rules: Record; }, { version: 1; rules: Record; }>; export type RuleMetricsFile = z.infer; /** Load rule metrics from disk. Returns empty metrics if file is missing or invalid. */ export declare function loadRuleMetrics(totemDir: string, onWarn?: (msg: string) => void): RuleMetricsFile; /** Save rule metrics to disk. Creates the directory if needed. */ export declare function saveRuleMetrics(totemDir: string, metrics: RuleMetricsFile): void; /** Record a rule trigger (violation detected). */ export declare function recordTrigger(metrics: RuleMetricsFile, lessonHash: string): void; /** Record a rule suppression (totem-ignore matched). */ export declare function recordSuppression(metrics: RuleMetricsFile, lessonHash: string): void; /** * Record that a lint run loaded and evaluated this rule (mmnto-ai/totem#1483). * Must fire exactly once per rule per lint run — NOT once per match. The * `runCompiledRules` caller loops over every active rule at the end of each * run and calls this helper; multiple triggers on the same rule within one * run still produce only one increment here. * * The caller (`runCompiledRules`) owns loop-once discipline. This helper is * dumb on purpose: it takes a hash and adds one. Downstream consumers * (`totem doctor` stale-rule check) rely on the invariant that * `evaluationCount >= triggerCount / contextCounts.*` never holds in a way * that contradicts "one run = one eval". */ export declare function recordEvaluation(metrics: RuleMetricsFile, lessonHash: string): void; /** Record the AST context where a rule fired. */ export declare function recordContextHit(metrics: RuleMetricsFile, lessonHash: string, context: 'code' | 'string' | 'comment' | 'regex' | undefined): void; export {}; //# sourceMappingURL=rule-metrics.d.ts.map