feat: TPP passive measurement engine (Story 20.3)#104
Conversation
Implement passive tokens-per-percent measurement that correlates Claude Code log parser token data with utilization poll changes. Creates per-model TPP measurements automatically between benchmark calibrations. - PassiveTPPEngine with accumulation window, reset detection, monotonic guard, 30-min cap, multi-model attribution, and confidence assignment - TPPStorageService extended with storePassiveResult, getMeasurements (filtered queries), and getAverageTPP (aggregation) - PollingEngine integration: captures previous poll, triggers log scan, invokes passive engine in fire-and-forget Task - AppDelegate wiring: log parser and TPP storage created before PollingEngine to enable dependency injection - 20 test cases across PassiveTPPEngineTests and TPPStorageServiceQueryTests
- Extract shared INSERT logic into private insertMeasurementRecord helper in TPPStorageService; storeBenchmarkResult and storePassiveResult both delegate to it, eliminating 60-line duplication - Move logger calls outside NSLock blocks in PassiveTPPEngine accumulation branches; use AccumulationAction enum to return result from lock closure - Story 20.3 status: done; sprint-status updated
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (14)
📝 WalkthroughWalkthroughThis PR introduces a passive TPP measurement engine that processes consecutive usage polls to compute tokens-per-percent metrics. It adds the engine protocol/service, extends storage with query/aggregation methods, integrates into PollingEngine and AppDelegate, includes health tracking, and provides comprehensive test coverage. Changes
Sequence Diagram(s)sequenceDiagram
participant PollingEngine
participant HistoricalDataService
participant PassiveTPPEngine
participant ClaudeCodeLogParser
participant TPPStorageService
PollingEngine->>HistoricalDataService: getLastPoll()
HistoricalDataService-->>PollingEngine: previous UsagePoll
PollingEngine->>PassiveTPPEngine: processPoll(current, previous)
PassiveTPPEngine->>ClaudeCodeLogParser: scan()
ClaudeCodeLogParser-->>PassiveTPPEngine: token aggregates
PassiveTPPEngine->>PassiveTPPEngine: compute deltas, validate resets
PassiveTPPEngine->>PassiveTPPEngine: accumulate or flush window
PassiveTPPEngine->>TPPStorageService: storePassiveResult(measurement)
TPPStorageService-->>PassiveTPPEngine: success/failure
PassiveTPPEngine-->>PollingEngine: PassiveTPPHealth
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Story
20.3: TPP Data Model and Passive Measurement Engine
Test plan
Summary by CodeRabbit
Release Notes
New Features
Tests
Chores