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

workerd / writable

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

An informal specification of the JS-backed writable stream classes as implemented in workerd, derived from — and kept in lockstep with — the test suite in this directory. The tests are the normative artifact. Both the C++ implementation (src/workerd/api/streams/writable.{h,c++} over standard.c++'s WritableImpl/WritableStreamJsController) and the TypeScript implementation (src/per_isolate/webstreams/writable.ts, behind typescript_implemented_streams) are covered. The suite COMPLEMENTS WPT (//src/wpt:streams runs writable-streams/ against both implementations): behaviors WPT already asserts identically on both sides are not duplicated here. The WPT C++ expectedFailures for writable-streams/ in…

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

We split this AGENTS.md into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    NOT change the outcomes below).

    line 25

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

WritableStream, WritableStreamDefaultWriter, WritableStreamDefaultController

An informal specification of the JS-backed writable stream classes as implemented in workerd, derived from — and kept in lockstep with — the test suite in this directory. The tests are the normative artifact. Both the C++ implementation (src/workerd/api/streams/writable.{h,c++} over standard.c++'s WritableImpl/WritableStreamJsController) and the TypeScript implementation (src/per_isolate/webstreams/writable.ts, behind typescript_implemented_streams) are covered.

The suite COMPLEMENTS WPT (//src/wpt:streams runs writable-streams/ against both implementations): behaviors WPT already asserts identically on both sides are not duplicated here. The WPT C++ expectedFailures for writable-streams/ in src/wpt/streams-test.ts (aborting ×11, bad-strategies ×2, bad-underlying-sinks ×2, constructor ×2, floating-point ×3, start ×1) seeded the ledger below; probing showed several "failures" (the aborting.any family) come from testharness strictness while the underlying behaviors are parity — those parity pins live in abort-matrix.js.

The startedness model (root of several divergences)

C++ invokes sink algorithms synchronously from writer.write()/close() (without pedantic_wpt; with it they are deferred a microtask, which does NOT change the outcomes below). TypeScript follows the spec's [[started]] gating: no sink hook runs until the start promise has settled in a microtask. A synchronous write(); abort(); sequence therefore finds the write already in flight under C++ (the sink runs; the write fulfills) but still queued under TypeScript (the sink never runs; the write rejects with the abort reason).

Divergence ledger (C++ vs TypeScript)

#AreaC++TypeScriptPinned in
1invalid highWaterMark at ctorTypeError (jsg uint64 conversion messages)RangeError "Invalid highWaterMark" (spec)highWaterMarkValidated
2sink.type validationignored (pedantic_wpt: RangeError)RangeError "Invalid underlying sink type" (spec)sinkTypeValidation
3argument conversion ordersink dictionary first (sink.write, hwm, size)strategy first (size, hwm ×2, sink.write; spec)argumentConversionOrder
4ready at construction (no backpressure)pending after a microtask, fulfills on a later turnfulfilled within a microtask (spec)readyFulfillTiming
5sync start() throwcaptured; stream errored, writes rejectescapes the constructor (spec)newWritableStreamStartError
6abort() on an errored streamrejects with the stored errorfulfills with undefined (spec)newWritableStreamAbortError
6bconcurrent abortsa fresh promise per abort() callthe same promise for both (spec); both fulfill undefinedconcurrentAbortPromiseIdentity
7startedness (see above)sync write→abort: sink runs, write fulfills; a same-turn mutation/detach/resize of the chunk's buffer after write() is NOT observed by the sinkwrite still queued: rejected with abort reason; the buffer change IS observedwritableStreamAbortWhileWriting, writableStreamAbortWriteClosePending, writableStreamPromisesResolvedInOrder, writableStreamCloseThrowRejectsPromises, abortRejectsOutstandingWriteWithReason, buffer-lifecycle.js (chunkMutationVisibility, detachAfterWriteTiming, resizableGrowAfterWrite, resizableShrinkOutOfBounds)
8close hook racing an immediate abortclose hook runs; close+abort reject with its errorclose still queued: hook never runs, close rejects with abort reason, abort fulfillswritableStreamCloseThrowRejectsPromises
9queue totalssize() → uint64 (fractions truncate; NaN/negative/±Infinity → TypeError, also for a write after close(), which with an earlier write queued rejects the close too); desiredSize narrowed through int (wraps past 2^31)double arithmetic per spec; invalid size → RangeError "Invalid chunk size", checked only on enqueue: a write after close() rejects alone and the close completesfloatingPointQueueTotals, fractionalSizeTruncation, invalidSizeReturnRejects, invalidSizeAfterCloseRejectsOnlyTheWrite
10signal.reason for reasonless abort()undefined (pedantic_wpt: AbortError DOMException)AbortError DOMException (spec)abortSignalReason
11desiredSize while erroringqueue accounting value (pedantic_wpt: null)null (spec)desiredSizeWhileErroring
12non-callable size / released-writer messagesjsg dictionary / "This WritableStream writer has been released."TS validator / "This writer has been released"nonCallableSizeThrows, releaseLockInsideSize
13releaseLock() with writes still queuedcancels them: queued writes reject with the released-writer error and their chunks are dropped (a C++ deviation — the source of its WPT piping/flow-control release-then-pipe expectedFailures)spec: release rejects only ready/closed; queued writes stay in [[writeRequests]] and drain on the sink's schedule (a new writer can relock and they still complete — WPT flow-control pins that; behind a never-settling in-flight write they wait forever on backpressure)cancelWriteOnReleaseLock
14when a promise returned by start() starts the streamadopts it: a write queued during start reaches the sink before the first marker chained on itspec (Node agrees): a new promise is resolved with it, so the write reaches the sink after the second marker, whether it was fulfilled on return or laterstartPromiseSettledInNewPromise

Parity worth noting (probed, pinned): the whole in-flight abort matrix — abort-before-start reason identity on ready/closed, errored-state reason identity, sink abort suppressed after a bad-strategy error or a pre-existing controller error (including while a write is in flight), in-flight write finishing with rejection during abort, an abort during a slow in-flight write leaving the write to FULFILL, both orders of abort()×controller.error() with a fulfilling in-flight write, and the abort-first order with a rejecting write; sink abort waits for in-flight start/write/close (abort-matrix.js, writableStreamAbortTiming, errorRaceWithCloseWritable); sink hook getters read exactly once at construction; a later sink write returning a rejected promise rejects that write, a REPLACED ready, and closed with the sink's error; sink write/close never run after a start() throw, however the failure surfaced; ready is replaced as soon as desiredSize reaches 0; a detached ArrayBuffer is an acceptable chunk (byteLength 0); a coercing {valueOf} highWaterMark is accepted via ToNumber; the user size() runs with an undefined receiver and one argument; reentrant writer.write() from size() enqueues the inner chunk first; size() is never consulted for doomed writes (the TS sinks' willAcceptWrite invariant); a patched Object.prototype.then getter never fires while settling writer promises (they resolve with undefined).

Compatibility flags

Flag (enable date)Pinned in main cellsUnflagged side guarded by
streams_enable_constructors (2022-11-30)yes (the suite's subject)writable-cpp-legacy cell: ctor throws a flag-pointing Error; WritableStreamDefaultController global absent
capture_async_api_throws (2022-10-31)yeswritable-cpp-legacy-writer cell: double close throws synchronously ("Cannot close a writer that is already being closed")
writable_stream_spec_compliant_writer (2026-03-24)yeswritable-cpp-legacy-writer cell: releaseLock() inside size() does not doom the write; release leaves a resolved ready in place
workers_api_getters_setters_on_prototype, set_tostring_tagyesgeneric placement/branding; identity suite legacy cell
internal_writable_stream_abort_clears_queue (2024-09-02)NOT pinnedinternal-impl only (internal.c++); unreachable from JS-backed WritableStream
pedantic_wpt (dateless opt-in)writable-cpp-pedantic cellflag-off sides are the C++ columns of ledger #2/#10/#11

Assertion catalogue

ModuleAsserts
api-surface.jswritable globals exist; controller not constructable; bare ctor works (full IDL shape is WPT's)
construction.jsledger #1–#5, #12; fractional and ToNumber-coerced hwm accepted
sink-algorithms.jsledger #14; which sink hooks run with what arguments/controller; sync+async hook errors surface on writer promises (#5, #6); size() consulted per write; hook getters read once; second-write rejection fan-out; hooks silent after start throw
write-semantics.jschunk identity (subarrays, any JS value via Object.is); multiple pending writes; settlement ordering incl. under abort (#7); queued-write fate at releaseLock (#13)
buffer-lifecycle.jschunks never copied/validated: already-detached AB accepted (byteLength 0); post-write() mutation, detach, resizable grow, and shrink-out-of-bounds all observed per the startedness model (#7); size() runs inside write() so queue totals are immune to later detach
close-semantics.jsclose-throw promise fan-out vs abort (#7, #8); double close rejects TypeError
abort-semantics.jsmigrated abort lifecycle: reason propagation, signal event, persistent errored state, in-flight sequencing, outstanding-write startedness, terminal-state interactions (#7)
abort-matrix.jsprobed parity matrix (see above), including controller-error races and sink-hook suppression + signal reason (#10) + concurrent-abort identity (#6b)
backpressure.jsdesiredSize accounting/recovery; ready replaced at capacity; WPT floating-point scenarios and invalid sizes, incl. after close() (#9); erroring desiredSize (#11)
reentrancy.jssize()-reentrant write ordering; releaseLock inside size (#12; flag-gated, cf. legacy-writer); controller.error inside write hook; doomed-write size skip; size receiver/arity
then-interceptors.jsthen-getter never fires on writer promise settlement
gc.jspending write survives gc() with all user refs dropped (--expose-gc)
legacy-ctor-gate.jsfully-unflagged: ctor Error + absent controller global
legacy-writer.jspre-flag writer semantics (see Compatibility flags)
data-volumes.jswrite-side volumes: 4096 × 16 B writes, single 1 MiB write, 1 MiB / 8 MiB chunked with writer.ready honored; the sink verifies the continuous prime-modulus pattern as chunks arrive
pollution.jsprototype pollution neither implementation observes: Object.prototype resolvers never reach the writer's settled ready/closed promises; omitted dictionaries read nothing from Object.prototype
which-impl.jsimplementation + pedantic detection

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.