{"record":{"id":"93e8e959ba65641e","repo":"koala73/worldmonitor","slug":"recordwavesent-lease-lost-expected-runid-arg","errorCode":null,"errorMessage":"[_recordWaveSent] lease lost: expected runId=${args.runId}, found ${row.pendingRunId ?? \"<cleared>\"}. Refusing to advance tier — investigate what cleared the lease.","messagePattern":"\\[_recordWaveSent\\] lease lost: expected runId=(.+?), found (.+?)\\. Refusing to advance tier — investigate what cleared the lease\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"convex/broadcast/rampRunner.ts","lineNumber":794,"sourceCode":"    waveLabel: v.string(),\n    broadcastId: v.string(),\n    segmentId: v.string(),\n    assigned: v.number(),\n    sentAt: v.number(),\n  },\n  handler: async (ctx, args) => {\n    const row = await loadConfig(ctx);\n    if (!row) throw new Error(\"[_recordWaveSent] no ramp configured\");\n    if (row.currentTier !== args.expectedCurrentTier) {\n      throw new Error(\n        `[_recordWaveSent] tier moved underneath us: expected ${args.expectedCurrentTier}, found ${row.currentTier}. Refusing to overwrite.`,\n      );\n    }\n    if (row.pendingRunId !== args.runId) {\n      // The lease changed under us — operator force-released it, or\n      // recoverFromPartialFailure cleared it. We must NOT advance the tier;\n      // bubble to Convex auto-Sentry so ops can investigate.\n      throw new Error(\n        `[_recordWaveSent] lease lost: expected runId=${args.runId}, found ${row.pendingRunId ?? \"<cleared>\"}. Refusing to advance tier — investigate what cleared the lease.`,\n      );\n    }\n    await ctx.db.patch(row._id, {\n      currentTier: args.newTier,\n      lastWaveLabel: args.waveLabel,\n      lastWaveBroadcastId: args.broadcastId,\n      lastWaveSegmentId: args.segmentId,\n      lastWaveAssigned: args.assigned,\n      lastWaveSentAt: args.sentAt,\n      lastRunStatus: \"succeeded\",\n      lastRunAt: Date.now(),\n      lastRunError: undefined,\n      pendingRunId: undefined,\n      pendingRunStartedAt: undefined,\n      // Clear all per-step progress markers — this run's state is now in\n      // the lastWave* fields and the markers would otherwise leak into the\n      // next run's recovery surface.","sourceCodeStart":776,"sourceCodeEnd":812,"githubUrl":"https://github.com/koala73/worldmonitor/blob/7d06c8633d256c18e38133030bc3613976a96ec9/convex/broadcast/rampRunner.ts#L776-L812","documentation":"Error \"[_recordWaveSent] lease lost: expected runId=${args.runId}, found ${row.pendingRunId ?? \"<cleared>\"}. Refusing to advance tier — investigate what cleared the lease.\" thrown in koala73/worldmonitor.","triggerScenarios":"Thrown at convex/broadcast/rampRunner.ts:792 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Identify what cleared or replaced pendingRunId: another ramp run started, an admin cancelled the ramp, or a competing _recordWaveSent from a stale worker","Check the ramp config document's history and current pendingRunId to see which run now owns the lease","Discard this run's in-flight wave results; the current lease owner is responsible for tier advancement","Audit other mutations that write pendingRunId and ensure only the lease holder clears or rotates it"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d06c8633d256c18e38133030bc3613976a96ec9","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}