import { z } from 'zod'; import type { RuleCategory, RuleDepth } from '../checkRules.js'; import type { VisualizerSpec } from '../visualizerModel.js'; export { VisualizerSpecSchema } from '../visualizerModel.js'; export type { VisualizerSpec } from '../visualizerModel.js'; export interface Relation { type: 'blocks' | 'blocked-by' | 'relates'; issueId: string; } export interface Source { id: string; kind: string; ref?: string; content?: string; } export interface Proof { explanation: string; evidenceRefs: string[]; } export interface BlockRef { issue: string; ac?: string; } export declare const PRIMITIVES: readonly ["labels", "relations", "children", "sources", "category", "proof", "blocking", "audit"]; export type PrimitiveName = (typeof PRIMITIVES)[number]; export interface CoreEvidence { id: string; } export interface CoreAC { id: string; status: string; evidence: CoreEvidence[]; category?: string; proof?: Proof; blockedBy?: BlockRef[]; blocks?: BlockRef[]; } export interface CoreIssue { id: string; title: string; summary: string; status: string; acceptanceCriteria: CoreAC[]; labels?: string[]; relations?: Relation[]; children?: string[]; sources?: Source[]; } export interface CoreRoot { issues: CoreIssue[]; } export interface Origin { path: string; lineStart?: number; lineEnd?: number; } export interface IssueRecord { id: string; title: string; status: string; assignee?: string; labels?: string[]; children?: string[]; body: string; origin?: Origin; } export interface IssueColumns { title?: string; status?: string; assignee?: string; labels?: string[]; children?: string[]; } export interface WaiverDirective { issueId: string; code: string; reason: string; approvedBy: string; acId?: string; ref?: string; } export interface AuditEntry { ts: string; issueId: string; op: string; field?: string; from?: string; to?: string; actor?: string; } export type Severity = 'error' | 'warning' | 'acknowledged'; export interface Finding { code: string; severity: Severity; message: string; issueId?: string; acId?: string; evidenceId?: string; subject?: string; waivable?: boolean; fix?: string; origin?: FindingOrigin; } export interface FindingOrigin { path: string; line?: number; } export interface ParseDiagnostic { code: string; severity?: 'error' | 'warning'; message: string; issueId?: string; } export interface Context { now?: string; phase?: 'all' | 'gate'; git?: { currentSha?: string; existingCommits?: string[]; prs?: Record; branches?: Record; evidenceBlobs?: Record; commitFiles?: Record; }; world?: { events?: readonly { id: string; service: string; type?: string; text?: string; annotationRequired?: boolean; }[]; annotations?: readonly { id: string; service?: string; eventId: string; classification: 'source' | 'noise' | 'duplicate'; quote?: string; }[]; }; categories?: Partial>; relevance?: 'optional' | 'required'; waivers?: WaiverDirective[]; } export declare const CoreContextSchema: z.ZodObject<{ now: z.ZodOptional; phase: z.ZodOptional>; git: z.ZodOptional; existingCommits: z.ZodOptional>; prs: z.ZodOptional; merged: z.ZodOptional; }, z.core.$strict>>>; branches: z.ZodOptional>; evidenceBlobs: z.ZodOptional>; commitFiles: z.ZodOptional>>; }, z.core.$strict>>; world: z.ZodOptional; text: z.ZodOptional; annotationRequired: z.ZodOptional; }, z.core.$strict>>>; annotations: z.ZodOptional; eventId: z.ZodString; classification: z.ZodEnum<{ source: "source"; noise: "noise"; duplicate: "duplicate"; }>; quote: z.ZodOptional; }, z.core.$strict>>>; }, z.core.$strict>>; categories: z.ZodOptional>; relevance: z.ZodOptional>; waivers: z.ZodOptional; ref: z.ZodOptional; }, z.core.$strict>>>; }, z.core.$strict>; /** The ONE top-level schema: ValidationInput = { context, root }, both strict. A * preset may pass an extended contextSchema for its own observed facts. */ export declare function makeValidationInputSchema(rootSchema: z.ZodType, contextSchema?: z.ZodTypeAny): z.ZodType>; export interface ValidationInput { context: Context; root: R; } export interface Located { issueId?: string; acId?: string; evidenceId?: string; } export interface ModelIssue { issueId: string; issue: R['issues'][number]; } export interface ModelAC { issueId: string; acId: string; issue: R['issues'][number]; ac: R['issues'][number]['acceptanceCriteria'][number]; } export interface ModelEvidence extends ModelAC { evidenceId: string; ev: R['issues'][number]['acceptanceCriteria'][number]['evidence'][number]; } export interface CycleFact extends Located { issueId: string; cycle: string[]; } export interface BlockerFact extends Located { issueId: string; acId: string; kind: 'missing' | 'self'; refText: string; } export interface CompletionFact extends Located { issueId: string; nodeKey: string; depKey: string; depStatus: string; } export interface DerivedModel { root: R; context: Context; issues: Array>; acs: Array>; evidence: Array>; duplicateIssueIds: Array<{ issueId: string; }>; duplicateAcIds: Array<{ issueId: string; acId: string; }>; graph: { cycles: CycleFact[]; blockerProblems: BlockerFact[]; completionViolations: CompletionFact[]; }; derived: Record; } export interface RuleRecord { code: string; severity?: Severity; phase?: 'gate' | 'transition'; state?: string | string[]; category?: RuleCategory; depth?: RuleDepth; waivable?: boolean; select: (m: DerivedModel) => Item[]; when?: (item: Item, m: DerivedModel) => boolean; message: (item: Item, m: DerivedModel) => string; subject?: (item: Item, m: DerivedModel) => string; } export type Rule = RuleRecord; /** Authoring helper: infers the selected item type so `when`/`message` are typed, * while storing as the existential `Rule` a preset's `rules` array holds. */ export declare function rule(r: RuleRecord): Rule; /** The blessed preset constructor a repo-local preset calls — today an identity, but a * stable seam so installed presets read `definePreset({...})` and we can add inference * or validation later without breaking them. */ export declare function definePreset(preset: Preset): Preset; export interface PresetContextInput { projectRoot: string; verifyCommits?: boolean; bundle?: string; root?: CoreRoot; } export interface Preset { name: string; schema: z.ZodType; contextSchema?: z.ZodTypeAny; loadContext?: (input: PresetContextInput) => Context | Promise; parse: (records: IssueRecord[]) => unknown; serialize?: (issue: R['issues'][number]) => { body: string; columns: IssueColumns; }; normalizeAcPatch?: (patch: Record, current: Record) => Record; rules: Rule[]; derive?: (model: DerivedModel) => Record; isIssueDone?: (issue: R['issues'][number]) => boolean; primitives?: Partial>; scaffold?: (title: string) => string; fixHint?: (finding: Finding) => string | undefined; visualizer?: VisualizerSpec; } export interface CheckResult { ok: boolean; findings: Finding[]; export?: R; examinedIssues?: number; } export declare function deriveCoreModel(root: R, context: Context, isIssueDone?: (issue: R['issues'][number]) => boolean): DerivedModel; export declare function parseWaiverLine(line: string): { code: string; acId?: string; ref?: string; reason: string; approvedBy: string; } | null; export declare function parseWaivers(records: IssueRecord[]): WaiverDirective[]; export declare function liftDiagnostics(candidate: unknown, originById?: Map): { root: unknown; findings: Finding[]; }; /** The one entry point: parse -> ValidationInputSchema.parse({context, root}) -> * pure rules. The validated Root is the export; nothing downstream re-parses or * re-derives. */ export declare function check(preset: Preset, records: IssueRecord[], ctx?: Context): CheckResult; /** Validate an already-parsed Root (the exported, validated model) against the same * schema + rules — the entry point for `check --input ` and CI. */ export declare function checkRoot(preset: Preset, root: unknown, ctx?: Context): CheckResult;