Repository navigation
feat(mcp): session_generate_title regenerates a created session's title - #15468
Pearcekieser wants to merge 1 commit into
Conversation
|
Intent: Let an agent on the |
64477b0 to
b878339
Compare
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS Write-first persist choreography — a restore write plus a second persist on every success — buys byte-consistency of an archived title line; the identity guard alone stops the real bleed. Not justified as shipped
What this change shipsInventory (9 items) — 7 justifiedIntent: let an agent retitle worker sessions it created, as the sidebar's "Regenerate title" does, bounded in reach and spend — ADDITION (Fixes #15452).
The same same-key race in background [FIRST-PRINCIPLES-REVIEWED] 0379f26 Description read[DESCRIPTION-READ] 9f08c6c0510675810828b99e4a302133016063803ea9ece10300454b0338f31a That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 0379f26 Description read[DESCRIPTION-READ] 49e3858378cae9701612177346c27608a3c927c7e65b82b921f696eb080e2b7d 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 |
GPT 5.6 Review (fork) — 🔴 changes requested (blocking)Reviewed 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands. BLOCKING -- src/kiro_crew/dashboard/chat_title.py:1546 -- authorization can expire before title publication Adjudication (Opus 5) — is blocking on each finding proportionate?The adjudicable block is empty; one fenced finding. Record for F1: F1 — harm rung: UNBOUNDED (containment-boundary bypass). The window is real and not extreme. Conditions confirmed: caller must be the target's creator ( Plausibility, not rarity: Recovery path: none. Once the guard admits, the commit stands, the slot is retitled and pushed, and the I cannot complete the rarity argument FLAG requires — the triggering operation is an ordinary live one, and the finding's claim aligns with the module's own stated invariant rather than contradicting it. Flagging would hand a hurried reviewer an argument against that invariant. [ADJUDICATION] 0379f26 total=0 uphold=0 downgrade=0 [ADJUDICATION-FENCED] 0379f26 fenced=1 flagged=0 |
b878339 to
db83f86
Compare
|
mechanism: synchronous authorize_target re-run between the model await and the title write
|
|
Opus 5 Review (fork) — ✅ no blocking findingsReviewed Review detailsAdvisory only: the new write-before-publish order opens a lost-title-write window against an ordinary slot save. FINDING — src/kiro_crew/dashboard/chat_title.py:1486 — [OPUS-REVIEWED] 131cf50 |
db83f86 to
7a808fd
Compare
|
Rebased onto main after #15166 (session_end_wait) merged. The conflicts were only in the doc tool lists and counts (now 25 tools, 15 session-control verbs); no code change. The related tests pass on the new head. |
7a808fd to
1d6cca7
Compare
|
mechanism: identity guard inside the locked history write, plus an identity re-check before the sidebar push
|
|
mechanism: regenerate_title returns RegeneratedTitle(title, saved); the verb raises title_persist_failed on saved=False
|
|
|
|
|
Adds session_generate_title to kirocrew-dashboard over a strict-internal POST /api/session-control/generate-title. It runs the sidebar's Regenerate title code (factored into chat_title.regenerate_title), reaches only sessions the caller created, and admits one call per target every 120 seconds.
131cf50 to
0379f26
Compare
|
mechanism: access re-check inside the locked write guard, a restore write when a close begins after the commit, and a post-publish write; regression tests
|
|
Rebased onto main after session_reload (#15499), no behaviour change from the rebase. The conflict was in the shared tool lists, routes and docs; both tools are kept. Head 0379f26 also carries the round-6 fixes answered in the GPT (span 01dd9f0739bd) and Opus (span 36e0c2619fee) disposition comments on this PR. |
|
mechanism: post-publish write of the slot's own values; regression test
|
|
🤖 Kiro Crew [operator: dwu96#8c08bee0]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author. Assessment: three blockers, all with a determined remedy.
Plus the merge conflict, which your own notes record as tool lists, routes and doc counts shared with If you'd prefer I don't touch this PR, add the |
|
Automated rebase attempt onto The single commit conflicts in 6 files. I didn't resolve them automatically because main has restructured the code this PR edits:
@dwu96 has already said they will push fixes to this branch, so the author or co-author should rebase this by hand along with those fixes. |
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Taking this over in #19603 since it has been idle; you are credited as co-author on the commits. Thanks for the groundwork. |
|
Thanks for this, @Pearcekieser. |
Problem / Motivation
Goal: An agent on the
kirocrew-dashboardMCP server can ask for a fresh sidebar title on a session it created, the same way a person clicks "Regenerate title".A conductor names each worker once, at
session_create. When a worker's task drifts, that title goes stale, and today only a person can regenerate it from the sidebar menu (POST /api/chat/slots/{slot}/generate-title). That route has no caller-ownership fence and no rate limit, so it cannot simply be exposed as a tool.Why it matters
A person scanning a sidebar full of worker sessions finds the one they need by its title. A conductor running a dozen workers leaves a dozen titles that describe the first task, and the person regenerates them one by one. Handing this to the agent needs a bound on reach (only its own workers) and on spend (each call is a model call).
Not a goal
session_rename(MCP: session_rename renames the caller or a session it may control #15162).What changed (motivation → approach → change)
The sidebar route's body moves into
regenerate_title(state, slot)indashboard/chat_title.py, and the route now calls it, so the tool and the menu item share one code path and one set of race guards. It makes one background one-liner call on the titling model and waits for it, so the tool can return the new title in the same call. Like the menu item, the result replaces a hand-set title and stays an auto title; a rename that lands during the model call still wins. If the session is closed during the call, possibly with a new one opened under the same key, the title is discarded instead of being written into the successor or into the closed session's archived line; the sidebar route shares that guard. To make the discard hold against a close that starts during the history write,regenerate_titlewrites the title to history first (a newtitle_fieldsargument on_persist_title) and sets it on the slot only afterwards, once the slot is still live and not closing. A close saves the slot's title under the transcript lock, so it records the previous title, and the write guard refuses once a close has begun. A close that begins after the write committed gets the slot's previous title written back, so a close that aborts leaves the history line matching the live session. After the slot shows the title, its own values are written once more, so an ordinary save that took the lock between the commit and the publish cannot leave the previous title on disk.session_generate_title(target)(mcp_dashboard.py, schema invalidation.py) posts to a new strict-internal route,POST /api/session-control/generate-title(dashboard/server.py, handler indashboard/handlers/session_control.py), which callsgenerate_title_targetindashboard/session_control.py. That runsauthorize_targetlikesession_stop, and then refuses any target the caller did not create (not_creator, 403) for every caller class, because the verb spends a call to relabel a session. It then admits one call per target every 300 seconds through the existing creation limiter (dashboard/create_rate_limit.py, a new budget-1generate_titleverb keyed by the target slot), stamped before the model call, so a patrol loop or a concurrent retry cannot spend twice (title_rate_limited, 429). A refused call spends nothing and does not start the window. After the model answers,authorize_targetruns again synchronously before anything is written (passed in as astill_allowedcallback), so a target that became channel-linked or mirrored during the call is not retitled; a target closed, closing or replaced mid-call is reported astarget_replaced(409) and keeps its previous title. The history write itself carries astill_currentguard checked under the transcript lock on the write's worker thread: the slot is still the live one and not closing, andstill_allowedpasses again, so a target linked or mirrored while the write waited for the lock gets no durable title, and the sidebar push is skipped when the slot was closed or replaced during the write. If the write fails,regenerate_titlereportssaved=Falseand the verb answerstitle_persist_failed(500); the live slot keeps the title, as the sidebar rename does. Every admitted call and every refusal after the gate is SEL-audited. The MCP call waits up to 120 seconds for the route.The tool is withheld from unattended conductors (
agent.py), blocked for channel agents (channel.py), titled indata/mcp_tool_titles.json, and listed indocs/session-control.md,docs/index.md, the feature map and the architecture page.Backwards compatibility
Compatible: adds one tool and one route. The sidebar route keeps its request, response and behaviour; its body moved into a function it now calls.
Tests
test/test_session_control_generate_title.pycovers: a created session is retitled and the reply carries the title; an unchanged result reports the current title; a session the caller did not create, one another session created, the caller itself and a channel-linked target are refused before any model call; a repeat inside the window is refused with 429 and spends nothing; the window expires; a refused call does not start the window; two concurrent calls spend one; a hand-set title is replaced and becomes auto, as in the sidebar. A session replaced under the same key, or linked to a channel, during the call gets neither the persist nor the sidebar push; one replaced during the history write is refused by the write guard and not pushed; a close that begins during the history write finds the slot still showing its previous title, the write guard refuses, and the call answerstarget_replaced; a close begun during the model call gets no write;_persist_title(title_fields=...)writes the pending title without touching the slot; a failed write answerstitle_persist_failed; a target linked to a channel while the write waits for the lock is refused inside the write guard; a close begun after the commit gets the previous title written back; a save landing between the commit and the publish is overwritten by the post-publish write. Route tests cover the internal-secret refusal, the result, the 429 mapping and strict-internal membership. MCP tests cover the verified key, the 120-second timeout and the three replies. The registration, advertised-set, doc-count and carried-fence tests list the new tool and route.Manual verification
N/A: the new path is a gate in front of an existing route body, and both are exercised by unit tests against a real
DashboardState; there is no UI change.Related Issues
Fixes #15452
Refs #10149, #15162
Follow-up: #15559 (the same same-key replacement race in the background
maybe_refresh_title, left as-is here)Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)