/** * IR Version Store — Types and pure logic for IR snapshot versioning. * * Provides semantic version tagging, integrity verification, changelog * generation, and version resolution. No filesystem I/O — that lives in * the CLI command layer. * * Design notes: * - Deterministic: same inputs always produce same outputs. * - IR is authority: versioning operates on IR, not source. * - Pure functions: no side effects, no I/O. */ import type { IR } from './ir'; import type { IRDiffReport, MigrationReport } from './ir-diff.js'; import type { BreakingChangeReport } from './breaking-change.js'; export interface SemanticVersion { major: number; minor: number; patch: number; } export interface IRVersionMeta { /** Monotonically increasing version number (1-based) */ versionNumber: number; /** Optional semantic version tag (e.g. "1.2.3") */ tag?: string; /** SHA-256 hash of the IR at save time */ irHash: string; /** SHA-256 hash of the source manifest */ contentHash: string; /** ISO timestamp when this version was saved */ savedAt: string; /** Compiler version that generated this IR */ compilerVersion: string; /** IR schema version */ schemaVersion: string; /** Optional human-readable label */ label?: string; } export interface IRVersionIndex { /** Store format version */ storeVersion: 1; /** Current highest version number */ currentVersionNumber: number; /** Ordered list of version metadata (oldest first) */ versions: IRVersionMeta[]; } export interface SaveVersionOptions { /** Explicit semver tag (e.g. "1.2.3") */ tag?: string; /** Auto-generate tag based on diff analysis */ autoTag?: boolean; /** Human-readable label */ label?: string; } export interface VerifyResult { valid: boolean; storedIrHash: string; computedIrHash: string; } export interface ChangelogEntry { fromVersion: number; toVersion: number; fromTag?: string; toTag?: string; diffReport: IRDiffReport; breakingReport: BreakingChangeReport; migrationReport: MigrationReport; } /** Create an empty version index. */ export declare function createVersionIndex(): IRVersionIndex; /** Add a version metadata entry to the index (immutable). */ export declare function addVersionToIndex(index: IRVersionIndex, meta: IRVersionMeta): IRVersionIndex; /** Remove a tag from any version that currently holds it (immutable). */ export declare function removeTagFromIndex(index: IRVersionIndex, tag: string): IRVersionIndex; /** Apply a tag to a specific version number, removing it from any other version. */ export declare function tagVersionInIndex(index: IRVersionIndex, versionNumber: number, tag: string): IRVersionIndex; /** Extract version metadata from an IR and provenance. */ export declare function createVersionMeta(ir: IR, versionNumber: number, options?: SaveVersionOptions): IRVersionMeta; /** Recompute the IR hash and compare against the stored value. */ export declare function verifyIRIntegrity(ir: IR, storedIrHash: string): Promise; /** Parse a semantic version string. Returns undefined for invalid input. */ export declare function parseSemverTag(tag: string): SemanticVersion | undefined; /** Format a SemanticVersion as "major.minor.patch". */ export declare function formatSemver(v: SemanticVersion): string; /** * Auto-increment a semantic version based on diff and breaking-change analysis. * * Rules: * - Breaking changes → major bump * - Compatible/deprecated changes (but no breaking) → minor bump * - No changes → patch bump * - No previous tag → "0.1.0" */ export declare function autoIncrementSemver(currentTag: string | undefined, diffReport: IRDiffReport, breakingReport: BreakingChangeReport): string; /** * Resolve a version reference to a version number. * * Accepts: * - "latest" or undefined → current version * - A number string (e.g. "1", "3") → that version number * - A semver tag (e.g. "1.2.3") → version with that tag */ export declare function resolveVersionRef(index: IRVersionIndex, ref?: string): number | undefined; /** * Generate a changelog between two versions. * Uses the existing diffIR and classifyBreakingChanges engines. */ export declare function generateChangelog(oldIR: IR, newIR: IR, fromMeta: IRVersionMeta, toMeta: IRVersionMeta): ChangelogEntry; //# sourceMappingURL=ir-version-store.d.ts.map