Repository navigation
Conversation
|
Intent: A transcript mirrored from a remote peer crew is never distilled into local semantic memory, no matter which entry point (session expiry, |
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The fence is written only when a consolidation pass runs while the privacy marker is still on the header — a transition before the first pass leaks. Watch
[DESIGN-REVIEWED] 011a410 |
GPT 5.6 Review — 🔴 changes requested (blocking)GPT 5.6 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/history_consolidation.py:824 -- resuming an unfenced remote transcript loses its privacy boundary (origin: validation) Adjudication (Opus 4.8) — is blocking on each finding proportionate?I have enough to rule. Key findings from the code I opened:
The scenario — a remote session resumed locally (an intentional, supported operation per the code comment) before its small transcript was fenced — is an ordinary path, not one requiring mutually contradicting timing or inputs the writer cannot produce. The consequence is silent, unrecoverable cross-context leakage of peer-authored content into local semantic memory. I cannot complete a rarity record that a human would accept this residual risk, so the FLAG bar is not met. Harm rung: UNBOUNDED (privacy boundary / cross-context leak, silent and unrecoverable). [ADJUDICATION] 011a410 total=0 uphold=0 downgrade=0 [ADJUDICATION-FENCED] 011a410 fenced=1 flagged=0 False positive or not applicable? A repository writer can comment: |
Opus 4.8 Review — ✅ no blocking findingsReviewed Review detailsI've reviewed both candidates against the code. Candidate 1 (private rows leak after the slot-owned marker clears): The fencing feature is entirely new in this PR — before it, remote/incognito transcripts leaked unconditionally on the Candidate 2 ( No Step 2 additions: the No findings. [OPUS-REVIEWED] 011a410 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify that a non-racing dashboard edit already leaves a replaced tail unextracted — preserving the stale offset in What this change shipsInventory (9 items) — 9 justifiedIntent: stop remote-mirror and incognito/temporary transcripts from being distilled into local memory — a FIX (documented invariant at
[FIRST-PRINCIPLES-REVIEWED] 011a410 |
e4104d6 to
24038b3
Compare
|
|
|
24038b3 to
5d88eea
Compare
|
|
5d88eea to
31c4496
Compare
|
|
…local memory Two kinds of transcript on this disk must never be distilled into local memory: the local mirror of a session bound to a remote peer (the relay mirrors a remote turn's frames through ordinary local slot.append calls, which is what makes the mirror faithful and also lands peer-authored conversation in local history), and a session running incognito/temporary (history.py defines those modes as never summarizable). The consolidator checks neither: history_consolidation carries no executor, memory_mode or privacy gate of any kind, so a distilled summary of another machine's conversation -- or of a session the user was promised leaves no memory -- can be re-injected into unrelated local sessions, carried into `kirocrew snapshot`, and surfaced in local full-text search. Gate it inside _consolidate, for the same reason the retry-eligibility gate beside it lives there: every entry point funnels through that function, so a caller carrying no check of its own still cannot leak. That is not hypothetical -- `kirocrew consolidate --all` globs every transcript on disk with no filter, and the session-expiry consolidator has no restricted-session check at all. The guard sits inside the function's existing try so the finally releases self._running on every outcome; callers claim that key before dispatching and rely on the release. One get_metadata_status read yields three outcomes. executor == "remote" or is_incognito_transcript(memory_mode) -- the shared predicate in history.py -- is PRIVATE: the pass fences the transcript instead of distilling it. ConversationLog.fence_consolidation reads the message count and rotation generation and advances last_consolidated to that count through mark_consolidated, all under one re-entrant _locked hold and without handing a row to the consolidator; the write is offloaded like the sibling I/O and sits inside the try so a failure releases the claim. Read-time refusal alone is not durable exclusion: both markers are slot-owned, so a slot that unbinds from its peer or a session whose memory mode returns to normal clears them, and the next pass would read the same rows as local. Behind the marker they stay out of memory across that transition, only rows appended afterwards consolidate, and the idle sweep stops re-classifying the key every tick because nothing is left unconsolidated. The pass returns the completed-pass value: the marker write is the pass for a private transcript, and a repeat pass rewrites nothing. last_consolidated therefore means every row below it is settled, distilled or fenced on purpose, and its docstring says so. An absent or unrecognized value is LOCAL, matching is_incognito_transcript's documented convention. An unreadable header, or a read that raises, is UNKNOWN: the pass returns _CONSOLIDATION_REFUSED, which every caller's done-callback already reads as "no pass ran", so offsets and mark_consolidated stay untouched, the failure budget is not charged, consolidate_now returns False, and a later pass retries. Both headers are slot-owned, so a slot save clears a stale value by omitting it. The CLI skip line names the general condition since the sentinel now has two causes. The fence only holds if nothing later moves the offset back below the fenced rows. A transcript rotation (history_rewrite, when the file exceeds its size cap) wrote last_consolidated = 0 even though it knows exactly how many rows it dropped, so a private session long enough to rotate after its marker cleared would re-enter local memory on the next pass. Rotation now rebases the offset to max(0, old - len(dropped)): a fully fenced transcript stays fully fenced, local rows appended after the transition keep the fence at the same boundary, and the rotation_generation bump still rejects an in-flight consolidator's stale write. mark_consolidated's two stale-write fallbacks (generation mismatch, offset beyond the message count) preserve the bounded on-disk value instead of writing 0, so a racing consolidator cannot lower the fence either, and the retry budget is released only when the caller's offset was actually applied (an explicit offset_applied flag, not value equality). Two behaviour changes for ordinary local transcripts follow: the retained tail is no longer re-distilled after every rotation, and a dashboard edit racing a consolidation no longer re-extracts the replaced tail via the stale completion; the edit owner carries the offset, as the non-racing rewrite path already does. Rotated rows go to the archive directory, which no consolidation path reads. The memory spec (docs/memory-and-learning.md) states the three outcomes under Consolidation as the contract every entry point inherits: the fence, the slot-owned markers, the post-transition rows that consolidate by design, and that rotation rebases rather than resets. The history module spec records the boundary ownership: rotation and rewrite own the offset in the new numbering, a stale consolidator never lowers it, archives are outside the consolidation path, and the dashboard-edit trade is named.
31c4496 to
011a410
Compare
|
|
🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days. I reviewed the blockers but they require your input:
First Principles PASSes, Opus 4.8 has no blocking findings, and everything else is green — the two test-file conflict hunks in When you've addressed these, the pipeline will re-assess on its next cycle. |
|
Thank you @cixuuz for this — never distilling a remote or incognito transcript into local memory is important, and your intent was spot on. Main has since covered the same hole through a more complete mechanism: #13760 (keep incognito and temporary transcripts, learn nothing), backed by the read_session_execution persistent-mode guard in src/kiro_crew/history_consolidation.py, which now refuses consolidation whenever memory_mode isn't 'persistent' (remote executor, incognito, or temporary), plus the is_incognito_transcript check and a withhold_restricted re-read under lock. So I'm closing this as superseded. Thanks again for the careful memory-privacy work — if something still feels uncovered, you're very welcome to open a small follow-up. |
Problem / Motivation
Two kinds of transcript sit on this machine's disk that must never be distilled into local memory: the local mirror of a session bound to a remote peer crew, and a session running in
incognitoortemporarymemory mode. When either expires, or when someone runskirocrew consolidate --all, the consolidator summarises it exactly as if it were an ordinary persistent local conversation.Why it matters
A mirrored transcript is another machine's conversation, possibly another person's. An incognito transcript is one the user was promised leaves no memory (
history.pydefines those modes as never summarizable, and the dashboard turn path honours that). Once consolidated, either summary is re-injected into unrelated local sessions, travels insidekirocrew snapshot, and turns up in local full-text search, with no way to tell afterwards which memories came from where. Nothing inhistory_consolidation.pylooks atexecutor,memory_mode, or any privacy marker.What changed (motivation → approach → change)
Peer content reaches the local transcript because the relay mirrors a remote turn's frames through ordinary local
slot.appendcalls; incognito rows are on disk for the live session.The guard lives inside
HistoryConsolidator._consolidate, beside the retry-eligibility gate: every entry point funnels through it, so a caller with no check of its own (kirocrew consolidate --allglobs every transcript; session expiry has no restricted-session check) cannot leak. It sits inside the existingtryso thefinallyreleasesself._runningon every outcome, and the metadata read runs underasyncio.to_threadlike the sibling I/O._transcript_privacy(key)makes oneget_metadata_statusread and returns one of three outcomes.executor == "remote"oris_incognito_transcript(memory_mode)(the shared predicate inhistory.py) is private:ConversationLog.fence_consolidation(key)reads the message count and rotation generation under one re-entrant_lockedhold and advanceslast_consolidatedto that count viamark_consolidated, handing no row to the consolidator. Behind the marker the rows never consolidate even after the marker clears, the idle sweep stops re-classifying the key, a repeat pass rewrites nothing, and the pass returns the completed-pass value.last_consolidatedtherefore means "every row below this index is settled": distilled, or fenced on purpose. An absent or unrecognised value is local. An unreadable header, or a read that raises, is unknown: the pass returns_CONSOLIDATION_REFUSED, which every done-callback already reads as "no pass ran", so offsets and the failure budget stay untouched,consolidate_nowreturnsFalse, a later pass retries, andsrc/kiro_crew/cli.pyprints a retryable skip. Both headers are inSLOT_OWNED_META_KEYS.The fence only holds if nothing moves the offset back below the fenced rows, and rotation did:
src/kiro_crew/history_rewrite.pywrotelast_consolidated = 0when a transcript exceeded its size cap, although it knows how many rows it dropped, so a private session that rotated after its marker cleared re-entered local memory. Rotation now rebases the offset tomax(0, old - len(dropped)); therotation_generationbump still rejects an in-flight consolidator's stale write.mark_consolidated's two stale-write fallbacks (generation mismatch, offset beyond the message count) preserve the bounded on-disk value instead of writing 0, and release the retry budget only when the caller's offset was applied (an explicitoffset_appliedflag, not value equality). Two named consequences for local transcripts: the retained tail is no longer re-distilled after every rotation, and a dashboard edit racing a consolidation no longer re-extracts the replaced tail through the stale completion (the edit owner carries the offset, as the non-racing rewrite path already does). Rotated rows go to the archive directory, which no consolidation path reads.src/kiro_crew/channel_transcript_migration.py's docstring, which cited the reset as precedent for the merge path's invalidation, now cites the rebase; the merge still invalidates to zero because it renumbers every row.src/kiro_crew/docs/memory-and-learning.mdstates the three outcomes, the fence, the slot-owned markers, the post-transition rows that consolidate by design, and that rotation rebases rather than resets.docs/system-specs/modules/history.mdrecords the boundary ownership: rotation and rewrite own the offset, a stale consolidator never lowers it, archives are outside the path, and the dashboard-edit trade is named.executor: remotelast_consolidated, nothing distilled, completed passmemory_mode: incognito/temporarylast_consolidated, nothing distilled, completed passmark_consolidatedafter a rotation or edit_runningreleased, bookkeeping untouched, retried later_runningreleased, bookkeeping untouched, retried laterconsolidateon a refused keydone ✓skipped (retryable; no consolidation pass ran)🟩 added · 🟨 changed · 🟦 unchanged
Tests
test/test_consolidation_remote_guard.py(new, 33 tests including parametrised cases):incognito/temporaryare private case-insensitively; other memory modes are local; an unreadable header is unknown; a raisingget_metadata_statusis unknown.unconsolidated_count == 0,last_consolidated == 3, no LLM call); rows fenced while private stay out after the marker clears (executor dropped from the header /memory_modeback topersistent, two local rows appended, the LLM prompt carries only the local rows and the offset lands at 5); a second private pass rewrites nothing; the idle sweep never reaches_consolidatefor a fenced transcript; a failed fence write propagates and releases the_runningclaim with the rows still unconsolidated andretry_eligibletrue; an unreadable header releases the_runningclaim, leaves offsets andmark_consolidateduntouched, and makesconsolidate_nowreturnFalse; an absent header still consolidates; a local transcript reaches the snapshot; the CLI path reportsdonefor a confirmed private skip.test/test_history_consolidation_guard.py(new, 5 tests): rotation rebases the offset by the dropped-row count (subtract, floor at zero, fully fenced tail stays fenced); a generation-mismatched and an oversized stalemark_consolidatedeach keep the rotation's rebased offset instead of writing 0.Re-pinned in
test/test_history.py,test/test_history_locking_remediation.pyandtest/test_history_consolidation_retry.py: the reset-to-zero contract those files asserted after a rotation or stale write is renamed and asserted as preserve-the-boundary (test_rotation_rebases_consolidatedrecords the local-transcript trade in its docstring), and a stale write whose rejected offset happens to equal the preserved boundary still keeps a capped retry budget. The== 0pins left in place govern different contracts (an interleaving merge invalidates the offset on purpose; a fresh transcript starts at zero).The consolidation and rotation suites pass on this head (827 tests across the guard, arithmetic, history, locking-remediation, retry, coverage, migration, CLI and placeholder files). Mutation checks: moving the guard back above the
tryfails the release/pending test; returning the completed-pass value for an unknown header fails the same test; neutering thememory_modebranch fails six tests including both before-snapshot end-to-end cases; removing the fence call fails nine tests including both lifecycle cases; fencing one row short (total - 1) fails eight, both lifecycle cases among them; rebasing the rotation offset one row short fails both rotation lifecycle cases, and one row long fails eight (both lifecycle cases and the renamed local pin, so the arithmetic is pinned on the completeness side too); setting either stale-write fallback back to 0 fails the matching arithmetic test; removing the generation bump fails the locking-remediation generation test; releasing the retry budget on value equality instead ofoffset_appliedfails the equal-offset cap test.Manual verification
N/A — unit coverage sufficient. Every entry point (
kirocrew consolidate --all, threshold, idle sweep, dashboard trigger, session expiry) calls_consolidate, and the end-to-end tests drive that function with real transcript files on disk.Related Issues
no linked issue: the leak was found while reviewing the adopt path landed in #10288 (which first produced remote-mirrored transcripts on disk) and was never filed separately.
Pattern harvest
Rule candidate: review-prompt
Pattern: privacy or authorization check placed at one caller instead of the single function every caller funnels through, so an entry point added later (or a CLI that globs everything) bypasses it
Rule candidate: review-prompt
Pattern: an early-return guard added above a function's
try/finallyskips thefinallythat releases a claim the callers took before dispatching, and returns the success value for a "could not determine" case so callers advance bookkeeping on nothingChecklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)