src/Orchestration/ConversationCompactor.cs (~700 lines) is one of the most complex classes in the codebase — it implements 5 compaction modes (llm, lossless, hybrid, window, intent), anti-thrash guards, reasoning block handling, and symbol-graph injection — but has no test file.
The existing test suite (tests/FuseraftCli.Tests/) covers validators, strategies, and orchestrators but nothing in ConversationCompactor.
Suggested test file: tests/FuseraftCli.Tests/ConversationCompactorTests.cs
Cases to cover at minimum:
ShouldCompact returns false when history is below threshold
ShouldCompact returns false when anti-thrash guard fires (last N compactions saved < AntiThrashMinSavingsRatio)
TrimToWindow truncates history to MaxConversationAge turns
lossless mode produces a deterministic output without calling the LLM
window mode drops old turns and keeps the system prompt
hybrid mode falls back to lossless if the LLM call fails
IncludeReasoning = false strips thinking blocks from output
- Empty history and single-turn history don't throw
- Post-compaction message count is less than pre-compaction count
The LLM dependency should be faked via the existing IChatClient test patterns already used in MagenticOrchestratorTests.cs.
Files to touch:
tests/FuseraftCli.Tests/ConversationCompactorTests.cs (new file)
src/Orchestration/ConversationCompactor.cs(~700 lines) is one of the most complex classes in the codebase — it implements 5 compaction modes (llm,lossless,hybrid,window,intent), anti-thrash guards, reasoning block handling, and symbol-graph injection — but has no test file.The existing test suite (
tests/FuseraftCli.Tests/) covers validators, strategies, and orchestrators but nothing inConversationCompactor.Suggested test file:
tests/FuseraftCli.Tests/ConversationCompactorTests.csCases to cover at minimum:
ShouldCompactreturns false when history is below thresholdShouldCompactreturns false when anti-thrash guard fires (last N compactions saved <AntiThrashMinSavingsRatio)TrimToWindowtruncates history toMaxConversationAgeturnslosslessmode produces a deterministic output without calling the LLMwindowmode drops old turns and keeps the system prompthybridmode falls back tolosslessif the LLM call failsIncludeReasoning = falsestrips thinking blocks from outputThe LLM dependency should be faked via the existing
IChatClienttest patterns already used inMagenticOrchestratorTests.cs.Files to touch:
tests/FuseraftCli.Tests/ConversationCompactorTests.cs(new file)