Skip to content

Fix Codex usage collection for archived sessions - #62

Merged
MayankBansal12 merged 1 commit into
mainfrom
fix/codex-archived-sessions
Sep 17, 2026
Merged

MayankBansal12 merged 1 commit into
mainfrom
fix/codex-archived-sessions

Conversation

@MayankBansal12

Copy link
Copy Markdown
Owner

Codex sessions archived before their first Usage sync were omitted from token and cost totals. Scan both sessions and archived_sessions in the default Codex home and every discovered profile home, retaining each profile's attribution.

Fixes #61

Changes

  • Add Extra Codex homes (codexHomes) for custom CODEX_HOME directories; scan both session locations in each configured home.
  • Cache hashed session-and-bucket identities so an active rollout and its archived copy are counted once, including when one copy is older. Bump the Codex cache version to reparse existing logs once; subsequent scans reuse unchanged files.
  • Keep the existing Codex database source identity so adding archive/custom roots does not discard previously recorded history whose logs are no longer available.
  • Document the supported locations and cache upgrade behavior.

Validation

  • npm test: 249 tests passed.
  • npm run check and npm run build: passed.
  • Regression coverage includes archived-only default/profile homes, archive/restore moves and continued usage, duplicate copies, symlinked profiles, partial discovery, cache upgrades, custom-home discovery, and retained history.
  • Clean local development install completed its initial sync with zero source errors; 33 archived Codex rollouts were present in the rebuilt local cache.

Scan cost

Measured on this machine with temporary caches and the same collector/parser, comparing active-only discovery against active plus archived discovery:

Scan Active only: 646 files Including archives: 679 files
Empty collector cache 5.082 s 5.334 s
Existing collector cache, median of three runs 79 ms 88 ms

All cached runs reused every file and reported zero failures. This is a small local sample, not a performance guarantee: directory traversal and file metadata checks still scale with history size, while first-time parsing scales with log contents. Files remain streamed and aggregated on the enrolled host, and the existing 10-minute source timeout and history retention window remain in effect.

AGENT GENERATED

@MayankBansal12
MayankBansal12 merged commit 2c1ff52 into main Sep 17, 2026
2 checks passed
@MayankBansal12
MayankBansal12 deleted the fix/codex-archived-sessions branch September 17, 2026 19:41
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.

Codex usage misses archived session logs

1 participant