Skip to content

gossip: reputation-report staked gate still uses Option with inverse polarity to AnnounceGate (#1222 follow-up) #1338

Closed

Description

@thiras

Context

#1335 (part of #1222) replaced the NodeAnnounce admission gate's Option<Arc<dyn StakedNodeSet>> with a purpose-named AnnounceGate<S> { Enforce(S), Disabled } enum, precisely because nullability was overloaded to encode two safety-opposite states (None = fail-open, Some = enforce ADR 001 rule 2).

That refactor left the reputation-report membership gate untouched:

// crates/gossip/src/service.rs — ReputationWiring
staked: Option<Arc<dyn StakedNodeSet>>,   // None = fail-CLOSED (reputation gossip not wired)

So the subsystem now holds two identically-typed Option<Arc<dyn StakedNodeSet>>-shaped gates with opposite polarity:

Gate Type None/Disabled means
NodeAnnounce (post-#1335) AnnounceGate<S> Disabled = fail-open (tests only)
Reputation report Option<Arc<dyn StakedNodeSet>> None = fail-closed (no reputation gossip)

This is exactly the "same type, opposite meaning" hazard #1222 set out to remove — now living one field over in the same file. It's currently not a bug (the reputation path's None semantics are correct), but a future reader can't tell the two Options apart by type, and a copy-paste between them would be silently wrong-way-round.

Options

  1. Docs-only (cheapest): add a one-line note on AnnounceGate and on ReputationWiring.staked cross-referencing each other's inverse convention, so the asymmetry reads as deliberate.
  2. Symmetric treatment: give the reputation-report gate its own named enum (e.g. ReportGate { Enforce(S), Disabled } or a domain-specific name) so both admission gates read identically and neither relies on Option polarity.

Reviewers leaned toward (1) as the minimum and flagged (2) as the more complete fix; either is fine. Not urgent — no behavior impact.

Acceptance

  • The two staked-membership gates are distinguishable without reading the surrounding semantics, or the inverse-polarity relationship is documented on both sides.

Surfaced by the multi-agent review on #1335.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions