Skip to content

fix(mothership): hold desktop leases, the resume wait and first claims to the call deadline - #9103

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/tool-deadline-ceilings
Oct 16, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/tool-deadline-ceilings

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Resume wait: a pending call's first watchdog deadline is capped at its ceiling, so a call whose worker deadline already passed is failed at deadline + grace instead of a full grace from now
  • Executor: once the recorded deadline is adopted, a call whose start window has closed and that nothing has claimed is settled as "did not run" without taking a claim. A crash between claim and the handler's own refusal can no longer recover it as an unknown outcome. A call that is already claimed (takeover) keeps its existing claim path. The claim predicate itself is unchanged: making the claim refuse would return existing and wait on an owner that does not exist
  • Desktop lease renewal (bound device and chat view) is refused once a call is past its deadline plus the resume grace, the point where the resume wait has already given up on it. The lease then lapses and the existing lapse cleanup settles the call as outcome unknown
  • Rows without a deadline (older workers) behave exactly as before

Type of Change

  • Bug fix

Testing

  • run.test.ts: an already-passed deadline fails at deadline + grace (fails before); a call without a deadline keeps its full budget
  • executor.test.ts: an unclaimed call past its start window is never claimed and records the not-started message (fails before); a claimed one keeps its claim; a call without a deadline is claimed without a settle attempt
  • executor.integration.ts (real Postgres/Redis): renewal inside the grace succeeds; past it, renewal is refused (fails before), and after the lease lapses the cleanup settles the call as outcome unknown; a row without a deadline renews as before
  • bound-turn.integration.ts, handlers and permission suites pass unchanged

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 16, 2026 3:09am UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/mothership/request/tools/executor.ts Outdated
Comment thread apps/sim/lib/mothership/request/tools/executor.ts Outdated
@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; no blocking issues were found.

Summary

This PR keeps tool work and desktop leases within the call’s recorded deadline.

  • Resumed tool waits stop at the worker deadline plus grace.
  • Late, unstarted Sim calls stay unclaimed and settle as never run.
  • Desktop leases stop renewing after the deadline plus grace.

The latest revision moves the first-claim decision under the run’s admission check, so a stopped run is reported as stopped first. No actionable new issues were found. Tests were inspected but not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Sim claim] --> B{Run still admits tools?}
  B -->|No| C[Report stopped]
  B -->|Yes| D{Pending and too late to start?}
  D -->|Yes| E[Leave unclaimed]
  E --> F[Fail only if still pending]
  D -->|No| G[Use existing claim rules]
Loading

Reviews (3) · Last reviewed commit: "fix(mothership): settle a too-late call ..." · Reviewed by Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptileai review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptileai review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit ecc3128 into staging Oct 16, 2026
56 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/tool-deadline-ceilings branch October 16, 2026 03:49

This branch was previously deployed

1 inactive deployment
Preview — 50e66ae7 Deployed Oct 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant