refactor(tracker): adopt asyncssh tracker_factory API#4
Merged
Conversation
Rework the idle auto-stop integration onto the redesigned asyncssh forward-tracker API (fork v2.23.0+forward-tracker.3, agreed in upstream PR ronf/asyncssh#807). Externally observable behavior is unchanged. - activity.py: ActivityTracker becomes the per-daemon aggregate and a tracker factory via make_tracker(); the asyncssh-facing hooks move to a per-connection _IdleConnectionTracker(asyncssh.SSHPortForwardTracker) with _opened/_closed idempotency guards so a connection counts exactly once even if connection_lost fires twice. - ssh.py: open_local_forwards takes tracker_factory (was tracker) and forwards it as forward_local_port(tracker_factory=...). - manager.py: pass tracker_factory=activity_tracker.make_tracker. - pyproject.toml: bump asyncssh fork pin to v2.23.0+forward-tracker.3. - tests: rewrite activity/ssh-transport/idle-watchdog/manager fakes for the factory + per-connection pair. - docs/specs: add revision-history note recording the API shift.
b870cb0 to
de380f3
Compare
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
Reworks the idle-auto-stop integration onto the redesigned asyncssh forward-tracker API. Externally observable behavior is unchanged — this is an integration-layer refactor to match the new upstream-agreed API shape.
Pairs with asyncssh fork
v2.23.0+forward-tracker.3(branchfeat/forward-tracker), the API agreed with the upstream maintainer in ronf/asyncssh#807.Why
The original
ForwardTracker(Protocol)(single object per listener,connection_made(orig_host, orig_port)/connection_lost(orig_host, orig_port, exc),tracker=kwarg) was redesigned during upstream review into a class hierarchy with a per-connection factory:asyncssh.SSHForwardTracker(parent, no-opconnection_lost+forward_local_bytes+forward_remote_bytes)asyncssh.SSHPortForwardTracker—connection_made(forwarder, orig_host, orig_port)(TCP)asyncssh.SSHPathForwardTracker—connection_made(forwarder)(UNIX)tracker_factory=kwarg, invoked once per accepted connectionChanges
activity.py—ActivityTrackeris now the per-daemon aggregate and the factory viamake_tracker(). The asyncssh-facing hooks move to a per-connection_IdleConnectionTracker(asyncssh.SSHPortForwardTracker)with_opened/_closedidempotency guards (a connection counts exactly once even ifconnection_lostfires twice). Public contract (make_tracker,note_connection_made,note_connection_lost,is_idle,seconds_since_activity) preserved.ssh.py—open_local_forwards(..., tracker_factory=...)(wastracker=), forwarded asforward_local_port(tracker_factory=...).manager.py— passestracker_factory=self.activity_tracker.make_tracker.pyproject.toml— asyncssh fork pin bumpedv2.23.0+forward-tracker.1→.3.test_activity/test_ssh_transport/test_idle_watchdog/test_manager_*fakes rewritten for the factory + per-connection pair.docs/specs/2026-05-21-auto-stop-idle-design.md— revision-history note recording the API shift.Verification
pytest tests/unit→ 213 passedactivity.py10.00/10connection_lostfixed) + RP/OP code-health-check → PASS (RP 32.3 / OP 29.0, max CC 4, MI grade A)