deepseek-ai/deepseek-harness · error · Error

goal change must be a positive safe integer

Error message

goal change ${field} must be a positive safe integer

What it means

Canonical-form guard in the goal fold's positiveInteger helper: a logged goal-change field (e.g. goal.revision or goal.maxGoalRounds) is not a number ≥ 1 safe integer. Replay of the session log fails loudly on malformed goal changes rather than projecting them.

Solutions

  1. Fix the writer that emitted the goal change to send a positive safe integer
  2. Investigate log corruption if the writer is the harness itself; this indicates a serialization bug, not a user input error
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/goal/goal/src/fold.ts:59 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/247d813f34b2372e. Report an issue: GitHub.

Appendix: source

Thrown at packages/goal/goal/src/fold.ts:59

  return {
    goal: undefined,
    roundsStarted: 0,
    createdAt: undefined,
    updatedAt: undefined,
    lastRef: undefined,
    seenGoalIds: new Set(),
  }
}

/** Whether a value is a JSON record rather than an array. */
function isRecord(value: unknown): value is Record<string, unknown> {
  return typeof value === 'object' && value !== null && !Array.isArray(value)
}

/** Require one positive safe integer. */
function positiveInteger(value: unknown, field: string): number {
  if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 1) {
    throw new Error(`goal change ${field} must be a positive safe integer`)
  }
  return value
}

/** Require one non-negative safe integer. */
function nonNegativeInteger(value: unknown, field: string): number {
  if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) {
    throw new Error(`goal change ${field} must be a non-negative safe integer`)
  }
  return value
}

/** Decode one canonical blocker explanation. */
function decodeBlockReason(value: unknown): GoalBlockReason {
  if (!isRecord(value) || Object.keys(value).sort().join(',') !== 'code,message') {
    throw new Error('goal change goal.blockedReason must have exactly code and message fields')
  }
  if (typeof value['code'] !== 'string' || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(value['code'])) {

View on GitHub (pinned to b150a551b8)