Skip to content

docs(hyperfly): document every public export for 1.0 - #93

Merged
eliahilse merged 31 commits into
mainfrom
docs/jsdoc-1.0
Oct 21, 2026
Merged

eliahilse merged 31 commits into
mainfrom
docs/jsdoc-1.0

Conversation

@eliahilse

@eliahilse eliahilse commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

What

Documentation only. No code, type or test changes.

  • JSDoc on every public export of hyperfly, hyperfly/zod and hyperfly/http:

    • every error code, one line each, as in wire-v0 §9, including artifact;
    • Codec and its members, CompileOptions with each default, PackHooks, Limits;
    • profile and IR types, train options and their validation rules;
    • the zod entry, the http header constants, and the option interfaces (LoadArtifactOptions, FetchArtifactOptions, ReadBodyOptions, Encoded).

    Defaults are taken from the code.

  • Stability links:

    • The package README gets a Stability section linking STABILITY.md, the spec's stability contract (wire-v0 Stability) and SECURITY.md.
    • The site's /docs further-reading list gets the same links.
    • STABILITY.md now lists artifact among the TypeScript error codes.

Tests

A check that the src/ diff has no non-comment lines prints nothing. Gates on this branch merged with main (1508d69): lint, check-types, and bun test with 1440 passing and 0 failing. The changeset check is ok.

Review

Sol checked every statement against the code. Defaults, train clamps, spec headings and policy anchors all match. Its three corrections (the maxByteLength scope and the full meanings of packed and json) are in fcb8442.

🤖 Generated with Claude Code

eliahilse and others added 30 commits October 20, 2026 16:19
readBody and fetchArtifact kept references to stream chunks until EOF, so a
stream that reuses one buffer across chunks produced corrupted bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Buffer.prototype.slice returns a view, so a stream yielding Buffers that
reuse one allocation still corrupted the body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onses

decodeResponse rejects malformed UTF-8 in JSON bodies as DecodeError "json".
readBody refuses a locked or consumed body with 400 and reports invalid
options through the returned promise. encodeFor throws EncodeError "json"
for values JSON cannot represent. respond sends no body for HEAD and for
204, 205 and 304 with the negotiated headers, and discovery answers only
GET and HEAD.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A throwing deflate hook, or one that returns something other than a
Uint8Array, now fails encoding with EncodeError "packed", carrying the
hook's error as cause, as inflate failures already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With validate: true, decode checks the decoded value against the schema and
returns it as decoded, so a value-changing check such as overwrite is not
applied a second time. The validating codec is frozen like compileIR's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
serializeArtifact checks the IR, layout and profile as compileIR does and
throws the same HyperflyError codes instead of emitting invalid text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An ArrayBuffer or other non-Uint8Array chunk is refused with 400 before it is
counted or copied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
readBody honours a Content-Length of ASCII digits with surrounding spaces or
tabs and otherwise counts the bytes as they arrive, as the Python package
does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
readBody and fetchArtifact check and count each chunk with the
%TypedArray%.prototype getters, so a subclass with an overridden byteLength
cannot pass the byte cap and a Uint8Array from another realm is accepted.
Refusing a chunk that is not bytes cancels the stream as the 413 path does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Catch blocks that check the caught value with instanceof now treat a value
whose prototype cannot be read, such as a revoked proxy, as not a library
error, so it is wrapped or rethrown as itself instead of raising a native
TypeError from the check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The type check and the byte count use the %TypedArray% getters, so a
subclass cannot misreport its length and a Uint8Array from another realm is
accepted. A refused chunk cancels the stream like an oversized one, and a
locked body is refused instead of throwing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ttp-robustness

# Conflicts:
#	packages/hyperfly/src/http.ts
#	packages/hyperfly/test/http.test.ts
Rename NegotiateOptions.accept to httpAccept, WellKnownResponse to
ArtifactResponse and FetchHandlerOptions to RespondOptions, matching the
Python names. encodeFor takes EncodeOptions, whose onFallback receives
(error, "encoder-limit").

JSON negotiations carry a FallbackReason and readBody refusals a
RequestRefusal, with the same strings as the Python package. Name the
result unions (ReadBodyResult, DecodedResponse, HyperflyNegotiation,
JsonNegotiation) and make CodecRegistry generic over its payload type,
which negotiate, encodeFor, respond, readBody and decodeResponse infer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ttp-api-1.0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rom any realm

respond sends the negotiated headers for HEAD and 204, 205 and 304 without
encoding the value. The deflate result is checked with the intrinsic typed
array tag, shared with readBody, so a Uint8Array from another realm is
accepted. serializeArtifact reads the profile inside its coded boundary, and
readBody compares Content-Length to maxBytes digit by digit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
respond encodes the value for HEAD exactly as for GET, so the JSON fallback
headers match, and drops the body; only 204, 205 and 304 skip encoding. The
changeset is shortened to the two-sentence limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
serializeArtifact keeps its validateIR check, which now enforces the 512
nesting bound from main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	packages/hyperfly/src/http.ts
# Conflicts:
#	packages/hyperfly/README.md
#	packages/hyperfly/src/http.ts
#	packages/hyperfly/test/http.test.ts
…d type

A value of another type no longer widens T in respond or encodeFor, so
respond(request, "wrong", CodecRegistry<"allowed">) fails to compile
instead of throwing EncodeError at run time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: GPT 6.1 Sol <noreply@openai.com>
…E and site

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	packages/hyperfly/README.md
#	packages/hyperfly/src/errors.ts
#	packages/hyperfly/src/http.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eliahilse
eliahilse merged commit ba9d30f into main Oct 21, 2026
17 checks passed
@eliahilse
eliahilse deleted the docs/jsdoc-1.0 branch October 21, 2026 15:40
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