Skip to content

Cleanup: trim draft-20 comments, consolidate tests (no behaviour change) - #101

Merged
floatdrop merged 12 commits into
draft-20from
cleanup/draft20
Sep 26, 2026
Merged

floatdrop merged 12 commits into
draft-20from
cleanup/draft20

Conversation

@floatdrop

Copy link
Copy Markdown
Owner

A cleanup pass over the draft-20 compliance work (#95–#100), which added about 17k lines: 11k of tests and 6k of production code, 38% of that comments. There is no behaviour or API change:

  • production .go files change only in comments, plus two gofmt field re-alignments;
  • tests are consolidated, with no test dropped and no assertion weakened.

Net result: 196 files changed, about 4,400 fewer lines.

Production comments (aggressive trim, as decided)

  • 7ec6c2a message, wire, uri
  • ea63596 session
  • 2b6805d relay: handlers, registry, cache, discovery

What was kept:

  • exported doc comments (contract, errors, concurrency);
  • one-line § citations;
  • one line wherever a spec interpretation or deviation, a lock-ordering or concurrency invariant, or a non-obvious ordering reason would otherwise be lost;
  • //nolint reasons.

History narratives, restatements of the code, and long or repeated spec quotations were removed.

Production Go: 2,849 lines removed, 1,268 added.

Tests

  • 6260ea3 session:
    • one helpers_test.go (a single handshake helper, one close-code recorder, shared stubs);
    • one-fix files folded into topical ones;
    • near-copies table-driven.
  • 9abdcc4 message, 2a1cef5 wire, 2ea4f6e registry, c2e4437 cache, 8338605 discovery: shared helpers, folded files, slices.Equal / generic receive helpers.
  • 80352cc, d99dc81 relay:
    • about 156 helpers reduced to a small set in harness_test.go, helpers_test.go and helpers_fetch_test.go;
    • 12 topical files absorb the one-fix files;
    • the auth-denial, token and cache tests are table-driven.

Tests: 9,995 lines removed, 7,184 added, and 209 test files down to 185.

Nothing lost. I ran the full suite on the base and on this branch:

  • 1,750 executed tests and subtests before, 1,754 after;
  • the 20 top-level names that disappeared each became a case of a table test;
  • no timeouts loosened, and t.Parallel() kept.

A few helpers are stricter than before: Close errors and failed accepts now fail the test.

Review follow-ups (c41519d)

A moqt-reviewer pass over the whole branch found no wire-behaviour change and no weakened test. The comment fixes it prompted:

  • Restored:
    • the "Assumption:" on RegisterInboundTrack (which Track Properties a shared alias keeps);
    • two exported contracts: OpenPublish callers allocate the alias, and AcceptPublish's refusal codes;
    • four invariants the code doesn't show.
  • Citations aligned:
    • omitted FORWARD → §10.2.18;
    • multi-publisher dedup → §9.3;
    • fetch order → §10.13;
    • one response per SUBSCRIBE → §5.1;
    • the §5.1.5 quote corrected.
  • Marked as a choice: §11.4.3's next-Object rule, where the relay uses only "one greater than the previous Object".

Not in this PR

  • Next-Object tests (§11.4.3). The relay reopens a downstream stream at any Object ID gap, even when the upstream skipped IDs on the same stream, which §11.4.3 allows forwarding. That's valid but wasteful; changing it is a behaviour change for a separate branch.
  • Long test files. Four older test files are still over 800 lines (session_pubsub, handler_fanout, cross_relay, datastream_object). They were trimmed but not split.
  • A weak older test. TestTrackStatus_ReplyForKnownTrack passes vacuously if its FETCH is refused. This predates the cleanup.

Testing

  • go build, go vet, golangci-lint: clean.
  • go test ./... and -race on session and relay: pass.
  • make bench-quick: allocs/op at the baseline.
  • make interop-loopback: 6/6 on raw QUIC and on WebTransport.

🤖 Generated with Claude Code

floatdrop and others added 12 commits September 26, 2026 09:50
Shorten the comments added by the draft-20 compliance work: drop long
spec quotations, repeated quotes and restatements of the code, keeping
doc contracts, one-line § citations, and the marked interpretations
(Range Filter scope, repeated Immutable Properties, filter replacement
by type). Comment-only; no code change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Shorten doc comments on the draft-20 compliance additions in
pkg/moqt/session to what a caller must know, cut long and repeated spec
quotations to section citations, and drop history and restated code.
Spec interpretations stay marked. Comment-only; the other changes are
gofmt field alignment.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Comment-only change in pkg/relay non-test files. It drops history narratives,
restatements of the code and long or repeated spec quotations. What stays:
exported contracts (including DiscoveryStore), one-line § citations, lock and
ordering invariants, and marked spec interpretations.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Move shared helpers (session openers, closeRecorder, handRolledSetup,
requireClosedProtocolViolation, requireStaysOpen, subscribePair, ...)
into helpers_test.go, replacing seven near-identical handshake helpers
and two close-recording conns. Fold one-fix files into topical ones:
handshake_test.go (PATH/AUTHORITY, GREASE, early data streams),
malformed_test.go, request_reject_test.go, request_ok_properties_test.go,
setup_token_test.go, fetch_test.go, broker_test.go, session_test.go.
Table-drive near-copies (FIN mid-object, TRACK_STATUS follow-ups, FETCH_OK
End before Start, param-scope openers, PATH/AUTHORITY send refusals) and
trim comments to purpose plus section citation.

Test-only; every test keeps its assertions and timeouts.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…cal files

Move the immutable-search and object-properties tests into
properties_test.go and the range-filter update tests into
rangefilter_eval_test.go, share the property builders, and trim history
from test comments. Test-only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Test-only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Add helpers_test.go with ns() and stubStream, embed the stub in the test
streams, factor the repeated answered-SUBSCRIBE setup, move the queue
reset test into namespace_test.go, cite §5.1 for the single SUBSCRIBE
response, and trim comments. Test-only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The descending case now also inserts out of order. Test-only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Test-only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Shared helpers move to helpers_test.go and the relay harness (pipeListener,
connectRelay, dialAnotherClient, dialRaw) to harness_test.go. Near-duplicates
merge into one helper each:

- publishing: publishVideoTrack/publishVideoTrackProps/publish, with
  newCam1Publisher for the relay-plus-publisher fixture (was
  publishWithTrackProps, publishTrack, publishWithProps, publishSecondCam1);
- Objects: writeSubgroup/publishObjects/sendObjects (was sendObject,
  publishSubgroupObject, publishOneSubgroup, publishObjects);
- subscribing: subscribeCam1 on a given session and newCam1Subscriber for a
  new client (was subscribeCam1Req/subscribeCam1); one subscribeTracks
  (was subscribeTracks/openSubscribeTracks);
- FETCH: tryFetchElems/collectFetchElems over one readFetchResponse, also
  used by fetchStitched (tryStitchFetch/collectFetchGroups removed);
- drainAll replaces drainAllStreams; ns() replaces videoNS, nsFields and the
  wire.TrackNamespace{[]byte(...)} literals; requireSessionClosed replaces
  the inline Done()/2s selects; slices/maps replace equalIDs/sortedKeys.

The one-fix files from the draft-20 compliance work fold into topical ones:
subscribe_tracks, malformed_track, cache, publish_done, forward_state,
request_stream, data_stream, track_status, rangefilter_relay,
session_update, session_namespace and relay_upstream.

TestRelay_MaxCacheDurationExpiresCachedObject and
TestRelay_MaxCacheDurationZeroNeverServesFromCache become the subtests of
TestRelay_MaxCacheDurationNotServedFromCache. No other test is removed or
changes what it asserts; no production code changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Test doc comments shrink to a line or two of purpose plus the § citation;
history narratives and long spec quotations go. Citations the review
flagged are corrected: multi-publisher dedup is §9.3, UPDATE_FAILED is
§10.9.1, and §9.5/§10.7 are no longer cited for claims they do not make.

Near-copies become tables:
- TestRelay_AuthDenialUsesPolicyCode replaces the six per-request
  *_AuthDenialUsesPolicyCode tests (SUBSCRIBE, FETCH, TRACK_STATUS,
  PUBLISH_NAMESPACE, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS);
- TestSessionHandler_TokenVerification replaces TokenDenialMapsToRequestError
  and TokenAllowReachesHandler (token_verify_test.go is folded into
  session_handler_test.go).
Each keeps its assertions as a subtest.

FETCH helpers move to helpers_fetch_test.go to keep helpers_test.go small;
every helper has a doc comment; locsEqual, the discovery import sentinel
and a hand-rolled clone/search give way to slices.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…cts and invariants

From the moqt-reviewer pass over the cleanup branch (comment lines only):

- Restore the "Assumption:" on RegisterInboundTrack: the draft does not
  say which Track Properties a shared alias carries (the trim had
  presented the repo's choice as §2.5).
- Restore two exported-API details: OpenPublish's caller allocates the
  alias, and AcceptPublish's refusal codes (UNSUPPORTED_EXTENSION for an
  unknown Mandatory Track Property, MALFORMED_TRACK for unparseable
  properties).
- Restore four invariants the code does not show:
  - why the relay's upstream sub is set to Forward=0;
  - the trackKnown coupling for the eagerly created entry;
  - RunWriter taking one message at a time for the queue bound;
  - why UpdatePrefix's old-prefix lookup is exact.
- Citations:
  - the remaining omitted-FORWARD §10.7 → §10.2.18;
  - multi-publisher dedup and redundant upstreams §9.5 → §9.3, matching
    the tests;
  - the §5.1.5 quote corrected.
- §11.4.3: mark the relay's use of only "one greater than the previous
  Object" as a choice among the draft's three next-Object tests.
- Fix a stale [subgroupWriter.join] link, and reflow three overlong
  comment lines.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@floatdrop
floatdrop merged commit 1c05ec0 into draft-20 Sep 26, 2026
11 checks passed
@floatdrop
floatdrop deleted the cleanup/draft20 branch September 26, 2026 05:50
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