[codex] Add AI conversation store coverage - #7722
Conversation
There was a problem hiding this comment.
Pull request overview
Adds focused unit tests for InMemoryAIConversationStore in the AI host module to increase confidence around validation, ownership rules, and retention/expiry behavior.
Changes:
- Added unit coverage for required fields (conversation ID, user ID) when saving.
- Added tests for tenant/user ownership enforcement during overwrite scenarios (including same-owner overwrite).
- Added tests for retention behavior (ephemeral, durable, configured deadlines) and pruning of expired conversations during saves.
Greptile SummaryThis PR fixes a bug where
Confidence Score: 5/5Safe to merge — the changes are a targeted bug fix with consistent coverage across both store implementations and their tests. The diff adds No files require special attention.
|
| Filename | Overview |
|---|---|
| src/modules/Elsa.AI.Host/Services/InMemoryAIConversationStore.cs | One-line bug fix: adds AIConversationStatus.Expired to the ephemeral terminal-state check in IsExpired, consistent with EFCore counterpart. |
| src/modules/Elsa.AI.Persistence.EFCore/Services/EFCoreAIConversationCleanup.cs | Adds expiredStatus variable and includes it in the ephemeral-retention delete filter, mirroring the in-memory fix. |
| src/modules/Elsa.AI.Persistence.EFCore/Stores/EFCoreAIConversationStore.cs | Same single-line fix as the in-memory store — AIConversationStatus.Expired added to IsExpired for ephemeral mode. |
| test/unit/Elsa.AI.Host.UnitTests/InMemoryAIConversationStoreTests.cs | New dedicated test class with 11 focused scenarios; covers validation, ownership, all retention modes, the new Expired terminal state, pruning survival, and case-insensitive ID matching. |
| test/unit/Elsa.AI.Host.UnitTests/AIRegistrationTests.cs | Removes in-memory store tests that were relocated to InMemoryAIConversationStoreTests; remaining registration tests are untouched. |
| test/unit/Elsa.AI.Persistence.EFCore.UnitTests/EFCoreAIConversationStoreTests.cs | Converts the single-status ephemeral-hide fact to a three-status theory and adds an Expired ephemeral entry to the cleanup test, updating the expected deletion count to 3. |
| Directory.Packages.props | Promotes six CShells packages from 0.0.24-preview.132 to the stable 0.0.24 release. |
| NuGet.Config | Adds explicit CShells and CShells.* patterns to the NuGet official source mapping so the stable release resolves from nuget.org. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[IsExpired called] --> B{RetentionMode?}
B -->|Ephemeral| C{Status?}
C -->|Completed| D[✅ Expired → evict]
C -->|Failed| D
C -->|Expired NEW| D
C -->|Active| E[❌ Not expired → keep]
B -->|Durable| F[❌ Not expired → keep]
B -->|Configured| G{RetentionExpiresAt?}
G -->|null| H[❌ Not expired → keep]
G -->|past deadline| I[✅ Expired → evict]
G -->|future deadline| H
Reviews (5): Last reviewed commit: "Fix CShells package restore source" | Re-trigger Greptile
| <PackageVersion Include="CShells" Version="0.0.24"/> | ||
| <PackageVersion Include="CShells.Abstractions" Version="0.0.24"/> | ||
| <PackageVersion Include="CShells.AspNetCore" Version="0.0.24"/> | ||
| <PackageVersion Include="CShells.AspNetCore.Abstractions" Version="0.0.24"/> | ||
| <PackageVersion Include="CShells.FastEndpoints" Version="0.0.24"/> | ||
| <PackageVersion Include="CShells.FastEndpoints.Abstractions" Version="0.0.24"/> |
| <packageSource key="NuGet official package source"> | ||
| <package pattern="*" /> | ||
| <package pattern="CShells" /> | ||
| <package pattern="CShells.*" /> | ||
| </packageSource> |
Summary
Adds focused unit coverage for
InMemoryAIConversationStorein the AI host module.The new tests cover:
Validation
dotnet test test/unit/Elsa.AI.Host.UnitTests/Elsa.AI.Host.UnitTests.csprojCoverlet reports
Elsa.AI.Hostat 30.75% line coverage for the targeted test project after this change.