Skip to content

fix: gate history reruns on kiro-cli only when their turn runs on it - #32839

Merged
bolichen97 merged 1 commit into
mainfrom
fix/14512-readiness-gate-scope
Nov 8, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/14512-readiness-gate-scope

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On a chat whose turns run on Claude, Codex or another harness that does not sign in through kiro-cli, Regenerate, Edit + Send and rewind work without kiro-cli installed or signed in, and Edit + Send and rewind are refused before any history is cut when that chat's last turn ended signed out.

On main the three history reruns ask "is kiro-cli signed in?" for every chat. A chat on a harness that never runs kiro-cli gets a kiro_prerequisite_required 503 whenever kiro-cli is missing or signed out. When kiro-cli is signed in, they go ahead with no sign-in fact at all about the harness the turn will use.

Why it matters

Anyone who runs Kiro Crew on a non-Kiro harness without kiro-cli loses Regenerate, Edit + Send and rewind to an error about a tool they do not use, and the only way out is to install and sign in to it.

Not a goal

What changed (motivation → approach → change)

Regenerate, Edit + Send and rewind no longer fail with a kiro-cli sign-in error on a chat that runs on Claude, Codex or another harness that never uses kiro-cli. On such a chat, Edit + Send and rewind are refused before they cut history when the chat's last turn ended signed out, so a signed-out harness does not throw away the messages they replace.

A kiro-cli or KAS chat is checked exactly as before. On any other harness the turn is its own sign-in authority, as for an ordinary send.

Part What it does
kiro_readiness.rerun_signs_in_via_kiro_cli Reads the backend a fresh session for the slot would start on, through _configured_backend_for_slot (crewmate pin, then member route, then default), from the session manager's applied config: the one its provider factory starts the turn from, not config.json, which runs ahead of it until the config watcher applies a write. Answers whether that backend is in backends_retired_by_host_logout(). No slot, no session manager, or a selection it cannot read, keeps the check.
Regenerate, edit-resend, rewind (chat_regenerate.py, chat_rewind.py) Run reject_if_kiro_unverified only when that answer is yes.
kiro_readiness.refuse_rerun_after_signed_out_turn When the check was skipped, Edit + Send and rewind answer harness_sign_in_required 503 under the slot lock, before history is cut, while the last turn this process ran on the slot ended signed out (_last_turn_auth_required, kept in memory). Regenerate is not refused: it replaces the reply only when its turn produces one.

The specs docs/system-specs/modules/learn-cron-dashboard.md and docs/system-specs/modules/cli.md record the scoped check and the refusal. This is the rerun half of #10414's gate scoping, cut to its smallest form.

Builds on #10414 by @amansk.

Backwards compatibility

Breaking: on a non-Kiro harness chat whose last turn ended signed out, Edit + Send and rewind answer harness_sign_in_required 503 instead of cutting history and starting a turn that fails the same way. Writer sweep on origin/main @ df553b0: the three callers below already handle any non-OK answer. Everything else widens: a non-Kiro chat is no longer refused over kiro-cli.

Reader: website/src/lib/rewindCall.ts:rewindWithRollback -- chat -- a failed rewind rolls the optimistic edit back
Reader: website/src/pages/chat/crew-window/CrewChatWindow.tsx:CrewChatWindow -- crew page -- a rejected rewind puts the edit back in the rewind draft
Reader: website/src/apps/mochi/panel/panelBridge.ts:editResend -- app -- a non-OK answer falls back to a plain send

Tests

  • test_rerun_readiness_scope.py: the check follows the slot's backend (kiro-cli and KAS gated, Claude not); a member DM is judged by agent.member_acp_backend both ways; no slot, no session manager, or an unreadable selection keeps the check. With kiro-cli signed out, all three reruns go through on a Claude chat and still answer kiro_prerequisite_required on a kiro-cli chat. After a signed-out last turn, Edit + Send and rewind on a Claude chat answer harness_sign_in_required with history and the native conversation untouched, while a kiro-cli chat with kiro-cli signed in is not refused. When config.json says Claude but the applied config still says kiro-cli, Edit + Send and rewind keep the kiro-cli check and cut nothing.
  • test_chat_regenerate_cov80.py, test_slot_ownership_checkpoint.py: the three tests that need the check to run give their session-manager double an applied config; test_chat_handlers_composition_contract.py pins the new _configured_backend_for_slot signature.
  • Determinism: the file passed 10 runs at -n0, a seeded shuffled order (shuf, seed 31415), and a run at -n 4 --dist loadgroup --max-worker-restart=2 beside test_chat_regenerate_cov80.py and test_slot_ownership_checkpoint.py (175 passed). The applied-config test fails on the disk read it replaces: edit-resend and rewind answered 200 and cut history.

