Skip to content

[codex] Add range-aware usage event collection#39

Merged
Miss-you merged 4 commits into
mainfrom
codex/eap-003-range-aware-filtering
Apr 17, 2026
Merged

[codex] Add range-aware usage event collection#39
Miss-you merged 4 commits into
mainfrom
codex/eap-003-range-aware-filtering

Conversation

@Miss-you

Copy link
Copy Markdown
Owner

Summary

  • Add an opt-in range-aware usage event collection interface and metrics for provider candidate filtering.
  • Pass resolved daily/session date windows into providers while keeping final stats.FilterEventsByDateRange as the authoritative event timestamp filter.
  • Add safe lower-bound candidate filtering for Claude, Codex, Kimi, and Cursor, with cross-day, --all, directory override, and timezone boundary coverage.

Verification

  • make fmt
  • go 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 ./stats
  • go test -count=1 ./e2e -run TestEventBasedCrossDayAcceptance
  • make test
  • make vet
  • make lint
  • make build
  • built-binary smoke checks for cross-day daily --json, daily --json --all, and session --json

- 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
Copilot AI review requested due to automatic review settings April 17, 2026 06:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and RangeAwareUsageEventProvider, including helpers for localized inclusive timestamp checks and lower-bound-only ModTime skipping.
  • 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.

Comment thread cmd/daily_test.go Outdated
Comment thread provider/provider.go Outdated
Comment thread provider/cursor/parser.go Outdated
Comment thread provider/kimi/parser.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread provider/codex/parser.go Outdated
- 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
@Miss-you
Miss-you merged commit aff50ca into main Apr 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants