Repository navigation
Conversation
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check the accepted crash outcome: a gateway stop mid-turn leaves What this change shipsInventory (9 items) — 9 justifiedIntent: stop a Regenerate whose new turn ends empty (refused, stopped, failed) from permanently deleting the previous reply (#14632). FIX.
[FIRST-PRINCIPLES-REVIEWED] 34c036e Description read[DESCRIPTION-READ] dd200c265b79dc4dbc2434931fc403b9fd378d6f8c55c76281b202316ff8d016 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Check the new in-between screen by hand: the old reply stays visible with the new one streaming under it, then [DESIGN-REVIEWED] 34c036e Description read[DESCRIPTION-READ] 143a1c83de1352133893f79bfeb987665db2d7530400202d05e7ff029aedf80a That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed Review detailsAdvisory only: the history spec still describes the regenerate truncation that this PR removed. FINDING — docs/system-specs/modules/history.md:1450 — the spec still says " [OPUS-REVIEWED] 34c036e |
59e37bf to
53270d3
Compare
|
Addressed the Opus 5 review on
Tests added: restore survives a compaction-notice-only turn; the restored reply is broadcast; a refused re-persist leaves the slot dirty and makes no success claim. Backend Tests (Windows) (7) — |
53270d3 to
86ba435
Compare
|
Addressed the GPT 5.6 review on
|
86ba435 to
b7b2eb7
Compare
|
Addressed the GPT 5.6 review on
1004 tests pass across the touched + adjacent modules; comment-history and black clean. |
b7b2eb7 to
565dc6a
Compare
|
Head
1004+ tests pass across the touched + adjacent modules; comment-history clean. |
565dc6a to
9477319
Compare
|
Head
flake8 / isort / mypy / black clean on the touched files; 973 module tests pass; comment-history clean; disposition here; PR body in lockstep. |
|
Addressed the variant inline-image fidelity finding at The recovery variant loop now persists each variant's inline-image bytes into the transcript's durable attachments store before redaction, mirroring the primary-content call directly above it and the slot save's own variant loop. Added Gates green: regenerate/history/dashboard suites pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, rebased onto current origin/main. |
|
Addressed the recovery-registration finding at Fix: Added Gates green: 1354 regenerate/dashboard/history tests pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, 0-behind current origin/main. |
|
Addressed the residual-truncation window at Fix: the removed reply is now registered as a pending recovery SYNCHRONOUSLY at the truncation (keyed by the original transcript), before the turn runs, so a stop anywhere during the turn is drain-visible. The pre-turn entry is cleared the moment the reply is durable again by any route — a new reply landed and the slot save persisted it, the empty-turn restore spliced it back and committed, or the recovery wrote it to the original transcript. A deleted/absent transcript is still honored (not resurrected). Added Gates green: 1355 regenerate/dashboard/history tests pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, 0-behind current origin/main. |
|
Addressed the stale-pending-entry finding at Fix: on the non-committed same-transcript attach, revert the dirty variant attach to its pre-attach snapshot (so the periodic flush persists no second copy) and recover the old reply through the SAME single drain-registry path (a top-level write, cleared on commit, retried on failure) — mirroring the sibling rebind branch minus the rebind. The drain now owns exactly one copy and cannot duplicate the reply, and no stale entry lingers. Added Gates green: 1356 regenerate/dashboard/history tests pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, 0-behind current origin/main. |
|
Addressed the reply-landed success-path finding at Fix: on the reply-landed path the entry is popped only AFTER a confirmed replacement save (an awaited Added Gates green: 1357 regenerate/dashboard/history tests pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, rebased onto current origin/main (0-behind). |
|
This push carries three recovery-machinery fixes:
Three non-vacuous tests added, all verified. Gates green: 1360 regenerate/dashboard/history tests pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, 0-behind current origin/main. |
|
Addressed the second-regenerate overwrite finding at Fix: the registry is now keyed PER-REGENERATE (a unique id per regenerate), so two regenerates on the same transcript keep distinct entries and the second cannot clobber the first's still-pending recovery. The entry's stored transcript_key is unchanged, so the drain still writes each to the correct transcript; a retry WITHIN one regenerate reuses its own id (replace, not stack); and Added Gates green: 1361 regenerate/dashboard/history tests pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, rebased onto current origin/main (0-behind). |
|
Addressed the absent-transcript finding at Fix: the recovery record now carries an Added Gates green: 1367 regenerate/dashboard/history tests pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, rebased onto current origin/main (0-behind). |
|
Two fixes in this push — one a regression from the previous existed-at-truncation fix, one a plain retention bound: F2 (regression) — F3 — Two non-vacuous tests added (intervening-delete honored despite stale bit; registry bounded), both verified fail-without-fix. The tombstone is bounded (FIFO, 256) and the registry cap is 512. Gates green: 1369 regenerate/dashboard/history tests pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, rebased onto current origin/main (0-behind). |
|
Addressed the unbounded-payload finding at On the cross-process-tombstone finding (F2): the in-memory recently-deleted tombstone correctly honors an intervening delete within THIS process (the common case), and a session that existed at truncation is already honored as a delete by the existed_at_truncation bit WITHOUT any tombstone — so the only residual gap is a second gateway on the same data home deleting a never-flushed conversation mid-regenerate. Making that cross-process-correct needs a durable on-disk deletion marker with a lifecycle that outlives any in-flight recovery in ANY process — i.e. cross-process coordination machinery, the same hard-exit/multi-gateway class deemed disproportionate for this PR. Flagged for the maintainer rather than fixed in scope. Non-vacuous tests: the registry stays bounded by both entry count and byte budget under repeated recoveries (verified fail-without-fix). Gates green: 1369 regenerate/dashboard/history tests pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, rebased onto current origin/main (0-behind). |
|
Three fixes this push: F3+F4 (chat_regenerate.py) — no recovery path bypasses the memory ceiling. The byte cap kept a single oversized entry (the eviction loop stopped at the just-added key), so one huge payload could sit in memory unbounded at either registration site. Now after evicting older entries, a lone entry still over the byte ceiling is dropped (logged) — its in-flight write already ran, so this only declines to RETAIN an over-ceiling payload for the drain, the same bounded loss eviction makes for older entries. Both registration sites route through the one F2 (history.py) — tombstone normalized across alias spellings. The recently-deleted tombstone keyed on the raw string, so it missed the alias forms F1 (history.py:800) verdict: the Three non-vacuous tests added/extended (single-oversize ceiling; byte-cap eviction; alias-spelling tombstone match), all verified fail-without-fix. Gates green: 1370 regenerate/dashboard/history tests pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, 0-behind current origin/main. |
|
Made the recovery-registry eviction LOSSLESS at the ceiling (F1:143). The prior byte/entry cap dropped an over-ceiling or evicted pending recovery with only a warning — trading unbounded memory for data loss, since an entry at the ceiling owes an already-truncated reply. Now Test ( The only residual F1 case is the genuine cross-process delete (second gateway on the same data home) + shutdown-during-save (F1:86) — out-of-scope cross-process coordination, flagged for the maintainer. Gates green: 877 dashboard + 493 regenerate/history tests pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, rebased onto current origin/main (0-behind). |
|
Simplified the recovery-registry bound to a plain entry-count cap, removing the byte-cap + lossless-flush-on-eviction machinery (per the adjudicator's subtraction remedy). The flush-on-eviction was circular: the only thing that fills the registry is a durable write that keeps failing, and the lossless eviction ran that SAME write — so at the ceiling the flush also failed and nothing was evicted, defeating the bound. Removed: _PENDING_RECOVERIES_MAX_BYTES, _PENDING_RECOVERY_SIZES, _PENDING_RECOVERY_TOTAL_BYTES, _recovery_payload_bytes, the _flush_then_forget eviction loop, and the json import they needed. _register_pending_recovery is sync again and keeps only the count cap (_PENDING_RECOVERIES_MAX=512): on overflow it drops the oldest entry (FIFO), which bounds the registry deterministically even when every write is failing — no dependency on the durable write. Test simplified to The only remaining fenced finding is the cross-process-delete / tombstone-ordering class (second gateway on the same data home) — out-of-scope cross-process coordination, flagged for the maintainer. Gates green: 1370 regenerate/dashboard/history tests pass; black/isort/flake8/mypy + comment-history + black-baseline clean. One commit, rebased onto current origin/main (0-behind). |
|
Addressed the three bounded findings from the latest review (head `2752668126`, one commit, rebased on fresh `origin/main`):
Gates green on the rebased tree: regenerate/history/dashboard suites, black (check script), isort/flake8/mypy, comment-history enforced vs origin/main. MERGEABLE, one commit. PR description updated in lockstep. |
|
Addressed the Opus 5.5 blocking finding (close mid-regenerate: restore saves refused by the close fence → out-of-order fallback write + Root cause: when a tab is closed mid-regenerate, Fix (the reviewer's named remedy): these restore saves ARE the retraction's own drain write — sequenced by the close, which awaits them, and the last chance the reply has to reach disk in order — so they now pass Test (red-then-green, non-vacuous): Full regenerate + dashboard suites green; black / isort / flake8 / mypy / comment-history clean. One commit, rebased on current |
|
Addressed both GPT 6.1 blocking findings at root on head F1 (chat_regenerate.py partial-branch rebound recovery — cross-transcript variant leak): on the partial-reply branch, when the variant-attach save finds the slot REBOUND to a different conversation, the recovery to the original transcript was F2 (admission reservation — concurrent-regenerate TOCTOU): Tests (both red-then-green, confirmed non-vacuous):
Full regenerate + dashboard suites green; black / isort / flake8 / mypy / comment-history clean. One commit, rebased on current |
|
Addressed both GPT 6.1 blocking findings at root on F1 (history.py — delete+recreate reinsert). A failed-regenerate recovery was pending; deleting the Slack history and posting to the same thread recreated the same-name transcript, so the existence check saw the file present and the stale reply was reinserted into the recreated session. Added a monotonic per-stem deletion generation on F2 (chat_regenerate.py — shutdown-before-first-segment duplicate). Tests (red-then-green, each confirmed non-vacuous):
Gates: 115 regenerate + 878 dashboard + 403 history/conversation tests pass; black / isort / flake8 / mypy / comment-history (enforced vs |
|
@iamwhatever Thanks for the detailed review — the snapshot-soundness read is right, and I've kept the current design (no inversion). Rebased onto fresh The four asks are addressed: Ask 1 — Ask 2a — the vacuous test now exercises the real field. Ask 2b — new second-op-during-save test. Minor 3 — splice/stat-attach alignment. Minor 4 — reset the restore task. Full local sweep green on the rebased head: black (py310) / isort / flake8 / mypy, the black-baseline and comment-history gates, and the regenerate + dashboard-chat + composition-contract + unattended-guardrails + history suites. Ready for re-review. |
|
Addressed both bounded recovery-reservation/entry leaks in the admission machinery at root (head BLOCKING — FINDING — Tests (both red-then-green, each confirmed non-vacuous):
The existing Gates green on the rebased tree: regenerate (116) + dashboard/contract/guardrails (1280) + history (608) suites pass; black (py310) / isort / flake8 / mypy + comment-history (enforced) + black-baseline clean. One commit, MERGEABLE. |
|
Addressed all four blocking findings at root on F1 — reply identity cleared by a successor before the snapshot ( F2 — retry-exhaustion close deleting an unpaid recovery ( F3 — rebind during eviction recovery authorizing the wrong transcript ( F4 — unbounded deletion-generation retention ( Tests (each red-then-green, verified non-vacuous by reverting the fix):
The turn-owned accumulator (F1) and the pre-save pin-to-authorized-transcript (F3) are designed together — both anchor a turn's restored rows to the identity captured in the turn's own frame rather than a shared, mutable slot field. Gates: black/isort/flake8/mypy, black-baseline and comment-history (enforced) all green; regenerate, history, dashboard, composition-contract and guardrails suites pass (1670). One commit, rebased on current main, MERGEABLE. |
|
Fixed at root in Finding (correct): the F2 "retain unless rows confirmed present" change made Fix: new The F2 invariant is unchanged — an entry is dropped only once its rows are confirmed present in the committed transcript. A read that cannot confirm presence errs on the SAFE side: a raised exception or a not-yet-on-disk row retains the entry ( Test (red→green, non-vacuous): Rebased onto current |
|
@iamwhatever — I inverted the regenerate flow as the Design Review and First Principles reviews both asked, and removed the recovery machinery. The change (head
Removed with the cause-level fix (every race they handled is now impossible, because the reply is never removed before its replacement is committed): the Footprint: 4 source files + 2 test files, a large net deletion (~+150 / −1700 in source). Tests that pinned the old truncate-up-front behavior were updated to the deferred-swap behavior, and new red-then-green tests cover the empty-turn no-op ( |
|
Addressed the GPT 6.1 review on F1 (UPHOLD-FENCED) — The hole was real: Root fix — scope the replacement to the owning turn by generation:
Regression test F2 (FLAG, not upheld) — The adjudication FLAGs this rather than upholding it, and I agree it is a defensible residual:
Fixing it would mean deleting a specific row from the already-persisted on-disk frozen prefix by id and fixing up its counters/cache — i.e. re-introducing exactly the durable-history-surgery machinery ( If a maintainer disagrees, the surgical option is to extend the first-flush rewrite to drop the target id from the archived prefix; I'll implement it on request. The fence keeps F2 mechanically blocking until a repository writer records an override, which I cannot issue as the fork author. Gates: black / isort / flake8 / mypy clean on the touched files; comment-history + black-baseline pass; regenerate suite (70) + dashboard_chat suite (895, incl. the new F1 test) green. Zero host/internal in code and this comment. |
|
Addressed GPT 6.1 F1 (BLOCKING, UPHOLD-FENCED) on head Finding: on a single-segment regenerate the inverted flow removes the old reply row from the live window on first content, so the window ends one row shorter than the index boundary captured at turn start. Fix (root, as prescribed — select the destination by the turn's recorded reply ids, not the pre-replacement window index): Added a non-vacuous red-then-green test ( |
UX Review (Opus 5.5, fork) — 🔴 BLOCKUX-level review of UX-Verdict: BLOCK cannot evaluate: missing a recording of Regenerate. The previous reply now stays on screen while the new one streams below it, then disappears in a hard swap when the turn ends. BlockersThe old reply disappears without a transition when the turn ends.
Evidence gaps
[UX-REVIEWED] 34c036e Description read[DESCRIPTION-READ] 757e157dcfe478b53354461af45f42fd2e3c53d4a80e2304a1fa1945af13b241 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
|
Head
|
|
Dispositions for
|
Regenerate deleted the previous reply and rewrote the transcript before the new turn ran, so a turn that ended with no reply (refused, cancelled before output, failed) lost the reply for good. The endpoint now writes nothing. It arms a RegenerateTarget naming the old reply rows, pinned to the transcript key and slot it authorized. At the turn's end (_end_turn_tail, before the queue hands off) settle_regenerate removes those rows and keeps the old reply as a variant only when the turn recorded a reply, through one pinned rewrite; an empty turn leaves the reply in place. The crew-log ordinal excludes the rows being replaced, so a regenerate stays a retry of the same turn. The dashboard no longer hides the reply optimistically. Fixes kirodotdev#14632 Co-authored-by: Rohan Khanderia <51836404+RohanK6@users.noreply.github.com>
|
Superseded by #23769, which re-applies this fix as one commit on current main. |
Problem / Motivation
Goal: A Regenerate that produces no new reply leaves the previous reply in place instead of destroying it.
Bug fix: pressing Regenerate and then having the new turn end before it produces any content permanently deletes the previous assistant reply. The old reply the user was trying to improve on is gone from the transcript and from disk, with no way to recover it. One concrete trigger is a Regenerate pressed while gateway memory preparation is still running — the turn is refused before it produces a reply — but any early exit from the turn before its first message hits the same path.
Why it matters
This is silent, user-visible data loss on a common action. A user reaches for Regenerate precisely because they value the current answer and want a variation; the failure mode throws that answer away exactly when the retry fails to replace it. There is no undo and no copy left anywhere, so the content cannot be recovered.
Not a goal
What changed (motivation → approach → change)
Symptom. Press Regenerate. If the new turn ends with no reply (refused, stopped before any text, failed), the old reply is gone from the screen and from disk.
Cause. The endpoint deleted the old reply and rewrote the transcript before the new turn ran. The only copy was destroyed before a replacement existed.
Change. Nothing is deleted until a new reply exists.
chat_turn/regenerate_swap.py(new owner):RegenerateTarget,settle_regenerate,note_regenerate_reply,rows_before_regenerate_target.chat_regenerate.py: the up-frontdel+ truncating save +regenerate_save_refused409 are gone; the endpoint arms the target. The done-callback drops a target no turn end settled.queue_cycle._end_turn_tail: callssettle_regenerateat depth 0, before_hand_off_queue, so a queued successor never sees the target.file_changes._note_reply_row(model segments, partial replies) andsegment_flush._append_command_reply(slash-command replies) record the reply on the target.segment_flush: the variant-stash loop moved verbatim into_adopt_pending_variants, so the settle step adopts variants for a reply no flush wrote.save_transaction.save_slot_off_loop: forwardsexpected_disk_older_countto_save_slot_to_history, so the replace write pairs its snapshot with the frozen-prefix boundary read beside it.docs/system-specs/modules/learn-cron-dashboard.md: a row for the new owner in the chat-runner composition table.chat_runner: the crew-log ordinal skips the rows being replaced, so a regenerate is still a retry of the same turn.turnActions.ts: the optimistictruncateAfterIndexand its rollback are removed. The old reply stays on screen until the server replaces it; the settle step broadcastschat_variant_switch, which makes tabs refetch.The replace write passes
expected_history_keyandexpected_slot_namecaptured at the endpoint and the_disk_older_countread with its snapshot, withbest_effort=False. The target records reply row ids, capped at_MAX_SLOT_MESSAGES. A rebind or a same-name recreate during the turn refuses it; a refused or failed write changes nothing in memory, so both replies stay and nothing is lost. Settling at the turn's end keeps the turn-stats and file-change boundaries on the window they were captured for, soturn_stats.pyis untouched and the black-baseline edit from the earlier revision is not needed.Backwards compatibility
Compatible: a Regenerate that produces a reply ends with the same window and variants as before; an empty turn keeps the reply.
Visible during a Regenerate: the previous reply stays on screen and the new reply appears below it until the turn ends, when the two collapse into one reply with the variant switcher.
Accepted outcome: if the gateway stops mid-turn after the turn's own save, the transcript keeps
user, old, newwith no variant link. Nothing is lost, and both rows render as ordinary assistant rows.Reader:
website/src/pages/chat/page/turnActions.ts:handleRegenerate-- chat -- the 409regenerate_save_refusedcode had no reader (git grepon origin/main finds only the endpoint and its test); other refusals still reachshowRefusedPress.Reader:
src/kiro_crew/dashboard/chat_turn/segment_flush.py:_flush_segment-- chat -- still adopts_pending_variantson the first segment (test_pending_variants_are_attached_and_broadcast).Tests
test/test_regenerate_swap.py(new):test_a_refused_regenerate_turn_keeps_the_previous_reply: real endpoint + real_run_chat, provider refuses → old reply in window and on disk. This is the Regenerate permanently deletes the previous reply when the new turn ends before its first message #14632 symptom.test_a_regenerate_turn_with_a_reply_replaces_the_previous_one: real endpoint +_run_chat, provider streams text → window and disk hold only the new reply, variants[old, new]._end_turn_tailsettles before hand-off at depth 0 only.test/test_dashboard_chat_regenerate.py:test_regenerate_empty_turn_keeps_the_previous_replyandtest_regenerate_replaces_the_reply_once_a_new_one_existsreplace the old truncate-and-persist test. Non-vacuous: re-adding the up-frontdel slot.messages[u_idx + 1 :]makes the empty-turn test fail.test/test_chat_regenerate_cov80.py: the tests pinning the up-front write now assert the endpoint writes nothing and arms a pinned target.test_slot_ownership_checkpoint_post_await.pydrops theregeneratecase: the endpoint holds no await after its ownership check now.ChatPageMoreCoverage.test.tsx: the reply stays on screen after Regenerate.Nearby inputs tested: trailing system notice after the reply, a newer
/compactuser row (still refused), slash-command reply, multi-segment reply, Stop mid-stream, recreate, write failure, queued successor.Determinism:
test_regenerate_swap.py+test_dashboard_chat_regenerate.py+test_chat_regenerate_cov80.pypassed 3 repeats (96/96 each,-n 4), and the first two passed in a seeded shuffled order (42/42,-n 0). black / isort / flake8 / mypy (3304 files) / eslint /tsc -p tsconfig.app.jsonclean.Manual verification
N/A — unit coverage sufficient: the two end-to-end tests drive the real endpoint and
_run_chatwith a fake provider and read the transcript back from disk.Screenshots / video
Why no screenshot: no component, layout or style changes; the existing rows and variant switcher render as before, and only the moment the previous reply leaves changes (see Backwards compatibility).
Related Issues
Fixes #14632
Continues the work of @RohanK6 (co-author on the commit), ported onto current
main.Pattern harvest
Rule candidate: review-prompt
Pattern: a replace operation deletes or truncates live state before its replacement exists.
Checklist
Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.