agentleFS
CloudflareKnown publishercloudflare/workerd/src/tests/streams/readable/AGENTS.md

workerd / readable

AGENTS.md8.8k starsChanged 9 months agoApache-2.0View on GitHub

Informal specification of the value-oriented ReadableStream as implemented in workerd, derived from — and kept in lockstep with — this suite. The tests are the normative artifact. Byte streams (type:'bytes', BYOB) belong to the readable-byte suite; the pipeTo/ pipeThrough matrix belongs to piping/. The suite COMPLEMENTS WPT (//src/wpt:streams). Probing the C++ expectedFailures showed many root-cause to a handful of construction divergences (hwm Infinity rejection, validation order) rather than behavioral gaps; the reentrancy family is mostly parity at finite hwm.

Trending

Quiet since August.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 2 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the cloudflare/workerd repository that our weekly crawl found: only 12 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about cloudflare/workerd

The biggest 5 of 12 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 12

Talked about on GitHub, Bluesky and Hacker News (12 times).

On GitHub · 6

1 more on GitHub

On Hacker News · 2

The file

Files
AGENTS.md

ReadableStream (default), ReadableStreamDefaultReader/Controller

Informal specification of the value-oriented ReadableStream as implemented in workerd, derived from — and kept in lockstep with — this suite. The tests are the normative artifact. Byte streams (type:'bytes', BYOB) belong to the readable-byte suite; the pipeTo/ pipeThrough matrix belongs to piping/.

The suite COMPLEMENTS WPT (//src/wpt:streams). Probing the C++ expectedFailures showed many root-cause to a handful of construction divergences (hwm Infinity rejection, validation order) rather than behavioral gaps; the reentrancy family is mostly parity at finite hwm.

Divergence ledger (C++ vs TypeScript)

#AreaC++TypeScriptPinned in
1garbage underlyingSourceaccepts null, rejects numbersrejects null (spec), accepts numbersgarbageSourceValidation
2ctor argument conversion ordersource.type, hwm, sizestrategy size, hwm, then source.type (spec)argumentConversionOrder
3invalid hwm (-1/NaN) + InfinityTypeError; Infinity REJECTED (integer conversion) — root cause of many WPT reentrant/errors failuresRangeError; Infinity accepted (spec)highWaterMarkValidated
4pull counts (hwm 1, enqueue-in-pull)1,1,3 — first read served from queue without pull, deferred pulls batch1,2,3 (spec: pull after start and every read)pullCountShape
5pull on reading the LAST queued chunkno pullpulls (spec)pullOnLastChunkRead
6sync start() throwcaptured; stream erroredescapes constructor (spec)syncStartThrow
7reader.closed after releaseLockSAME promise object, settled state keptREPLACED with TypeError 'This reader has been released' (spec)closedReplacedOnReleaseAfterClose/...Error
8size() errors stream then throws/returns Infinityenqueue swallowsenqueue rethrows / RangeError (spec)sizeErrorsStreamThenThrows/...ReturnsInfinity
9invalid size() return (NaN/-1)enqueue returns normally, stream errored (ds null); DEFECT: subsequent read() spins the isolate synchronously (unpinnable)enqueue throws RangeError 'Invalid chunk size', reads reject same (spec)invalidSizeReturnValue
10queue total-size mathinteger-ish: saturates (maxSafeInt shape -2,-1,1,0), fractional sizes truncate to 0; DEFECT: reading a fractional-size chunk spins the isolatefull double-precision per spec (all four WPT shapes)queue-math.js (3 tests)
11tee cancel compositesource cancel gets ONLY the pair-completing branch's reason; first branch's cancel promise fulfills immediatelyAggregateError of every branch's reason, in the order they cancelled (identity; intentional divergence from spec's array — tee is N consumers on one queue, the last to leave cancels the source); LONE branch cancel promise PENDS until the other cancels (spec) — never await a lone branch cancelteeCancelReasonComposite, teeCancelReverseOrder
12from(string)iterates per code unit ['h','i']single chunk ['hi'] (spec: throws — both diverge from spec)fromString
13async-iterator prototypeexposes constructor + next/returnnext/return onlyiteratorPrototypeShape
14read() inside size()in-flight chunk fed DIRECTLY to the reentrant readchunk queued; the NEXT enqueue bypasses the queue into the reentrant read (spec) — deliveries swappedreadInsideSize
15adopted body stream lock after consumptionreleasedkept lockedbodyIdentityAndLockCoupling
16then-getter fires during a read cycle1 (harness context)2thenGetterFireCountOnRead
17close-twice / enqueue-after-close / size-not-function / from-return validation messagesown textsown textscloseTerminality, sizeMustBeFunction, fromReturnValidationMessages
18error() while a close() is still pending (chunks queued)ignored: the requested close is final, desiredSize is already 0 and the chunks drain to a clean closedesiredSize is hwm minus the queued chunks (-1) until the error, then the stream errors (spec: close() only requested the close, the state is still "readable"): chunks discarded, reads/closed reject, desiredSize nullerrorAfterCloseWithQueuedChunk
19controller held, stream dropped and collectedthe controller does not keep its stream alive: its consumer leaves the queue, enqueue() drops the chunk silently, desiredSize stays at the high-water mark (no backpressure for a producer holding only the controller)the controller references the stream (spec [[stream]]): enqueues count, desiredSize 4 → 0controllerOnlyHeldStreamLiveness
20pull() after both tee branches are collected (controller held)keeps pulling for consumers that no longer exist; DEFECT: a source that enqueues on every pull runs until the stream closesthe source is released: pull() is never called again (the parity half — enqueue drops, desiredSize at the high-water mark, close() as ever — is teeBranchesCollected)teeBranchesCollectedPullStops
21body consumption of a TransformStream readable that delivers more than its declared expectedLengthreturns everything (consumption ignores the declaration)rejects with RangeError 'stream delivered more bytes than its declared expectedLength' and cancels the readable with it, which errors the writable (the declaration is the exact-total contract the byte and native sources already enforce)transformExpectedLengthOverflow
22async-iterator next() interleavings where WebIDL clears the ongoing promiseevery call strictly serialized: a next() from a continuation registered on an earlier next() still waits for the queued ones, and one queued behind return() reports done; after a next() rejects, later ones reject with the same errorspec: that next() reads ahead of the queued one (n2 'c', n3 'b') and ahead of a queued return() (reads data; the return still cancels); after a next() rejects, the iterator is finished and later ones report done (this last shape is among the WPT async-iterator.any C++ expectedFailures; the read-ahead shapes are derived from the WebIDL algorithm)nextFromEarlierContinuationReadsAhead, nextFromEarlierContinuationBeatsReturn, nextAfterRejectedNextIsDone
23when a promise returned by start() starts the streamadopts it: the first pull runs before the first marker chained on itspec (Node agrees): a new promise is resolved with it, so the pull runs after the second marker, whether it was fulfilled on return or laterstartPromiseSettledInNewPromise

Parity worth noting (probed, pinned): pull serialization (never re-entered); pull/async-start rejection identity; error-undefined preserved through closed; error() twice / after a completed close are no-ops (a close still pending is ledger #18); desiredSize lifecycle (1 → 0 close, null error, 0 cancel) and enqueue-skips-queue-with-pending-read; cancel-with-pending-pull; cancel reason identity + once; locked-stream cancel rejects without running the hook; tee error propagation identity to both branches, tee pull-per-read shape, tee backpressure following the slowest branch (a push source stalls both branches on an idle one; the spec's per-branch queues would not), tee after partial read; the tee-reentrancy crash regressions; from() cancel plumbing identity through return(); async-iterator protocol interleavings (return/next no-await; the WebIDL ongoing-promise shapes are #22); chunks held BY REFERENCE (mutation visible, identity) + detach-while-queued observed; and the ENTIRE integration surface except #15 and #21: body chunk normalization (messages included: 'This ReadableStream did not return bytes.'), a failing consumer cancelling the source with its error (the cancel's own rejection then wins) and leaving the stream locked, chunks collectible while consumption runs (the bytes are copied out), exact assembly across odd chunk sizes, disturbed-into-Response TypeError, locked-into-Response ACCEPTED, clone-both-read, cancel-body-then-consume 'Body has already been used', readAll small/big/failed paths, SELF fetch round-trips (fetch body + Request body, the workerd#5113 shapes).

The ts cell additionally sets the internal-testing expose_draining_reader flag, installing the ReadableStreamDrainingReader global — the bulk-drain conduit the C++ bridge drives to consume TypeScript streams (conduit basics in the identity suite's draining-reader.js). No such global exists under the C++ implementation; draining-reader.js asserts both sides.

Compatibility flags

FlagPinned in main cellsUnflagged side
streams_enable_constructors (2022-11-30)yes (the suite's subject)readable-cpp-legacy cell: ctor and .from() throw plain Errors naming the flag; ReadableStreamDefaultController not exposed; native-backed streams (Response bodies) fully usable incl. tee()
transformstream_enable_standard_constructoryes (tee-reentrancy drives tee through TransformStreams)transform suite's legacy cells
capture_async_api_throws, workers_api_getters_setters_on_prototype, set_tostring_tag, fixup-transform-stream-backpressure, writable_stream_spec_compliant_writeryesother suites' legacy cells
pedantic_wpt (dateless opt-in)readable-cpp-pedantic cellzero observable deltas on this suite's probed surface (cpp == pedantic in every probe)

Module map

ModuleCoverage
api-surface.jsglobals, controller not constructable, getReader modes, locked lifecycle
construction.jsledger #1-#3, default hwm 1
source-algorithms.jsledger #4-#6, #23, pull serialization, rejection identity, cancel-with-pending-pull
controller.jsdesiredSize accounting/terminal states, error idempotence, close terminality (#17), close-drains-queue, error during a pending close (#18)
reader.jsread ordering, releaseLock, closed replacement (#7), undefined error, reader.cancel, reader swap
cancel.jsreason identity, locked-cancel, hook rejection identity, queue discard
bad-strategies.jsledger #8, #9, size-not-function
queue-math.jsledger #10 (WPT float shapes; cpp bounded observables only)
tee.jsmigrated edge cases + error propagation + cancel composite (#11) + pull-per-read + slowest-branch backpressure
tee-reentrancy.jsthe three C++ push-loop crash regressions (from api/streams/streams-test.js)
from.js11 migrated + fromString (#12) + return validation messages
async-iteration.js7 migrated + no-await interleavings + proto shape (#13) + ongoing-promise interleavings (#22)
reentrancy.jsenqueue/close/cancel-in-size (parity) + read-in-size (#14; guard the size() or C++ captures every later chunk)
buffer-lifecycle.jschunk by reference, detach observed
integration-body.jsreadAll family, normalization (incl. detached and out-of-bounds views, DataViews included, SharedArrayBuffer-backed views, resizable-extent pinning), clone, cancel-then-consume, SELF round-trips
integration-body-failures.jsconsumer-side failures cancel the source with the error (every consumer; the cancel's rejection replaces it; nothing to cancel once the closing batch is in), leave the stream locked and stop pulls; TransformStream expectedLength overflow (#21) and exact delivery
integration-body-memory.jsbody consumption copies bytes out as they arrive: chunk buffers are collectible mid-consumption (WeakRef + gc()), ~2.5 MiB of pseudo-random chunk sizes assembles exactly as bytes and as text, one chunk wider than a 1 MiB collection block assembles exactly, a declared-length byte body is exact
integration-locked-disturbed.jsdisturbed rejected, locked accepted, body identity + lock coupling (#15)
gc.jspending read + async iteration survive gc(); a controller held with its stream collected (ledger #19); both tee branches collected while the controller is held: enqueue() drops without retaining (WeakRef-checked, backlog included), desiredSize at the high-water mark, close() then enqueue() as ever, and pull() stops (ledger #20); one branch cancelled and the other collected, observed in the gc()'s own job (before finalization callbacks): the controller's queries drop the consumer themselves
then-interceptors.jsledger #16; a then getter that cancels tee branches while a read result settles (during enqueue() and close(), one branch or two of three): the other branches' pending reads still resolve and their backlog still counts toward desiredSize
legacy-constructors.jsthe unflagged cell (see flags table)
draining-reader.jsTS only (C++ cell asserts the global's absence): a queued backlog plus the close sentinel swept in ONE batched read; value chunks pass through UNTOUCHED (object identity); pull-driven yields per read with EOF as a separate empty batch; expectedLength undefined; error/cancel propagation; lock exclusivity and release
data-volumes.jsvalue-stream volume axes: 4096-chunk counts, a 1 MiB single string chunk, 8 MiB aggregate (128 × 64 KiB), and 1 MiB through tee on both branches — every chunk index-encoded
pollution.jsprototype pollution neither implementation observes: a patched array iterator or replaced Number global leaves bodies intact; a patched controller error() still errors the stream; omitted dictionaries read nothing from Object.prototype; @@asyncIterator shape (TS: the values() function object, per WebIDL; C++: a separate function) and for-await ignoring a patched values()

Consumed sources: streams-async-iterator-test.js (deleted), streams-tee-edge-cases-test.js (value half), streams-test.js (from/ readAll/reader/cancel families; BYOB+writable+TransformStream tests remain), api/streams/streams-test.js (tee-reentrancy trio + ResponseTextLargeBody), ts-webstreams-test.js (three parity body tests; its TS-identity assertions remain). streams-js-test.js is deliberately untouched: its tests interleave value and byte sections, so its value halves move when the readable-byte suite consumes the byte halves.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.