[codex] Add range-aware usage event collection#39
Conversation
- pass daily and session date windows into providers that support range-aware collection - add provider candidate metrics and lower-bound-only file filtering for Claude, Codex, Kimi, and Cursor - cover cross-day, --all, directory override, and event timestamp filtering behavior
There was a problem hiding this comment.
Pull request overview
Adds an opt-in, range-aware usage-event collection path so commands can pass resolved local date windows into providers for candidate narrowing (while keeping stats.FilterEventsByDateRange as the authoritative timestamp filter), plus coverage and documentation for cross-day and --all behavior.
Changes:
- Introduce
provider.UsageEventCollectOptions,UsageEventCollectMetrics, andRangeAwareUsageEventProvider, including helpers for localized inclusive timestamp checks and lower-bound-onlyModTimeskipping. - Wire
daily/session/collector plumbing to resolve date ranges earlier and call range-aware provider collection when applicable. - Implement range-aware candidate filtering (Claude/Codex/Kimi) and in-provider row filtering (Cursor), with expanded cmd/provider/e2e tests and EAP-003 workspace artifacts.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| workspace/EAP-003/verification.md | Records verification commands and acceptance evidence for EAP-003. |
| workspace/EAP-003/test_strategy.md | Documents test plan for range-aware collection and provider filtering. |
| workspace/EAP-003/review.md | Captures pre/post implementation review notes and constraints. |
| workspace/EAP-003/original_impl.md | Describes pre-change flow and risks for EAP-003 context. |
| workspace/EAP-003/new_impl.md | Proposes the range-aware interface and provider filtering approach. |
| workspace/EAP-003/final_impl_v1.md | Finalized design/contract notes for implementation. |
| workspace/EAP-003/final_impl.md | Declares approved implementation scope for EAP-003. |
| provider/provider.go | Adds range-aware collection options/metrics + helper methods. |
| cmd/collect.go | Adds collectUsageEventsFromProvidersInRange and dispatches to range-aware providers when a window exists. |
| cmd/collect_test.go | Tests range-aware dispatch, wrapper behavior, and error propagation. |
| cmd/daily.go | Resolves daily date window before collection; passes range options into provider collection. |
| cmd/daily_test.go | Adds tests for range wiring, invalid-flag precedence, --all full-history behavior, and authoritative stats filtering. |
| cmd/session.go | Expands --until to local end-of-day and passes range options into provider collection. |
| cmd/session_test.go | Adds tests for session range-aware wiring, until-only behavior, and full-history fallback. |
| provider/claude/parser.go | Adds CollectUsageEventsInRange and ModTime-based lower-bound candidate filtering + metrics. |
| provider/claude/parser_test.go | Adds fixtures/tests for range-aware candidate skipping and cross-day file inclusion. |
| provider/codex/parser.go | Adds range-aware collection, path-date overlap logic with 1-day lookback, and ModTime fallback + metrics. |
| provider/codex/parser_test.go | Adds tests/fixtures for skipping inactive files, previous-day inclusion, and recent-modtime inclusion. |
| provider/kimi/parser.go | Adds range-aware collection and wire.jsonl ModTime lower-bound candidate filtering + metrics. |
| provider/kimi/parser_test.go | Adds tests for inactive wire skipping and “modified after until” inclusion. |
| provider/cursor/parser.go | Adds range-aware collection and filters emitted events by localized inclusive date semantics (without ModTime file skipping) + metrics. |
| provider/cursor/parser_test.go | Adds tests for row filtering correctness and explicit directory semantics in range-aware calls. |
| e2e/e2e_test.go | Extends cross-day acceptance with daily --json --all full-history equivalence assertions. |
| docs/plans/2026-04-17-event-aggregation-performance-optimization-task.md | Marks EAP-003 as done and records timeline notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 973cb42988
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- preserve Codex candidates when dated path parsing is unknown - align usage-event metrics with parse attempts - clean up review-noted test and Kimi stat handling
…ware-filtering # Conflicts: # docs/plans/2026-04-17-event-aggregation-performance-optimization-task.md # provider/claude/parser.go # provider/claude/parser_test.go
Summary
stats.FilterEventsByDateRangeas the authoritative event timestamp filter.--all, directory override, and timezone boundary coverage.Verification
make fmtgo test ./cmd ./provider/claude ./provider/codex ./provider/kimi ./provider/cursor -run 'Test(CollectUsageEventsFromProviders_UsesRangeAware|CollectUsageEventsFromProviders_ReturnsRangeAware|RunDaily_DefaultWindowPassesRange|RunDaily_InvalidDateFlags|RunDaily_RangeCandidate|RunSession_ExplicitDateRangeUsesRangeAware|RunSession_UntilOnly|Collect.*UsageEventsInRange)'go test ./cmd -run 'Test(CollectUsageEventsFromProviders|RunDaily|RunSession|ResolveDailyDateRange|ResolveSession)'go test ./provider/...go test ./statsgo test -count=1 ./e2e -run TestEventBasedCrossDayAcceptancemake testmake vetmake lintmake builddaily --json,daily --json --all, andsession --json