Skip to content

feat: mark queued prompts that won't survive a restart - #31441

Merged
bolichen97 merged 1 commit into
mainfrom
fix/11695-queue-card-durable-marker
Nov 7, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/11695-queue-card-durable-marker

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A queued prompt that will not survive a gateway restart says so on its queue card.

A prompt sent while a turn is running is queued and saved so a restart cannot lose it. The saved copy holds at most 32 prompts and 256 KB. A prompt past either bound is still accepted, but it is not saved. Today only a server log line says so: the queue card looks exactly like every other card.

Why it matters

A restart before that prompt runs (an auto-update, a watchdog exit) drops it, and the sender had no way to see that coming. With a visible label they can keep the text, cancel the card, or send it again later.

Not a goal

  • Changing the bounds, or refusing a send that is past them. Refusing takes the user's words away at the one moment they cannot be re-read.
  • Putting the verdict on the /api/chat JSON receipts. Nothing reads them for it; the card reads the websocket frame.
  • Re-judging a live card on every queue change (edit, reorder, drain). The refresh at the end of each turn judges the whole queue again.
  • A summary on the collapsed queue stack. A card deeper than the peeking cards shows its label once the stack is expanded.
  • A label on a requeued steer's frame. A steer is requeued at the head of the queue, so the count cap never refuses it, and the turn-end refresh judges it with the rest.

What changed (motivation → approach → change)

The server already knows the answer: warn_if_not_durable reads it off the durable writer's own output and logs it. That verdict now reaches the card, in both places a card is drawn from.

Where Change
queue_push frame: busy-slot send (dashboard/chat_delivery.py), sub-agent hold (dashboard/chat_api/chat_send.py) carries meta.durable: false when the saved copy cannot hold the entry. The fair-admission work id is now stamped inside queue_for_next_turn (callers in chat_api/chat_send.py and responsive_chat.py pass it), before the verdict, because the write weighs it
slot-detail queue: queue_view in dashboard/chat_delivery.py, used by chat_api/slot_detail.py and chat_api/resume.py through dashboard/chat_handlers.py judges the whole queue on every read (refused_durable_ids in dashboard/slot_queue_repository.py), so a refreshed card keeps the label only while it is still true. Slot detail judges the live entries, not its trimmed copy, because the writer also weighs fields the copy drops (source channels)
frontend store (store/chat/queue.ts, store/chat/wire.ts) keeps durable: false on the queued row from either source
QueueStack.tsx a quiet italic "won't survive a restart" label on that card; the key is in all 12 catalogs under website/src/i18n/locales/ and the pseudolocale

A frame-only marker was the first option, and it is not enough: every turn end refreshes the slot and rebuilds the queue cards from the slot-detail read, which would erase the label at the next turn. Judging again on that read also clears the label once enough of the queue ahead has drained.

The spec section Queued prompt durability in docs/system-specs/modules/session.md describes where the verdict lives now.

Builds on #11768 by @fathirramadhan-web, which drew the card half of this.

Backwards compatibility

Compatible: one optional meta.durable key is added to the queue_push frame and to slot-detail queue entries, and only when it is false. An older client ignores it and draws the card as before.

Removes nothing: no key, row, route or function is removed or renamed.

Tests

  • test_an_over_cap_enqueue_warns_and_is_still_accepted: the busy-slot frame for the 33rd prompt carries meta.durable: false.
  • test_a_held_prompt_past_the_durable_cap_is_marked_on_its_frame: the same for a prompt held behind running sub-agents. It sends as an unmarked caller, because the session's own composer sends are no longer held behind sub-agents.
  • test_the_slot_detail_queue_marks_only_the_refused_prompt: the slot-detail queue marks only the refused prompt (not a system entry), and drops the mark once the queue ahead drains.
  • test_the_slot_detail_read_judges_the_live_entries: through GET /api/chat/slots/<slot>, seven prompts with source channels near the byte budget mark the seventh, which the writer refuses. Red with the slot-detail read judging its own copy.
  • test_the_admitted_work_id_is_weighed_before_the_frame: a busy-slot send under fair admission is judged after its work id is on the entry (queue_for_next_turn(..., queued_work=) stamps it before the verdict), so a prompt that only fits without the id is marked. Red with the stamp after the frame.
  • test_an_ordinary_enqueue_emits_no_warning_and_reaches_disk: an ordinary send carries no mark.
  • test_crew_mode_workers.py now imports dashboard.chat_handlers at module load. It copies chat_delivery / chat_runner names at import, so a first import inside a test that patches those names kept the fake for later tests on the same worker. That made three tests in test_queue_during_subagents.py fail about 1 run in 4 under -n 4. 20 runs of both files at -n 4 now pass (5 of 20 failed before).
  • queue.durable.test.ts: the row keeps durable: false from a pushed frame and from a slot-detail rebuild, and a crewmate's pinned row (kept in place by hydrateQueuedBubbles) takes the refreshed verdict both ways. Red before the pinned-row sync.
  • QueueStack.test.tsx: the label renders on the refused card only.

Determinism: the changed test_queued_prompt_durability.py tests ran 20 times at -n0 and 10 times at -n 4 --dist loadgroup --max-worker-restart=2 beside test_queue_hold_gate.py and test_chat_steer.py; both changed backend files ran in a shuffled order (seed 4242, 158 tests); the two vitest files ran 5 times with --sequence.shuffle (seeds 1001-1005). All green.

Manual verification

Ran the built SPA with every /api/** call answered from fixtures: a running session whose queue holds two entries, the second with meta.durable: false. The harness asserted exactly one label, on the second card, in light and dark themes and in a 760 px pane.

Screenshots / video

Light theme, expanded stack: only the second card wears the label.

light theme, label on the refused card

Dark theme:

dark theme, label on the refused card

Narrow pane (760 px): the label and the preview both truncate

narrow pane

Related Issues

Closes #11695

Sibling sweep

Siblings: none -- a feature that adds a label; there is no defect with a second site.

Pattern harvest

Not generalizable: a new on-screen label for an existing server verdict, not a defect class.

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

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 13:53
@bolichen97
bolichen97 requested a review from Zedmor November 6, 2026 13:53
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the label reuses the writer's own verdict on both card sources, and every slot-detail read judges the queue again, so the turn-end refresh keeps or clears the label.

[DESIGN-REVIEWED] 91cb08d

Description read

[DESCRIPTION-READ] ce4233353644e33a7c5e4607a4278a8165589dea16e6222bd70c84058824476e

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 Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 91cb08d4bf19ffffbafc0164d2993b9239d155f1 — 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 label reuses the verdict the server already computes (durable_queue_entries via warn_if_not_durable). The pin this PR rewrites deferred the marker "with its consumer (issue #11695)", and this PR ships that consumer.

What this change ships

Inventory (7 items) — 7 justified

Intent: let someone who queued a prompt see that a gateway restart would drop it, so they can keep the text or send it again. This is an ADDITION (Closes #11695).

  1. A queue card shows an italic "won't survive a restart" label when the saved queue cannot hold its prompt — justified
  2. The queue_push frame carries meta.durable: false on busy-slot sends and on prompts held behind sub-agents — justified
  3. Slot-detail and resume reads judge the whole queue again, so the label clears after the queue ahead drains (queue_view, refused_durable_ids; 3 call sites) — justified
  4. The frontend store keeps the verdict from both sources and updates pinned crewmate rows — justified
  5. The fair-admission work id is stamped inside queue_for_next_turn before the verdict, replacing 2 caller-side stamps — justified
  6. The new label string is in 12 locales plus the pseudolocale — justified
  7. A test-isolation fix: test_crew_mode_workers.py imports chat_handlers early — justified

[FIRST-PRINCIPLES-REVIEWED] 91cb08d

Description read

[DESCRIPTION-READ] e4744e4d4ded34c32576e48d10e321667e81cea6006ed800fdddea5c103c14c9

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 Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 91cb08d4bf19ffffbafc0164d2993b9239d155f1 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks. The screenshots show the new label, and the blind reader understood it as "this waiting message will be lost if the app or assistant restarts", which is what it means.

Notes

  • The title on queue-card-not-durable repeats the label word for word, so it explains nothing. The reader asked "a restart of what?", "why only message 2?" and "what should I do?". Make the tooltip answer all three, e.g. "The saved queue is full. If Kiro Crew restarts before this runs, it is lost. Copy or resend it later."
  • At 760 px the label cuts to "won't survive a re…", which the reader called meaningless. Name the restart and keep it short, e.g. "lost if Kiro Crew restarts". On a screen about a software release, the reader thought "restart" might be a checklist step.

[UX-REVIEWED] 91cb08d

Description read

[DESCRIPTION-READ] d7de34e3d947e62056a4e54a5d75177be5aec4c19a85eba2313c81f0b5a9b52a

That sha256 names everything this verdict read: the PR description, plus the 6 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 Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 91cb08d4bf19ffffbafc0164d2993b9239d155f1 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 91cb08d

Verdict parsed from the review's SHA-scoped output markers for commit 91cb08d4bf19ffffbafc0164d2993b9239d155f1.

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

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 91cb08d4bf19ffffbafc0164d2993b9239d155f1 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 91cb08d

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

@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 14:13
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/11695-queue-card-durable-marker branch from d240587 to 5ab37a8 Compare November 6, 2026 19:27
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • fixed span=559f32a34877: judge durability before projecting away writer-relevant fields

fixed in 5ab37a8: slot detail now reads the verdict off the live slot._queue with refused_durable_ids, in the same tick it takes its trimmed copy, and passes it to queue_view(snapshot, refused). The copy is still what is rendered off-loop.
Class: any read that judges a projection. resume.py already passes the live queue; the queue_push sites judge slot._queue. No other site.
red/green: test_the_slot_detail_read_judges_the_live_entries (seven prompts with source channels near the byte budget, through GET slot detail) fails with the copy judged and passes now.
self-added: no
mechanism: judge the live queue, render the copy

@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 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
@bolichen97
bolichen97 force-pushed the fix/11695-queue-card-durable-marker branch 2 times, most recently from d286f8a to 753fca3 Compare November 6, 2026 22:05
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 7, 2026
@bolichen97
bolichen97 force-pushed the fix/11695-queue-card-durable-marker branch from 753fca3 to 93287c9 Compare November 7, 2026 07:12
@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 7, 2026
A prompt queued past the durable queue bounds is accepted but only
logged as not persisted, so the queue card shows it like any other.
Put the verdict on the queue_push frames and the slot-detail queue as
meta.durable: false and draw a quiet "won't survive a restart" label
on that card, so the sender can see it before a restart drops it.
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased: main moved in the line-budget and platform collect-ignore tests (fixed on main by #32252 and #32209) since this head went red (b65af1a -> f58c3cf); CI re-running. The patch is unchanged (git range-diff shows the same commit); changed backend and frontend tests, flake8, isort, mypy and tsc pass locally, and local GPT and Opus reviews of 91cb08d passed.

AI-assisted, posted on behalf of bolichen97

@bolichen97
bolichen97 force-pushed the fix/11695-queue-card-durable-marker branch from 93287c9 to 91cb08d Compare November 7, 2026 13:48
@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 Nov 7, 2026

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

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

APPROVE at 91cb08d.

What it does for users: a prompt queued while a turn runs is saved so a restart cannot lose it, but the saved copy holds at most 32 prompts and 256 KB. A prompt past either bound used to be silently unsaved; only a server log line said so. Its queue card now shows a quiet "won't survive a restart" label, so the sender can keep the text or send it again later. Nothing else on the card changes, and a send is never refused.

Evidence:

  • The verdict comes from the writer itself. Both paths read the writer's own output (durable_queue_entries): warn_if_not_durable (slot_queue_repository.py:263-268) and the new refused_durable_ids (slot_queue_repository.py:287-291). refused_durable_ids subtracts the kept set from the durable candidates only, so a system entry (a cron notice, a recovery continuation) is never labelled on a slot-detail read.
  • Busy-slot frame (chat_delivery.py:1428-1434): the broadcast now goes out after the verdict, and a refused entry carries meta.durable false. The sub-agent hold frame does the same (chat_send.py:1449, 1474-1476).
  • The fair-admission work id is now stamped inside queue_for_next_turn before the verdict (chat_delivery.py:1385-1388). The writer weighs that id, so judging before the stamp would label the wrong prompts. The two callers that stamped afterwards (chat_send.py busy branch, responsive_chat.py) now pass queued_work instead. stamp_queued_work itself is unchanged (shared_crew admission_entry.py:222-235).
  • Slot detail and resume use queue_view (chat_delivery.py:1710-1727). Slot detail judges the live entries in the same tick as its trimmed copy (slot_detail.py:1214-1216), because the copy drops source channels that the writer counts.
  • Frontend: wire.ts and queue.ts keep durable false from either source. A pinned crewmate row takes the refreshed verdict both ways (queue.ts:91-100). QueueStack.tsx draws the label only when meta.durable === false. The string is present in all 13 locale files.
  • The session spec section "Queued prompt durability" was updated in the same commit. It replaces the earlier "log only, not shipped" stance and lists the cases the turn-end refresh corrects.

Mutation: the busy-slot durable = False assignment replaced with pass. Result: test_an_over_cap_enqueue_warns_and_is_still_accepted and test_the_admitted_work_id_is_weighed_before_the_frame go red; restored and the tree checked clean.

Tests: test_queued_prompt_durability, test_queue_during_subagents and test_crew_mode_workers gave 246 passed. queue.durable.test.ts plus QueueStack.test.tsx gave 55 passed.

CI at this head: 83 success, 11 skipped, 0 failing. PR Readiness and both CodeBuild statuses are success. The GPT, Opus, Design, UX and First Principles lanes report PASS or no findings. It merges cleanly with main.

Source-only: the rendering in light, dark and narrow panes, judged from the screenshots in the description.

Follow-ups (non-blocking):

  • A label drawn from a push frame can go stale until the next turn-end refresh. If an earlier card is cancelled or edited shorter, a later card may keep "won't survive a restart" although it now fits. The description and spec both scope this out; worth a note if users report it.
  • warn_if_not_durable answers false for any entry that is not a durable candidate, such as an entry with empty text. If an attachment-only send with empty text can reach queue_for_next_turn (I did not check), that card would carry the label on its push frame and lose it on the next slot-detail read. The label is literally true there, but the two sources disagree.

@bolichen97
bolichen97 merged commit 039193d into main Nov 7, 2026
99 of 101 checks passed
@bolichen97
bolichen97 deleted the fix/11695-queue-card-durable-marker branch November 7, 2026 19:45
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 7, 2026
bolichen97 added a commit that referenced this pull request Nov 9, 2026
…32334)

A send that waits in the queue lost the knowledge envelope mark the
composer records on meta.knowledge.envelope, so the queue card guessed
the envelope from the wire text: it showed the whole text when a
knowledge item held the close marker on its own line, and hid a typed
copy of an envelope as if it were real.

The gateway now keeps that mark, bounded and nothing else, on the queue
entry as meta.knowledgeEnvelope (busy, hold, responsive and requeued
steer paths), and sends it on queue_push and the slot-detail queue. The
card finds the envelope with knowledgeEnvelopeEnd, and the text-parsing
splitKnowledgeEnvelope is gone.

Closes #24011

(cherry picked from commit 790b725)

Backport note: the durable marker and the queued_work parameter that
sit beside these lines on main come from feat #31441, which is not on
release, so each of the six conflicts keeps release's side and adds only
the knowledge envelope part: queue_for_next_turn takes only the
knowledge parameter and stamps it on the push before release's own
broadcast; the idle-hold push, responsive_chat.accept, queue.ts and
wire.ts add only the knowledgeEnvelope field (no durable). The
learn-cron-dashboard spec adds only the knowledge envelope paragraph,
not the queue editor hold paragraph from #30549.
bolichen97 added a commit that referenced this pull request Nov 9, 2026
…32334)

A send that waits in the queue lost the knowledge envelope mark the
composer records on meta.knowledge.envelope, so the queue card guessed
the envelope from the wire text: it showed the whole text when a
knowledge item held the close marker on its own line, and hid a typed
copy of an envelope as if it were real.

The gateway now keeps that mark, bounded and nothing else, on the queue
entry as meta.knowledgeEnvelope (busy, hold, responsive and requeued
steer paths), and sends it on queue_push and the slot-detail queue. The
card finds the envelope with knowledgeEnvelopeEnd, and the text-parsing
splitKnowledgeEnvelope is gone.

Closes #24011

(cherry picked from commit 790b725)

Backport note: the durable marker and the queued_work parameter that
sit beside these lines on main come from feat #31441, which is not on
release, so each of the six conflicts keeps release's side and adds only
the knowledge envelope part: queue_for_next_turn takes only the
knowledge parameter and stamps it on the push before release's own
broadcast; the idle-hold push, responsive_chat.accept, queue.ts and
wire.ts add only the knowledgeEnvelope field (no durable). The
learn-cron-dashboard spec adds only the knowledge envelope paragraph,
not the queue editor hold paragraph from #30549.
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.

Render the queued-prompt durable: false receipt on the queue card

2 participants