{"record":{"id":"6f322e8790c746d5","repo":"deepseek-ai/deepseek-harness","slug":"goal-stale-revision","errorCode":"GOAL_STALE_REVISION","errorMessage":"stale goal ref \"${ref.id}\" revision ${ref.revision}; current is \"${current.id}\" revision ${current.revision}","messagePattern":"stale goal ref \"(.+?)\" revision (.+?); current is \"(.+?)\" revision (.+?)","errorType":"exception","errorClass":"GoalError","httpStatus":null,"severity":"error","filePath":"packages/goal/goal/src/index.ts","lineNumber":405,"sourceCode":"    }\n    this.commit(agent, cache, change, 'disarmed')\n    return { ...tombstone }\n  }\n\n  /** Resolve and validate the cache used by a mutation. */\n  private prepareMutation(agent: Agent): GoalCache {\n    this.assertLive(agent)\n    const cache = this.cache(agent.session)\n    this.sync(agent.session, cache)\n    return cache\n  }\n\n  /** Reject stale or missing current-state refs. */\n  private expectCurrent(cache: GoalCache, ref: GoalRef): GoalSnapshot {\n    const current = cache.state.goal\n    if (current === undefined) throw new GoalError('no current goal', 'GOAL_NOT_FOUND')\n    if (ref.id !== current.id || ref.revision !== current.revision) {\n      throw new GoalError(\n        `stale goal ref \"${ref.id}\" revision ${ref.revision}; current is \"${current.id}\" revision ${current.revision}`,\n        'GOAL_STALE_REVISION',\n      )\n    }\n    return current\n  }\n\n  /** Enforce exact live-agent identity rather than trusting a matching id. */\n  private assertLive(agent: Agent): void {\n    if (this.ctx.agents.get(agent.id) !== agent) {\n      throw new GoalError(`agent \"${agent.id}\" is not live in this registry`, 'GOAL_AGENT_NOT_LIVE')\n    }\n  }\n\n  /** Return the per-session cache, folding a seed once with activation disarmed. */\n  private cache(session: Session): GoalCache {\n    let cache = this.caches.get(session)\n    if (cache !== undefined) return cache","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/goal/goal/src/index.ts#L387-L423","documentation":"Optimistic-concurrency guard in expectCurrent: the caller's GoalRef (id and revision) does not match the projected current goal, so the mutation would build on stale state. The message names both the stale and current revisions.","triggerScenarios":"Thrown at packages/goal/goal/src/index.ts:405 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-read the goal with get_goal and copy its exact goal_id and revision","Retry the mutation with the fresh ref"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}