Skip to content

fix: saturating prune-cutoff cast, drop stale dead_code allow#10

Merged
jaredLunde merged 1 commit into
mainfrom
jared/streams
Jun 12, 2026
Merged

fix: saturating prune-cutoff cast, drop stale dead_code allow#10
jaredLunde merged 1 commit into
mainfrom
jared/streams

Conversation

@jaredLunde

Copy link
Copy Markdown
Contributor

Two small hardening fixes out of a safety audit of src/:

  • src/transport.rs — the prune cutoff computed d.as_millis() as i64, a silent-wrap narrowing cast. Now i64::try_from(...).unwrap_or(i64::MAX), matching the saturating discipline the nats.rs max_age conversion already documents. No behavior change on any reachable input (wrap required a >292-million-year wall clock); the point is consistency so the safe pattern is the only one in the codebase.
  • src/nats.rsNatsHandle.client carried a stale #[allow(dead_code)] claiming the field is never read after construction; store_with_config reads it. Removed the vestigial suppression and corrected the comment to point at the real reader.

Audit context: the only other production-path finding (the cross-function invariant expect in swap_pointer) is deliberately left as-is — the pointer-swap model proves the state unreachable, and a panic there is the desired loud witness if the kernel/plumbing agreement ever breaks.

🤖 Generated with Claude Code

- transport.rs: prune cutoff now uses i64::try_from(...).unwrap_or(i64::MAX)
  instead of a silent 'as i64' wrap — same discipline as the nats.rs max_age
  conversion.
- nats.rs: NatsHandle.client carried a stale #[allow(dead_code)]; the field
  is read by store_with_config, so the suppression was vestigial. Removed it
  and pointed the comment at the real reader.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jaredLunde jaredLunde merged commit 7c29ff0 into main Jun 12, 2026
1 check passed
@jaredLunde jaredLunde deleted the jared/streams branch June 12, 2026 18:30
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.

1 participant