Skip to content

fix(chat): apply the merge-card kept-prompt rule only on kiro-cli - #32470

Merged
KiroCrewCaptain merged 2 commits into
mainfrom
crew/issue-triage/23164-merge-card-kiro-only
Nov 7, 2026
Merged

KiroCrewCaptain merged 2 commits into
mainfrom
crew/issue-triage/23164-merge-card-kiro-only

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A merge card on a harness other than kiro-cli is never lost because of a kiro-cli-only rule; at worst it is sent twice.

_merge_cards_reached_the_model (src/kiro_crew/dashboard/chat_turn/turn_stats.py) stamps a merge card consumed for a turn that did not land when _kiro_cli_kept_the_prompt says the native session kept the prompt. That is kiro-cli's contract (it appends a prompt to its session log once the model has answered it), but the rule ran for every agent.acp_backend. A harness that drops such a prompt would lose the card.

Why it matters

The merge card's context is the only copy of what a fork added that reaches the parent's agent. On a harness nobody checked against the kiro-cli contract, a lost card silently drops the fork's work from the parent chat.

Not a goal

  • Checking each other harness's session log and adding it to the named list. Each gets its own check later.
  • The first-turn history settle in chat_turn/prompt_assembly.py, which also reads _kiro_cli_kept_the_prompt. It is not a merge card and is outside Merge-back: limit the merge-card consumption rule to named backends #23164.
  • Changing the landed-turn clause or _native_session_lacks_the_prompt: a landed turn consumes on every harness (otherwise a card would repeat forever), and the "lacks" rule only ever restores a card.

What changed (motivation → approach → change)

Symptom: an unlanded turn's merge card can be stamped consumed on a harness whose session may not hold the prompt.
Cause: the kept-prompt clause in _merge_cards_reached_the_model is applied without asking which harness ran the turn.
Change: the clause counts only when the turn's client positively reports is_kiro_backend is True or is_kas_backend is True (H5: identity is positive). KAS stays in because it is the default harness and runs the Kiro CLI pick; dropping it re-sent cards to a live session that held them (Opus review, round 1). Every other harness consumes a card only on a landed turn, so a wrong guess re-sends the card instead of losing it. The spec row in docs/system-specs/modules/session.md says so.

Backwards compatibility

Compatible: kiro-cli and KAS behave exactly as before; other harnesses can only get a card one extra time, never one fewer.

Removes nothing: no key, path, record or function is removed or tightened; one consumption clause is narrowed to the harness it was written for.

Tests

  • test/test_harness_parity.py::test_merge_card_kept_prompt_rule_is_kiro_only, parametrized over ACP_BACKENDS_KNOWN: an unlanded turn after a real end_turn consumes its card on kiro-cli and KAS and keeps it on each other backend (claude, codex, copilot, deepseek, goose, opencode, pi, strands).
  • Existing merge-card suites pass: test_chat_runner_coverage_merge_cards.py, test_chat_merge_back*.py, test_recovery_l1_chat_runner.py (337 passed).

Proof: not provable -- other: prove.py stops at BASELINE_RED on this host, where two untouched tests in test_harness_parity.py fail on an enterprise platform profile; a manual revert of the production gate fails 8 of the 10 new cases (every backend outside kiro-cli and KAS), and dropping KAS from the gate fails the kas case.

Manual verification

N/A — unit coverage sufficient: the change is one boolean clause, pinned per backend.

Related Issues

Deferred from #17165. Part of #3816.

Fixes #23164

Sibling sweep

Swept: git grep -n "_kiro_cli_kept_the_prompt(" -- src/
Sibling: src/kiro_crew/dashboard/chat_turn/turn_stats.py:429 -- changed here
Sibling: src/kiro_crew/dashboard/chat_turn/prompt_assembly.py:1266 -- not affected -- first-turn history settle, not a merge card; listed under Not a goal

Pattern harvest

Rule candidate: review-prompt
Pattern: a helper named for one harness's contract (_kiro_cli_*) called on a path that runs for every agent.acp_backend without a positive identity check.

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] b33e737

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

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

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

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

This is a narrow fix for #23164. It only changes behaviour on harnesses outside kiro-cli and KAS, where a wrong guess now sends a merge card twice instead of losing it.

What this change ships

Inventory (3 items) — 3 justified

