router: test that members who leave leave nothing behind #759
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.50) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 567 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.379
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #759"
general
weight: 0.35
aojea
Refs #277
This is the regression test offered on #277 for the remaining item 1, router memory after members leave. As discussed there, it is parked until both upstream fixes are released:
ConnectedAddrTTL.Once both are in a release, the change that bumps
go-libp2p-pubsubandgo-libp2premoves the two skips, and CI checks the pickup from then on.What the test does
TestRouterReleasesDepartedMembersininternal/router/member_churn_test.gostarts a router throughstandalone.New. 50 in-process members (plain libp2p hosts running gossipsub) connect, complete the mesh handshake with a credential signed by the control plane's key, and then close. Against a baseline taken once the router settles, it checks three things:1. Router goroutines come back within 5 of the baseline. The router's goroutines are told apart from the members' by a pprof label set when the router starts, which every goroutine it spawns inherits. This check passes today and always runs.
2. Gossipsub per-peer contexts come back to the baseline. The context gossipsub is built with is wrapped in a context that counts its live children, the approach #735's own test uses. This check fails on v0.18.0.
3. Peerstore addrs of the departed members are gone once a mock clock passes
RecentlyConnectedAddrTTLand the addr book's gc runs. This check fails on v0.49.0.Checks 2 and 3 skip unless
AGENTMESH_TEST_UPSTREAM_LEAKS=1is set, and the skip message names the upstream PR.Production change
Router.Startreads two unexported hooks that onlyexport_test.gosets: a peerstore to build the host on (libp2p.Peerstore(pstoremem.NewPeerstore(pstoremem.WithClock(clk)))), and a wrapper for the context passed topubsub.NewGossipSub. When neither is set, behavior is unchanged. They are package variables, likegoAwayGrace, because the router is built insidestandaloneand anOptionsfield could not be set from there without exporting it.Results
Current deps (go-libp2p-pubsub v0.18.0, go-libp2p v0.49.0):
-race), with the two upstream checks skipped.AGENTMESH_TEST_UPSTREAM_LEAKS=1:- The gossipsub check fails, with 12 to 22 of 50 child contexts still live across 6 runs:
gossipsub child contexts after 50 members left = 17, want the baseline 0.- The peerstore check fails:
50 of 50 departed members still have addrs in the router's peerstore past RecentlyConnectedAddrTTL and the addr book's gc.With the fix branches swapped in locally through
replace(#735 on v0.18.0, #3559 cherry-picked onto v0.49.0):-race.Things to know
make test, it could stay behind the variable after the bump, or wait for an upstream way to trigger the gc.pstorememaddr book that uses the real clock and that the test cannot reach. The host-peerstore check exercises the same downgrade path that #3559 fixes./enroll. The control plane runs with an operator signing key file (Ed25519 plus the required P-256), so the test signs member Biscuits itself and avoids the enrollment rate limit of 10/s. Joining takes about 0.1s for 50 members.Validation
go build ./...go vet ./internal/router/ ./internal/standalone/golangci-lint run ./...(v2.14.0, the versionhack/lint.shpins): 0 issueshack/lint.sh: cleango test -race -count=1 ./internal/router/ ./internal/standalone/: passgo test -race -count=3 -run TestRouterReleasesDepartedMembers ./internal/router/: pass