feat: name the signed-in account from Crew's vault on the KAS route
Problem / Motivation
Goal: On the KAS route, when Crew's own Kiro sign-in is the account the agent runs as, the dashboard names that account and fills the credit meter without ever asking kiro-cli.
Today the account modal on a Crew sign-in shows a blank identity: the vault credit reading carries no account_type, so there is no provider badge. On the bundle route (agent.kas_bundle) with no sign-in, the credit pill gets a 503 from the kiro-cli readiness gate instead of "sign in". And fetch_local_identity, the dashboard's one identity door, always runs kiro-cli whoami: on a host without kiro-cli it has nothing to answer, and on a host with it, it names kiro-cli's login, which is not the account the sessions run as.
Why it matters
The bundle route is the no-kiro-cli install (#21843). A user who signs in through Settings → Agent Harness → Kiro sign-in should see who they are and how many credits they have. Showing nothing, or a 503, reads as "sign-in did not work". Naming kiro-cli's login beside a Crew sign-in would label one account's balance with another account's name.
Not a goal
- The
kirocrew doctorwhoami row andcloud/login_target.py(other items under #21843). - Showing an e-mail for a Crew sign-in: the vault stores none. Only the kind of sign-in (Builder ID, Identity Center, company SSO, Google, GitHub) is shown.
- Any change to the kiro-cli route: it keeps
kiro-cli whoamiand the whoami bracketing exactly as before. - Any frontend change: the account modal already renders
account_type.
What changed (motivation → approach → change)
The vault is the harness's credential in two cases: the KAS bundle route always (the engine's token callback reaches Crew alone), and the KAS relay route when the vault holds a usable identity (the spawn's own vault_holds_identity question). _vault_owns_usage_sync in handlers/sessions.py now says yes for both, where before it asked the vault even on the bundle route. That one verdict routes three things:
| Surface | Before | Now |
|---|---|---|
| Credit reading (vault path) | numbers only | numbers plus account_type from the vault's own claims |
| Bundle route, signed out | kiro-cli readiness gate → 503 | signin_required from the vault path, no kiro-cli |
fetch_local_identity | always kiro-cli whoami | vault fields when the vault owns the credential; {} when signed out |
The label is built by a new handlers/kiro_vault_identity.py: the vault's store slot and provider class map onto the accountType vocabulary kiro-cli whoami prints (BuilderId, IamIdentityCenter, ExternalIdP, SocialGoogle, SocialGithub — the social kind keeps the vault's one-capital provider spelling, since the badge splits a humanized name at an inner capital), so the account modal's existing provider badge works with nothing new in the frontend. auth/bridge.py gains vault_identity_claims, one vault read that returns the identity fingerprint and those two token-free claims together; vault_identity_fingerprint reads through it. _refresh_from_vault takes its after-fingerprint from that same read, so once it matches the before-fingerprint the label describes the account the credential was read for, mirroring how the kiro-cli path labels from the whoami adjacent to the publish. kiro_usage_api.fetch_usage_limits_with_credential is unchanged: it resolves the profile from the stored ARN or the token's own ListAvailableProfiles answer and never consults whoami.
Specs updated: learn-cron-dashboard.md (GET /api/sessions/usage, the sessions facade), kas-auth.md (vault consumers), and the feature map's credit-balance row.
Backwards compatibility
Compatible: the kiro-cli route and every non-KAS harness take exactly the path they took; the vault path adds one key (account_type) the frontend already reads and the relay route's verdict is unchanged.
Removes nothing: no key, route, function or behaviour is removed or tightened; vault_identity_fingerprint keeps its signature and values.
Tests
test/test_kiro_vault_identity.py(new): every store slot maps to its whoamiaccountType;identity_fieldsnever emits an emptyemail/start_url;vault_identity_claimsover a realTokenStorereturns the fingerprint and token-free claims from one read,("", {})for an empty or unreadable vault; the off-loop snapshot agrees.test/test_usage_crew_vault.py: the vault reading is labelledSocialGooglewith noemail; the bundle route owns usage whatever the vault holds andkas_bundlegrants nothing on the kiro-cli harness;fetch_local_identityanswers from the vault with no kiro-cli resolved, returns{}when signed out, and keepskiro-cli whoamiwhen the vault does not own the credential. The vault seam patch moves fromvault_identity_fingerprinttovault_identity_claims(the one read both now share).
Manual verification
Isolated gateway from this worktree: fresh HOME, own KIROCREW_HOME, PATH without kiro-cli (no kiro-cli resolvable), kirocrew kas install done, agent.acp_backend=kas, agent.kas_bundle=true.
Signed out: GET /api/kas-login → authenticated: false; GET /api/sessions/usage → 200 {"usage": {"available": false, "reason": "signin_required"}} (not the 503 kiro_prerequisite_required main answers here); GET /api/cloud/identity → {"discovery": "read", "identity": {}}; gateway.log and security_events.jsonl contain no whoami.
Signed in through Settings → Agent Harness → Kiro sign-in: pending a human sign-in on that gateway (recorded in a PR comment when done).
Screenshots / video
Why no screenshot: no frontend file changes; the account modal renders the account_type the gateway now sends through its existing provider badge.
Related Issues
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