/** * Spec Validator - validates specifications against constitutional constraints * * @module strategies/speckit/spec-validator */ import type { Constitution, SpecContent, ValidationReport, ValidationResult } from "./types.js"; /** * Validates specification documents against a design "constitution" * composed of principles, constraints, architecture rules, and design principles. * * Typical usage is to create an instance for a given {@link Constitution} and then * call {@link SpecValidator#validate} for each {@link SpecContent} you want to * check for alignment and coverage. * * @example * ```ts * import { SpecValidator } from "./spec-validator.js"; * import type { Constitution, SpecContent } from "./types.js"; * * const constitution: Constitution = loadConstitutionSomehow(); * const validator = new SpecValidator(constitution); * * const spec: SpecContent = { * title: "Payments Service ADR", * overview: "Describes the architecture and design decisions for the payments service.", * }; * * const result = validator.validate(spec); * * if (!result.valid) { * // Inspect result.issues and result.score to understand gaps and violations. * } * ``` */ export declare class SpecValidator { private constitution; constructor(constitution: Constitution); /** * Validate a specification against the constitution * * @param spec - The specification content to validate * @returns Validation result with score and issues */ validate(spec: SpecContent): ValidationResult; /** * Check if spec aligns with a principle * * @param spec - The specification content * @param principle - The principle to check * @returns ValidationIssue if violation found, null otherwise */ private checkPrinciple; /** * Check if spec violates a constraint * * @param spec - The specification content * @param constraint - The constraint to check * @returns ValidationIssue if violation found, null otherwise */ private checkConstraint; /** * Check architecture compliance * * @param spec - The specification content * @param rule - The architecture rule to check * @returns ValidationIssue if violation found, null otherwise */ private checkArchitectureRule; /** * Check design principle compliance * * @param spec - The specification content * @param principle - The design principle to check * @returns ValidationIssue if violation found, null otherwise */ private checkDesignPrinciple; /** * Generate a comprehensive validation report * * @param spec - The specification content to validate * @returns Comprehensive validation report with metrics and categorization */ generateReport(spec: SpecContent): ValidationReport; /** * Categorize validation results by constraint type * * @param result - The validation result * @returns Breakdown of results by constraint type */ private categorizeResults; /** * Generate recommendations based on validation results * * @param result - The validation result * @returns List of recommendations for improvement */ private generateRecommendations; /** * Format validation report as GitHub-flavored markdown * * @param report - The validation report to format * @returns Markdown-formatted report */ formatReportAsMarkdown(report: ValidationReport): string; } /** * Factory function to create a SpecValidator instance * * Convenience factory for instantiating a {@link SpecValidator}. * Equivalent to `new SpecValidator(constitution)`. * * @param constitution - The constitution to validate against * @returns A new SpecValidator instance * * @example * ```ts * import { createSpecValidator } from "./spec-validator.js"; * import { parseConstitution } from "./constitution-parser.js"; * * const constitution = parseConstitution(constitutionMarkdown); * const validator = createSpecValidator(constitution); * * const result = validator.validate(mySpec); * ``` */ export declare function createSpecValidator(constitution: Constitution): SpecValidator; //# sourceMappingURL=spec-validator.d.ts.map