Repository navigation
fix(session): stop waiting for the Kiro account check after 30 seconds - #34795
Conversation
Every session acquire awaits the account check first, with no time limit. A slow store read or a long identity sweep held up even a claim of a live or warm session, which needs no start permit. The acquire now waits at most 30 seconds, logs a warning, and goes ahead without the check, as it did before the check existed. The installed check runs its sweep in a task of its own, so the sweep keeps running. An acquire that then cold-starts still queues for a start permit behind that sweep.
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. This is one bounded wait backed by a linked issue (#34787) and the maintainer's follow-up request on #19752. Base code shields the sweep ( What this change shipsInventory (4 items) — 4 justifiedIntent: stop a slow Kiro account check from holding up every task, channel, workflow and cron acquire. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 6c52cfc Description read[DESCRIPTION-READ] 2093cfb0571786e437bf16715914782331265251d0e393e287a141608b3e4aa3 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the bound is the follow-up the maintainer asked for, and a revert undoes it cleanly. Notes
[DESIGN-REVIEWED] 6c52cfc Description read[DESCRIPTION-READ] 4b2bfb3685a904f372494a6daae37898e28bf13d019ede4394303aac482705da That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Code change approver recommendation: ApproveWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. The change bounds the account check before an acquire to 30s using asyncio.timeout (Python 3.12+), then logs and goes ahead, the same fail-open path a check that raises already takes. I confirmed the installed check runs its sweep in its own task behind asyncio.shield (account_identity.py:298, 333-335), so the timeout does not cancel the sweep and later acquires still share its result. The check still runs in the acquire's own task, so the _ACQUIRING_TASK marker still works. The new test would hang without the bound and pins the call order and the warning. The spec update matches the code. All CI checks pass and the AI review lanes report no blocking findings. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
I approved this PR. Here is what the review checked on head 6c52cfc:
- On timeout, claims.py waits up to 30 seconds for the account check, logs a warning, and continues. The installed check's
asyncio.shieldaround its own sweep task means giving up the wait does not cancel the shared sweep. - An outside cancel still reaches the acquire.
- With claims.py reverted to the merge base, the new test fails by name. With the head code, the whole test file passes, and the new test passed 5 out of 5 repeats.
- session.md is updated in the same commit and matches the code.
Done well: the new test uses an already expired deadline and a bounded wait, with no sleeps, so it fails clearly instead of hanging.
Optional:
- Say in the body that an acquire that times out falls back to the behaviour before #19752. That means it can reuse an unstamped session still on the previous account. This also answers the Design note.
- The Proof line names head 7a6642a. Refresh it to name 6c52cfc.
- The log assertion does not prove the acquire used the patched deadline. A spy on the
asyncio.timeoutdelay would pin it, and so would asserting the 30 second constant.
Problem / Motivation
Goal: A slow Kiro account check no longer holds up a session acquire for more than 30 seconds.
Since #19752, every session acquire other than a dashboard chat turn awaits the Kiro account check before it hands a session out, and nothing bounds that wait. After an account change the check may run the identity sweep, which first collects every cold-start permit, so it waits for every cold start already in flight. Until the check returns, every acquire behind it waits, including a claim of a live session or a warm-pool process, which needs no start permit.
Why it matters
A slow store read or a long sweep stalls every task step, channel turn, workflow agent, sub-agent completion and cron run on the host. Before #19752 none of those waited on the check. The maintainer review on #19752 asked for this bound as a follow-up.
Not a goal
What changed (motivation → approach → change)
The account check now has a deadline, in
session_parts/claims.py. An acquire waits at most 30 seconds for it, then logs a warning and goes ahead without it, which is what every acquire did before the check existed. A check that raises was already handled this way.Giving up the wait does not stop the check's work. The installed check already runs its sweep in a task of its own and shields it, so the sweep keeps going and later acquires still share its result.
The deadline uses
asyncio.timeout, so the check runs in the acquire's own task, as before. That matters because the acquire marks its task to keep a nested acquire from checking twice.The session spec now states the deadline, and that a cold-starting acquire can still wait for a sweep.
Backwards compatibility
Compatible: an acquire that used to wait on a check now goes ahead after 30 seconds instead; nothing that works today is refused.
Removes nothing: no field, key, function or capability is taken away; only a wait gets a bound.
Tests
test_a_check_that_does_not_finish_in_time_does_not_hold_up_the_acquireinstalls a check that never finishes, with the deadline already expired. It pins that the check starts, the acquire still allocates, and the warning is logged.Proof: PROVEN test/test_acquire_identity_check.py::test_a_check_that_does_not_finish_in_time_does_not_hold_up_the_acquire (head 7a6642a)
The existing
test_cancelling_the_acquire_that_started_the_shared_check_does_not_cancel_itstill covers the shielded sweep surviving a cancelled waiter. Without the shield, a timed-out acquire would cancel the sweep (checked locally by removing the shield).Manual verification
N/A — unit coverage sufficient: the change is one bounded await in the acquire wrapper, exercised by the real
SessionManagerin the tests above.Related Issues
Closes #34787
Refs #19651, #19752
Sibling sweep
Swept: git grep -nE "identity_check_before_acquire(|_retire_sessions_on_identity_change(" -- src/
Sibling: src/kiro_crew/dashboard/chat_turn/turn_admission.py:924 -- not affected -- the attended dashboard turn's own check predates #19752 and holds up only that person's own turn
Pattern harvest
Not generalizable: the unbounded wait came from one new awaited callback on the acquire path, and that path now has its bound.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)