Skip to content

test(link): pin the Child relay wait observer across Home failures, queued aborts and cancels, and correct its comments - #8683

Merged
lidge-jun merged 7 commits into
devfrom
test/link-child-relay-wait-observer-followup
Nov 13, 2026
Merged

lidge-jun merged 7 commits into
devfrom
test/link-child-relay-wait-observer-followup

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Follow-up to #8680 (the Child HTTP relay's test-only wait observer), from its final review. Comments, tests and one structure sentence; no code changes.

  • Comments. src/client/link-websocket-limits.ts and the test header now say:

    • the observer is for the Child's memory acceptance (no test uses it for that yet);
    • it reports false when the reader asks again or the relay ends;
    • "without reading ahead" is gone, because the relay streams underneath read one Home chunk ahead.

    The observer comment also says it reports false when the reader cancels, and never reports true again once the relay has ended. The waitObservation comment in src/client/link-relay.ts says that an unread Home failure keeps the relay waiting while it holds that chunk and its request, until its next read, a reader cancel, a caller abort or (SSE) the idle limit ends it.

  • Tests (tests/clients/link-relay-wait-observer.test.ts), driven by a Home body the test answers read by read. It has a high-water mark of 0, so every read the relay makes is a pull the test waits for before it sends a chunk or a failure. No sleeps, timers or polling.

    • A Home body that fails after one chunk while the relay is reading it ahead (JSON and SSE): exactly [true, false], and the reader's next read fails.
    • A Home failure the relay has not read yet (SSE). The test fails the Home only once the relay has queued its read-ahead chunk, and the Home has seen exactly two reads. The sync point: the SSE relay re-arms its idle timer, through an injected clock that never fires, in the same synchronous step in which it queues each chunk, so the third arm (start, "one", "two") means "two" is queued. The relay's queue is then full and it is not reading the Home, so it stays reported as waiting. It still hands over the held chunk (false, then true). Handing it over frees the relay's queue, so its read-ahead reads the Home, meets the failure and ends the relay without the reader asking again. The test waits for the fourth event and asserts exactly [true, false, true, false]; the reader's next read then fails. That order held in 50 runs of the case.
    • A caller abort while the relay holds a queued second chunk and the Home then stalls (SSE, with the same sync point): exactly [true, false], the Home body is cancelled, and nothing the reader does afterwards reports a wait again. The ordinary-body path has no hook that shows a chunk queued, so the two queued-chunk cases run on SSE only. The case where the Home fails while the relay reads it runs on both.
    • The cancel case now asserts that the reader's cancel reached the Home body.
    • The throwing observer counts its calls and asserts the count is above zero.
  • Structure. In structure/remote-link.md, the sentence after the Child relay's signal now starts "On the Home, ...", since it describes the Home's waits.

What keeps it inert: no runtime code changes. The observer stays null in production, as before.

Tests and how they were checked

These tests pin behaviour that #8680 already has, so they pass on the base. To show they are not vacuous, I ran two mutations on a scratch copy of src/client/link-relay.ts and restored the file afterwards:

  • with the relay cleanup no longer ending the observation (bodyCleanup = cleanup): at a3f8ccbd8, 8 of 12 cases failed, including both new "fails after one chunk" cases and the new queued-chunk abort case. After its last change, the unread-failure case, run alone under the same mutation, also fails (a timeout at its fourth event);
  • with the wrapper's cancel not passed down to the relay, the cancel case fails on home.cancelled().

Verification

  • bun test tests/clients/link-relay-wait-observer.test.ts, 5 runs in a row: 12 pass, 0 fail each
  • bun run typecheck: exit 0; bun run privacy:scan: exit 0; bun run structure:check: exit 0
  • TMPDIR=/tmp bun scripts/test.ts --parallel=2 over link-relay-wait-observer, client-link-relay, link-traffic and link-boundary (under tests/clients/), tests/test-layout.test.ts, tests/test-layout-tooling.test.ts and the file-size, structure and import-cycle ratchets: exit 0, 183 pass, 0 fail (at a3f8ccbd8); at the final head, over link-relay-wait-observer, client-link-relay, link-boundary and the file-size and structure ratchets: exit 0, 118 pass, 0 fail
  • the unread-failure case alone, 50 runs: 50 pass

Review: gpt-6.1-terra at xhigh, read-only, two rounds with the same reviewer. Round 1 found that the queued-chunk cases failed or aborted while the second chunk was still in flight, before the relay had queued it (P2). It is fixed with the idle-timer sync point above. Round 2 had no findings. The final review (approve with nits) found the unread-failure case's checks too loose to fail when the relay misbehaves, and two comments incomplete. All three are fixed in the last three commits, which the coordinator read in place of another terra pass. Open P0-P2: 0.

NOT RUN: the full suite, macOS and Windows.

Checklist

  • No runtime behaviour change
  • structure/remote-link.md updated
  • Tests deterministic (no sleeps, timers or polling)

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Nov 13, 2026
@lidge-jun
lidge-jun marked this pull request as ready for review November 13, 2026 10:18
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 13, 2026 10:18
@lidge-jun
lidge-jun merged commit 6935346 into dev Nov 13, 2026
28 checks passed
@lidge-jun
lidge-jun deleted the test/link-child-relay-wait-observer-followup branch November 13, 2026 10:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T10:19:49.908942Z dafb5a5 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant