feat: aggregate daily usage by event date#32
Merged
Conversation
- Switch daily to collect and aggregate UsageEvent records in the selected timezone - Add command tests for event-date splits, timezone filtering, default windows, and JSON grouping - Record EBTA-007 OpenSpec/workspace artifacts and update stale Claude subagent daily e2e semantics
There was a problem hiding this comment.
Pull request overview
Updates codetok daily to aggregate/filter by provider.UsageEvent.Timestamp (localized by --timezone) instead of session start time, and records EBTA-007 workspace/OpenSpec artifacts.
Changes:
- Switch
dailycommand pipeline to collect/filter/aggregateUsageEvents (with injected provider/clock seam for deterministic tests). - Add command-level tests covering cross-midnight splits, timezone date keys, explicit/localized date windows, and model grouping across providers.
- Update the Claude subagent daily e2e expectation to match distinct-session-per-day semantics; add EBTA-007 OpenSpec/workspace documentation.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
cmd/daily.go |
Replace session-based daily aggregation with usage-event pipeline; add provider/clock seam and date-bound conversion helper. |
cmd/daily_test.go |
Add focused command tests for event-date aggregation, timezone behavior, and localized date filtering; add JSON decode helper. |
e2e/e2e_test.go |
Update daily session-count expectation for Claude subagent fixture under event aggregation semantics. |
docs/plans/2026-04-16-event-based-token-aggregation-task.md |
Mark EBTA-007 as done and record verification/review notes in the task board. |
workspace/EBTA-007/todo.md |
Record deferred follow-ups (cross-day e2e fixtures; flag-validation ordering note). |
workspace/EBTA-007/test_strategy.md |
Document EBTA-007 testing gates and focused test cases. |
workspace/EBTA-007/review.md |
Record review result and residual risks. |
workspace/EBTA-007/original_impl.md |
Capture pre-change daily command flow and caveats. |
workspace/EBTA-007/new_impl.md |
Describe proposed event-based daily approach and scope control. |
workspace/EBTA-007/final_impl_v1.md |
Summarize final implementation decisions and review notes (v1). |
workspace/EBTA-007/final_impl.md |
Summarize implemented behavior and verification targets. |
openspec/changes/event-based-token-aggregation-daily-command/.openspec.yaml |
Register new OpenSpec change artifact. |
openspec/changes/event-based-token-aggregation-daily-command/proposal.md |
Motivate and scope the daily event-aggregation change. |
openspec/changes/event-based-token-aggregation-daily-command/design.md |
Document design decisions, risks, and mitigations. |
openspec/changes/event-based-token-aggregation-daily-command/tasks.md |
Track implementation and validation tasks as completed. |
openspec/changes/event-based-token-aggregation-daily-command/specs/daily-event-aggregation/spec.md |
Add formal requirements/scenarios for event-date aggregation and localized filtering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Defer stdout restoration and pipe cleanup in captureStdout - Address Copilot review feedback about FailNow inside capture callbacks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codetok dailyfrom session-start aggregation toprovider.UsageEventtimestamp aggregation.--timezone, explicit date filters, and default rolling windows to localized event dates.Validation
make fmtgo clean -testcache && make testmake vetmake buildmake lintNotes
workspace/EBTA-007/todo.md.