Skip to content

test(core): direct unit tests for PeerLifecycle's dispatch and self-connect guards - #123

Merged
Mearman merged 1 commit into
mainfrom
test/peer-lifecycle-mutation-coverage
Sep 15, 2026
Merged

Mearman merged 1 commit into
mainfrom
test/peer-lifecycle-mutation-coverage

Conversation

@Mearman

@Mearman Mearman commented Sep 15, 2026

Copy link
Copy Markdown
Member

Summary

  • PeerLifecycle was only exercised indirectly through end-to-end mesh integration tests, leaving several individual branches, self-connect guards, and handleDataMessage's method-dispatch branches unobserved.
  • A couple of Stryker's survivors against handleDataMessage were actually Timeouts under the whole-suite command runner: emptying the method body doesn't fail fast, it hangs some unrelated integration test waiting on state that never arrives. A direct unit test asserting the same mutation fails immediately instead, converting a slow timeout into a fast, precise kill.
  • Adds a direct DI-based unit test file covering handlePeerList/handlePeerJoined's self-connect guards, handlePeerConnected's state_sync gating on non-empty agent state, handleDataMessage's method-dispatch branches, handleBecomeCoordinator's full peer-table replacement and stale-agent-checker start, and handlePeerDisconnected's peerInfo cleanup.
  • Raises src/core/peer-lifecycle.ts's mutation score from a freshly-measured 61.29% (17 killed, 2 timeout, 12 survived) toward the repo's 80% threshold.

Closes #108

Test plan

  • pnpm typecheck
  • pnpm lint
  • pnpm test (62 files, 449 tests, full suite green)

…irectly

PeerLifecycle was previously exercised only indirectly through end-to-end
mesh integration tests, leaving several individual branches, self-connect
guards, and handleDataMessage's method-dispatch branches unobserved. A
couple of the survivors Stryker reported against handleDataMessage were
timeouts rather than survivors under the whole-suite command runner:
emptying the method body doesn't fail fast, it hangs some unrelated
integration test waiting on state that never arrives. A direct unit test
that asserts on the same mutation fails immediately instead, converting a
slow timeout into a fast, precise kill.

PeerLifecycleDeps is a narrow, injectable surface built exactly for direct
testing: a fake deps object with vi.fn() collaborators asserts on
handlePeerList/handlePeerJoined's self-connect guards, handlePeerConnected's
state_sync gating on non-empty agent state, handleDataMessage's
method-dispatch branches, handleBecomeCoordinator's full peer-table
replacement and stale-agent-checker start, and handlePeerDisconnected's
peerInfo cleanup.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-15T08:35:18.067206Z 0b7a8ea PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Mearman
Mearman merged commit 4ec2e40 into main Sep 15, 2026
6 checks passed
@Mearman
Mearman deleted the test/peer-lifecycle-mutation-coverage branch September 15, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raise src/core/peer-lifecycle.ts mutation score to 80%

1 participant