Repository navigation
fix(daemon): reclaim unused transports at the broker limit - #469
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: blocked before merge. What this changesThis PR reclaims unused daemon transports at the 256-transport limit so new caller identities can connect. Example: 260 CLI callers use one keep-alive HTTP server with distinct CALLER_SESSION_ID values.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this PR addresses a verified capacity failure still present on main, and the earlier diagnostic finding is resolved; approval of the retained-session eviction policy remains outstanding. Priority: P1 Decision needed
Before merge
FindingsNone. Agent review detailsHow this fits togetherThe daemon broker receives view-authorized MCP requests, selects a retained transport by connection identity, and serializes calls and retirement through the runtime. flowchart LR
A[CLI caller] --> B[Configuration view]
B --> C[Daemon broker]
C --> D[Capacity admission]
D --> E[Serialized retirement]
D --> F[Retained runtime]
E --> F
F --> G[MCP server]
Technical reviewBest possible solution: Use owner-approved capacity reclamation through the existing serialized retirement path while preserving connection identity and protection for active or uncertain work. Do we have a high-confidence way to reproduce the issue? Current-main source establishes permanent slot accumulation and rejection of identity 257, corroborated by inspected contributor CLI output; no target code was executed during this read-only review. Is this the best way to solve the issue? The implementation addresses capacity accumulation through existing broker serialization and verified retirement, but evicting retained live sessions requires the area owner's policy decision. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2874448832eb. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 26, 2026, 5:26 AM ET / 09:26 UTC (Revision 2). |
|
Addressed the P3 in 6d3af15: the On the session-retention question: reclaiming only happens at the 256 limit, never touches active, queued, unknown-outcome, Chrome-owned or failed-retirement transports, and the alternative today is that every new caller identity is refused until a manual restart. Happy to gate it differently if you prefer. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
6d3af15 to
6419e72
Compare
|
Refreshed this branch onto current main and moved its release note into Unreleased. The capacity regressions reproduce on the old broker; the proposed implementation passes all 10 targeted cases and the complete Linux gate (2,302 tests). Independent review found no actionable implementation issue after checking the reported authorization-order concern against the marker-only helper. Leaving this open for the retained-session policy decision identified above. At capacity, the proposal may reset a quiet but still-live caller's session before its configured idle deadline, including when no deadline is configured. This round does not resolve that product-policy hold, so #468 remains open as well. |
|
@steipete Thanks for refreshing and validating this. I propose narrowing this PR so it does not introduce early eviction of retained sessions. The remaining cleanup bug is that configured idle retirement closes the transport and marks its entry Proposed scope:
This would be a partial fix for #468. It would not resolve the original case where all 256 transports remain connected indefinitely, and the current 260-caller proof would no longer demonstrate the proposed behavior. I would replace To keep the review clear, I suggest revising this PR in place, resolving its conflicts, and leaving pressure eviction for a separate policy discussion rather than opening a competing implementation now. Does this narrower scope work for you? No implementation change has been pushed with this proposal. |
Document early session retirement at the broker limit and preserve protected transports. Co-authored-by: Vitālijs Silins-Ozers <silins@silins.lv>
6419e72 to
c3fcd6e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3fcd6edd6
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const [key, entry] of candidates) { | ||
| if (admitted()) return true; | ||
| if (!reclaimable(key, entry)) continue; |
There was a problem hiding this comment.
Refresh eviction priorities after an awaited retirement
At capacity, if the first candidate's retirement waits and the entry is subsequently kept because a caller rejoins it—or retirement fails—later candidates can change priority during that wait. For example, another entry's idle timer can finish retiring it, but this loop still closes the next connected entry from the original snapshot instead of reclaiming the now-idle entry; a completed call that updates lastUsed is likewise ignored. This can unnecessarily destroy a live server session despite an already-retired or older unused entry being available. Re-scan the candidates after an awaited unsuccessful reclamation rather than continuing through the stale ordering.
Useful? React with 👍 / 👎.
Fixes #468.
The broker retained connection identities indefinitely, so 256 past caller environments could prevent all new sessions. At the limit it now retires the least recently used transport with no queued or active call, preferring already retired entries and failed connections. It rechecks eligibility on the existing serialized retirement path and preserves browser owners, unknown outcomes, and failed retirements.
This deliberately permits reclaiming a quiet live session before its configured idle deadline, including sessions without an idle timeout. Its next call reconnects and may lose server-side session state. Below the limit, retention is unchanged. The daemon guide and Unreleased changelog document that tradeoff.
Validation: capacity regressions cover early retirement only at capacity, LRU choice, concurrent admission, rejoining callers, failed connects and retirements, and unknown outcomes.
pnpm checkpassed. The broad Linux test run passed 2,364 tests; eight native-build tests failed because the test machine had Bun 1.4.0. Installing the repository-required Bun 1.4.4 and rerunning the two affected files passed all 25 tests. Cross-platform CI must pass at the final head before merge.Original implementation and regression coverage by @vitalijssilins; contributor credit is retained in the squash commit and changelog.