Repository navigation
feat(mcp): session_queue lets a sender list and reorder what it queued - #15423
Conversation
|
Intent: Give a session that queued messages with |
7d153d6 to
24c4cff
Compare
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the ownership-gated verb is aimed at a real gap, sits behind the existing gate and manager fence, and the reorder change is additive and documented. Notes
[DESIGN-REVIEWED] e736211 Description read[DESCRIPTION-READ] cf8fab3b3475d424e49db5a0e421ea6eca05c950c4d10e2d7dc66409d40cefee 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 |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the new verb answers a linked issue (#15421), and the base exposes only What this change shipsInventory (8 items) — 7 justifiedIntent: a session that queued messages on a busy session it manages can see them and reorder its own by priority. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] e736211 Description read[DESCRIPTION-READ] 7e43c7417a7e9343fda3a94d3eea3ac69a87568cebf389b3596deecfbe735e39 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
24c4cff to
adbe305
Compare
|
span=36bec42fc986
|
|
span=739080f4a6fa
|
iamwhatever
left a comment
There was a problem hiding this comment.
Reviewed. queue_target runs the same authorize_target as session_send plus a creator fence for every caller class; an entry counts as the caller's only when it is not the person's typed message, has no producer kind or _on_consumed callback, and carries a sender stamp matching the caller's slot and tab; cancel/move refuse anything else with not_your_entry and move_blocked, and the gate-to-write path is synchronous. Channel agents blocked, unattended conductors withheld. security_posture.py only extends the existing 'Session control read' row; the -12 in chat_handlers.py is the re-sort moved verbatim into chat_utils._reorder_queued_rows. Tests use real state and slots with mutation guards.
Non-blocking: the creator fence matches slot key only, so a new occupant of a reused deterministic key (cron-{job}) can read list excerpts but cannot mutate; no test drives a channel-linked or app-scoped caller through queue_target.
Head branch was pushed to by a user without write access
adbe305 to
449cb91
Compare
|
Rebased onto main c1a02ce after session_end_wait (#15166) landed. The conflicts were docs only: the tool lists in docs/architecture/mcp.md, the feature map and session-control.md now name both verbs, and the tool counts are now 25 tools and 15 session-control tools. No behaviour change; the queue tests and the registration and doc-count tests pass (396). |
|
note (non-blocking): Opus 5.5 Review lane run https://github.com/kirodotdev/KiroCrew/actions/runs/42547413884 needs a rerun. |
|
note (non-blocking): Static Ratchet Gate also fails on main, without this PR.
|
|
note (non-blocking): Build Desktop jobs https://github.com/kirodotdev/KiroCrew/actions/runs/42581206491/job/129040330163 (ubuntu-22.04) and https://github.com/kirodotdev/KiroCrew/actions/runs/42581206491/job/129040330297 (ubuntu-22.04-arm) need a rerun. |
|
note (non-blocking): Backend Tests (3.12, 3) also fails on main, without this PR.
|
|
note (non-blocking): Opus 5.5 Review lane run https://github.com/kirodotdev/KiroCrew/actions/runs/42729139652 needs a rerun. |
Code change approver recommendation: A person should decideAutomated, not a person, and not a review: a maintainer still decides.
Why: the decider approves but is not confident enough to auto-approve (p_defect 0.14 > 0.12). Adds a session_queue MCP verb (list/move) backed by a strict-internal route. It runs authorize_target plus a hard manager fence (_outside_reach with "queue" added to HANDOFF_WIDENED_OPERATIONS). An entry is the caller's only if the sender stamp matches both slot key and tab id, and only plain entries qualify, which matches what session_send's path writes (kind="", no callbacks). A move earlier may pass only the caller's own entries. A move follows the card's PUT .../queue/order path: memory change, shared row re-seat, queue_reorder broadcast, save left to the periodic flush. The shared _queued_row_id helper is consistent with the only meta.queueId writers (session_deliver's app twin and cron_inject, which stamps the same id in both spellings), and it fixes edit and reorder for app-twin rows. Tests are broad and include checks that fail if the key checks are removed. I found no regression, fail-open path or unmet goal. If this recommendation is wrong, reply here; the replies are how the approver is evaluated. |
|
note (non-blocking): Backend Tests (3.12, 6) job https://github.com/kirodotdev/KiroCrew/actions/runs/42728598752/job/129543865440 needs a rerun. Its one failure is the known flake #34256. |
|
note (non-blocking): Backend Tests (3.12, 3) job https://github.com/kirodotdev/KiroCrew/actions/runs/42744629267/job/129597693223 needs a rerun. Its one failure is the known flake #34284. |
|
note (non-blocking): Opus 5.5 Review lane run https://github.com/kirodotdev/KiroCrew/actions/runs/42745093084 needs a rerun. |
|
span=0062fac9ccad
Upheld. A steer that took the live path loses its delivery id in Tests: This PR passed the seam limit, so this round also narrows scope: mechanism: ownership reads a positive queued-send mark instead of excluding known requeue shapes resolution: narrowed -- yours now requires a marker only the session_send queue arms write, and remove and edit are back to main |
bolichen97
left a comment
There was a problem hiding this comment.
Design brief at ac3c28d. This is a comment, not an approval: the PR adds a new MCP tool, a new strict-internal route and a new handoff-widened verb, so the maintainer signs off on the direction.
What it does. session_queue(target, action=list|move, entry?, position?) lets a session that queued a session_send on a busy session it manages see that queue and reorder its own entries. Calls go through POST /api/session-control/queue to queue_target, which runs authorize_target and then _outside_reach(..., "queue"). The PR adds "queue" to HANDOFF_WIDENED_OPERATIONS, so after a handoff, queue access moves to the manager along with read and summary. An entry counts as "yours" only if it carries session_send_queued, has no kind or callback, and its sender stamp names the caller's slot and current tab. A move earlier may pass only your own entries. A person's typed message is never yours and is never passed.
Pros.
- A sender can finally see where a queued
session_sendsits, and move it later than other entries. - The reorder for the card's rows moves into the shared
_reorder_queued_rows, so app-twin rows now follow the order throughmeta.queueIdinstead of dropping to the end. - Entry excerpts are redacted for a non-human reader. Channel agents are blocked from the tool, and unattended conductors are held back until a skill step adopts it.
Cons / risks.
- It is a new way to write to another session's queue. It is bounded by the manager fence and the own-entries rule, but it is new reach, and that is the call to make here.
- Nothing calls the tool yet (the conductor grant is held back), so the first real use comes in a later PR.
- Cancel was left out on purpose, so a sender can move a queued send but cannot take it back.
Tech debt. Low. The verb lives in its own module and reuses the existing gates and the card's reorder path. It adds one more entry to the MCP surface and the docs counts.
Open from the earlier review. The spec now lists queue in HANDOFF_WIDENED_OPERATIONS, so that point is fixed. _QUEUE_FROM_LABELS is still re-exported from mcp_dashboard.py (L759). The earlier change request asked to drop it or link an issue for the follow-up.
Checks: 96 ok, 0 red.
|
chore (non-blocking): 2ab272c makes the label map a local, |
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 14% chance that this change introduces a defect, above the 12% limit for approving on its own. This PR adds a session_queue tool that lists a managed session's queue and moves only the entries the caller queued. It calls a new internal-only route. Access goes through authorize_target and then a manager check that applies to every caller, and handoff moves it with read and summary. Only session_send's queue arms write the new ownership mark. Requeued steers never get it, entries restored after a restart lose the sender stamp so they read as An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed at 2ab272c. The earlier open point is fixed: _QUEUE_FROM_LABELS is no longer a module name or re-exported from mcp_dashboard.py. _render_session_queue now uses a local from_labels.
Requesting changes on one point only, which I missed in my last pass: a new regex in product code. This repo's review rules do not accept new regex in product code.
validation_parts/messaging_session_schemas.py:_QUEUE_ENTRY_ID_RE = re.compile(r"^[A-Za-z0-9_-]{1,64}$"), passed aspattern=on theentryfield ofSESSION_QUEUE_SCHEMAand re-exported throughvalidation.py.
Two plain options:
- Drop the
patternand keepmax_len=QUEUE_ENTRY_ID_MAX_CHARS.queue_targetonly comparesentryfor equality with ids already in the queue, so any other string ends inentry_not_foundand nothing free-form is acted on. - If the token shape should still be checked at the schema, add a small check:
1 <= len(s) <= QUEUE_ENTRY_ID_MAX_CHARS and all(c in _QUEUE_ID_CHARS for c in s), with_QUEUE_ID_CHARS = frozenset(string.ascii_letters + string.digits + "_-"). Then drop the_QUEUE_ENTRY_ID_REexport fromvalidation.py.
Everything else I checked on this head is unchanged from what I read at ac3c28d, apart from that label move. 96 checks green.
|
chore (non-blocking): the new regex is gone, option 1 f9a8e0b removes |
|
chore (non-blocking): Backend Tests (3.12, 7) in run 42914845733 needs a rerun. It is flake #34543: a facade_mirror_guards tree scan timed out and worker gw2 crashed. |
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed at 9e4255e. My request for changes is resolved: _QUEUE_ENTRY_ID_RE and its pattern= are gone, along with the re-export through validation.py. The entry field now keeps only max_len=QUEUE_ENTRY_ID_MAX_CHARS, and the comment explains why: queue_target only compares it for equality with the ids already in the queue. I searched the saved diff for the old name, re.compile, new RegExp and /.../ literals in product files, and found none.
The only other changes since 2ab272c are a rebase update to the MCP route-table counts and digest, and a new test_move_of_free_text_is_not_found. That test sends a multi-line forged id and checks that it ends in entry_not_found with no raw newline in the error.
I read test/test_mcp_dashboard_session_queue.py in full. It covers:
- the
yours/person/otherlabels, including a reused-key tab mismatch, stamped person entries, producer entries with a kind or callback, and requeued steers in four meta shapes plus the real requeue path; - redaction and bounds on excerpts, ids and titles;
authorize_target, the manager fence and the handoff moving reach;- archived, incognito and self targets;
- no
cancel; - the move-earlier limit and the docs example;
- reseating both row spellings;
- one
allowedaudit, the verb not suspending, and no save of its own; - the strict-internal route and its error mapping, the tool posting the verified key, and rendering that keeps one row per entry whatever line breaks the text holds.
The maintainer has signed the direction. iamwhatever's earlier _QUEUE_FROM_LABELS point was fixed at 2ab272c. 95 checks green.
|
@iamwhatever both points from your change request at d9851f2 are addressed on 9e4255e. The spec's |
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed at 935fd2b, a rebase of the head I approved earlier. I read the whole diff on this head, tests included, and every check is green now.
session_queuelists a session's queue and moves only the entries the caller queued withsession_send. Ownership needs the slot key, the tab identity and the queued-send mark, so a person's message, another session's entry and a requeued steer are never movable. A move to an earlier position may pass only the caller's own entries.- The route is strict-internal, the tool is withheld from channel agents and from the conductor grant, and the verb does not suspend between its gate and its write.
- The two points from the earlier change request are in:
queueis inHANDOFF_WIDENED_OPERATIONSand in the spec text, and_QUEUE_FROM_LABELSis a local in_render_session_queue, not a re-export frommcp_dashboard.py. - No regex in product code. The entry id field keeps only a length bound.
A session that queues a session_send on a busy session it created can now see where that message sits and move its own entries, without touching anything a person or another session queued. - New session_queue(target, action=list|move, entry?, position?) tool, backed by the strict internal-secret POST /api/session-control/queue route and queue_target in dashboard/session_control_queue.py. - The target must pass authorize_target and be a session the caller created. move reaches only entries carrying the caller's sender stamp (slot key and tab id), and a move earlier may pass only the caller's own entries. - There is no cancel. A queued session_send to a worker bound to the caller's work ledger can already be stamped as the conductor's recorded answer (the hand-back from kirodotdev#19823), so removing it could leave a decision the worker never receives. - move takes the queue card's path: it reorders the in-memory queue and the queued rows through the shared _reorder_queued_rows helper and broadcasts queue_reorder. The helper now also matches an app-twin row by meta.queueId. - The route is counted by the session-control call counter (op folds to other), the tool is withheld from unattended conductors and blocked for channel agents, and it is documented in docs/session-control.md.
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed at e736211. This head is a rebase of the 935fd2b I approved earlier. I compared the PR's own diff on both heads (against their merge bases): every product file, test and doc line is identical. The only differences are two rebase updates that move with main: one route added to the MCP route table row and its digest in test_dashboard_server_composition_contract_reach.py (350 to 352 rows), and the work-ledger row of the feature map picking up a route main added. Nothing in session_queue, its ownership rule, its gates or its tests changed.
All checks are green on this head. My earlier review of the whole diff stands, including that there is no regex in product code.
Problem / Motivation
Goal: A session that queued a message with
session_sendcan see it in the target's queue and move it, without touching anything a person or another session queued.session_sendto a busy session queues the message and answersstarted: false. After that the sender has no handle on it. It cannot see where the message sits, and cannot change where it sits when its priority changes. The dashboard's queue routes (DELETE /api/chat/slots/{slot}/queue/{queue_id},PUT .../queue/order) are human routes that check app scope only, and thekirocrew-dashboardMCP server does not expose them.Why it matters
A session that sends follow-ups to a busy session it created can stack several in that session's queue, and the target runs them in arrival order even when a later one is more urgent. Today only a person can reorder the queue, by dragging the cards. The first caller is a person-attended session that used
session_send; unattended conductors stay withheld from the tool until a conductor skill step adopts it (see theagent.pynote).Not a goal
session_sendto a ledger-bound worker can already be stamped as the conductor's recorded answer, so removing it could leave a decision the worker never gets. Four review rounds each found a new race or fail-open read in guards for that, so cancel is left out of this PR and can come back as its own change with its own design.What changed (motivation → approach → change)
Goal: the sender of a queued
session_sendgets a handle on that entry. The card's queue routes check app scope and nothing else, so an MCP tool on top of them would let an agent delete a person's queued message. This PR adds a session-control verb with its own ownership rules instead.session_queue(target, action=list|move, entry?, position?)tool (src/kiro_crew/mcp_dashboard_session_tools.py,src/kiro_crew/mcp_dashboard_session_runs.py, re-exported fromsrc/kiro_crew/mcp_dashboard.py; schema insrc/kiro_crew/validation_parts/messaging_session_schemas.py, forwarded bysrc/kiro_crew/validation.py). It calls a new strict-internalPOST /api/session-control/queue(src/kiro_crew/dashboard/handlers/session_control.py, registered insrc/kiro_crew/dashboard/server.py, counted asother).queue_targetinsrc/kiro_crew/dashboard/session_control_queue.pyrunsauthorize_target, then the manager fence_outside_reach(..., "queue")for every caller class."queue"is inHANDOFF_WIDENED_OPERATIONS, so a handoff moves queue access withreadandsummary. Archived sessions returntarget_not_found.SESSION_SEND_QUEUED_META, which onlysession_send's two queue arms write, and itssend_origin_slotstamp names the caller's slot key and current tab id. A requeued steer keeps the stamp but never the mark, because the requeue builds its meta from the steer's admission. A person's entry, or one with a producerkindor a callback, never counts. The drain pops the mark before it writes a row.moverefuses other entries (not_your_entry); a move earlier may pass only the caller's own entries (move_blocked).listshows up to 50 entries in run order, each labelledyours,personorother, with a display-redacted excerpt cut to 200 characters and an id cut to 64. The rest are counted inomitted. Rendering collapses every whitespace run, so untrusted text cannot forge a row.movedoes what the card'sPUT .../queue/orderdoes: reorders the in-memory queue, re-seats queued rows, sendsqueue_reorder, and leaves the save to the periodic flush. No await sits between the gate and the change.src/kiro_crew/dashboard/chat_handlers.pymoved into_reorder_queued_rows(src/kiro_crew/dashboard/chat_utils.py), shared by both paths. It also matches an app twin'smeta.queueId, so that row no longer trails on reorder; a non-string id is skipped. Remove and edit keep main's behaviour.src/kiro_crew/channel.py), withheld from unattended conductors (src/kiro_crew/agent_parts/spec_grants.py), titled inmcp_tool_titles.json, and documented indocs/session-control.md, the docs index, the MCP architecture table, the feature map and the session-control module spec.Backwards compatibility
Compatible: a new tool and a new route. The reorder route's row handling moved into a shared helper. The one behaviour change is on app-twin queued rows: they now follow the card's new order instead of trailing it. Remove and edit are unchanged. Entries that
session_retry,session_continueor a recovery requeue put back carry the sender stamp without the queued-send mark, so they list asother.Tests
test/test_mcp_dashboard_session_queue.py: list labels and redaction, list bound, an oversized restored id cut to the cap, a stamp whose tab no longer matches readsother, a stamped person entry still readsperson, a stamped entry with a kind or callback readsother, a requeued steer readsotherandmoverefuses it in four meta shapes (delivery id, row mid only, possibly delivered only, bare admission), a real-path steer requeued with no echo readsotherwhile two real queued sends readyours, a credential-shaped restored id redacted, the gate isauthorize_target, the creator fence, archived/incognito/self refusals, move of own entries with its frame and no save of its own, refusal of person and peer entries, the move-earlier limit, move later past others, queued-row reseat for both row spellings, a malformed restored queue id skipped by the reorder helper, the verb completing without suspending, a singleallowedaudit, schema bounds, route internal-only and error mapping, strict route set, tool dispatch and rendering, one rendered row per entry whatever line breaks its text holds, a one-line header whatever the title holds, and a bounded title. The creator-fence and move-earlier tests fail when those checks are removed.test_cancel_is_not_an_actionasserts the verb refusesaction=cancelwithbad_actionand leaves the queue untouched, and that the schema rejects it.test_the_docs_example_reorders_by_moving_laterruns the three-entry layout fromdocs/session-control.md(yours, person, yours) throughqueue_target: moving the last entry to 0 is refusedmove_blocked, and moving the first entry to 2 gives the documented order.test_reorder_reseats_an_app_twin_rowintest/test_queue_reorder.pycovers the card's reorder route.Manual verification
N/A: the verb is a server-side route plus text rendering, covered end to end at the handler and MCP-dispatch level; there is no UI change.
Related Issues
Fixes #15421
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)