fix(agent-core-v2): treat cache entries missing required fields as cold misses - #2395
Merged
Merged
Conversation
…ld misses - normalize `archived` to a boolean when mirroring session metadata to the read model, so entries for pre-`archived` sessions no longer lose the key during JSON serialization - add a runtime shape check on read-model cache hits; entries missing required fields are rebuilt from disk and overwritten, self-healing poisoned entries written before the fix - log a warning when the TUI session picker fails to fetch sessions instead of silently showing "No sessions found."
🦋 Changeset detectedLatest commit: ac32b14 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
Merged
11 tasks
Pidbid
added a commit
to Pidbid/kkm
that referenced
this pull request
Jul 31, 2026
Pidbid
added a commit
to Pidbid/kkm
that referenced
this pull request
Jul 31, 2026
Pidbid
added a commit
to Pidbid/kkm
that referenced
this pull request
Jul 31, 2026
…Index/sessionIndexService.ts
Pidbid
added a commit
to Pidbid/kkm
that referenced
this pull request
Jul 31, 2026
…sionMetadata/sessionMetadataService.ts
Pidbid
added a commit
to Pidbid/kkm
that referenced
this pull request
Jul 31, 2026
…nIndex/sessionIndex.test.ts
Pidbid
added a commit
to Pidbid/kkm
that referenced
this pull request
Jul 31, 2026
…ssionMetadata/sessionMetadata.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
None — the problem is explained below.
Problem
Sessions whose on-disk metadata predates the
archivedfield could disappear from the session picker (the TUI would misleadingly show "No sessions found."). Two things combined to cause this:archivedwas passed through asundefinedfor older sessions. JSON serialization then dropped the key entirely, writing a cache entry that violates the session-summary contract.What changed
1. Normalize
archivedwhen mirroring metadataProblem:
SessionMetadataforwardeddata.archivedas-is, so pre-archivedsessions wrote cache entries without the key.What was done:
archivedis now normalized to a boolean (this.data.archived === true) before being put into the read model, matching the normalizationreadSummaryalready applies.2. Self-healing shape check on cache hits
Problem: Poisoned entries written before the fix stayed in the cache forever and kept failing contract validation.
What was done:
isSessionSummaryShape) on read-model cache hits inFileSessionIndex. Entries missing required fields are treated as cold misses, rebuilt from disk, and the disk backfill overwrites the bad cache entry.listcold-miss path (bad entry overwritten by backfill) and thegetfallback-to-disk path.3. Log picker fetch failures in the TUI
Problem: When fetching sessions for the picker failed, the error was silently swallowed and the picker showed "No sessions found.", hiding the real failure.
What was done:
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.