Proof: PROVEN test/test_chat_handlers_composition_contract.py::test_a_moved_name_keeps_its_base_shape_and_owner[slot_effort:_configured_backend_for_slot], test/test_rerun_readiness_scope.py::test_a_signed_out_kiro_cli_refuses_only_a_rerun_that_runs_on_it[claude-200-regenerate-body0], test/test_rerun_readiness_scope.py::test_a_signed_out_kiro_cli_refuses_only_a_rerun_that_runs_on_it[claude-200-edit-resend-body1], test/test_rerun_readiness_scope.py::test_a_signed_out_kiro_cli_refuses_only_a_rerun_that_runs_on_it[claude-200-rewind-body2], test/test_rerun_readiness_scope.py::test_a_signed_out_last_turn_refuses_a_foreign_rerun_before_the_cut[claude-503-edit-resend-body0] (head 71769bed4824)

Manual verification

Not run live: a signed-out non-Kiro harness needs that harness's own account. The tests drive the real handlers with a signed-out kiro-cli and the harness written to the test's config.json and applied to the session manager, the way a user's pick takes effect.

Screenshots / video

N/A: backend-only change, no frontend file touched.

Related Issues

Part of #14512

Sibling sweep

Swept: git grep -n "reject_if_kiro_unverified(" -- src/
Sibling: src/kiro_crew/dashboard/chat_regenerate.py -- changed here
Sibling: src/kiro_crew/dashboard/chat_rewind.py -- changed here
Sibling: src/kiro_crew/dashboard/openai_compat.py -- tracked in #10414
Sibling: src/kiro_crew/dashboard/handlers/agents.py -- not affected -- the /api/models catalog spawns kiro-cli itself
Sibling: src/kiro_crew/dashboard/handlers/sessions.py -- not affected -- the usage poll and refresh spawn kiro-cli themselves

Pattern harvest

Rule candidate: review-prompt
Pattern: a kiro-cli readiness verdict used to authorize a turn without first asking whether that turn's harness signs in through kiro-cli (backends_retired_by_host_logout()).

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

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision a25bd540d9474dd89ea897bb3d04cd24f7fc7e4a 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 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of a25bd540d9474dd89ea897bb3d04cd24f7fc7e4a — 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

Nothing blocks. Both behaviour changes are in the frozen Goal, reuse existing mechanisms (_configured_backend_for_slot, backends_retired_by_host_logout(), _last_turn_auth_required), and fix the cause: a kiro-cli verdict was being applied to harnesses that don't sign in through kiro-cli.

What this change ships

Inventory (5 items) — 5 justified

Intent: let people on a non-Kiro harness use Regenerate, Edit + Send and rewind without needing kiro-cli, without losing history to a signed-out turn. This is a FIX.

  1. On a chat whose turn runs on Claude, Codex or another non-kiro-cli harness, Regenerate, Edit + Send and rewind no longer fail with kiro_prerequisite_required — justified
  2. On such a chat, Edit + Send and rewind now answer harness_sign_in_required 503 before cutting history when the last turn ended signed out — justified
  3. kiro-cli and KAS chats are still gated as before. A missing slot, a missing session manager or an unreadable backend also keeps the gate — justified
  4. The backend choice is read from the session manager's applied config, not from config.json — justified
  5. _configured_backend_for_slot gains an optional config parameter, used by one caller, the new scope check — justified

[FIRST-PRINCIPLES-REVIEWED] a25bd54

Description read

[DESCRIPTION-READ] 1b88ccccf117d8680352e0789fcb7a501ee8a12eb882663fc5b91b6d8fce96cb

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the gate now follows the turn's own harness, a selection it can't read keeps the old check, and the one new refusal is listed with its three readers.

Notes

  • The refusal depends on _last_turn_auth_required, which lives only in memory. After a gateway restart, a signed-out Claude or Codex chat can still cut history on Edit + Send or rewind. You list this as deferred under Restore safe history reruns for non-Kiro ACP harnesses #14512, and nothing new is lost because main behaves the same way today.

[DESIGN-REVIEWED] a25bd54

Description read

[DESCRIPTION-READ] a905ba1ddf4ba4b023f8138e7a0b313ddb9bc77855b38883b6fb456386f8c7d4

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] a25bd54

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

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

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a25bd54

False positive or not applicable? A repository writer can comment:
/ai-review override gpt a25bd540d9474dd89ea897bb3d04cd24f7fc7e4a 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 Nov 8, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) November 8, 2026 02:44
Regenerate, edit-resend and rewind refused with kiro_prerequisite_required
whenever kiro-cli was missing or signed out, even on a slot whose turn runs
on Claude, Codex or another harness that never reads kiro-cli's sign-in.
They now ask the kiro-cli gate only when the backend the session manager's
applied provider factory picks for the slot's session (member DMs and
crewmate pins included) signs in from kiro-cli's store. The applied config
is read rather than config.json, which runs ahead of the factory until the
config watcher applies a write.

