test(mesh): pin session config-resolution helpers (_max_peers, endpoint-scheme gate, PeerInfo repr)#984
Merged
cagataycali merged 1 commit intoJul 2, 2026
Conversation
…nt-scheme gate, PeerInfo repr)
yinsong1986
approved these changes
Jul 2, 2026
yinsong1986
left a comment
Contributor
There was a problem hiding this comment.
Summary
Test-only PR (+119/-0, one new file tests/mesh/test_session_config_helpers.py) adding focused regression coverage for three pure-Python config helpers in strands_robots/mesh/session.py: _max_peers() env clamping, _validate_endpoint_schemes() auth-mode/scheme gating, and PeerInfo.__repr__. The assertions match the implementation exactly — non-int/non-positive STRANDS_MESH_MAX_PEERS falls back to MAX_PEERS_DEFAULT (session.py:82-89), the mtls/none scheme allowlists (_MTLS_OK_SCHEMES / _NONE_OK_SCHEMES, session.py:282-285) gate as tested, the unknown-auth-mode deferral branch (session.py:306-308) is exercised, and empty CSV segments are skipped (session.py:310-311). No runtime behaviour is modified.
What's good
- Assertions are on observable outputs (returned value / raised type / repr text), not internal state — matches AGENTS.md "Test behavior, not implementation".
- Uses
monkeypatch.setenv/delenvfor env manipulation rather than mutatingos.environdirectly, per AGENTS.md > Review Learnings (#86) > Testing Patterns. - Tight scope: no host paths, no emojis, no touch on Zenoh/torch/MuJoCo import chains.
- The error-message assertions on
_validate_endpoint_schemespin the actionable-ValueError contract (env var name + offending endpoint present in the message).
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds focused regression coverage for the pure-Python configuration helpers in
strands_robots/mesh/session.pythat resolve operator env vars and validate endpoint schemes before any transport is opened. These are contracts callers depend on but that had no direct coverage, so a regression in the fallback ordering or the scheme gate would have slipped through.New file
tests/mesh/test_session_config_helpers.pypins:_max_peers()clamps a non-integerSTRANDS_MESH_MAX_PEERS(e.g.not-a-number,10.5) and a non-positive value (0,-1) toMAX_PEERS_DEFAULTinstead of raising or accepting a bound that would disable/invert the peer-flood cap; a valid positive value is honoured._validate_endpoint_schemes()accepts TLS-bearing schemes undermtls, rejects a plaintexttcpendpoint undermtlswith an actionableValueErrornaming the env var and offending endpoint, acceptstcpundernone, rejectswssundernone, defers on an unknown auth mode without raising (that isresolve_auth_mode's error to raise), skips empty CSV entries, and normalises scheme case.PeerInfo.__repr__renders a stable identity string (peer_id,type,age).Why
These helpers gate mesh security posture (which transports are allowed under which auth mode) and bound peer bookkeeping. The env-var fallbacks and the auth-mode/empty-entry branches of the scheme validator were exercised only indirectly. The tests assert observable outputs (returned value / raised type / repr text), not internal state.
Testing
Test-only change; no runtime behaviour is modified.
strands_robots/mesh/session.pyline coverage 97% -> 99% (closes the_max_peersnon-int fallback,PeerInfo.__repr__, and both_validate_endpoint_schemesdeferral branches; the two remaining uncovered lines are best-effortexcept: passsession-teardown race paths).hatch run lintclean (ruff + format + mypy).