Repository navigation
test(fake-gateway): answer a raw blob with its proven size, as the gateway does - #9
Merged
Merged
Conversation
…teway does decdn's gateway now proves a raw blob's size before it answers (decdn/decdn #2645): it pays for the last chunk group under the first node's size claim, and the proven size gives the response its Content-Length, one Range (206/416) and a 402 when it does not fit the allowance. A cold HEAD pays for the proof too, and is refused or fails as its GET would be. The fake mirrors that: a raw blob answers as a sized entry does, a proof charges one chunk group of the allowance once per blob, and a raw blob's HEAD runs the GET's checks (402, 503, 404) unless its size is already proven. The partial-window test keeps its hash-mismatch check on the unsized entry, since a raw blob now has a length. head()'s doc says a public HEAD of a raw blob may pay for a proof. Co-Authored-By: Claude Opus 5.5 <[email protected]>
9 tasks done
There was a problem hiding this comment.
🟡 Changes recommended
The fake still diverges from gateway behavior in empty-blob accounting, range admission, and site-host HEAD handling.
3 open issues
What changed in this PR
Updates the test gateway to model proven raw-blob sizes while leaving SDK runtime behavior unchanged.
Changes:
- Adds size-proof accounting and shared sized responses for raw blobs and entries.
- Tests raw-blob lengths, HEAD metadata and refusals, and partial-body verification.
- Documents the possible proof cost of a public raw-blob HEAD request.
| File | Description |
|---|---|
| test/unit/client.test.ts | Adds raw-blob metadata and refusal tests; adjusts partial-body expectations. |
| test/fake-gateway.ts | Models size proofs, sized responses, ranges, and raw-blob HEAD handling. |
| src/client.ts | Updates the head() doc comment to describe proof costs. |
Review effort: Balanced
… a window as the gateway does - HEAD /_decdn/<hash> on a site answers through the raw-blob HEAD, as the gateway's head_blob does: free once the size is proven, else one proof, instead of a body charge. - The empty blob is empty with no proof and no charge, as the gateway's empty root is. - A window is admitted and charged by its span widened to chunk groups (Extent::billable), after its 416 check, instead of by the whole size. This also brings a sized entry's window in line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
thiras
added a commit
to decdn/decdn
that referenced
this pull request
Oct 27, 2026
A raw blob that no pull on the gateway had verified streamed with no Content-Length, ignored Range, and its HEAD had no length. A node's size claim cannot give a length: the server stops reading a body at its length, so a claim below the real size would end a short pull as a whole response. - Client: Streamer::prove_size pays for the last chunk group under a size claim and returns the size a leg proved. Only the true size verifies a final chunk (ADR 039), so a claim off by less than one group proves the true size, and any other claim proves nothing. A claim past the cap on held bytes opens nothing. - CLI fetch: BlobFetch::prove runs the proof in fetch_on and records a proven size with the verified sizes. A fault the following pull would reach again (classify: command-fatal, or a give-up) ends the fetch; any other leaves the size unproven. A pool replacement reruns the proof, which writes no byte. - Gateway: blob() proves an unknown size first, then takes the sized path (length, one Range 206/416, 402 when it does not fit, capped pull). A cold HEAD goes through paid() and pays for its proof, refused or failed as its GET would be. Each proof counts PROOF_BYTES (one chunk group) against the allowance, a request dropped mid-proof included (ProofCharge). A proof that proves nothing streams unsized, as before. - Tests: client proof cases (true, low, high, within the last group, past the cap, a lying source), proof error classification, gateway cold GET/Range/416/402/HEAD/drop/bucket/funding/loopback/retired-capability cases, and gateway_public opens a never-fetched blob with a Range. - ADR appendix-gateway, CHANGELOG, and the TypeScript SDK pin (decdn/sdk-typescript#9: the fake answers a raw blob with its size). Closes #2645 Closes #2616 Co-Authored-By: Claude Opus 5.5 <[email protected]>
thiras
added a commit
to decdn/decdn
that referenced
this pull request
Oct 28, 2026
…dk-typescript#9) Co-Authored-By: Claude Opus 5.5 <[email protected]>
thiras
added a commit
to decdn/decdn
that referenced
this pull request
Oct 28, 2026
…2654) * feat(gateway,client): prove a raw blob's size before its first byte A raw blob that no pull on the gateway had verified streamed with no Content-Length, ignored Range, and its HEAD had no length. A node's size claim cannot give a length: the server stops reading a body at its length, so a claim below the real size would end a short pull as a whole response. - Client: Streamer::prove_size pays for the last chunk group under a size claim and returns the size a leg proved. Only the true size verifies a final chunk (ADR 039), so a claim off by less than one group proves the true size, and any other claim proves nothing. A claim past the cap on held bytes opens nothing. - CLI fetch: BlobFetch::prove runs the proof in fetch_on and records a proven size with the verified sizes. A fault the following pull would reach again (classify: command-fatal, or a give-up) ends the fetch; any other leaves the size unproven. A pool replacement reruns the proof, which writes no byte. - Gateway: blob() proves an unknown size first, then takes the sized path (length, one Range 206/416, 402 when it does not fit, capped pull). A cold HEAD goes through paid() and pays for its proof, refused or failed as its GET would be. Each proof counts PROOF_BYTES (one chunk group) against the allowance, a request dropped mid-proof included (ProofCharge). A proof that proves nothing streams unsized, as before. - Tests: client proof cases (true, low, high, within the last group, past the cap, a lying source), proof error classification, gateway cold GET/Range/416/402/HEAD/drop/bucket/funding/loopback/retired-capability cases, and gateway_public opens a never-fetched blob with a Range. - ADR appendix-gateway, CHANGELOG, and the TypeScript SDK pin (decdn/sdk-typescript#9: the fake answers a raw blob with its size). Closes #2645 Closes #2616 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(gateway): let a proof's pool replacement reach the worker, and cap its lanes - A size proof no longer runs its pass again on a pool replacement. The gateway's pool payer shares one RunFunding across fetches, and its pool is written once, so a rerun paid from stale funding facts, and the worker, which never saw the PoolReplaced, kept the retired payer for later requests. The replacement now ends the proof's fetch as it ends a pull's, and the worker rebuilds the pool payer. - The proof runs on at most --max-sources lanes, as the stream does, instead of the client's default lane cap. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci: pin the TypeScript SDK at its fake's site HEAD, empty-blob and window fixes Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci: pin the TypeScript SDK at its merged sized raw-blob fake (decdn/sdk-typescript#9) Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
decdn's gateway now proves a raw blob's size before it answers (decdn/decdn#2645, PR to follow): it pays for the last chunk group under the first node's size claim, and the proven size gives the response its
Content-Length, oneRange(206/416) and a 402 when it does not fit the allowance. A coldHEADpays for the proof too, and is refused or fails as itsGETwould be. The SDK can observe the newContent-Length(it bounds a body from below), so the fake mirrors it:sized(), shared withentry()): length,Accept-Ranges, one range, 402 by size on a public gateway.HEADruns theGET's checks (402, 503, 404) unless its size is already proven, and then answers free with its length.HASH_MISMATCHcheck on the unsized entry, since a raw blob now has a length (its partial answer isTRUNCATED, as a sized entry's is).contentLength,head()of a raw blob, and itsHEADrefusals.head()'s doc says a publicHEADof a raw blob may pay for a proof.No contract-suite change: the suite also runs against the gateway floor (0.3.0) and the latest release, which do not prove sizes. The decdn PR runs this branch's contract suite against the new gateway and moves
.github/sdk-typescript.shaonce this lands.No CHANGELOG entry: the package's behaviour is unchanged (test fake and one doc comment).
Test plan
pnpm lintpnpm test(159 passed)gateway_sdke2e (public + loopback) against the new gateway with this checkout🤖 Generated with Claude Code