Repository navigation
fix(channel): let an idle listening member answer a clear-context - #11707
Conversation
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
3 similar comments
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsFINDING -- src/kiro_crew/channel.py:772 -- lifecycle marker calls can be deleted without failing tests -> Fix: extend the existing |
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The lifecycle-lease marker is never unmarked, so it outlives a dead member on its surviving session and strips later turn-scoped holders of the strict busy answer. Watch
[DESIGN-REVIEWED] 7180a23 |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The narrow-question machinery — flag, two markers, two manager methods — has zero production callers here; its only consumer is unmerged #11691. Not justified as shipped
The re-acquire fix (items 1–2) is real on base: What this change shipsInventory (5 items) — 2 justifiedIntent: make clearing a live channel member's context both possible and survivable — the member-side half of a declared two-PR split; FIX.
[FIRST-PRINCIPLES-REVIEWED] 7180a23 |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
e1f61d4 to
cc09be5
Compare
Covers the member-side half: an idle member's lifetime lease no longer refuses forever, and a background sweep leaves a listener's cached provider alone.
cc09be5 to
7180a23
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approved after a live re-verification: readiness: passed label, PR Readiness status success on this head, no required check pending/failed/cancelled, mergeable, no effective CHANGES_REQUESTED, and no unresolved human blocking request found in comments or review threads. Native auto-merge (squash) enabled; no admin override used.
…rodotdev#11707) Covers the member-side half: an idle member's lifetime lease no longer refuses forever, and a background sweep leaves a listener's cached provider alone.
…rodotdev#11707) Covers the member-side half: an idle member's lifetime lease no longer refuses forever, and a background sweep leaves a listener's cached provider alone.
Carved from #7161 under an authorised split. That PR is +12601 across 89 files; this is one
reviewable behaviour from it, cut off the current
maintip. It is the member-side half ofthe clear-context work whose handler-side half is #11691.
Problem / Motivation
A channel member holds its lifecycle lease for its whole listening life, not for a turn. Three
consequences, each with a test here:
turn is running.
has_active_turn, so a clear in that window would destroy a session that is about to stream.at spawn, leaving every later message driving a dead provider with nothing to re-fetch it.
Why it matters
The first is a feature that silently never works on a live channel. The third is worse than a
refusal: the sweep succeeds, the listener keeps running, and its next message goes to a shut-down
provider — a failure that surfaces later and nowhere near its cause.
What changed (motivation → approach → change)
_turn_in_flightasks two different questions depending on who is asking.A background sweep passes nothing and keeps the lease test, which is deliberately the
stricter one: it also covers a turn that has acquired the semaphore but not yet put a prompt in
flight, and it is what keeps the sweep off a listening member.
A caller acting on an explicit user request passes
refuse_only_on_active_turnand gets thenarrower question — the holder's own
lifecycle_turn_activefirst, since a turn begins atdequeue and the setup before the prompt reads as idle, then the provider's
has_active_turn. Anunknown provider shape keeps the strict answer, because refusing a teardown is recoverable and
tearing down a streaming reply is not.
On the member side, a session discarded from under a listener is re-acquired rather than reused,
so the cached provider cannot outlive the clear.
test/test_channel_clear_context_idle_member.pytest/test_channel_prompt_busy.pysrc/kiro_crew/channel.pysrc/kiro_crew/session_lifecycle.py_turn_in_flightsrc/kiro_crew/session.pysession.pyandtest/test_channel_prompt_busy.pyare byte-identical to #11691's copies.channel.pyandsession_lifecycle.pyare now a strict subset of them: every one of the 58added
channel.pylines and all 50 insession_lifecycle.pyappear in #11691's added set, while124 of #11691's
channel.pyadded lines are absent here. What came out is the_log_lockhunk,has_queued_work, and one stray blank line — subtracted as undeclared riders, sopost()is nowbyte-identical to
main.This unit still compiles and tests alone, and merge order still imposes no dependency — but
whichever lands second now needs a real rebase of those two files rather than a no-op textual
match.
Tests
test/test_channel_clear_context_idle_member.pyis new, 12 tests in four classes:holds its lease; a deferred project reset lands the same way; a declared turn still defers
it; a reply in flight still refuses; and a plain turn lease still refuses without asking the
provider, which is the control that keeps the narrow question from being applied to
non-lifecycle callers.
window refuses, and the same clear succeeds once the turn is released.
re-acquired mid-turn.
member holding its lease, the user-initiated clear still clears that same member, a session
the listener acquires still answers a user clear, and a static check that no
acquiresitesits outside the functions these controls drive.
Manual verification
N/A — unit coverage is sufficient.
A regression sweep over 129 suites (every test importing
channel,sessionorsession_lifecycle) gives 4531 passed, 0 failed. The identical sweep on a pristine checkout ofthe same base gives 4515 passed, 0 failed, 2 errors, and both errors are
can't start new threadfrom host thread exhaustion rather than from the tree. The +14 passes are this unit's 12 newtests plus 2 from the carried fake update.
Pattern harvest
Rule candidate: review-prompt
Pattern: a busy predicate that answers from a held lease rather than a declared turn,
applied to a caller whose lease is held for a lifetime.
skip_if_busyreadsession.semaphore.locked()and nothing else. That is the right answer for acaller whose lease spans one turn, and a permanent refusal for one that holds it across an idle
listening life — the refusal never lifts, so the retry-when-idle the caller offers can never
succeed. The defect is not a wrong predicate; it is one predicate serving two questions that
differ in whose "busy" is meant.
The generalizable check is that a busy/blocked predicate must name the scope it measures, and
every call site must be classifiable against that scope. A predicate whose refusal has no
reachable end state is the signature: if no state transition can make it return false, the
feature behind it silently never works. That reads as a review prompt rather than a semgrep
pattern, because the lease-lifetime relationship is not local to the expression.
Related Issues
Carved from #7161. Handler-side half is #11691; shares carried primitives with #11163.
One test class from the source file is not included:
TestAnAgentOnlyArmDoesNotForceAColdStart EveryTurncallsmark_retire_on_next_claimand reads arms throughSessionAllocationService._arm_if_any, which do not exist onmain. It reopens with theretirement-arm subsystem.