feat: add plan-verified streaming decode#303
feat: add plan-verified streaming decode#303Nelson Spence (Fieldnote-Echo) wants to merge 4 commits into
Conversation
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
PR Summary by QodoAdd plan-verified streaming decode for ordvec-manifest artifacts
AI Description
Diagram
High-Level Assessment
Files changed (14)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a47c95fb77
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| r.read_exact(&mut buf)?; | ||
| v.push(parse(buf)); | ||
| let elements_per_chunk = READ_CHUNK_BYTES / W; | ||
| let mut scratch = [0u8; READ_CHUNK_BYTES]; |
There was a problem hiding this comment.
Move the 64 KiB read buffer off the stack
On threads configured with small stacks, every nonempty Rank, Bitmap, or SignBitmap load now places a 64 KiB array in the loader's stack frame, replacing the previous 2–8 byte buffer; this can overflow the thread stack and abort the process even for a tiny valid artifact. Allocate this chunk fallibly on the heap, or use a substantially smaller stack buffer, so the loader preserves its recoverable-error behavior.
Useful? React with 👍 / 👎.
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6607c98b23
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| let decoded = decoder(&mut reader, expected_size); | ||
| let decoder_consumed = reader.consumed; | ||
|
|
||
| let mut scratch = [0u8; VERIFIED_DECODE_DRAIN_BYTES]; |
There was a problem hiding this comment.
Move the plan decode drain buffer off the stack
On worker threads configured with small stacks, every call to decode_primary_with or decode_verified_with reserves this 64 KiB array in decode_plan_verified's stack frame—even when the decoder consumes the entire artifact and the drain loop never runs—so a valid decode can overflow the thread stack and abort the process. Although the similar rank_io scratch buffer has now been moved to fallible heap storage, this separate plan-decode buffer remains; allocate it fallibly on the heap or use a substantially smaller stack chunk.
Useful? React with 👍 / 👎.
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
Summary
Why
OrdinalDB needs to load large artifacts directly into their final representations without first allocating an artifact-sized byte buffer. The verified-plan API also needs one consistent contract for access failures, type rejection, stale content, decoder failures, and incomplete consumption.
Contract and limits
Plan-verified means that the delivered bytes and observed descriptor state match the size and digest recorded in a verified plan. It does not authenticate the manifest producer or signer.
The loader rejects a final symlink or reparse point and a nonregular descriptor, but it trusts the caller-selected local parent directory. It detects mutations reflected in delivered bytes or observed descriptor state; it cannot promise detection of a transient mutation that is perfectly restored between observations.
Validation