Repository navigation
fix(kas): make a defaulted-KAS spawn wait for the kiro-cli floor verdict - #22376
Conversation
85fc46c to
11289db
Compare
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. The gate only arms when KAS is the default and is never declared. Its wait is capped by the probe's own timeout, and boot and explicit choices keep today's timing. Notes
[DESIGN-REVIEWED] d1170cc Description read[DESCRIPTION-READ] 6bbdd4ea733a1d223f1e5b056d9a7f08cc8e5e5161edf74cde6888d3dff1aafe 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Every item fixes the race reported in #20469, which What this change shipsInventory (7 items) — 6 justifiedIntent: on an old kiro-cli where nobody chose a backend, the first chat after a restart runs on kiro-cli instead of failing. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] d1170cc Description read[DESCRIPTION-READ] 6c2ead58362e403f9053226c37b74e08c6db11f4a6a31ef9da215c81a66929e3 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
11289db to
4896368
Compare
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
|
self-added: no
|
|
|
4896368 to
f2c9d6a
Compare
f2c9d6a to
4c3728d
Compare
|
self-added: yes
|
d643f96 to
bdc9a33
Compare
|
self-added: yes
|
|
self-added: yes
|
|
|
bdc9a33 to
ba13b2a
Compare
|
self-added: no
|
|
CI status on ba13b2a:
All review findings on this head are answered; GPT and Opus report no findings, and Design and First Principles pass. |
ba13b2a to
d1170cc
Compare
|
Review-ready on d1170cc.
Only a maintainer approval remains. This crew did not merge, approve or enable auto-merge. |
Problem / Motivation
Goal: On a too-old kiro-cli with no backend chosen, the first chat after a gateway start runs on kiro-cli instead of failing.
With no
agent.acp_backendstored, the backend defaults to KAS (#20359). The kiro-cli floor check (_start_kas_cli_floor) runs in the background with a 15 sacp --helpprobe. Until it lands, the backend stayskas. A session created in that window (a quick first dashboard chat, a Slack message queued at boot, an overdue cron, the warm pool or the background session) spawns with--agent-engine, which an old kiro-cli rejects. The user sees one failed turn. The floor's log notice also says "KAS is selected" to a user who never chose it.Why it matters
The KAS default is new, so every user on an older kiro-cli hits this on the first turn after each restart. It looks like Kiro Crew is broken right at the start.
Not a goal
kasbehavior. A user who chose KAS keeps today's timing.What changed (motivation → approach → change)
A spawn that runs before the floor's verdict picks KAS, because the verdict has not moved the backend yet. Crew-member DMs hit the same race:
agent.member_acp_backendalso defaults to KAS.So the spawn waits for the verdict first, but only when its own KAS is a default. When the gateway schedules the floor, it arms a small gate (
kas_floor_wait) per role whose resolved backend is KAS, from in-memory config only, so boot reads no file. The floor's background task first reads, off the loop, which roles the user chose (agent.acp_backend,agent.member_acp_backend) and releases those at once; a chosen KAS never waits for the probe. Defaulted roles wait for the verdict. The cold-start path inget_or_create(member role for a member DM key, main otherwise), the warm-pool fill, the background session (bothget_bg_session, which background one-liners use, and the persistent start) and the task-run runtime bootstrap (companions.py) await that gate before they pick a backend. A kiro-cli spawn whose role is not armed never waits. The factory then reads whatever the verdict decided. The wait is bounded by the probe's own 15 s timeout, counted from when the gate was armed. It returns at once when nothing is armed, the verdict already landed, or the deadline passed. A failed or timed-out check leaves the backend as configured, as the floor already does.The floor notice says "KAS is the default backend, but ..." when no KAS role was chosen, and keeps "KAS is selected, but ..." otherwise. It takes that answer from the same off-loop read, so the files are read once.
agent_sdk/kas_floor_wait.pydocs/system-specs/modules/slack-gateway.md,docs/system-specs/modules/session.mdslack/gateway_runtime/process_entry.py,slack/gateway.pyconfig/loader_document.py,config/loader.pymember_acp_backend_declared()session_allocation_parts/get_or_create.py,session_allocation_parts/companions.py,session_pool.py,session_background.pyplatform/bootstrap.pyBackwards compatibility
Compatible: an explicit backend choice, the bundle route,
test_modeand non-gateway processes arm no gate, so they spawn exactly as before.Removes nothing: the change only adds a bounded wait and a second notice wording.
Tests
test/test_kas_cli_floor.py:test_spawn_before_the_verdict_waits_and_lands_on_kiro_cli: the floor reports an old kiro-cli; a chat spawn started before the verdict waits, then lands on kiro-cli. Red without the gate (the spawn picks KAS).test_member_dm_on_a_defaulted_member_backend_waits_and_main_does_not: withkirostored and the member backend defaulted, a member DM waits and lands on kiro-cli; a main chat does not wait.test_a_task_run_started_before_the_verdict_lands_on_kiro_cli: the task-run bootstrap waits at the gate, then picks kiro-cli.test_shared_runtime_waits_before_backend_selection: a background one-liner made before the verdict waits outside the runtime lock, then starts on kiro-cli.test_explicit_kas_does_not_wait(main and member): a storedkasspawns while the probe is still blocked; the defaulted role keeps waiting.test_declaration_documents_are_read_only_off_loop: boot returns before any config-document read, and the reads run off the loop thread.test_a_landed_verdict_costs_no_waitandtest_the_wait_is_bounded_by_the_probe_timeout: no wait after the verdict or past the deadline; the bound equals the probe timeout.TestDefaultNoticeWording: both notice wordings.The verdict is a controllable event or future; no test sleeps or uses a short fixed timeout (
test_wait_discipline_ratchet.pypasses).TestGatewayBootDoesNotWaitForTheFloorstill passes. Determinism:test/test_kas_cli_floor.pypassed 20 serial runs, 10 four-worker runs and shuffled orderings.Manual verification
N/A — unit coverage sufficient: the race is driven deterministically with a held floor verdict, and the real probe path is already covered by the existing floor tests.
Related Issues
Closes #20469
Pattern harvest
Not generalizable: the race is specific to one background check that changes a resolved default after boot.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)