Skip to content

fix(cloud): preserve Identity Center login through managed launch - #9840

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
jeeshofone:fix/cloud-managed-idp
Sep 17, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
jeeshofone:fix/cloud-managed-idp

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

An IAM Identity Center (Kiro Pro) user launching a managed EC2 crew — through kirocrew setup's cloud step, kirocrew cloud launch, or the dashboard's Remote Crew launch — is shown the generic Builder ID portal, not their organization's sign-in. The remote command was kiro-cli login --use-device-flow with no identity flags on every managed path. Worse, the pre-login check was a boolean (is_logged_in: "is some session present?"), so approving the wrong account read as success: the instance exists, the device code was valid, setup reports done, and the crew runs on the wrong license tier, model entitlement and usage pool. A resumed instance carrying a wrong-but-valid session short-circuited the same way.

#6650 added --identity-provider / --license / --idp-region to the standalone recovery command kirocrew cloud login and forwarded them correctly there. It deliberately did not carry them through the managed paths — the Design and First Principles reviews on that PR recorded the gap and the approval called it deferred pending the per-invocation-flags vs instance-property decision. #3221 was nevertheless closed by that merge; this PR is the deferred remainder.

Why it matters

Every Identity Center user who launches a managed crew hits this on a fresh instance (#3221 has confirmations from several organizations, CLI and dashboard). The failure is silent: nothing tells the user the crew is on the wrong identity, and the only recovery was an SSM/SSH workaround. It also defeats the point of a managed crew — "my Kiro running elsewhere" — for exactly the users on a paid tier.

What changed (motivation → approach → change)

Approach: the login identity is a durable property of the managed launch, not per-invocation flags. Flags would recreate this exact omission at every sibling call site (the wizard's verification retry and the engine's resume are the two #6650 missed). So there is now one type, KiroLoginTarget (src/kiro_crew/cloud/login_target.py), and every sign-in entry point takes it — which makes the omission type-visible instead of a thing a reviewer has to notice.

  1. Shared model. KiroLoginTarget(license, start_url, region) — validated for SAFETY, not shape (https on the default port; no userinfo/query/fragment; a syntactically valid hostname; control and shell metacharacters refused; region shape; free|pro; pro ⇒ start URL + region), normalized, serializable. The empty target is Builder ID and is byte-for-byte the pre-existing behaviour. Also here: parse_whoami_output (extracted from the dashboard's credit readout, which now calls it — one JSON scrape, not two), discover_local_identity (the launching machine's kiro-cli whoami --format json), identity_matches_target.

  2. cloud/login.py. is_logged_in(..., target=) means logged in as that identity: a valid session for the wrong account family is False. The default (Builder ID) target's family is a closed allowlist: BuilderId and the Social<Provider> sessions its own callback fallback produces; IamIdentityCenter, ApiKey and an unknown type are not a match. New remote_identity() / remote_identity_state() read the remote whoami --format json and classify match | mismatch | absent | unknown — a transient SSM fault is unknown, never a mismatch. start_device_login / resume_login_daemon / wait_until_logged_in all take target= (the legacy string kwargs still work; cloud login is unchanged for values it accepted before). An identity-pinned attempt never falls back to the social/callback flow — that is a different identity family — it surfaces the error instead.

  3. All nine managed call sites carry the target — enumerated up front, not discovered per review round: wizard.py ×5 (sign-in step, verification check/start/resume/wait), launch_engine.py ×2 (_RealSigninHandle start and resume — the handle holds the target so a device-code timeout cannot restart as Builder ID), cli_cloud.py ×2 (login). The wizard and CLI both report a mismatch with the exact cloud logout && cloud login … commands rather than adopting the wrong session.

  4. Durable launch job. LaunchJob.login_target is persisted and round-trips; a job file written before the field loads as Builder ID. LaunchJobStore.create(login_target=). The runner calls begin_signin through _begin_signin_with_target, which versions the LaunchEngine protocol: an engine that accepts login_target gets it; a downstream provisioner on the older three-argument shape keeps working for the default target, and a non-default target on such an engine fails loud (RuntimeError) rather than silently signing in as the wrong identity.

  5. Dashboard. POST /api/cloud/launch accepts login_target and validates it at the owner-only boundary (coded 400 invalid_login_target; absent = Builder ID, pre-seam bodies unchanged). New owner-only GET /api/cloud/identity returns the launching machine's {account_type, start_url} and a suggested target (no email; never a credential). RemoteCrewPanel gains a "Kiro sign-in for the crew" section: Builder ID / Company SSO radios, preselected from the inherited identity, start URL + Identity Center region inputs (labelled as distinct from the EC2 region), and Launch is disabled until an Identity Center target is complete.

  6. CLI. --identity-provider / --license / --idp-region move to a shared helper used by both cloud login and cloud launch; cloud launch also gets --no-inherit-identity. Resolution: explicit flags › inherited local whoami › Builder ID. A local whoami that could not run (the binary fails to resolve, will not start, or times out) or exited nonzero without printing an identity (an expired or broken local session) leaves the identity unknown, and the command refuses — naming --identity-provider/--idp-region and --no-inherit-identity — rather than defaulting to Builder ID; only a whoami that ran and reported no Identity Center sign-in falls through to the default. The dashboard form applies the same rule: GET /api/cloud/identity answers discovery: "unknown" with no suggested target when whoami could not answer, and the form then shows a notice, treats the checked Builder ID radio as a placeholder, and keeps Launch disabled until the user picks an identity by hand (a failed request is handled the same way). In the wizard, an identity mismatch verified at the sign-in step holds through the operational recheck unless that recheck positively confirms the right identity, so a transient SSM fault on the recheck cannot turn a wrong-identity launch into an exit-0 "not signed in" warning. --idp-region alone completes the inherited target (it is the one field whoami cannot report) rather than replacing it. kirocrew setup's hand-built launch namespace carries the same fields, so it inherits too. An inherited Identity Center target without a region is completed before anything is provisioned: asked interactively, or refused under --yes with the flag to pass — never downgraded to Builder ID. cloud login now runs its flags through the same from_fields validation as the managed path -- a deliberate tightening, not preserved behaviour: an unsafe value (shell metacharacter, http:, userinfo) that the recovery command previously forwarded to the remote shell verbatim is refused up front with the same message the wizard gives. The host and path are NOT pinned (an Identity Center portal on GovCloud, China or a custom domain is accepted; the portal itself rejects a URL that is not one of its own). The older per-invocation identity_provider=/license_=/idp_region= keywords on start_device_login / resume_login_daemon are removed -- every caller passes target=.

  7. The remote login runs under a pseudo-terminal when the identity is pinned. Found on a live launch (below): kiro-cli 2.21.2 prompts for the Identity Center start URL and region even when the flags supply them — the flags only prefill the answers — and it reads those prompts from a TTY. With the existing nohup … </dev/null launch the answers come back empty and the flow dies with invalid value for field: region - must be a valid host label before any device code is printed; Builder ID prompts for nothing, which is why the old flow never hit this. A small stdlib-only Python pty driver (_LOGIN_PTY_DRIVER, written to the instance next to the login log under the same umask 077) runs kiro-cli, presses Enter on each prefilled prompt, strips ANSI/CR, and drops the prompt echo from the log so the echoed start URL cannot be read as the verification URL; parse_login_output(ignore_url=) guards the same thing from the parsing side. The Builder ID launch is byte-identical to before.

Alternatives considered: per-invocation flags on cloud launch only (the shape #6650 took for cloud login) — rejected for the reason above; inferring the Kiro identity from the AWS provisioning profile — rejected, the two identities are unrelated (a crew provisions correctly in any AWS account while signing in as the wrong Kiro account).

Tests

test/test_cloud_login_target.py (53) — one class per boundary #6650 left open:

  • Model: default target is backward compatible; pro normalizes; 15 malformed shapes rejected (HTTP, userinfo, port, query, fragment, wrong host, wrong path, shell metacharacters, control chars, missing region, region without URL, bad license); from_dict of a malformed persisted target falls back to default.
  • whoami parsing / matching: leading-JSON-only, length-bounded, trailing Profile block ignored; Identity Center match requires the same normalized portal; a Builder ID session is not a match for an Identity Center target and vice versa.
  • Login module: wrong-identity session → is_logged_in(target=) False and state mismatch; matching identity short-circuits; absent vs unknown kept distinct; target flags reach the remote command on both start and resume (and via the legacy kwargs); the default target emits exactly the old command; an identity-pinned attempt never calls the callback fallback while the default still may; a pinned login runs under the pty driver (written after umask 077, cleaned up with the log) while Builder ID keeps the plain nohup; parse_login_output ignores the pinned start URL; and a real pty run of the driver against a fake kiro-cli that prompts like 2.21.2 answers both prompts, emits no prompt echo / start URL / ANSI, and yields a parseable code + user_code= URL.
  • Launch job: round-trip; legacy file loads as default; persisted target holds only {license, start_url, region}.
  • Engine: _RealSigninHandle forwards the target on start, resume and poll; the runner passes it to a target-aware engine, and refuses a non-default target on a legacy engine while leaving the default path untouched.
  • Handler: valid target persisted; pre-seam body = Builder ID; five invalid shapes → 400 invalid_login_target with nothing persisted; non-owner 403 before parsing; /api/cloud/identity owner-only, suggests the target, omits email.
  • CLI: explicit flags win and are validated; inheritance yields an un-regioned Identity Center target; --idp-region alone completes it (and is still refused with nothing to attach to); --no-inherit-identity and a Builder ID local identity both yield the default; cloud launch threads the target into the wizard; both parsers accept the shared flags; the setup namespace inherits.
  • Wizard: --yes with an un-regioned Identity Center target exits 2 naming --idp-region, provisioning nothing.

All 591 cloud tests (test/test_cloud_*.py) pass; black / flake8 / isort / mypy / comment-history gates green.

website/src/test/RemoteCrewPanel.test.tsx (+2): the inherited Identity Center identity is preselected and named, Launch is disabled until the region is entered, and the body carries login_target; overriding back to Builder ID sends no target. 104/104 in the panel's three test files.

Manual verification

Live launch from this branch into a disposable AWS account (cloud launch --size light --idp-region <region> --new --keep-on-failure, launching machine signed in to Identity Center):

  • Inheritance + completion: -> The crew will sign in as IAM Identity Center (https://<org>.awsapps.com/start, <region>). printed before any provisioning. (The first attempt exposed the --idp-region-alone resolver bug in item 6 — "an Identity Center region without a start URL is meaningless" — fixed and covered by test.)
  • Provisioning: stack CREATE_COMPLETE, instance healthy, KiroCrew installed.
  • Sign-in step exposed item 7: kiro-cli did not produce a device-code prompt for IAM Identity Center (…). Diagnosed on the kept instance over SSM: kiro-cli 2.21.2's log held only error: failed to construct request; -vv showed called input while stdout is not a terminal ×2 then invalid value for field: region - must be a valid host label; the same command under a pty showed ? Enter Start URL › https://<org>.awsapps.com/start waiting; a Builder ID control printed its code normally; and driving the pty with Enter on both prompts produced Confirm the following code in the browser / Code: XXXX-XXXX for the Identity Center portal. That driver is the fix.
  • Fixed sign-in step, re-run on the same instance (the exact remote script _device_login_command renders for the pinned target, delivered through ssm.run_command's wrapper): captured log is exactly Confirm the following code in the browser / Code: XXXX-XXXX / Open this URL: https://<org>.awsapps.com/start/#/device?user_code=… — the org portal, zero prompt echo; driver + kiro-cli child alive and polling under the pid in the pid file; log, driver and pid file all 0600 ec2-user. After approving the code in a browser: whoami on the box reports IamIdentityCenter with the org start URL, and the driver and its child have exited.
  • Identity matrix (remote_identity_state / is_logged_in(target=) against that live session): pinned org target → match / True; a different org's start URL → mismatch / False; the default Builder ID target → mismatch / False (every supplied target is verified, the default included — a reused instance's Identity Center session is not adopted by a Builder-ID launch; only a caller passing NO target asks the legacy "some session" question). Before the approval all three read absent / False.
  • Not exercised live: the dashboard launch path and kirocrew setup (same KiroLoginTarget plumbing, covered by handler/CLI tests), a device-code timeout mid-launch (engine resume covered by test), and a gateway restart mid-sign-in.

Screenshots / video

Captured with scripted Playwright against an isolated gateway built from this branch (instances.enabled=true seeded; the launching host is an Identity Center user, so Company SSO is preselected — the start URL shown is a typed placeholder, not a real portal). Files under temp-screenshots/cloud-idp/, pinned to this commit.

Company SSO preselected from the host's identity; region missing → Launch gated with the identity message:

Company SSO selected, Identity Center region empty, Launch disabled: "Enter the Identity Center start URL and region to launch."

Builder ID override — the Identity Center fields collapse:

Builder ID selected; start URL and region inputs hidden; Launch gated only on the AWS prerequisites

Company SSO complete (region entered — identity message clears)

Company SSO with start URL and region filled; the identity gating message is gone

Related Issues

Refs #3221 (closed by #6650; reopen requested there — this PR is the deferred managed-flow remainder). Refs #6650.

Pattern harvest

Rule candidate: review-prompt
Pattern: an authentication/identity target is threaded through one entry point (cloud login) but omitted from sibling orchestration and resume paths that reach the same remote command — check every caller of the sign-in primitive, and prefer a required structured type over optional string triples so the omission is a type error.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

@jeeshofone
jeeshofone requested review from a team and patrigao September 10, 2026 02:50
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Sep 10, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — 🟡 CONCERNS

Design-level review of 4848141d2b36266dca49cce44092309eca7c9545 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Sound durable-identity design, but it rewrites login-flow behavior the owning cloud.md spec still describes the old way, and the pty driver rests on one observed kiro-cli version.

Watch

docs/system-specs/modules/cloud.md is not updated, though it owns what this PR changes: it still says start_device_login falls back to the social-callback flow (now never, for pinned targets), inventories the on-box /tmp artifacts as "login log + FIFO" (the pty driver dir is new), and lists the cloud test files (missing test_cloud_login_target.py). AGENTS.md requires the spec update in the same commit; a stale security-behavior spec misleads the next change to login.py.
Clears when: cloud.md covers the pinned no-fallback rule, the pty-driver artifact and its mktemp -d hygiene, and the new test file.

The Identity Center path now depends on driving kiro-cli 2.21.2's undocumented interactive prompts (caret marker, exactly two Enter presses). A future kiro-cli that adds a prompt or drops the caret breaks pinned remote sign-in — fail-loud, but every managed Identity Center launch is down until this repo ships a driver update, with no in-product fallback (fallback is forbidden by design).
Clears when: an upstream issue asks kiro-cli to honor --identity-provider/--region non-interactively (or the driver's prompt handling is verified against the version the instance bootstrap actually installs).

Suggestions

Replace inspect.signature sniffing in _engine_accepts_login_target with an explicit capability attribute on LaunchEngine — a downstream engine using **kwargs or a wrapped begin_signin is silently misclassified as unsupported and refused at preflight.

[DESIGN-REVIEWED] 4848141

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — 🟡 CONCERNS

Premise-level review of 4848141d2b36266dca49cce44092309eca7c9545 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All checks are done: I've read the full diff, the intent file, and verified in the base tree that every remote sign-in call site is covered (wizard, launch engine, CLI — no unfixed siblings; the dashboard signin endpoint only reads the pending prompt), that the remote_provisioners CPP seam documented in platform/interfaces.py makes the versioned-engine shim a derived requirement, and counted consumers for the new surfaces.

First-Principles-Verdict: CONCERNS

The pty driver rests on one author-side reproduction of kiro-cli's prompting, and the failed-whoami refusal makes Builder ID users pay for an Identity Center harm.

What this change ships

Inventory (10 items, capped — engine-protocol versioning, whoami-parse dedup and 12 locale files also ride) — 10 justified

Intent: an IAM Identity Center user launching a managed crew gets their organization's sign-in, verified, instead of the Builder ID portal — a FIX (deferred remainder of #6650, closing #3221).

  1. Managed launches (setup, cloud launch, dashboard) sign the crew in as the inherited/named identity — justified
  2. "Already signed in" now means as that identity; a wrong-but-valid session fails the launch with the logout recovery — justified
  3. Flagless Builder ID launches onto a reused instance holding an IdC/ApiKey session now fail where they reported success — justified
  4. cloud launch gains the three identity flags (shared helper with cloud login) plus --no-inherit-identity — justified
  5. A local whoami that cannot answer now refuses the launch instead of defaulting to Builder ID — justified
  6. Identity Center remote logins now run under a pty driver that auto-answers kiro-cli's prompts — justified
  7. Dashboard launch form gains the identity section; Launch is disabled until the identity is read or the user picks — justified
  8. New GET /api/cloud/identity; POST /api/cloud/launch accepts login_target with a coded 400 — justified
  9. The target persists on the launch job; an unreadable persisted target loads the job as FAILED, never Builder ID — justified
  10. cloud login flags now validated up front; some previously-forwarded values refused (declared deliberate tightening) — justified

Watch

  • The whole Identity Center flow rests on "kiro-cli PROMPTS for the start URL and region even when the flags supply them" and reads them from a TTY — one quoted error reproduction; the fake in test_pty_driver_answers_prefilled_prompts_and_filters_their_echo encodes the premise ("prompts like 2.21.2"), it doesn't verify it. And --license free alone (no Identity Center) also routes through the pty branch (if identity_provider or license_ or idp_region:), a case the reproduction never covered. Clears when: a real-instance login is confirmed on a named kiro-cli version for both the Identity Center and the --license-only shapes.
  • _resolve_login_target turns a whoami that "exited nonzero without printing an identity" into a refusal (exit 2) on cloud launch and kirocrew setup — a Builder ID user with an expired local session previously launched fine and now needs --no-inherit-identity. Deliberate, but the population paying is not the one harmed. Clears when: confirmed that an expired-session kiro-cli whoami --format json still prints the identity JSON, so the refusal only hits a whoami that reports nothing.

Subtractions

  • Fold remote_identity() into remote_identity_state() in cloud/login.py — 1 real consumer (grep remote_identity(: only remote_identity_state calls it outside tests); one public name fewer on the module.

[FIRST-PRINCIPLES-REVIEWED] 4848141

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5, fork) — 🟡 CONCERNS

UX-level review of 4848141d2b36266dca49cce44092309eca7c9545 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

I have everything I need. The frontend adds a "Kiro sign-in for the crew" section (two radios, two conditional inputs, six gate/notice strings); the CLI/wizard copy asserts state and names exact recovery commands throughout. The three screenshots are hosted on the author's fork (raw.githubusercontent.com), not as GitHub user-attachments, so the workflow downloaded nothing and the sandbox blocks fetching them — none could be opened, and this fork lane has no blind read. One material finding: aria-invalid has no visible styling or error text anywhere in this codebase, so a format-invalid start URL or region looks identical to a valid one while the footer says "Enter the… start URL and region," which reads as "missing."

UX-Verdict: CONCERNS

Sound copy and gating, but no screenshot could be opened (fork-hosted, not attachments) and an invalid start URL/region gives zero visible field feedback.

Watch

  • Invalid vs. missing is indistinguishable: the inputs set only aria-invalid (no visible error text, and nothing in this codebase styles [aria-invalid]), so a filled-but-invalid region ("US-EAST-1", "useast1") or start URL with a query string shows no field signal while the gate says "Enter the Identity Center start URL and region to launch." — the user re-reads two filled fields against a message claiming they're empty. Hits every format typo, moderate stall, persists until guessed. Fix: render field-level error text like ConnectionsPage.tsx:1026's role="alert" pattern, and lowercase the region before validating.

Evidence gaps

  • All three screenshots are raw.githubusercontent.com fork links, not PR attachments — the workflow downloaded none, so every control in the "Kiro sign-in for the crew" section (radios, start URL/region inputs, gate messages) is unverified; re-attach the PNGs to the PR description or push the branch here for the blind read.
  • No screenshot (even as claimed) shows the lookup-failed/unknown notices with both radios unchecked, or the "Reading this computer's Kiro sign-in…" pending gate — capture one of each.

Suggestions

  • While identityQuery is pending, Builder ID renders checked beside "Reading this computer's Kiro sign-in to preselect an identity…" and can visibly jump to Company SSO when discovery lands; include identityQuery.isPending in the identityRadioShown condition so no radio shows checked until the read answers.
  • Unify "Choose the crew's Kiro identity to launch." with the section's vocabulary ("Kiro sign-in for the crew") — one term, "Kiro sign-in", across the gate strings.

[UX-REVIEWED] 4848141

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review (fork) — ✅ no blocking findings

Reviewed 4848141d2b36266dca49cce44092309eca7c9545 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 4848141

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed 4848141d2b36266dca49cce44092309eca7c9545 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 4848141

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 10, 2026
@jeeshofone
jeeshofone force-pushed the fix/cloud-managed-idp branch from 776da9e to da0255c Compare September 10, 2026 04:02
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention labels Sep 10, 2026
@jeeshofone
jeeshofone force-pushed the fix/cloud-managed-idp branch 2 times, most recently from 5fb46d3 to f736bdf Compare September 10, 2026 22:59
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Sep 10, 2026
@jeeshofone
jeeshofone force-pushed the fix/cloud-managed-idp branch 3 times, most recently from 7795f2b to b40c593 Compare September 11, 2026 01:46
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Review disposition (head b40c593d7)

Four upheld findings accepted and fixed; the fifth is the adjudicator's FLAG for a maintainer.

F2 (predictable /tmp driver path, non-atomic write as ec2-user) — accepted, fixed. The pty driver is no longer written to a fixed path. The launcher creates a fresh directory with mktemp -d "${TMPDIR:-/tmp}/kirocrew-login-pty.XXXXXXXX" (0700, unpredictable name, owned by the launching user), writes driver.py inside it, and aborts — printing __KIRO_LOGIN_DRIVER_SETUP_FAILED__ and starting nothing — if either the directory or the write fails, instead of executing whatever sits at a guessable path. start_device_login reports that sentinel by name ("could not stage the sign-in driver in a private temporary directory…"). The directory is removed by the driver's parent shell when the login process exits. Tests: the launcher shape (mktemp -d, no fixed path, two sentinel exits, umask 077 first, reap on exit) and the by-name report.

F3 (parts.port raises bare ValueError → 500 / CLI traceback) — accepted, fixed. normalize_start_url wraps urlsplit and the .port access; any ValueError becomes LoginTargetError("start URL is not a valid URL"), so the handler's 400 invalid_login_target and the CLI's exit-2 path see one refusal for the whole malformed class. Test: :abc port and an unbalanced IPv6 bracket added to the rejected-shapes parametrisation (now 17 shapes).

F4 (identity query failure is silent) — accepted, fixed. identityQuery.isError renders an inline ErrorNotice above the identity radios with the failure detail. The hand-off is deliberately off, with the reasoning in a code comment: the only consequence of this failure is that the launching computer's identity could not be read to preselect the radios — the form is fully usable and the user picks the target by hand — and a hand-off to chat would unmount the form mid-launch for a non-blocking error. New string identity_lookup_failed (en + en-XA regenerated). Test: rejected cloudIdentity → notice with the cause, no "Ask the agent" button, Builder ID default, launch still submits.

F5 (feature map) — accepted, fixed. The Cloud launch row now describes the identity target, lists cloud/login_target.py + cloud/login.py under Handler, and adds login_target on POST /api/cloud/launch plus GET /api/cloud/identity to Endpoints.

F1 (default target adopts an existing Identity Center session) — FLAGGED by the adjudicator; maintainer decision. This is the documented _STRICT_DEFAULT_IDENTITY = False choice: with no identity pinned, any valid session counts, exactly as before this PR, so existing Builder-ID launches onto reused instances do not start refusing. The strict alternative is a one-line flip and the mismatch path it would take is already implemented and live-verified (cloud logout && cloud login … instructions). I've left the default lenient for backward compatibility; happy to flip it if the maintainers prefer strict-by-default.

Floor on the head: 595 cloud tests, 44 panel tests, black / flake8 / isort / mypy / diff-scoped comment-history / docs lint / tsc / i18n-check all green. Screenshot URLs re-pinned to this SHA.

@jeeshofone
jeeshofone force-pushed the fix/cloud-managed-idp branch from b40c593 to 1719902 Compare September 11, 2026 02:41
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Review disposition (head 171990244)

F2 (ErrorNotice lacks the no-hand-off marker) — accepted, fixed. The decision now uses the repo's {/* No hand-off: … */} JSX marker form (as in RegistryManager.tsx), naming the unsaved Identity Center start-URL and region draft the hand-off would discard. Behaviour unchanged; 44 panel tests, tsc, i18n-check green.

F1 (default target adopts an existing Identity Center session) — FLAGGED again by the adjudicator, maintainer decision. Unchanged from the previous disposition: the documented lenient default (_STRICT_DEFAULT_IDENTITY = False) keeps existing Builder-ID launches on reused instances working; strict-by-default is a one-line flip whose mismatch path is already implemented and live-verified. I will flip it on a maintainer's word.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

**On 825f33436: F1 (malformed login_target type returns a coded 400 without an SEL launch_create/denied event) is FLAGGED, not upheld — the adjudication itself calls it a consistent, no-state-change gap a writer may accept, and the neighbouring structural rejections in the same handler (invalid JSON, non-object body) carry no audit line either. Holding rather than pushing for it: adding the one _audit line is trivial, but auditing one structural rejection and not its siblings would be less consistent than the current shape, and auditing all of them is a handler-wide convention decision for the maintainers. Happy to do either on request.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Correcting my note above — I had the consistency argument backwards. The validation branch that rejects a login_target with the very same code (invalid_login_target, a few lines below) already emits _audit("launch_create", "denied", …); only the type-check branch for the same code did not. Two rejections with one code and two audit behaviours is the inconsistency, not the fix. 825f33436 → 5585f7ee7: the type-check branch now emits the same denied event (error="invalid login target: not an object"). The generic body-shape rejections (invalid JSON, non-object body) stay as they are — a different code, and a handler-wide convention I still leave to the maintainers. The existing parametrized invalid-target test now asserts exactly one launch_create/denied audit event for every case; it fails on the previous head for the not-an-object case only. 722 across the cloud suites; gates green.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

5585f7ee7 → 403701045. F1 (UPHELD → fixed): the sign-in step's else branch — reached when both identity probes were transiently unknown and start_device_login was attempted — closed the prompt and warned generically even when kiro-cli had refused the login over a live session for the WRONG identity (prompt.identity_mismatch). That is a verified mismatch by another route, and it was not recorded, so an operational recheck that was also unknown read the launch down to an exit-0 "not signed in" warning. The branch now sets mismatch_seen, names the wrong-identity condition and prints the target's recovery command, exactly as the probe branch does. Test: both probes answer unknown, the sign-in attempt returns identity_mismatch=True; the launch exits 1 with the recovery, registers and connects (the recovery needs both), and never says "is live on AWS" — fails on the previous head with rc 0. 723 across the cloud suites; isort/flake8/mypy, black (baseline-aware), comment-history gates green.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Status on 403701045: both review lanes green. The one red check, Backend Tests (macOS) (1), is the intermittent test_concurrent_provisioning_is_serialized_by_the_deps_lock failure that also hit main's 19:03 UTC run and two other fork PRs this evening — filed as #10425; this PR does not touch apps/. Remaining structural blocker is the fork workflow-change guard (.github/black-baseline.txt prune), which needs the allow-fork-workflow-change label.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

@iamwhatever — could a maintainer add allow-fork-workflow-change here? The fork workflow-change guard is the only red that is not a known main-side flake: this PR's sole .github/ change is removing entries from .github/black-baseline.txt for files it makes black-clean (the baseline gate itself demands the prune — check_black_formatting.py fails with "graduated entries to prune" otherwise). No workflow file is touched. Both review lanes are green on the current head.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

403701045 → 365532478 — rebase onto main at 0c1ddc0aa, no code change. Two effects:

726 across the cloud families; isort/flake8/mypy, black (baseline-aware), comment-history, brand and ACP-boundary gates green. Frontend untouched since the last full vitest run.

A managed EC2 crew launched through `kirocrew setup`, `kirocrew cloud
launch` or the dashboard's Remote Crew form signed kiro-cli in with a bare
`login --use-device-flow`: an IAM Identity Center (Pro) user was shown the
Builder ID portal, and because the pre-login check was a boolean, a valid
session for the WRONG account read as success. kirodotdev#6650 threaded the identity
flags through the standalone `cloud login` only and recorded the managed
paths as deferred.

The login identity is now a durable property of the launch, not a flag on
whichever `kiro-cli login` happens to run. One validated type,
`KiroLoginTarget`, is carried by every sign-in entry point:

- cloud/login_target.py: the model (https://<org>.awsapps.com/start only,
  region shape, free|pro; empty = Builder ID, byte-for-byte the old
  behaviour), shared whoami parsing, local identity discovery, matching.
- cloud/login.py: is_logged_in(target=) means "as that identity"; remote
  whoami classifies match/mismatch/absent/unknown; start, resume and wait
  all take the target; an identity-pinned attempt never falls back to the
  social flow.
- All nine managed call sites carry it (wizard x5, launch engine start AND
  resume, cli_cloud login x2); a mismatch is reported with the logout/login
  commands, never adopted.
- LaunchJob persists it (legacy files load as Builder ID); the runner
  versions LaunchEngine.begin_signin so an older provisioner keeps working
  for the default target and fails loud for a non-default one.
- POST /api/cloud/launch validates login_target at the owner boundary;
  GET /api/cloud/identity suggests the inherited target; the Remote Crew
  form gains the identity section with the Identity Center region named
  as distinct from the EC2 region.
- cloud launch shares cloud login's three flags plus --no-inherit-identity;
  setup inherits by default; an inherited target missing its region is
  completed before provisioning or refused under --yes.

Refs kirodotdev#3221, kirodotdev#6650.
@jeeshofone

Copy link
Copy Markdown
Contributor Author

365532478 → 4848141d2. UX Review's blocker and both Watch items taken; frontend only.

  • Two causes, two notices. identity_unknown is replaced by identity_unknown_no_answer (whoami did not answer; identity is null) and identity_unknown_no_portal (an Identity Center sign-in was read without its portal address; identity.account_type === 'IamIdentityCenter'). The render site picks by the server's own distinction, so an Identity Center user is told they are one and pointed at the Identity Center radio + start URL + region.
  • No radio pre-checked while unknown. In the unknown and lookup-failed states neither radio renders checked until the user clicks one (identityRadioShown); a read identity, or the user's own choice, shows the selection. The "Preselected from this computer's Kiro sign-in" hint is likewise shown only for a read Identity Center identity.
  • No raw exception text. identity_lookup_failed is a fixed human sentence; the {{detail}} interpolation of error.message is gone.
  • Suggestion taken: identity_resolving ends "… or choose one below."
  • All four strings in the 12 catalogs plus the regenerated pseudolocale; DNT gate green.

Tests: the lookup-failure test now asserts the short cause, no raw message, and both radios unchecked until the click; new names the Identity Center cause when the sign-in was read but its portal was not covers the second cause, the unchecked radios and the absent inherited hint. Full frontend suite 2082 files / 33,250 tests green; tsc -b, lint, comment-history and brand gates green; no .github/ diff.

Evidence gap I cannot close from here: the screenshots are fork-hosted because a fork PR body cannot attach user-attachments through the API; a maintainer viewing the PR page sees them inline. Captions describe the section, the unknown notice and the failed-launch mismatch step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants