ruvnet/ruflo · error · InMemoryFenceReferenceError

stale-fence

stale-fence

Error message

stale or altered fence ${presented.leaseId}

What it means

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.

Source

Thrown at v3/@claude-flow/codex/src/harness/in-memory-fenced-lease-reference.ts:195

      .sort((left, right) => compare(left.leaseId, right.leaseId))
      .map(copyLease);
  }

  private assertStoredFence(presented: FencedLease): StoredLease {
    const stored = this.leases.get(presented.leaseId);
    if (!stored) throw new InMemoryFenceReferenceError('unknown-lease', `unknown lease ${presented.leaseId}`);
    const current = stored.lease;
    if (
      current.repositoryId !== presented.repositoryId
      || current.sessionId !== presented.sessionId
      || current.workloadId !== presented.workloadId
      || current.worktreeId !== presented.worktreeId
      || current.kind !== presented.kind
      || !sameStrings(current.scopes, presented.scopes)
      || current.epoch !== presented.epoch
      || current.version !== presented.version
    ) {
      throw new InMemoryFenceReferenceError('stale-fence', `stale or altered fence ${presented.leaseId}`);
    }
    return stored;
  }

  private pruneExpired(now: number): void {
    for (const [leaseId, stored] of this.leases) {
      if (stored.expiresAtMs <= now) this.leases.delete(leaseId);
    }
  }
}

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Re-read the current fencing epoch from the lease manager and retry with the fresh fence token.
  2. Do not cache or hand-modify fence tokens; always use the token issued with the lease.
  3. If the lease changed hands, acquire a new lease and discard the old fence token.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at v3/@claude-flow/codex/src/harness/in-memory-fenced-lease-reference.ts:195 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/ef0fca9907df81c8. Report an issue: GitHub.