/**
 * cli:update-snapshot — types.ts
 *
 * Writes `<moduleRoot>/.run-snapshot.json` from the current pagespecs, so the
 * NEXT `compute-page-diff` run has a baseline to diff against. The orchestrator
 * calls this ONLY after a successful Phase 3a regeneration — never before, so a
 * failed run never poisons the baseline.
 *
 * Kept separate from `compute-page-diff` (which stays a pure read-only spec-diff,
 * AC-F4.1-011): persistence is this CLI's single responsibility.
 */
import { z } from 'zod'

export const UpdateSnapshotInputSchema = z
  .object({
    /** Module folder holding `pagespecs/` — e.g. `.smartstack/ba/<APP>/<MODULE>`. */
    moduleRoot: z.string().min(1),
    /**
     * ISO timestamp recorded as `lastRun`. Injectable for deterministic tests;
     * the CLI fills `new Date().toISOString()` when omitted.
     */
    timestamp: z.string().optional(),
  })
  .strict()

export type UpdateSnapshotInput = z.infer<typeof UpdateSnapshotInputSchema>

export interface UpdateSnapshotReport {
  snapshotPath: string
  pageCount: number
  lastRun: string
  warnings: string[]
}

export interface ValidationResult {
  valid: boolean
  errors: string[]
  warnings: string[]
  spec?: UpdateSnapshotInput
}
