Skip to content

[codex] collect Codex usage events#31

Merged
Miss-you merged 6 commits into
mainfrom
codex/ebta-003-codex-usage-events
Apr 16, 2026
Merged

[codex] collect Codex usage events#31
Miss-you merged 6 commits into
mainfrom
codex/ebta-003-codex-usage-events

Conversation

@Miss-you

Copy link
Copy Markdown
Owner

Summary

  • Add native Codex UsageEvent collection from local rollout token_count records.
  • Prefer last_token_usage, recover deltas from cumulative total_token_usage, handle cumulative counter resets, and honor $CODEX_HOME/sessions when no explicit Codex directory is provided.
  • Keep legacy Codex session collection compatible while sharing delta recovery and adding bounded parallel parsing for usage event files.
  • Add EBTA-003 OpenSpec/workspace artifacts and close the task board entry.

Validation

  • go test ./provider ./provider/codex -run 'Test(ParseCodexUsageEvents|ParseCodexSession_KeepsFirstSessionMetadataAndSumsResetUsage|CollectCodexUsageEvents|CodexHome)'
  • go test ./provider ./provider/codex
  • make fmt
  • make test
  • make vet
  • make build
  • make lint

Review Notes

  • Multi-agent implementation review found and verified fixes for mixed last/total baseline overcount, legacy session reset metadata handling, and serial event parsing.
  • Secret scan passed before commit and before push.

- Add native Codex UsageEvent collection with last-token precedence, cumulative delta recovery, reset handling, and CODEX_HOME source resolution.\n- Keep legacy Codex session parsing compatible while sharing delta recovery and bounded parallel event parsing.\n- Add EBTA-003 OpenSpec/workspace artifacts and focused regression coverage.
Copilot AI review requested due to automatic review settings April 16, 2026 10:01

@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: cf24c105ca

ℹ️ 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

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 native UsageEvent production for the Codex provider by parsing local rollout JSONL token_count records into timestamped token deltas, while keeping legacy session collection compatible and improving file parsing throughput via bounded parallelism.

Changes:

  • Implement Provider.CollectUsageEvents for Codex with delta recovery (last_token_usage preferred; otherwise cumulative total_token_usage diffs with reset handling).
  • Refactor Codex source-dir resolution to honor $CODEX_HOME/sessions when baseDir is empty, shared across sessions and events.
  • Add a generic provider.ParseUsageEventsParallel helper and comprehensive Codex tests for the new behaviors.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
provider/codex/parser.go Adds Codex usage-event parsing/collection, shared path discovery, CODEX_HOME resolution, and shared delta/reset logic for sessions + events.
provider/codex/parser_test.go Adds tests for Codex native usage events, reset handling, metadata stability, and CODEX_HOME / explicit-dir precedence.
provider/parallel.go Introduces ParseUsageEventsParallel to parse event files with bounded concurrency.
workspace/EBTA-003/test_strategy.md Test strategy and targeted behaviors for EBTA-003.
workspace/EBTA-003/review.md Captures review findings and the implemented fixes.
workspace/EBTA-003/original_impl.md Documents pre-change Codex behavior and test coverage gaps.
workspace/EBTA-003/new_impl.md Implementation plan describing the intended approach and constraints.
workspace/EBTA-003/final_impl_v1.md Finalized implementation spec for the task scope.
workspace/EBTA-003/final_impl.md Pointers/summary for the approved final implementation doc.
openspec/changes/codex-native-usage-events/.openspec.yaml Registers the OpenSpec change (schema + created date).
openspec/changes/codex-native-usage-events/proposal.md Motivation and high-level change summary.
openspec/changes/codex-native-usage-events/design.md Design decisions, trade-offs, and risks.
openspec/changes/codex-native-usage-events/tasks.md Task checklist for tests/implementation/validation.
openspec/changes/codex-native-usage-events/specs/codex-native-usage-events/spec.md Requirements/spec for Codex native event emission and directory resolution.
docs/plans/2026-04-16-event-based-token-aggregation-task.md Updates EBTA task board status to mark EBTA-003 done with verification notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread provider/codex/parser.go Outdated
Comment thread provider/parallel.go
@Miss-you
Miss-you merged commit f58f04a into main Apr 16, 2026
7 checks passed
@Miss-you
Miss-you deleted the codex/ebta-003-codex-usage-events branch April 16, 2026 10:58
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