UNPKG

aiwg

Version:

Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo

257 lines 7.2 kB
/** * NFR Ground Truth Corpus - Manage validated NFR measurement baselines * * Provides storage, retrieval, and statistical validation of ground truth * NFR measurements for accuracy testing and regression detection. * * Features: * - Store validated NFR measurement baselines * - Load/save corpus data (JSON format) * - Statistical queries (mean, median, percentiles) * - Measurement validation against baselines * - Category-based filtering and analysis * - Environment-specific baselines * * @module testing/nfr-ground-truth-corpus */ /** * NFR category types */ export type NFRCategory = 'Performance' | 'Accuracy' | 'Reliability' | 'Security' | 'Usability'; /** * Measurement data with statistical properties */ export interface Measurement { /** Measured value */ value: number; /** Unit of measurement (e.g., 'ms', 'MB', 'percentage') */ unit: string; /** Raw sample data (optional) */ samples?: number[]; /** Confidence level (0-1) */ confidence: number; } /** * Metadata about measurement context */ export interface Metadata { /** Environment where measurement was taken */ environment: string; /** System architecture */ system: string; /** Node.js version */ nodeVersion: string; /** Additional notes */ notes?: string; } /** * Ground truth entry in corpus */ export interface GroundTruthEntry { /** Unique entry identifier */ id: string; /** NFR identifier (e.g., 'NFR-PERF-001') */ nfrId: string; /** NFR category */ category: NFRCategory; /** Measurement data */ measurement: Measurement; /** Measurement metadata */ metadata: Metadata; /** ISO 8601 timestamp */ timestamp: string; /** Human verification flag */ verified: boolean; } /** * Statistical baseline summary */ export interface BaselineStats { /** NFR identifier */ nfrId: string; /** Number of measurements */ count: number; /** Arithmetic mean */ mean: number; /** Median (50th percentile) */ median: number; /** Standard deviation */ stddev: number; /** Minimum value */ min: number; /** Maximum value */ max: number; /** 95th percentile */ p95: number; /** 99th percentile */ p99: number; } /** * Validation result comparing measurement to baseline */ export interface ValidationResult { /** Whether measurement passes validation */ passes: boolean; /** Actual measured value */ actualValue: number; /** Baseline value (mean) */ baselineValue: number; /** Deviation from baseline (percentage) */ deviation: number; /** Whether deviation is within tolerance */ withinTolerance: boolean; } /** * Category statistics summary */ export interface CategoryStats { /** Category name */ category: NFRCategory; /** Total entries in category */ entryCount: number; /** Unique NFR IDs in category */ uniqueNFRs: number; /** Average confidence across category */ avgConfidence: number; /** Verification rate (percentage) */ verificationRate: number; } /** * NFRGroundTruthCorpus - Manage validated NFR measurement baselines * * @example * ```typescript * const corpus = new NFRGroundTruthCorpus('.aiwg/testing/nfr-ground-truth.json'); * await corpus.load(); * * // Add ground truth measurement * corpus.addEntry('NFR-PERF-001', { * value: 42.5, * unit: 'ms', * confidence: 0.95 * }, { * environment: 'test', * system: 'linux-x64', * nodeVersion: 'v20.0.0' * }); * * // Validate new measurement * const result = corpus.validateMeasurement('NFR-PERF-001', 45.2); * console.log(`Passes: ${result.passes}, Deviation: ${result.deviation.toFixed(2)}%`); * * await corpus.save(); * ``` */ export declare class NFRGroundTruthCorpus { private corpus; private corpusPath; private defaultTolerance; constructor(corpusPath?: string); /** * Load corpus from file * * @throws {Error} If file exists but cannot be parsed */ load(): Promise<void>; /** * Save corpus to file * * @throws {Error} If file cannot be written */ save(): Promise<void>; /** * Add ground truth entry to corpus * * @param nfrId - NFR identifier * @param measurement - Measurement data * @param metadata - Measurement metadata * @param category - NFR category (default: 'Performance') * @param verified - Human verification flag (default: false) */ addEntry(nfrId: string, measurement: Measurement, metadata: Metadata, category?: NFRCategory, verified?: boolean): void; /** * Get all entries for a specific NFR * * @param nfrId - NFR identifier * @returns Array of ground truth entries */ getEntries(nfrId: string): GroundTruthEntry[]; /** * Get all NFR IDs in corpus * * @returns Array of NFR identifiers */ getAllNFRs(): string[]; /** * Remove specific entry from corpus * * @param nfrId - NFR identifier * @param entryId - Entry unique identifier * @returns true if entry was removed, false if not found */ removeEntry(nfrId: string, entryId: string): boolean; /** * Calculate statistical baseline for NFR * * @param nfrId - NFR identifier * @returns Baseline statistics * @throws {Error} If no entries exist for NFR */ getBaselineStats(nfrId: string): BaselineStats; /** * Validate measurement against baseline * * @param nfrId - NFR identifier * @param value - Measured value to validate * @param tolerance - Acceptable deviation (default: 0.10 = 10%) * @returns Validation result * @throws {Error} If no baseline exists */ validateMeasurement(nfrId: string, value: number, tolerance?: number): ValidationResult; /** * Get specific percentile value for NFR * * @param nfrId - NFR identifier * @param percentile - Percentile to calculate (0-100) * @returns Percentile value * @throws {Error} If no entries exist or percentile is invalid */ getPercentile(nfrId: string, percentile: number): number; /** * Get all entries by category * * @param category - NFR category to filter * @returns Array of entries in category */ getEntriesByCategory(category: NFRCategory): GroundTruthEntry[]; /** * Get statistics by category * * @returns Map of category to statistics */ getCategoriesStats(): Map<NFRCategory, CategoryStats>; /** * Get entries by environment * * @param environment - Environment name * @returns Array of entries from environment */ getEntriesByEnvironment(environment: string): GroundTruthEntry[]; /** * Clear all entries from corpus */ clear(): void; /** * Get total number of entries in corpus * * @returns Total entry count */ getTotalEntries(): number; /** * Calculate percentile from sorted array * * @private */ private calculatePercentile; } //# sourceMappingURL=nfr-ground-truth-corpus.d.ts.map