Skip to content

Resubscribe the feed when its socket stays connected and stops delivering - #1056

Merged
robzolkos merged 1 commit into
mainfrom
feed-resubscribe-deaf-socket
Nov 22, 2026
Merged

robzolkos merged 1 commit into
mainfrom
feed-resubscribe-deaf-socket

Conversation

@robzolkos

@robzolkos robzolkos commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

After the Cable Redis failover on 23 October, a connector's live socket stayed connected and kept getting keep-alives, but its subscription delivered almost nothing. The SDK resets its staleness timer on every frame, pings included, so nothing noticed. The once-a-minute repair poll carried every event about a minute late until someone restarted the connector by hand. Card: Connector doesn't notice when its live feed stops delivering after a Cable failover.

This makes the connector notice and resubscribe on its own.

How it tells a dead socket from a quiet one

The repair poll runs about 30 seconds behind the live socket. In steady state, everything it serves was already delivered live, so dedupe leaves it nothing new. Intake now counts, per repair walk, the new events each lane brought. When the last three walks found at least 3 new events by poll, spread over at least 2 of those walks, and more than the socket delivered, intake resubscribes. It uses the reconnect it already has for membership changes, which resumes from the saved position, so nothing is lost. That covers the partial loss seen on the day (about 80% of events polled), not only a fully dead socket.

These don't count as evidence:

  • the catch-up walk right after a connect
  • loss repairs
  • a walk in which intake held the feed's goroutine for more than 10 seconds in total (deliveries, observer callbacks, the signal handler), and the repair walk after it
  • a walk in which the live buffer overflowed, and the repair walk after it

While intake is held up, the socket's frames wait in the SDK, and a poll that reaches them first suppresses their live copies. Counting those walks would blame a healthy socket.

If resubscribing doesn't bring live delivery back (Cable down for everyone), the span doubles before the next try, up to 48 walks (about 48 minutes). A full span in which the socket delivered at least what the poll found resets it.

Verification

  • Reproduced first, on main. A throwaway test against the real feed loop with the SDK fakes: pings every second for 10s (past the 7.5s staleness window) and a 250ms repair poll. All 40 events came by poll, none came live, there was 1 dial and no stale warning. A control without pings went stale and was redialed.
  • With this change: TestIntakeResubscribesASocketThatOnlyAnswersKeepalives runs the same deaf socket through the feed loop and checks that it is replaced on the third repair walk, not before and not after. TestIntakeKeepsASocketThatDelivers is the control: the same pings and poll, with the socket delivering each event first, and the socket is kept. TestIntakeHoldsTheVerdictWhileIntakeIsBusy runs a deaf socket behind a slow admission queue, and the socket is kept.
  • Mutation pass. I reverted each rule in turn: the resubscribe, counting, catch-up exclusion, loss-repair exclusion, the minimum, the spread, the live comparison, the backoff, forgiveness, both taints and their expiry, and each timing site. Every one fails a named test. Mutants that didn't compile were counted as unmeasured, not as survivors.
  • The liveness and intake tests passed 10 to 30 times under -race. bin/ci is green on 32a83f5.

Review

Codex (gpt-6.1-sol, high) did four local adversarial passes in the worktree. None was posted to this PR.

  1. On an earlier version, it found that local backpressure could make a healthy socket look deaf, and two weak tests. Fixed: walks are discounted after a stall or an overflow, and the tests were rebuilt to wait on completed walks.
  2. It found that a per-offer timer missed slow pointer writes and accumulated lag, and that a taint expired one walk too early. Fixed: the whole ingest is timed and summed per walk, and a taint covers two walks.
  3. It found that observer callbacks were untimed, and that a reconnect's catch-up spent the taint. Fixed: every callback and the signal handler are timed, and the catch-up passes the taint through.
  4. On 2adf1e82, it found nothing needing a production change, and one overstated comment, fixed in 32a83f5 (comment-only).

Copilot reviewed the head commit, 32a83f5, covering all three changed files, and approved with no findings. The posted review is on this PR.

Built by R2-D2 (Rob's agent) on Claude Opus 5.5.

…ring

After the Cable Redis failover on 2026-10-23 a connector's socket kept
receiving keep-alives while its subscription delivered almost nothing.
Every frame re-arms the SDK's staleness window, so the socket was never
stale, and the repair poll carried every event about a minute late until
someone restarted the connector by hand.

The repair poll runs about thirty seconds behind the live lane, so in
steady state the events it serves were already delivered live and it
finds nothing new. Intake now counts, per repair walk, the new events
each lane brought. When the last three walks found at least three new
events by poll, in at least two of the walks, and more than the socket
delivered, it resubscribes through the reconnect it already uses for a
membership change, resuming from the saved position.

Not counted: the catch-up walk after a connect, loss repairs, and any
walk in which the feed's goroutine spent more than ten seconds in intake
(deliveries, observer callbacks, the signal handler) or the live buffer
overflowed, together with the next repair walk. While intake is held up
the socket's frames wait in the SDK, and a poll that reaches them first
suppresses their live copies, so those walks restart the span rather
than count against the socket. A resubscribe that does not bring live
delivery back doubles the span before the next one, up to 48 walks
(about 48 minutes), and a full span in which the socket delivered at
least what the poll found resets it.

Basecamp card: https://app.basecamp.com/2914079/buckets/48699913/card_tables/cards/10435111118
@robzolkos
robzolkos requested a review from a team as a code owner November 22, 2026 21:45
Copilot AI balanced review requested due to automatic review settings November 22, 2026 21:45
@github-actions github-actions Bot added the tests Tests (unit and e2e) label Nov 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

No active review issues are recorded for the automatic live-feed recovery change.

No open issues 🎉

What changed in this PR

Adds automatic recovery when the connector’s live feed stays connected but stops delivering events, reducing reliance on delayed repair polls and manual restarts.

Changes:

  • Detects repeated poll-only delivery and resubscribes through the existing reconnect path.
  • Excludes catch-up, loss repairs, and local stalls or buffer overflows from the evidence; backs off when resubscribing does not help.
  • Adds unit and feed-loop tests for detection, healthy sockets, backoff, and stall handling.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
internal/​connector/​intake.go Tracks delivery counts and blocked time, then requests reconnects when needed.
internal/​connector/​feed_liveness.go Implements detection thresholds, evidence exclusions, and retry backoff.
internal/​connector/​feed_liveness_test.go Tests detection rules and reconnect behavior through the feed loop.

Review effort: Balanced

@robzolkos
robzolkos merged commit 2e4370f into main Nov 22, 2026
32 checks passed
@robzolkos
robzolkos deleted the feed-resubscribe-deaf-socket branch November 22, 2026 21:54
robzolkos added a commit that referenced this pull request Nov 22, 2026
* origin/main:
  Let auth login reach a beta preview on a private network (#1054)
  Resubscribe the feed when its socket stays connected and stops delivering (#1056)
  Open pin-comment repair PRs as the org PR bot (#1052)
jeremy added a commit that referenced this pull request Nov 23, 2026
…950575

* origin/main:
  Keep a person's client flag when it is false (#1055)
  Filter gauge listings by chosen projects (#1049)
  Say how to recover a broken connect.json, and keep reporting around it (#1053)
  Support schedule entry drafts, highlights, and join links (#1019)
  Let auth login reach a beta preview on a private network (#1054)
  Resubscribe the feed when its socket stays connected and stops delivering (#1056)
jeremy added a commit that referenced this pull request Nov 23, 2026
…983764

* origin/main: (47 commits)
  Keep a person's client flag when it is false (#1055)
  Filter gauge listings by chosen projects (#1049)
  Say how to recover a broken connect.json, and keep reporting around it (#1053)
  Support schedule entry drafts, highlights, and join links (#1019)
  Let auth login reach a beta preview on a private network (#1054)
  Resubscribe the feed when its socket stays connected and stops delivering (#1056)
  Open pin-comment repair PRs as the org PR bot (#1052)
  Stop approving Dependabot PRs with GITHUB_TOKEN (#1048)
  Send mentions and files back bare when rich text is edited (#1046)
  Bump the basecamp/mcp toolkit, and title every MCP tool (#1045)
  Stop telling an agent to send a Markdown fold as HTML (#1030)
  Update nix flake and plugin version for v0.30.0 (#1042)
  Watch a connector in a terminal, and talk to its orchestrator (#1039)
  Lift the connector's cap on workers, and let a start set one (#1040)
  Never give the connector's monitor a timeout (#1035)
  Update nix flake and plugin version for v0.29.0 (#1037)
  Let assignments notify people with --notify (#1034)
  Update nix flake and plugin version for v0.28.1
  Bind local config trust to approved settings
  Update nix flake and plugin version for v0.28.0 (#1029)
  ...

# Conflicts:
#	API-COVERAGE.md
#	skills/basecamp/SKILL.md
jeremy added a commit that referenced this pull request Nov 23, 2026
…988117

* origin/main: (42 commits)
  Keep a person's client flag when it is false (#1055)
  Filter gauge listings by chosen projects (#1049)
  Say how to recover a broken connect.json, and keep reporting around it (#1053)
  Support schedule entry drafts, highlights, and join links (#1019)
  Let auth login reach a beta preview on a private network (#1054)
  Resubscribe the feed when its socket stays connected and stops delivering (#1056)
  Open pin-comment repair PRs as the org PR bot (#1052)
  Stop approving Dependabot PRs with GITHUB_TOKEN (#1048)
  Send mentions and files back bare when rich text is edited (#1046)
  Bump the basecamp/mcp toolkit, and title every MCP tool (#1045)
  Stop telling an agent to send a Markdown fold as HTML (#1030)
  Update nix flake and plugin version for v0.30.0 (#1042)
  Watch a connector in a terminal, and talk to its orchestrator (#1039)
  Lift the connector's cap on workers, and let a start set one (#1040)
  Never give the connector's monitor a timeout (#1035)
  Update nix flake and plugin version for v0.29.0 (#1037)
  Let assignments notify people with --notify (#1034)
  Update nix flake and plugin version for v0.28.1
  Bind local config trust to approved settings
  Update nix flake and plugin version for v0.28.0 (#1029)
  ...

# Conflicts:
#	API-COVERAGE.md
jeremy added a commit that referenced this pull request Nov 24, 2026
…989271

* origin/main: (45 commits)
  Keep a person's client flag when it is false (#1055)
  Filter gauge listings by chosen projects (#1049)
  Say how to recover a broken connect.json, and keep reporting around it (#1053)
  Support schedule entry drafts, highlights, and join links (#1019)
  Let auth login reach a beta preview on a private network (#1054)
  Resubscribe the feed when its socket stays connected and stops delivering (#1056)
  Open pin-comment repair PRs as the org PR bot (#1052)
  Stop approving Dependabot PRs with GITHUB_TOKEN (#1048)
  Send mentions and files back bare when rich text is edited (#1046)
  Bump the basecamp/mcp toolkit, and title every MCP tool (#1045)
  Stop telling an agent to send a Markdown fold as HTML (#1030)
  Update nix flake and plugin version for v0.30.0 (#1042)
  Watch a connector in a terminal, and talk to its orchestrator (#1039)
  Lift the connector's cap on workers, and let a start set one (#1040)
  Never give the connector's monitor a timeout (#1035)
  Update nix flake and plugin version for v0.29.0 (#1037)
  Let assignments notify people with --notify (#1034)
  Update nix flake and plugin version for v0.28.1
  Bind local config trust to approved settings
  Update nix flake and plugin version for v0.28.0 (#1029)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants