Skip to content

test(link): the Child's link WebSocket memory acceptance (design 6.3, 11.2-9), opt-in - #8686

Merged
lidge-jun merged 15 commits into
devfrom
test/link-child-rss-acceptance
Nov 13, 2026
Merged

lidge-jun merged 15 commits into
devfrom
test/link-child-rss-acceptance

Conversation

@lidge-jun

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

Copy link
Copy Markdown
Owner

Summary

The Child's link WebSocket release gate (linkWebsocketChildReady in src/client/link-websocket-limits.ts) stays closed until two things have passed: the framer's client conformance run and the Child's memory acceptance. The Autobahn run is in #8681. Until now the Child had no memory acceptance; the Home has one (tests/e2e-style/link-websocket-rss.test.ts, with #8647's settle rule). This PR adds the Child's, shaped like the Home's, and records three settled passing runs. It changes nothing under src/ and opens no gate.

What the test does. tests/e2e-style/link-websocket-rss-child.test.ts is opt-in with OCX_LINK_WS_RSS_CHILD_ACCEPTANCE=1. It runs the same held load twice, each time through a fresh Child process (tests/fixtures/link-ws-rss-child.ts): the real Child listener, link WebSocket relay and HTTP relay, with the Child's gate opened in that process only through the relay's ready seam. The Codex-side clients and a stand-in Home (tests/fixtures/link-ws-standin-home.ts) stay in the test process, so they do not count against the Child's RSS.

  • 8 Codex-side sockets (the Child's cap) each send a near-8 MiB request (8,323,072 bytes of input) and then stop reading.
  • The stand-in Home answers only once the whole request has arrived: the complete create frame on the WebSocket, every byte of the declared content-length over HTTP. The test records each load request's size at the Home and requires all 8 to be whole on both transports.
  • It answers with near-4 MiB events, written onto TCP in the Home acceptance's chunk plan (1 byte to 16 MiB), and holds each stream after 16 MiB. For the WebSocket run the events are server text frames; for the HTTP run, the same events as a chunked SSE body.
  • The Child's HTTP relay accepts request bodies up to 256 MiB (LINK_RELAY_BODY_MAX_BYTES), so both loads carry the same request; nothing is scaled down.
  • One warm-up turn on each transport, with the same near-maximum input, runs before the idle reading.
  • The sockets are cut in a seeded random order; the test waits until the Child has closed its side of every cut Home connection (its legs and relays), and only then reads the peak (the Home acceptance's order). That wait is bounded: a Child that has not closed its side 30 s after the cut fails the run, and cleanup still runs.

When it counts as settled. The Child process itself announces the stall:

  • WebSocket: every Home leg paused, i.e. more than 1 MiB waits toward Codex (the relay's onDownlinkPause seam). A paused leg that ends reports "resumed" as it finishes, which drops the count; the fixture also counts the relay's releases (onReleased, once a leg's Home connection has closed and its slot is freed) as a second guard: the idle reading waits for the warm-up socket's release (30 s at most, else the run is invalid), and a release after it and before the stall is announced makes the run invalid, so a load that lost a leg can never settle.
  • HTTP: every relayed response waiting for its reader, through setLinkChildRelayWaitObserverForTests (test(link): report the Child's HTTP relay waiting for its reader to a test-only observer #8680, contract as corrected in test(link): pin the Child relay wait observer across Home failures, queued aborts and cancels, and correct its comments #8683): true after a chunk is handed to a reader that has not asked for the next one; false when it asks again or cancels, or when the relay ends. The relay reads one Home chunk ahead, so "waiting" means the reader holds a chunk and the relay may hold one more.
  • The settle rule is the Home fixture's (fix(link): link WebSocket readiness follow-ups: settled memory acceptance, the Home counts link sockets, and the review nits of #8622 and #8625 #8647), copied so the Home's fixture stays as it was measured: the stall is announced only after a 2.5 s quiet window in which every reader stayed waiting and VmHWM did not rise. A load not settled 180 s after the idle reading fails; the deadline never passes a run.
  • The observer reports every relayed response, management reads included. The fixture counts every transition from the start. The test sends nothing else through the Child during the load and requires: no wait open at the idle reading (the warm-up turns have ended theirs); while settling, the fixture reports the run invalid if more readers wait than the load has or the count goes below zero; and the peak answer carries the lowest and highest counts from the idle reading through the peak reading, which must be 0 and 8. Otherwise a wrong HTTP signal can only make that run settle early or never: an early HTTP settle lowers the HTTP peak, which makes the acceptance harder to pass, and a run that never settles fails at the deadline.

Accepted when both Child processes reported their own settled stall, both peaks are the kernel's high-water mark (VmHWM, reset after the idle reading; a sampled peak cannot pass), and the WebSocket run's peak over idle minus the HTTP run's is at most 8 reservations (8 x 32 MiB = 256 MiB). OCX_LINK_WS_RSS_CHILD_SOCKETS (the only other setting) makes the run a diagnostic that prints its numbers and asserts no budget. The test runs on Linux only (elsewhere it skips with the reason: the peak is VmHWM, and a sampled peak cannot pass).

structure/remote-link.md names the test beside the Home's acceptance. Passing it is one of the two conditions on the Child's gate; what else the gate-opening change owes for the TypeScript Child is in devlog/_plan/261113_link_websocket_gate_opening/000_plan.md (TypeScript Child items 2 to 7). The same branch corrects that unit's item 3: 3 retries is the gate's setting (stream_max_retries = 3 in the Codex provider config that runGateCodex in tests/helpers/link-gate-codex.ts writes), and 5 is Codex's default.

Results

A trial and three canonical runs on f75a98eb9 (dev eb727e1ba merged, plus the review commits), Linux x86_64 (kernel 6.12.113), Bun 1.4.4, clean tree, each the only heavy job on a 4-core, 15.6 GiB VM, under a watcher that would have stopped the run if MemAvailable fell below 1.5 GiB. The trial's lowest MemAvailable (9,001 MiB) stayed above 4 GiB, so the three runs followed.

Run WS idle WS peak WS over idle WS settle HTTP idle HTTP peak HTTP over idle HTTP settle WS minus HTTP budget lowest MemAvailable
trial 109.0 MiB 288.8 MiB 179.8 MiB 3.2 s 105.9 MiB 191.8 MiB 85.9 MiB 2.9 s 93.9 MiB 256 MiB 9,001 MiB
1 103.6 MiB 274.0 MiB 170.4 MiB 3.2 s 102.2 MiB 197.3 MiB 95.2 MiB 2.8 s 75.2 MiB 256 MiB 9,048 MiB
2 102.7 MiB 303.6 MiB 200.8 MiB 3.1 s 104.2 MiB 195.9 MiB 91.8 MiB 2.8 s 109.1 MiB 256 MiB 9,102 MiB
3 102.3 MiB 260.5 MiB 158.2 MiB 3.2 s 102.7 MiB 195.0 MiB 92.3 MiB 2.9 s 65.9 MiB 256 MiB 9,069 MiB

Each run: exit 0, 1 pass, 8-10 s wall, both peaks kernel-vmhwm, websocketSync: child-legs-paused, httpSync: child-relays-waiting, and every check in the test held (the warm-up socket released and no wait open at the idle reading, wait counts between 0 and 8 through the peak, no link socket released before the stall, every load request received whole by the Home, every cut connection closed by the Child before the peak was read). Per socket, the WebSocket transport added 8.2 to 13.6 MiB over the HTTP relay (66-109 MiB over 8 sockets), well inside the 32 MiB reservation. After the cut the Child returned to 100-111 MiB. Across all recordings so far (75b2f16a5, 325acfccc, f75a98eb9) the difference has ranged from 66 to 113 MiB.

The raw lines of each run (the two load lines and the acceptance line):

trial {"method":"kernel-vmhwm","transport":"websocket","sockets":8,"idleMiB":108.95703125,"peakMiB":288.7578125,"deltaMiB":179.80078125,"perSocketMiB":22.47509765625,"budgetMiB":256,"quietWindowMs":2500,"settleMs":3216,"afterCutMiB":102.8828125,"inputBytes":8323072}
trial {"method":"kernel-vmhwm","transport":"http","sockets":8,"idleMiB":105.87890625,"peakMiB":191.828125,"deltaMiB":85.94921875,"perSocketMiB":10.74365234375,"budgetMiB":256,"quietWindowMs":2500,"settleMs":2916,"afterCutMiB":110.63671875,"inputBytes":8323072}
trial {"acceptance":true,"sockets":8,"websocketSync":"child-legs-paused","httpSync":"child-relays-waiting","websocketMinusHttpMiB":93.8515625,"budgetMiB":256}
run-1 {"method":"kernel-vmhwm","transport":"websocket","sockets":8,"idleMiB":103.6015625,"peakMiB":273.97265625,"deltaMiB":170.37109375,"perSocketMiB":21.29638671875,"budgetMiB":256,"quietWindowMs":2500,"settleMs":3219,"afterCutMiB":99.6796875,"inputBytes":8323072}
run-1 {"method":"kernel-vmhwm","transport":"http","sockets":8,"idleMiB":102.1796875,"peakMiB":197.34375,"deltaMiB":95.1640625,"perSocketMiB":11.8955078125,"budgetMiB":256,"quietWindowMs":2500,"settleMs":2820,"afterCutMiB":103.72265625,"inputBytes":8323072}
run-1 {"acceptance":true,"sockets":8,"websocketSync":"child-legs-paused","httpSync":"child-relays-waiting","websocketMinusHttpMiB":75.20703125,"budgetMiB":256}
run-2 {"method":"kernel-vmhwm","transport":"websocket","sockets":8,"idleMiB":102.74609375,"peakMiB":303.5703125,"deltaMiB":200.82421875,"perSocketMiB":25.10302734375,"budgetMiB":256,"quietWindowMs":2500,"settleMs":3127,"afterCutMiB":100.02734375,"inputBytes":8323072}
run-2 {"method":"kernel-vmhwm","transport":"http","sockets":8,"idleMiB":104.17578125,"peakMiB":195.92578125,"deltaMiB":91.75,"perSocketMiB":11.46875,"budgetMiB":256,"quietWindowMs":2500,"settleMs":2821,"afterCutMiB":105.1640625,"inputBytes":8323072}
run-2 {"acceptance":true,"sockets":8,"websocketSync":"child-legs-paused","httpSync":"child-relays-waiting","websocketMinusHttpMiB":109.07421875,"budgetMiB":256}
run-3 {"method":"kernel-vmhwm","transport":"websocket","sockets":8,"idleMiB":102.33984375,"peakMiB":260.50390625,"deltaMiB":158.1640625,"perSocketMiB":19.7705078125,"budgetMiB":256,"quietWindowMs":2500,"settleMs":3243,"afterCutMiB":99.87109375,"inputBytes":8323072}
run-3 {"method":"kernel-vmhwm","transport":"http","sockets":8,"idleMiB":102.69140625,"peakMiB":194.98828125,"deltaMiB":92.296875,"perSocketMiB":11.537109375,"budgetMiB":256,"quietWindowMs":2500,"settleMs":2917,"afterCutMiB":108.6796875,"inputBytes":8323072}
run-3 {"acceptance":true,"sockets":8,"websocketSync":"child-legs-paused","httpSync":"child-relays-waiting","websocketMinusHttpMiB":65.8671875,"budgetMiB":256}

Verification

Final head f75a98eb9: the runs above were made on it. The dev merge is a0b176739 (dev eb727e1ba, #8681); its only conflict was the last line of the explicit map in scripts/test-layout/layout.json, where link-websocket-rss-child.test.ts, link-websocket-child-gate.test.ts and link-websocket-child-restart.test.ts now appear once each (and once each in tests/fixtures/test-layout-expected.json); git show --remerge-diff a0b176739 touches only that line. Runs on the earlier heads are kept under superseded-4502be331/, superseded-c6beadb35/ and superseded-325acfccc/ and are not evidence.

  • ~/handoff/rss-child-run.sh <dir> ×4 (a trial and three runs) (OCX_LINK_WS_RSS_CHILD_ACCEPTANCE=1 bun test tests/e2e-style/link-websocket-rss-child.test.ts under the MemAvailable watcher, no other OCX_LINK_WS_RSS_CHILD_* set): exit 0 each, 1 pass, watcher never fired; results above.
  • Mutations on f75a98eb9, each reverted (exit 1 each, no Child process left over): the budget cut to 64 MiB fails the size assertion (received 76.8 MiB); the fixture told the load has 7 stalls instead of 8 reports the run invalid ("more readers waited than the load has"); the HTTP stand-in answering before the body has arrived fails the body check; a wait left open at the idle reading fails the idle check; one WebSocket client cut after the load is in place and before the stall reports the run invalid ("a link socket was released before the stall was announced"); the close deadline at 1 ms fails the run ("the Child did not close 1 Home connections within 1 ms of the cut"); a warm-up release that never arrives reports the run invalid after the 30 s bound ("the warm-up socket was not released before the idle reading").
  • A 2-socket diagnostic run earlier (OCX_LINK_WS_RSS_CHILD_SOCKETS=2) passed as a diagnostic; it is not evidence.
  • Without the opt-in variable: bun test tests/e2e-style/link-websocket-rss-child.test.ts exit 0, 0 pass, 2 skip.
  • tests/test-layout.test.ts, tests/test-layout-tooling.test.ts and tests/ci-workflows/structure-ssot.test.ts: exit 0, 80 pass. bun run structure:check exit 0; bun run privacy:scan exit 0.
  • bun check --no-script --noEmit on the two new files: no error in them. (Checking files one by one also reports dev's existing type errors in tests/helpers/link-ws-child.ts and tests/fixtures/link-ws-standin-home.ts, at lines this PR does not change; the repository's typecheck uses the project configuration.)
  • CI: tests/fixtures/ changes put this PR on the full Ubuntu lane; the full shards must pass on its head.
  • NOT RUN:

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed (structure/remote-link.md).
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults (test-only; the Child's gate is opened only inside the fixture process; the gate stays closed).

@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.

@lidge-jun
lidge-jun marked this pull request as ready for review November 13, 2026 12:15
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 13, 2026 12:15
@lidge-jun
lidge-jun merged commit 050548f into dev Nov 13, 2026
33 checks passed
@lidge-jun
lidge-jun deleted the test/link-child-rss-acceptance branch November 13, 2026 12:15
@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-13T12:16:49.397607Z f75a98e 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