[codex] Aggregate sessions by usage event date#34
Merged
Conversation
- switch session filtering to localized UsageEvent dates and group filtered events by provider/session - add focused session command tests, OpenSpec change, EBTA workspace artifacts, and update stale Claude subagent e2e expectation
There was a problem hiding this comment.
Pull request overview
Updates codetok session to filter and aggregate by localized usage-event dates (matching the existing event-based aggregation model) while keeping the session JSON/table output shape stable.
Changes:
- Switch
sessionfrom session-start-time filtering to timezone-aware usage-event filtering + aggregation back intoSessionInforows. - Add focused
cmd/session_test.gocoverage for filtering, timezone behavior, grouping, and provider override routing. - Update the Claude subagent e2e expectation and add an OpenSpec change + EBTA-008 workspace artifacts documenting the work.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| workspace/EBTA-008/verification.md | Adds EBTA-008 verification notes, commands, and manual CLI smoke steps. |
| workspace/EBTA-008/test_strategy.md | Documents RED/green evidence and focused coverage targets for EBTA-008. |
| workspace/EBTA-008/review.md | Records multi-agent review outcomes and post-review verification commands. |
| workspace/EBTA-008/original_impl.md | Captures the pre-change session behavior and the motivating gap. |
| workspace/EBTA-008/new_impl.md | Describes the intended event-based session aggregation approach and contract. |
| workspace/EBTA-008/final_impl_v1.md | Outlines a scoped implementation plan for the session command change. |
| workspace/EBTA-008/final_impl.md | Finalizes decisions and test coverage expectations for the implementation. |
| openspec/changes/event-based-token-aggregation-session-command/tasks.md | Tracks task checklist completion for the OpenSpec change. |
| openspec/changes/event-based-token-aggregation-session-command/specs/session-event-aggregation/spec.md | Adds requirements/scenarios for session event-date filtering, timezone use, and provider/session grouping. |
| openspec/changes/event-based-token-aggregation-session-command/proposal.md | Explains rationale and scope of switching session to usage-event aggregation. |
| openspec/changes/event-based-token-aggregation-session-command/design.md | Documents design decisions and risks/trade-offs for the new pipeline. |
| openspec/changes/event-based-token-aggregation-session-command/.openspec.yaml | Registers the OpenSpec change with creation date. |
| e2e/e2e_test.go | Adjusts Claude subagent session JSON expectation to match provider/session event grouping. |
| docs/plans/2026-04-16-event-based-token-aggregation-task.md | Marks EBTA-008 as done and records timeline notes. |
| cmd/session_test.go | Adds new focused unit tests for session event filtering, timezone, aggregation, and overrides. |
| cmd/session.go | Implements timezone flag, event filtering, event→session aggregation, and localized date rendering for session output. |
| cmd/collect.go | Removes now-unused collectSessions wrapper (session now uses event collection). |
Comments suppressed due to low confidence (1)
e2e/e2e_test.go:583
- The comment says “Verify both are from claude provider”, but the test now expects exactly 1 combined session row. Update the wording to avoid confusion (e.g., “Verify provider is claude”).
// Verify both are from claude provider
for _, s := range sessions {
if s.ProviderName != "claude" {
t.Errorf("expected provider %q, got %q", "claude", s.ProviderName)
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 sessionfrom session-start filtering to localized usage-event filtering.Validation
go test -count=1 ./cmd -run 'Test(RunSession|AggregateSessionEvents|ResolveSessionEventFilterDates|CollectUsageEvents)'go test -count=1 ./e2e -run TestClaudeSubagentSessions_JSONOutputmake fmtmake lintmake testmake vetmake build./bin/codetok ... session --json --since 2026-02-15 --until 2026-02-15 --timezone UTCNotes
Turnsremains best-effort using included usage-event count until an event-level turn model exists.