Skip to content

feat(workflows): Kiro Workflows dashboard routes and chat-turn wiring - #25450

Open
kyleseaman wants to merge 4 commits into
feat/kas-wf-2b-enginefrom
feat/kas-wf-2c-dashboard
Open

kyleseaman wants to merge 4 commits into
feat/kas-wf-2b-enginefrom
feat/kas-wf-2c-dashboard

Conversation

@kyleseaman

@kyleseaman kyleseaman commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Off by default behind agent.kas_workflows (Developer › Feature Previews); with it off, behaviour is main's.

Problem / Motivation

Goal: When Crew's agent backend is Kiro Agent (KAS), a developer can turn on Kiro Workflows and launch, watch, answer and control KAS workflow runs from the dashboard, with every question or approval a run raises held for a person.

Why it matters

Kiro Agent is the default harness and ships its own workflow engine (recipes, multi-step runs, steps that park for input), but Crew drops the whole _kiro/workflow/* surface: a KAS chat cannot start a workflow, nobody sees a run's steps, and a step that asks a question stalls with no sign anywhere. A run left to channel auto-answer paths could have a person's answer given on their behalf.

Not a goal

  • Turning Kiro Workflows on by default. It stays a developer opt-in (agent.kas_workflows); with it off, Crew behaves exactly as main.
  • Replacing Crew's own workflows (workflow_run, saved Crew workflows). They keep running.
  • Workflows on other harnesses. KAS is the only engine that has them.
  • The session-message cards: they are their own PR (A in the stack).

What changed (motivation → approach → change)

The dashboard wiring around the engine.

Piece Where
/api/workflows/kas/*: recipes, runs, run and step controls, step transcripts, approvals, questions, reconnect handlers/kas_workflows.py, server_runtime/mcp_routes.py
Launch and observe turns claim the chat's session; a KAS plan handoff stays on the person's card under every mode (the chat model's own questions are _kiro/userInput, answered on main's elicitation card) chat_runner.py, chat_turn/*, chat_api/slot_approval.py, kas_workflows/chat.py (needs_a_person), providers/acp.py, providers/acp_turns.py
Rewind, edit-resend and regenerate past a live run are refused (409 rewind_workflow_running) chat_rewind.py, chat_regenerate.py
Boot recovery of interrupted runs; a steer into an observe turn queues instead server_runtime/workflow_startup.py, chat_delivery.py, state_parts/*
The chat's needs-you state counts a run parked on the person slot_projection.py
agent.kas_workflows becomes dashboard-editable for the Settings switch the UI PR draws; a change card reads turning it on as a widen handlers/core_config_schema.py, change_card_catalog_kinds.py

A request's project directory is confined to server-held roots before any filesystem use (CodeQL py/path-injection on _project_dir). Every route refuses unless the switch is on and the backend is Kiro Agent. Responses go through _redact_obj, and the handler is a registered sink. The feature map gains the API-only row.

Stack

Split out of #25395, which was over the 1 MB review cap. Merge bottom-up. Only a PR based on main gets CI (ci.yml and fast-gate.yml run on pull_request: branches: [main]), so each stacked PR is rebased onto main once the one below it merges. A and the B1a protocol PR do not depend on each other. C2's UI uses A's card, which is on main.

# PR Branch Base
1 #25470 (merged) feat/kas-wf-1-session-cards main
2 #25447 (merged) feat/kas-wf-2-backend main
3 #25449 feat/kas-wf-2b-engine main
4 #25450 (this PR) feat/kas-wf-2c-dashboard feat/kas-wf-2b-engine
5 #25459 feat/kas-wf-3-person-holds feat/kas-wf-2c-dashboard
6 #25466 feat/kas-wf-4-frontend feat/kas-wf-3-person-holds
7 #25471 feat/kas-wf-4b-frontend-ui feat/kas-wf-4-frontend

Backwards compatibility

Compatible: every route refuses while the switch is off; the chat-turn changes only act on KAS launch / observe messages and KAS plan handoffs, which do not exist with it off.

Removes nothing: only additions.

Tests

  • test_kas_workflows_parity_routes.py, _l4_recipes.py, _round5.py, _optin_gate.py, _boot_recovery.py, _chat_session.py, _round4_l2.py, _project_root.py, test_chat_runner_kas_observe.py, test_chat_mode_security.py, test_chat_runner_coverage_approval.py, test_kas_slot_needs_person.py, composition contracts (+28 lazy imports, +29 MCP routes).
  • Local gates on this head as for every Python PR in the stack.
  • Second commit (after the restack onto main): the KAS session fake takes main's new session_cwd keyword, chat_runner drops an unread kas_workflows.chat import that main's compose-binding test now refuses, and the parity-route waits use FALLBACK_TIMEOUT_SECS (flake ratchet K19).

Proof: not provable -- other: feature PR, not a fix; each behaviour has its own test named above.

Manual verification

N/A — the UI that calls these routes arrives in C1 / C2; route tests drive them through aiohttp here.

Screenshots / video

N/A — this PR changes no website file, so it has no rendered surface.

Sensitive change

This PR adds rows to src/kiro_crew/security_posture_sinks_gateway.py (SCR-watched): one row, for dashboard/handlers/kas_workflows.py. Nothing else
under the Sensitive Change Review globs changes. Draft for the owner to post as the review comment:

Sensitive change review

Head: 552b9b6

  • What rule changed: the redaction-sink registry gains one row, for dashboard/handlers/kas_workflows.py; no redactor, scanner or allowlist changes.
  • Before -> after: before, the new handler calls _redact_obj but sits in no registry; after, it is a named sink and the panel counts it. test_security_posture.py learns that _redact_obj( runs both scanners (exfil then credential, keys included).
  • Worst case if wrong: the dual-pass marker is too broad and a future single-scanner _redact_obj slips the disclosure check; every _redact_obj today runs both.
  • Evidence checked: every _redact_obj definition in the tree runs redact_exfiltration_urls then redact_credentials; every route body and error passes it.
  • Tools still work: no tool gate, approval or sandbox rule is touched; the rows are registry data the security panel counts.
  • Backward compatible: additive rows only; the redaction_paths count on the security panel goes up by the number of rows.
  • Existing tests: test_security_posture.py (omission detection, partial-coverage disclosure, stale-allowlist) passes unchanged in intent.
  • How to undo: revert this PR; the modules then fail the omission ratchet, which is the intended signal.

Related Issues

N/A — no tracking issue, by the owner's choice.

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

@kyleseaman
kyleseaman requested review from a team and KiroCrewCaptain as code owners October 28, 2026 21:41
@kyleseaman
kyleseaman requested review from dodgeblaster and removed request for a team October 28, 2026 21:41
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security_posture_sinks_gateway.py

  • No reasoning template for 552b9b6 yet.

How to clear this check:

  1. The PR author posts the template below as a PR comment, with
    every field filled (N/A needs a reason). Keep the
    Head commit line: it must name the current head SHA.
  2. The check turns green within a minute, with no push.
  3. A new push resets this check: post it again for the new head.

Only the author's comment counts this way. A reviewer can instead
paste the filled template into an "Approve" review on this head.
Merging still needs a reviewer's approval.

## Sensitive change review
- Head commit: 552b9b60184715417e5da2d99bb268d8e380ea2d
- What rule changed:
- Before -> after (what was allowed/blocked, now):
- Worst case if wrong (breaks commands / leaks secret / locks user out):
- Evidence checked (which sandbox result proves it):
- No regression:
  - Tools still work (which tools/commands were run, result):
  - Backward compatible (old config / old data / old callers still work, how checked):
  - Existing tests (which suites passed on this head):
- How to undo:

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

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 67be079a3c9e21f6b7202a9faa08c000a3104c16 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 28, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the feature is off by default and needs the backend to be Kiro Agent; a launch or observe turn needs a token that only the gated routes issue; it takes nothing away.

Notes

  • Every chat turn now calls get_router().note_chat_session(...) and schedule_reattach(...) in turn_admission.py, even with agent.kas_workflows off. That builds the router singleton and fills its per-slot maps on gateways that never use the feature, which goes against "with it off, behaviour is main's". Check chat_workflows_enabled() first, as slot_projection.kas_slot_needs_person already avoids get_router().
  • "Manual verification: N/A" covers the UI only. Before the switch is offered in Settings, run stream_observe and a held plan handoff (person_only, which waits until the turn's time limit) once against a real Kiro Agent session; CI only runs them against fakes.

[DESIGN-REVIEWED] 67be079

Description read

[DESCRIPTION-READ] 0063e914f04c6aff7de6bad9e615689d6c058ca6334c345431d4609f4005aafc

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 67be079a3c9e21f6b7202a9faa08c000a3104c16 — 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: every chat-turn change only acts when the agent.kas_workflows switch is on, which is off by default. Two additions in the diff are missing from the description.

Notes

  • Item 9 — undeclared: _kas_chat_redirect makes api_workflow_author, api_workflow_run and api_workflow_run_intent return 409 kas_workflows_in_chat in a KAS-enabled chat. The description says "Replacing Crew's own workflows … They keep running" but never mentions this refusal of new Crew workflows.
  • Item 10 — zero consumers: nothing in website/src or src calls GET /api/workflows/engine (grep workflows/engine finds only the route registration and one test), and the description's route table doesn't list it. Subtraction: remove api_workflow_engine and its route, and add them back in the stacked UI PR that reads them.

What this change ships

Inventory (10 items) — 8 justified

Intent: a developer who has opted in can launch, watch, answer and control KAS workflow runs from the dashboard, and every question a run raises waits for a person. ADDITION.

  1. Kiro Workflows API (/api/workflows/kas/*, 20 routes; switch and backend gated) — justified
  2. Chat turns that launch or observe a KAS run, using the chat's session — justified
  3. A KAS plan handoff always goes to the person's card, whatever the approval mode — justified
  4. Rewind, edit-resend and regenerate return 409 while a run is live — justified
  5. Interrupted runs reattach at boot and on the chat's next turn — justified
  6. A steer sent during an observe turn is queued instead — justified
  7. The sidebar's needs-input state counts a run waiting on a person — justified
  8. agent.kas_workflows can be edited from the dashboard; the change card treats turning it on as a widen — justified
  9. Creating a new Crew workflow in a KAS-enabled chat is refused with 409 — undeclared
  10. GET /api/workflows/engine reports which workflow engine is active — undeclared, zero consumers

[FIRST-PRINCIPLES-REVIEWED] 67be079

Description read

[DESCRIPTION-READ] 4b0a6bb5e718b4c5b00d44f4cee3a5758f3ce8a33a6407986eccc54d75b92fd1

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — 🔴 changes requested (blocking)

GPT 6.1 found at least one blocking issue that must be resolved before merging 67be079a3c9e21f6b7202a9faa08c000a3104c16. 2 of 3 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/dashboard/handlers/kas_workflows.py:627 -- Polling still approves and resumes runs after opt-out

await router.recheck_pending()
Trigger: With held KAS runs and the opt-in disabled, GET /api/workflows/kas/state passes _refusal; changing a pending ordinary-tool request’s chat from Normal to Trust makes recheck_pending() call _auto_approve(). State and runs polling also enqueue reconnect turns for interrupted runs.
Outcome: Polling approves the held tool or resumes a stale-owner run although the corresponding approval, resume and reconnect routes return 409.
Anchor: defect
Fix: Gate approval rechecks and automatic reconnect/reattach on the current opt-in, leaving disabled-mode reads side-effect-free.
Sites: src/kiro_crew/dashboard/handlers/kas_workflows.py:602, src/kiro_crew/dashboard/handlers/kas_workflows.py:624, src/kiro_crew/dashboard/chat_turn/turn_admission.py:1453

BLOCKING -- src/kiro_crew/dashboard/chat_rewind.py:315 -- Rewind refusals expose unredacted workflow names

"runs": kas_refusal["runs"],
Trigger: A live KAS run’s name contains credential-bearing text and the person rewinds an earlier message; mirror retains the raw name, and runs_since() carries it through rewind_refusal() into this response.
Outcome: The dashboard receives the credential-bearing name without either required redaction scanner; edit-resend exposes the same value.
Anchor: backend-security-controls
Fix: Apply the existing recursive credential-and-exfiltration redaction chain to both refusal response bodies.
Sites: src/kiro_crew/dashboard/chat_regenerate.py:677

BLOCKING -- test/test_kas_workflows_boot_recovery.py:176 -- Concurrency verification has an unbounded self-unblocked wait

await both_slots_taken.wait()
Trigger: A concurrency regression admitting only one reconnect makes the first callback retain its semaphore permit while waiting for the second arrival; neither this wait nor the enclosing recovery call has a timeout.
Outcome: The test hangs rather than reporting the failed concurrency invariant, leaving pytest-timeout to terminate the worker.
Anchor: tests-are-deterministic
Fix: Bound the event wait or enclosing recovery call with the existing named lost-run ceiling.
Sites: test/test_kas_workflows_boot_recovery.py:180

[BLOCK-MERGE] 67be079
[GPT-REVIEWED] 67be079

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1. Harm rung: MEDIUM. When the operator switches the feature off, the polls are meant to be read-only, but they still resume runs and approve held steps. Confirmed conditions:

  • With the switch off and a run still held, the state and runs polls pass through _refusal (src/kiro_crew/dashboard/handlers/kas_workflows.py:77-88).
  • api_kas_state then calls _auto_reconnect and recheck_pending without checking the switch (kas_workflows.py:621-627), and api_kas_runs calls _auto_reconnect (kas_workflows.py:598).
  • recheck_pending calls _auto_approve on the chat's current Trust mode (src/kiro_crew/kas_workflows/router.py:718), and _auto_reconnect sends reconnect turns (kas_workflows.py:282-286). turn_admission.py:1453 reattaches without a switch check.

The effect is visible and has an exit: Trust mode and the name-grant check still apply (router.py:777-797), and the operator can Stop the run. The fix is cheap: _refusal already loads the config, and the same switch check can wrap these three calls. That costs far less than the harm, so the finding stands.

F2 (fenced). Confirmed. rewind_refusal returns the raw name from runs_since (src/kiro_crew/kas_workflows/chat.py:275,301), and both 409 bodies send it without _redact_obj (src/kiro_crew/dashboard/chat_rewind.py:315, chat_regenerate.py:677). The other KAS routes do redact it. A model-written run name containing a credential is unusual but not contradictory, so I can't build a rarity record.

F3 (fenced). Confirmed. await both_slots_taken.wait() (test/test_kas_workflows_boot_recovery.py:175) and recover_on_boot (:179) have no timeout. The only trigger is a regression in exactly the behaviour the test exists to catch, which is an ordinary event. On Windows the hang aborts the whole job.

[ADJUDICATION] 67be079a3c9e21f6b7202a9faa08c000a3104c16 total=1 uphold=1 downgrade=0
UPHOLD F1 src/kiro_crew/dashboard/handlers/kas_workflows.py:627 reason=harm-warrants-remedy
[GPT-ADJUDICATED] 67be079a3c9e21f6b7202a9faa08c000a3104c16

[ADJUDICATION-FENCED] 67be079a3c9e21f6b7202a9faa08c000a3104c16 fenced=2 flagged=0
UPHOLD-FENCED F2 src/kiro_crew/dashboard/chat_rewind.py:315 -- The raw run name reaches both 409 bodies without the redaction every other KAS route applies, and a model-written name carrying a credential is uncommon but not contradictory.
UPHOLD-FENCED F3 test/test_kas_workflows_boot_recovery.py:176 -- The wait and recover_on_boot are both unbounded, and the only trigger is the regression the test exists to catch, which is an ordinary event.
[GPT-ADJUDICATED-FENCED] 67be079a3c9e21f6b7202a9faa08c000a3104c16

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

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — 🔴 changes requested (blocking)

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

KAS workflow step approvals ignore the YOLO scoping that the chat's own tool calls obey, so a channel-linked chat auto-approves every workflow step under --approval yolo. Separately, with agent.kas_workflows off, a dashboard poll still resumes runs, and a queued launch can be lost.

BLOCKING — src/kiro_crew/dashboard/chat_turn/tool_approval.py:290
yolo = bool(state.is_yolo_active()) / if yolo or _slot_is_trusted(slot): return "trust", _auto_approve_reason(slot, yolo)
Trigger: The gateway runs with kirocrew gateway --approval yolo, so is_cli_launch is True. A chat is linked to a Slack or Discord channel (linked_session_key is a channel key, or _slack_channel is set) and runs a KAS workflow. Each step's permission request goes _turn_admit → note_chat_session(..., _kas_step_mode_reader(state, slot)) → router._auto_approve, which acts on reader() returning MODE_TRUST and never re-checks yolo_reaches.
Outcome: yolo_reaches returns False for this slot, so the chat's own tool calls keep asking (tool_approval.py:1419, :357). Every workflow step tool call is auto-approved and logged with reason "yolo". The channel-boundary scoping of the YOLO grant is bypassed for workflow steps.
Anchor: residual/security
Fix: Compute yolo = state.is_yolo_active() and state.yolo_reaches(slot), the same way tool_approval.py:357 does.

BLOCKING — src/kiro_crew/dashboard/handlers/kas_workflows.py:624
await _auto_reconnect(request, router) / await router.recheck_pending()
Trigger: An operator turns agent.kas_workflows off while the router still holds a run, and that run's chat runtime is then recycled. _refusal lets workflow.kas.state through (_READ_ONLY_WHEN_HELD). The dashboard's poll then runs _auto_reconnect → due_reconnects → _send_reconnect → reconnect turn → router.reattach. For a run paused as stale, reattach calls METHOD_RESUME (router.py:1459). Nothing on that path checks kas_workflows_enabled.
Outcome: The run resumes, and held steps get auto-approved, after the operator switched the feature off. _refusal's own contract says resume is refused while the switch is off, and here a plain GET triggers it.
Anchor: defect
Fix: In api_kas_state (and api_kas_runs), skip _auto_reconnect and recheck_pending unless kas_workflows_enabled(config) is true.

BLOCKING — src/kiro_crew/dashboard/handlers/kas_workflows.py:693
started = slot.enqueue_or_run_prompt(launch.message(run_label or name or source.strip()), _run_chat, state)
Trigger: dashboard.merge_queued_messages is on and the chat is busy. The launch marker is queued with no kind and no turn actor. The person then types a follow-up, which also has no turn actor. _dequeue_next_message merges the two into "[2 queued messages merged]\n\n...", so _LAUNCH_RE's ^Start workflow anchor no longer matches and is_turn_action returns False.
Outcome: The route already answered 202, but the workflow never starts. The marker, with its launch token, is sent to the model as ordinary prompt text.
Anchor: defect
Fix: Queue launch and reconnect markers under a non-merging gateway_prompt_kind, or another structural kind the merge stops at.

[BLOCK-MERGE] 67be079
[OPUS-REVIEWED] 67be079

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 67be079a3c9e21f6b7202a9faa08c000a3104c16 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 Oct 28, 2026
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2c-dashboard branch from 102dbec to 87d2e9d Compare November 2, 2026 16:29
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 2, 2026
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2b-engine branch from d4da76b to bd01ffa Compare November 2, 2026 17:57
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2c-dashboard branch from 87d2e9d to 2e1f8d3 Compare November 2, 2026 17:57
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2b-engine branch from bd01ffa to 3a99302 Compare November 2, 2026 18:02
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 2, 2026
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2c-dashboard branch from 2e1f8d3 to 4c1d139 Compare November 2, 2026 18:19
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2b-engine branch from 6e81460 to 49e0654 Compare November 6, 2026 18:45
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2c-dashboard branch from 2f734ed to 781f017 Compare November 6, 2026 19:05
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 6, 2026
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2b-engine branch from 49e0654 to d171853 Compare November 6, 2026 20:29
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 6, 2026
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2b-engine branch 8 times, most recently from ce49ae4 to 93ddbaf Compare November 12, 2026 05:50
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2c-dashboard branch from 781f017 to 67be079 Compare November 12, 2026 06:37
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 12, 2026
Kyle Seaman added 2 commits November 12, 2026 07:31
The engine half of Kiro Workflows on Kiro Agent: the router that
launches runs on the parent chat's own KAS process, routes each
runtime's workflow frames into the one run mirror, holds step approvals
and questions (kas_workflows/router.py, asks.py, policy.py), reads a
step's transcript (transcript.py), and recovers interrupted runs; the
ACP runtime and session-handle hooks that carry those frames and the
observed engine turns (acp/workflow_sink.py, session_handle_kas.py,
runtime_*); and the live-capture recorder (scripts/capture_kas_workflow.py).

A project directory a caller names is resolved and confined to
server-held roots (home, KIROCREW_PROJECT_DIR, recent projects) before
any filesystem use (kas_workflows/project_root.py). Router, asks and
transcript redact the text they hand to any surface, and are registered
as redaction sinks. All of it is inert unless agent.kas_workflows is on
and the backend is Kiro Agent.
…line cap

kas_workflows/router.py was 2,829 lines, over the repository's file line cap.
Its types, limits and pure helpers move to router_base.py, and three groups of
KasWorkflowRouter methods move to owner modules the class binds back by name
(own_methods), the pattern AcpRuntime and AcpSessionHandle use:
router_reads.py (requests, rows, recipes, run lists, step transcripts),
router_controls.py (run, step and recovery controls) and router_recovery.py
(ledger, reconnects, boot recovery). router.py keeps the class, every method
that redacts, the module entry points and the singleton, and imports every
moved name, so router.<name> still resolves for callers and tests. Every
redactor call stays in router.py, the module the security posture registry
names; the new modules call none. The moved code is AST-identical except one
line in schedule_reattach that unpacks the binding before the closure, so
mypy can type it.

scripts/capture_kas_workflow.py reads the kiro-cli and Kiro Agent versions after
the drive instead of before it: kiro-cli extracts its engine on the first acp
spawn, so a fresh HOME has no @kiro/agent package.json until then.

The new waits in test_acp_observe_turn.py, test_kas_workflows_parity.py and
test_kas_workflows_step_user_input.py take their bound from kiro_crew.testing.wait
(default_timeout, or async_wait_until's own default) instead of a short literal,
as the flake ratchet's K19 rule asks.

A KAS question the chat itself asks (_kiro/userInput) is left to main's
elicitation path, which holds it for a person under every approval mode. The
workflow surface answers only a step's question, one on a session nobody reads,
and one its sink fails on, each "answered" with text built by
acp.elicitation's user_input_response, so a dismiss, deny, blank answer or
failure never sends a reply KAS reads as yes. With the switch off, only a KAS
chat's session/new says workflows.enabled:false. The kas_client_capabilities
toggle is gone: main declares userInput on every KAS handshake.

A step's command is resolved once, from KAS's _meta.kiro.command and the
call's rawInput, for the deny screen, the grant key and every approval mode;
a command named in a shape it cannot read, or two that disagree, is held for a
person and never matched by a grant. Run and step routes are kept only for runs
the mirror holds and go when it evicts them, and a step ask's answer task
counts against the runtime's shared answer cap. agent.kas_creator_effort,
AcpEvent.answers_only and the chat question-card helpers are gone: nothing in
the stack reads them.

Every value the router keeps from a KAS frame or a launch is bounded where it
is stored: titles, options, plan views, question ids, launch fields and
reconnect tokens are capped, and an id or grant input over its cap is refused
or gets no grant, never cut. Inspections run only for runs the mirror holds, and
the mirror refuses a run id over its cap instead of cutting it.

A step's permission request or question is claimed by the router only while the
run's chat has an approval-mode reader registered (note_chat_session), read at
request time. With none, nothing would ever answer a held request, so the
runtime's own fail-closed reply answers it: the permission is rejected and a
question gets the no-answer reply.

A person's "Always" on a step's tool is sent to KAS as allow-once on every
path, so Crew's own step grant is the only "always"; the grant is recorded only
when the call has a grant key, and the card says "once" when it has none. A step
that offers only an always-allow is refused and stays held, so it can still be
rejected. A request that names a command is never taken for a plan handoff.
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2b-engine branch from 93ddbaf to d6acbd5 Compare November 12, 2026 07:45
Kyle Seaman added 2 commits November 12, 2026 07:45
The dashboard half of Kiro Workflows on Kiro Agent: the
/api/workflows/kas/* routes (recipes, runs, run controls, step
transcripts, approvals, questions, reconnect), the chat-turn wiring that
starts a launch or observe turn on the chat's own KAS session, keeps a
KAS plan or question on the person's card under every approval mode,
refuses a rewind / edit-resend / regenerate past a live run (409
kas_rewind_refused), and boot recovery of interrupted runs.

A request's project directory is confined to server-held roots before
any filesystem use. Every route refuses unless agent.kas_workflows is on
and the backend is Kiro Agent; responses are redacted and the handler
is registered as a redaction sink.
- The KAS session fake takes main's new session_cwd keyword.
- chat_runner no longer imports kas_workflows.chat: nothing reads it there,
  and main's compose-binding test now refuses an unread runner import.
- The parity-route waits use FALLBACK_TIMEOUT_SECS (K19); the turn-ceiling
  stub carries flake-ok, since nothing waits on it.
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2c-dashboard branch from 67be079 to 552b9b6 Compare November 12, 2026 08:06
@kyleseaman
kyleseaman force-pushed the feat/kas-wf-2b-engine branch from d6acbd5 to 91df23c Compare November 12, 2026 08:54
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant