Repository navigation
fix(readiness): accept Crew's sign-in for turn gates on the KAS bundle route - #25562
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns: the patch adds an opt-in second authority to the gate, every existing caller keeps the kiro-cli default, and it takes nothing away. Notes
[DESIGN-REVIEWED] fb415b9 Description read[DESCRIPTION-READ] 1cb7eb2303c70c553a1ca9ea2741578a7991475d93aa25a06a0c2b88be0d70ed 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 to check. What this change shipsInventory (9 items) — 9 justifiedIntent: on a host that runs Crew's own KAS engine bundle, is signed in through Crew and has no kiro-cli installed, a person can regenerate, edit-resend, rewind and call
[FIRST-PRINCIPLES-REVIEWED] fb415b9 Description read[DESCRIPTION-READ] d0a881f01c5a8481110853e9251e0197e48399ad2e89ba54d50fc5d96789cc58 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: |
bf87ebe to
870e302
Compare
|
HOLD (policy_sensitive) at The readiness gate in front of regenerate, edit-resend, rewind and AI findings judged non-blocking (Design notes, no author reply):
This PR also edits the top of — crew-pr-reviewer (r135) |
870e302 to
4803cff
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
Request changes at 4803cff31ac0e6bfe3839e3f61a30be3efa04242.
The new KAS-bundle bypass in reject_if_kiro_unverified decides the route from the configured backend (select_provider_backend), not from the session that will actually run the turn (kiro_readiness.py#L163). An existing live session is reused without a backend check (get_or_create.py#L463-L466), and changing agent.acp_backend retires only the background runtime. So after the default is switched to KAS while an idle kiro-cli session is still alive, a regenerate, edit-resend or rewind passes the gate on Crew's sign-in, persists truncated history, and the retained kiro-cli turn then fails auth. That is the history loss this gate exists to prevent. GPT 6.1 raised this as a fenced blocking finding and adjudication upheld it; there is no reply yet.
Smallest fix: when the slot already has a live session, read that session's provider backend and spawn route and allow the vault bypass only when it is the KAS bundle; use the configured selection only for a cold start. Add a test with a live non-KAS session under a KAS default.
The branch also has a merge conflict with main now. This PR changes which credential authorizes a gate, so a human reviewer is still needed after the fix.
— crew-pr-reviewer (r135)
4803cff to
d617343
Compare
|
361f30b to
5512608
Compare
5512608 to
9b48bde
Compare
625eb44 to
b812a00
Compare
|
bolichen97
left a comment
There was a problem hiding this comment.
Approving head b812a00. The gate shows 97 checks passed, none red or pending, and the branch merges cleanly into main.
What I checked in kiro_readiness.py and its callers:
- The gate judges the session that will run the turn. For a live session,
live_turn_routereads that session's own route. The Crew sign-in bypass applies only when it is the KAS bundle, and a live session on any other route, or one whose route cannot be read, keeps the kiro-cli gate. Only a cold start (None) reads the configured selection, through_kas_bundle_turn_syncandselect_provider_backend, so a member thread is judged onagent.member_acp_backend. - Regenerate, edit-resend and rewind pass the right flag.
chat_regenerate.pyandchat_rewind.pypassturn_reuses_sessionaccording to whether the turn keeps the live conversation, so a turn that discards it is judged as a cold start. - App callers learn nothing about a slot.
api_completionsjudges an app caller on the default backend without looking up the slot it names, so the gate's answer cannot reveal whether that slot exists or how it is routed. No new refusal is added. The JSON body is now parsed before the gate, which only changes the order of two existing errors. - Tests pin the live-session cases, including
test_live_kiro_cli_session_under_a_kas_default_is_refused, the case from the open change request, and an unreadable route keeping the kiro-cli gate.
The change only lets the KAS bundle route accept Crew's own sign-in, and every other route keeps today's gate. No product regex.
@iamwhatever could you take another look? Your change request on 4803cff asked that a slot with a live session be judged by that session's own backend and route, with the configured selection used only for a cold start, plus a test with a live non-KAS session under a KAS default. Both are in at this head, as above.
|
@iamwhatever could you take another look? Your change request on 4803cff looks addressed at head b812a00:
@CrysisDeu the branch now conflicts with main, so please also update it onto main. |
|
Rebased onto current main at 78df04e (still one commit). Main's #32839 changed the same three rerun handlers: regenerate, edit-resend and rewind now ask the kiro-cli gate only when
Nothing else changed in this PR's lines. |
The same push also fixes the four |
|
|
|
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 14% chance that this change introduces a defect, above the 12% limit for approving on its own. The PR adds a second, opt-in authority to I checked the following against the code:
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 |
…e route (#21957) On a KAS engine-bundle host (agent.kas_bundle) with a Crew sign-in and no kiro-cli, regenerate, edit-resend, rewind and POST /v1/chat/completions answered 503 kiro_prerequisite_required, because reject_if_kiro_unverified consulted only the kiro-cli probe. Their turn on that route spawns no kiro-cli and draws its credential from Crew's vault. reject_if_kiro_unverified takes harness_turn=True plus the session_key of the turn (turn_gate_target names it from the target slot) for callers whose only kiro-cli dependency is the turn they start; those are also authorized by kas_crew_signin_ready(session_key): the session's own backend resolves to KAS through select_provider_backend (a member thread runs on agent.member_acp_backend), agent.kas_bundle is on with an engine installed, and KasAuthProvider.current() yields a credential (no identity, or a refused or unattemptable refresh, is not ready). A slot the gate cannot read keeps the kiro-cli gate, as do the kiro-cli spawn sites.
|
Findings on
This only refuses more than the previous head, and never more than main, whose gate always asked the |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approving head fb415b9. Verified on this head: PR Readiness is green, and no main commit since the merge base touches the gated files. The new gate path is limited to regenerate, edit-resend, rewind and /v1/chat/completions (harness_turn=True), and /api/models and the usage scrape keep today's default. Each handler passes the flags that match what it does with the live process (discard_conversation for edit-resend, a possible swap_conversation for rewind). The cold-start check selects the backend from the same inputs as KasHarness.resolve_spawn, including the crewmate pin and an installed engine. The three owning specs are updated in the same commit.
Done well: an app caller is gated on the default backend without a lookup of the slot it names, so the gate cannot reveal whether that slot exists before app authorization. A parametrized test pins this.
Security: the new branch only allows a turn through, and only on a positive vault credential. kas_crew_signin_ready uses KasAuthProvider.current() with allow_env_api_key=False, so an ambient KIRO_API_KEY does not count. A rejected or blocked refresh answers not ready. Any unreadable slot, config, pin or live runtime answers False, and the kiro-cli gate then decides as on main. A live session whose route is not the bundle keeps the kiro-cli gate. The gate checks that a prerequisite is met before history is rewritten; it does not authorize the caller. The known residual (a dead bundle process after a config switch) can only produce a failed turn. No history is lost, because regenerate rewrites nothing unless its turn replies.
The design is signed off under the standing maintainer sign-off for changes by team members.
Optional:
- #36755 edits the same top of
api_completionsandkiro_readiness.py, and the two conflict textually. Please name the merge order in both bodies. The PR that lands second could reuse the other one's live-provider read, so the module keeps a single reader of the live route. - No test covers
self._kas_engine_bundle = plan.engine_bundleinruntime_spawn_launch.py. A case in the style oftest_kas_spawn.pywould close that gap: await_resolve_spawn_plan(), then assert the flag for the bundle route and for the relay route. - The spec says a liveness check would need a new pid reader.
SessionManager.is_provider_alivealready exists and is not a ratchet needle. Either use it to treat a dead provider as a cold start, or correct that sentence.
Problem / Motivation
Goal: on a KAS engine-bundle host signed in through Crew, with no kiro-cli installed, regenerate, edit-resend, rewind and
POST /v1/chat/completionsstop answering 503kiro_prerequisite_required.#21956 let
/api/sessions/usageskipreject_if_kiro_unverifiedon that setup. The same gate still refused the other callers, because it asks only the kiro-cli prerequisite probe, and on a host with no kiro-cli that probe is never ready.Why it matters
On the bundle route (
agent.kas_bundle: true) chat works: the engine is Crew's own Node build and takes its credential from Crew's sign-in vault. But every rerun and every OpenAI-compatible request was refused with a "Kiro CLI setup or sign-in is required" error for a CLI the route never uses.Not a goal
agent.kas_bundle: false). It spawns kiro-cli, so the kiro-cli gate stays its authority./api/modelson the bundle route. Its catalog iskiro-cli --list-modelsoutput, so it keeps the kiro-cli gate (see the per-site table)._vault_owns_usage.Intended? / Repro
Intended? No. The gate exists because a signed-out kiro-cli would fail the turn after history was rewritten (
src/kiro_crew/dashboard/kiro_readiness.py:251reject_if_kiro_unverifieddocstring). On the bundle route kiro-cli is not involved in the turn at all (src/kiro_crew/acp/harness/kas.py:385KasHarness.resolve_spawn, bundle branch: "no kiro-cli is involved",host_auth=True). #21956 deferred these sites to this issue.Repro (read on current main):
agent.acp_backend: kas,agent.kas_bundle: true,kirocrew kas installdone, signed in through the dashboard's Sign in, kiro-cli removed.POST /api/chat/slots/<slot>/regenerate→chat_regenerate.py:112callsreject_if_kiro_unverified(request)→kiro_verified_ready→KiroPrerequisiteService.verified_readyre-probes kiro-cli, which is missing → 503{"code": "kiro_prerequisite_required"}. The same happens atchat_regenerate.py:449(edit-resend),chat_rewind.py:126(rewind) andopenai_compat.py:145(/v1/chat/completions). The user sees the "Kiro CLI setup or sign-in is required" error although a plain send in the same slot works.What changed (motivation → approach → change)
Symptom: turn-starting endpoints refused on a host that needs no kiro-cli. Cause: the shared gate knows only the kiro-cli probe. Change: the gate learns one more authority, used only by callers whose sole kiro-cli dependency is the turn they start.
kiro_readiness.kas_crew_signin_ready(session_key): true when the turn on that session runs on Crew's installed KAS engine bundle (_kas_bundle_turn_sync) ANDKasAuthProvider(default_token_store(), allow_env_api_key=False).current()yields a credential._kas_bundle_turn_syncasks what the KAS harness itself asks, per session: the session's own backend throughslot_effort.configured_backend_for_session, the selection_configured_backend_for_slotalso runs (one copy: session pick, then crewmate pin, thenselect_provider_backend; a member thread runs onagent.member_acp_backend, and a governance-denied member backend degrades to kiro, so it is not the bundle turn),agent.kas_bundle(the flagKasHarnessreads to take the bundle route), andkas_bundle.installed_bundle(). It does not usekas_bundle.kas_bundle_route(), which asks about the default backend only and would refuse a member thread on KAS under a non-KAS default.kiro_readiness.live_turn_route(state, session_key): a session that already has a live provider is judged by the process it runs, not by the config.get_or_createreuses a live session with no backend check, and anagent.acp_backendchange retires only the background runtime, so after the default moves to KAS a retained kiro-cli session would otherwise pass the gate and then fail auth after history was rewritten. The KAS harness now marks its bundle spawn (SpawnPlan.engine_bundle=True), the runtime keeps it (AcpRuntime._kas_engine_bundle), and this reads it, unwrapping the session map'sAcpProviderto theAcpSessionProviderit exposes asclient. A live session that is not on the bundle, or whose route cannot be read, answersFalseand keeps the kiro-cli gate. A cold start reads the crewmate's harness pin first (crew_backend=crewmate_backend_pin(...)), as the provider factory does, so a crewmate pinned to kiro-cli under a KAS member backend keeps the kiro-cli gate; a pin that cannot start keeps it too.kas_crew_signin_ready(session_key, live_route)reads the configured selection only for a cold start (None).reject_if_kiro_unverified(..., turn_reuses_session=True): regenerate and/v1/chat/completionsrun their turn on the live provider, so they readlive_turn_route. Edit-resend and rewind calldiscard_conversationbefore their turn, which tears the live process down, so the turn cold-starts from the current config; they passturn_reuses_session=Falseand are judged on the configured route. A rewind with sub-agents attached swaps the conversation on the live process instead (keep_children->swap_conversation), so it also passesmay_keep_live_process=True: a live process not on the bundle keeps thekiro-cligate, and otherwise the configured route is judged (fixed in fb415b9 after Opus 5.5 and GPT 6.1 on 438b37c).kiro_readiness.turn_gate_target(state, slot_key): names the session the target slot's turns run on (effective_session_key;Nonefor a slot not created yet). A state or slot it cannot read answersharness_turn=False, so the kiro-cli gate decides and the gate still answers before the handler touches state. The credential call is the same one that answers the engine's_kiro/auth/getAccessToken, so no identity, a refused refresh (RefreshRejected) or a refresh that cannot be attempted (RefreshBlocked) is not ready, and a rerun is still refused before history is rewritten. It reads fresh state on every call; there is no latch to go stale.reject_if_kiro_unverified(..., harness_turn=False, session_key=None): new keywords. Withharness_turn=Truethe gate passes whenkas_crew_signin_ready(session_key)holds, without probing kiro-cli; otherwise it falls through to the existing kiro-cli check. Each caller passes the session its turn runs on (effective_session_keyof the target slot;Nonefor a slot that does not exist yet, which takes the default backend). The default keeps today's behavior, so a caller that spawns kiro-cli itself stays gated unless it opts in.Per site:
chat_regenerate.pyregenerateharness_turn=True, slot's session keychat_regenerate.pyedit-resendharness_turn=True, slot's session keychat_rewind.pyrewindharness_turn=True, slot's session keyopenai_compat.py/v1/chat/completionsharness_turn=True, theidslot's session key (JSON is parsed before the gate to read it)handlers/agents.py/api/modelskiro-cli chat --list-modelsDocs:
docs/system-specs/modules/learn-cron-dashboard.md,acp-client.mdandcli.mddescribe the rule.Security
The gate guards destructive reruns, so the new authority is no weaker than the probe it replaces on this route: it requires a credential that resolves (and refreshes) now, read from Crew's vault only; an ambient
KIRO_API_KEYdoes not count. Failure logs carry only the exception type, never its message, since a refresh error can carry response bytes.kiro_crew.authis imported at call time, keepingcryptographyoff the handlers' import path. No new route, port or permission.Open, for a maintainer to rule: GPT 6.1 (security-class, fenced) flags
chat_rewind.py:148: rewind with attached subagents keeps the live process (keep_children->swap_conversation), but the gate judges the configured route. So an idle KAS-bundle slot whose configured backend was switched to kiro-cli, with the kiro-cli probe failing, gets a 503 on Edit & Resend. origin/main returns the same 503 for that input:rerun_signs_in_via_kiro_cli(unchanged here) reads the configured kiro-cli backend, and main callsreject_if_kiro_unverified(request)with no KAS check. The 503 comes before any history change. Judging the configured route also covers the swap'sdiscard_conversationfallback (chat_rewind.py:566). Not changed here. Since fb415b9 the rewind also reads the live process, which only adds refusals, so this 503 still matches main.Backwards compatibility
Compatible: on every host that is not KAS-on-bundle the gate behaves exactly as on main, and callers that do not pass
harness_turnare unchanged.Removes nothing: no key, field or error path is removed.
Tests
test/test_kas_bundle_readiness_gate.py(new):TestBundleTurn: a default session on the installed bundle route, a member session on KAS, and a member session on KAS under a non-KAS default are the bundle turn; a default session under a non-KAS default, a member session on another backend, nothing installed, the relay route (engine not read) and an unreadable config are not.test_an_unreadable_slot_keeps_the_kiro_cli_gate: a slot or stateturn_gate_targetcannot read answers(False, None).test_relay_archive.pyandtest_slot_ownership_checkpoint.py: their gate stubs accept the new keywords.TestCrewSigninReady: a resolvable credential is ready (vault only,allow_env_api_key=False);NotAuthenticated,RefreshRejectedandRefreshBlockedare not; off the route the vault is not read.TestGate: a harness turn passes on a Crew sign-in without probing kiro-cli; without one it falls back to the kiro-cli 503; a default caller never consults the Crew sign-in.test_destructive_reruns_gate_on_the_slots_own_session(regenerate, edit-resend, rewind) andtest_destructive_rerun_of_an_unknown_slot_gates_on_the_default;test_chat_completions_gates_on_the_target_slots_sessionandtest_chat_completions_for_a_new_slot_gates_on_the_default: each site passesharness_turn=Trueand the session its turn runs on.test_api_models_off_the_bundle_route_never_consults_the_crew_signin:/api/modelsstays on the kiro-cli gate.TestLiveTurnRoute: no key, no session map or no live provider is a cold start (None); a live bundle process isTrue, including through the realAcpProvider→AcpSessionProviderwrapper; a live kiro-cli session, a live KAS relay session, a provider with no readable runtime and a failing session map areFalse.TestBundleTurn(crewmate pin): a crewmate pinned to kiro-cli under a KAS member backend is not the bundle turn; one pinned to KAS under a non-KAS member backend is; a pin that cannot start keeps the kiro-cli gate.TestLiveRouteSignin: a live route off the bundle refuses without reading the config or the vault; a live bundle route skips the config check but still needs the Crew sign-in;test_live_kiro_cli_session_under_a_kas_default_is_refusedpins the reviewer's case end to end (KAS-bundle default, live kiro-cli session, usable vault) to the 503.TestDiscardingRerun: withturn_reuses_session=False, a live bundle session under a non-bundle default is refused (503, vault not read), and a live kiro-cli session under a bundle default passes on the Crew sign-in. Withmay_keep_live_process=True(rewind), a live kiro-cli session is refused, and a live bundle session under a non-bundle default is refused.test_destructive_reruns_gate_on_the_slots_own_session: regenerate passesturn_reuses_session=True; edit-resend and rewind pass False. Only rewind passesmay_keep_live_process=True.test_kas_bundle.py: the bundle spawn plan carriesengine_bundle=True.On main the per-site and gate tests fail: the keyword and
kas_crew_signin_readydo not exist.Proof: not provable -- other: this host runs no local tests; CI runs the new tests
Manual verification
N/A: needs a host with the KAS engine bundle installed, a Crew sign-in and no kiro-cli. Static gates run locally: black, isort, flake8,
scripts/check_agent_sdk_boundary.py,scripts/check_file_line_cap.py,scripts/docs_lint.py. Tests run in CI.Related Issues
Fixes #21957
Sibling sweep
Swept: git grep -n "reject_if_kiro_unverified(" -- src/
Sibling: src/kiro_crew/dashboard/chat_regenerate.py -- changed here (regenerate, edit-resend)
Sibling: src/kiro_crew/dashboard/chat_rewind.py -- changed here
Sibling: src/kiro_crew/dashboard/openai_compat.py -- changed here
Sibling: src/kiro_crew/dashboard/handlers/agents.py -- not affected (spawns kiro-cli; stays gated)
Sibling: src/kiro_crew/dashboard/handlers/sessions.py -- not affected (usage routes skip the gate on
_vault_owns_usagesince #21956)Pattern harvest
Rule candidate: review-prompt
Pattern: a readiness gate that asks one harness's prerequisite (kiro-cli) refuses turns that run on a different harness; gate on the harness the target session's turn will use.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.