Upstream source
Evaluate and adapt the still-relevant cleanup from Kpa-clawbot/CoreScope#1966: eviction must remove resolved full-pubkey references from byPathHop, not only raw wire-hop references.
Current fork evidence
At fork master 1bdf088e, addResolvedPubkeysToPathHopIndex inserts transmissions under resolved full pubkeys, while removeTxFromPathHopIndex derives keys only from raw PathJSON hops. removeFromResolvedPubkeyIndex updates a different membership index and does not remove the *StoreTx pointers in byPathHop.
Until a later full rebuild, relay counts, transported scopes, and retained memory can therefore include expired transmissions.
Fork-specific adaptation
Do not copy the whole upstream change. The fork already materializes owned relay values under RLock; preserve that unless a focused race test disproves it. Add immediate resolved-key cleanup compatible with the fork's reverse index, byNode, nodeHashes, caches, and rebuild defense.
Acceptance criteria
- Remove every evicted transmission from all raw and resolved
byPathHop buckets, including duplicates.
- Delete empty buckets and avoid retaining evicted objects through oversized pointer arrays.
- Preserve surviving entries and all related index invariants.
- Invalidate relay/stat caches.
- Cover retention and memory eviction; later rebuilds cannot resurrect an evicted transmission.
- Concurrent relay aggregation and eviction remain race-free.
Verification
Add deterministic raw/resolved/duplicate/backing-array tests, exercise both resolved-index modes, run relay/scope/cache and full server suites under -race, benchmark realistic eviction batches, and run static checks.
No deploy or live-environment mutation is part of this issue.
Upstream source
Evaluate and adapt the still-relevant cleanup from Kpa-clawbot/CoreScope#1966: eviction must remove resolved full-pubkey references from
byPathHop, not only raw wire-hop references.Current fork evidence
At fork master
1bdf088e,addResolvedPubkeysToPathHopIndexinserts transmissions under resolved full pubkeys, whileremoveTxFromPathHopIndexderives keys only from rawPathJSONhops.removeFromResolvedPubkeyIndexupdates a different membership index and does not remove the*StoreTxpointers inbyPathHop.Until a later full rebuild, relay counts, transported scopes, and retained memory can therefore include expired transmissions.
Fork-specific adaptation
Do not copy the whole upstream change. The fork already materializes owned relay values under
RLock; preserve that unless a focused race test disproves it. Add immediate resolved-key cleanup compatible with the fork's reverse index,byNode,nodeHashes, caches, and rebuild defense.Acceptance criteria
byPathHopbuckets, including duplicates.Verification
Add deterministic raw/resolved/duplicate/backing-array tests, exercise both resolved-index modes, run relay/scope/cache and full server suites under
-race, benchmark realistic eviction batches, and run static checks.No deploy or live-environment mutation is part of this issue.