On such a foreign harness the one sign-in fact Crew holds is the slot's
last outcome, so edit-resend and rewind, which cut history before their
turn runs, refuse with harness_sign_in_required while the last turn ended
signed out. Restoring the replaced tail after a failed foreign turn stays
open on the issue.

Builds on #10414 by @amansk.
Part of #14512
@bolichen97
bolichen97 force-pushed the fix/14512-readiness-gate-scope branch from 72fe91c to a25bd54 Compare November 8, 2026 12:52
@bolichen97

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the rerun gate read the slot's backend from config.json on disk

  • Resolve readiness against the applied provider configuration span=04b44db6832d

fixed in a25bd54: rerun_signs_in_via_kiro_cli selects the slot's backend from the session manager's applied config (sessions._cfg), which refresh_defaults installs together with the provider factory under one lock, so a config.json write the watcher has not applied no longer skips the kiro-cli check before the cut.
Pinned by test_a_choice_the_watcher_has_not_applied_keeps_the_gate_before_the_cut: Kiro CLI applied, Claude on disk, kiro-cli signed out; edit-resend and rewind answer 503 with history and the native conversation untouched. It fails on the disk read.
No backend pin is threaded through _run_chat: the replacement turn's factory is the same applied object the gate now reads, and an explicit backend_override would skip the crewmate pin's fail-closed check (H17).
[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/cli.md and docs/system-specs/modules/learn-cron-dashboard.md since this head's CI ran (601aa4c -> de25ac3); CI re-running.

[operator: bolichen97]

@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: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 8, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving head a25bd54. The review read the full src diff and checked that the rerun gate uses the same member-aware backend selector as the provider factory. It reads the applied config, not config.json, and it names the harness by positive membership in backends_retired_by_host_logout(). Every unreadable path keeps the gate. The new harness_sign_in_required refusal runs under the slot lock, before any history is cut. On an extracted head tree, test_rerun_readiness_scope.py passed 18 of 18, the sibling files passed 499, and 12 of 13 mutants on the production hunks were killed.
Done well: every refusal test also asserts that history and the native conversation stay untouched, so a refusal placed after the cut would fail.
Optional: add a _REGENERATE case (Claude slot, signed-out last turn, expect 200) to pin "Regenerate is not refused". That was the one mutant no test killed.
Optional: on the chat page, rewindWithRollback swallows the new 503 and the edit disappears without a message. A follow-up issue could surface both rerun refusal codes there.
Optional: after merge, note on #10414 that the rerun half and its helper are on main, so it can narrow to the /v1/chat/completions half. Also name the merge order against #25562, which edits the same three gate call sites. The Proof line still cites 71769bed and could be refreshed to this head.

@bolichen97
bolichen97 merged commit 91ee8a0 into main Nov 8, 2026
99 checks passed
@bolichen97
bolichen97 deleted the fix/14512-readiness-gate-scope branch November 8, 2026 14:14
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 8, 2026
buluoray added a commit that referenced this pull request Nov 8, 2026
…32839)

Regenerate, edit-resend and rewind refused with kiro_prerequisite_required
whenever kiro-cli was missing or signed out, even on a slot whose turn runs
on Claude, Codex or another harness that never reads kiro-cli's sign-in.
They now ask the kiro-cli gate only when the backend the session manager's
applied provider factory picks for the slot's session (member DMs and
crewmate pins included) signs in from kiro-cli's store. The applied config
is read rather than config.json, which runs ahead of the factory until the
config watcher applies a write.

On such a foreign harness the one sign-in fact Crew holds is the slot's
last outcome, so edit-resend and rewind, which cut history before their
turn runs, refuse with harness_sign_in_required while the last turn ended
signed out. Restoring the replaced tail after a failed foreign turn stays
open on the issue.

Builds on #10414 by @amansk.
Part of #14512

Original author: Bolin Chen
(cherry picked from commit 91ee8a0)
buluoray added a commit that referenced this pull request Nov 8, 2026
…32839)

Regenerate, edit-resend and rewind refused with kiro_prerequisite_required
whenever kiro-cli was missing or signed out, even on a slot whose turn runs
on Claude, Codex or another harness that never reads kiro-cli's sign-in.
They now ask the kiro-cli gate only when the backend the session manager's
applied provider factory picks for the slot's session (member DMs and
crewmate pins included) signs in from kiro-cli's store. The applied config
is read rather than config.json, which runs ahead of the factory until the
config watcher applies a write.

On such a foreign harness the one sign-in fact Crew holds is the slot's
last outcome, so edit-resend and rewind, which cut history before their
turn runs, refuse with harness_sign_in_required while the last turn ended
signed out. Restoring the replaced tail after a failed foreign turn stays
open on the issue.

Builds on #10414 by @amansk.
Part of #14512

Original author: Bolin Chen
(cherry picked from commit 91ee8a0)
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.

2 participants