Skip to content

Commit c6f2bac

Browse files
committed
fix(mothership): guard the run's controller token in the recovery helper and shrink the non-null baseline
1 parent 6a1be75 commit c6f2bac

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎apps/sim/lib/mothership/async-runs/orphaned-runs.integration.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,14 +570,17 @@ describe.runIf(Boolean(redisUrl))('Chat runs no controller owns', () => {
570570
* then claim, so the claimed run has a lock holder for as long as its controller lives.
571571
*/
572572
const recover = async (orphan: Awaited<ReturnType<typeof admittedRun>>) => {
573+
const previousToken = orphan.controllerToken
574+
if (!previousToken)
575+
throw new Error('Recovery needs the run it takes over to have a controller')
573576
if (!(await acquirePendingChatStream(orphan.chatId, orphan.streamId, 0))) return false
574577
const lease = getLocalChatStreamLease(orphan.chatId, orphan.streamId)
575578
if (!lease) throw new Error('Recovery acquired the chat lock without a local lease')
576579
await assertChatStreamLease(lease)
577580
const claimed = await claimRunController({
578581
runId: orphan.runId,
579582
chatId: orphan.chatId,
580-
previousToken: orphan.controllerToken!,
583+
previousToken,
581584
token: lease.value,
582585
recoveryBackoff: FIRST_RECOVERY,
583586
})

‎scripts/check-explicit-any.baseline.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,7 @@
15921592
"apps/sim/lib/mothership/agent-cli/workbench-file-provenance.integration.ts": 4,
15931593
"apps/sim/lib/mothership/agent-cli/workbench-file-provenance.ts": 2,
15941594
"apps/sim/lib/mothership/assistant/tool-policy.test.ts": 2,
1595-
"apps/sim/lib/mothership/async-runs/orphaned-runs.integration.ts": 11,
1595+
"apps/sim/lib/mothership/async-runs/orphaned-runs.integration.ts": 10,
15961596
"apps/sim/lib/mothership/auth/internal.ts": 1,
15971597
"apps/sim/lib/mothership/billing/service-store.integration.ts": 3,
15981598
"apps/sim/lib/mothership/chat/application/context.ts": 1,

0 commit comments

Comments
 (0)