Skip to content

feat(mcp): session_queue lets a sender list and reorder what it queued - #15423

Merged
bolichen97 merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/mcp-session-queue
Nov 12, 2026
Merged

bolichen97 merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/mcp-session-queue

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A session that queued a message with session_send can see it in the target's queue and move it, without touching anything a person or another session queued.

session_send to a busy session queues the message and answers started: 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 the kirocrew-dashboard MCP 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 the agent.py note).

Not a goal

  • Editing queued text.
  • Cancelling a queued entry. Since fix(work-ledger): stamp the hand-back when a session_send answers a waiting item #19823 a queued session_send to 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.
  • Changing the human queue routes or the queue card, apart from the shared reorder helper: the card's reorder now also matches an app twin's row (see Approach). Remove and edit are unchanged.
  • Recovering sender identity for entries restored after a gateway restart (the restore path drops the sender stamp on purpose).
  • A generic tool-registration framework.

What changed (motivation → approach → change)

Goal: the sender of a queued session_send gets 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.

  • New 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 from src/kiro_crew/mcp_dashboard.py; schema in src/kiro_crew/validation_parts/messaging_session_schemas.py, forwarded by src/kiro_crew/validation.py). It calls a new strict-internal POST /api/session-control/queue (src/kiro_crew/dashboard/handlers/session_control.py, registered in src/kiro_crew/dashboard/server.py, counted as other).
  • queue_target in src/kiro_crew/dashboard/session_control_queue.py runs authorize_target, then the manager fence _outside_reach(..., "queue") for every caller class. "queue" is in HANDOFF_WIDENED_OPERATIONS, so a handoff moves queue access with read and summary. Archived sessions return target_not_found.
  • An entry is the caller's only when it carries SESSION_SEND_QUEUED_META, which only session_send's two queue arms write, and its send_origin_slot stamp 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 producer kind or a callback, never counts. The drain pops the mark before it writes a row. move refuses other entries (not_your_entry); a move earlier may pass only the caller's own entries (move_blocked).
  • list shows up to 50 entries in run order, each labelled yours, person or other, with a display-redacted excerpt cut to 200 characters and an id cut to 64. The rest are counted in omitted. Rendering collapses every whitespace run, so untrusted text cannot forge a row.
  • move does what the card's PUT .../queue/order does: reorders the in-memory queue, re-seats queued rows, sends queue_reorder, and leaves the save to the periodic flush. No await sits between the gate and the change.
  • The card route's row reorder in src/kiro_crew/dashboard/chat_handlers.py moved into _reorder_queued_rows (src/kiro_crew/dashboard/chat_utils.py), shared by both paths. It also matches an app twin's meta.queueId, so that row no longer trails on reorder; a non-string id is skipped. Remove and edit keep main's behaviour.
  • Blocked for channel agents (src/kiro_crew/channel.py), withheld from unattended conductors (src/kiro_crew/agent_parts/spec_grants.py), titled in mcp_tool_titles.json, and documented in docs/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_continue or a recovery requeue put back carry the sender stamp without the queued-send mark, so they list as other.

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 reads other, a stamped person entry still reads person, a stamped entry with a kind or callback reads other, a requeued steer reads other and move refuses it in four meta shapes (delivery id, row mid only, possibly delivered only, bare admission), a real-path steer requeued with no echo reads other while two real queued sends read yours, a credential-shaped restored id redacted, the gate is authorize_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 single allowed audit, 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.
  • No cancel: test_cancel_is_not_an_action asserts the verb refuses action=cancel with bad_action and leaves the queue untouched, and that the schema rejects it.
  • Existing tool-set, doc-count and running-reader enumerations updated for the new verb.
  • test_the_docs_example_reorders_by_moving_later runs the three-entry layout from docs/session-control.md (yours, person, yours) through queue_target: moving the last entry to 0 is refused move_blocked, and moving the first entry to 2 gives the documented order. test_reorder_reseats_an_app_twin_row in test/test_queue_reorder.py covers 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

  • 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

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Intent: Give a session that queued messages with session_send a way to list, cancel and reorder those messages in a session it created, while a person's queued message and another session's stay untouchable.
Not a goal: editing queued text, changing the human queue routes or the queue card, recovering sender identity for entries restored after a restart, or a generic tool-registration framework.

@Pearcekieser
Pearcekieser marked this pull request as ready for review September 30, 2026 14:44
@Pearcekieser
Pearcekieser requested a review from a team as a code owner September 30, 2026 14:44
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of e736211c8a6564ce7820b26fbfbda04415a98eaa via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Ownership needs three things to match: the queued-send mark, the sender's slot key and its tab id. A restart drops the stamp, and a tab-less caller owns nothing. The doc already says so. Callers may find the tool does nothing in more cases than they expect, so check that before a conductor skill adopts it.

