/** * Skill Signals v2 — discriminated-union schema for .specweave/state/skill-signals.json * * v1 (legacy) was a generation-only store produced by SignalCollector * (see src/core/skill-gen/types.ts). v2 adds refinement signals emitted by * closure gates (judge-llm, rubric, code-reviewer) and keeps generation * signals bit-identical except for an added `type: "generation"` discriminator. * * Migration is lazy: the reader detects a v1 file and returns a v2 view in * memory; the next writer call persists v2 to disk. * * @module types/skill-signals */ import { z } from 'zod'; export type SignalSource = 'judge-llm' | 'rubric' | 'code-reviewer'; export type SignalSeverity = 'low' | 'medium' | 'high'; export declare const SIGNAL_SOURCES: readonly SignalSource[]; export declare const SIGNAL_SEVERITIES: readonly SignalSeverity[]; /** * Legacy generation signal produced by SignalCollector. All v1 fields are * preserved; `type: "generation"` is added during migration. */ export interface GenerationSignal { type: 'generation'; id: string; pattern: string; category: string; description: string; incrementIds: string[]; firstSeen: string; lastSeen: string; confidence: number; evidence: string[]; suggested: boolean; declined: boolean; generated: boolean; uniqueSourceFiles?: string[]; } export declare const GenerationSignalSchema: z.ZodObject<{ type: z.ZodLiteral<"generation">; id: z.ZodString; pattern: z.ZodString; category: z.ZodString; description: z.ZodString; incrementIds: z.ZodArray; firstSeen: z.ZodString; lastSeen: z.ZodString; confidence: z.ZodNumber; evidence: z.ZodArray; suggested: z.ZodBoolean; declined: z.ZodBoolean; generated: z.ZodBoolean; uniqueSourceFiles: z.ZodOptional>; }, z.core.$strip>; /** * Refinement signal emitted by a closure gate when a gate failure traces * to a specific skill's instructions. */ export interface RefinementSignal { type: 'refinement'; id: string; source: SignalSource; targetSkill: string; severity: SignalSeverity; incrementId: string; evidence: string; detectedAt: string; consumedBy: string | null; } export declare const RefinementSignalSchema: z.ZodObject<{ type: z.ZodLiteral<"refinement">; id: z.ZodString; source: z.ZodEnum<{ "judge-llm": "judge-llm"; rubric: "rubric"; "code-reviewer": "code-reviewer"; }>; targetSkill: z.ZodString; severity: z.ZodEnum<{ medium: "medium"; low: "low"; high: "high"; }>; incrementId: z.ZodString; evidence: z.ZodString; detectedAt: z.ZodString; consumedBy: z.ZodNullable; }, z.core.$strip>; export type SkillSignal = GenerationSignal | RefinementSignal; export declare const SkillSignalSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"generation">; id: z.ZodString; pattern: z.ZodString; category: z.ZodString; description: z.ZodString; incrementIds: z.ZodArray; firstSeen: z.ZodString; lastSeen: z.ZodString; confidence: z.ZodNumber; evidence: z.ZodArray; suggested: z.ZodBoolean; declined: z.ZodBoolean; generated: z.ZodBoolean; uniqueSourceFiles: z.ZodOptional>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refinement">; id: z.ZodString; source: z.ZodEnum<{ "judge-llm": "judge-llm"; rubric: "rubric"; "code-reviewer": "code-reviewer"; }>; targetSkill: z.ZodString; severity: z.ZodEnum<{ medium: "medium"; low: "low"; high: "high"; }>; incrementId: z.ZodString; evidence: z.ZodString; detectedAt: z.ZodString; consumedBy: z.ZodNullable; }, z.core.$strip>], "type">; /** * v2 on-disk envelope for `.specweave/state/skill-signals.json`. */ export interface SignalFile { schemaVersion: 2; signals: SkillSignal[]; } export declare const SignalFileSchema: z.ZodObject<{ schemaVersion: z.ZodLiteral<2>; signals: z.ZodArray; id: z.ZodString; pattern: z.ZodString; category: z.ZodString; description: z.ZodString; incrementIds: z.ZodArray; firstSeen: z.ZodString; lastSeen: z.ZodString; confidence: z.ZodNumber; evidence: z.ZodArray; suggested: z.ZodBoolean; declined: z.ZodBoolean; generated: z.ZodBoolean; uniqueSourceFiles: z.ZodOptional>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"refinement">; id: z.ZodString; source: z.ZodEnum<{ "judge-llm": "judge-llm"; rubric: "rubric"; "code-reviewer": "code-reviewer"; }>; targetSkill: z.ZodString; severity: z.ZodEnum<{ medium: "medium"; low: "low"; high: "high"; }>; incrementId: z.ZodString; evidence: z.ZodString; detectedAt: z.ZodString; consumedBy: z.ZodNullable; }, z.core.$strip>], "type">>; }, z.core.$strip>; export declare const EMPTY_SIGNAL_FILE: SignalFile; interface V1SignalEntry { id: string; pattern: string; category: string; description: string; incrementIds: string[]; firstSeen: string; lastSeen: string; confidence: number; evidence: string[]; suggested: boolean; declined: boolean; generated: boolean; uniqueSourceFiles?: string[]; } interface V1SignalStore { version: string; signals: V1SignalEntry[]; } /** * Returns true when `raw` conforms to the v1 on-disk shape. * v1 is identified by a string `version` field (e.g. "1.0") and absent * `schemaVersion`. v2 uses a numeric `schemaVersion: 2`. */ export declare function isV1(raw: unknown): raw is V1SignalStore; /** * Migrate a v1 store to v2 without data loss. Adds `type: "generation"` * to every existing entry; all other fields are preserved verbatim. */ export declare function migrateV1toV2(v1: V1SignalStore): SignalFile; export {}; //# sourceMappingURL=skill-signals.d.ts.map