Skip to content

fix(mothership): classify a cancel the worker reports as an explicit stop - #10329

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/mothership-worker-stop-reason
Nov 23, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/mothership-worker-stop-reason

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • A user Stop could be logged at ERROR as "Stream cancelled with unknown abort reason" with an undefined reason, even though finalize correctly treated the turn as an explicit stop
  • Cause: a turn is cancelled when this node's abort signal fired or when the worker's terminal said cancelled. The worker sends a cancelled terminal only for a Stop. When that Stop reached it another way (another Sim node, or the worker's own stop handling), live or replayed during recovery, this node's signal never fired, and recordCancelled read only the signal
  • Fix: recordCancelled uses the new AbortReason.WorkerTerminalStop when the signal is still live, because that is the only other source of a cancelled verdict. Nothing aborts with it, so the controller, its listeners and the SSE close telemetry are unchanged. isExplicitStopReason accepts it, so the span is recorded as an expected stop
  • Also corrects a stale comment in otel.ts that listed only two of the explicit-stop reasons

Type of Change

  • Bug fix

Testing

  • start.test.ts: the existing "cancelled without abortSignal aborted" test now also asserts that no unknown-reason error is logged; it fails on the previous code. The session mock's isExplicitStopReason delegates to the real classifier, so its list can't drift
  • tsc --noEmit and bun run lint clean; lib/mothership/request plus the slack-search assistant (which shares the classifier) pass
  • check-test-types and check-source-conventions pass
  • /simplify review (reuse, simplification, efficiency, altitude). The altitude pass moved the fix from the stream loop to where the verdict is consumed, so recovery replays are covered too

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)

…stop

A turn is cancelled when this node's abort signal fired or when the worker's
terminal said cancelled. The worker sends a cancelled terminal only for a
Stop, but when that Stop reached it another way (another Sim node, or the
worker's own stop handling), live or replayed during recovery, this node's
signal never fired. recordCancelled read only the signal, so a user Stop was
logged at ERROR as "Stream cancelled with unknown abort reason" with an
undefined reason, although finalize correctly reported an explicit stop.

recordCancelled now takes AbortReason.WorkerTerminalStop when the signal is
still live: that is the only other source of a cancelled verdict. Nothing
aborts with it, so the controller, its listeners and the SSE close telemetry
are unchanged. The start test's session mock now delegates to the real
classifier.
@vercel

vercel Bot commented Nov 23, 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 Nov 23, 2026 10:57am 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.

No issues found across 4 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

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Classifies a worker-reported cancellation as an explicit Stop when this node's abort signal has not fired.

  • Worker-reported Stops now count as explicit cancellations.

No actionable issues were found. Tests were inspected but not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Cancelled turn] --> B{Local signal aborted?}
  B -->|Yes| C[Keep signal reason]
  B -->|No| D[Use WorkerTerminalStop]
  C --> E[Classify cancellation]
  D --> E
  E --> F[Record reason and finish span]
Loading

Reviews (1) · Last reviewed commit: "fix(mothership): classify a cancel the w..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 merged commit 5b0fd08 into staging Nov 23, 2026
84 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/mothership-worker-stop-reason branch November 23, 2026 12:08

This branch was previously deployed

1 inactive deployment
Preview — 92b5425b Deployed Nov 23, 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