Skip to content

fix(usage): show an account-type-only sign-in without another user's balance - #17784

Closed
jeeshofone wants to merge 1 commit into
kirodotdev:mainfrom
jeeshofone:fix/17710-externalidp-identity
Closed

jeeshofone wants to merge 1 commit into
kirodotdev:mainfrom
jeeshofone:fix/17710-externalidp-identity

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: An account whose kiro-cli whoami reports only an account type shows the provider it signed in with in the Kiro Account modal, and is told plainly that its balance is not available, never showing a balance that may belong to another user.

On an external identity provider sign-in, kiro-cli whoami --format json answers {"accountType":"ExternalIdP","email":""}: no email, no startUrl, no Profile: ARN. Today every reading is discarded as unproven, so the modal shows "Credit usage unavailable" forever and hides the provider.

Why it matters

Every such account sees a dead end.

What changed (motivation → approach → change)

ExternalIdP accounts with no per-user claim show no balance. #17710 is fixed for identity display: the provider is shown and the state explained. A balance follows once a per-user field is shown to exist (asked on #17710).

_fetch_usage_bg (dashboard/handlers/sessions.py) gains one early return, next to the existing API-key one. When the top-of-refresh whoami reports the ExternalIdP account type and no email, start URL or profile ARN (_account_type_only), the refresh publishes {available:false, reason:"account_unproven"} plus that whoami's identity fields, and stops. No earlier reading is kept and no scrape number is read. The API call still runs, for its auth_state only (its reading is never published). signin_required needs evidence the sign-in is broken: rejected (a 401) alone, or no_credential corroborated by one /usage scrape run for its outcome only (a plan → account_unproven, no plan or a parked scrape → signin_required; it feeds the back-off as usual). no_credential alone is not proof. A timeout or error in this branch leaves the same account_unproven marker while the adjacent whoami is still this shape. A corroborating scrape that parks the scrape returns the parked marker to its caller, as the ordinary path does. The degraded-API WARN now says only that the API returned no reading, true on every path. Every other shape takes the existing path.

Scope of the gate: ExternalIdP only. A type-only Builder ID or Identity Center whoami has lapsed; it takes the existing path and ends as signin_required (TestOtherTypesKeepTheirRemedy).

Why no reading is published for this shape. Only per-user claims (sub, user id, email, account id) can prove continuity. Under the existing claim allowlist, what kiro-cli stores for this sign-in is client_id and scopes, and both belong to the IdP registration that every user of it shares. A switch from user A to user B of one registration leaves them identical. The previous head digested them anyway and could publish A's balance under B. TestASwitchWithinOneRegistration reproduces it on a real SQLite store.

Why not decode the token's sub? It digests secret material through a second auth-store reader.

account_unproven UI. An account configuration (like API-key auth), not a failed read. The modal shows "Signed in with Company SSO" above a passive info notice, "Credit balance isn't shown for this Company SSO sign-in, because kiro-cli doesn't report which user is signed in.", with no Refresh. The copy states only the cause _account_type_only checks. The pill shows the muted dash plus an info mark, labelled "Kiro credit usage — balance isn't available for this sign-in" (no provider named). Two new keys, in every catalog plus en-XA. The badge's provider label now reads Company SSO for every ExternalIdP sign-in, including ones that publish a reading (main showed the humanized id "External Id P"), because that is the sign-in flow's own name for it.

providerLabelFromWire moved from KasLoginGate.tsx to components/kasProviderLabel.ts for the modal.

Reader: _fetch_usage_bg calls _account_type_only; KiroAccountModal and kiroUsageSegment read KiroAccountOnly, which carries only accountType.

Not a goal

  • Showing a balance for registration-only external IdP sign-ins. A follow-up adds the per-user field the reporter's row is shown to carry.
  • Changing the usage API branch: it still needs an email, start URL or ARN proven on both sides.
  • Reclassifying the API's HTTP 403.

Backwards compatibility

Every shape that published before still publishes. account_unproven is a new reason; an older client reads it as no reading. fetch_usage_limits keeps its signature; only the degraded WARN's wording changes.

Tests

  • test/test_session_usage_account_type_identity_17710.py drives _fetch_usage_bg with the issue's exact whoami bytes: the API only for auth_state, its reading never published (spied, not just the final cache), the account with no balance; rejected → signin_required with no scrape; no_credential + a working scrape → account_unproven (number unpublished), + a failing scrape → signin_required (back-off counted), + a parked scrape → signin_required with no spawn; an error or a deadline timeout in the branch → account_unproven (the deadline fires only once the hung call is entered), a named adjacent whoami → the ordinary path; every payload published while the scrape runs carries only the marker's keys (a spy on _publish_usage, so a number published and then overwritten still fails); a corroborating scrape that parks reports the park; an email on both sides still publishes; an A → B switch within one registration never publishes; TestOtherTypesKeepTheirRemedy for type-only BuilderId/IamIdentityCenter. Each mutation of these rules turns a test red.
  • KiroAccountModal.test.tsx: account_unproven parses to exactly {accountOnly, accountType} and shows "Signed in with Company SSO" (for ExternalIdP, ExternalIdp, External-IdP) and the notice naming the cause, the Manage account link below it, no Refresh, no alert; the notice names the provider through the badge's own accountProviderLabel; with no type the notice still names Company SSO; a refresh out of failed into it adds no outcome notice. App.creditPillError.test.tsx: the dash plus the info mark, hover text equal to its accessible name.
  • Ran on the final SHA: the PR's test file (33 passed; the timeout test 15/15 in a loop); every test/*usage*.py, test_kiro_usage_api.py and test_spawn_audit.py (708 passed); vitest KiroAccountModal, App.creditPillError, KiroSignInCard, KasLoginGate, i18nGateTable, i18nStrictRule (116 passed); tsc -b, eslint, i18n-check, i18n-strings, pseudolocale (no diff), mypy, black gate, isort, flake8, comment-history, docs-lint, Semgrep 1.78.0 with semgrep/ and the registry packs on changed files (0 on this PR's lines).

Manual verification

Built SPA behind the stub API with the account_unproven payload, light and dark (stills below). The pill's hover text is a native title, asserted in App.creditPillError.test.tsx.

Screenshots / video

account_unproven modal, dark
account_unproven modal, light
top-bar dash and info mark, dark
top-bar dash and info mark, light

Related Issues

Closes #17710

Pattern harvest

Rule candidate: review-prompt
Pattern: an identity gate weighing only optional fields is unsatisfiable for a payload carrying none of them; neither an account type nor a registration-level claim (an OAuth client id) is per-user continuity.

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

@jeeshofone
jeeshofone requested a review from a team as a code owner October 7, 2026 15:58
@jeeshofone
jeeshofone requested a review from bolichen97 October 7, 2026 15:58
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 7, 2026
@jeeshofone
jeeshofone force-pushed the fix/17710-externalidp-identity branch from 4121e8c to e78e8cc Compare October 7, 2026 17:23
@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 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 7e233a23fc629199df70c814381c540b04b104a4 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.

First-Principles-Verdict: PASS

Check one thing: a credit reading that has an account type but no email or account name now shows a "Signed in with …" badge instead of "Account details unavailable".

Not justified as shipped

  • Item 4 — undeclared: the description never states this. The diff edits the existing pin keeps the panel useful when structured identity is unavailable to add accountType: undefined, so it keeps passing. The new guard is !named || (!identity && !provider), which affects readings of every account type, not just ExternalIdP ones.

What this change ships

Inventory (8 items) — 6 justified

Intent: let an external identity provider sign-in see which provider it used and get a plain "no balance available" message, never another user's balance. This is a FIX (#17710).

  1. An ExternalIdP whoami with no user fields now ends with a no-balance account_unproven marker instead of a dead end — justified
  2. The account modal shows "Signed in with Company SSO" plus a passive info notice, with no Refresh button — justified
  3. The top-bar pill shows a muted dash plus an info mark, with its own label — justified
  4. A reading with an account type but no name now shows the provider badge instead of "Account details unavailable" — undeclared
  5. An ExternalIdP reading that does carry a name is now labelled "Company SSO" instead of "External Id P" — rides along
  6. When no credential is readable, one /usage scrape run decides between signin_required and account_unproven — justified
  7. A timeout or error in this branch keeps the account_unproven marker — justified
  8. The degraded-API warning now says only that the API returned no reading — justified

[FIRST-PRINCIPLES-REVIEWED] 7e233a2

Description read

[DESCRIPTION-READ] 7c45dab53ce147d3d8b59ad96a880706140df864f830d6157e7a5a087a73f884

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 7, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — 🟡 CONCERNS

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

UX-Verdict: CONCERNS

The Company SSO notice is a permanent dead end with no next step, and no first-time reader has seen the modal or the pill's new info mark.

Watch

  • No way forward from the notice. The new string is "Credit balance isn't shown for this {{provider}} sign-in, because kiro-cli doesn't report which user is signed in." It explains the cause but says nothing about where else to check the balance. attachment-01/02 show only "Manage account" below it, and nothing ties that link to the balance. Every ExternalIdP user meets this on every open, and it never goes away, so the modal teaches them that this surface is useless for checking their balance. Moderate severity: it hits a narrow group of users, but every time. Fix: add a short clause after the cause that points to where the balance can be seen, such as the Kiro account page behind "Manage account".
  • The info mark appears on only one of the permanent no-value pill states. The new branch renders <Coins/> — <Info/>. The 'api-key' state is just as permanent and renders <Coins/> — with no mark (kiroUsageReadout.tsx:137). Users can't learn what the "ⓘ" means, because two permanent states look different for no visible reason. In attachment-03/04 the mark is also faint at opacity-60. Low severity: it's always in the daily chrome but only causes friction. Fix: use the same treatment for both permanent states, either the mark on both or on neither.

Suggestions

  • In the pill's tooltip kiro_credit_usage_sign_in_type, write "isn't available" so it matches the modal's "isn't shown". Using one verb for the same state avoids implying two different causes.

[UX-REVIEWED] 7e233a2

Description read

[DESCRIPTION-READ] 705ccc22a208f78c8f5e05f260dcd6fa6cad02d6166a085561b0d82f21cdbd2b

That sha256 names everything this verdict read: the PR description, plus the 7 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 7, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

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

Design-Verdict: PASS

Check that a working ExternalIdP sign-in with no_credential is fine running the /usage scrape on every refresh just to pick a reason string.

[DESIGN-REVIEWED] 7e233a2

Description read

[DESCRIPTION-READ] be5caeb98fb842c0823b27214faaf3a7af39ea84e26f5b4d6eb33c05f8aab6a8

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 7, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 7e233a2

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

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

Review details

No findings.
[GPT-REVIEWED] 7e233a2

@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 7, 2026
@jeeshofone jeeshofone changed the title fix(usage): publish an account-type-only reading and show its provider fix(usage): show an account-type-only sign-in and tie its reading to the account Oct 7, 2026
@jeeshofone
jeeshofone force-pushed the fix/17710-externalidp-identity branch from e78e8cc to 89c4a0a Compare October 7, 2026 21:47
@jeeshofone

Copy link
Copy Markdown
Contributor Author

ai-review-disposition target=gpt head=89c4a0abbaf2bf87bddb86079ef7eb28d944bc32

F1 sessions.py:1219 (matching provider types do not prove account continuity): fixed on 89c4a0abbaf2bf87bddb86079ef7eb28d944bc32.

A type now publishes nothing on its own. The /usage scrape takes an account fingerprint beside each whoami of its bracket, and _scrape_continuity accepts signed_in only when both fingerprints are present and equal:

  • kiro_usage_api.account_fingerprint() is a SHA-256 over the allowlisted subject fields (account_id, sub, subject, user_id, refresh_token_id and their camelCase forms) of every credential blob in kiro-cli's own auth store, keyed by store key. Token values never enter the digest and nothing about it is logged. A blob with no subject field (alone or beside a named one), an unreadable store or an unrecordable audit returns None. The read has its own audit id, kiro_usage_api.account_fingerprint, registered in _AUDIT_ONLY_READ_IDS.
  • Two present fingerprints that differ refuse the reading, as a switch.
  • A missing fingerprint does not publish the reading as current: the cache becomes {account_type, available: false, reason: "account_unproven"} and nothing of an earlier reading is kept.
  • same (an account-level field proven) is unchanged; the API branch never publishes on signed_in.

Your sequence, ExternalIdP A → ExternalIdP B between the two whoami reads, is test_a_switch_between_two_accounts_of_one_type_is_rejected: same whoami both times, fingerprints differ, cache ends {"available": false}. Run against e78e8cceb, that sequence published A's 10,000-credit reading. Also pinned: an unchanged fingerprint publishes, a fingerprint missing on either side shows the account with no balance, and the _scrape_continuity table.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

ai-review-disposition target=first-principles head=89c4a0abbaf2bf87bddb86079ef7eb28d944bc32

Item 4 (a type change under a matching email refuses the reading): accepted and removed on 89c4a0abbaf2bf87bddb86079ef7eb28d944bc32.

The early _WHOAMI_DIFFERENT return is gone. _whoami_agreement returns signed_in only when no account-level field is carried and both sides report the same non-empty type; two different types with no account-level field land in unproven, and a type change under a matching email is same, both as on main. The test that pinned the ride-along (test_a_type_change_under_a_matching_email_is_still_a_switch) is deleted, and test_two_different_account_types_prove_nothing pins the unproven case. The body's Backwards-compatibility line now says every verdict that published before is unchanged.

