mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-25 11:12:36 -07:00
2.4 KiB
2.4 KiB
Context Pipeline Testing Strategy & Audit
Philosophy: Defense in Depth
Our testing strategy avoids the "endless tax" of brittle tests by strictly separating concerns:
- Unit Tests (Processors, System Fakes, Mappers): Exhaustively test logical boundaries, token math, and state transformations. Driven by shared, DRY test factories (no repetitive boilerplate).
- Component Tests (ContextManager, Orchestrator): Test the wiring and triggers. Verify that barriers block, background pipelines execute, and events fire correctly.
- Golden / E2E Tests: Test emergent behavior. Pass in complex, raw chat histories and assert the exact final projected
Content[]output against committed JSON snapshots.
Audit Checklist & Coverage Tracker
1. The Tooling Library (contextTestUtils.ts)
- Implement
ContextTestBuilderor shared factory functions (createDummyEpisode,createDummyState). - Ensure all existing tests are migrated to use these helpers to establish the pattern.
2. Unit Tests (The Processors & Map/Reduce)
Goal: Ensure every component gracefully handles boundary conditions (budget satisfied vs. deficit), skips protected IDs, and correctly transforms IR.
BlobDegradationProcessor(Completed)ToolMaskingProcessor(Completed)HistorySquashingProcessor(Completed)SemanticCompressionProcessor(Completed)StateSnapshotProcessor(Completed)EmergencyTruncationProcessor(Completed)ContextTracer(Completed)SidecarLoader(Completed)IrMapper/graphUtils(Completed - Handles Multi-Tool Concurrency and Backwards Graph Traversal)
3. Component Tests (The Orchestration)
Goal: Prove the sidecar configuration accurately drives runtime behavior without testing the processor logic itself.
PipelineOrchestrator: Test sync vs. async routing, error swallowing, and trigger setup.ContextManager: TestsubscribeToHistory(Opportunistic triggers).ContextManager: Testproject()(Synchronous barrier triggers).
4. Golden / E2E Tests
contextManager.golden.test.ts: Ensure we have a scenario representing a "Day in the Life" of the CLI (some images, some huge tool outputs, deep history) mapping to a snapshot.
Next Actions
- Audit the ContextManager component tests (opportunistic updates & sync barrier).
- Finalize the End-to-End "Day in the Life" Golden Snapshot test.