Repository navigation
fix(openai-compat): ask for kiro-cli sign-in only when the turn runs on it - #36755
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The gate now runs where the turn's harness is known and the caller is authorized, using the check the reruns already use. Nothing is taken away. Notes
[DESIGN-REVIEWED] 6135207 Description read[DESCRIPTION-READ] ff934e4bf809706d9e8b7d45c6c289229474c1c57b10965f233b929777cd454d 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 Nothing blocks. The gate now asks which harness runs the turn, which is the cause in #36754. Each item that rides along comes from the gate's new position. Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: let OpenAI SDK clients use a gateway on a non-kiro harness while kiro-cli is signed out. FIX.
[FIRST-PRINCIPLES-REVIEWED] 6135207 Description read[DESCRIPTION-READ] f4001fe9fb2580f59d0f089dd31e2ae19e863233e56c7b1d6ba3178ccf892b47 That sha256 names the PR description this verdict read. Recompute it with |
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: |
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: |
b109157 to
39d9ed9
Compare
Code change approver recommendation: A person should decideWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, but it changes 499 lines, more than the 400 it may approve on its own. The completions endpoint now asks for a kiro-cli sign-in only when the turn runs on a kiro-cli harness, using the same rerun_signs_in_via_kiro_cli check the reruns use. With reuses_live=True, a live provider's own backend decides. The session map stores the AcpProvider wrapper, whose capabilities property is a real SessionCapabilities, so live non-kiro sessions are not gated. Dead providers fall back to the config, matching how get_or_create replaces them; the one case it keeps (claude per_session) can only cause a needless 503, never an ungated kiro-cli turn. The check now runs after app isolation. A newly created slot refused with 503 is retracted through _retract_failed_newborn. Before dispatch the handler re-checks that the slot is registered, not closing and not busy. Tests cover each new behaviour, and CI and all review lanes are green. 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 |
39d9ed9 to
f817094
Compare
f817094 to
6680c84
Compare
6680c84 to
73b5ed7
Compare
|
Disposition for the GPT note downgraded on Fixed in Known limit, not changed here: if turn admission resets an unpinned slot's live session because its inherited model changed, the replacement turn can start on Kiro and answer |
…on it POST /v1/chat/completions refused every request with 503 kiro_prerequisite_required while kiro-cli was signed out, whatever harness the turn ran on. Reuse rerun_signs_in_via_kiro_cli, as regenerate, edit-resend and rewind do, so a turn on any other harness is its own sign-in authority. The check now runs after app isolation, and a refused request drops the slot it created. Caller auth is unchanged.
73b5ed7 to
6135207
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
I reviewed head 6135207 and found nothing that blocks merge. The checks: the sign-in gate now runs after the app-isolation checks, so a caller cannot use it to probe a slot it is not allowed to reach. Harness identity is a positive membership test, and an exception or an unreadable selection keeps the gate. The live provider decides only while it is alive. After the probe, a re-check refuses a slot that was replaced, closed or taken by another turn. A refused newborn slot is retracted, but a slot another send took up is kept. Regenerate, edit-resend and rewind keep their current behaviour.
Done well: the fix reuses the existing rerun_signs_in_via_kiro_cli check instead of adding a parallel one, and the handler tests run the real api_completions against the real slot registry.
Optional:
test/test_openai_compat_harness_gate.py:125and:196stub_run_chatwith a bareAsyncMock(), so a regression of the post-probe re-check hangs until the test timeout instead of failing by name.AsyncMock(side_effect=_fake_run_chat)makes the same mutation fail in a few seconds.- No test pins
if freshly_created:(openai_compat.py:642) oror slot.is_closing(:658). An assertion that a pre-existing emptys1survives a 503, plus a probe that setsis_closingwithout popping the slot, would pin both. - The PR body's sibling sweep line says regenerate is "not affected". Regenerate calls the check without
reuses_live, so a follow-up issue would describe it more accurately.
Problem / Motivation
Goal:
POST /v1/chat/completionsstops refusing requests for a missing kiro-cli sign-in when the request's turn runs on a harness that does not sign in through kiro-cli.Today the endpoint answers 503
kiro_prerequisite_requiredwhenever kiro-cli is signed out, whatever harness serves the turn. On a host whose default harness is claude, codex, opencode, goose, pi, copilot or deepseek, every OpenAI-compatible request fails while chat in the same slot works.Why it matters
OpenAI SDK clients pointed at a gateway on any non-kiro harness get a 503 for a CLI the turn never uses. Seven of nine harnesses are affected (R-LAU-12 in
docs/architecture/harness-gap-analysis.md).Not a goal
_MIXED_INTERNAL_API_PATHS) and app isolation are unchanged.reject_if_kiro_unverifiedcallers (/api/models,/api/sessions/usage).What changed (motivation → approach → change)
Symptom: a signed-out kiro-cli blocks every completion. Cause:
api_completionscalledreject_if_kiro_unverifiedbefore it knew which harness the turn would run on. Change: it now asksrerun_signs_in_via_kiro_clifor the resolved slot first, the same check regenerate, edit-resend and rewind use, and gates only when that answer is yes. For this endpoint, whose turn reuses the slot's live session, the check also reads the provider already registered for it (reuses_live=True), since a live one runs the turn whatever the config now selects: its own backend decides, one naming no backend keeps the gate, and a dead one falls back to the config because it is replaced. Edit-resend and rewind discard that provider, so they keep judging the backend a fresh session would start on. An unreadable harness keeps the gate. When it gates, the call passesturn_gate_target(state, slot.key)toreject_if_kiro_unverifiedas the reruns do, so the KAS engine-bundle route (#25562) is still served by Crew's own sign-in.The check moved below app isolation, so an app caller is told 403 for a slot it may not reach before any sign-in answer. Because the probe can await, a refused request retracts the slot it created only through
_retract_failed_newborn(kept if another send took it up), and before dispatch the handler re-checks that the slot is still registered, not closing (404) and not busy (409), aschat_senddoes. The spec paragraph inlearn-cron-dashboard.mdand the gate docstrings now name this caller.Backwards compatibility
Compatible: a kiro-cli turn is still refused with the same 503 body; other harnesses now proceed, and a malformed or unauthorized request now gets its 400/403/409 before the 503.
Removes nothing: no route, key or check is removed; the gate is narrowed to the turns it describes.
Tests
test/test_openai_compat_harness_gate.py: kiro turn 503 vs claude/codex 200 for named and ephemeral slots with no slot left behind; app isolation 403 ahead of the gate; endpoint stays on the caller-auth path list; a turn started during the probe answersslot_busy; a slot closed during the probe is not run; a refusal keeps a new slot another send took up during the probe; a live provider decides in both directions (kiro-cli or unnamed live provider gated under a codex config, live codex provider not gated under a kiro config), a dead one falls back to the config.test/test_kas_bundle_readiness_gate.py: the three/v1/chat/completionsgate tests from fix(readiness): accept Crew's sign-in for turn gates on the KAS bundle route #25562 now drive the gate at its new place: a named slot's own session is gated, an unauthorized app gets 403 before the gate reads its target, and a new ephemeral slot is gated on its own session and removed when refused.test/test_rerun_readiness_scope.py: only a caller that reuses the live provider is gated by it; edit-resend and rewind that discard a live kiro-cli provider are not.test/test_openai_compat.py,test/test_members_dm_thread_resume_and_reservation.py: the existing 503-shape test pins a kiro-cli turn; mock slots carryis_closing = False.Proof: not provable -- prove.py timed out
prove.py PROVED the first revision (b109157: the claude/codex and app-isolation cases fail without the fix), then timed out on the current one because the closed-slot test hangs without its fix. The later hunks were proven by hand: reverting each fails
test_a_live_provider_names_the_harness_the_turn_reuses[-503]/[None-503]andtest_a_slot_closed_during_the_probe_is_not_run, and reverting thereuses_livesplit failstest_a_rerun_that_discards_a_live_kiro_cli_provider_is_not_gated_by_it; prove.py timed out on the whole-diff revert (the closed-slot test hangs without its fix)Manual verification
N/A — the handler is covered end to end with the real slot registry and harness selection; no UI.
Related Issues
Fixes #36754
Sibling sweep
Swept: git grep -n "reject_if_kiro_unverified(" -- src/
Sibling: src/kiro_crew/dashboard/chat_regenerate.py -- not affected -- already gated by rerun_signs_in_via_kiro_cli
Sibling: src/kiro_crew/dashboard/chat_rewind.py -- not affected -- already gated by rerun_signs_in_via_kiro_cli
Sibling: src/kiro_crew/dashboard/handlers/agents.py -- not affected -- /api/models spawns kiro-cli itself
Sibling: src/kiro_crew/dashboard/handlers/sessions.py -- not affected -- usage scrape spawns kiro-cli itself
Pattern harvest
Rule candidate: review-prompt
Pattern: a kiro-cli readiness gate in front of a turn must first ask which harness runs that turn.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)