{"record":{"id":"807fbaf623ab5f13","repo":"ruvnet/ruflo","slug":"cannot-supersede-anchor-oldid-not-found","errorCode":null,"errorMessage":"Cannot supersede: anchor \"${oldId}\" not found","messagePattern":"Cannot supersede: anchor \"(.+?)\" not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/guidance/src/truth-anchors.ts","lineNumber":348,"sourceCode":"      }\n    }\n\n    return { valid, invalid };\n  }\n\n  /**\n   * Create a new anchor that supersedes an existing one.\n   *\n   * The old anchor remains in the store (immutable) but the new\n   * anchor's `supersedes` array includes the old anchor's ID.\n   * This creates a verifiable supersession chain.\n   *\n   * Throws if the old anchor ID does not exist.\n   */\n  supersede(oldId: string, params: AnchorParams): TruthAnchor {\n    const old = this.get(oldId);\n    if (!old) {\n      throw new Error(`Cannot supersede: anchor \"${oldId}\" not found`);\n    }\n\n    const supersedes = [...(params.supersedes ?? [])];\n    if (!supersedes.includes(oldId)) {\n      supersedes.push(oldId);\n    }\n\n    return this.anchor({\n      ...params,\n      supersedes,\n    });\n  }\n\n  /**\n   * Resolve a claim against an internal belief.\n   *\n   * Searches for active truth anchors whose claim matches the\n   * provided claim text. If a matching truth anchor exists and","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/guidance/src/truth-anchors.ts#L330-L366","documentation":"Thrown by TruthAnchorStore.supersede(oldId, params) when no anchor with the given ID exists in the store. Supersession works by embedding the old anchor's ID in the new anchor's supersedes array to form a verifiable chain, so the referenced anchor must already exist. Note that the store evicts expired anchors under capacity pressure (LRU), so an ID that once existed can disappear.","triggerScenarios":"Calling supersede with a typo'd or truncated ID; using an ID obtained from a different store instance (e.g. after a restart without re-importing); referencing an anchor that was LRU-evicted after capacity was exceeded; calling supersede before the original anchor() call completed.","commonSituations":"Persisting anchor IDs externally and replaying them against a fresh store; long-running stores where capacity eviction removed old anchors; string-vs-anchor-object confusion (passing an anchor object or its content hash instead of its id field).","solutions":["Verify existence first: if (!store.get(oldId)) throw — use the exact id string returned by anchor creation","Capture and reuse the id returned from const { id } = store.anchor(params) rather than reconstructing IDs by hand","If anchors are being evicted, raise capacity in TruthAnchorConfig or import the historical anchors before superseding"],"exampleFix":"// before\nstore.supersede(oldAnchorId, params); // throws if ID unknown/evicted\n\n// after\nif (!store.get(oldAnchorId)) {\n  throw new Error(`anchor ${oldAnchorId} missing; create or import it first`);\n}\nstore.supersede(oldAnchorId, params);","handlingStrategy":"validation","validationCode":"// Confirm the anchor exists (and has not been evicted) before superseding\nif (!store.get(oldId)) {\n  throw new Error(`cannot supersede '${oldId}': not present in this store (evicted or foreign ID)`);\n}\nconst next = store.supersede(oldId, params);","typeGuard":"function anchorExists(store: TruthAnchorStore): (id: string) => id is string & { __exists: never } {\n  // simpler: just use the boolean below in conditionals\n  return ((id: string) => store.get(id) !== undefined) as never;\n}\n// pragmatic check:\nconst exists = (id: string) => store.get(id) !== undefined;","tryCatchPattern":"try {\n  return store.supersede(oldId, params);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('not found')) {\n    // recover: (re)create the base anchor, then supersede it\n    const base = store.anchor(baseParams);\n    return store.supersede(base.id, params);\n  }\n  throw e;\n}","preventionTips":["Always supersede using the id field returned from store.anchor()","Persist anchor IDs together with the data they certify so they can be re-imported","Size capacity so anchors you plan to supersede are not LRU-evicted first"],"tags":["truth-anchors","supersession","entity-not-found","guidance"],"backgroundTag":"entity-not-found","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}