Skip to content

test(mcpx): make the orphaned-session test name its own failure mode - #336

Merged
dezren39 merged 1 commit into
mainfrom
sweep/290-orphan-test-diagnostics
Oct 19, 2026
Merged

dezren39 merged 1 commit into
mainfrom
sweep/290-orphan-test-diagnostics

Conversation

@dezren39

@dezren39 dezren39 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Fixes the diagnosability half of #290 (the Nix-build flake itself does not reproduce locally — see below).

Problem

TestTerminateOrphanedSessionEndsTheUpstreamSession flaked in the Nix build gate with the orphaned session saw 0 DELETE(s) (PR #275's run 39121884524), and the test discarded the evidence that would identify the cause:

  • the mock upstream counted only DELETEs for live sessions — a DELETE for a session the upstream had forgotten is answered 404 and counted as nothing, indistinguishable from no DELETE arriving at all;
  • the test never captured the upstream.session.orphaned events, which are exactly where TerminateOrphanedSession reports why a termination failed.

Fix (test-only)

  • sessionUpstream records every DELETE attempt and its session id (the daemon package's orphanUpstream mock already does this — the pool mock now matches it).
  • The test captures terminated and orphaned events via a new lifecycleCapture helper (the existing lifecycleEvents hook can hold only one kind), and its failure message reports attempts, session ids, and orphaned reasons.

The three failure modes now read differently:

  • no DELETE arrived → attempts=0 (+ orphaned reason if the dial errored);
  • DELETE arrived for a forgotten session → attempts=1, deleted=[sess-1], deletes=0, terminated still fires (404 is success by design in closeSession);
  • DELETE errored → orphaned event carries the reason.

Verification

Refs #290


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Tests
    • Expanded coverage for session cleanup when an upstream deletion attempt returns “not found.”
    • Added checks for orphaned and terminated session lifecycle events, including verification of the reported session details.

…290)

TestTerminateOrphanedSessionEndsTheUpstreamSession flaked in the Nix
build with '0 DELETE(s)', and the test discarded everything that could
say why: the mock counted only DELETEs for live sessions (a DELETE for a
forgotten session is answered 404 and counted as nothing) and the test
never looked at the upstream.session.orphaned events that carry
TerminateOrphanedSession's failure reason.

- sessionUpstream now records every DELETE attempt and its session id,
  like the daemon package's orphanUpstream already does.
- The test captures terminated and orphaned events together (new
  lifecycleCapture helper; the existing helper's hook holds one kind)
  and its failure message reports attempts, session ids and the
  orphaned reasons.

The three failure modes now read differently: no DELETE arrived
(attempts=0), the DELETE named a session the upstream had forgotten
(attempts=1, terminated still fires — 404 is success by design), or the
DELETE errored (orphaned event with the reason). Verified with a
sabotage run (upstream forgets the session before termination).
Test-only change; full internal/pool suite green, -count=200 and -race
runs of the target test green locally (the flake itself is Nix-sandbox
only and does not reproduce in a dev environment).
@dezren39
dezren39 requested a review from a team as a code owner October 19, 2026 06:05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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
📝 Code Review ✅ Completed 2026-10-19T06:09:47.187100Z — 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.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 93aac0b1-2551-4641-9d5f-e8cce4f6f86d
📥 Commits

Reviewing files that changed from the base of the PR and between 7b081c3 and 9ecdeae.

📒 Files selected for processing: 1
  • pkgs/mcpx/internal/pool/upstream_session_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

📝 Walkthrough

The upstream session test mock now records DELETE attempts, including attempts that receive 404. The orphan-termination test captures termination and orphan lifecycle events and checks that exactly one termination event identifies remote and sess-1.

Changes: Upstream session termination tests

Layer / File(s) Summary
DELETE and lifecycle event assertions
pkgs/mcpx/internal/pool/upstream_session_test.go
The mock records attempted session IDs before checking whether a session is live. The test captures termination and orphan events, checks the expected termination event, and includes attempt and event details in failure messages.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 9ecde

This change updates test observability and assertions without changing production behavior. No concrete merge-blocking risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: improving the orphaned-session test so its failure mode is identifiable.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@dezren39
dezren39 merged commit 284cd52 into main Oct 19, 2026
17 checks passed
@dezren39
dezren39 deleted the sweep/290-orphan-test-diagnostics branch October 19, 2026 06:14
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.

1 participant