Skip to content

feat(serve): compile-time integrity witness on the streaming serve path - #964

Merged
ertime037 merged 1 commit into
mainfrom
feat/849-streaming-typestate
Sep 6, 2026
Merged

feat(serve): compile-time integrity witness on the streaming serve path#964
ertime037 merged 1 commit into
mainfrom
feat/849-streaming-typestate

Conversation

@devitway

@devitway devitway commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

The buffered serve path already discharges a compile-time integrity witness: Storage::get_verified yields a Blob<Verified> and the only response-body sink, verified_body, accepts nothing weaker — so serving unverified bytes there is a compile error.

Streaming served its bytes through a bare Body::from_stream, leaving that guarantee runtime-only on the growing streaming path: a new streaming serve could forget to wrap its reader in the EOF-verifying VerifyingReader / VerifyingStream and still compile.

This restores the witness for streaming:

  • verified.rs gains sealed sole-sinks stream_body (accepts only a VerifiedByteStream) and reader_stream_body (accepts only a VerifiedByteReader), implemented solely by the EOF-verifying types (raw VerifyingStream, docker VerifyingReader). Handing a raw reader/stream to them is a compile error — proven by compile_fail doctests.
  • Byte-range serves take an explicit open_world_stream_body arm (a partial range has no whole-file digest to verify against), so the open-world case stays named rather than silent.
  • Body::from_stream is now confined to these sinks; the docker, raw and range serves route through them.

No behavior change on the happy path — the EOF digest check and abort-on-mismatch are unchanged.

Closes #849.

@devitway
devitway requested a review from ertime037 as a code owner September 6, 2026 04:53
The buffered serve already discharges a compile-time witness (verified_body takes
only Blob<Verified>). Streaming served bytes through a bare Body::from_stream, so a
new streaming serve could forget the EOF digest check and still compile. Add sealed
sole-sinks in verified.rs — stream_body(VerifiedByteStream) and
reader_stream_body(VerifiedByteReader) — implemented only by the EOF-verifying types
(raw VerifyingStream, docker VerifyingReader); a raw reader/stream is now a compile
error at the sink (compile_fail doctests prove it). Byte-range serves take the
explicit open_world_stream_body arm (a partial range has no whole-file digest).
Body::from_stream is now confined to these sinks.

Closes #849.
@devitway
devitway force-pushed the feat/849-streaming-typestate branch from 55def87 to 1cb776e Compare September 6, 2026 04:54
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

🐳 Test image pushed: ghcr.io/getnora-io/nora:pr-964

docker pull ghcr.io/getnora-io/nora:pr-964
docker run --rm -p 4000:4000 ghcr.io/getnora-io/nora:pr-964

1 similar comment
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

🐳 Test image pushed: ghcr.io/getnora-io/nora:pr-964

docker pull ghcr.io/getnora-io/nora:pr-964
docker run --rm -p 4000:4000 ghcr.io/getnora-io/nora:pr-964

@ertime037
ertime037 added this pull request to the merge queue Sep 6, 2026
Merged via the queue into main with commit 7d95325 Sep 6, 2026
20 checks passed
@ertime037
ertime037 deleted the feat/849-streaming-typestate branch September 6, 2026 05:15
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.

Type-enforce streaming integrity verification (VerifiedBody sole-sink), restoring the compile-time witness on the streaming path

2 participants