Skip to content

polish: tighten Bytes/Percent newtype surface (post-#911) #914

Closed

Description

@yigitdot

Follow-up polish from the multi-agent review of #911. No defects — these are minor consistency/hardening nits intentionally split out of the PR rather than bundled.

  • Resolver/type boundary parity test. The window≤budget invariant is enforced in two places — resolve_cache (crates/common/src/config/mod.rs:1287, <=) and LeechCaps::new (crates/node/src/leech_governor.rs:118, >). LeechCaps::new has an initial == budget boundary test; the resolver does not. Add a resolver-level pull_ahead_bytes == max_unrecouped_leech_bytes test so the two enforcers can't silently diverge if one comparison is later changed.
  • Typed scale_saturating (optional). Percent::scale_saturating(self, bytes: u64) -> u64 (crates/config-types/src/percent.rs) drops back to raw u64. Consider (bytes: Bytes) -> Bytes to keep the scaled result typed — weigh against the governor's intentionally-u64 per-peer counters (PeerLeech.served/pulled).
  • WindowExceedsBudget payload typing. Its fields are raw u64 (crates/node/src/leech_governor.rs:51-52); Bytes would make the unit typing end-to-end through the error type.
  • Dead doc link. crates/config-types/src/percent.rs:9 links [\SHARE_RATIO_SCALE`]`, but that const is private — renders as a dead link in published docs. Drop the brackets or note it's internal.
  • Cross-crate doc reference. crates/config-types/src/bytes.rs:4-8 says "the same structs," but those structs live in the node crate, not config-types. Name the consumer (e.g. the node's LeechCapsConfig) for locatability.

Context: #911 introduced the Bytes/Percent transparent newtypes for the seed-leech cap knobs.

Activity

  1. added
    kind:feature
    prio:low
    rust
    on Jun 15, 2026
  2. github-actions commented on Jun 15, 2026

    @github-actions

    🎯 Triage report

    Post-review polish split out of PR #911, which introduced Bytes/Percent transparent newtypes for the seed-leech cap knobs. All five items are no-defect consistency/hardening nits: one missing boundary test, two raw-u64 fields that should be typed, and two inaccurate doc comments. No functional impact today.

    📊 Assessment

    Dimension Value Reasoning
    Type Task Five discrete, bounded work items — no design discovery needed
    Labels enhancement, technical, rust, low Consistent with sibling issues #894 and #910; polish nits with no user-visible impact
    Coding agent Suitable Four of five items (test parity, WindowExceedsBudget field typing, two doc fixes) are fully mechanical. Item 2 (scale_saturating return type) is marked optional and carries a design note in the issue body — an agent can implement it if it judges the trade-off documented there acceptable, or skip it and leave a comment.

    🔗 Similar issues

    💡 Notes and suggestions

    Item-by-item breakdown:

    1. Resolver boundary test (crates/common/src/config/mod.rs ~L1287) — Add a resolve_cache test where pull_ahead_bytes == max_unrecouped_leech_bytes and assert it resolves OK (mirrors the initial == budget test already in LeechCaps::new). Low risk, copy-adapt the existing governor test.

    2. Typed scale_saturating (optional) — The trade-off is documented in the issue: governor accumulators (PeerLeech.served/pulled) are intentionally u64, so a Bytes → Bytes return would require .get() unwraps at the call sites inside the governor. If node: thread Bytes through leech-governor accumulators + client.rs window math (full-arithmetic newtype, follow-up to #894) #910 is resolved first (making those accumulators Bytes), this item becomes clean; consider sequencing accordingly or skipping until node: thread Bytes through leech-governor accumulators + client.rs window math (full-arithmetic newtype, follow-up to #894) #910 lands.

    3. WindowExceedsBudget fields (crates/node/src/leech_governor.rs:51-52) — Straightforward: change u64 → Bytes on the two error-struct fields and update any Display/Debug formatting that renders them.

    4. Dead doc link (crates/config-types/src/percent.rs:9) — Replace [\SHARE_RATIO_SCALE`]` with either a plain backtick span or an explicit "internal constant" note. One-liner.

    5. Cross-crate doc reference (crates/config-types/src/bytes.rs:4-8) — Replace the vague "the same structs" with the concrete name LeechCapsConfig (in crates/node/src/leech_governor.rs) so readers can grep for it.

    Sequencing note: Items 3–5 are independent. Item 1 depends on nothing. Item 2 has a soft dependency on #910 and is marked optional — safe to defer or skip in the same PR.

    Generated by Agentic Triage for issue #914 · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  3. self-assigned this
    on Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:featureprio:lowrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions