Skip to content

mcpx/testsupport: replay Send honours its context (#17221 slice 3) - #17234

Merged
developing-today-fleet[bot] merged 2 commits into
mainfrom
xaltha/0900s-17221-replay-ctx
Nov 30, 2026
Merged

developing-today-fleet[bot] merged 2 commits into
mainfrom
xaltha/0900s-17221-replay-ctx

Conversation

@developing-today-fleet

@developing-today-fleet developing-today-fleet Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Refs #17221 (slice 3 of 3 — the replay leg; slice 1 is lane 0900-N's bin-args timeouts, slice 2 the era-probe race, both tracked on the issue).

Defect

ReplayTransport.Send dropped its context.Context (_ context.Context) and waited on a sync.Cond for the recorded interleave. Nothing could cancel that wait. Send is synchronous — mcpclient's call reaches its own ctx.Done select only after Send returns — so a stalled interleave held the caller's goroutine past its deadline. That is the transport contract every other Send honours (stated in mcpclient's TestAHungServerDoesNotOutliveTheCallTimeout), and the shape behind the ubuntu stress failure in run 46433738642: TestReplayTruncatedTraceFailsTheCall's first call sat out its whole 10s context (replay_test.go:332, context deadline exceeded) under -race -shuffle 6839106235133155819 -count=3.

Replay is the only Send whose blocking is a peer-condition wait rather than I/O (checked: HTTP honours ctx; stdio/record/sse/supervised perform writes or forward), so the fix is scoped to it.

Fix

Replace the cond with a broadcast wake channel (closed and replaced under the mutex on every state change). Send selects on the wake channel and ctx.Done() while waiting and returns the context's error; expiry records no divergence, so the replay is not poisoned and can still be driven to completion. Recv/Close/divergence wake through the same channel with unchanged behaviour.

Tests (failing-first, per the mcpx testing doctrine)

New replay_ctx_test.go, oracle = the context, not the clock:

  • deadline expires while Send waits on the interleave → context.DeadlineExceeded
  • cancel while Send waits → context.Canceled
  • context expiry does not poison the replay (owed frame still Recvs; a fresh Send completes; Finish passes)
  • a waiting Send still completes once Recv advances the interleave

Failing-first evidence: run 46447246624 (fleet-command, exact head bb242a9, tests only) — both context cases FAIL with "Send outlived its context while waiting on the interleave".

Verification of this head: run 46448919826 (fleet-command) — go test ./internal/testsupport/ -run 'TestReplay|TestRecordReplay|TestClientTraceCapture|TestDialCapture' -race -shuffle=on -count=5 plus a full-package -count=1 pass; conclusion recorded on #17221.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-30T15:19:41Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": "/home/hatch",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/hatch",
      "repo": "developing-today/code",
      "branch": "main",
      "sha": "a5c7d0c9db1fd1918e903ac85cd57eb87faf2620"
    },
    "auth_subject": "xaltha",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…lice 3)

Failing-first: ReplayTransport.Send ignores its context entirely and
cond-waits on the recorded interleave, so a stalled interleave cannot
be cancelled by the caller's deadline — the shape behind the ubuntu
stress failure of TestReplayTruncatedTraceFailsTheCall (10.01s,
context deadline exceeded, run 46433738642). The cases name the
context as oracle: deadline while waiting, cancel while waiting,
expiry does not poison the replay, and a waiting Send still completes
when the interleave advances.
ReplayTransport.Send dropped its context and waited on a sync.Cond
for the recorded interleave; nothing could cancel that wait, so a
stalled interleave held the caller's goroutine past its deadline —
Send is synchronous, and the client reaches its ctx select only
after Send returns (mcpclient's transport contract, stated in
TestAHungServerDoesNotOutliveTheCallTimeout).

Replace the cond with a broadcast wake channel (closed and replaced
on every state change). Send now selects on the wake channel and
ctx.Done while waiting and returns the context's error; expiry
records no divergence, so the replay is not poisoned and can still
be driven to completion. Recv, Close and divergence wake through
the same channel with unchanged behaviour.
@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8541d308-d4d1-4af0-a058-27b0d3781580

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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