Commit e4b11af
committed
keyviz: track hidden bucket members for accurate route_count
Round-2 review fixes for PR #646 (Codex P2 ×2):
P2 #1: foldIntoBucket dedup only consulted the visible MemberRoutes
slice, so re-registering a past-cap (hidden) routeID inside the
prune grace incremented MemberRoutesTotal a second time —
route_count drifted upward on remove/re-register churn even though
the bucket membership didn't grow.
P2 #2: pruneMemberRoute only decremented MemberRoutesTotal for
routes visible in MemberRoutes. Past-cap members were absent from
that list, so removals never reduced the total — route_count stayed
permanently inflated and route_ids_truncated stayed permanently
true even after the route was fully gone.
Add a `hiddenMembers map[uint64]struct{}` set on routeSlot. Past-cap
folds land there instead of being silently dropped from accounting:
- foldIntoBucket dedups against both MemberRoutes and hiddenMembers
before incrementing.
- pruneMemberRoute checks hiddenMembers when the routeID isn't in
the visible list, deletes from the set (releasing the map when it
empties), and decrements the total.
Refactor: extract addMemberToBucket helper so foldIntoBucket stays
under the cyclop budget.
Tests:
- TestPastCapMemberRejoinDoesNotInflateTotal — Remove + Register a
hidden member → MemberRoutesTotal stays the same, no drift.
- TestPastCapMemberPruneDecrementsTotal — Remove + grace expiry of a
hidden member → MemberRoutesTotal decrements after the prune fires
on the second post-grace flush.
- Updated TestMemberRoutesCappedAtConfiguredCap to assert
MemberRoutesTotal=8 alongside the existing visible-cap=3 check.1 parent 237a090 commit e4b11af
2 files changed
Lines changed: 143 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
234 | 239 | | |
235 | 240 | | |
236 | 241 | | |
| |||
455 | 460 | | |
456 | 461 | | |
457 | 462 | | |
458 | | - | |
459 | | - | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
460 | 466 | | |
461 | 467 | | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
| 468 | + | |
468 | 469 | | |
469 | 470 | | |
470 | 471 | | |
| |||
478 | 479 | | |
479 | 480 | | |
480 | 481 | | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
481 | 507 | | |
482 | 508 | | |
483 | 509 | | |
| |||
719 | 745 | | |
720 | 746 | | |
721 | 747 | | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
728 | 755 | | |
729 | 756 | | |
730 | 757 | | |
| |||
738 | 765 | | |
739 | 766 | | |
740 | 767 | | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
741 | 777 | | |
742 | 778 | | |
743 | 779 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
916 | 916 | | |
917 | 917 | | |
918 | 918 | | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
919 | 1007 | | |
920 | 1008 | | |
921 | 1009 | | |
| |||
0 commit comments