Repository navigation
fix: exit an enterprise boot that has no kiro login or no governance rules - #23968
Conversation
9f49a98 to
8b3574a
Compare
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: the diff adds no dashboard control and changes no existing one. The only new user-facing output is the stderr boot-refusal text, and each message says what failed and gives the next step. Notes
[UX-REVIEWED] 785c4e8 Description read[DESCRIPTION-READ] e8cc69350234ece094c0d3f5704ef128468515ca2b5e3d289d059e22006a6083 That sha256 names everything this verdict read: the PR description, plus the 3 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 |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change does what the accepted RFC says ("If either fails, exit"), every check runs before any port is bound, and an oss build runs none of the new code. Notes
[DESIGN-REVIEWED] 785c4e8 Description read[DESCRIPTION-READ] 2ebfc28ab5325eb56699201933a9262082411bcdce4c895252418983c95653c4 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 The fallback login check inside Notes
What this change shipsInventory (8 items) — 7 justifiedIntent: an enterprise build with no kiro login, or whose governance rules fail to load, exits at boot with a clear error instead of running a locked gateway. FIX (the accepted RFC covers it: "Start | Login and fetch rules. If either fails, exit").
[FIRST-PRINCIPLES-REVIEWED] 785c4e8 Description read[DESCRIPTION-READ] ba681ba444a72509a7404b577138ed4efae7b2d3ff20fdb09382ddbf92fd92ab 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: |
8b3574a to
e164a41
Compare
e164a41 to
947ed61
Compare
…rules An enterprise build now checks the kiro login (the setup gate's own --version and whoami steps) before any gateway service starts, and exits 1 with what failed and the fix when it fails. A governance policy load that fails in boot_platform exits the same way. Both run before the HTTP server binds, so a failed boot serves nothing. The enterprise gate now starts open on the verified login and refuses to install on a service with no login. A login lost while running still closes it and the middleware is unchanged. The desktop build bakes EDITION from the same KIROCREW_BUILD_EDITION stamp (enterprise only), and an enterprise app waits 80s longer for its local gateway so those checks can finish. An oss app is unchanged. Design: docs/request-for-change/rfc-crew-enterprise-edition.md, "Enterprise gate".
947ed61 to
785c4e8
Compare
cruisercohen
left a comment
There was a problem hiding this comment.
Reviewed 785c4e8b81 merged onto current main 09816d215f. This is a comment, not an approval: it changes the enterprise gate's boot behaviour, which is governance and security scope.
What changed in the enterprise gate: it now starts OPEN (EnterpriseGate(closed_for=())) instead of closed until a probe. It can only start open after a login was verified before the bind:
- Every boot runs the check.
start_dashboardandstart_api_serverboth runrequire_kiro_loginbefore the bind unless they are handed a service. The Slack gateway path hands in the service its own pre-startrequire_kiro_loginproduced. - The check fails closed. It exits on every non-signed-in status, and on a probe that raises.
- No test-mode bypass.
assume_readycannot mark an enterprise service ready:self._assume_ready = assume_ready and not is_enterprise()is unchanged from main. - A skipped check fails at boot.
install_enterprise_gateraises when its login source is not authenticated, so a caller that skipped the check fails at boot rather than opening the gate. - The runtime half is unchanged. A login lost while the gateway runs still closes the gate; the middleware change is the starting state only.
The electron EDITION file only lengthens the local gateway's wait budget. It decides nothing about access.
Tests:
test_enterprise_boot.pyplustest_kiro_prerequisite_service.py: 55 of 60 pass.- The other 5 are the gateway, api-server and CLI exit-before-bind tests. They need an optional dependency my environment lacks, so I could not run them. Neither could
test_enterprise_gate.py, which holds the install-time guard. CI's backend shards are green on this head. - Electron
edition.test.jsandgateway-wait.test.jspass 51/51.
Fail-open mutations (each turned the suite red; worktree restored clean after each):
- The boot check returning the service while signed out.
- The check swallowing a probe exception.
- The login-only latch reporting authenticated regardless of
whoami. - The policy refusal returning instead of exiting.
buluoray
left a comment
There was a problem hiding this comment.
Approve @ 785c4e8b81e066bc487d0ae3c09182d352ccf030.
Matches the accepted RFC ("Start | Login and fetch rules. If either fails, exit"; phase 2 exit criterion).
oss unchanged: require_kiro_login and refuse_policy_boot return before doing anything when not enterprise. start_dashboard / start_api_server then build the service exactly as before, and cli.main / run_gateway re-raise the same exceptions. The desktop wait only grows for watchSpawn && edition === "enterprise", and a missing or odd EDITION file reads as oss. Mutating the edition early-return turns test_oss_checks_nothing and test_oss_gateway_boots_on_without_a_login_check red.
Enterprise fails closed: any exception or non-authenticated status exits 1 before _init_services and before any bind. The login-only latch uses the same authenticated=whoami.ok as the full probe, and --test-mode still cannot assume readiness. install_enterprise_gate refuses an unauthenticated service, so a skipped check still stops at boot.
No conflict with merged work: #23686's cold-cache/failed-fetch abort raises PlatformCompositionError in boot_platform, which is exactly what refuse_policy_boot turns into a clean exit. #23689 is composition data only. For #23697 only the starting state changes; the allowlist, middleware, LoginWatch and gateway_locked are untouched, and the route-pinning tests pass.
Tests: 166 backend tests pass (including the exit-before-bind gateway / API / CLI tests), and 176 Electron tests pass. 11 of 12 single mutants go red on a named test.
Non-blocking:
- One survivor: dropping
start_dashboard's own check when handed no service. It still stops via the install guard, but with a traceback, and no test covers the dashboard path. A twin oftest_api_server_without_a_login_exits_before_the_bindwould pin it. platform-context.mdsays the boot check is alogin_verified(max_age_secs=0)probe; the code callsboot_login_status().- The policy-refusal hint "and that you are signed in to Kiro" points at the login, but the fetch does not use it yet.
- Not run in a packaged enterprise desktop build.
Problem / Motivation
Goal: An enterprise build with no kiro login, or whose governance rules fail to load, stops at boot with a clear error instead of running a locked gateway.
Refs #23697. That PR keeps a failed enterprise boot running with the gate CLOSED and serves the pinned login/health routes. The owner rejected this: a gateway that is running but locked is still a surface someone could get past. The accepted RFC
docs/request-for-change/rfc-crew-enterprise-edition.md, section "Enterprise gate", says Crew stops:and in the Migration plan, phase 2: "Exit: with no login, or with the governance fetch failing, an enterprise build exits".
Why it matters
Today an enterprise gateway with no login listens on its port and serves a set of routes. Every route that stays reachable is something an attacker can probe, and the allowlist has to stay correct forever. If the gateway exits before it binds, there is nothing to reach.
Not a goal
enterprise_gate_closed, exactly as merged in feat: close the enterprise gate until a kiro login is seen #23697.ossbehaviour.What changed (motivation → approach → change)
Product-shape decision: the accepted RFC above, section "Enterprise gate" and Migration plan phase 2. It is on main with status
acceptedsince #23714.Everything below applies only when
kiro_crew.edition.is_enterprise()is true. Anossbuild skips every new branch.kiro_crew/enterprise_boot.py.require_kiro_login()calls the newKiroPrerequisiteService.boot_login_status(). It runs only the setup gate's own--versionandwhoamisteps (not a second login check). The spec andacp --helpchecks of a full probe are left for after the bind. The probe is left not done, so the post-bind warm-up and the login watch run the full one.whoamithat clearly answers "signed out" reads as no sign-in, which nameskiro-cli loginand the SSO command. A missing CLI names the install link, and a CLI that does not start names the reinstall. A sandbox refusal, a CLI that does not answer in time, or awhoamithat times out or fails says the sign-in could not be checked, and gives that error.refuse_policy_boot(exc)turns aPlatformCompositionErrorfromboot_platform(the policy load) into the same kind of error and exit 1.GatewayOrchestrator.runcallsrequire_kiro_loginright after the sandbox warm-up (the probe runs kiro-cli inside the sandbox). That is before_init_services, before the MCP gateway sidecar starts, and before the HTTP bind. This is a bounded, fail-closed check that has to come before serving:--versionhas a 10 s limit andwhoamihas 30 s.start_dashboard/start_api_serveraskiro_prerequisite_service. If a caller passes no service, those two functions run the same check themselves, still beforerunner.setup()/site.start().cli.mainandrun_gatewaysend a failedboot_platformtorefuse_policy_boot.doctorstill runs on a failed composition. That exception is unchanged.install_enterprise_gatenow builds an openEnterpriseGateand raises if the service it is given has no login. A caller that skips the boot check therefore fails at boot instead of serving a locked app.LoginWatchstill closes the gate when the login is lost or expires while running, and the middleware, its allowlist and the dashboard's sign-in screen are untouched.docs/system-specs/modules/platform-context.md§ Enterprise gate.Desktop (Electron):
gateway-supervisor.js,childOut). When that child exits non-zero during boot, the supervisor opens its "gateway failed to start" window, which shows the tail of that log.--version), 30 s (whoami) and 10 s (policy fetch). The app's 30 s Mac/Linux wait could expire on a signed-in user whose token refresh is slow.packaging/build-desktop.shnow stageswebsite/electron/EDITIONfrom the sameKIROCREW_BUILD_EDITIONstamp the backend uses. It does this for an enterprise build only, and refuses any other value.website/electron/edition.js. No environment variable or config is read at run time.gatewayWaitTimeoutMsgives an enterprise spawned local gateway its normal budget plus 50 s for the checks and 30 s of headroom (110 s on Mac/Linux, 200 s on Windows). A failed check still ends the wait at once, because the child exits.Order of the two checks: today the policy loads in
boot_platform, before the login probe. RFC open question 1 (how the login identity is presented to the governance service) is still undecided, so the fetch does not use the login yet. Either failure exits before the bind.Backwards compatibility
Compatible: an
ossbuild runs no new code. In an enterprise build the only change is that a boot with no login or no rules exits instead of serving a locked gateway, which is what the accepted RFC requires.Reader: src/kiro_crew/dashboard/enterprise_gate_middleware.py:install_enterprise_gate -- release -- both gateway entrypoints pass it the boot-verified service; test_gate_starts_open_after_the_boot_check, test_gate_refuses_to_install_without_a_login
Reader: src/kiro_crew/enterprise_gate.py:EnterpriseGate -- release -- the default (closed for login) is unchanged for direct callers; the gateway passes closed_for=(); test/test_enterprise_gate.py
Reader: website/src/components/KiroPrerequisiteGate.tsx:KiroPrerequisiteGate -- crew page -- still reads enterprise_login_required, now set only after a login is lost while running; test_closed_gate_status_asks_an_established_install_to_sign_in
Tests
Proof: not provable -- other: prove.py is INCONCLUSIVE because reverting the production hunks removes the new enterprise_boot module, so the tests fail at collection (head 785c4e8)
test/test_enterprise_boot.py. No fixed sleeps.require_kiro_loginexits 1 with the sign-in command. A missing CLI, a CLI that does not start, a sandbox refusal, a version-probe timeout, a probe error and a probe that raises each exit 1 with their own message, and none of them says "no sign-in".--versionandwhoami, and a latersnapshot()still runsacp --help. A timed-outwhoamilatches aprobe_error, and a clearly signed-outwhoamilatches none.GatewayOrchestrator.runexits 1 before_init_services,_init_mcp_gateway,_init_dashboardand_init_api_server, and no TCP socket listens (asocket.listenspy).start_api_serverhanded no service, with no login: exits 1,TCPSite.startis never awaited, and no TCP socket listens.run_gatewayandcli.main gatewayeach exit 1 with the error before the orchestrator or_gatewayruns, and no TCP socket listens.require_kiro_loginconstructs nothing and returnsNone.GatewayOrchestrator.rungoes on to_init_serviceswith no probe.refuse_policy_bootreturns, so the caller re-raises as before.website/electron/test/edition.test.js): no baked file, or anything butenterprise, reads as oss. Oss budgets are unchanged on all platforms. An enterprise local gateway gets +80 s, and an enterprise connection tab keeps 30 s. Both wait callers pass the baked edition. The file is packed, andbuild-desktop.shstages it only for enterprise.test/test_enterprise_gate.pyruntime tests now install the gate after a login and then expire it, which models a mid-run expiry.Local gates: black, isort, flake8, mypy (3630 files), comment-history and brand all pass. 2,100+ related tests pass.
test_cli_main_entry.py::TestMcpBuiltinDispatch::test_mcp_builtin_dispatches_to_modulealso fails locally on unmodifiedorigin/main, so this change did not cause it.Manual verification
Ran a real enterprise-stamped gateway (
EDITIONpatched toenterprise, isolatedHOME,--test-mode --port auto) on a host with no usable sandbox. It printed "Kiro Crew cannot start: the Kiro sign-in could not be checked (unshare(CLONE_NEWUSER) failed with errno 1 (EPERM))" with its fix, exited 1, and no TCP socket listened.Related Issues
Refs #23697
Sibling sweep
Siblings: none -- the two boot entrypoints (start_dashboard, start_api_server) both changed here, and they are the only places install_enterprise_gate is called
Pattern harvest
Not generalizable: the defect is one design choice (keep a failed enterprise boot serving), reversed by an owner decision, not a coding pattern
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.