Skip to content

fix(minimald): a kept session leaves the tearing-down set before the cleanup's answer - #2505

Merged
bryan-minimal merged 2 commits into
mainfrom
fix/kept-session-leaves-tearing-down-before-answer
Oct 24, 2026
Merged

bryan-minimal merged 2 commits into
mainfrom
fix/kept-session-leaves-tearing-down-before-answer

Conversation

@bryan-minimal

@bryan-minimal bryan-minimal commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

a_cleanup_destroy_keeps_a_finished_session failed in #2226's merge group this afternoon: the cleanup destroy answered "kept", and the record read on the reply found nothing. The conditional destroy (#2233) answers its caller from inside the teardown task, and the task's drop guard takes the session out of the tearing-down set only when the task ends, so for a moment after the reply a kept session is still hidden behind the set, which get_record and list honour. On the box the test passes 5/5 alone; under a loaded runner the window is real.

One change: the guard is dropped before the answer goes out, so a caller that reads on the reply sees the kept session. The cleanup tests, the teardown tests and the listing tests pass three runs over.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Conditional session cleanup now clears teardown tracking before sending its response, allowing subsequent session operations to proceed without waiting for the response to finish.

…cleanup's answer

The conditional destroy answered its caller from inside the teardown task,
whose drop guard took the session out of the tearing-down set only when
the task ended. A caller that read the record or the listing on the reply
could still find a kept session hidden behind the set, which is what
a_cleanup_destroy_keeps_a_finished_session hit in a merge group under
load. The guard is dropped before the answer goes out.
@bryan-minimal
bryan-minimal requested a review from a team as a code owner October 23, 2026 18:29
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 7f5315fb-43c5-4468-bae8-0e9628316951
📥 Commits

Reviewing files that changed from the base of the PR and between 608ab9c and 147414f.

📒 Files selected for processing: 1
  • crates/minimald/src/box_manager.rs

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

📝 Walkthrough

The conditional-destroy task now releases the teardown guard before it sends the destroy result. This changes the order of guard cleanup and response handling.

Changes: Conditional destroy response

Layer / File(s) Summary
Release guard before response
crates/minimald/src/box_manager.rs
The task stores the destroy result, drops the TearingDown guard, and then sends the response.

Priority: ⬇️ Low

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

Change: Bug fix

Possibly related issues

Suggested reviewers: mitodrummer

Merge Risk: ⚪ Minimal · up to 53bf8

Merge Risk: ⚪ Minimal · up to 53bf8

The reordered teardown guard release addresses the reported visibility race without introducing an established production failure.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly describes the primary change and follows the repository's Conventional Commit format.
Description check Passed The description provides a clear summary, explains the failure, and reports test results. It does not use the template headings or include the checklist, but the required information is mostly present…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
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.
Full details: Description check

Explanation

The description provides a clear summary, explains the failure, and reports test results. It does not use the template headings or include the checklist, but the required information is mostly present.

✨ Finishing Touches
📝 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

A rabbit watched the teardown end,
The guard was dropped before response,
The result then hopped along its way,
No lingering lock delayed the day,
The burrow settled, calm and clear.

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

@minimal-foundry

minimal-foundry Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed: no findings; approval withheld, 1 thread unresolved at 53bf890375f0.

APPROVE withheld: 1 unresolved thread — minimal-foundry[bot] crates/minimald/src/box_manager.rs:1718. Resolving the last thread releases the approval on this head.

Resolve the open threads. Resolving the last one releases the approval on this head; no new review is required.

Clobber: none.

@minimal-foundry minimal-foundry Bot 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.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

Comment on lines +1711 to +1718
}
.await;
// Out of the set before the answer goes out: a
// caller that reads the record or the listing on
// the reply must not find a kept session still
// hidden behind the set.
drop(release);
r.handle(async { answer }).await;

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.

LOW · tests · confidence 0.55 · in BoxManager

The fix closes a timing race, but the diff adds no test that fails without it. The existing a_cleanup_destroy_keeps_a_finished_session is the flaky test and only fails under load. A test can pause the reply with a gated reply channel and assert that get_record finds the kept session at that point. Also note the destroyed answer now leaves the set before the reply, so a second destroy can reach a not-yet-evicted actor. Check that the actor evicts itself before it answers.

What the reviewer checked

drop(release);
r.handle(async { answer }).await;

Hand this to an agent
Act on a code-review finding.

File:       crates/minimald/src/box_manager.rs
Lines:      1711-1718
Category:   tests
Severity:   low (reviewer confidence 0.55)

Finding:
The fix closes a timing race, but the diff adds no test that fails without it. The existing `a_cleanup_destroy_keeps_a_finished_session` is the flaky test and only fails under load. A test can pause the reply with a gated reply channel and assert that `get_record` finds the kept session at that point. Also note the destroyed answer now leaves the set before the reply, so a second destroy can reach a not-yet-evicted actor. Check that the actor evicts itself before it answers.

First verify this against the code yourself. It is model output and
may be wrong. If it is wrong, or the tradeoff was deliberate, say so
and change nothing.

👍 useful · 👎 noise — react to tell the reviewer. Replying works too, and says more.

@minimal-foundry minimal-foundry Bot 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.

minimal-review — approval withheld

Verdict COMMENT — APPROVE withheld: 1 unresolved thread — minimal-foundry[bot] crates/minimald/src/box_manager.rs:1718. No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

@bryan-minimal
bryan-minimal added this pull request to the merge queue Oct 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 24, 2026
@bryan-minimal
bryan-minimal added this pull request to the merge queue Oct 24, 2026
@bryan-minimal
bryan-minimal merged commit c167e08 into main Oct 24, 2026
36 checks passed
@bryan-minimal
bryan-minimal deleted the fix/kept-session-leaves-tearing-down-before-answer branch October 24, 2026 00:56
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.

2 participants