import type {
  SerializedExecutionRecord,
  SerializedStepTrace,
} from "./contracts.js";

export type BinaryPair = [number, number];

export interface XorDemoState {
  accepted: BinaryPair[];
  attempts: number;
}

export interface XorCritiqueLayerState {
  activations: number[];
  deltas: number[];
  biases: number[];
}

export interface XorCritique {
  outputs: number[];
  loss: number;
  layer_states: XorCritiqueLayerState[];
}

export interface XorCategory {
  winner: number;
  matched: boolean;
  new_category: boolean;
  delta_vigilance: boolean;
  committed_categories: number;
  vigilance: number;
  expected_vector: number[];
}

export interface XorDecision {
  accepted: boolean;
  label: string;
}

export interface XorStepMetadata {
  critique: XorCritique;
  category: XorCategory;
  decision: XorDecision;
}

export type XorStepTrace = SerializedStepTrace<
  XorDemoState,
  BinaryPair,
  XorStepMetadata
>;

export type XorExecutionRecord = SerializedExecutionRecord<
  XorDemoState,
  BinaryPair,
  XorStepMetadata
>;
