{"record":{"id":"feb236519c55ed83","repo":"ruvnet/ruflo","slug":"scope-conflict","errorCode":"scope-conflict","errorMessage":"scope conflicts with active lease ${current.leaseId}","messagePattern":"scope conflicts with active lease (.+?)","errorType":"exception","errorClass":"InMemoryFenceReferenceError","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/codex/src/harness/in-memory-fenced-lease-reference.ts","lineNumber":104,"sourceCode":"  private readonly leases = new Map<string, StoredLease>();\n  private readonly repositoryEpoch = new Map<string, bigint>();\n\n  constructor(private readonly now: () => number = Date.now) {}\n\n  acquire(request: FencedLeaseRequest): FencedLease {\n    const repositoryId = text(request.repositoryId, 'repositoryId');\n    const scopes = [...new Set(request.scopes.map((scope) => normalizeScope(request.kind, scope)))]\n      .sort(compare);\n    if (!scopes.length || !Number.isSafeInteger(request.ttlMs) || request.ttlMs <= 0) {\n      throw new InMemoryFenceReferenceError('invalid-request', 'lease requires scopes and a positive safe ttlMs');\n    }\n    const now = this.now();\n    this.pruneExpired(now);\n    for (const stored of this.leases.values()) {\n      const current = stored.lease;\n      if (current.repositoryId !== repositoryId || current.kind !== request.kind) continue;\n      if (current.scopes.some((held) => scopes.some((wanted) => overlaps(request.kind, held, wanted)))) {\n        throw new InMemoryFenceReferenceError(\n          'scope-conflict',\n          `scope conflicts with active lease ${current.leaseId}`,\n        );\n      }\n    }\n\n    const epoch = (this.repositoryEpoch.get(repositoryId) ?? 0n) + 1n;\n    this.repositoryEpoch.set(repositoryId, epoch);\n    const expiresAtMs = now + request.ttlMs;\n    if (!Number.isSafeInteger(expiresAtMs)) {\n      throw new InMemoryFenceReferenceError('invalid-request', 'lease expiry exceeds safe timestamp range');\n    }\n    const lease: FencedLease = {\n      leaseId: `lease-${randomUUID()}`,\n      repositoryId,\n      sessionId: text(request.sessionId, 'sessionId'),\n      workloadId: text(request.workloadId, 'workloadId'),\n      worktreeId: text(request.worktreeId, 'worktreeId'),","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/codex/src/harness/in-memory-fenced-lease-reference.ts#L86-L122","documentation":"Thrown when acquiring a lease whose scope overlaps an already-active lease. Defense: check for existing active leases on the same scope before acquiring; release or wait for the conflicting lease to expire, and retry with the current fencing epoch.","triggerScenarios":"Thrown at v3/@claude-flow/codex/src/harness/in-memory-fenced-lease-reference.ts:104 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Release or wait out the active lease that covers the requested scope before acquiring again.","Acquire the lease with a scope that does not overlap the scope of the conflicting lease.","List active leases and renew the existing one instead of requesting a new lease for the same scope."],"exampleFix":null,"handlingStrategy":null,"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-14T00:17:10.932Z"}