export interface GraphNodeSpec {
  node_id: string;
  node_type: string;
  input_names: string[];
  output_names: string[];
}

export interface GraphEdgeSpec {
  source_node_id: string;
  source_output: string;
  target_node_id: string;
  target_input: string;
}

export interface GraphSchema {
  nodes: GraphNodeSpec[];
  edges: GraphEdgeSpec[];
}

export interface ArtifactEnvelope<Payload = unknown> {
  artifact_type: string;
  schema_version: string;
  payload: Payload;
  metadata: Record<string, unknown>;
}

export interface ArtifactManifestEntry {
  artifact_type: string;
  file_name: string;
}

export interface ArtifactManifest {
  schema_version: string;
  artifacts: ArtifactManifestEntry[];
  metadata: Record<string, unknown>;
}

export interface SequenceAnalysis {
  item_count: number;
  alphabet_size: number;
  unigram_entropy_bits: number;
  conditional_entropy_bits: number;
  normalized_entropy: number;
  predictability: number;
  redundancy: number;
}

export interface RunReport {
  parameters: Record<string, unknown>;
  accepted_count: number;
  attempt_count: number;
  total_seconds: number;
  sequence_analysis: Partial<SequenceAnalysis>;
  average_attempts_per_accept: number;
}

export interface SerializedStepTrace<
  State = unknown,
  Candidate = unknown,
  Metadata = unknown
> {
  previous_state: State;
  next_state: State;
  candidate: Candidate;
  accepted: boolean;
  elapsed_seconds: number;
  metadata: Metadata | null;
}

export interface SerializedExecutionRecord<
  State = unknown,
  Candidate = unknown,
  Metadata = unknown
> {
  accepted: SerializedStepTrace<State, Candidate, Metadata>[];
  attempts: SerializedStepTrace<State, Candidate, Metadata>[];
  final_state: State;
  total_seconds: number;
}
