Skip to content

test(js/net): a recovery's CANCEL echo no longer fails the lost-run wire check - #9203

Merged
kixelated merged 1 commit into
mainfrom
quest/m0/test-flakes-3/js-lost-run-cancel-echo
Nov 19, 2026
Merged

kixelated merged 1 commit into
mainfrom
quest/m0/test-flakes-3/js-lost-run-cancel-echo

Conversation

@kixelated

@kixelated kixelated commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

js/net/src/lite/drop_record.test.ts, "a sequence whose run the relay forgot is filled for a wide reader", fails intermittently in the merge queue (run 44577207435, run 44571188329). It asserts that no non-OLD drop crosses the wire after the run is forgotten, and it sometimes sees { hop: "down", start: 1n, end: 2n, error: 1 } (CANCEL).

It is a test race, not a relay forwarding bug. During the narrow reader's phase, the viewer's recovery subscription for groups 1 and 2 is left owing nothing once the narrow reader judges them stale. It aborts the groups and stops their streams with CANCEL (untilAbandoned in lite/subscriber.ts). If the relay already wrote the group's FIN, the stop is a no-op. If the stop arrives first, the relay's write fails, and its publisher names the group in SUBSCRIBE_DROP with the stop's code. Both TS and Rust do this on purpose (Rust's a_stopped_group_stream_is_dropped_with_its_stop_code). The viewer's recovery reads that drop as a passing refusal (lost: false), which answers only the fills owing the group at that moment and is recorded nowhere, so it settles no reader. In every failing run, the wide reader still received groups 1 and 2 with no drop.

Approach

  • tap() marks each subscription opened after the chain's two (the relay's upstream and the viewer's) as recovery.
  • The lost-run wire check still rejects every non-OLD drop, except a CANCEL drop on a recovery subscription, which is the publisher echoing the subscriber's own stop.
  • Fixes stale Mirrors Rust ... comments in the file. Three named Rust tests that no longer exist now name their current counterparts. The lost-run pair's mirror is removed, since it has no Rust counterpart.

Validation

All loops ran the whole drop_record.test.ts file under quest gate, with one busy loop per core as load. On its own, the test passed 200/200 without load.

  • Before (this branch's parent, an earlier main): 15 failures in 400 loaded file runs (1/60, 8/120, 5/120, 1/100), about 3.7%. Each was this test at line 519.
  • Instrumented: in the failing runs, the relay's publisher logged stop sending: 1 on group 1's stream before its FIN. Passing runs logged the FIN first.
  • After: 0 failures in 1000 loaded file runs (300 + 700), where the old rate predicts about 37. In the 300 instrumented runs, the race still fired 11 times (3.7%). Every row the new exclusion dropped was exactly {"hop":"down","recovery":true,"kind":"drop","start":"1","end":"2","error":1}, and the wide reader's own checks (no drop, groups 1 and 2 filled) held each time.
  • just check passed.

Impact

  • Public API: none. Wire: none. Test-only.

Alternatives

  • Force one ordering of the stop and the FIN: both orderings are legal on a real network, so the test would cover only one of them.
  • Stop the publisher from naming a subscriber-stopped stream: Rust relies on this so a subscriber learns which group a stream stopped before its header carried. Changing it would be a wire behavior change in both languages for no reader-visible gain.
  • Drop the wire check: the assertion still catches a stale give-up forwarded with any code but OLD on the copy-feeding subscriptions, and any non-CANCEL drop on a recovery.

Decisions

Made headless, as a child of the test-flakes epic. Each can be undone in review:

  • ✅ Planned and fixed in this one PR (rejected: a separate plan PR first). quest start claims only quests already on main, and this session merges nothing. The quest (quest/m0/test-flakes-3/js-lost-run-cancel-echo.md, S, m0, because flakes join the open m0 epic) would be created and deleted here, so it has no file and its decisions are recorded here.
  • ✅ Narrow the exclusion to CANCEL on recovery subscriptions (rejected: excluding every drop on a recovery). Any other code on a recovery still fails the test.

Caused by

  • moq-dev/moq#8908 - replaced the check's exclusion of single-group drops for groups already received with a strict OLD-only filter, which counts a recovery's CANCEL echo (found by queue).

Follow-ups

None.

Models

Size: S
Implementer: Claude Code, claude-opus-5-5, unknown effort

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 73d8a22

  • Base: origin/main at 947d61c

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1f523-d75c-7b80-b68c-bd87628e89fe, round 1

  • Score: 9/10, Source review found no actionable defects in the recovery-subscription CANCEL handling test, but tests were not run as instructed.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

…ire check

A viewer's recovery stops a group no fill owes any more with CANCEL. When the
stop beats the relay's FIN, the relay names that group in SUBSCRIBE_DROP with
the stop's code, by design. The recovery takes it as a passing refusal that
settles nothing, but the test counted it as a settling drop. The tap now marks
subscriptions opened after the chain's two, and the check excludes only a
recovery's CANCEL. Also fixes stale Rust mirror test names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 19, 2026 18:49
@kixelated
kixelated enabled auto-merge November 19, 2026 18:50

@pullfrog pullfrog 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 new issues found.

Approach: sound. The test narrows its wire check to ignore only the subscriber's own CANCEL echo on a recovery subscription, and every other non-OLD drop still fails it.

Reviewed changes: the single test file js/net/src/lite/drop_record.test.ts.

  • recovery tagging in tap(): subscriptions opened after the chain's first two are marked recovery. The fallback for an unknown reader is recovery: true, which matches the hops.size >= 2 rule.
  • Lost-run wire check: it excludes only CANCEL drops on a recovery. I confirmed the exclusion is limited to that one code and that StreamCode.Cancel exists.
  • Comment fixes: the three renamed Mirrors Rust ... references point to Rust tests that exist in rs/moq-net/tests/integration/drop_record.rs. The mirror for the lost-run pair is dropped because it has no Rust counterpart.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The drop-record test helper now records whether decoded drops and skips came from recovery subscriptions. The lost-run test excludes OLD drops and recovery CANCEL drops from its final-drop check. Test names and Rust mirror comments describe the corresponding scenarios more specifically.

Merge Risk: Minimal · up to 73d8a

This change only makes an intermittent drop-record test less flaky. It does not alter runtime or wire behavior, and no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the recovery subscription's CANCEL drop echo no longer fails the lost-run wire check in the js/net test. The raw summary and objectives confirm the test exclusion for …
Description check Passed The description explains the intermittent failure of the drop_record test, the race between the stop and FIN, the approach that marks recovery subscriptions and excludes only recovery CANCEL drops, an…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the recovery subscription's CANCEL drop echo no longer fails the lost-run wire check in the js/net test. The raw summary and objectives confirm the test exclusion for CANCEL drops on recovery subscriptions, so the title matches the changeset.

Full details: Description check

Explanation

The description explains the intermittent failure of the drop_record test, the race between the stop and FIN, the approach that marks recovery subscriptions and excludes only recovery CANCEL drops, and the validation runs. It is directly related to the changeset.

Finishing Touches

Simplify code

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b355ca67-93c5-4a26-8412-3e798f5f7dcc
Commits

Reviewing files that changed from the base of the PR and between 947d61c and 73d8a22.

Files selected for processing: 1

  • js/net/src/lite/drop_record.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

Merged via the queue into main with commit 6c4c508 Nov 19, 2026
7 checks passed
@kixelated
kixelated deleted the quest/m0/test-flakes-3/js-lost-run-cancel-echo branch November 19, 2026 19:07
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