The same push adds an account fingerprint check on the signed_in path (the GPT F1 fix). That one is not a ride-along: without it two accounts of one external identity provider are indistinguishable across the scrape, so the fix itself would publish one account's balance under the other.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

ai-review-disposition target=design head=89c4a0abbaf2bf87bddb86079ef7eb28d944bc32

Watch 1 (owning spec no longer matches the code): fixed on 89c4a0abbaf2bf87bddb86079ef7eb28d944bc32. The /api/sessions/usage paragraph of docs/system-specs/modules/learn-cron-dashboard.md now describes signed_in (same type both sides, no account-level field), that it never licenses the API reading, that the scrape publishes on it only with matching account fingerprints (_scrape_continuity, kiro_usage_api.account_fingerprint), the account_unproven marker for a missing fingerprint, and unproven now covering two different types. The type-change-under-a-matching-email rule is removed from the code (First Principles item 4), so the spec does not describe it.

Watch 2 (the "type only while signed in" premise is unverified): resolved by not depending on it. The docstring no longer asserts it. A type alone now publishes nothing: the scrape needs an equal account fingerprint read from kiro-cli's own store on both sides. The spec records the premise as an assumption the rule does not rely on. If a signed-out kiro-cli did print a type, the worst case is the provider pill with no balance.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

ai-review-disposition target=opus head=89c4a0abbaf2bf87bddb86079ef7eb28d944bc32

Advisory, learn-cron-dashboard.md:3598 (spec contradicts the signed_in publish rule): fixed on 89c4a0abbaf2bf87bddb86079ef7eb28d944bc32. The identity-invariant sentence now names signed_in, says it licenses only the scrape and only with matching account fingerprints on both sides of the read, and describes the account_unproven marker. The type-mismatch-is-different rule was removed from the code in the same push (First Principles item 4), so two different types with no account-level field are unproven, which the spec now says.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

ai-review-disposition target=ux head=89c4a0abbaf2bf87bddb86079ef7eb28d944bc32

