Skip to content

refactor(chat-core): route issue-radar and auto-improvement seeds through sendTurn - #9576

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/chat-core-p2-app-seeds
Sep 9, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/chat-core-p2-app-seeds

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Chat-core RFC P2, batch A of #9570: the two non-interactive seed senders — apps/issue-radar/lib/agentSession.ts and apps/auto-improvement/lib/agentSession.ts — stop calling api.sendChat and reading the raw Response through readSendReceipt themselves, and instead call the chat-core transport sendTurn and 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, in website/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/chat re-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:

  • The core contract text for transport-error in chat-core/transport/sendTurn.ts said "the send never left, so restore-and-report is safe", and the SEND_ABORT_MS comment 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.
  • The user-facing failure text is the core's own pages.chatPage.could_not_start_a_new_session copy, with the server's reason appended when it gave one — no more could 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.status Slot Record + navigate Error surfaced
dispatched / queued kept yes —
refused deleted no Could not start a new session (<server reason>); just the sentence when the body carried none
transport-error / response-late, slot stays empty across the bounded re-reads (or the slot is gone) deleted no Could not start a new session — the seed provably never landed
transport-error / response-late, slot holds ≥1 message or the read itself fails kept yes — (the seed is, or may be, running)
unknown kept yes — (accepted, receipt unreadable — deleting would cancel real work)

createdSlotKey is 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: the transport-error doc / label correction above (comment and test-name only; no runtime change).
  • apps/issue-radar/lib/investigate.prompt.ts: stale comment that named api.sendChat.
  • .github/coverage-baselines/frontend.txt: apps/auto-improvement/lib/agentSession.ts now 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 one in review); #9570 added to tracking-issues, this PR to implementation-prs.

Tests

New website/src/test/seedReceipt.test.ts pins settleSeedReceipt under 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.ts mocks sendTurn (the #5909 / #8599 pattern) and pins the table above for both seeders through the shared helper — it previously exercised only issue-radar and stubbed api.sendChat. agentSessionConcludedNoRerun.test.ts and agentSessionResumeMissingSlot.test.ts swap their api.sendChat stub for a sendTurn stub (their seeded() probe now counts transport calls); every assertion is unchanged.

Tested

  • npx tsc --noEmit -p . — clean.
  • npx eslint on the changed files — clean.
  • npm run i18n:check and node scripts/check-i18n-strings.mjs (the CI added-lines gate) — clean; the fallback reuses an existing key, no new literal.
  • Unit tests are left to CI (repo rule for this workstream).

Why no screenshot: no component, layout or styling changes; the only rendered delta is the fallback reason text inside the existing AgentSessionButton error notice (could not seed the session (HTTP <n>) → the pages.chatPage.could_not_start_a_new_session copy) on a refused seed whose body carried no reason.

Refs #9570

@CrysisDeu
CrysisDeu requested review from a team and bolichen97 September 8, 2026 23:16
@CrysisDeu
CrysisDeu force-pushed the refactor/chat-core-p2-app-seeds branch from cbc8053 to 1931862 Compare September 8, 2026 23:17
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of adecc596f88a4d3725bf46cb13ec0f6dd56e15cb and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] adecc59

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

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

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

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of adecc596f88a4d3725bf46cb13ec0f6dd56e15cb — 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 lenses run. Consumer counts: settleSeedReceipt has 2 real consumers (both seeders); the remaining direct api.sendChat( callers outside the transport are 2 (App.tsx:2955, useSceneInteraction.tsx:355), both declared as batch C in the RFC row this PR updates. The rewritten transport-error pin rests on a protocol fact (a fetch rejects identically on a post-delivery connection reset), and the existing resumeIfLive probe answers a different question (liveness, not seed presence), so no duplication. Final review follows.

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 ships

Inventory (10 items, 1 more under cap) — 10 justified

Intent: 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.

  1. Both app launch buttons seed through the shared transport, not their own send/receipt copy — justified
  2. A seed send now gives up after 10 s instead of hanging the launch on a stalled POST — justified
  3. A no-receipt seed is settled by reading the slot (up to 3 reads, 1 s apart) instead of guessing — justified
  4. An empty slot after a no-receipt seed is torn down and reported, not left orphaned — justified
  5. A slot holding the seed is recorded and opened even without a receipt — justified
  6. Launch failure text is the localized "Could not start a new session" copy, no raw HTTP status — justified
  7. Transport-error contract text/test label now reads "indeterminate", not "the send never left" — justified (rewritten pin, but backed by the protocol fact; comment/label only)
  8. New shared settleSeedReceipt policy both seeders call — justified (2 consumers, counted)
  9. Coverage baseline entry removed for the now-covered file — justified
  10. RFC row split into three tracked batches — justified

(One more under the cap: a stale api.sendChat comment reworded in investigate.prompt.ts.)

Watch

The accepted residual — a POST landing after the last re-read runs in a slot /api/chat silently re-creates, unrecorded, while the user was told it failed — sits at symptom level with the cause named as server-side ("needs the send to opt out of slot auto-create server-side") but nothing tracking it.
Clears when: an issue exists for the server-side slot auto-create opt-out, or a late landing is shown not to occur in practice.

[FIRST-PRINCIPLES-REVIEWED] adecc59

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ✅ PASS

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

Reconciliation complete: the diff adds no component, control, or new UI state — the only rendered delta is the seed-failure message inside the existing AgentSessionButton error popover, which changes from developer jargon (could not seed the session (HTTP 503)) to already-shipped localized copy ("Could not start a new session", server reason appended when given). The new probe wait runs under the existing busy spinner, the error asserts a settled fact (the slot was probed empty) rather than hedging, and retry plus the askAgent hand-off remain available. The blind read had nothing to look at because there is nothing new to see — the no-visual-delta rationale in the PR holds.

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

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] adecc59

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable adecc596f88a4d3725bf46cb13ec0f6dd56e15cb: <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 8, 2026
@CrysisDeu
CrysisDeu force-pushed the refactor/chat-core-p2-app-seeds branch from 1931862 to 9b1dbf7 Compare September 8, 2026 23:40
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 8, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • transport-error can cancel a dispatched seed in both seeders — fixed in 9b1dbf7

A fetch rejection cannot distinguish "never left" from "connection reset after the server dispatched the seed", and a seed has no earlier call on the same link to weigh the odds. Both seeders now tear the slot down ONLY on refused; transport-error is treated as indeterminate exactly like unknown / response-late (slot kept, session recorded and opened). This ruling covers every finding that asks a seeder to act on transport-error as a proof of non-delivery.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 8, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • seed teardown fires on transport-error, which is not always "never ran" — fixed in 9b1dbf7

Dropped transport-error from the teardown condition in both seeders; it is now indeterminate (slot kept, recorded, opened), the same as unknown / response-late. The test table pins transport-error on the keep side for both apps.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • error fallback prints raw internal enum literals — fixed in 9b1dbf7

transport-error no longer reaches the error notice at all (indeterminate, no error thrown). The remaining reasonless refusal reads could not seed the session (the server declined) instead of (refused); the server's own reason still wins when present. Pinned by the seed-receipt test for both seeders.
Evidence gap: the only rendered delta is that fallback sentence inside the existing AgentSessionButton notice, so the PR body carries the no-visual-delta waiver naming it rather than a screenshot.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 8, 2026
@CrysisDeu
CrysisDeu force-pushed the refactor/chat-core-p2-app-seeds branch from 9b1dbf7 to 1589f00 Compare September 8, 2026 23:56
@CrysisDeu
CrysisDeu force-pushed the refactor/chat-core-p2-app-seeds branch from 1589f00 to 4bfff54 Compare September 9, 2026 00:08
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • Watch: seeders reinterpret transport-error against the core contract's documented meaning — fixed in 4bfff54

The core doc is where the meaning lives. sendTurn.ts's transport-error entry now states the status as INDETERMINATE (no response; usually never left, but a reset after the server took the POST rejects identically) with restore-vs-proceed as call-site policy; the contract test's "never left the machine" label is corrected to match. The twin app comments shrink to this caller's policy only and point at SendReceiptStatus for the meaning. Composers that restore on it (ChatPane, ChatPage) are unchanged and consistent with the corrected doc.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Suggestion: a genuinely-offline seed records and navigates silently; surface a "delivery unconfirmed" notice — fixed in 4bfff54

transport-error no longer records or navigates: the seeder keeps the slot (a possibly-running turn is never cancelled) and reports Could not start a new session through the launch button's existing error notice -- the same reaction the old bare fetch had when it rejected. unknown and response-late still proceed as accepted, as the old code did for an unreadable 2xx.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • Not justified / Watch: transport-error = "may be running" contradicts sendTurn's own contract text; two meanings ship — fixed in 4bfff54

One meaning, stated once at the core: sendTurn.ts's transport-error doc and the contract test label now say "no response -- delivery indeterminate; reaction is call-site policy". The seeders keep the slot AND report the failure on that status (no silent empty session), so the "offline seed silently records a session that never ran" outcome is gone; only refused tears a slot down.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Subtraction: replace the twin 13-line transport-error rationale comments with a pointer to the core contract — fixed in 4bfff54

Done: each seeder now carries a short per-status policy list that defers the meaning to SendReceiptStatus in chat-core; the reset-after-dispatch reasoning lives only in sendTurn.ts.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Watch: a network drop at launch lands the user in an empty session with no notice, and the button thereafter only resumes it — fixed in 4bfff54

On transport-error the seeder no longer writes the record or navigates. The slot is kept (the request may have gone out) and the user sees Could not start a new session on the launch button, so the next click re-seeds instead of resuming an unexplained empty session -- the old behaviour on the same event, minus nothing.

@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 9, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 9, 2026
@CrysisDeu
CrysisDeu force-pushed the refactor/chat-core-p2-app-seeds branch from b904346 to 40dbfc7 Compare September 9, 2026 01:14
@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Watch: "provably never landed" is only probe-window-deep — /api/chat auto-creates a missing slot, so teardown does not foreclose a late landing — fixed in 40dbfc7 (comment + description name the residual as accepted)

The helper's comment and the PR description now state this as an accepted residual instead of claiming proof: a POST that reaches the gateway after the last re-read finds the slot deleted and is re-created by /api/chat, so that seed runs unrecorded while the user was told it did not start -- the old always-orphan outcome confined to a multi-second corner. The line "a slot that is GONE cannot be running anything" is rewritten to "a slot the server reports GONE is not running the seed". Closing the corner needs the send to opt out of slot auto-create server-side, which is not this caller's to add; findings that ask this PR to make the verdict airtight are covered by this ruling.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Item 5 / Watch: the SEND_ABORT_MS comment still says "the turn is running" for response-late — fixed in 40dbfc7

The comment now says reaching the bound means only that no receipt arrived in time -- usually a late reply, but a POST that never reached the gateway looks the same -- so delivery is indeterminate: not a failure signal and not a delivery receipt. One wording for both no-receipt statuses, matching the status doc and settleSeedReceipt's premise.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Subtraction: un-export seedFailureText — fixed in 40dbfc7

Module-private now; the test asserts the composed text through settleSeedReceipt's reason instead.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Watch: auto-improvement never renders the hook's error, so its seed failures stay silent — rebutted (pre-existing, out of this PR's scope)

On main the auto-improvement consumers already destructure only { openSession, busy } and never rendered error -- the seed-failure notice was unreachable there before this PR and this PR does not touch those consumers. Adding an error surface to AutoImprovementPage is an app UI change (with its own ErrorNotice / hand-off decision and screenshot) outside a transport-routing refactor whose stated scope is zero behaviour change beyond the receipt defects. The copy fix still lands where the notice IS rendered (issue-radar's launch button). Findings that ask this PR to add a new error surface to an app are covered by this ruling.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Watch: worst-case failure now takes ~13 s with only an opacity-50 icon as feedback in auto-improvement — rebutted (bound where none existed; feedback gap is the pre-existing one above)

Before this PR the same path had NO bound: a hung seed POST spun forever. The 10 s transport deadline plus a bounded 3 x 1 s probe is the ceiling, reached only on a no-receipt outcome; issue-radar's pending label covers it, and auto-improvement's missing feedback is the pre-existing surface gap ruled on above.

@CrysisDeu
CrysisDeu force-pushed the refactor/chat-core-p2-app-seeds branch from 40dbfc7 to 6f2a504 Compare September 9, 2026 01:36
@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Watch: the response-late teardown is a NEW corner, not "the old always-orphan outcome confined" — fixed in 6f2a504 (comment + description reworded)

Agreed and stated plainly now, in seedReceipt.ts and the PR body: for a rejected fetch the late-landing residual is the old orphan confined to a corner; for the deadline it is a new failure mode 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 late-landing window against an unbounded hang, and the window (SEED_PROBE_ATTEMPTS x SEED_PROBE_GAP_MS) is documented as a judgement, not a measurement, to be widened if late landings turn up. Closing it outright needs the send to opt out of slot auto-create server-side. This ruling covers the framing of that residual.

@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 9, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • Any slot message can impersonate the seed (probe accepts total > 0) — rebutted (not a defect)

The probed slot is not a broadcast slot: it was created by createSlot in the same call a few hundred milliseconds earlier, its key is known only to this client, and it is linked to no channel, mirror, cron or workflow -- nothing else can address it before the seed. The only writer besides this seeder is the same user in another tab clicking the just-filed session in the sidebar and typing within the 10 s window; in that case the slot holds a live user conversation and recording it is the CORRECT outcome, not corruption -- an unrecorded live session is the r3 orphan this probe exists to prevent. A correlation id would therefore change no reachable outcome. This ruling covers the class of "a foreign message satisfies the seed probe" findings on a freshly minted, unlinked slot.
Maintainer override sentence: /ai-review override gpt 6f2a5044afd1a0ed34ea4adb1d977939c4941009: the probed slot is freshly created, unlinked and known only to this client; any other message in it is the user's own live conversation, which must be recorded.

…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
@CrysisDeu
CrysisDeu force-pushed the refactor/chat-core-p2-app-seeds branch from 6f2a504 to adecc59 Compare September 9, 2026 02:40
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 9, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) September 9, 2026 07:21

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bolichen97
bolichen97 merged commit 5a20118 into main Sep 9, 2026
65 checks passed
@bolichen97
bolichen97 deleted the refactor/chat-core-p2-app-seeds branch September 9, 2026 07:57
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 9, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…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
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.

2 participants