Skip to content

fix(dashboard): gate /todos on live and allocated capabilities - #17971

Merged
chenmingwei23 merged 1 commit into
mainfrom
push/13876-todos-live-capability
Oct 8, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
push/13876-todos-live-capability

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Let /todos reach the dashboard harness that actually serves the session, and only that one.

The dashboard blocks /todos with a static per-harness set
(_KIRO_ONLY_BLOCKED_SLASH_COMMANDS = {"/todos"} in chat_utils.py, added by
#13805). That set keys on a hard-coded harness identity, not on what the session
that would run the command can do: a harness that implements native /todos
(claude-agent-acp) still has it blocked, and a dead/evicted registry row, a
member-DM backend override, or a provider replaced between the pre-turn probe
and the claim can all make the pre-turn answer diverge from the harness that
actually serves the turn.

Why it matters

A user on a Claude harness cannot use the native /todos command the harness
supports, and the opposite error (forwarding /todos to a harness that cannot
serve it) sends prompt text to a backend that interprets it as an ordinary
request. The gate must track the live, allocated session, not a static identity.

Not a goal

  • No new user-visible surface beyond the existing /todos command and its
    autocomplete suggestion.
  • No change to how agent-authored task state is rendered — every harness keeps
    that; this is only the command-dispatch gate.
  • The unrelated learn-cron-dashboard.md doc churn the original fork PR carried
    is deliberately not included.

What changed (motivation → approach → change)

The /todos gate moved from chat_runner.py to chat_utils.py on main (#13805)
and SessionCapabilities grew several fields since the original fork PR, so this
re-authors the fork's live-capability gate onto main's current layout rather than
rebasing it.

  • New H6 capability SessionCapabilities.supports_native_todos, backed by
    ACP_BACKENDS_NATIVE_TODOS = {claude} and read fail-closed via
    capabilities_for / capabilities_of (unknown and newly registered backends
    stay refused). Classified in backend_cards.py OFF_CARD_SETS (it selects a
    command-dispatch path, not a task capability a reader loses).
  • _run_chat /todos gate: commands impossible on every harness stay a true
    pre-dispatch refusal; /todos is answered before acquisition by a
    positively-alive provider or the member-aware select_provider_backend(...);
    the acquired provider is the final authority and refuses after the claim when
    it lacks the capability, dispatching no prompt and preserving first-claim
    bookkeeping (a fresh claim re-arms the replay lease; a resumed claim keeps its
    native transcript and re-arms only member re-injection, honoring the
    replay-lease-forces-resumed-False invariant) plus any live Slack OPTIONS
    (deferred, then drained or cleared in the finally).
  • The sibling /compact gate is moved onto the same
    get_provider / is_provider_alive + member-aware selection, so a dead
    registry row can no longer answer for its get_or_create successor.
  • GET /api/slash-commands filters /todos from suggestions by the configured
    default backend's capability.
  • is_claude_backend_name stays imported in chat_runner.py (under noqa) as a
    base-surface re-export the composition contract requires; the identity branch
    that read it is gone.

Backwards compatibility

Compatible: nothing that works today stops working. /todos was globally blocked
in the dashboard; this only widens where it is allowed (a Claude harness) and
keeps it refused everywhere it was before. The capability defaults False for every
backend except Claude, matching the prior static behaviour on kiro/kas.

Removes nothing: no path is hidden, no record pruned, no validator tightened, no
key or public function removed. The one legacy claude_code+Kiro-backend case now
refuses /todos (it previously passed on the provider axis) — H2 admits only
provider=acp, so that label never selected the Claude harness; the refusal
corrects a path that would have forwarded an unservable command.

Tests

  • test_agent_sdk_capabilities.py — pins supports_native_todos per backend
    (Claude True, others False) and that the field has a consumer.
  • test_backend_cards.py — the new set is classified by the card.
  • test_api_slash_commands.py — /todos appears in suggestions only when the
    default backend supports it.
  • test_chat_runner_coverage.py — the acquired-provider authority after stale-row
    eviction; reprojected-claim confirmation; fresh-vs-resumed first-claim
    bookkeeping; deferred Slack-OPTIONS drain across early-failure and cancellation;
    member override vs global default both directions; busy-session and warm-refusal.
  • test_manual_compact_gate.py — /compact dead-row-successor and member-override
    cases.
  • test_chat_runner_composition_contract.py — the base-surface binding set still
    resolves.

682 passed locally across these files; flake8 / black / isort / mypy clean.

Manual verification

N/A — unit coverage is sufficient; this is a backend command-gate change with no
rendered delta.

Related Issues

Fixes #17970
Refs #8939
Replaces #13876 by @leonlaiyc

Pattern harvest

Not generalizable: this is a specific capability gate for one slash command;
the capability-set + capabilities_for pattern it uses is already the
established H6 shape, not a new rule to harvest.

@iamwhatever
iamwhatever requested a review from a team as a code owner October 8, 2026 03:11
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 351966fce2f36710cb400cbc048301ad53f9119e touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — 🟡 CONCERNS

Design-level review of 351966fce2f36710cb400cbc048301ad53f9119e — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

The description says the is_claude_backend_name import was dropped instead of carrying a # noqa, but the diff keeps the import and adds that # noqa.

Watch

  • Description claim with no code behind it. The description says it "Dropped the now-unused is_claude_backend_name import … rather than carrying a # noqa". The diff does the opposite: +from kiro_crew.agent_sdk.backend_identity import is_claude_backend_name # noqa: F401. Nothing in chat_runner.py uses the import any more. Keeping it leaves a dead harness-identity symbol in the one module this PR moves onto positive capabilities, so the next edit can bring back a not is_claude_backend_name branch without anyone noticing. The description also says the gate lives in chat_utils.py, but every gate hunk edits chat_runner.py.
    Clears when: the import line is deleted, or the description is corrected to match the diff.
  • One command now needs a refusal path inside a claimed session. Making the acquired provider the final authority for /todos adds a deferred Slack-OPTIONS flag that three sites must handle: the post-acquire refusal, the drain, and the finally. It also adds a choice between a replay lease and member re-injection inside _run_chat. Any future capability-gated command has to copy all of this by hand, or it will spend OPTIONS or lose first-claim context. The new tests cover the paths that exist today, but nothing makes a second gated command reuse them.
    Clears when: the post-acquire refusal (OPTIONS deferral plus first-claim re-arm) is one helper keyed on _KIRO_ONLY_BLOCKED_SLASH_COMMANDS, or the spec says that any added gated command must use this same path.

[DESIGN-REVIEWED] 351966f

Description read

[DESCRIPTION-READ] 3e10de38b95accb8264d4dd51dfd00531640e025bbf1344d5c8b3d2a4b09aaac

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of 351966fce2f36710cb400cbc048301ad53f9119e — 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: CONCERNS

The post-acquisition /todos re-check, with its replay-lease, reinjection and deferred Slack-OPTIONS bookkeeping, guards against a race nobody has reported. The pre-acquisition gate already removes the defect.

Not justified as shipped

  • Item 3 — oversized: the race behind it is only asserted ("a provider replaced between the pre-turn probe and the claim") and has no reproduction. The sibling /compact gate refuses before acquisition only. This mechanism adds _deferred_options_expiry at three sites, plus mark_provider_switch_replay and mark_needs_reinjection branches inside _run_chat.
    Subtraction: delete the _refused_native_todos block, _deferred_options_expiry and its two drains, and restore the unconditional expire_slack_options.
    Clears when: a reproduction shows get_or_create returning a harness that select_provider_backend did not predict.
  • Item 7 — zero consumers: the description says "Dropped the now-unused is_claude_backend_name import… rather than carrying a # noqa". The diff keeps it as import is_claude_backend_name # noqa: F401.
    Subtraction: delete the import and its name in test/test_chat_runner_composition_contract.py:238.
    Clears when: the import is deleted.
  • Item 6 — undeclared: the base pin ("claude_code", "", False) ("the claude harness answers on either provider axis") is flipped to refused. H2 supports the flip, but the description never mentions it.

What this change ships

Inventory (7 items) — 4 justified

Intent: let /todos reach the harness that actually serves the session, and only that one (FIX, #17970).

  1. /todos follows the member-selected backend and ignores dead registry rows — justified
  2. A new supports_native_todos capability, with Claude as its only member — justified
  3. /todos is re-checked after acquisition; a refusal re-arms replay/reinjection and defers Slack-OPTIONS expiry — oversized
  4. The /compact gate becomes member-aware and ignores dead rows — justified
  5. Slash suggestions list /todos when the default backend is Claude — justified
  6. The legacy claude_code label with the Kiro backend now refuses /todos — undeclared
  7. The unused is_claude_backend_name import is kept under noqa — zero consumers

[FIRST-PRINCIPLES-REVIEWED] 351966f

Description read

[DESCRIPTION-READ] a8dc83be2f82a26d5239a9096c7cbb0cec69e32b5c08c57c97cdfba552faf9ee

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

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 351966f

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 351966fce2f36710cb400cbc048301ad53f9119e: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

Live Slack OPTIONS controls can be expired on a /todos turn that never got past admission.

FINDING — src/kiro_crew/dashboard/chat_runner.py:19155 — _deferred_options_expiry is set True before the try. On a session whose harness supports native todos, a /todos turn can leave before acquisition: the member-slot refusal return, a wait_for_memory_preparation timeout, or a Stop during that wait. The outer finally then runs await expire_slack_options(state, session_key) and strikes through the live OPTIONS controls. The old code never reached the expiry on these exits, and the admission comment says they "retain queued intent until a later admitted turn" → Fix: in the finally, expire only when _memory_preparation_admitted is true. Alternatively, set _deferred_options_expiry = True right after _memory_preparation_admitted = True rather than before the try.

[OPUS-REVIEWED] 351966f

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 351966fce2f36710cb400cbc048301ad53f9119e: <one-sentence reason>

@iamwhatever
iamwhatever force-pushed the push/13876-todos-live-capability branch from cf6861e to 9d63f82 Compare October 8, 2026 03:31
@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 Oct 8, 2026
Replace the static per-harness /todos block with a capability gate on the
live, allocated session. A positively-alive provider answers from
SessionCapabilities.supports_native_todos; otherwise the member-aware
select_provider_backend picks the backend the factory would build. The
acquired provider is the final authority and refuses after the claim when it
lacks the capability, dispatching no prompt and preserving the first-claim
bookkeeping (fresh claims re-arm the replay lease; resumed claims keep their
native transcript and re-arm only member re-injection, honoring the #17689
replay invariant) and any live Slack OPTIONS.

The sibling /compact gate is moved onto the same get_provider/is_provider_alive
+ member-aware selection, so a dead registry row can no longer answer for its
get_or_create successor. ACP_BACKENDS_NATIVE_TODOS = {claude} is the H6 opt-in;
unknown and newly registered backends stay refused until their adapter joins
the table.

Fixes #17970
Refs #8939
Replaces #13876 by @leonlaiyc

Co-authored-by: Leon <276034861+leonlaiyc@users.noreply.github.com>
@iamwhatever
iamwhatever force-pushed the push/13876-todos-live-capability branch from 9d63f82 to 351966f Compare October 8, 2026 04:01
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention 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 Oct 8, 2026
@chenmingwei23
chenmingwei23 merged commit 94be69a into main Oct 8, 2026
111 of 112 checks passed
@chenmingwei23
chenmingwei23 deleted the push/13876-todos-live-capability branch October 8, 2026 05:57
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 8, 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.

fix(dashboard): gate /todos on live and allocated session capability (not a static harness set)

3 participants