Skip to content

fix(session): stop waiting for the Kiro account check after 30 seconds - #34795

Merged
unstablebrainiac merged 1 commit into
kirodotdev:mainfrom
unstablebrainiac:fix/acquire-check-timeout
Nov 11, 2026
Merged

unstablebrainiac merged 1 commit into
kirodotdev:mainfrom
unstablebrainiac:fix/acquire-check-timeout

Conversation

@unstablebrainiac

Copy link
Copy Markdown
Contributor

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_acquire installs 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_it still 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 SessionManager in 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

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.
@unstablebrainiac
unstablebrainiac enabled auto-merge (squash) November 10, 2026 21:07
@github-actions github-actions Bot added the fork Pull request from a fork (external contributor) label Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 6c52cfcabe69c8be99b10c687380fd87c389351e via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 6c52cfc

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 6c52cfcabe69c8be99b10c687380fd87c389351e via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 6c52cfc

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 6c52cfcabe69c8be99b10c687380fd87c389351e touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 6c52cfcabe69c8be99b10c687380fd87c389351e via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 (account_identity.py:298,335), so giving up the wait leaves it running.

What this change ships

Inventory (4 items) — 4 justified

Intent: stop a slow Kiro account check from holding up every task, channel, workflow and cron acquire. This is a FIX.

  1. An acquire now waits at most 30 seconds for the account check, then goes ahead as it did before fix(session): check the Kiro account before every session acquire #19752. — justified
  2. A warning is logged when the check runs past the deadline. — justified
  3. A private constant, _IDENTITY_CHECK_BEFORE_ACQUIRE_TIMEOUT_SECS, with one consumer. — justified
  4. The session spec states the deadline and that a cold-starting acquire still waits on a running sweep. — justified

[FIRST-PRINCIPLES-REVIEWED] 6c52cfc

Description read

[DESCRIPTION-READ] 2093cfb0571786e437bf16715914782331265251d0e393e287a141608b3e4aa3

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 6c52cfcabe69c8be99b10c687380fd87c389351e via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the bound is the follow-up the maintainer asked for, and a revert undoes it cleanly.

Notes

  • The timeout fires mainly after an account switch, because that is when the sweep waits on the cold-start permits. That is the case fix(session): check the Kiro account before every session acquire #19752 guards. An acquire that times out can then claim a live session still on the previous account. Before going ahead, it could run the cheap stamp check (_flag_stamp_mismatches_after_shared_check), which flags sessions stamped for another account without needing a sweep. Either way, the description should state this trade-off.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: 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 6c52cfcabe · 65 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 11, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.shield around 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.timeout delay would pin it, and so would asserting the 30 second constant.

@unstablebrainiac
unstablebrainiac merged commit 32d5f13 into kirodotdev:main Nov 11, 2026
94 of 96 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Every session acquire waits on the Kiro account check with no time limit

2 participants