Skip to content

feat(session-control): escalate to the human as a peer (session_escalate) - #8613

Closed
CrysisDeu wants to merge 1 commit into
mainfrom
feat/escalation-user-peer
Closed

CrysisDeu wants to merge 1 commit into
mainfrom
feat/escalation-user-peer

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

A crew member that hits a wall — a permission it lacks, something only a person can reach, a one-way door — has had two bad options: ring the bell (a notification with no conversation around it) or write an [OPTIONS:] line in its own transcript and wait. Neither is how it talks to a peer, and neither leaves a record of what is waiting on the human.

Why it matters

Members run with nobody at the keyboard. Without a non-blocking way to raise a decision and carry on, a member either stalls (blocking ask_question) or acts without saying so. The human, in turn, has no roster-level signal of which member needs them.

What changed (motivation → approach → change)

Goal: make the human addressable as a peer — a card in the owning member's DM thread, nothing blocks, a badge on the roster.

Approach (revised on review): the first revision overloaded session_send with a reserved target="user". The review showed that does not survive contact with the rest of the surface: two disjoint parameter sets under one name (four fields silently dead unless target was one literal), two kinds of operation (a send runs a turn on the target; an escalation writes a row and runs nothing), and — the expensive part — policy keyed on the tool name, so escalation inherited session_send's containment by accident with no way to write a rule that tells them apart. This revision ships session_escalate as its own tool and reverts session_send to target + message.

What was built:

  • session_escalate(message, deadline?, default_action?, options?, goal?) → POST /api/session-control/escalate. No target; "user" is no longer a reserved word (a session may be titled user, nothing consults titles). Delivery lands one escalation row in the DM thread of the member that owns the caller (a member: its own thread; a worker a member created: the creating member's thread; any other session: its own transcript, no index), mirrors it onto the bell bus (kind: escalation, group_key: escalation:<slug>:<goal>) and returns. Every caller gate of authorize_target applies with the same codes; the human is not a slot so no target gate does.

  • Each policy site classifies the verb explicitly (spec table in session-control.md → "Escalating to the human"): in SESSION_CONTROL_TOOLS (caller identity); in CHANNEL_AGENT_BLOCKED_TOOLS — blocked, not on session_send's grounds but on send_notification's (the bell mirror is exactly the reach-the-user path that list closes), and the backend's linked_session_caller / mirrored_caller gate agrees, so letting a channel agent escalate is a deliberate two-site change rather than an accident of a shared name; granted to members in _MEMBER_DASHBOARD_GRANTS (it runs nothing and writes only into the member's own thread — the mid-turn, nobody-at-the-keyboard case is what the verb exists for); mounted-but-gated for both conductors like every other write; own schema in MCP_DASHBOARD_SCHEMAS. An escalation field passed to session_send is now refused as an unknown field, never dropped.

  • Three constraints (spec): non-blocking with a veto window (deadline + default_action = "unless you stop me by t, I do X"; the window closing records defaulted, never a failure; no deadline wakeup — the member that declared the default is the actor that runs it); attention budget (one group_key per goal, no transport-specific switch); escalation is not approval (anything the human must actively grant stays on the approval surfaces).

  • The per-member conversation index (crew_conversation.py, feat(members): thin per-member conversation index #8612) now rides here with its consumer (its former host fix(members): dispatch server carries the gateway home override #8611 was narrowed to the dispatch-home fix). Record written before the card under a pre-minted row id; needs_you / pending_escalations derived and projected on the slots frame and GET /api/members; GET /api/members/{slug}/conversation (owner-only) exposes it. Open decisions per member are capped (MAX_PENDING_ESCALATIONS = 50): pending records are never evicted by the file's size cap, so at the ceiling the next escalation is refused atomically (escalation_backlog_full, 429) with the count, telling a runaway member to wait for answers rather than grow the index without bound; settled records (answered, or past a deadline) free slots. Reply matching is one rule on both sides: a live owner user row with meta.escalation_id (through idle / queue / steer / merged-drain paths; a non-owner entry never launders an id onto an owner row) answers that record; typed text answers only when exactly one record was pending at the row's position; a replayed row answers nothing. A mixed merged batch (chips and typed text drained as one row) is replayed in order at the drain against the pending view, and the row then names every record the sequence answered — so "chip for A, then text" answers A and B exactly as the two replies would have separately, while "text, then chip for A" leaves B pending exactly as the sequence would; with no pending view the row names the chips alone (the under-answering side). Restore-time reconciliation re-derives the index from the transcript (orphans retracted after a grace, durable replies applied, judged at the reply row's own timestamp); live rows not yet flushed count for card presence only — their human_reply is stripped before the replay, so a record is never settled on disk ahead of the reply that settles it — and an answered record whose card survives but whose reply was rewound away is reopened (the transcript is the truth), so reconciliation runs on every generation change, pending or not; cards the transcript holds but the size cap already evicted from the index count as candidates in that replay (never written back), so a reply that was ambiguous when made stays ambiguous. An index file that exists but cannot be read is not an empty index: writers refuse to overwrite it, the roster forces a reconciliation, and the reconciliation rebuilds every card the transcript holds as a real pending record before replaying replies — repaired from the truth, never replaced by a blank. Both readers of the index — the roster's pending count and the thread's GET /api/members/{slug}/conversation view — go through the same reconcile step (_reconcile_member_sync) before they read, so a rewind that removed an answering reply reopens the record on whichever surface polls first. In a member thread the queue merge breaks at a human-provenance boundary (_dequeue_next_message): the owner's stamped replies never share a merged row with an unstamped neighbour (a peer's session_send, a cron prompt), which would otherwise strip human_reply from the row and leave the answered escalation pending. A client POST may name one record via a validated escalation_id; the plural escalation_ids is the drain's merge artifact and is stripped from client meta, so one body can never answer every decision at once. The on-loop pending view is bound to the raw KIROCREW_HOME it was resolved under, so a home change reads as unprimed until the next off-loop prime — never another home's badge — and prime() takes the same per-slug lock the writers hold, so a restore-time prime cannot install a stale view over a writer's fresh one. The live hook's persist-and-mark tasks are serialised per slot in transcript order, so a chip's slow save can no longer let a later typed reply be judged first (and decline against two pending).

  • options and the two other choice surfaces (review). options is the card's contract — the interactive EscalationCard (folded in from feat(members): chat-profile projection and escalation cards in the DM thread #8614, see below) renders it as the row's own chips in the Crew Members thread and answers with meta.escalation_id. Every other surface draws the row by default: EscalationNotice is registered in the default renderer registry (so the Crew Members thread — a ChatPane, the surface the bell deep-links to — shows the member's markdown, the veto window in words — "Unless you reply by <localized time, with its zone>, Radar will: ", the same actor and clock the bell names — and the options bound to how to answer them ("Reply in this thread with one of these to answer: …"); in the Crew Members thread the interactive card claims the role and replaces that entry. The bell mirror body says the same things in words (a UTC clock time, no glyphs). The tool description promises exactly that and no click. deriveFollowUpOptions gains an explicit escalation branch that ends the pill scan, so an escalation row can never inherit a previous assistant turn's [OPTIONS:] chips (the stale-chip mis-answer the review traced). The ask_question interaction is now a stated rule: a card is resolved through its own endpoint and writes no transcript row, so answering it never answers an escalation, and an escalation arriving while a card is open changes nothing about the card.

  • The bell's "Open" lands on the thread. _mirror_escalation emits /members?member=<crew name>; MembersPage now consumes that param once the roster loads (opens the member's thread through the same idempotent memberThread path a click uses, then strips the param with replace), so a notification opens the thread that needs the human rather than an unselected roster. GET /api/members/{slug}/conversation's 400 now carries code: invalid_member_slug like every other refusal in that handler.

Tests

test/test_escalation.py — delivery into own / creating-member / plain thread with no turn started (any _run_chat call asserts); a session titled user is not a collision; session_send has no escalation arm (a deadline on it is refused as unknown, never forwarded); the verb is classified at every policy site (SESSION_CONTROL_TOOLS, CHANNEL_AGENT_BLOCKED_TOOLS, MCP_DASHBOARD_SCHEMAS, member grants, not conductor grants; session_send schema back to target+message; escalate schema has no target; description promises no click); MCP dispatch posts /api/session-control/escalate under the verified key and renders the non-blocking reply; caller gates + SEL denial audit (escalate:<code>); index record before card, needs_you projection, reply clears (live) / does not (replayed), merged-drain id laundering, deadline → defaulted, field validation refused before append, bell mirror payload now including the readable options line, route passthrough + 400, roster + conversation endpoint. test/test_crew_conversation.py (moved here with the index). test_mcp_dashboard_registration.py / test_mcp_dashboard_folders.py pin the advertised set with session_escalate; test_channel_blocked_tools.py's existing "every session-control tool is contained" pin covers the containment entry. website/src/test/deriveFollowUpOptions.test.ts — an escalation row ends the scan and offers nothing, its own meta.options never leak into the bar. test_mixed_merged_batch_replays_chip_then_text_in_order pins both orders of a mixed drained batch (chip→text answers both; text→chip leaves the second pending) and test_replay_helper_falls_back_to_the_chips_alone_when_the_view_is_unavailable the non-member / unprimed fallback; TestPendingViewFollowsTheDataHome pins that a KIROCREW_HOME change makes the memoized view unprimed, not another home's. test_restore_sweeps_orphaned_pending_records now also pins that a reply present only in the live window does NOT settle its record on a roster read, and does once persisted. test_reply_marks_settle_in_transcript_order_even_when_saves_contend pins that a chip whose save is slower than the typed reply that follows still marks first, so both records settle. TestPendingCeiling (unit) and test_backlog_ceiling_refuses_with_backpressure_and_no_row (route) pin the open-decision ceiling: refused at the cap with no row written, settled records do not count, an answer frees a slot. test_client_meta_carries_only_the_validated_singular_escalation_id pins that escalation_ids and an ungrammatical escalation_id never reach the row; test_reconcile_retracts_orphans_defers_young_and_applies_durable_answers now also pins that rewinding a reply reopens the records the transcript no longer answers, and that the reply coming back re-answers them with their original stamps; test_reconcile_counts_index_evicted_cards_still_in_the_transcript pins that an index-evicted card still in the transcript keeps an ambiguous reply ambiguous and never reaches the index; test_unreadable_index_is_rebuilt_from_the_transcript_and_never_overwritten pins that a torn index refuses writers, is rebuilt from the card rows (meta intact, then answered by the transcript's reply) and reads as repaired; test_a_human_reply_that_happens_to_start_with_the_peer_prefix_still_answers pins that human_reply alone decides. MembersPage.test.tsx — ?member= opens the named member's thread once and strips the param; an unknown name leaves the roster. messageRenderers.test.ts — escalation resolves to a default entry; EscalationNotice.test.tsx — veto line in words (no raw timestamp), options as text, deadline-only and bare variants, defensive meta read. The bell-mirror test asserts the sentence form and the absence of glyphs.

Manual verification

Verified live on the previous revision (isolated pod, crew "Radar", KAS backend): card landed in the member's thread, roster and slots frame reported needs_you: true, index held the pending record, the member's turn continued; a reply in the thread flipped the record to answered and cleared needs_you. This revision changes the tool name, route and policy classification, not the delivery path; those are pinned by the tests above.

Screenshots / video

The escalation row as the Crew Members thread draws it (the surface the bell deep-links to), rendered through the real ChatMessageList + default registry — three variants (deadline + default + options; deadline only; bare) — and the bell mirror body in words. Captured by website/scripts/capture-escalation-notice.mjs (fixture website/capture/escalation-notice.{html,tsx}), which self-checks the claim: three cards claimed by default, the veto line a sentence, no raw ISO timestamp, no glyphs.

Escalation row in the member thread, dark

Light theme

Escalation row in the member thread, light

Related Issues

no linked issue: stacked feature work (see Stack).

Stack

Collapsed on 2026-09-07: #8611 fix/member-dispatch-home merged to main; #8614 feat/crew-chat-profile (Crew Members chat projection + interactive escalation card) merged INTO this branch. This PR now carries backend verb + conversation index + frontend card, based on main, with no downstream.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|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

Frontend: chat-profile projection and escalation cards (folded in from #8614)

#8614 was stacked on this branch and merged into it (2026-09-07); its body follows so the combined PR reads as one. Rebased onto main after #8611 and #8546 landed: this branch's one-shot ?member= deep-link effect and its two tests were dropped in favour of #8546's URL-driven member selection, which the bell mirror's /members?member=<name> link now rides.

While the base was a feature branch only the 20-check reduced matrix ran, so the first full run on main surfaced latent test debt in both PRs, fixed here: the slot projection's needs_you key added to the to_dict key-order contract; the roster reconcile uses member_thread_session_alias (main's canonical-alias test); the session_escalate refusal audit redacts through redact_log_via_context (main's gate-side redactor census); _mark_member_escalations_answered's asyncio.run fallback allow-listed in the spawn audit as a non-spawn; three fixtures corrected (a reply stamped before its record's created_ts is correctly not an answer; a past deadline written after both records so record_escalation's pre-append sweep does not default the first; the stale-grace card test now confirms the cancel, matching the card's rule and case (g)); and the new hi/ko strings brought in line with the catalog style tests (informal तुम, 이(가), ‘ ’ quotes). Also from that round's review: an option send now binds its (empty) pre-send record under the queue id whether or not its in-flight entry is still present — two identical option chips are indistinguishable by wire text, so a sibling's pre-receipt cancel could consume this send's entry and leave its own later cancel to the content parser, which appended the option label to the draft. An unreadable receipt (unknown / response-late) keeps the in-flight record: the send may have queued under an id this pane will never learn, so that record is the only one a cancel of the card can find.

Summary

The Crew Members DM thread rendered the member's raw transcript — every tool row, notice and nudge between the human's message and the member's reply. That is the right view on the Sessions page and the wrong one for a conversation. This PR gives ChatPane a displayProfile (transcript, the unchanged default, or chat) and mounts the chat profile on the Members page.

Crew chat demo — task, working state, escalation card with countdown and chips, one-click reply, view process, bell mirror

recorded from 693f9d3b5a327c73d4d9b698369cf4735f54166b · isolated pod wt-escalation, seeded config, crew "Radar" on the KAS backend · mode: --approval yolo · real server + real model turns, no fixtures

What the chat profile does

pages/members/chatProjection.ts is a pure projection over the same rows, computed client-side so the view can never disagree with the transcript it is drawn from:

  • Keeps the human's messages, the final assistant reply of each turn, escalation cards, approval and error rows. Hides tool / thinking / notice / nudge / inject / subagent rows and attaches them to the reply as meta.chat_process — one click on View process (N steps) shows them.
  • Working line. While the member runs a turn, "Working: ‹tool purpose›" stands in for the hidden rows (WS tool_call → slotStatusDetail; falls back to the tool name, then a generic line). It is the only busy indicator in the chat profile — the footer's ghost carousel is suppressed there (stopping/compacting states still show).
  • Silent rounds fold. Consecutive auto-nudge rounds whose reply said nothing new collapse into one "N check-ins with nothing new" row with its own expander. Implemented and unit-tested, but ships dark: a member thread cannot host an auto-nudge loop today (autonudge_authz refuses member-mode slots, and the member's kirocrew-core has no identity channel on KAS). Whether to lift that guard for member-armed loops is a separate decision.

Escalation cards

role: escalation rows (from #8613's session_escalate / POST /api/session-control/escalate) render as a card: title ("Radar needs you"), sender, goal chip, markdown body, a live countdown to the deadline, the default action if unanswered, and the options as a vertical single-choice list with one Send reply button (the same shape as QuestionCard; double-click an option to select and send in one gesture). The pick-then-send step is drawn, not implied: each option carries a radio dot, the button restates the pick once one is made (“Send ‘Hold until Monday’”, clipped to a phrase with the full text as its title), and until something is picked the hint beside it reads “Pick an option, then Send reply.” — so a click on an option is never mistaken for the reply. The reply carries meta.escalation_id, so the backend answers exactly that record — and because it is addressed by id, ChatPane.doSend does not treat it as the answer to whatever stateless question card or blocking ask happens to be pending on the slot (no capture, no retire): a reply to the member's escalation cannot silently dismiss an unrelated pending question. Card state is derived on the client by the same rule the index applies (#8613): a reply carrying the id answers that card; a free-text reply answers only when exactly one escalation is pending; a reply after the deadline never answers; the 1-second tick flips a live card to expired / defaulted ("Default applied: …") the moment the clock passes the deadline. The roster row shows a Needs you badge from the slot frame's needs_you. Every other surface keeps drawing #8613's read-only EscalationNotice (the SDK default), which points at the Members thread; this card is the ONE place an escalation is answered. The conversation index (GET /api/members/{slug}/conversation) is the authority on which escalation is still open; when that request fails before any record has loaded the cards fall back to the client-side rule, and when a REFETCH fails the last good record stays authoritative (a stale pending beats a window simulation that could read a truncated transcript as answered); either way an inline ErrorNotice under the thread says so (title + the raw error, no askAgent: the hand-off would unmount the pane and the composer draft in it), and the 20 s safety-net poll keeps retrying while a card is pending. An optimistic (not yet acknowledged) reply never counts as an answer, so a refused send leaves the card answerable. A reply the pane had to queue behind a running member turn keeps the card latched for as long as its queue entry exists; when the entry leaves the stack the latch lets go only if the server confirmed the cancel (useQueuedMessageActions now also exposes cancelledIds, the ids whose DELETE resolved) — the stack removes a cancelled entry optimistically, so an entry that is merely absent may still be queued behind a failed cancel and unlocking on absence alone would let a second reply run on top of the first. Unconfirmed, the authority (the index or the confirming row) is the only release. The same rule covers an uncertain acceptance — a 2xx the pane could not read, or one that arrived after the abort deadline (SendOutcome.uncertain): the reply may be queued under an id the host never learned, so the card drops its 45 s valve and waits for the authority instead of unlocking on a clock. One invariant, stated once: a reply the server may hold is never released by a timer or by an entry's absence — only by the index, the confirming row, or a server-confirmed cancel. Cancelling such a queued reply from the stack restores the pick on the card and nothing to the composer: the option send binds an empty pre-send record (queuedSendStash), so the cancel path takes the stash hit instead of parsing the row and appending the option label to the draft. For an option send only, that empty record is also registered under the send's own sendId (inFlightSendStash) BEFORE the request goes out and moved under the queue id when the receipt names one, so a cancel that lands in the queue_push-before-receipt gap still finds it by wire text — safe precisely because the record is empty by construction (typed sends, whose text and files could be mis-restored by a wire-text collision, stay bound by queue id only); and a server-confirmed cancel releases the card's latch even for an entry the stack never showed it, so that same gap cannot leave the card locked with no way out.

card answered

Coordination

MembersPage.tsx is touched in three small hunks only (isNeedsYou, the badge, the displayProfile prop) to stay clear of the in-flight remember-last-member and driving-sessions work in the same file. Everything else is new files under pages/members/ plus a displayProfile seam in ChatPane; messageRenderers.tsx is untouched (its escalation default stays #8613's notice).

i18n

26 keys under pages.members.chat in all 12 catalogs + regenerated pseudolocale, with per-language plural forms (CJK _other only; es/fr/pt/it _many; ru _few/_many); plural bases registered in pluralKeys.json; translator context in en.context.json. All 19 i18n:check gates pass against origin/main.

Tests

  • chatProjection.test.ts (11) — hiding, final-reply selection, process attachment, streaming kept while running, fold of 3 silent rounds, non-quiet round not folded, escalation/permission kept
  • EscalationCard.test.tsx (18) — body/options, select + Send → onSend(text, {escalation_id}), double-click quick send, radio dot + restated Send label + pick hint, long-option clipping, expired/defaulted (fake timers) closes the card and swaps the default line to "Default applied", live countdown and clock-crossing flip, answered badge, formatRemaining
  • chatProfileRenderers.test.tsx (6) — the assistant override wins after mergeRenderers, process disclosure, fold row, chips send via host handler, the SDK default alone draws feat(session-control): escalate to the human as a peer (session_escalate) #8613's EscalationNotice (not this card)
  • useEscalationIndex.test.tsx — fetch/poll/abort/dedupe, and error is set only by a FAILED request (null while loading, on success, and on a non-member slot)
  • MembersPage.test.tsx — badge from live slot and from roster fallback; ChatPane receives displayProfile="chat"
  • tsc -b, eslint, and the full i18n gate set are clean locally; the vitest suite for src/pages/members + src/i18n + the ChatPane working-loader harness passes (732 tests).

Stack

  1. fix(members): dispatch server carries the gateway home override #8611 fix/member-dispatch-home
  2. feat(members): thin per-member conversation index #8612 feat/crew-conversation-index
  3. feat(session-control): escalate to the human as a peer (session_escalate) #8613 feat/escalation-user-peer (base of this branch)
  4. this PR feat/crew-chat-profile

@CrysisDeu
CrysisDeu requested review from a team and dwu96 and removed request for a team September 5, 2026 01:12
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

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

Design-Verdict: CONCERNS

Sound, well-decomposed design; one contract crack — the card asserts "Default applied" for a default the system deliberately never runs or verifies.

Watch

  • The spec's own words: "defaulted therefore records that the window closed with a default declared — not that the action ran", and a member whose turn ends before its deadline "must arrange its own wake." Yet EscalationCard.tsx:444 flips to escalation_default_applied ("Default applied: {{action}}") on a client-side clock tick, and en.context.json says the default "is now in effect." Chain: member escalates with a default → its turn ends, no wake arranged → window closes → card tells the human the action was applied → human stops watching → the action never runs. That reintroduces the PR's own stated harm in mirror form (the system says without acting), on the exact surface built to be truthful. Reword the defaulted state to what the record actually means (window closed; the member said it would do X) or gate "applied" on evidence the member acted.
    Clears when: the defaulted card state stops asserting execution — wording matches the spec's "window closed, default declared" semantics, or the card shows "applied" only from a member-produced confirmation.

Suggestions

  • The read-only EscalationNotice already has the honest tense ("will: X"); reuse its phrasing for the interactive card's closed state rather than introducing a past-tense sibling key.

[DESIGN-REVIEWED] 45b7ea7

@github-actions

github-actions Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Stale verdict notice (2026-09-08 23:08 UTC): a later GPT 5.6 run did not produce a completed verdict for 45b7ea75b37b39142b65a5b9cb1eb74a9cec3699; the verdict below is from an earlier completed run. Inspect the GPT 5.6 Review job logs and re-run the workflow, or have a repository writer comment /ai-review override gpt 45b7ea75b37b39142b65a5b9cb1eb74a9cec3699: <one-sentence reason>.

GPT 5.6 Review — 🔴 changes requested (blocking)

GPT 5.6 found at least one blocking issue that must be resolved before merging f2ba19cd1ee050e6f6b7ee8c0f0eba6f6e80d598. 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/dashboard/session_control.py:2414 -- successful escalations can be lost on restart

append_and_surface(state, home, ESCALATION_ROLE, ...)
Accepted escalation -> process exits before asynchronous persistence -> card, notification, and badge disappear after recovery.
Anchor: residual/crash-data-loss-corruption
Fix: persist the slot before returning success; retract and refuse if persistence fails.

FINDING -- src/kiro_crew/dashboard/session_control.py:2290 -- "default_action" is accepted without a deadline, leaving its escalation permanently pending with no point when the default applies -> Fix: reject a non-empty default action unless deadline_iso is set.

[BLOCK-MERGE] f2ba19c
[GPT-REVIEWED] f2ba19c

Adjudication (Opus 4.8) — is blocking on each finding proportionate?

The adjudicable block is empty. F1 is fenced (data-loss / unbounded-harm class): a crash in the window between append_and_surface succeeding (session_control.py:2414 — in-memory transcript row + live broadcast) and the slot's async flush persisting the transcript. On recovery, reconcile_with_transcript (crew_conversation.py:667) treats the transcript as truth and, after ORPHAN_GRACE_SECS, retracts the pending record as an orphan (crew_conversation.py:685-689) — so the accepted escalation vanishes silently.

The required window is an ordinary crash between append and async flush — not mutually-contradicting timing, not inputs the writer cannot produce. The recovery path is deletion, not reconstruction: the content is unrecoverable. I cannot state a rarity argument that a human would plausibly accept the residual risk, so the FLAG evidence bar is not met. When torn, UPHOLD-FENCED.

[ADJUDICATION] f2ba19cd1ee050e6f6b7ee8c0f0eba6f6e80d598 total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] f2ba19cd1ee050e6f6b7ee8c0f0eba6f6e80d598

[ADJUDICATION-FENCED] f2ba19cd1ee050e6f6b7ee8c0f0eba6f6e80d598 fenced=1 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/dashboard/session_control.py:2414 -- An ordinary crash between the surfaced append and the slot's async flush silently loses an accepted escalation, which reconcile then retracts as an orphan; the window is not extreme, so residual risk cannot be waived.
[GPT-ADJUDICATED-FENCED] f2ba19cd1ee050e6f6b7ee8c0f0eba6f6e80d598

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

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 45b7ea75b37b39142b65a5b9cb1eb74a9cec3699 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All evidence gathered. Counts verified: participants/sessions are written and serialized in crew_conversation.py but read nowhere (backend grep: only lines 273–280, 366, 962–963 — all writer/serializer sites; frontend useEscalationIndex.ts reads entries only); pending_escalations has one website hit, the type declaration in client.ts, while the badge reads needs_you (MembersPage.tsx:636). No pins deleted; temp-screenshots/ and website/capture/ follow an established convention with hundreds of siblings.

First-Principles-Verdict: CONCERNS

The conversation index ships future-proof fields nobody reads, and much of the new backend keeps a store its own spec calls a re-derivable projection.

Not justified as shipped

  1. The persisted conversation index — zero consumers on most of its surface: of the fields GET /api/members/{slug}/conversation returns, only entries has a reader; participants, sessions, conversation_id, and the pending_escalations count (roster and view) have none, and the spec justifies the list shape only by "a later multi-member goal:<id> conversation".

What this change ships

Intent: let an unattended crew member raise a non-blocking decision to its human and keep working — an ADDITION. (More than 10 items; the 10 most visible kept.)

  1. A member or its worker can raise a decision to the human (session_escalate), without blocking — justified
  2. The question lands as a card in the owning member's DM thread; a readable row on every other chat surface — justified
  3. The card offers option chips, a countdown and a stated default; one click answers it — justified
  4. The bell rings once per goal and deep-links to the member — justified
  5. Roster and sidebar show a per-member "needs you" badge — justified
  6. A per-member conversation.json index plus an owner-only conversation endpoint — zero consumers (see above)
  7. Member DM threads now read as a conversation: tool/process rows fold behind a disclosure, a "Working…" line stands in — justified
  8. Channel agents cannot escalate (containment list plus backend gate) — justified
  9. Only the owner's own composer replies can answer an escalation; peer sends, cron and internal callers never can — justified
  10. A member with 50 open escalations is refused until some are answered — justified

Watch

  • Two stores kept in agreement: the spec says "the transcript is the truth and the index a thin projection of it", and reconcile_with_transcript proves it by rebuilding the whole index from the transcript — yet an index write failure refuses delivery (escalation_index_unavailable, 500), and a large share of the diff (orphan grace, generation keys, phantom candidates, provisional reopen, per-slot mark chains, merged-batch replay) exists solely to keep the copy agreeing with the truth. A memory-only pending view primed by the same replay this PR already runs on every roster read would remove that whole consistency class.
    Clears when: a fact is named that the index alone holds and the transcript cannot supply, or the file is dropped for the primed in-memory view.
  • Speculative record shape: participants and sessions are maintained, evicted and serialized but never read (0 readers; greps above), supported only by "a later goal:<id> conversation is a new key shape, not a schema migration".
    Clears when: a real reader lands, or the two lists are dropped.

Subtractions

  • Drop participants/sessions and _ensure_participants/_ensure_session from src/kiro_crew/crew_conversation.py — 0 readers; reintroduce with the first feature that has a second participant.
  • Drop pending_escalations from the roster row (handlers/members.py) and public_view — 0 consumers (website grep: 1 hit, the client.ts type declaration); needs_you is the form the UI reads.
  • Defer conversation.json itself: keep the in-memory pending view and the transcript replay that already rebuilds it, and add the file only when a fact the transcript cannot hold appears.

[FIRST-PRINCIPLES-REVIEWED] 45b7ea7

@github-actions

github-actions Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 45b7ea75b37b39142b65a5b9cb1eb74a9cec3699 — this comment is updated in place on each push.

Review details

The candidate's mechanics check out (503 raised by escalate_to_user, _refusal maps only 403/404/409/429/500 → everything else 400), but the observable-harm leg (c) fails. The route is MCP-only (_STRICT_INTERNAL_API_PATHS, registered under _register_mcp_routes), and its sole consumer — session_escalate in mcp_dashboard.py — reads the JSON body via _http_error_body (resp.get("error")/code), never the HTTP status. Both 400 and 503 yield the identical {"error", "code"} dict to that caller. The claimed harm is a "status-aware HTTP client (or retry middleware)" that does not exist in the repo — a hypothetical future/external consumer, which the candidate itself concedes. That is a "could/might" outcome, not a concrete one.

No other grounded defect surfaced in the changed lines.

No findings.

[OPUS-REVIEWED] 45b7ea7

Verdict parsed from the review's SHA-scoped output markers for commit 45b7ea75b37b39142b65a5b9cb1eb74a9cec3699.

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

@CrysisDeu
CrysisDeu force-pushed the feat/crew-conversation-index branch from 3be88bd to 0675595 Compare September 5, 2026 01:50
@CrysisDeu
CrysisDeu force-pushed the feat/escalation-user-peer branch from 916eda8 to 2e8d603 Compare September 5, 2026 01:51
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 5, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/crew-conversation-index branch from 0675595 to 1d1628e Compare September 5, 2026 02:07
@CrysisDeu
CrysisDeu force-pushed the feat/escalation-user-peer branch from 2e8d603 to 7e122ff Compare September 5, 2026 02:07
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 5, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/crew-conversation-index branch from 1d1628e to 032d9e7 Compare September 5, 2026 02:27
@CrysisDeu
CrysisDeu force-pushed the feat/escalation-user-peer branch from 7e122ff to c7e3957 Compare September 5, 2026 02:27
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 5, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Spec says the projection folds by goal; no such fold exists — accurate: goal's consumers are the bell group_key and the card's chip. The sentence in session-control.md is corrected locally to say exactly that and rides with the next push (a doc-only line is not worth superseding the round now running).

no goal-based fold exists in chatProjection.ts

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Drop participants / sessions / conversation_id; drop simulateEscalationState; drop pending_escalations — the grep is right: none of the three record fields is read by the frontend beyond a type, pending_escalations on the roster row has no frontend reader today (my earlier disposition over-claimed a consumer; corrected here), and simulateEscalationState only decides rows whose index entry has not arrived. Declined for this PR as a scope call rather than on the merits: the record fields are the index's stable shape shared by the Python writer, its tests and the spec, pending_escalations is one integer per row that the badge's count is derived from, and the simulation is the only thing that closes a card during an index outage. Each is a candidate for the subtraction follow-up; recorded as such rather than re-cutting a merged surface in the same PR.

zero consumers (grepped: writers, tests, and an unread client.ts type only

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Transcript rewrites leave the escalation index stale on the conversation view (span=96b17a80a753) — accurate and fixed in f493797024ffcd91fad4347ffe95cb79ccb33685, as suggested: the per-member reconcile step is extracted from the roster into _reconcile_member_sync and GET /api/members/{slug}/conversation runs it before it reads, so both readers of the index — the roster's count and the thread's own card view — re-derive from the transcript first. Same generation gate (persisted-transcript mtime + live-window length, plus the unreadable-index override), so an unchanged member costs a stat. Pinned by test_conversation_endpoint_reconciles_a_rewound_reply_without_a_roster_read: answered record, transcript rewound to drop the reply, the conversation view alone reopens it and lights needs_you.

Owner rewind removes an answering reply -> card polling reads the stale index without reconciliation -> the escalation remains answered and its needs-you signal stays cleared.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • A merged non-owner entry discards the owner's explicit answer (span=db37e66c9e96) — accurate and fixed in ee56ec609d689321b8740b0cc3f4df90836c326f, as suggested: in a member thread _dequeue_next_message now breaks the queue merge at a human-provenance boundary, so entries the owner's composer stamped human_reply never share a merged row with an unstamped neighbour (a peer's session_send, a cron prompt, an automation post); the neighbour drains on its own row next, order preserved. The all-or-nothing stamp rule in the drain stays as the backstop. Scoped to member slots — the only place human_reply decides anything — so ordinary chats merge exactly as before. Pinned by test_member_thread_merge_breaks_at_a_human_provenance_boundary and test_non_member_slots_still_merge_across_provenance.

Owner reply → queue merge with non-owner post → row loses human_reply → escalation remains pending and may default.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Default escalation renderer missing from the feature map (span=2f6082500a24) — accurate and fixed in ee56ec609d689321b8740b0cc3f4df90836c326f: pages/chat/EscalationNotice.tsx is now named in the Crew Members row's frontend column, annotated as the default escalation row on every other chat surface.

Added pages/chat/EscalationNotice.tsx → default escalation rendering ships → no map row names its frontend owner.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Unknown receipts discard option-send recovery state (span=42cfccb1d7fb) — accurate and fixed in 62d4d98e24d2908ae0976f63a737941a9660ff30, as suggested: the in-flight record is now deleted only on a READABLE receipt; on unknown / response-late it is retained, since the send may have queued under an id this pane will never learn and that record is the only one a cancel of the card can find (by wire text). If the send in fact dispatched, the retained entry is the same three-string orphan the stash already tolerates.

Unreadable accepted queue receipt -> cancellation misses both stashes -> the option label is appended to the user's draft.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Closed-state copy asserts the default ran — repeat (dispositioned on b6b640c); unchanged: recorded for the copy/screenshot follow-up, where the closed-state line will read as the member's declared intent.

the human-facing card says "Default applied: {{action}}"

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Settlement is a second consumer of queue/rewind/merge semantics — accurate; that coupling is the price of "the transcript is the truth". Each dependency is pinned by a test that fails on its own (provenance boundary, generation reconcile, per-slot hook chain), so a future change to queue or history internals turns red here instead of silently defaulting an escalation. Accepted trade-off.

Future changes to history/queue internals can si[lently break settlement]

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Option chips read as send-on-click — repeat; the radio dots, pick hint and restated send button are the mitigation and are to be re-read on fresh stills in the screenshot follow-up.

"clicking one sends that choice as my reply → sure"

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • "Reply sent" while the reply is queued — accurate and new: when the receipt names a queueId the card knows the reply is queued behind the member's turn, and a queued-specific line ("Reply queued — sends when Radar finishes its turn") would be truer than "Reply sent"; a stack-cancel then unlocking the card is the designed path (the reply never went). Deferred into the same copy follow-up (13 catalogs) rather than a copy-only CI round; the card's latch behaviour is unaffected.

escalation_sent says "Reply sent" while the reply is queued behind a running member turn

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Screenshots stale / closed states unshown / gif too large — repeat of three items dispositioned on b6b640c; unchanged: the re-capture (card at HEAD, closed states, a smaller recording) is the first follow-up on this PR.

recapture escalation-card.png at HEAD

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • participants / sessions have zero consumers; delete them — repeat (dispositioned on b6b640c as a scope call); unchanged: they are the index's stable shape shared by the writer, its tests and the spec, and the subtraction is recorded as a follow-up candidate rather than re-cut in a merged PR.

0 consumers (grepped participants in src/**

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • The index persists a projection the change fully re-derives — repeat (three heads running); position unchanged: the persisted copy is what makes the 50-open ceiling atomic across processes and needs_you a loop-synchronous read on start, and the rebuild path exists so that a corrupted copy is repaired from the transcript rather than trusted.

reconcile_with_transcript rebuilds every record from the transcript

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Patrol-round fold is farthest from the stated job; defer it — accurate that it is separable; it is feat(members): chat-profile projection and escalation cards in the DM thread #8614's scope (the DM thread read as a conversation), folded in when the stack collapsed, with its reader named in that PR's body (a thread where every quiet patrol round is a full row between the human's message and the reply). Kept; not splitting a merged PR a second time.

Defer the patrol-round fold (ChatFoldRow.tsx + its projection branch)

@bolichen97

Copy link
Copy Markdown
Contributor

@CrysisDeu I audited every open PR for relationships, and this one (audited at ee56ec6; the head has since moved to 62d4d98) overlaps textually with your own #8947.

The overlap is four files: website/src/pages/members/MembersPage.tsx, website/src/components/ChatPane.tsx, website/src/app-sdk/messageRenderers.tsx, and docs/feature-map/README.md. The sharpest point is the single ChatPane mount line in MembersPage.tsx: this PR appends displayProfile="chat", #8947 appends openSideChat={openMemberSideChat}. In ChatPane.tsx this PR rewrites the props block and the ChatMessageList and composer mount region, which is exactly where #8947 attaches onQuote / onAsk and the FlyingQuote landing wrapper. Both also register a row through messageRenderers.tsx and edit the same Crew Members row in the feature map.

Nothing semantic collides. Escalation cards and the needs-you badge are independent of selection Quote / Ask, and both props can coexist on the mount line. This is a rebase-order question, not a design one.

Suggested order: land this PR first, then rebase #8947 onto it. This PR's merge base is main's tip (12ecd45), while #8947 is 128 commits behind and already conflict-dirty, so it absorbs the ChatPane.tsx rewrite once instead of twice. Worth noting that #8852 is a third claimant on the same mount line (busyMode="steer-only"), so it is cheaper to fix the order across all three of yours now than per PR.

Posted from the 2026-09-08 open-PR relationship audit (read-only, one auditor per PR); reply here if any of this is wrong.

…ate)

A crew member that hits a wall -- a permission it lacks, something only a
person can reach, a one-way door -- gets its own verb to raise it to the
human: `session_escalate(message, deadline?, default_action?, options?,
goal?)`. It never starts a turn: it lands one `escalation` row in the DM
thread of the member that owns the caller (a worker's creating member; a
plain session's own transcript), mirrors it onto the bell bus with a
per-goal group_key, and returns while the caller keeps working.

Its own tool, not a reserved `target` of `session_send` (review): a send
delivers text the target RUNS as a turn, an escalation writes a row and
runs nothing, and a shared name made their policy inseparable. Each
policy site now classifies the verb on its own: in SESSION_CONTROL_TOOLS
(caller identity), in CHANNEL_AGENT_BLOCKED_TOOLS (on send_notification's
grounds -- the bell mirror -- with the backend's linked/mirrored-caller
gate agreeing), granted to members (writes only into their own thread),
mounted-but-gated for the conductors, own schema in MCP_DASHBOARD_SCHEMAS.
`session_send` is back to `target` + `message`; an escalation field on it
is refused as unknown, never dropped.

The per-member conversation index (crew_conversation.py, #8612) rides
here with its consumer: pending records written before the card under a
pre-minted row id, `needs_you` derived and projected on the slots frame
and the roster, replies matched by `meta.escalation_id` or, for typed
text, by exactly-one-pending at the row's position, restore-time
reconciliation against the transcript.

`options` is the card's contract (#8614 renders it); until then the row is
a plain line and the options are readable in the bell mirror, not
clickable -- the tool description promises exactly that. An `escalation`
row ends the follow-up pill scan so a previous turn's `[OPTIONS:]` chips
can never post as the escalation's answer.

--- Frontend (folded in from #8614) ---

feat(members): chat-profile projection and escalation cards in the DM thread

The Crew Members DM thread rendered the member's raw transcript: every tool
row, notice and nudge between the human's message and the member's reply.
That is the right view on the Sessions page and the wrong one for a
conversation. This gives ChatPane a `displayProfile` — `transcript`
(default, unchanged) or `chat` — and mounts the chat profile on the Members
page.

The chat profile is a projection over the same rows (pages/members/
chatProjection.ts), computed client-side so the view can never disagree
with the transcript it is drawn from:

* human messages, the FINAL assistant reply of each turn, escalation cards,
  approval and error rows stay; tool / thinking / notice / nudge / inject /
  subagent rows are hidden and attached to the reply as `meta.chat_process`,
  reachable through a "View process (N steps)" expander;
* while the member runs a turn, a "Working: <tool purpose>" line stands in
  for the hidden rows (WS tool_call -> slotStatusDetail; falls back to the
  tool name, then a generic line);
* consecutive auto-nudge rounds whose reply said nothing new fold into one
  "N check-ins with nothing new" row with its own expander. (Implemented and
  unit-tested; a member thread cannot host an auto-nudge loop today because
  autonudge_authz refuses member-mode slots, so this ships dark until that
  guard is revisited.)

Escalation rows (role `escalation`, from session_send target=user) render
as a card: title, sender, goal chip, markdown body, a live countdown to the
deadline, the default action if unanswered, and option chips that send the
chosen text as the human's reply. Card state is derived on the client —
answered when a later user row exists, expired when the deadline passed —
so it needs no extra fetch. The roster row shows a "Needs you" badge from
the slot frame's `needs_you`. A read-only card variant is registered in the
SDK defaults and on the Sessions page so the row is never drawn raw.

MembersPage.tsx changes are three small hunks (isNeedsYou, the badge, the
displayProfile prop) to stay clear of the in-flight remember-last-member
and driving-sessions work in the same file.

i18n: 21 keys under pages.members.chat in all 12 catalogs + pseudolocale,
with per-language plural forms (CJK _other only; es/fr/pt/it _many; ru
_few/_many); bases registered in pluralKeys.json.

Evidence: temp-screenshots/crew-chat/ — GIF recorded on an isolated pod
against a real member session and real model turns, no fixtures.
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Parking this as draft: we want to design the member->human messaging path holistically (DM thread, notifications, session_send target=user, channel DMs) before landing one more entry point. Will revisit after the design note.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Closing for now (owner decision 2026-09-10). We want the member -> human messaging path designed holistically first — DM thread, notifications, session_send target=user, channel DMs, and how it relates to ask_question (good question @iamwhatever) — before adding another entry point. Design note: research/member-to-user-messaging.md in the crew workspace; the mailbox model (author/recipient-tagged messages, trigger_turn, child -> parent push) will supersede this. Branch stays; a fresh PR will follow once the design lands.

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

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants