Skip to content

feat: remote crew sign-in via Crew's vault on the KAS bundle route - #23657

Merged
CrysisDeu merged 1 commit into
mainfrom
feat/kas-bundle-remote-signin
Oct 26, 2026
Merged

CrysisDeu merged 1 commit into
mainfrom
feat/kas-bundle-remote-signin

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A remote crew (an EC2 instance signed in by kirocrew cloud login, or the aws_control crew container) that runs the KAS bundle route can be signed in, show who it is signed in as, and sign out through Crew's own vault, with no kiro-cli on the remote machine, while every other route keeps its kiro-cli sign-in exactly as before.

On the KAS bundle route (agent.acp_backend: kas with agent.kas_bundle: true) the engine's only credential is Crew's own vault and kiro-cli is not installed (#21843). Two remote sign-in surfaces still drove kiro-cli on the remote machine:

  • kirocrew cloud login|logout and the launch wizard ran kiro-cli login, kiro-cli whoami --format json and kiro-cli logout on the instance over SSM. On a bundle-route instance every one of those is "command not found": the box cannot be signed in, its identity cannot be read, and the launching machine's own identity (discover_local_identity) also came from kiro-cli whoami.
  • The aws_control crew container's supervisor wrote a sentinel row into kiro-cli's login store and asked kiro-cli whoami to accept it before every start. On a bundle-route task there is no kiro-cli to ask, so the task refuses to start.

Why it matters

The bundle route is the no-kiro-cli install that lets the desktop app drop the bundled kiro-cli-chat (#21843). Until a remote crew can sign in through the vault, turning the route on by default would leave every cloud instance and every crew container with a chat backend nobody can sign in. The relay route must keep working unchanged, because that is what every remote crew runs today.

Not a goal

What changed (motivation → approach → change)

The local kirocrew cloud command cannot read the remote config (it lives in the instance's config.json), so the box decides which program owns the sign-in.

New verbs kirocrew kas login | whoami | logout | route (cli_kas_login.py) drive the existing KasLoginService from a shell in kiro-cli's vocabulary: login prints Open <URL> and code: XXXX-XXXX, polls until approved, exits 0 once the vault holds the credential (already signed in over a usable identity); whoami --format json prints the kiro-cli whoami document (accountType, startUrl; never a token or e-mail), exit 1 when signed out; logout empties the vault; route prints kas-bundle or kiro-cli, and reports an unreadable config as an error (exit 1), never as kiro-cli.

Every remote script in cloud/login.py splices in cloud/login_vault.py's prelude, which runs the box's own kirocrew kas route. Only the exact answer kas-bundle takes the vault branch; any other answer runs the kiro-cli commands the scripts always ran. A box with neither program (no kiro-cli, probe not kas-bundle) gets a plain-language refusal with the probe's own error and the remedy, not kiro-cli: command not found. Both branches share one log, capture loop and parsers; a failed vault sign-in never degrades into kiro-cli's callback flow; cancel and replace stop both patterns; the vault logout kills no engine process (the pre-turn identity-change check retires them).

An OIDC sign-in records its start URL on the token and every refresh keeps it, so an Identity Center vault identity matches its organisation for the life of the sign-in. whoami/login treat a refresh-rejected slot as signed out, as doctor and the card do. Because kas logout is a second process over the gateway's vault, the store carries a sign-out generation under a store-wide flock: every sign-out bumps it, every login compares it before it saves (and its account-switch deletions) under the same lock; the poll handler answers that refusal as the begin's 409. discover_local_identity reads the launching machine's vault on the bundle route. The accountType mapping in auth/whoami.py duplicates #23615's; collapsing them is #23856. The bundle-route predicate's single spelling across the codebase is #23858.

The container supervisor decides after write_backend_config: on the bundle route it skips the kiro-cli store seed (the gateway's readiness gate names a missing engine per turn); elsewhere the seed runs as before.

Wiring and wording: cli_kas.py mounts the verbs; cli_parser_gateway.py lists them; cli_cloud.py, cli_parser_admin.py, cloud/wizard.py say "Kiro" instead of "kiro-cli"; dashboard/handlers/kas_login.py maps the poll's sign-out code to 409.

Backwards compatibility

Compatible: the kiro-cli route's remote commands are unchanged inside the else branch, a box without the new verb answers empty and takes that branch, kirocrew kas keeps install|status|remove, and KasToken.extra already round-trips unknown keys.

Removes nothing: every path, key and function on main stays; the container's kiro-cli seed still runs on every config that does not turn the bundle route on.

Tests

  • test/test_cli_kas_login.py: the parser; route spells the constant the remote scripts compare against; whoami exit codes and a JSON that parses through parse_whoami_output; logout empties every slot; login prints a prompt parse_login_output reads, forwards IdC start URL and region, answers already signed in over a usable identity, names a lapsed slot as the one it replaces, and reports expiry / store failure with exit 1. The login service is faked at its class seam.
  • test/test_cloud_login_vault.py: every remote script asks the box for its route, the vault verb is the if branch and the kiro-cli verb the else, the vault launch is one shape per target with shell-quoted flags, the callback script refuses on the vault route, cancel/replace stop both patterns; the local side reads a vault prompt like a kiro-cli one, never falls back to the callback flow on the vault route, and reads a vault whoami document as the remote identity; discover_local_identity on the bundle route. Then the generated scripts run under bash against stub kirocrew/kiro-cli programs, one isolated HOME per route (kas-bundle, kiro-cli, empty), asserting which program the box ran and the shared sentinels; a box with no kiro-cli whose kas route fails produces the readable refusal, and the local side reads it as unknown. kas route on an unreadable config prints the error and exits 1.
  • test/test_kas_login_signout_generation.py: two services over one store (the gateway and a shell): a sign-out in one refuses the other's pending login at persist time with signed_out_during_login and leaves the vault empty; a login with no sign-out in between persists; every sign-out moves the generation; a refresh keeps the recorded start URL; a refresh-rejected slot reads as signed out.
  • test/test_kas_auth_whoami.py: the accountType spelling per slot, the document's parse and target match for Builder ID and Identity Center, no e-mail and no secret in it, resolve_signed_in is the usable predicate, vault_owns_sign_in is positive on both halves, and the service records the start URL on Builder ID and IdC sign-ins.
  • container_tests/test_supervisor_kiro_login.py and test_supervisor_main.py: kas_bundle_route reads the written config and is positive on both halves (unreadable or absent config = relay route); run() seeds kiro-cli's store after the config is written and before the backend, and skips the seed on the bundle route while the backend still starts.

Determinism and side effects: no sleeps, no clocks beyond fixed dates, no ports; the bash tests run foreground scripts only with a controlled HOME/PATH whose first entry shadows kirocrew, kiro-cli, pkill and pgrep with logging stubs, so no real process or store is reached and no background login is started.

Manual verification

  • The generated scripts for check / whoami / device login (Builder ID and IdC) / callback / logout / cancel pass bash -n and were driven end to end against stub kirocrew and kiro-cli programs in three isolated HOMEs: with kas route answering kas-bundle the box ran kirocrew kas whoami, kirocrew kas login [--provider idc --start-url … --region …], kirocrew kas logout and refused the callback flow; answering kiro-cli or nothing, it ran kiro-cli whoami, kiro-cli login --use-device-flow […], kiro-cli login (callback) and kiro-cli logout, with the same sentinels on the local side.
  • kirocrew kas route printed kiro-cli on a default config and kas-bundle with {"agent": {"acp_backend": "kas", "kas_bundle": true}}; kas whoami --format json exited 1 signed out; kas logout was a clean no-op signed out.
  • Live issuer, no credentials: kirocrew kas login --provider builder_id in an isolated KIROCREW_HOME completed RegisterClient and StartDeviceAuthorization against oidc.us-east-1.amazonaws.com and printed the verification URL and user code, then was killed after 20 s with nobody approving. The approval half (CreateToken) needs a human's own Builder ID and was not run; kas-auth.md § Validation status says so.
  • Not run: a real EC2 instance on the bundle route over SSM (needs an instance and a human approval), and a bundle-route crew container (the image ships no engine).

Screenshots / video

N/A — CLI and remote-script change, no dashboard surface.

Related Issues

Part of #21843
Refs #21843 #15373 #23856 #23858

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|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

@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners October 24, 2026 03:47
@CrysisDeu
CrysisDeu requested a review from buluoray October 24, 2026 03:47
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision f0bf3f906368276c66eb8b12d6851aab7f8a3e14 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of f0bf3f906368276c66eb8b12d6851aab7f8a3e14 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the bundle-route box chooses its own sign-in program, the relay route still runs the same kiro-cli commands in the else branch, and no UI surface changed.

Notes

  • kas_bundle_route treats an unreadable config.json as "not the bundle route". On a bundle-route container with no kiro-cli, the seed then fails at startup with a kiro-cli error, not a config error. The remote scripts already report this case as ROUTE_UNKNOWN, and the container could say the same.
  • Sign-out now fails when it cannot write the new sign-out generation (TokenStoreError), where it used to always succeed. Make sure the dashboard's Sign out shows this as a readable failure and not a 500.

[DESIGN-REVIEWED] f0bf3f9

Description read

[DESCRIPTION-READ] 37a539c75056290cb7d15841af906c66fc88d3977207f4d479b81e1cd6e3cf10

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of f0bf3f906368276c66eb8b12d6851aab7f8a3e14 — 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 does not.

First-Principles-Verdict: PASS

Each item fixes a defect on the bundle route, where kiro-cli is not installed. Nothing changes a default. The extra sign-out fence and the duplicated route and account-type spellings are notes.

Notes

  • Item 9 — oversized: the sign-out generation (a new kas/signed-out marker, a store-wide signout.lock, _signout_gen state and a poll 409) exists only because kas logout writes the vault from a second process beside the gateway. Nothing reported the race between a pending dashboard login and a shell logout; it is new state that never goes away. Subtraction: defer the cross-process fence and keep the in-process _epoch guard.
  • Item 4 — duplicate: auth/whoami.py:_ACCOUNT_TYPE_BY_SLOT writes out "BuilderId" and "IamIdentityCenter" again, though cloud/login_target.py:37-38 already defines them as ACCOUNT_TYPE_BUILDER_ID and ACCOUNT_TYPE_IDENTITY_CENTER. Subtraction: import those two constants.
  • Item 4 — second spelling: agent_owns_sign_in is the 4th bundle-route predicate in the package (grep agent.kas_bundle): acp/harness/kas.py:132, kiro_prerequisite_service.py:323, backend_install.py:195). Its docstring says it is "the shape kiro_prerequisite_service._kas_bundle_route uses", but that function reads only kas_bundle. Subtraction: delete that docstring claim.

What this change ships

Inventory (10 items) — 8 justified

Intent: sign a remote crew on the KAS bundle route in and out, and read who it is signed in as, through Crew's vault without kiro-cli. ADDITION.

  1. New kirocrew kas login command (device-code sign-in from a terminal) — justified
  2. New kirocrew kas whoami [--format json] and kirocrew kas logout commands — justified
  3. New kirocrew kas route command, which prints which program owns the sign-in — justified
  4. New auth/whoami.py module: account-type mapping and route predicate — duplicate of cloud/login_target.py constants
  5. cloud login/logout and the launch wizard use the vault on a bundle-route box; the kiro-cli route is unchanged — justified
  6. A box with neither program, or an unreadable config, gets a plain-language refusal — justified
  7. The launching machine's identity is read from its own vault on the bundle route — justified
  8. The container supervisor skips the kiro-cli store seed on the bundle route — justified
  9. Cross-process sign-out fence: a persisted generation marker plus a flock; a refused login gets a 409 — oversized
  10. The Identity Center start URL is stored on the token and kept across refreshes; help text says "Kiro" instead of "kiro-cli" — justified

[FIRST-PRINCIPLES-REVIEWED] f0bf3f9

Description read

[DESCRIPTION-READ] 703262e57ccc643b41400cb7ceda824a4d46aba5e7caaff9a302b51407810563

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed f0bf3f906368276c66eb8b12d6851aab7f8a3e14 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] f0bf3f9

Verdict parsed from the review's SHA-scoped output markers for commit f0bf3f906368276c66eb8b12d6851aab7f8a3e14.

False positive or not applicable? A repository writer can comment:
/ai-review override fable f0bf3f906368276c66eb8b12d6851aab7f8a3e14 false-positive: <reason, 20 to 500 characters>

@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 Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of f0bf3f906368276c66eb8b12d6851aab7f8a3e14 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f0bf3f9

False positive or not applicable? A repository writer can comment:
/ai-review override gpt f0bf3f906368276c66eb8b12d6851aab7f8a3e14 false-positive: <reason, 20 to 500 characters>

@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-remote-signin branch from 3c7bd0c to f08b7eb Compare October 24, 2026 04:13
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 24, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-remote-signin branch from f08b7eb to 77e2887 Compare October 24, 2026 04:31
@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 Oct 24, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-remote-signin branch 2 times, most recently from 2c10142 to aa6be00 Compare October 24, 2026 05:13
@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 Oct 24, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-remote-signin branch from aa6be00 to 16dbdc6 Compare October 24, 2026 06:17
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 24, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-remote-signin branch from 16dbdc6 to d7c215f Compare October 24, 2026 07:22
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 24, 2026
@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 Oct 24, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-remote-signin branch from fb4a2dc to a1942e2 Compare October 24, 2026 23:45
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 24, 2026
On the KAS bundle route (agent.acp_backend kas with agent.kas_bundle on)
the engine's only credential is Crew's own vault and kiro-cli is not
installed, yet two remote sign-in surfaces still drove kiro-cli on the
remote machine: the cloud instance sign-in over SSM and the aws_control
crew container's kiro-cli store seed.

The box now decides which program owns the sign-in. New verbs
`kirocrew kas login | whoami | logout | route` drive KasLoginService
from a shell in kiro-cli's own vocabulary (the device prompt lines, the
`whoami --format json` document, the exit codes), and every remote
script `kirocrew cloud login|logout` runs asks the box's `kirocrew kas
route` before choosing its branch; only the exact answer `kas-bundle`
takes the vault verbs, every other answer (an older Kiro Crew included)
runs the kiro-cli commands it always ran. The local reading of an
identity shares one parser for both, and an OIDC sign-in records its
start URL so an Identity Center vault identity can be matched to its
organisation. The launching machine's own identity is read from its
vault when it runs the bundle route.

The container supervisor decides after writing the backend config:
on the bundle route it skips kiro-cli's sentinel store seed and
requires the installed engine instead; elsewhere the seed runs as
before. Builder ID device authorization through the vault was run
against the live issuer up to the device prompt; the approval half
needs a human and is recorded as not yet validated.

Refs #21843
@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-remote-signin branch from a1942e2 to f0bf3f9 Compare October 25, 2026 00:43
@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 Oct 25, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 25, 2026
@CrysisDeu
CrysisDeu requested a review from iamwhatever October 25, 2026 01:48
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

@iamwhatever re-review requested for head f0bf3f9: PR Readiness passed, Design / First Principles / GPT / Opus all PASS; every r124 ask is addressed above (issue #23856 linked; kas route failure readable and an unknown route refused before either program; require_bundled_engine removed; the predicate-consolidation issue link still pending the #23618 worker's comment). The one red is the macOS on-demand shard 1, logged as flake #23862 (not this PR's code).

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Reply to the First Principles note on the third spelling of the bundle-route predicate (auth/whoami.vault_owns_sign_in, now agent_owns_sign_in): the one consolidation issue covering every copy is #23858, opened by the #23618 worker ("one predicate for 'is the KAS bundle route on'"). This PR adds no second issue for it; the in-process spelling here is already one function (agent_owns_sign_in) that #23858 can fold onto the shared one.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Oct 25, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Hold for maintainer review. Reviewed at f0bf3f906368276c66eb8b12d6851aab7f8a3e14.

The r124 asks are met. #23856 tracks the accountType collapse and #23858 tracks the bundle-route predicate, and both issues cover what the description defers. I found no defect in the credential paths I read. A login compares the sign-out generation and saves under the store-wide lock that sign-out holds across its deletes and bump. An unreadable marker refuses the login rather than allowing it.

This PR changes sign-in, sign-out, credential storage and the container's sign-in program, and it adds a pkill on the instance. A maintainer gives the final sign-off.

Three notes on this head have no reply yet:

  • Design 1. The container route check reads an unreadable config.json as the relay route, so a bundle-route task fails with a kiro-cli error instead of a config error. Say why that is acceptable, or report it the way the remote scripts' ROUTE_UNKNOWN does.
  • Design 2. Sign-out can now fail on the generation write. The logout handler already returns a coded logout_failed, so a one-line reply saying so is enough.
  • First Principles item 4. The agent_owns_sign_in docstring says it matches kiro_prerequisite_service._kas_bundle_route, which reads only kas_bundle. Drop the claim or reply.

The red macOS Tests (on demand) shard 1 fails only test_acp_elicitation_runtime.py, a main defect fixed by #23870. A rebase should clear it.

— crew-pr-reviewer (r125)

@CrysisDeu
CrysisDeu merged commit d199f30 into main Oct 26, 2026
131 of 134 checks passed
@CrysisDeu
CrysisDeu deleted the feat/kas-bundle-remote-signin branch October 26, 2026 08:47
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants