Skip to content

fix(history): keep incognito transcripts on 0.7 (backport #13760) - #15261

Merged
iamwhatever merged 2 commits into
release/0.7.0from
backport/0.7-incognito-transcript
Sep 30, 2026
Merged

iamwhatever merged 2 commits into
release/0.7.0from
backport/0.7-incognito-transcript

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On 0.7.x, an Incognito or Temporary chat keeps its transcript across a gateway restart, and still teaches the product nothing.

Since 0.7.0.8, an Incognito or Temporary chat is gone after every gateway restart. The mode picker promises "Keeps the transcript for tab recovery", and Settings says "Every chat still appears in History". Neither is true on 0.7.x today.

This is a backport of #13760 to release/0.7.0. #13760 is on main and ships in v0.8.0-insider.1. No 0.7.x backport exists yet.

Why it matters

Every 0.7.x user who picks Incognito or Temporary loses the chat on the next restart or update. They cannot reopen it from History.

Not a goal

  • Changing what the modes withhold. Consolidation, lessons, memory injection and the other learning readers still skip a restricted transcript.
  • Resurrecting a restricted tab on its own at boot. open_slots.json still lists persistent tabs only; the chat is reopened from History.
  • The parts of fix(history): keep incognito and temporary transcripts, learn nothing #13760's second commit built on main-only machinery (see below).

What changed (motivation → approach → change)

part change
_save_slot_to_history (dashboard/chat_persistence.py) writes every mode's transcript
recorded memory_mode the strictest of slot, live carrier and on-disk line
restricted line names no memory_store; pins restricted_member_id
turn-start binder (dashboard/chat_runner.py) refuses a restart re-selection that resolves to a different member
title upsert (dashboard/chat_title.py) stamps the restricted mode on a title-born header
bind_session_execution (execution_context.py) folds the line's mode into a carrier-less bind
live slot tightened to the ratcheted line mode on save
rows-only hand-over a restricted tail tightens a persistent replacement's line and lands, instead of being refused
summary (dashboard/chat_summary.py), transfer bundle (dashboard/session_transfer.py: export and tunnel send) also refuse when the on-disk line they read is restricted or unreadable
turn start (dashboard/chat_runner.py) ratchets the slot to its line before binding

The symptom is a lost chat. The cause: _save_slot_to_history returned early for any non-persistent slot, so nothing reached the session JSONL. The fix removes that early return and makes the saved memory_mode a ratchet. A later writer can only tighten it, so a restart never reads back a looser mode than the chat ran under. The learning readers already gate on that field.

This PR is the cherry-pick of b0cc428, the first commit of #13760, which carries the whole fix. chat_summary.py and session_export.py keep refusing a restricted transcript, and suggestions.py skips one when it grounds a prompt. The specs, config/prompt.md and docs/memory-and-learning.md say the same thing.

Conflict resolutions against release/0.7.0:

  • chat_persistence.py, _fresh_fields: kept only the _mode ratchet line. The _remember_reasoning_effort_for_restore call beside it is main-only and was left out.
  • execution_context.py, bind_session_execution docstring: kept the 0.7 one-line summary and the new ratchet paragraph. The vouch= paragraphs describe a main-only parameter and were left out.

The first commit here is the cherry-pick. The second is the 0.7 shape of the core of 043742b. A persistent slot recreated on a restricted line kept reading persistent, so the summary and export, which gate on the slot and read rows from disk, could hand the private rows to a model or a file: the save now carries the line's mode onto the live slot, its restricted marker and the carried execution_context record, and both readers check the line itself. A restricted tail draining onto a persistent replacement's line was refused and lost: it now tightens the line and lands, as on main. A restricted line keeps no carrier, so the restart re-selects the member from agent; the line pins the member id it ran as, and the binder refuses an alias that now names someone else.

Not cherry-picked: 043742b itself (+6056/−419 across 51 files). The rest of it hardens hand-overs and more on-disk readers on top of main-only machinery that 0.7 does not have: guarded-write registration, the retraction fence, TranscriptRevisionChanged, the legacy member-record backfill. A cherry-pick of it conflicts in 10 files against symbols that are absent here.

Backwards compatibility

Compatible: every mode that saved before still saves the same way. A restricted chat gains a transcript file where it had none, under the same memory_mode every learning reader already gates on.

Tests

From #13760, carried as-is:

  • test/test_ephemeral_sessions.py::TestRestore::test_restore_rebuilds_memory_mode locks the restart path: a restricted slot saved to history is restored by a fresh state with its mode. It fails on release/0.7.0 (assert 0 == 1) and passes here.
  • TestHistoryPersistence in test/test_ephemeral_sessions.py and TestSaveSlotToHistory in test/test_temporary_chat.py lock that incognito and temporary transcripts reach disk with their mode.
  • test/test_slot_close_recreation_race.py locks that a same-key persistent recreate cannot relabel a restricted line, and that a restricted hand-over tail tightens a persistent replacement's line, slot, marker and execution record and lands (test_delete_handover_of_a_restricted_tail_tightens_a_persistent_line, ported from main).
  • test_restricted_member_session_persists_transcript_but_no_owner_record in test/test_chat_agent_selection.py drives a restricted member chat through a restart: the line pins the member id, a save with no live carrier keeps it, and a re-selection resolving to another member is refused.
  • test/test_session_transfer.py locks that the bundle refuses a restricted or unreadable line and a slot tightened during the read; test_turn_start_ratchets_a_persistent_slot_to_its_restricted_line locks the turn-start ratchet. Each fails with its guard removed.
  • TestPersistTitle in test/test_temporary_chat.py locks that a title upsert stamps the mode and never loosens it.
  • test_same_key_persistent_recreate_is_restricted_like_its_line in test/test_slot_close_recreation_race.py, plus the restricted-disk-line cases in test/test_session_summary_generate.py and test/test_session_export.py, lock the 0.7-only guard. Each fails with its guard removed.
  • The rest of the touched tests are updated for the new "restricted chats save" contract.

The 30 test functions the cherry-pick adds or edits, plus test/test_session_summary_generate.py and test/test_session_export.py whole, pass locally (162 cases).

#14793 is not included. Its test lives in test/integration/test_memory_bindings.py, and release/0.7.0 has no test/integration/ layer or gateway_boot harness. Bringing it would mean backporting that whole layer, so it is skipped; test_restore_rebuilds_memory_mode covers the restart path at the unit level.

Manual verification

N/A: the restart path is covered by test_restore_rebuilds_memory_mode, and this is a faithful cherry-pick of a fix already running on main.

Pattern harvest

Rule candidate: review-prompt
Pattern: a privacy gate placed on the WRITE of a record whose READERS already gate on the record's own mode field; the write gate loses the record without adding privacy.

no linked issue: backport of #13760 and #14793; the tracking issue belongs to #13760 on main.

An incognito or temporary chat vanished at every gateway restart: since
the member-store simplification (#11780) `_save_slot_to_history` returned
early for a non-persistent slot, so nothing of the conversation reached
the session JSONL while the mode picker still promised "Keeps the
transcript for tab recovery" and Settings said "Every chat still appears
in History". The mode was meant to stop the product LEARNING from a chat,
not to lose the chat, and every reader that learns -- consolidation,
lessons, memory injection, the MCP history tools, the summary, the
workflow and task snapshots -- already gates on the transcript's own
`memory_mode`. Refusing the write bought no privacy those gates did not
already give, and forced a choice between privacy and a usable history.

The slot save now writes every mode's transcript and records the
STRICTEST mode it can see -- the slot's own or the live execution
carrier's, read inside the transcript lock -- so a restart never re-reads
a looser mode than the session ran under. A restricted line names no
`memory_store`: with no execution carrier written for a restricted
session, the store name would read back as the legacy owner claim the
identity backfill refuses, and the restart would refuse the chat; left
out, the restart reads the session as unbound and the next turn
re-selects the member from `agent` under the retained mode. The title
upsert of a restricted slot stamps its mode as well, since the on-send
titler can write the first line of a session and a mode-less header
resurrects as persistent (the ghost header files of the 0.7.0.8 report).

Long term this makes the two modes what their descriptions say: a chat
the user can reopen from History that teaches the product nothing. The
agent prompt, the specs and the user docs say the same thing.

Backport of #13760 (first commit, b0cc428) to release/0.7.0.

(cherry picked from commit b0cc428)
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Verify 0.7's remaining transcript readers (consolidation, lessons, memory injection) gate on memory_mode — the whole premise for writing restricted rows to disk here.

[DESIGN-REVIEWED] a0387fd

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of a0387fd4a9c37eae0b0b2c9b9b0effa3468abb82 — 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.

First-Principles-Verdict: PASS

Verify the second commit against main's 043742b by behavior, not diff — it is a hand-reshaped port, not a cherry-pick, per the description itself.

Not justified as shipped

  • Item 10 — rides along: _P → Path alias rename in test_history_locking_remediation.py, unrelated to the fix and unmentioned; harm-free tidy.

What this change ships

Inventory (10 items) — 9 justified

Intent: FIX — restore the shipped promise ("Keeps the transcript for tab recovery", en.manual.json:2925) that an Incognito/Temporary chat survives a restart on 0.7.x, lost since the #11780 early return; backport of #13760.

  1. Incognito/Temporary dashboard chats persist and reopen from History after restart — justified
  2. Saved memory_mode is a strictest-wins ratchet across slot, live carrier and on-disk line — justified
  3. Restricted line names no memory store, pins restricted_member_id; a reassigned alias is refused at rebind (read at chat_runner.py:8059) — justified
  4. Title-born header now carries the restricted mode (kills the 0.7.0.8 ghost persistent sessions) — justified
  5. Summary, file export and tunnel send also refuse a restricted/unreadable on-disk line (new transfer_slot_not_persistent code) — justified
  6. A restricted hand-over tail tightens a persistent replacement's line and lands instead of being lost — justified
  7. Turn start ratchets a persistent slot to its restricted line before binding — justified
  8. Suggestions prompt skips restricted transcripts, mirroring the existing gate at chat_folder_suggest.py:123,150 — justified
  9. Specs, prompt.md and user docs rewritten from "nothing is kept" to "kept, nothing derived", same commit — justified
  10. Test-only alias rename in test_history_locking_remediation.py — rides along, harm-free

The deleted no-persist test pins recorded the regression, not a decision: the base history.md spec already stated _save_slot_to_history "has no memory_mode gate … already writes its full transcript", and the shipped UI strings promise the same, so the reversal is evidenced and declared. Every learning reader named in the description gates on memory_mode (verified: history_consolidation.py:886, mcp_core.py:2205, session_resume.py:428). Not product shape: a fix restoring behaviour the base spec and UI already pin.

[FIRST-PRINCIPLES-REVIEWED] a0387fd

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 5.6 flagged blocking issues on a0387fd4a9c37eae0b0b2c9b9b0effa3468abb82; Opus 4.8 adjudication downgraded every one of them to advisory. Adjudication downgraded all 1 blocking finding(s) to advisory: the remedy each one requires is disproportionate to the harm it prevents. Read them as advice, not as merge conditions.

This comment is updated in place on each push.

Review details

BLOCKING -- src/kiro_crew/dashboard/chat_persistence.py:4482 -- replacement privacy state is published before persistence
_tighten_live_slot(state, holder, _mode)
Restricted handover + failed atomic_write -> replacement remains falsely restricted despite unchanged persistent transcript.
Anchor: persist-before-you-publish
Fix: tighten the replacement only after atomic_write succeeds.
[BLOCK-MERGE-DOWNGRADED] a0387fd
[GPT-REVIEWED] a0387fd

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

Harm rung: LOW. The tighten at chat_persistence.py:4482 moves the in-memory replacement toward MORE restrictive (persistent→restricted); _tighten_live_slot (chat_persistence.py:3376-3383) is a monotonic ratchet and returns early for mode=="persistent", so a write failure at chat_persistence.py:4625 can only leave the slot over-restricted, never under-restricted. That is the privacy-safe direction, and the in-memory window genuinely holds the restricted original's tail, so marking it restricted is content-correct regardless of write outcome.

Conditions confirmed: restricted-original→persistent-replacement rows-only handoff makes tighten_line true (chat_persistence.py:4455-4469); atomic_write failure (chat_persistence.py:4625). Recovery: disk is unchanged on failure (chat_persistence.py:3355-3360), the tail stays in the in-memory window, and the next flush re-serializes and re-writes it under the now-restricted mode — self-correcting.

Remedy cost exceeds the harm: the ordering is deliberate (chat_persistence.py:4462-4465 — "the live replacement is tightened before the rows are written. Both race orders then reach the same file"). The proposed fix (tighten only after atomic_write succeeds) opens a window in which restricted tail rows sit under a persistent-marked live slot, readable by the summary/export/memory/artifact gates _tighten_live_slot exists to protect (chat_persistence.py:3369-3374) — trading a fail-safe over-restriction for an actual leak.

[ADJUDICATION] a0387fd4a9c37eae0b0b2c9b9b0effa3468abb82 total=1 uphold=0 downgrade=1
DOWNGRADE F1 src/kiro_crew/dashboard/chat_persistence.py:4482 reason=disproportionate-remedy
[GPT-ADJUDICATED] a0387fd4a9c37eae0b0b2c9b9b0effa3468abb82

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

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

I've validated the sole candidate against the actual code.

Falsification of CANDIDATE 1: The candidate claims a fail-open in _refuse_a_rebound_restricted_member when effective_session_key(slot) != slot_history_key(slot), triggered by "a session whose slot.linked_session_key differs from its slot key." But chat_utils.py:769-804 shows the two keys can only diverge when linked_session_key is empty AND channel_origin is True — when linked_session_key is non-empty, both functions return linked_session_key and the keys coincide. The candidate's stated input condition therefore produces equality, not divergence; its premise is backwards. For every session that actually writes RESTRICTED_MEMBER_ID_KEY (a pure dashboard restricted-member slot: channel_origin=False, empty linked), both keys resolve to the same _history_key_for(slot.key), so the pin is written and read under one key. The only real divergence case (unbound channel-origin slot) is not a restricted-member pin writer, cannot be grounded to a persisted pin, and requires assuming unconfirmed paths. (a) is self-contradictory and (b)/(c) collapse to "if a caller were to." Dropped.

No further grounded defect at 80+ survived in the changed lines.

No findings.

[OPUS-REVIEWED] a0387fd

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

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

@iamwhatever iamwhatever changed the title backport(0.7): keep incognito and temporary transcripts fix(history): keep incognito transcripts on 0.7 (backport #13760) Sep 30, 2026
@iamwhatever
iamwhatever force-pushed the backport/0.7-incognito-transcript branch from 0552bd3 to 81ef8a7 Compare September 30, 2026 03:49
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Disposition for the GPT advisory on chat_persistence.py (_tighten_live_slot(state, holder, _mode) before the write, downgraded on 0552bd3):

Kept as is, on purpose. The live holder is tightened before the rows are written so that no reader can see the private rows on disk while the replacement still reads persistent; that is the order main uses too. If the write then fails, the replacement stays stricter than its line, which only withholds learning and summaries from that tab. It never discloses anything, and the replacement's own next save folds the same ratchet. Tightening after the write would reopen the disclosure window this change closes.

The branch has been squashed to two commits for PR Hygiene; the tree is byte-identical to 0552bd3.

@iamwhatever
iamwhatever force-pushed the backport/0.7-incognito-transcript branch from 81ef8a7 to 16a8d97 Compare September 30, 2026 04:04
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Dispositions for GPT on 81ef8a7:

  • F1 (chat_persistence.py, restricted restart re-selects the member from the agent alias): fixed in 16a8d97. The restricted line now pins restricted_member_id, the member id the live carrier ran as, and _refuse_a_rebound_restricted_member in chat_runner.py refuses a turn-start re-selection that resolves to a different member (fails closed on an unreadable line). Covered in test_restricted_member_session_persists_transcript_but_no_owner_record; the test fails with either half removed.
  • F2 (tighten the live holder before atomic_write): downgraded by adjudication; kept as is, reason in the earlier disposition comment (tightening first means no reader sees private rows on disk under a persistent slot; a failed write only leaves the tab stricter).

@iamwhatever
iamwhatever force-pushed the backport/0.7-incognito-transcript branch from 16a8d97 to ff55e6f Compare September 30, 2026 04:24
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Disposition for GPT F1 on 16a8d97 (session_export.py, rebinding during the build moves the post-build line check): real, fixed in ff55e6f. The handler names the transcript key before the build and the post-build check covers both that key and the slot's current key, refusing if either line is restricted or unreadable. test_a_rebind_during_the_build_cannot_move_the_line_check rebinds the slot mid-build onto a persistent key and fails with the pre-build key removed from the check.

…heted line

The 0.7 shape of the core of #13760's second commit.

A persistent slot recreated on a key whose line a restricted slot already
tightened kept the line restricted, but the slot itself still read
persistent. The session summary and the file export gate on the slot's mode
and then read the whole transcript from disk, so they would hand the
original's private rows to a model or a file. The save now carries the
ratcheted mode onto the live slot and its restricted marker, folds the
carried execution_context record to the line's mode, and the summary and
export also check the on-disk line, failing closed on an unreadable one.

A restricted original's unsaved tail draining onto a same-key persistent
replacement's line was refused, so the close returned 500 and the rows the
user was watching were lost with no retry path. The rows-only drain now
folds the ratchet too: the line is tightened to the stricter mode, its store
name is dropped, the live replacement is tightened, and the rows land.

A restricted line keeps no carrier and no store, so the first turn after a
restart re-selects the member from the `agent` alias. The line now records
`restricted_member_id`, the member id the live carrier ran as, and the
turn-start binder refuses a re-selection that resolves to a different member
(an alias since reassigned) instead of binding that member's memory.

The shared transfer bundle (file export and tunnel send) checks the line of
the transcript it read, after the read, and the live slot, refusing with
TranscriptWithheld. A turn first ratchets its slot to the line, so the
binder never builds a persistent execution over a restricted conversation.
@iamwhatever
iamwhatever force-pushed the backport/0.7-incognito-transcript branch from ff55e6f to a0387fd Compare September 30, 2026 04:39
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Dispositions for GPT on ff55e6f (both real, fixed in a0387fd):

  • F1 (chat_persistence.py, an in-flight tunnel send is not invalidated by a live tightening): the shared bundle builder (session_transfer.py, used by the file export and the tunnel send) now checks the on-disk line of the transcript it read inside the read thread, after the rows, and the live slot after the read, raising TranscriptWithheld; handlers_instances.py maps it to 400 transfer_slot_not_persistent. A hand-over writes its rows and tightens the line in one write, so a bundle whose rows include restricted content always sees the tightened line. Tests: test_bundle_refuses_a_restricted_or_unreadable_line, test_bundle_refuses_a_slot_tightened_during_the_read.
  • F2 (execution_context.py, the bind's ratcheted mode is not returned to the turn): the turn now ratchets its slot to the line before building its execution (_ratchet_slot_to_its_line in chat_runner.py), so the execution the turn uses is already restricted. Test: test_turn_start_ratchets_a_persistent_slot_to_its_restricted_line.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Root cause of the GPT rounds on this PR: the first commit is #13760's commit 1 (b0cc428), which starts writing restricted transcripts. #13760's commit 2 (043742b) carries the guards that make the restricted line authoritative for every in-process reader, and it was not cherry-picked (it builds on main-only machinery). Each GPT round found the next of those guards missing. The second commit here re-implements that intent in 0.7 shape.

Every finding so far, mapped to main (origin/main 89b9e76):

GPT head Finding On main Disposition
ca51d96 restricted restart re-selects the member from the agent alias same code: chat_persistence.py:4850, chat_runner.py:11586 main parity; gap tracked in #15294
ca51d96 disk ratchet leaves the replacement slot unrestricted tighten_replacement_to_restricted_original (chat_utils.py:961), summary via derive_messages_chained (chat_summary.py:365) covered by 043742b on main, not backported; 0.7 shape here
ca51d96 rows-only hand-over drops a restricted tail ratchet instead of refuse (chat_persistence.py:5145) covered by 043742b on main, not backported; 0.7 shape here
0552bd3, 81ef8a7 live holder tightened before atomic_write tightened before the drain write (chat_handlers.py:4156) main parity; downgraded by adjudication
81ef8a7 member replaced under the same alias binds its memory same as row 1 main parity; #15294
16a8d97 export check moves with a mid-build rebind bundle reads via derive_messages_chained_with_keys (session_transfer.py:295-305), session_export.py:366,486 covered by 043742b on main, not backported; 0.7 shape here
ff55e6f in-flight tunnel send not invalidated TranscriptWithheld in the bundle read, handlers_instances.py:1491; the transmit window after the last check is the residual overridden on #13760 covered by 043742b on main, not backported; 0.7 shape here
ff55e6f bind's ratcheted mode not returned to the turn _read_and_tighten_turn_execution (chat_runner.py:519, called at :11625) covered by 043742b on main, not backported; 0.7 shape here

From here, a new finding is fixed on this branch only if this backport introduced it and main does not share it. Anything main shares, or 043742b covers, gets a disposition and a maintainer override request instead of another push.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 30, 2026
@iamwhatever
iamwhatever merged commit 75190f0 into release/0.7.0 Sep 30, 2026
25 of 31 checks passed
@iamwhatever
iamwhatever deleted the backport/0.7-incognito-transcript branch September 30, 2026 05:23
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 30, 2026
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