Repository navigation
refactor(chat-core): route issue-radar and auto-improvement seeds through sendTurn - #9576
Conversation
cbc8053 to
1931862
Compare
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS The probe-the-slot policy is the right shape: one shared helper, delivery honesty pushed into the transport contract, residuals named rather than hidden. Suggestions
[DESIGN-REVIEWED] adecc59 |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of All lenses run. Consumer counts: First-Principles-Verdict: PASS The 3×1s probe window is, by the author's own comment, "a judgement, not a measurement" — verify it against real gateway latency before trusting the never-landed verdict. What this change shipsInventory (10 items, 1 more under cap) — 10 justifiedIntent: stop the two app seed senders re-deriving the send-receipt contract by routing them through the shared chat-core transport — an ADDITION (consolidation), no reported defect claimed fixed.
(One more under the cap: a stale WatchThe accepted residual — a POST landing after the last re-read runs in a slot [FIRST-PRINCIPLES-REVIEWED] adecc59 |
UX Review (Fable 5) — ✅ PASSUX-level review of Reconciliation complete: the diff adds no component, control, or new UI state — the only rendered delta is the seed-failure message inside the existing UX-Verdict: PASS Transport refactor with one rendered delta: the seed-failure notice drops "seed" jargon and raw HTTP status for shipped localized copy — strictly clearer. [UX-REVIEWED] adecc59 |
Opus 4.8 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
1931862 to
9b1dbf7
Compare
|
self-added: yes
|
|
self-added: yes
|
|
9b1dbf7 to
1589f00
Compare
1589f00 to
4bfff54
Compare
|
self-added: yes
|
|
|
self-added: yes
|
|
|
b904346 to
40dbfc7
Compare
|
|
|
|
|
40dbfc7 to
6f2a504
Compare
|
|
self-added: yes
|
…ough sendTurn Chat-core RFC P2, batch A of #9570. The two non-interactive seeders (issue-radar and auto-improvement `agentSession.openSession`) called `api.sendChat` and read the raw response through `readSendReceipt` on their own. Both now call the transport's `sendTurn` and branch on its receipt status, so the deadline and the six-way classification are the core's, not re-derived per app: refused -> delete the empty slot, report (server reason appended when given) transport-error / response-late -> no receipt, indeterminate (a reset AFTER the server took the POST rejects like a request that never left; a stalled POST may still land), so ASK the slot: the seed is stored as its first message before the turn runs. Empty after bounded re-reads (3 x 1 s), or gone -> delete + report like a refusal; a message, or a probe the server cannot answer -> record + navigate (never cancel, never orphan what may run, never record what never landed) unknown -> keep the slot, record + navigate (accepted, receipt unreadable: deleting would cancel real work) dispatched/queued -> record + navigate, as before Only a seed that provably never ran -- `refused`, or a no-receipt send whose slot stays empty -- tears a slot down. The policy lives once, in `utils/seedReceipt.ts` (`settleSeedReceipt`), called by both seeders. No composer exists on these paths, so there is no recovery policy: the receipt classification is the whole contract. The core's `transport-error` doc said "the send never left, so restore-and-report is safe"; that is over-strong and would have had the seeders contradicting the contract in app comments. The doc (and the contract test's label) now states the status as indeterminate with the reaction left to the call site; the composers that restore on it are unchanged. The failure text is the core's own `pages.chatPage.could_not_start_a_new_session` copy instead of `could not seed the session (HTTP <status>)`. The seed-receipt test now mocks `sendTurn` and pins the mapping for BOTH seeders (it previously exercised only issue-radar); auto-improvement's `agentSession.ts` crosses the per-file coverage floor and leaves the frontend coverage baseline. RFC 4.2 splits the "not started" P2 row into the three #9570 batches. Refs #9570
6f2a504 to
adecc59
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approving at adecc59.
Payload equivalence holds: sendTurn({message, slot}) → api.sendChat(message, slot, undefined, signal, …), and client.ts spreads color_theme/theme_consent_sha/meta/steer only when truthy, so the wire body is still exactly {message, slot}; the only addition is the disclosed 10 s AbortSignal. Receipt parity for every previously classified path (refused → deleteSlot + throw; unknown/dispatched/queued → record; empty body.error falls back to base copy); the only changed outcomes are transport-error/response-late, as the body says, and the probe premise is sound because /api/chat appends the user row before the receipt. No other readSendReceipt call sites re-signatured; the removed string has no other consumer; could_not_start_a_new_session exists in en.manual.json. Tests drive the real seeder → settleSeedReceipt → chatSlotDetail path for both apps with concrete assertions. 1 commit.
Advisory: the four "slot stays empty" cases run the real SEED_PROBE_GAP_MS sleeps (~8 s total wall-clock) under a 10 s timeout — the polling is already pinned under fake timers in seedReceipt.test.ts, so these could stub timers; auto-improvement.md ~L957 still describes the old sendChat sequence (already stale on renameSlot).
…ough sendTurn (kirodotdev#9576) Chat-core RFC P2, batch A of kirodotdev#9570. The two non-interactive seeders (issue-radar and auto-improvement `agentSession.openSession`) called `api.sendChat` and read the raw response through `readSendReceipt` on their own. Both now call the transport's `sendTurn` and branch on its receipt status, so the deadline and the six-way classification are the core's, not re-derived per app: refused -> delete the empty slot, report (server reason appended when given) transport-error / response-late -> no receipt, indeterminate (a reset AFTER the server took the POST rejects like a request that never left; a stalled POST may still land), so ASK the slot: the seed is stored as its first message before the turn runs. Empty after bounded re-reads (3 x 1 s), or gone -> delete + report like a refusal; a message, or a probe the server cannot answer -> record + navigate (never cancel, never orphan what may run, never record what never landed) unknown -> keep the slot, record + navigate (accepted, receipt unreadable: deleting would cancel real work) dispatched/queued -> record + navigate, as before Only a seed that provably never ran -- `refused`, or a no-receipt send whose slot stays empty -- tears a slot down. The policy lives once, in `utils/seedReceipt.ts` (`settleSeedReceipt`), called by both seeders. No composer exists on these paths, so there is no recovery policy: the receipt classification is the whole contract. The core's `transport-error` doc said "the send never left, so restore-and-report is safe"; that is over-strong and would have had the seeders contradicting the contract in app comments. The doc (and the contract test's label) now states the status as indeterminate with the reaction left to the call site; the composers that restore on it are unchanged. The failure text is the core's own `pages.chatPage.could_not_start_a_new_session` copy instead of `could not seed the session (HTTP <status>)`. The seed-receipt test now mocks `sendTurn` and pins the mapping for BOTH seeders (it previously exercised only issue-radar); auto-improvement's `agentSession.ts` crosses the per-file coverage floor and leaves the frontend coverage baseline. RFC 4.2 splits the "not started" P2 row into the three kirodotdev#9570 batches. Refs kirodotdev#9570
Summary
Chat-core RFC P2, batch A of #9570: the two non-interactive seed senders —
apps/issue-radar/lib/agentSession.tsandapps/auto-improvement/lib/agentSession.ts— stop callingapi.sendChatand reading the rawResponsethroughreadSendReceiptthemselves, and instead call the chat-core transportsendTurnand branch on its receipt status. The 10 s deadline and the six-way classification are now the core's, not re-derived per app.Behaviour is unchanged on every path the old code classified except the two no-receipt outcomes — a rejected fetch (
transport-error) and the transport's new 10 s deadline (response-late). Both are indeterminate: a connection reset after the server took the POST rejects exactly like a request that never left, and a stalled POST may still land. The old code threw on the first and waited forever on the second. Instead of guessing, the seeder now asks the slot: the seed is stored as the slot's first message before its turn runs, so a one-row slot read settles it — an empty slot, re-read up to 3 times a second apart so a late arrival still counts, means the seed never landed and the empty slot is torn down like a refusal; a message, or a probe the server cannot answer, means the seed is or may be running, so the session is recorded and opened (never cancelled, never left orphaned for a retry to duplicate); a slot that is gone short-circuits. This is the invariant behind rounds 1–4 of review: never delete what may be running (GPT/Opus r1), never silently open an empty session (Design/FP/UX r2), never orphan a live one (GPT r3), never record an unseeded one (GPT r4). The policy lives once, inwebsite/src/utils/seedReceipt.ts(settleSeedReceipt), and both seeders call it (First Principles r4). One accepted residual, named in the helper's comment: the verdict is only as good as the probe window — a POST that reaches the gateway after the last re-read finds the slot deleted and/api/chatre-creates it, so that seed runs unrecorded while the user was told it did not start. For a rejected fetch that is the old always-orphan outcome confined to a corner; for the deadline it is a new corner, bought deliberately — the old seeder had no deadline, so a stalled POST hung the launch until it resolved and was then recorded. The trade is a bounded wait plus a small, judgement-sized late-landing window (3 × 1 s) against an unbounded hang. Closing it outright needs the send to opt out of slot auto-create server-side (Design r5, First Principles r6). Two other things move:transport-errorinchat-core/transport/sendTurn.tssaid "the send never left, so restore-and-report is safe", and theSEND_ABORT_MScomment said reaching the deadline means "the turn is running". Both are over-strong, and the seeders' handling would have contradicted it in app comments; the doc (and the contract test's label) now states the status as indeterminate, with restore-vs-proceed left to the call site (Design / First Principles, round 2). The composers that restore on it (ChatPane, ChatPage) are unchanged — for a composer a visible duplicate still beats a silent loss.pages.chatPage.could_not_start_a_new_sessioncopy, with the server's reason appended when it gave one — no morecould not seed the session (HTTP 503)(raw status; "seed" is developer vocabulary; the transport does not expose the status line anyway).Receipt mapping (both seeders, identical)
receipt.statusdispatched/queuedrefusedCould not start a new session (<server reason>); just the sentence when the body carried nonetransport-error/response-late, slot stays empty across the bounded re-reads (or the slot is gone)Could not start a new session— the seed provably never landedtransport-error/response-late, slot holds ≥1 message or the read itself failsunknowncreatedSlotKeyis still cleared the moment the send is started (before the await), so a rollback triggered by a later metadata failure can never destroy a slot whose turn may have begun. Only a seed that provably never ran —refused, or a no-receipt send whose slot stays empty — tears a slot down.Also
chat-core/transport/sendTurn.ts+test/chatCoreTransport.contract.test.ts: thetransport-errordoc / label correction above (comment and test-name only; no runtime change).apps/issue-radar/lib/investigate.prompt.ts: stale comment that namedapi.sendChat..github/coverage-baselines/frontend.txt:apps/auto-improvement/lib/agentSession.tsnow clears the 80% per-file floor (86.7% in CI, was 32.6%), so its baseline entry is removed as the Coverage Gate requires.docs/request-for-change/rfc-chat-core-extraction.md: the §4.2 "not started" P2 row is split into the three chat-core P2-rest: route the remaining app-local senders through sendTurn #9570 batches (this onein review);#9570added totracking-issues, this PR toimplementation-prs.Tests
New
website/src/test/seedReceipt.test.tspinssettleSeedReceiptunder fake timers: the mapping, the bounded re-read count and gap, a seed landing mid-probe, the gone-slot short-circuit.website/src/test/agentSessionSeedReceipt.test.tsmockssendTurn(the #5909 / #8599 pattern) and pins the table above for both seeders through the shared helper — it previously exercised only issue-radar and stubbedapi.sendChat.agentSessionConcludedNoRerun.test.tsandagentSessionResumeMissingSlot.test.tsswap theirapi.sendChatstub for asendTurnstub (theirseeded()probe now counts transport calls); every assertion is unchanged.Tested
npx tsc --noEmit -p .— clean.npx eslinton the changed files — clean.npm run i18n:checkandnode scripts/check-i18n-strings.mjs(the CI added-lines gate) — clean; the fallback reuses an existing key, no new literal.Why no screenshot: no component, layout or styling changes; the only rendered delta is the fallback reason text inside the existing
AgentSessionButtonerror notice (could not seed the session (HTTP <n>)→ thepages.chatPage.could_not_start_a_new_sessioncopy) on a refused seed whose body carried no reason.Refs #9570