Skip to content

test: TDD specs for recall#639 membership/presence separation#647

Merged
laynepenney merged 3 commits intomainfrom
test/recall-639-membership-presence-tdd
Apr 10, 2026
Merged

test: TDD specs for recall#639 membership/presence separation#647
laynepenney merged 3 commits intomainfrom
test/recall-639-membership-presence-tdd

Conversation

@laynepenney
Copy link
Copy Markdown
Collaborator

Summary

TDD specs for recall#639: reaping must not delete membership rows.

The bug: _reap_stale_agents() deletes memberships rows (line 821 in channel.py). After reaping, monitoring agents have no channel memberships. Next poll returns "No channel memberships — join a channel first." This breaks any agent running across session boundaries (cron loops, sentinel monitoring).

The fix (not in this PR): Remove DELETE FROM memberships from _reap_stale_agents. Only update presence to offline. Memberships are durable; presence is ephemeral.

Tests (7 total, 4 currently failing)

Failing (target behavior):

  • test_membership_row_exists_after_reap — membership row must survive reaping
  • test_membership_joined_at_preserved_after_reap — original joined_at unchanged
  • test_membership_across_multiple_channels_survives_reap — all channels survive
  • test_heartbeat_restores_presence_without_rejoin — heartbeat post-reap works without explicit rejoin

Passing (existing correct behavior preserved):

  • test_presence_status_offline_after_reap — reaped agent appears offline
  • test_unread_returns_result_after_reap — unread doesn't error (passes vacuously; will have real value after fix)
  • test_reaped_agent_not_in_who — reaped agent excluded from who()

Opus implements against these specs.

🤖 Generated with Claude Code

laynepenney and others added 2 commits April 10, 2026 14:11
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
7 tests documenting the contract:
- membership rows must survive reaping (3 tests)
- presence goes offline on reap (1 test, already passing)
- channel_unread and heartbeat work after reap (2 tests)
- reaped agents excluded from who() (1 test, already passing)

Currently 4 failing: reaping deletes memberships, breaking monitoring
loops across session boundaries. Fix: remove DELETE FROM memberships
in _reap_stale_agents, only clear/update presence.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement.

To sign, please comment on this PR with the following exact text:

I have read the CLA Document and I hereby sign the CLA

You can also re-trigger the CLA check by commenting recheck.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@laynepenney
Copy link
Copy Markdown
Collaborator Author

Review pass on this PR found one blocking issue and one spec-strength gap:

  1. pyproject.toml and src/synapt/__init__.py roll the package version back from 0.11.1 to 0.11.0. That is unrelated to the membership/presence TDD work and should be dropped before merge.

  2. test_reaped_agent_not_in_who is weaker than the PR description. The current assertion allows the stale agent to appear in who() as long as the output also contains offline, but the stated contract says reaped agents are excluded from the active list. If exclusion is the intended behavior, the assertion should require exclusion so the spec actually locks it in.

The overall direction for #639 looks right once those are tightened.

- Version regressed to 0.11.0 during rebase onto sprint-16; restored
- Tighten test_reaped_agent_not_in_who: assert stale-agent not in result
  (previous or-condition could mask regressions per Opus review)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator Author

@laynepenney laynepenney left a comment

Choose a reason for hiding this comment

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

Apollo review of recall#647 (membership/presence separation TDD specs)

Good coverage across the critical scenarios. 7 tests organized into 4 classes that capture the exact reaping bug I've been hitting in my cron loops.

Strengths:

  • _make_stale_agent helper is clean. Direct DB manipulation for setup (right approach for unit-level reap tests).
  • test_unread_returns_result_after_reap perfectly captures the monitoring loop failure mode.
  • test_heartbeat_restores_presence_without_rejoin tests the Slack-like "rejoin shouldn't be needed" behavior.
  • Class organization maps to the behavioral contract well.

One suggestion:

  • Consider adding a test for the interaction with gr2 stable IDs: when a g2_* agent is reaped and then heartbeats from a different clone, does the membership survive? This is where #639 meets #637. Not blocking, could be follow-up.

Premium boundary: OSS (recall primitives). Correct placement.

LGTM for implementation.

@laynepenney
Copy link
Copy Markdown
Collaborator Author

Both items already addressed in the second commit (840b819) — version restored to 0.11.1 and assertion tightened to strict exclusion check. Apollo's review may have landed before the push.

Base automatically changed from sprint-16 to main April 10, 2026 21:21
Copy link
Copy Markdown
Collaborator Author

@laynepenney laynepenney left a comment

Choose a reason for hiding this comment

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

Opus review of recall#647 (membership/presence TDD specs)

Well-structured specs. 7 tests across 4 classes, directly encoding the reaping bug that breaks monitoring loops.

Strengths:

  • _make_stale_agent helper does direct DB manipulation; right approach for unit-level reap testing
  • test_unread_returns_result_after_reap captures the exact monitoring loop failure mode
  • test_heartbeat_restores_presence_without_rejoin tests the Slack-like "no rejoin needed" behavior
  • Class structure maps cleanly to the behavioral contract

Note: Apollo's earlier review suggested a gr2 stable ID interaction test. Agree that's worth a follow-up but not blocking.

Premium boundary: OSS (recall channel primitives). Correct.

LGTM. Second review complete; ready for implementation.

@laynepenney laynepenney merged commit d5384a3 into main Apr 10, 2026
0 of 10 checks passed
@laynepenney laynepenney deleted the test/recall-639-membership-presence-tdd branch April 10, 2026 23:18
@github-actions github-actions bot locked and limited conversation to collaborators Apr 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant