← Back to Pull requests

feat(v2:shred): receiver primitives for shred harness #1632

Merged
yewman merged 4 files (152 lines) on Jul 08, 2026 21:53 UTC
View on GitHub
yewman yewman commented on Jun 26, 2026 11:41 UTC
Author

Four independent primitives the sol_compat_shred_parse_v1 conformance harness needs out of Receiver. Each is self-contained — review per commit.

No behavioural change to existing callers: new feature gates default to inactive, Receiver.reset() is opt-in, and the hoisted parse-time bound was already enforced one stage later.

Commits

1. feat(v2:shred): split debug-skip flags into sig-verify and version-check — replaces the single -Ddebug-skip-shred-checks meta-flag with two orthogonal options (-Ddebug-skip-shred-sig-verify, -Ddebug-skip-shred-version-check). The harness needs to skip sig verify (synthetic shreds, no known leader) but keep version-check on.

2. feat(v2:shred): add Receiver.reset() for state-free reuse — in-place reset of Receiver, InProgressSets, DoneSets, and a new Pool.reset() that rebuilds the free list without touching the backing buffer. Lets the harness reuse a single Receiver across fixtures (a fresh one per call is too expensive — the ctx pool alone holds 4096 in-flight sets).

3. feat(v2:shred): reject shred-indices past max_shreds_per_slot — hoists the slot_idx < 32768 bound into Shred.fromPacketChecked so the parse-level verdict (reportShredParseResult) matches Agave/FD. Previously the bound was enforced one frame too late — after the harness had already observed parses_as_chained = true. The 32768 literal is promoted to a single named pub const max_shreds_per_slot. Closes the last shred-fixture mismatch in test-vectors/shred/fixtures (1001/1001).

4. feat(v2:shred): discard unexpected data-complete shreds under feature gate — adds Receiver.Features with the discard_unexpected_data_complete_shreds activation slot (default maxInt(Slot) = inactive). When active for a slot, a data shred with DATA_COMPLETE set is only accepted when slot_idx == fec_set_idx + FEC_SHRED_COUNT - 1. Enforced in processPacketInner because it needs the runtime activation slot. Mirrors agave's ledger/src/shred/filter.rs.

Diff: 152 lines (+136 / -16) across 4 files Reviewer: hamza-syndica Review duration: 17891m
All Vouch review confidence checks passed
Residual risk 0.07 = Change Risk (0.37) × (1 − Review Confidence (0.80)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 152 lines diff across 4 files
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.67 · 3 substantive comment(s)
0.67
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
80%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.301
Real PR Conversation Timeline
8 items
codecov[bot] codecov[bot] commented on Jun 26, 2026 13:00 UTC
Bot

Codecov Report


:x: Patch coverage is 67.74194% with 10 lines in your changes missing coverage. Please review.

| Files with missing lines | Patch % | Lines |
|---|---|---|
| v2/lib/shred/receiver.zig | 66.66% | 9 Missing :warning: |
| v2/lib/shred.zig | 0.00% | 1 Missing :warning: |

:x: Your patch check has failed because the patch coverage (67.74%) is below the target coverage (85.00%). You can increase the patch coverage or adjust the target coverage.

| Files with missing lines | Coverage Δ | |
|---|---|---|
| v2/lib/collections/pool.zig | 81.50% <100.00%> (+0.38%) | :arrow_up: |
| v2/lib/shred.zig | 16.11% <0.00%> (-0.10%) | :arrow_down: |
| v2/lib/shred/receiver.zig | 45.38% <66.66%> (+2.19%) | :arrow_up: |
<details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • </details>

    Sobeston Sobeston commented on code on Jun 30, 2026 22:18 UTC
    Code Review
    v2/lib/collections/pool.zig:1
    @@ -222,6 +222,18 @@ pub fn Pool(Item: type, IdInt: type) type {
                 };
             }
     
    +        /// Rebuilds the free list in place, returning every item to the pool
    +        /// without freeing or reallocating the backing buffer. The buffer
    +        /// contents are clobbered.
    +        pub fn reset(self: *PoolSelf) void {
    +            const buf = self.buf[0..self.len];
    +            for (buf[0 .. buf.len - 1], 0..) |*node, i| {
    +                node.* = .{ .next_free = @enumFromInt(i + 1) };
    +            }
    +            buf[buf.len - 1] = .{ .next_free = .null };
    +            self.free_list = @enumFromInt(0);
    +        }

    this seems the same

            pub fn reset(self: *PoolSelf) void {
                const buf = self.buf[0..self.len];
                self.* = init(buf);
            }
    

    Sobeston Sobeston commented on Jun 30, 2026 22:19 UTC
    Reviewer

    Looks great, I've got one comment, resolve it if you feel like it

    yewman yewman commented on code on Jul 01, 2026 08:51 UTC
    Code Review
    v2/lib/collections/pool.zig:1
    @@ -222,6 +222,18 @@ pub fn Pool(Item: type, IdInt: type) type {
                 };
             }
     
    +        /// Rebuilds the free list in place, returning every item to the pool
    +        /// without freeing or reallocating the backing buffer. The buffer
    +        /// contents are clobbered.
    +        pub fn reset(self: *PoolSelf) void {
    +            const buf = self.buf[0..self.len];
    +            for (buf[0 .. buf.len - 1], 0..) |*node, i| {
    +                node.* = .{ .next_free = @enumFromInt(i + 1) };
    +            }
    +            buf[buf.len - 1] = .{ .next_free = .null };
    +            self.free_list = @enumFromInt(0);
    +        }

    17d8772bd9c7d77feee045cd3318c8e4555f580c

    hamza-syndica hamza-syndica approved these changes on Jul 07, 2026 14:25 UTC
    Approved Reviewer

    Approved these changes.

    Sobeston Sobeston approved these changes on Jul 08, 2026 17:20 UTC
    Approved Reviewer

    Approved these changes.

    prestonsn prestonsn approved these changes on Jul 08, 2026 18:32 UTC
    Approved Reviewer

    Looks good! commits are unsigned for some reason

    Reviewers
    Assignees
    yewman yewman
    Labels
    risk: low confidence: 80% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 37.5% (MEDIUM) · Higher = larger blast radius
    37.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 80% · Lower = rushed or shallow review
    80%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.5% · Safe to merge
    7.5%
    Repository