Skip to content

fix(acp): run a Kiro CLI pick on KAS outside the gateway too - #25808

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/kiro-pick-kas-outside-gateway
Oct 29, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/kiro-pick-kas-outside-gateway

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A stored Kiro CLI harness pick runs on Kiro Agent (KAS) in every Kiro Crew process where the installed kiro-cli offers its v3 engine, not only inside the gateway.

A user who stored agent.acp_backend: "kiro" has that pick moved onto Crew's KAS path only inside the gateway. The evidence that kiro-cli offers v3 is process-local — confirm_kiro_cli_offers_kas() is set only by the gateway's KAS floor — so kirocrew chat (and the eval, task and consolidation processes) still starts the bare v2 kiro-cli acp launch. Where kiro-cli already serves a bare acp on v3, that launch drives a v3 engine as the v2 harness (wrong skill-view aliases, cli.json overlay and re-filtered specs).

Why it matters

Once kiro-cli serves v3 by default, a Kiro CLI pick run outside the gateway hits the v3-driven-as-v2 mismatch the KAS-pick decision exists to prevent: the terminal chat and background runs would silently diverge from the gateway for the same user on the same config.

Not a goal

  • Does not change behaviour for any backend other than a stored Kiro CLI pick — default / kas / claude / codex pay no probe and start exactly as before.
  • Does not move a Kiro CLI pick onto KAS on a kiro-cli without v3, on the bundle route, or where policy denies KAS.
  • Does not rewrite the stored value, change the gateway path, or touch kirocrew doctor (already correct).

What changed (motivation → approach → change)

Root cause: the v3 evidence is process-local and only the gateway floor records it. Approach: of the two options (a per-process bounded probe, or a cached verdict keyed on the pinned kiro-cli version), take the per-process probe — it reuses the exact mechanism and positive-evidence-only rule the gateway floor already uses, adds no persistence or cache-invalidation surface, and cannot promote on a stale verdict after a kiro-cli downgrade.

Change: add ensure_kiro_cli_kas_verdict() beside the existing process flag. It returns when evidence is already recorded; gates on two cheap document reads (acp_backend_stored_as_kiro, acp_backend_bundle_route) so it probes only for a Kiro CLI pick off the bundle route; otherwise runs the one bounded acp --help probe and records the verdict on positive evidence only. It is probe-once and lock-guarded, so concurrent callers run the spawn exactly once. Every non-gateway process that loads config and spawns an ACP agent calls it before its config load: cli_chat._chat, cli_commands_eval._run_eval, cli_server._run_task, cli_knowledge._consolidate_cmd. The bundle-route and policy-denied cases keep the v2 launch, matching the gateway floor.

Backwards compatibility

Compatible: the change is purely additive — a new helper and four call sites, each gated on the stored pick being Kiro CLI off the bundle route. No field, kind, validator or key is rejected, renamed or removed.

Removes nothing: no path is hidden, no record or key deleted, no validator tightened, no public function removed; a non-kiro backend takes exactly the path it took before.

Tests

  • test/test_cli_chat.py::test_a_stored_kiro_pick_runs_on_kas_in_cli_chat — end-to-end through the CLI entry: a stored kiro pick with a v3-positive probe resolves to KAS at the provider factory.
  • test/test_acp_backend_kas.py::TestAProcessOutsideTheGatewayReachesTheSameVerdict — the helper: positive-evidence promotion, unknown/gap keep v2, non-kiro backend spends no probe, bundle route spends no probe, KAS-not-selectable spends no probe, probe-once, and concurrent callers probe exactly once.

Proof: not provable -- prove.py is not installed on this host; the CLI end-to-end test is confirmed to fail on origin/main (provider factory handed the v2 launch, '') and pass on the branch (kas).

Manual verification

N/A — unit coverage sufficient: the config-load remap and all four call sites are exercised by the tests above.

Screenshots / video

N/A — no user-visible frontend surface is touched (backend harness resolution only).

Related Issues

Part of #25288. Fixes #25695.

Sibling sweep

Swept: git grep -nE "acp_backend_stored_as_kiro|kiro_cli_pick_backend|confirm_kiro_cli_offers_kas" -- src/
Sibling: src/kiro_crew/platform/bootstrap.py:apply_kas_cli_floor -- not affected -- the gateway floor already records the verdict and already declines the bundle route; this helper mirrors its rule for non-gateway processes.
Siblings: none other -- the gap is specific to processes that never run the floor, which are the four spawn entries wired here.

Pattern harvest

Not generalizable: this is a single process-local-evidence gap specific to the KAS-pick promotion; the fix is to reach the same verdict the gateway floor already establishes.

Checklist

  • At most two commits (one), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable) — N/A, no doc-coupled change
  • No secrets, credentials, or internal references in the diff

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

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision a801fa92d4fe2a8966d250a6d50efea2f81cef82 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 Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the per-process probe uses the gateway floor's own evidence and promotion rule, and only a stored Kiro CLI pick off the bundle route runs it.

Notes

  • The decision entry docs/decisions/2026-10-28-a-kiro-cli-choice-runs-on-kas.md still says "once the gateway's check confirms". The behaviour now covers every process that spawns an agent. Ask a maintainer whether that wording needs a superseding entry rather than relying only on the spec edits.
  • Process-local evidence now has two writers: the floor and this helper. Any new spawn entry point (another runner, MCP-spawned work) silently falls back to v2 unless someone remembers to add this call. Calling it once from the shared config-load or provider-factory path would remove that per-entry duty.

[DESIGN-REVIEWED] a801fa9

Description read

[DESCRIPTION-READ] dd9d1aadad59411f19b07abf3093362df444d7b835f1d339fb2f2ccc26861923

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

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

The fix sits at the cause: non-gateway spawn entries now get the same v3 evidence the gateway records. The four call sites cover every non-gateway build_provider_factory/SessionManager constructor. The only extra surface is a lock that no caller needs.

Notes

  • Item 7 — oversized: the comment says "a peer server or an app could reach it from more than one thread", but all 4 callers (cli_chat._chat, _run_eval, _run_task, _consolidate_cmd) make one call each on a single thread before the first spawn. Zero callers reach it from more than one thread. Subtraction: delete _kiro_cli_kas_probe_lock, the re-read inside it and test_concurrent_callers_probe_exactly_once, and keep the plain _kiro_cli_kas_probed check. Clears when: the mechanism is removed, or a human amends the Goal.

What this change ships

Inventory (8 items) — 7 justified

Intent: a stored Kiro CLI pick should run on KAS in every Kiro Crew process where kiro-cli offers v3, as docs/decisions/2026-10-28-a-kiro-cli-choice-runs-on-kas.md records. FIX.

  1. kirocrew chat with a stored "kiro" pick now runs on KAS where kiro-cli offers v3 — justified
  2. The eval runner does the same — justified
  3. kirocrew task runs do the same — justified
  4. History consolidation does the same, and reloads config before building its factory — justified
  5. The first start of these processes with a Kiro CLI pick now spawns one bounded acp --help probe — justified
  6. New document reader acp_backend_bundle_route (one consumer) — justified
  7. Thread lock around the probe-once check — oversized: no caller runs it from more than one thread
  8. The acp-client, config and harness-parity H1 specs now say "this process" instead of "the gateway" — justified

[FIRST-PRINCIPLES-REVIEWED] a801fa9

Description read

[DESCRIPTION-READ] ed78e7bcd37dbfe9751c2e4f0fd6ea5ab8898e49901f7ad259c56267a15bb24f

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] a801fa9

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

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

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a801fa9

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

@chenmingwei23
chenmingwei23 force-pushed the fix/kiro-pick-kas-outside-gateway branch from a17cd90 to 37b6d88 Compare October 29, 2026 16:46
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Re: Opus 5.5 review — fixed in 37b6d88.

The per-process helper now declines the bundle route, matching the gateway floor. ensure_kiro_cli_kas_verdict() gates on a new cheap document read acp_backend_bundle_route() alongside acp_backend_stored_as_kiro(): when agent.kas_bundle is on it returns early without probing or promoting, so the CLI/eval/task/consolidation processes keep the pick on kiro-cli exactly as apply_kas_cli_floor does. Both now share the same predicate (the stored-document readers in loader_document). Covered by test_the_bundle_route_spends_no_probe.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Re: GPT 6.1 review — fixed in 37b6d88.

test_concurrent_callers_probe_exactly_once now bounds every wait: the threading.Barrier carries a 10s timeout, starts are wrapped in try/finally, and if a Thread.start() is rejected the barrier is aborted so parked threads return instead of blocking forever. Each thread is then joined with a 15s timeout and the test asserts none is still alive, so a start failure fails the test rather than stranding non-daemon threads and stalling the shard.

@chenmingwei23
chenmingwei23 force-pushed the fix/kiro-pick-kas-outside-gateway branch from 37b6d88 to c8a61c4 Compare October 29, 2026 17:02
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Re: Opus 5.5 review — fixed in c8a61c4.

The owning specs now match the code. harness-parity.md H1 names ensure_kiro_cli_kas_verdict and the four non-gateway entry points (chat, eval runner, task runner, consolidation) as the second place the v3 evidence is set, drops "another process" from the keeps-v2 list, and adds TestAProcessOutsideTheGatewayReachesTheSameVerdict and test_cli_chat.py::test_a_stored_kiro_pick_runs_on_kas_in_cli_chat to the Pinned-by column (plus ensure_kiro_cli_kas_verdict to Constrains). acp-client.md's Kiro CLI launch bullet now says the pick leaves the v2 launch once this process confirmed v3 — the gateway floor at boot or the per-process probe before a non-gateway spawn. config.md's harness-choice record is updated the same way (a process that never confirms it — an MCP server, a kiro-cli without v3, the bundle route — still reads kiro).

A stored Kiro CLI pick (agent.acp_backend: "kiro") moves onto Crew's KAS
path only inside the gateway, because the evidence that kiro-cli offers its
v3 engine is process-local: confirm_kiro_cli_offers_kas() is set only by the
gateway's KAS floor. A process that never runs the floor still starts the v2
kiro-cli acp launch, which is driven as v2 even where kiro-cli serves v3.

Add ensure_kiro_cli_kas_verdict(): gated on the stored pick being Kiro CLI
and the bundle route being off (two cheap document reads, no spawn for a
default/kas/claude/codex backend, and the bundle route stays on kiro-cli just
as the gateway floor keeps it). It runs one bounded acp --help probe at most
once per process -- lock-guarded for concurrent callers -- and records the
verdict on positive evidence only, the same promotion rule the floor uses.
Every non-gateway spawn entry (kirocrew chat, the eval runner, the task
runner, history consolidation) calls it before its config load, so the pick
reads as KAS the same way the gateway reads it. The gateway path and kirocrew
doctor are unchanged.

Part of #25288. Fixes #25695.
@chenmingwei23
chenmingwei23 force-pushed the fix/kiro-pick-kas-outside-gateway branch from c8a61c4 to a801fa9 Compare October 29, 2026 17:57
@chenmingwei23
chenmingwei23 marked this pull request as ready for review October 29, 2026 18:42
@chenmingwei23
chenmingwei23 requested review from a team and KiroCrewCaptain as code owners October 29, 2026 18:42
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 29, 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.

Approved on behalf of the watch holder (bolichen). Design and First Principles pass on this head (or skipped / author override), UX skipped or pass, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit 310dffb into main Oct 29, 2026
96 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/kiro-pick-kas-outside-gateway branch October 29, 2026 19:51
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A Kiro CLI pick run outside the gateway still starts bare kiro-cli acp

2 participants