[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 .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 Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of e736211c8a6564ce7820b26fbfbda04415a98eaa via the fork AI-review pipeline — 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: the new verb answers a linked issue (#15421), and the base exposes only queue_depth for agents, with no listing and no sender-scoped reorder.

What this change ships

Inventory (8 items) — 7 justified

Intent: a session that queued messages on a busy session it manages can see them and reorder its own by priority. This is an ADDITION.

  1. New session_queue MCP tool: list a managed session's queue, labelled yours/person/other, as redacted excerpts — justified
  2. move reorders only the caller's own session_send entries, and a move earlier can never pass someone else's entry — justified
  3. New strict-internal POST /api/session-control/queue route, counted as other — justified
  4. session_send queue entries now carry a queued-send mark, so a requeued steer is not counted as the caller's — justified
  5. After a handoff, queue access moves to the new manager (HANDOFF_WIDENED_OPERATIONS gains queue) — justified
  6. The tool is blocked for channel agents and withheld from unattended conductors — justified
  7. Dragging a card on the person's queue card now also moves an app's queued row in the transcript instead of leaving it at the back — rides along (declared; it has its own test)
  8. Docs, tool title and tool-count updates — justified

[FIRST-PRINCIPLES-REVIEWED] e736211

Description read

[DESCRIPTION-READ] 7e43c7417a7e9343fda3a94d3eea3ac69a87568cebf389b3596deecfbe735e39

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed e736211c8a6564ce7820b26fbfbda04415a98eaa via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e736211

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed e736211c8a6564ce7820b26fbfbda04415a98eaa via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] e736211

@Pearcekieser

Pearcekieser commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

span=36bec42fc986
issue (blocking): fixed in adbe305

  • Queue entry IDs bypass the per-field response bound

fixed: queue_target now emits each id through _queue_entry_id, which cuts an id over QUEUE_ENTRY_ID_MAX_CHARS (64, the same constant the entry argument's schema uses) and marks the cut.
An id that long could never be named back to cancel or move, so cutting it loses nothing the caller can act on.
Test: test_an_oversized_restored_id_is_cut_to_the_argument_cap puts a 5000-character restored id in the queue and asserts the listed id is 64 characters plus the marker.

@Pearcekieser

Pearcekieser commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

span=739080f4a6fa
chore (non-blocking): fixed in adbe305

  • Item 6: chars has no consumer

fixed: the per-entry chars field is deleted from the queue_target response. The renderer never read it and the route has no other caller.
The oversized-id test also asserts the entry keys are exactly id, position, from and excerpt.

@github-actions github-actions Bot added readiness: checking Automated validation is still running 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 Sep 30, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 30, 2026
iamwhatever
iamwhatever previously approved these changes Sep 30, 2026

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

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.

@iamwhatever
iamwhatever enabled auto-merge (squash) September 30, 2026 17:37
auto-merge was automatically disabled September 30, 2026 18:02

Head branch was pushed to by a user without write access

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Sep 30, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Opus 5.5 Review lane run https://github.com/kirodotdev/KiroCrew/actions/runs/42547413884 needs a rerun.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Static Ratchet Gate also fails on main, without this PR.

test/test_pid_reader_ratchet.py::test_owner_marked_sites_match_the_recorded_count finds 9 pid-owner-ok sites in src, but _BASELINE_OWNER_MARKED is 8. I get the same failure on main 69d3a9a and on this PR's base 87defc8. This PR adds no pid readers. Of the markers on main, the newest come from #32376 (session_background.py) and #31145 (review_pool.py). Fast Gate run 42566179923 on main cab936f also failed. Await Fast Gate and Coverage Gate fail here only because Fast Gate failed. I will rebase after main records the new count.

@Pearcekieser

Pearcekieser commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Backend Tests (3.12, 3) also fails on main, without this PR.

test/test_review_repair_routing_skill.py::test_slim_skills_do_not_regrow_duplicate_guidance_or_wire_model_ids[kirocrew-worktree-dev-16000] fails because src/kiro_crew/builtin_skills/kirocrew-dev/kirocrew-worktree-dev/SKILL.md is 16,004 bytes and the cap is 16,000. I get the same failure on main f068b8a. This PR does not touch that file. The last main changes to it are #33084 and #33254. I will rebase after main fixes the size.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Opus 5.5 Review lane run https://github.com/kirodotdev/KiroCrew/actions/runs/42729139652 needs a rerun.

@Zedmor

Zedmor commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Code change approver recommendation: A person should decide

Automated, not a person, and not a review: a maintainer still decides.

decider-v3c@217fe607 · p_defect 0.14 · router R0 (approves only when p_defect <= 0.12, on changes of at most 400 changed lines) · head 79bd5f1457 · 1385 changed lines

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.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Opus 5.5 Review lane run https://github.com/kirodotdev/KiroCrew/actions/runs/42745093084 needs a rerun.

@Pearcekieser

Pearcekieser commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

span=0062fac9ccad
issue (blocking): fixed, a requeued steer of yours no longer reads as yours

fixed in ac3c28d. A requeued steer can keep the caller's sender stamp and lose steer_delivery_id, so _queue_entry_from read it as yours and move accepted it.

Upheld. A steer that took the live path loses its delivery id in chat_delivery.py but keeps its admission, and _requeue_unconsumed_steers copies that admission onto the new entry. Checking REQUEUED_STEER_ROW_MID_META and STEER_POSSIBLY_DELIVERED_META as well would still miss one shape: a requeue whose row patch finds no row and whose RPC already finished carries the same meta keys as a plain queued send. So the fix is a positive mark instead of a longer denylist. session_send's two queue arms now write SESSION_SEND_QUEUED_META, _queue_entry_from needs it for yours, and the drain pops it before it writes a row. A requeue builds its meta from the steer's admission, which never holds the mark, so a requeued steer reads other whatever else the requeue writes. Entries that session_retry, session_continue or a recovery requeue put back also read other now.

Tests: test_a_requeued_steer_is_not_yours_whatever_its_meta covers four shapes (delivery id, row mid only, possibly delivered only, bare admission). test_a_steer_requeued_after_a_live_delivery_is_not_yours steers through the real send path and requeues with no echo. test_a_queued_session_send_reads_as_yours keeps the plain send movable. The new shape tests fail on 280752f.

This PR passed the seam limit, so this round also narrows scope: _remove_queued_by_id and _edit_queued_by_id are back to main's behaviour, and only the reorder helper stays shared.

mechanism: ownership reads a positive queued-send mark instead of excluding known requeue shapes
self-added: no

resolution: narrowed -- yours now requires a marker only the session_send queue arms write, and remove and edit are back to main

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

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_send sits, 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 through meta.queueId instead 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.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

chore (non-blocking): _QUEUE_FROM_LABELS is no longer re-exported from mcp_dashboard.py

2ab272c makes the label map a local, from_labels, inside _render_session_queue in src/kiro_crew/mcp_dashboard_session_runs.py, and removes its line from the mcp_dashboard.py import block. The facade contract binds every module-level name that an mcp_dashboard_*.py owner defines, so a local needs no re-export. The rendered listing does not change. The spec already lists queue in HANDOFF_WIDENED_OPERATIONS, so this PR now makes both points from the r134 change request. The head is also rebased on main 34f545d.

@KiroCrewCaptain

KiroCrewCaptain commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: 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 other, and the drain removes the mark before writing a row. A move earlier may pass only the caller's own entries, and the change runs with no wait between the checks and the write, the same way the card's reorder does. The shared reorder helper keeps cron-twin behaviour and adds the declared app-twin row re-seat. Remove and edit are unchanged. Unattended conductors don't get the tool, channel agents are blocked from it, and tests cover the behaviour. I found no regression, fail-open path or unmet goal.

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 935fd2b99c · 1432 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

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

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 as pattern= on the entry field of SESSION_QUEUE_SCHEMA and re-exported through validation.py.

Two plain options:

  1. Drop the pattern and keep max_len=QUEUE_ENTRY_ID_MAX_CHARS. queue_target only compares entry for equality with ids already in the queue, so any other string ends in entry_not_found and nothing free-form is acted on.
  2. 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_RE export from validation.py.

Everything else I checked on this head is unchanged from what I read at ac3c28d, apart from that label move. 96 checks green.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

chore (non-blocking): the new regex is gone, option 1

f9a8e0b removes _QUEUE_ENTRY_ID_RE from validation_parts/messaging_session_schemas.py, its pattern= on the entry field of SESSION_QUEUE_SCHEMA, its export from validation.py and its line in test/test_validation_parts_facade.py. The field keeps max_len=QUEUE_ENTRY_ID_MAX_CHARS. queue_target compares entry only for equality with the ids in the queue. An empty value ends in entry_required, and any other string that matches no id ends in entry_not_found. That refusal shows the value through repr, so a line break in it cannot add a row to the reply. The new test test_move_of_free_text_is_not_found pins that path, and the schema test now uses a value one character over the cap in place of has space. The head is also rebased on main d8b7044.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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
bolichen97 previously approved these changes Nov 11, 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.

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 / other labels, 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 allowed audit, 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.

@bolichen97

Copy link
Copy Markdown
Contributor

@iamwhatever both points from your change request at d9851f2 are addressed on 9e4255e. The spec's HANDOFF_WIDENED_OPERATIONS list now includes queue, and _QUEUE_FROM_LABELS is no longer re-exported from mcp_dashboard.py (it is now a local inside _render_session_queue). Could you take another look when you have a moment?

bolichen97
bolichen97 previously approved these changes Nov 12, 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.

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_queue lists a session's queue and moves only the entries the caller queued with session_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: queue is in HANDOFF_WIDENED_OPERATIONS and in the spec text, and _QUEUE_FROM_LABELS is a local in _render_session_queue, not a re-export from mcp_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 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.

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.

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

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(mcp): session_queue lets a sender list, cancel and reorder what it queued

6 participants