{"record":{"id":"ef0fca9907df81c8","repo":"ruvnet/ruflo","slug":"stale-fence","errorCode":"stale-fence","errorMessage":"stale or altered fence ${presented.leaseId}","messagePattern":"stale or altered fence (.+?)","errorType":"exception","errorClass":"InMemoryFenceReferenceError","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/codex/src/harness/in-memory-fenced-lease-reference.ts","lineNumber":195,"sourceCode":"      .sort((left, right) => compare(left.leaseId, right.leaseId))\n      .map(copyLease);\n  }\n\n  private assertStoredFence(presented: FencedLease): StoredLease {\n    const stored = this.leases.get(presented.leaseId);\n    if (!stored) throw new InMemoryFenceReferenceError('unknown-lease', `unknown lease ${presented.leaseId}`);\n    const current = stored.lease;\n    if (\n      current.repositoryId !== presented.repositoryId\n      || current.sessionId !== presented.sessionId\n      || current.workloadId !== presented.workloadId\n      || current.worktreeId !== presented.worktreeId\n      || current.kind !== presented.kind\n      || !sameStrings(current.scopes, presented.scopes)\n      || current.epoch !== presented.epoch\n      || current.version !== presented.version\n    ) {\n      throw new InMemoryFenceReferenceError('stale-fence', `stale or altered fence ${presented.leaseId}`);\n    }\n    return stored;\n  }\n\n  private pruneExpired(now: number): void {\n    for (const [leaseId, stored] of this.leases) {\n      if (stored.expiresAtMs <= now) this.leases.delete(leaseId);\n    }\n  }\n}\n","sourceCodeStart":177,"sourceCodeEnd":206,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/codex/src/harness/in-memory-fenced-lease-reference.ts#L177-L206","documentation":"Thrown when the fencing token presented with a lease is stale or altered. Defense: always present the exact token issued at acquisition or last renewal; on this error, discard cached tokens and re-acquire the lease.","triggerScenarios":"Thrown at v3/@claude-flow/codex/src/harness/in-memory-fenced-lease-reference.ts:195 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-read the current fencing epoch from the lease manager and retry with the fresh fence token.","Do not cache or hand-modify fence tokens; always use the token issued with the lease.","If the lease changed hands, acquire a new lease and discard the old fence token."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}