feat(#689): persistent meal-planner session state to prevent RAG leakage#695
Closed
feat(#689): persistent meal-planner session state to prevent RAG leakage#695
Conversation
…ed DataStore Prevents IllegalStateException by sharing the AboutPreferencesModule DataStore instead of creating a duplicate instance. Multiple active DataStore instances on the same file cause crashes. Fixes crash when toggling verbose logging in About screen on PR #649. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…leakage Add conversation-scoped Room-backed session store for meal-planner state, wire it into ChatViewModel to inject structured session context into prompts and suppress episodic/RAG injection during active meal-planner turns. New files: - MealPlanSessionEntity: Room entity with conversationId PK, status, preferences, plan, and day tracking fields - MealPlanSessionDao: DAO with getByConversationId, upsert, delete methods - MealPlanSessionRepository: Convenience layer with createOrReset, updateStatus, updatePreferences, saveHighLevelPlan, advanceDay, markCompleted Changes to existing files: - KernelDatabase: add MealPlanSessionEntity, MIGRATION_23_24, version 24 - MemoryModule: add DAO/repository providers, include MIGRATION_23_24 - ChatViewModel: detect active meal-planner turns, suppress RAG context, inject structured meal-plan context block, force history replay Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Debug APK readyCommit: Updated on each push. Removed when PR is merged or closed. |
Collaborator
Author
|
Rebased and addressed code review: #698 |
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.
Summary
Add conversation-scoped, Room-backed meal-planner session state and wire it into the chat prompt pipeline. During active meal-planner turns, the model receives structured session context (preferences, plan, current day) instead of relying on chat history — and episodic/RAG context is suppressed to prevent stale memory leakage.
Changes
New files
MealPlanSessionEntity.kt— Room entity withconversationIdPK, status, peopleCount, days, dietary/protein preferences (JSON), high-level plan, current day index, updatedAtMealPlanSessionDao.kt— DAO withgetByConversationId,upsert,deleteByConversationId,deleteAllMealPlanSessionRepository.kt— Convenience layer:createOrReset,updateStatus,updatePreferences,saveHighLevelPlan,advanceDay,markCompletedModified files
KernelDatabase.kt— AddedMealPlanSessionEntity,mealPlanSessionDao()abstract method,MIGRATION_23_24, bumped version to 24MemoryModule.kt— Added DAO/repository providers, includedMIGRATION_23_24in migration listChatViewModel.kt— AddedMealPlanSessionRepositoryinjection, session detection block that:buildMealPlanContext()effectiveRagContextForPrompt)needsHistoryReplay = trueto clear stale episodic KV cacheVerboseLoggingPreferenceUseCase.kt— Merge conflict resolution from bringingmainup to date (added missing@ApplicationContextimport)Architecture
Session context block (injected into prompt)
Testing
./gradlew assembleDebug— builds cleanMemoryRepositoryImplTestandLatexConversionTestare unrelated)core:inferenceare pre-existing (unrelated)Next steps (out of scope for this PR)
MealPlannerSkill(stage 4 of the plan)MealPlannerSkillinstruction updates (stage 5)Closes #689