deepseek-ai/deepseek-harness · error · Error

surface replace: start seq

Error message

surface replace: start seq ${op.start} not found in surface

What it means

Lookup failure in replacementRange: the replace operation's start seq does not match any node currently in the surface fold. The cited start of the replacement range refers to an event that was never appended or was already shadowed by an earlier replace.

Solutions

  1. Use a start seq that is currently live in the surface
  2. Re-derive the range against the current fold state instead of a stale snapshot
  3. Avoid chaining replaces that reference nodes an earlier replace already shadowed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/core/session/src/surface.ts:252 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of deepseek-ai/deepseek-harness@b150a551b8 (2026-08-24). Data as JSON: /api/errors/bfc0a6855181a847. Report an issue: GitHub.

Appendix: source

Thrown at packages/core/session/src/surface.ts:252

    }
    if (nonEarlierSource !== undefined) {
      throw new Error(`sourceEventSeqs must reference earlier events: ${nonEarlierSource} >= current seq ${event.seq}`)
    }
  }
  const missing = shadowedSeqs.filter(seq => !sources.has(seq))
  if (missing.length > 0) {
    throw new Error(`surface replace: sourceEventSeqs must include every shadowed surface node; missing ${missing.join(', ')}`)
  }
}

/** Locate one replacement range without mutating the current fold state. */
function replacementRange(
  state: SurfaceFoldState,
  op: Extract<SurfaceOp, { op: 'replace' }>,
): Pick<SurfaceReplacePlan, 'startIdx' | 'endIdx' | 'shadowedSeqs'> {
  const startIdx = state.nodes.indexOf(op.start)
  if (startIdx === -1) {
    throw new Error(`surface replace: start seq ${op.start} not found in surface`)
  }
  const endIdx = state.nodes.indexOf(op.end)
  if (endIdx === -1) {
    throw new Error(`surface replace: end seq ${op.end} not found in surface`)
  }
  if (startIdx > endIdx) {
    throw new Error(`surface replace: start seq ${op.start} (index ${startIdx}) is after end seq ${op.end} (index ${endIdx})`)
  }
  return {
    startIdx,
    endIdx,
    shadowedSeqs: state.nodes.slice(startIdx, endIdx + 1),
  }
}

/**
 * Deep structural equality over the session-event JSON value domain
 * (null/boolean/number/string, arrays, plain objects). Replaces

View on GitHub (pinned to b150a551b8)