Repository navigation
feat: close the enterprise gate until a kiro login is seen - #23697
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS No new strings or controls. Both screenshots show the sign-in step that enterprise mode reuses, and the blind reader read "Check sign-in again" correctly. The only control this PR changes is the other-agents picker, which it hides. Notes
[UX-REVIEWED] d678afc Description read[DESCRIPTION-READ] 424f7c442d88f1c107e7ff59e1a4549b83e313520f5c736fbef53743f6a487fd That sha256 names everything this verdict read: the PR description, plus the 5 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 No item is blocking. Two framing gaps should be read before merge: the PR goes against the accepted RFC's "exit on no login", and its own Notes
What this change shipsInventory (8 items) — 5 justifiedIntent: an enterprise build serves only sign-in until a kiro login is verified, and relocks when that login is lost. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] d678afc Description read[DESCRIPTION-READ] aa2eb6a39491a68f3330a3961c1f71183fcbdb8a99774a5332de075d2097ea90 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The gate only exists in enterprise builds, which have no installed base yet. It only narrows access, and a revert would undo it cleanly. Notes
[DESIGN-REVIEWED] d678afc Description read[DESCRIPTION-READ] ef5e6b5c012fe953910f66753b4f1e435553415c16377ccb84c65f77ab274782 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings. Notes:
[OPUS-REVIEWED] d678afc 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: |
839d0a7 to
9d88bbe
Compare
|
GPT F1 (established installs bypass the login screen): real, fixed in 9d88bbe. While the gate is closed, |
|
GPT F2 (file downloads escape gate-close revocation): real, fixed in 9d88bbe. Admission is now tracked per connection and held until the transport itself closes, instead of being dropped when the handler returns, so a |
|
GPT F3 (closed gate prevents session revocation): real, fixed in 9d88bbe. |
|
First Principles note, item 3 ( |
|
First Principles note, item 6 (multi-reason gate with one consumer): kept on purpose. The work item asked for a gate-state object with a clear API the governance item will close under its own reason. With a single flag, a login success would reopen a gate that a governance fetch failure closed, which is the fail-open case the RFC forbids. The reasons set is about 20 lines. |
|
Design note 1 (setup gate also calls config and |
|
Design note 2 (a slow |
9d88bbe to
1d4bd30
Compare
|
GPT (test mode bypasses enterprise login verification): real, fixed in 1d4bd30. |
1d4bd30 to
73154ab
Compare
|
GPT (make the enterprise login override independent-harness readiness): real, and the same class as the earlier F1, so the approach changed from a backend-only payload tweak to the gate itself. Fixed in 73154ab: |
buluoray
left a comment
There was a problem hiding this comment.
Re-review of the changes since my approval at 83d9784, pinned to head b1cb28c69eddae88def8ef60d243f5ac788b5c54 (merge-base 56b568a is unchanged, so git range-diff isolates the new commit).
What changed: lib/closeAllDialogs.ts (one window event), the Radix Dialog root and Modal both honour it, and a LockCover that sends it on mount, traps Tab (handleEscape:false, restoreFocus:false), pulls stray focusin back, and refocuses after the closing dialogs' own restore timers have run.
Verified:
- Escape cannot dismiss the cover. It is derived from the prerequisite status alone, and the trap's Escape handler is a no-op.
- Both timers are cleared and the
focusinlistener is removed on unmount. - No new user-facing strings.
- The cover is
fixed inset-0 z-[10002] pointer-events-auto, so it stays clickable even when a Radix dialog leavesbodyatpointer-events:none. KiroPrerequisiteGate.enterprise.test.tsxpasses 11/11. The Modal, Dialog and gate suites pass 238/238.tsc -p tsconfig.app.json --noEmitis clean.- Mutations, run one at a time:
- Removing
requestCloseAllDialogs()turns bothcloses an open radix|modal dialog on relock…cases red. - Removing the
focusinpull-back turns both red (radix at the pull-back assertion, modal at the initial focus assertion). - Flipping
handleEscapetotrueis an equivalent mutant (the callback is a no-op). No test presses Escape on the cover.
- Removing
Follow-ups (non-blocking, reproduced in jsdom):
-
A controlled Radix dialog whose owner declines
onOpenChange(false)stays open under the cover, and its focus scope keeps keyboard focus on the hidden dialog. Examples:useCrewEditor.requestClosewhilecommittingorcapabilityBusy, orSchedulePagewhile a delete is running. Pointer users and the 5 s poll are unaffected, but keyboard users cannot reach "Check sign-in again". -
A Radix dialog that opens after the cover is up fights the cover's
focusinpull-back until the stack overflows. A plausible path is a discard prompt raised once a pending save settles. -
The cover has no
role="dialog"oraria-modal, and the app under it is notinert, so a screen reader's virtual cursor can still reach it.Making everything except the cover
inertwhile relocked (including dialog portals), plus a re-entrancy guard on the pull-back, would close all three. It might also let dialogs be suspended instead of dismissed.
Lane dispositions on this head:
- GPT 6.1 (fenced BLOCK, dialog draft dropped on relock): the finding is real, and it is the trade-off stated as a residual in the description. The adjudication notes the loss is narrower than on main, where a relock unmounted the whole app. This needs an explicit owner decision before the gate can clear.
- First Principles (BLOCK): the
## Not a goalbullet "Frontend changes" is no longer true, and "What changed" does not listcloseAllDialogs.ts, theDialogroot change, or theModalclose-all path. Please amend the description so it matches the diff, and add a "What changed" bullet for the dialog close-all mechanism, including that it overridesdismissDisabled. - Bundle Size Gate:
ModelEffortDropdownis at 505.0 KB against a 500 KB budget. It passed at 83d9784, and main has gained frontend code since then. Please rebase and re-run. If it is still over, split the chunk or justify a budget change in the PR.
Approving the code in this increment.
b1cb28c to
b9b4d3a
Compare
|
GPT (enterprise relock destroys unsaved dialog drafts, |
buluoray
left a comment
There was a problem hiding this comment.
Approving at b9b4d3ac72e62b188347f0618b94e7ee71dff227.
This increment. The relock cover, the close-all-dialogs mechanism and the Modal/dialog hooks are gone. When a dashboard already in use relocks, it now stays mounted (unlessRelocked / appShown in KiroPrerequisiteGate.tsx). Before a resolved status has rendered the app, a lock still shows the first-run sign-in path. Both lane findings from b1cb28c69e are moot as a result (GPT: dialog drafts dropped; First Principles: frontend scope), and every AI review lane on this head reports no blocking findings.
Leaving the app on screen is safe because the server enforces the gate.
- The gate middleware sits right after token auth in both chains:
_insert_enterprise_gatein_install_dashboard_middlewaresand in_install_api_middlewares. - It is an allowlist. While closed, every route not on it is refused 403
enterprise_gate_closed, including unknown routes and every WebSocket upgrade. - When the gate closes, connections that carried a gated request are closed.
- The TCP, secondary-loopback and unix-socket sites share the one runner, so they all pass through it. The tunnel copies the middleware list after the gate is inserted.
- The middlewares that run before it only refuse, redirect, or serve the static shell.
test_closed_gate_serves_exactly_the_pinned_routeswalks the real dashboard and MCP route tables and pins the 16 that stay open.
Verification.
test/test_enterprise_gate.pyand the related backend files passed (184 tests).KiroPrerequisiteGate.enterpriseandKiroPrerequisiteGatepassed (71 tests). The full suite was not run locally.- Reverting the relock branch (
relocked = false && …) turnskeeps the app mounted and on screen when an established session relocksred. - Admitting the app from an unresolved status turns 6 enterprise tests red.
- Letting closed-gate requests through to their handler turns 4 tests in
test_enterprise_gate.pyred. - Dropping the WebSocket-upgrade exclusion from the allowed-route check stays green. It is covered in effect by
test_no_websocket_route_is_allowlisted, since no allowed path is a WebSocket route, so it is defence in depth rather than independently tested.
Bundle Size Gate. The red check (ModelEffortDropdown 506.7 KB against 500 KB) also fails on main (#23866). This PR adds about 1.7 KB to that chunk, which still fits under the 531 KB ceiling proposed in #23867. It needs #23867, or an equivalent fix, before it can merge.
Non-blocking follow-ups:
- Until #23882 lands, a relocked dashboard has no banner and nothing that says to sign in. Actions fail with the 403 message, live views stop updating, and only the status poll reopening the gate after a new sign-in, or a reload, recovers it. Please give #23882 a tier label so it is triaged.
app()setsappShown.currentduring render. That works here, but moving the write into an effect would keep it correct under concurrent rendering.- Builtin apps that run their own HTTP servers were not part of this check. If any of them can be reached directly rather than through gateway routes, it would need its own gate.
An enterprise build now starts with the gateway gate closed and opens it once the setup gate's own whoami probe sees a valid kiro login. While closed, middleware placed right after token auth in both gateway chains serves only the login status route, the session-cookie routes, the liveness probes, local shutdown and the login screen's static files; every other route, an unknown one or a WebSocket upgrade included, is refused 403 enterprise_gate_closed. A lost or expired login closes the gate again, and connections admitted while open are dropped. An oss build installs nothing. The gate keeps a set of reasons so a later governance fetch failure can close it under its own reason without touching the login half. Design: docs/request-for-change/rfc-crew-enterprise-edition.md, "Enterprise gate".
Replacing the app with the setup screen on relock unmounted it and lost form state held in components. Once the app has been admitted from a resolved status, a relock now leaves it mounted and on screen; the gateway refuses its requests until sign-in, and a reload lands on the sign-in step. The relock screen itself is follow-up #23882.
b9b4d3a to
d678afc
Compare
Problem / Motivation
Goal: In an enterprise build, Crew serves nothing but its login screen until a valid kiro login is seen, and locks again when that login expires or is lost.
The Crew Enterprise Edition RFC (
docs/request-for-change/rfc-crew-enterprise-edition.md, section "Enterprise gate", #23208) requires that login and governance form one gate, and that while the gate is closed the gateway denies every API except login.kiro_crew.edition.is_enterprise()landed in #23213, but nothing reads it at the gateway yet: an enterprise build with no kiro login serves every route.Why it matters
The enterprise edition is defended by that gate. Without it, an enterprise install with no login (or an expired one) exposes chat, config, sessions and every other API, which is the exact state the RFC's fail-closed rule forbids. This is the login half of Migration plan phase 2; the governance half needs a gate object to close, which this PR provides.
Not a goal
close(reason)/clear(reason)for the governance item; this PR does not wire it.GET /api/kiro-prerequisite, which stays open; screens that also call other APIs see a 403 until login.ossbuild.What changed (motivation → approach → change)
RFC "Enterprise gate" → one small gate object, the existing login check, one allowlisting middleware:
src/kiro_crew/enterprise_gate.py(new):EnterpriseGate, open or closed while any reason holds it.close(reason)/clear(reason)/status()(open plus reasons) /add_listener. Each concern clears only its own reason, so a later governance failure cannot be cleared by a login.LoginWatchownslogin_required:check()asksKiroPrerequisiteService.login_verifiedand opens or closes;sync()reads the latched verdict per request and only ever closes. It checks at once on startup, then every 5 s while closed, every 60 s while open; a close wakes it from the open interval.src/kiro_crew/kiro_prerequisite_service.py:authenticated(latch read) andlogin_verified(max_age_secs). The latter reuses the setup gate's ownwhoamiprobe (_probe); it re-probes when the last probe is past its age or the identity store now names another account, and answers False when the probe raises. No second login check.src/kiro_crew/dashboard/enterprise_gate_middleware.py(new):install_enterprise_gate(both entrypoints, right after the service is built; starts CLOSED; no-op inoss) and the middleware. While closed it serves onlyALLOWED_WHILE_CLOSED, method-scoped; answers a SPA document navigation with the static shell (never the route's handler); and raises 403enterprise_gate_closedwith thereasonfor everything else, including unknown routes and every WebSocket upgrade. When the gate closes, every connection that carried a gated request while open is closed, tracked per connection until it closes so a download aiohttp sends after the handler returns is cut too.src/kiro_crew/dashboard/handlers/kiro_prerequisite.py: while the gate is closed, the status reportsenterprise_login_required: trueandinitial_setup_complete: false, so the existing setup gate shows its sign-in screen instead of rendering the app for an established install. Nothing changes inoss.website/src/components/KiroPrerequisiteGate.tsx: when the status carriesenterprise_login_requiredand the app has not been shown yet (first boot, or a reload), the gate skips every bypass that would render the app (ready, an established install, a usable independent harness, the pending-config shortcut), so its existing first-run screens run in order: a missing CLI or a sandbox refusal keeps its own remedy, then the sign-in step. The poll stays at 5 s even whenreadyis latched; the config and harness reads, which the closed gate refuses, are not issued, and the other-agents picker (it writes config) is hidden. A relock of a dashboard already in use keeps the app mounted and on screen; the gateway refuses its requests until sign-in, and a reload lands on the sign-in step. The relock screen is follow-up Enterprise edition: show a sign-in screen when the login gate relocks a running dashboard #23882. No new string. The flag is absent on oss, so nothing changes there.src/kiro_crew/mcp_shared_policy.py,mcp_shared_dispatch.py: a managed MCP server whose tool-policy read gets the gate's 403 (enterprise_gate_closed) recordsgateway_locked, which refuses the call, instead of reading it as the permissivepolicy_forbidden. Without this, a turn started from cron or a channel while the gate is closed would run with the operator'smanagedToolPolicyexclusions dropped.src/kiro_crew/dashboard/server_runtime/middleware_chain.py:_insert_enterprise_gateputs the middleware right after token auth in both chains. Inner to token auth, so it only narrows; it raises, sodeny_auditrecords each refusal. Enterprise boot with no gate installed raises instead of serving ungated. The middleware holds the gate object, so the tunnel's copied chain shares it.Allowlist while closed (
ALLOWED_WHILE_CLOSED):/api/kiro-prerequisite/api/kiro-prerequisite/repair-specs,/api/kiro-prerequisite/update-cli/api/auth/me,/api/auth/refresh/api/auth/logout,/api/logout/api/token/local/api/health,/api/live,/api/ready/api/shutdown/,/api/theme/boot,/logo.png,/favicon.ico,/manifest.json,/sw.js,/icon-N.png,/assets/*,/fonts/*How routes were enumerated:
test_closed_gate_serves_exactly_the_pinned_routesbuilds an app withkiro_crew.dashboard.routes.register_all(the dashboard route registry) plusserver._register_mcp_routes, walksapp.router.routes(), and pins the exact set of registered (method, route) pairs the closed gate serves.test_every_allowlisted_api_path_is_a_real_routefails if an allowlist entry stops matching a registered route.Security: no bind, origin, CORS or token-auth rule changes; the change only removes access in an enterprise build.
Backwards compatibility
Compatible: an
ossbuild installs no gate and no middleware (test_oss_installs_no_gate_and_no_middleware,test_oss_chain_insert_is_a_no_op); the two new service members are additive.Removes nothing: in
ossnothing is gated, and the enterprise edition has no installed base.Tests
test/test_enterprise_gate.py(new):synccloses but never opens; the run loop's intervals.login_verified: probes when never probed, re-probes on an identity change, fails closed on a raising probe./api/statusand allows/api/kiro-prerequisite; unknown routes denied; WebSocket upgrade denied (403); a page navigation gets only the static shell; login opens, expiry closes (latch and background check), re-login reopens; closing drops an open WebSocket and a connection whose handler already returned; logout routes stay open; the status asks an established install to sign in (owner and non-owner).website/src/test/KiroPrerequisiteGate.enterprise.test.tsx(new): the flag blocks and keeps the 5 s poll even withready; on first boot an established install and a latchedreadyget the sign-in step, a non-owner the owner screen, never the dashboard; a missing CLI keeps the install remedy and a sandbox refusal its remedy; a usable independent harness does not bypass and the refused reads are skipped; the dashboard opens once the gate reports open; a relock of an app already shown keeps it mounted with its draft.test_a_close_wakes_a_watch_sleeping_its_open_intervalcovers the wake;test_403_from_a_closed_enterprise_gate_refuses_the_call(intest_mcp_shared_cache.py) the policy read.Updated pins:
test_kiro_prerequisite_service.py(member table),test_dashboard_server_composition_contract.py(lazy imports),test_dashboard_server_composition_contract_reach.py(boot call order).Local: black/isort/flake8/mypy clean, file-line-cap, comment-history, brand, docs-lint pass.
scripts/local-gate.pybackend related set: all pass except 84 failures intest_kas_bundle.py,test_file_explorer_app.py,test_design_tweak_backend.py,test_design_tweak_devproc.py,test_app_agent_launch_copy.py, which fail identically on a cleanorigin/maincheckout on this host (old glibc / host sandbox).Manual verification
N/A — unit and aiohttp-server tests cover the gate, the middleware and the chain wiring; there is no enterprise build to run end to end until the governance half lands.
Screenshots / video
Rendered from this head through the isolated capture entry, with
/api/kiro-prerequisiteanswered from fixtures and every other/api/call answered 403enterprise_gate_closed: the first-boot sign-in step with the gate closed, and the other-agents picker hidden.A relock of a dashboard that is already open changes nothing on screen in this PR (see below), so it has no capture.
Related Issues
Refs #23882 (relock screen for a running dashboard). Refs #23206. RFC: #23208. Builds on #23213.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.