Watch (the pill is the account's only identity; "IdP" is an unexpanded acronym): holding position, asking a maintainer for the cold read.

The lane names its own smallest fix as a first-time reader checking the pill on a branch in this repository, which a fork author cannot run. The label comes from the account type kiro-cli reports, humanized with acronyms kept whole. Expanding one type would mean a per-provider label and new strings in every catalog, which this PR rules out under Not a goal.

New on 89c4a0abbaf2bf87bddb86079ef7eb28d944bc32: when the reading cannot be tied to the account (no account fingerprint on both sides of the scrape), the modal keeps the same identity block above the existing "No balance reading is available for this account yet." notice and its Refresh, and the pill shows the existing no-reading dash. No new strings. Covered by KiroAccountModal.test.tsx and App.creditPillError.test.tsx. The two committed stills show the published-reading state; the no-balance state has no still of its own (this host could not build the SPA for a capture), and the tests above pin it.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

CI on the previous head e78e8cceb, both outside this diff:

  • Backend Tests (Windows) (5): test_wake_judge_feedback.py::TestJudgeTickReportsWhetherItAsked::test_a_committed_row_keeps_the_join_key_when_sweep_outlives_budget failed with assert None is True. This PR touches no wake-judge code. It is the second sighting I know of on an unrelated diff (the first was a website-only PR on 5 Oct, same shard), and no issue or PR names it. 89c4a0abbaf2bf87bddb86079ef7eb28d944bc32 re-runs it.
  • E2E (stub ACP backend, offline): every spec passed (322 passed, 1 flaky), and the job failed on the zero-retry ceiling because session-tags-e2e.spec.ts "17b. right-click on ANOTHER row while the Tags picker is open" passed only on retry (toBeVisible timed out at 5 s). This PR does not touch session tags or the sidebar menus. No issue or PR names it. 89c4a0abbaf2bf87bddb86079ef7eb28d944bc32 re-runs it.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention 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 readiness: checking Automated validation is still running labels Oct 7, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Watch 1 (two names for one sign-in: the pill says "Company SSO", the notice says "organization sign-ins"): fixed on b34d8e5, with a different wording than the suggestion.

The notice now reads "Balance isn't available for this sign-in." and the pill title "Kiro credit usage — balance isn't available for this sign-in". It points at the provider pill directly above it and names no category, so there is one name on the screen. I did not reuse "Company SSO" in the sentence: that label is the sign-in flow's name for Identity Center sign-ins too, and those do show a balance, so "…for Company SSO sign-ins" would be false for them. All 12 catalogs plus en-XA carry the new wording; the i18n style suite passes with the base ref set. The two modal stills are re-shot at this head, light and dark.

Watch 2 (the pill dash looks like the other dashes): held. The dash is the shared terminal-state glyph, and the modal opened by the same click states the reason. A distinct glyph for one state is a separate design decision for a maintainer.

Suggestion (say where else the balance can be seen): held. Nothing in this change verifies that any surface shows a balance for this sign-in, so naming one would be a guess.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

New head b34d8e5: one commit, rebased onto main 640abeb, no merge conflicts. The only changes since c84e09b are the two lane fixes answered above:

  • KasLoginGate.tsx: the unused KasLoginProvider re-export is removed.
  • The credit notice and the pill title now say "this sign-in" in every catalog plus en-XA; the system spec and KiroAccountModal.test.tsx follow; the two modal stills are re-shot.

Gates run on this head: tsc -b, the website/src/i18n suite (style tests with I18N_BASE_REF=origin/main), KiroAccountModal and App.creditPillError vitest, i18n:check, lint:i18n, and the backend test file for this change. The body was edited before the push.

CI on c84e09b, outside this diff: Backend Tests (3.12, 7) failed on test_mochi_routes.py::...::test_walk_done_restores_after_an_instant_walk (state still "walking" after /walk-done; passes locally with this change), and Backend Tests (3.12, 1) on test_main_ratchet_audit.py::TestConvergenceStaysExempt::test_a_superseded_run_still_collapses_a_split_record (exit 141, SIGPIPE, the family tracked in #13360; passes locally). Coverage Gate fails closed on both. Neither file is in this diff, so no change is made for them here.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Holding on both Watch items on this head. Neither has an author-side change that makes it go away.

  • Pill looks like the other dashes; the hover text is unseen. The title is asserted by App.creditPillError.test.tsx (hover text equals the accessible name). A native title is not drawn by headless Chromium, so a capture of it needs a headed browser, which this change's tooling does not have. The modal opened by the same click states the reason, so the dash is never the only explanation.
  • The notice gives no cause or next step. Naming a cause ("…for Company SSO sign-ins") would be false for the Identity Center sign-ins that carry the same provider label and do show a balance, and "yet" promises a fix nobody has scheduled. The next step this state allows is the "Manage account" link already in the modal. Naming another place to see a balance would be a guess, since nothing here verifies one exists.

A maintainer who wants either changed can say so, and it is a one-string follow-up.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

New head 9acef09, a pure rebase of b34d8e5 onto main 0a47021. git range-diff shows the commit unchanged (=), there were no conflicts, and the diff stat is the same (29 files, +646/-77).

Why it exists: the reds on b34d8e5 were fixed on main after that head was built.

Local gates on this head: tsc -b exit 0, the whole src/i18n suite with I18N_BASE_REF=origin/main (46 files, 768 tests), i18n:check, lint:i18n, the modal, pill and KasLoginGate vitest files (56 tests), and test_session_usage_account_type_identity_17710.py (24 tests).

UX CONCERNS: unchanged, and the answer on this head is the disposition above this one (the one on b34d8e5). Both Watch items are held with evidence. The hover text is covered by App.creditPillError.test.tsx, and a native title is not drawn by headless Chromium. Naming "Company SSO" in the notice would be false for the Identity Center sign-ins that share the provider label and do show a balance. A maintainer who wants either changed can say so, and it is a one-string follow-up.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Disposition for the UX Review CONCERNS on 9acef09, fixed in head 1aecc0b (rebased onto current main, one commit):

  • The notice gives no next step: fixed. The notice now reads "Balance isn't available for this sign-in. Manage account below opens your Kiro account." in every catalog plus en-XA, pointing at the existing Manage account link directly under it. It does not claim that page shows the balance, since that is not verified. KiroAccountModal.test.tsx asserts the notice names the link and the link is rendered.
  • The pill's reason can't be seen without hovering / looks like the other dashes: fixed. The account_unproven pill now shows an info mark instead of the dash the failed, none and api-key states share, so it no longer reads as a failed read; the label and accessible name are unchanged. App.creditPillError.test.tsx asserts the mark and that no dash renders, including when the config read fails.
  • Stills re-shot at this head: temp-screenshots/17784/account-unproven-modal-{light,dark}.png and temp-screenshots/17784/account-unproven-topbar-{light,dark}.png (the old hover stills are removed).

E2E (stub ACP backend, offline) on 9acef09: not this PR. Every spec passed (executed=323 unexpected=0 flaky=0), then Playwright ran 1020s, past the 1020s bound, which is #18185; the same overshoot hit unrelated #11015 (run 38318425772). The PR touches no Playwright spec.

Local on 1aecc0b: pytest test_session_usage_account_type_identity_17710.py 24 passed; vitest KiroAccountModal, App.creditPillError, src/i18n/style/ 171 passed; src/i18n/ + src/shell with I18N_BASE_REF 784 passed; tsc -b clean; i18n:check pass; description check pass.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Disposition for the UX Review CONCERNS on 1aecc0b, head c48a14c:

  • The pill's state is shown only by an icon: taken, using the lane's own smallest fix. The pill now shows the muted dash the sibling no-value pills show, plus the info mark, so it reads as "no value here" and matches its siblings. Label and accessible name are unchanged. App.creditPillError.test.tsx asserts the dash and the mark. Stills re-shot at this head, light and dark: temp-screenshots/17784/account-unproven-topbar-{light,dark}.png and account-unproven-modal-{light,dark}.png.
  • The notice's second sentence only describes the link: held. The lane's fix is conditional ("If the Kiro account page shows the balance, say so"), and nothing verifies that the account page shows a balance for this sign-in type. Saying it does would be a remedy we cannot stand behind. The sentence names the one next step the modal offers. If a maintainer confirms what that page shows for an external identity provider sign-in, the copy can say so in one line.

E2E (stub ACP backend, offline) on 1aecc0b: the same #18185 overshoot as the previous head (executed=323 unexpected=0, Playwright ran 1020s, past the 1020s bound). Not this PR.

Local on c48a14c: vitest App.creditPillError + KiroAccountModal 54 passed; tsc -b clean; eslint clean; comment-history and docs_lint pass; description check pass.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Disposition for the UX Review CONCERNS on c48a14c, head 5982143 (one commit, rebased onto current main):

  • The notice never says why the balance is missing: fixed. The notice now gives the reason before the next step: "Balance isn't available because this sign-in doesn't say which account is signed in. Manage account below opens your Kiro account." That reason is exactly what the gateway checks: this state is published only when whoami names the provider and no email, start URL or profile ARN, so no reading can be tied to the user. It still does not claim the account page shows a balance, which is unverified. Updated in every catalog plus en-XA and in the spec line that quotes it. Modal stills re-shot at this head: temp-screenshots/17784/account-unproven-modal-{light,dark}.png.
  • The pill's info mark looks like its own button: held. The last three UX rounds asked for opposite things on this pill. On 9acef09 the dash read as a failed read, so the dash became an info mark. On 1aecc0b an icon-only state was the concern, and that round's own smallest fix was the sibling dash plus the mark, which is what ships. This round objects to the mark. Removing it brings back the 9acef09 finding, and the lane rates this one low impact because a click anywhere on the pill opens the modal, which states the reason in words. A maintainer call on the pill's final shape would settle it; I am not changing it again without one.

Local on 5982143: pytest test_session_usage_account_type_identity_17710.py 24 passed; vitest src/i18n/, src/shell, KiroAccountModal, App.creditPillError with I18N_BASE_REF 838 passed; i18n:check pass; tsc -b, eslint, bundle-size gate, comment-history gate and docs-lint clean; description check pass.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Dispositions for 5982143, fixed in 8ad75c4 (one commit, rebased onto current main; range-diff = before the fixes).

Design Review Watch, "the sign-in check is skipped too": fixed. The ExternalIdP early return no longer skips fetch_usage_limits. It still runs, for its auth_state only, and its reading is never published. no_credential or rejected now ends as signin_required, so an expired or refused ExternalIdP credential gets "Sign in to Kiro again". Any other outcome (the issue's 403 included) stays account_unproven. The /usage scrape still never runs for this shape. test_a_lapsed_or_refused_credential_keeps_the_signin_remedy (both states) replaces the test that pinned the old result. Dropping the new branch fails both cases. test_a_reading_the_api_returns_is_never_published covers the healthy API answer.

UX Review Watch 1, notice copy explains the mechanism: fixed. The notice now reads "Credit balance isn't shown for this Company SSO sign-in, and signing in again won't change that. Manage account below opens your Kiro account settings in your browser." The provider is interpolated from the badge's own label, so the notice and badge agree. It says a fresh sign-in won't help (true now that a lapsed credential takes the sign-in path above) and says what the link opens. Updated in all 12 catalogs plus en-XA. The modal stills under temp-screenshots/17784/ were re-shot on this head, light and dark.

UX Review Watch 2, no blind read of the top-bar tooltip: held. No author-side change can satisfy it. It asks for a cold read by someone without the diff in mind, and headless Chromium does not draw a native title. App.creditPillError.test.tsx asserts the hover text equals the accessible name. A maintainer is welcome to do that read.

E2E (stub ACP backend, offline): not ours. test_dashboard_playwright_suite hit the 1020 s Playwright bound on a member-memory.spec.ts case. This PR touches no member-memory code. Tracked as #18185 and #18632.

Gates run on 8ad75c4: pytest test_session_usage_account_type_identity_17710.py (27 passed) plus every test file that names the touched modules (41 files, 2816 passed); black gate, isort, flake8, mypy, comment-history, subprocess-encoding, docs_lint; tsc -b, eslint, vitest src/i18n/, src/shell, KiroAccountModal, App.creditPillError with I18N_BASE_REF=origin/main (838 passed); i18n:check.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

SF-1 (no_credential alone produced "Sign in again" with no corroboration): fixed in 06e9fea.

In the ExternalIdP branch, only rejected (GetUsageLimits answered 401) now maps straight to signin_required. For no_credential, the /usage scrape runs once and only its outcome is used, to pick the reason. If it parses a plan, kiro-cli still authenticates and the reason stays account_unproven. If it parses no plan, the reason is signin_required. The scrape's number is never read into the cache. The attempt feeds the scrape back-off as usual, and while the scrape is parked its earlier failures count as the evidence, the same way the ordinary path's parked marker treats them. Every other auth_state stays account_unproven. This is the module's documented rule that no_credential alone is not proof. Running the scrape also lets kiro-cli renew its own store, as it does on main.

To avoid a second spawn path, the scrape's wrap and spawn are factored into two nested helpers (_wrap_scrape_argv, _spawn_scrape) that the ordinary path and this branch share. Reaping, the sandbox cleanup and back-off accounting are unchanged.

Tests in test_session_usage_account_type_identity_17710.py:

  • rejected gives signin_required with no scrape.
  • no_credential with a working scrape gives account_unproven, publishes no number and leaves the failure count at 0.
  • no_credential with a failing scrape gives signin_required and adds 1 to the failure count.
  • no_credential with the scrape parked gives signin_required and spawns nothing.

On 8ad75c4 the working-scrape and failing-scrape cases fail on behaviour. The rejected case keeps 8ad75c4's outcome, so on that head it fails only on the new scrape_fallback kwarg. That test pins the no-scrape path. Mutations, each red: an uncorroborated no_credential mapped to signin_required (2 failed); the scrape outcome ignored (1); rejected treated like no_credential (1); a scrape while parked (1); the back-off not fed (1).

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

SF-2 (PR title described the earlier design): fixed. The title now matches the commit subject: "fix(usage): show an account-type-only sign-in without another user's balance". I changed it together with the body before pushing 06e9fea.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

N-1 (an exception or timeout in the branch left the "no reading yet" state): fixed in 06e9fea.

Both outer handlers (TimeoutError and Exception) now record through one _cache_failure(adjacent). If the refresh took the account-type-only branch and the whoami taken next to the failure still has that shape, or could not be read, it publishes the same account_unproven marker. Otherwise the ordinary _cache_transient_failure runs against that whoami. The modal therefore never says a reading is coming "yet" for this sign-in.

Tests:

  • test_an_error_in_the_api_call_leaves_account_unproven.
  • test_a_timeout_leaves_account_unproven: the API call is held on an event past a 0.05 s refresh deadline and released after the refresh returns. The test asserts no elapsed time.
  • test_a_switch_seen_after_the_error_is_judged_as_usual: the adjacent whoami names a user, so the ordinary path runs.

The first two fail on 8ad75c4. Mutations: the handlers always ordinary (2 failed); the adjacent whoami ignored (1).

@jeeshofone

Copy link
Copy Markdown
Contributor Author

N-2 (the degraded-API WARN claimed a text-scrape fallback): fixed in 06e9fea. fetch_usage_limits takes a keyword-only scrape_fallback (default True, which keeps today's wording) and passes it to _note_api_outcome. The ExternalIdP branch passes False, so its once-per-process WARN reads "Kiro usage API returned no reading (...); this sign-in shows no balance, so no fallback reading follows". The parametrized TestTheDegradedWarning checks both wordings. Ignoring the flag turns it red.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

N-3 (the notice hard-coded the ExternalIdP label): fixed in 06e9fea. The notice now takes its provider from accountProviderLabel(usage.accountType), the mapping the badge already uses. If a payload ever arrives without a type, it falls back to the old label so the sentence stays whole. The gateway always sends the type for this state. New vitest names the same provider in the notice as in the badge uses an IamIdentityCenter type and shows the badge and notice naming the same provider. It fails on 8ad75c4. The copy is unchanged, so the stills still match.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Design and First Principles, "check before merge" on the no_credential case: answered by SF-1 in 06e9fea. Both lanes asked whether no_credential alone should give "Sign in to Kiro again" when no scrape backs it up. It no longer does. In this branch a missing credential leads to signin_required only when the /usage scrape also fails, or is parked after repeated failures. A scrape that parses a plan keeps account_unproven, and the plan's number is never published. This is the rule the ordinary path follows and the usage spec states. The scrape now runs in that case, so kiro-cli also gets the chance to renew its own store, as on main. We have not verified whether kiro-cli whoami renews an expired access token by itself. The corroboration gives the right answer either way. The spec paragraph in learn-cron-dashboard.md was updated to match.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

UX Review Watch (blind read of the pill's native title): held, unchanged. Nothing the author can change satisfies a cold human read, and headless Chromium does not draw a native title. App.creditPillError.test.tsx asserts that the hover text equals the accessible name, and the modal explains the state in full. A maintainer read would settle it.

UX Suggestion (the notice's third sentence repeats the link): declined. The lane's fix depends on the account page actually showing the balance for this sign-in, which this PR cannot verify. The sentence is accurate, because the Manage account link always renders below the notice. No UI or copy changed this round (N-3 only changes where the provider label comes from), so the committed stills under temp-screenshots/17784/ still match.

E2E (stub ACP backend, offline), if it shows: main-side, #18185 and #18632. Independent review: left to the loop.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Head 3eaf57404d: spawn-audit fix for Backend Tests (3.12, 6) and Backend Tests (Windows) (6).

test_spawn_audit.py::test_every_spawn_is_routed_or_allowlisted failed on 06e9fea60 with dashboard/handlers/sessions.py::_spawn_scrape. The audit judges each spawn by the function it sits in. On main the /usage scrape spawn sat in _refresh next to the _wrap_argv_usage_scrape wrap, so it counted as sandbox-routed. The previous round split the wrap and the spawn into two nested helpers, and the spawn's helper no longer showed that its argv was the wrapped one.

Fix: one nested _run_scrape(binary, before_spawn=None) wraps the argv (sandbox at the configured tier, off the loop), applies cgroup_scope_argv, then spawns through spawn_supervised_oneshot. The spawn is back in a routed, resource-limited, cgroup-scoped function. BENIGN_SPAWNS is unchanged and the sandbox path is the same. The /usage refresh still takes its whoami right before the spawn, now through the before_spawn hook, which runs after the wrap and immediately before the child starts. So the bracket order is the same as on 06e9fea60. The diff has no other spawn.

Tests: test_spawn_audit.py, test_session_usage_account_type_identity_17710.py and every *usage* test file: 699 passed. Admission-paths, kill-chokepoint, hardened-reads ratchets and every test_session* file: 5828 passed. On sessions.py: black, isort, flake8 and mypy are clean, and the comment-history gate passes. Semgrep 1.78 with the repo's semgrep/ rules over the changed files: 0 findings on this PR's lines. The one hit, test-promise-sleep in App.creditPillError.test.tsx, is an existing line from main.

Other reds: E2E is the main-side failure tracked in #18185 / #18632. First Principles and UX NEUTRAL items wait on a maintainer ruling, unchanged.

First-pass check: R1-R8 OK (R8: the spawn audit is the gate this round missed, since a refactor moved a spawn into a new function key without running test_spawn_audit.py).

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Dispositions for head 67f4235 (rebased onto current main, d06b611).

First Principles item 5 (the scrape_fallback keyword is more surface than a log sentence needs): fixed. The keyword is gone from _note_api_outcome and fetch_usage_limits, and both are back to main's signatures. The single degraded WARN now reads "Kiro usage API returned no reading (%s); overage will not be visible until the API path recovers", which is true whether or not a scrape follows. The two-wording test is deleted.

Also in this head:

  • Every payload _publish_usage receives in the no_credential tests (working and failing scrape) is checked against the account-only marker's keys through a wraps= spy. The final cache alone could not catch a scrape number published and then overwritten by the marker a few awaits later. Publishing the parsed scrape before the marker now fails both tests.
  • A corroborating scrape that is the third miss now returns scrape_parked to its caller, as the ordinary path does. New test; reverting to return None fails it.
  • _account_type_only_reason's docstring says the corroborating scrape is not whoami-bracketed because only the reason depends on it, never a number.
  • New vitest: an account_unproven state with no accountType still names Company SSO in the notice. Dropping the fallback fails it.

Held, unchanged from earlier dispositions:

  • First Principles items 8 and 9 (the Company SSO label on every ExternalIdP reading, the provider-only identity block): answered on earlier heads; they need a maintainer call.
  • UX blind read: we cannot verify that the account settings page shows this sign-in's balance, so the notice still says what the link opens, not what it shows.

Gates on 67f4235: the PR's test file (33 passed); usage files, test_spawn_audit.py, admission, kill-chokepoint, hardened-reads and pid-reader ratchets, oneshot supervisor (943 passed); every sessions, kiro_usage_api and ratchet file (1370 passed); vitest KiroAccountModal and App.creditPillError (56 passed); tsc -b, mypy, black gate, isort, flake8, comment-history, docs-lint. Semgrep 1.78.0 with the repo's semgrep/ rules on changed files: 0 on this PR's lines.

First-pass check: R1-R8 OK. AUTOSDE rules matching this round's files: prefer-subtracting-a-duplicate-mechanism (the keyword is removed, not reworded); an-invariant-line-needs-a-mutation-pin (the no-number publish, the park return and the notice fallback each have a mutation that turns a test red); an-operator-facing-string-states-what-was-measured (the WARN names the API's terminal reason and claims nothing about a scrape); no-blocking-call-on-event-loop, persist-before-you-publish, a-refusal-is-not-a-commit, a-bound-bounds-every-field-it-retains, no-sync-store-call-from-a-coroutine, backend-security-controls, a-ratchet-may-only-tighten, feature-map-correctness, recorded-decisions-are-not-regressions: this round adds no call, store, cap, ratchet entry or feature-map row, and the spawn path is unchanged (test_spawn_audit.py green, no BENIGN_SPAWNS edit).

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Dispositions for head e95ebe2 (one commit, rebased onto current main e4270cf).

Opus BLOCKING (tests-are-deterministic, test_a_timeout_leaves_account_unproven): fixed. The 50 ms deadline is gone. The hanging fetch_usage_limits stub sets an event when it is entered, and the refresh deadline expires only after that event is set: the outer wait_for is given a sentinel deadline, waits for the event, then hands the still-running refresh to the real wait_for with no time left, which cancels it and raises TimeoutError as an expired deadline does. Whatever setup takes before the API call (whoami, sandbox mode, the executor hop) can no longer decide the outcome. Evidence:

  • with a 0.5 s delay inserted into the refresh's setup (after _resolve_kiro_bin_for_spawn), the new test still passes; the previous version of the test fails under the same delay with {'available': False};
  • with the branch's behaviour removed (_cache_failure never takes the account_unproven path), the new test fails;
  • 15 of 15 consecutive runs pass.

Sweep of this PR's other new tests for wall-clock races: none found. The Python tests use no sleep or deadline other than this one (the stub's release.wait(30) is only an upper bound on a thread released in finally), and the vitest additions wait on conditions with waitFor, not on time.

First Principles "check one thing" (a no_credential reading spawns a /usage scrape whose number is discarded): bounded, no code change. The scrape runs only when auth_state is no_credential (sessions.py:1167), never while the scrape is parked (:1169). A refresh starts only when the cache is older than _USAGE_REFRESH_SECS = 600 s (:242, checked at :1515), and _publish_account_unproven resets that clock. Refreshes are single-flight (:1044; the manual Refresh POST answers 409 while one runs, :1562). Worst case is therefore 6 timer-driven scrapes an hour plus one per Refresh press. That is the same rate main's ordinary path already pays whenever the API returns no plan, since its fallback scrape also runs on every refresh. Failing scrapes still count toward the existing park (3 misses, then 6 h; :279, :283). No new mechanism is needed.

Design "check one thing" (does kiro-cli store anything per-user for ExternalIdP?): copy softened. We cannot verify kiro-cli's storage from here, so the notice no longer claims that signing in again won't change anything. It now says only what this branch checks: "Credit balance isn't shown for this {{provider}} sign-in, because kiro-cli doesn't report which user is signed in." _account_type_only takes this branch exactly when whoami carries the ExternalIdP type and no email, start URL or profile ARN. Updated in all 12 catalogs, en-XA regenerated with gen-pseudolocale.mjs, the spec paragraph in learn-cron-dashboard.md, and both modal stills re-shot at this head.

UX suggestion: taken. The "Manage account below opens your Kiro account settings in your browser." sentence is cut, because we cannot verify that the account page shows this sign-in's balance. The Manage account link stays below the notice. KiroAccountModal.test.tsx checks that the notice names the cause, no longer mentions signing in again or the link, and that the link is still rendered.

UX Watch (the top-bar info mark needs a cold read): held for a maintainer, as before. A first-time read is not something we can provide from our side.

Gates on e95ebe2: the PR's test file (33 passed), plus test_kiro_usage_api.py, test_session_usage.py and test_spawn_audit.py (310 passed before the rebase, 199 for the touched subset after it); vitest KiroAccountModal, App.creditPillError and src/i18n with I18N_BASE_REF (832 passed); tsc -b, mypy, black, isort and flake8 on the changed test, comment-history (base ref), docs-lint. Semgrep 1.78.0 with semgrep/ on changed files: 0 findings on this PR's lines (one finding, test-promise-sleep at App.creditPillError.test.tsx:212, is on a line already on main). No spawn code moved this round.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Head 93591fc is a pure rebase of e95ebe2 onto main c50003c. git diff of the commit against its parent is byte-identical to the previous head (30 files, +1016/-120), with no conflicts and no body edit. Why it exists: on e95ebe2 the GPT 6.1 review reached a verdict but did not publish it ("verdict not published", an infra failure), so that lane needs a fresh head to run again. E2E on the previous head is the main-side Playwright 1020 s bound, tracked in #18185.

UX Watch 1 (the info mark looks like its own button): held for a maintainer cold read, as on the earlier heads. The mark is part of the pill's single click target, and a click anywhere on the pill opens the modal that states the reason in words. Removing it brings back the earlier finding that the bare dash reads as a failed read. Only a person seeing the pill without the diff in mind can settle which shape is right.

UX Watch 2 (the notice offers no next step): held, and the reversal is named. On 67f4235 the same lane's own suggestion asked to cut the "Manage account below…" sentence, and this PR did. Adding a next step back would reverse that suggestion. kiro-cli exposes no user-level fix for this state, so there is no honest next step to name, and the notice does not claim the account page shows a balance because nothing here verifies it.

Run locally on 93591fc: test_session_usage_account_type_identity_17710.py, test_session_usage.py, test_kiro_usage_api.py, test_usage.py and test_spawn_audit.py (408 passed); vitest KiroAccountModal.test.tsx and App.creditPillError.test.tsx (56 passed); the comment-history gate against origin/main (passed).

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Head 7d48b20 is the previous head rebased onto main 2e69397, plus two test-only changes. It has no conflicts, and the PR body was edited before the push. This answers every lane item as numbered in the UX, Design and First Principles verdicts on 93591fc.

Fixed in 7d48b20 (tests only). test_a_reading_the_api_returns_is_never_published now spies on _publish_usage and asserts that every payload carries only the marker's keys. A mutation that publishes the type-only API reading before the marker now fails that test. It passed every test before. The timeout test's asyncio.wait has timeout=10 and asserts that one of the two awaitables finished, so a wedge before the API stub is entered fails with a message instead of hanging.

UX Watch 1 (the pill's hover text is in no still): held. The hover text is a native title tooltip, and a headless capture cannot render one. App.creditPillError.test.tsx asserts that the pill's title equals its accessible name, so a test covers what the still cannot show.

UX Watch 2 (the notice offers no next step): held as written on 93591fc. kiro-cli offers no user-level fix for this state, and an earlier round of this lane asked for the Manage account sentence to be cut.

UX Suggestion (copy "for Company SSO sign-ins"): declined. The plural would be false. An ExternalIdP sign-in whose whoami carries an email still publishes a balance (test_an_email_on_both_sides_still_publishes). So the notice keeps "this … sign-in".

Design "check one cost" (the scrape on no_credential): bounded. The refresh runs only when now - _usage_cache_ts > _USAGE_REFRESH_SECS (600 s, sessions.py:242, :1515), and _publish_usage resets _usage_cache_ts (:746). It is single-flight. Failing scrapes park after _USAGE_SCRAPE_FAILURE_THRESHOLD (3) misses for _USAGE_SCRAPE_BACKOFF_SECS (6 h, :279, :283). The worst case is about 6 scrapes per hour for a working-scrape no_credential sign-in, the same rate the ordinary fallback already pays.

First Principles item 8 (Company SSO relabel undeclared): declared. The body now says that the badge's provider label reads Company SSO for every ExternalIdP sign-in, including ones that publish a reading. Main showed the humanized id "External Id P", and Company SSO is the sign-in flow's own name for that provider.

CI on 93591fc. Backend Tests (Windows) (4) crashed with an access violation in _migrate_fts_index under test_workflows_startup. That is #20202, and #20313 covers it: test_workflows_startup imports _cancel_stray_tasks from test_dashboard_server_startup_coverage, and #20313 makes that helper join the loop's default executor before the knowledge store closes. The crash is outside this diff.

Run locally on 7d48b20: this PR's test file (33 passed; the timeout test 15/15 in a loop); every test/*usage*.py, test_kiro_usage_api.py and test_spawn_audit.py (708 passed before the final rebase, 310 after it); vitest for the modal, credit pill, sign-in card, login gate and i18n gate tests (116 passed); tsc -b, eslint on changed files, the i18n checks, the pseudolocale (no diff), mypy, the black gate, isort, flake8, comment-history and docs-lint all clean; Semgrep 1.78.0 with semgrep/ and the registry packs on the changed files found nothing on this PR's lines.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Disposition for the lane comments as they read on 7d48b2007 (re-run 19:20-19:22Z). This replaces the item numbering in the 18:49 comment, which answered the items as they read on 93591fcad.

  • UX Watch 1 ("Pill explains itself only on hover"): hold. Clicking anywhere on the pill opens the modal, and the modal states the reason. The pill's title equals its accessible name (App.creditPillError.test.tsx), so screen readers get the full sentence. The dash plus ⓘ is the existing muted-state glyph the sibling no-value states use.
  • UX Watch 2 ("Modal notice uses tool jargon"): hold. As the lane notes, the sibling credit_usage_signin_required already names kiro-cli. The cause is kiro-cli's own whoami, so naming it is the honest cause, and rewording only one of the two sibling strings would make them inconsistent.
  • Design check (no_credential with a working V2 /usage scrape ends as account_unproven): covered by test_no_credential_with_a_working_scrape_stays_account_unproven and test_no_credential_with_a_failing_scrape_asks_for_a_sign_in in test/test_session_usage_account_type_identity_17710.py. The path is _account_type_only_reason in dashboard/handlers/sessions.py: no_credential, not parked, and the scrape parses a plan, which gives account_unproven. I don't have a real ExternalIdP install to run this against.
  • First Principles check (a broken credential reads rejected/no_credential): rejected gives signin_required with no scrape (test_a_refused_credential_keeps_the_signin_remedy_without_a_scrape). no_credential with a failing or parked scrape gives signin_required (same file). The same real-install caveat applies.

Non-green on 7d48b2007, none involving this diff:

…balance

An external identity provider sign-in makes kiro-cli whoami report an
account type and nothing else ({"accountType":"ExternalIdP","email":""}).
The /usage scrape bracket demanded an email, start URL or profile ARN on
both sides, so every refresh ended in a bare "Credit usage unavailable",
and the Kiro Account modal hid the provider label it had computed because
no name was available.

A type names a provider, not a user, and nothing kiro-cli prints or
stores for this sign-in is evidenced to name the user: the stored
credential's stable claims (client_id, scopes) belong to the IdP
registration that every user of it shares. So a top-of-refresh whoami
with the ExternalIdP account type and no email, start URL or ARN ends the
refresh without publishing a reading: the cache names the account with
reason account_unproven and no balance, keeping nothing of an earlier
reading, and no number is read from the /usage scrape. The usage API
call still runs for its auth_state alone: a refused credential (401) ends
as signin_required. A missing credential is not proof on its own, as on
the ordinary path, so the /usage scrape runs once for its outcome only: a
parsed plan keeps account_unproven, no plan (or a parked scrape) ends as
signin_required. A timeout or error in this branch leaves the same
account_unproven marker while the adjacent whoami keeps this shape. A
corroborating scrape that parks the scrape reports the park to its
caller, as the ordinary path does. The once-per-process degraded-API
warning now says the API returned no reading, which is true on every
path, instead of naming a text-scrape fallback this branch never uses.

The modal labels the sign-in "Signed in with Company SSO", the sign-in
flow's existing name for the provider (providerLabelFromWire, moved into
its own module so the modal can share it; the notice names the provider
through the same mapping as the badge), and shows the identity block
(a name, a provider, or both) above a passive notice saying the balance
is not shown for this sign-in and that signing in again will not change
it, with no Refresh, since another read of the same sign-in answers the
same. The pill shows a terminal dash with that label.

The gate is scoped to ExternalIdP. A Builder ID or Identity Center
whoami that prints only its type takes the ordinary path and keeps its
"sign in again" remedy (reason signin_required).

Closes kirodotdev#17710
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Disposition for the UX Review CONCERNS on 7e233a23f. No push on this head: every item below is held or answered.

Headline (no first-time reader has seen the modal or the pill's info mark): held for a maintainer. A cold read needs a person who has not seen the change, and the author cannot provide one by pushing. This is the same hold as on earlier heads. A maintainer cold read is welcome, and any wording it asks for is a one-string follow-up.

Watch 1 (no way forward from the notice): held. This is the question answered in this earlier comment. Nothing verifies that any surface, "Manage account" included, shows the balance for this sign-in type, so the notice does not point users at one. The "Manage account" link renders directly under the notice. If a maintainer knows a surface that shows the balance for these sign-ins, the notice can name it in a follow-up.

Watch 2 (the info mark is on this state and not on api-key): held. The mark came from an earlier UX round on this PR, which found that the plain dash read as a failed read. Removing it brings that finding back. Adding it to api-key changes a state this PR does not touch. Earlier rounds asked for opposite treatments of this pill (earlier comment), so the final shape of the permanent no-value states needs a maintainer decision, covering all of them together in its own change. The opacity-60 dimming is the treatment every no-value pill state uses.

Suggestion (one verb, "isn't available" vs "isn't shown"): holding reply. Noted. It is a two-string change across the catalogs. It will land with the next push that has real work in it, and does not get a push of its own, because a push re-runs every lane.

Earlier Watch answers, unchanged: the hover-text item and the kiro-cli naming item stay held as answered in this comment.

This PR is not ready while the UX lane reads CONCERNS. The remaining items wait on a maintainer.

@bolichen97

Copy link
Copy Markdown
Contributor

Thanks for this fix. Please rebase onto current main. The head 7e233a2 no longer merges cleanly: main changed the same long line in docs/system-specs/modules/learn-cron-dashboard.md (the session sidebar ordering text). That is the only conflicting file. The code files merge cleanly.

What I checked on 7e233a2 (read, not run locally):

  • The ExternalIdP type-only branch in sessions.py publishes no number. The API result is used only for auth_state, and the corroborating scrape is used only to check whether a plan parsed.
  • _publish_account_unproven replaces the whole cache, so no field of an earlier reading survives. Private _ fields are dropped and strings are redacted.
  • On a timeout or error, _cache_failure keeps the no-balance marker only while the adjacent whoami is still this shape. Otherwise it takes the existing path.
  • Main does not contain this fix yet.

Two should-fix items, for the rebased head:

  1. In the type-only branch, the marker is published only after the API call (up to about 30 s), and for no_credential also after the scrape (up to 60 s). During that window, the usage GET keeps serving the previous refresh's cache, which may hold the previous account's balance and email. Main has the same window on the ordinary path, so this is not a regression. But this branch already knows that nothing it reads can be shown. Publish _publish_account_unproven(identity, _REASON_ACCOUNT_UNPROVEN) when the branch starts, then publish again with the final reason.
  2. test_an_earlier_reading_is_not_kept seeds an earlier reading with no email. Add a case where the earlier reading belongs to another user with an email and an account name, and assert neither key survives. That pins "the previous user's identity is not shown", not only "the previous balance is not shown".

If either item is already covered by a test I missed, tell me which one and I will withdraw it.

@buluoray

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Taking this over in #22861 since it has been idle; you are credited as co-author on the commits. Thanks for the groundwork.

#22861 is this PR's change carried onto current main. The conflicts came from the sessions_parts split (#21532), so _account_type_only now sits in sessions_parts/usage_scrape.py, plus the spec line and the credit-pill tests that #15370 also extended. The tests and website code are byte-identical to your head 7e233a2.

@iamwhatever

Copy link
Copy Markdown
Contributor

Thanks @jeeshofone for this fix and the careful dispositions. Closing as superseded: this exact change was carried onto current main in #22861 (you are credited as co-author), which merged on 2026-10-21 as 2de262e and closed #17710. _account_type_only now lives on main in src/kiro_crew/dashboard/handlers/sessions_parts/usage_scrape.py, so a rebase of this branch would add nothing. The remaining ask on #17710 (a per-user field from kiro-cli whoami so the balance can come back for External IdP sign-ins) is a separate follow-up and is tracked on that issue.

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) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

External-IdP account: credit reading discarded, account type never shown

4 participants