Intent: keep a fork's merge card from being silently dropped on harnesses where nobody has checked the kiro-cli kept-prompt contract. FIX.

  1. On a harness other than kiro-cli or KAS, a turn that did not land no longer marks its merge card consumed. The card is queued again. — justified
  2. The session spec's "card restored" row now says the kept-prompt condition applies only on the Kiro harnesses. — justified
  3. A test runs one unlanded end_turn turn on every known backend. It expects the card consumed on kiro-cli and KAS only. — justified

[FIRST-PRINCIPLES-REVIEWED] b33e737

Description read

[DESCRIPTION-READ] 68a03c72b9b7f9dd213fc0f25f9967bce327a4c49b58d9998fedcfca7efba1f6

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. The change only narrows when a card counts as consumed, so the worst outcome is a card sent twice, never one lost.

Notes

  • If turn.client is ever a wrapper (a fallback or proxy provider) that doesn't pass is_kiro_backend / is_kas_backend through, kiro-cli turns quietly lose the kept-prompt clause and their cards get re-sent. Asking the turn's resolved backend id against ACP_BACKENDS_KIRO_FAMILY, the set the test already uses, would close that.

[DESIGN-REVIEWED] b33e737

Description read

[DESCRIPTION-READ] 21a2c5e1971ebf1c06fa871656a27581c0ccbd87ce2776e2d51e9889ac56499d

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] b33e737

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

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

_merge_cards_reached_the_model consumed an unlanded turn's merge card
when kiro-cli's kept-the-prompt contract said the native session held
it, on every harness. No other harness has been checked against that
contract. Read it only when the turn's client is kiro-cli, so any other
harness consumes a card only on a landed turn and a wrong guess sends
the card twice instead of losing it. Pin it per known backend in the
harness-parity suite.

Fixes #23164
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/23164-merge-card-kiro-only branch from 215d741 to 3fe0c95 Compare November 7, 2026 17:08
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • BLOCKING — src/kiro_crew/dashboard/chat_turn/turn_stats.py:426

fixed in 3fe0c95: real defect from this PR. KAS is the default harness and runs the Kiro CLI pick, so gating on is_kiro_backend alone re-sent a merge card to a live session that already held it. The gate is now is_kiro_backend is True or is_kas_backend is True, so kiro-cli and KAS behave as on main; every other harness still consumes a card only on a landed turn. test_merge_card_kept_prompt_rule_is_kiro_only expects consumption for each member of ACP_BACKENDS_KIRO_FAMILY: dropping KAS from the gate fails the kas case, and removing the gate fails the 8 other backends.

KAS runs the Kiro CLI pick and is the default backend, so dropping the
kept-prompt clause there re-sent a merge card to a live session that
already held it. Gate on kiro-cli or KAS; every other harness still
consumes a card only on a landed turn.
@iamwhatever
iamwhatever force-pushed the crew/issue-triage/23164-merge-card-kiro-only branch from 3fe0c95 to b33e737 Compare November 7, 2026 17:43
@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 Nov 7, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 7, 2026 19:06

@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.

Tier 1 auto-approve: fix (3 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: the merge-card kept-prompt rule applies only on the kiro-cli and KAS backends; with a parity test. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/modules/session.md.

@KiroCrewCaptain
KiroCrewCaptain merged commit 7b0e787 into main Nov 7, 2026
97 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the crew/issue-triage/23164-merge-card-kiro-only branch November 7, 2026 19:07
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 7, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving b33e737 as maintainer. 98 checks pass. Fixes #23164.

About the one red check: the helper job "rerun / Re-run Sensitive Change Review" fails because it found no Sensitive Change Review run to rerun for this head. Sensitive Change Review itself passed on this same head at 17:44 UTC, so the helper's red does not block. We treated the same helper red the same way on #32279 today. I reran the helper once and it failed the same way.

What I checked:

  • _merge_cards_reached_the_model now counts the "kept the prompt" clause only when the provider is kiro-cli or KAS (is_kiro_backend / is_kas_backend exactly True). Any other harness consumes a merge card only on a landed turn, so a wrong guess there repeats the card instead of losing it.
  • A landed turn, and the _native_session_lacks_the_prompt guard, are unchanged for every harness.
  • The new parity test runs the same unlanded end_turn turn on every known backend and expects consumption only for the Kiro family. The session spec row says the same.

Auto-merge is already set by another maintainer, so I am not setting it.

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.

Merge-back: limit the merge-card consumption rule to named backends

3 participants