import { z } from 'zod';
// Design principle: machine-readable record of a quick task execution.
// Fields are intentionally minimal — just enough for aggregation, traceability,
// and re-verification suggestions. source_finding is best-effort and optional.
const VerificationStatusEnum = z.enum(['pass', 'fail', 'skip']);
const FileChangeSchema = z.object({
    path: z.string().min(1),
    change: z.string().min(1),
});
const VerificationSchema = z.object({
    typecheck: VerificationStatusEnum,
    lint: VerificationStatusEnum,
    visual: VerificationStatusEnum,
    test: VerificationStatusEnum,
    evidence_path: z.string().optional(), // relative path to screenshot inside task dir
});
// Traceability back to a verify-proof run or TOMORROW.md priority item.
// All fields are optional — linkage is best-effort, never blocking.
const SourceFindingSchema = z.object({
    proof_run: z.string().optional(), // e.g. ".aperant/proof/run-20260412/"
    test_id: z.string().optional(), // e.g. "sidebar-collapse-P1"
    priority_id: z.string().optional(), // e.g. "P1-1"
});
const CommitSchema = z.object({
    hash: z.string().min(1),
    message: z.string().min(1),
});
export const QuickTaskSchema = z.object({
    id: z.string().regex(/^(quick-\d{8}-[A-Za-z0-9_-]+|[A-Za-z0-9_-]+_\d{2}-\d{2}-\d{2})$/, {
        message: 'id must be quick-YYYYMMDD-{slug} or canonical {slug}_YY-MM-DD (slug: alphanumeric, hyphens, underscores only)',
    }),
    description: z.string().min(1),
    files_changed: z.array(FileChangeSchema).default([]),
    verification: VerificationSchema,
    commit: CommitSchema,
    source_finding: SourceFindingSchema.optional(),
    timestamp: z.string().regex(/^\d{4}-\d{2}-\d{2}T[\d:.Z+-]+$/, {
        message: 'timestamp must be a full ISO 8601 datetime string',
    }),
    duration_seconds: z.number().int().nonnegative().optional(),
});
// Validator — thin wrapper returning zod's discriminated union { success: true, data } | { success: false, error }
export function validateQuickTask(data) {
    return QuickTaskSchema.safeParse(data);
}
// Pre-computed JSON Schema for use in LLM prompt injection
export const quickTaskJsonSchema = z.toJSONSchema(QuickTaskSchema);
//# sourceMappingURL=quick-task.js.map