AIXC / docsProject documentation

Reference

Codec State Machine

Look up syntax, contracts, layouts, algorithms, and exact behavior.

A conforming implementation can be reconstructed as two lockstep state machines. The encoder and decoder both maintain a context buffer, a predictor handle, a unit index, and stream cursors. The encoder additionally observes the source unit at each index; the decoder additionally observes the next decision bit and residual cursor.

state E = {
  context: unit[]
  index: number
  predictor: Predictor
  decisions: bit[]
  residuals: unit[]
}

for source[index]:
  prediction = predictor.argmax(context)
  if prediction == source[index]:
    decisions.push(1)
  else:
    decisions.push(0)
    residuals.push(source[index])
  context.push(source[index])
  index += 1
Encoder state. The encoder records only prediction failures as residuals; the context always advances with the true source unit.
state D = {
  context: seed
  index: number
  predictor: Predictor
  decisionCursor: number
  residualCursor: number
}

while output.length < originalLength:
  prediction = predictor.argmax(context)
  if decisions[decisionCursor] == 1:
    unit = prediction
  else:
    unit = residuals[residualCursor]
    residualCursor += 1
  output.push(unit)
  context.push(unit)
  decisionCursor += 1
Decoder state. The decoder consumes residuals exactly at miss positions and feeds reconstructed units back into predictor context.
0≤residualCursori≤decisionCursori≤unitIndexi0 \le residualCursor_i \le decisionCursor_i \le unitIndex_i
Cursor invariant. The residual cursor cannot advance except when a consumed decision bit is a miss.