Repository navigation
fix(history): keep stateless cron runs out of the session search window - #34173
Conversation
c70ad29 to
0ad9138
Compare
UX Review (Opus 5.5) — ⏭️ skippedRevision |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level blocker: the window exclusion goes after the cause, and the description lists and accepts the reader that loses content-search hits. Notes
[DESIGN-REVIEWED] 8838d88 Description read[DESCRIPTION-READ] 5c7f6c19e587957ebfbd86a8fa82aa49f86209504d2bdc4afd9413775b19fda4 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix targets the window that stateless runs were filling. The new key predicate restates a run-key regex the prune already has, which is a note, not a blocker. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: let people with a frequent stateless cron job find older chats in session search. FIX.
[FIRST-PRINCIPLES-REVIEWED] 8838d88 Description read[DESCRIPTION-READ] 39b7b41bde71740f3db5cd6e67f2c1692c848562074f32102e873d87b36e7d3d That sha256 names the PR description this verdict read. Recompute it with |
0ad9138 to
8838d88
Compare
Code change approver recommendation: ApproveAutomated, not a person, and not a review: a maintainer still decides.
Why: the decider approves with p_defect 0.12 <= 0.12 and every rail passes. Approve. The PR stops stateless cron run transcripts (cron:<8hex>:<8hex>) from using up slots in the session search window, so older chats are searched again. The filter runs before every window slice (search, warm-up, index backfill) and before the count behind the 'not searched' note. A grep found no other window slice in src/. Runs already in the search index are dropped by the backfill's existing cleanup of keys outside the window, and no transcript is deleted. The cron_run='tab' tag is already written on main (cron_delivery.py:183) before a tab is published. It now reaches listing rows through _apply_metadata, which both the cached listing and the direct scan use. The app-scoped keys= path loses nothing, because cron transcripts have no app owner. The key predicate matches exactly what gets created. New tests would fail without the change, and the spec is updated. Remaining concerns (legacy untagged tab runs, the duplicated regex) are deliberate or minor. If this recommendation is wrong, reply here; the replies are how the approver is evaluated. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (5 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: bug fix; session search leaves untabbed stateless cron run transcripts out of its scan window, so frequent cron runs no longer push older chats out of search, with tests. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/modules/history.md.
…ow (#34173) Backport note: history_search_listing.py is not on release (the listing split of #29452 is unreleased), so its cron_run metadata projection is dropped. Release's three window call sites read list_sessions(), not list_sessions_indexed(), and get the _searchable filter as they are. The cron_run == "tab" exemption serves the per-run chat tab of #31139 (unreleased), so _searchable drops every stateless run by key alone; the docstrings, history.md and the test lose the tab sentences, the tab-run test is dropped and the backfill test expects the two chats only. (cherry picked from commit d503d56)
Problem / Motivation
Goal: Session search finds older chats on a host that runs a stateless cron job every few minutes.
Session search reads only the newest
session.search_scan_windowtranscripts (default 2000). A stateless cron job writes a newcron:<job id>:<run id>transcript on every fire, and each one takes a window slot. On one real host 7,510 of 8,990 transcripts are stateless runs. A 2000-file window there reaches back five days, so a chat from last week is never searched, open or archived. The run-transcript prune (#31757) now keeps 20 tagged runs per job, but it never removes an untagged run, and every run written before theephemeraltag existed is untagged.Why it matters
Anyone with a frequent stateless cron loses content search over most of their history. The dashboard History filter,
search_chat_historyand the channel session picker all share this window, so "where did that chat go?" returns nothing on every surface.Not a goal
title:search.cron:<job id>) or sequential-agent sessions (cron:<job id>:<agent>).What changed (motivation → approach → change)
Stateless cron runs no longer take a slot in the session search window, so the window's slots go to conversations.
cron_service/identity.pygainsis_stateless_cron_run_key, beside the code that mints the key. It matchescron:<8 hex>:<8 hex>in the live and the transcript-stem spelling.history_search.pydrops those keys before slicing the window in the search, the warm-up and the index backfill. They are also left out of theeligiblecount, so the "older sessions were not searched" note does not count them.new_chat_per_runrun that opened its own chat tab is taggedcron_run="tab"and stays searchable.history_search_listing.pycopiescron_runonto the listing row so the window can read it.docs/system-specs/modules/history.mdstates the rule.A persistent job keeps one transcript that can hold a real conversation, so it stays searchable. A sequential-agent session (
cron:<job id>:<agent>) looks like a run only when the agent's name is eight lowercase hex characters. That one case is left out of the window too.Backwards compatibility
Compatible: no config key, API field or stored data changes; only which transcripts a content search reads.
Reader: src/kiro_crew/dashboard/handlers/sessions_parts/history_reads.py:api_sessions_search -- chat -- the History filter no longer returns untabbed stateless run transcripts for a content query; the listing and a bare
title:search still show themReader: src/kiro_crew/mcp_tools/sessions.py:search_chat_history -- subagent -- returns conversations and persistent cron sessions; a stateless run is still readable with get_chat_session by key
Reader: src/kiro_crew/history.py:ConversationLog.search_sessions -- crew page -- the federated instance search and the channel session picker call the same ranking and get the same rows
Tests
test/test_session_search_scan_window.py:TestStatelessCronRunsTakeNoWindowSlotlocks in that newer runs do not push chats out of a window of two, that persistent and sequential-agent cron sessions are still searched, that a run taggedtabis searched while anephemeralone is not, and that the index backfill indexes a tabbed run and no other run.TestStatelessRunKeychecks the predicate against keys minted bybuild_cron_session_context, both spellings, and near-miss keys.Proof: PROVEN test/test_session_search_scan_window.py::TestStatelessCronRunsTakeNoWindowSlot::test_newer_runs_do_not_push_chats_out_of_the_window, test/test_session_search_scan_window.py::TestStatelessCronRunsTakeNoWindowSlot::test_persistent_and_agent_sequence_cron_sessions_are_searched, test/test_session_search_scan_window.py::TestStatelessCronRunsTakeNoWindowSlot::test_a_run_that_opened_its_own_chat_tab_is_searched, test/test_session_search_scan_window.py::TestStatelessCronRunsTakeNoWindowSlot::test_the_backfill_never_indexes_a_run (head 8838d88)
Determinism: the new tests passed 5 of 5 repeats, in a shuffled order, and under
-n 4with the whole file.Manual verification
On the host described above, a read-only count with
is_stateless_cron_run_keyover its session directory: today the 2000-file window ends at a file modified Nov 4; with runs left out, all 1,480 remaining transcripts fit in the window. No UI changes, so nothing else to check by hand.Related Issues
Closes #34135
Sibling sweep
Swept: git grep -nE "_facade_search_scan_window()|search_scan_window()" -- src/
Sibling: src/kiro_crew/history_search.py -- changed here
Pattern harvest
Not generalizable: the window is the only newest-N cap in the tree that a per-fire writer can fill.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)