Skip to content

fix: parser.py / pricing.py housekeeping (#182)#191

Merged
microsasa merged 1 commit intomainfrom
fix/182-parser-pricing-housekeeping-783fefca59f6f797
Mar 21, 2026
Merged

fix: parser.py / pricing.py housekeeping (#182)#191
microsasa merged 1 commit intomainfrom
fix/182-parser-pricing-housekeeping-783fefca59f6f797

Conversation

@microsasa
Copy link
Owner

Closes #182

Three small housekeeping fixes:

1. _RESUME_INDICATOR_TYPES → module-level frozenset

Moved the set literal from inside build_session_summary() to a module-level frozenset constant, avoiding recreation on every call and signaling immutability.

2. _sort_key uses datetime sentinel instead of ISO strings

Replaced the ISO string comparison sort key with a datetime sentinel (_EPOCH = datetime.min.replace(tzinfo=UTC)). Sessions with start_time=None sort to _EPOCH (effectively last when sorted descending), avoiding reliance on implicit string ordering.

3. Added gpt-5.4-mini to _RAW_MULTIPLIERS

Added at 0.0× multiplier (tier LIGHT), consistent with gpt-5-mini and gpt-4.1.

Tests

  • Item 1: No new test needed — existing coverage validates unchanged behavior.
  • Item 2: Existing test_sessions_without_start_time_sort_last validates the sort behavior.
  • Item 3: Added parametrized entries to test_known_multipliers (gpt-5.4-mini, 0.0) and test_known_tiers (gpt-5.4-mini, LIGHT).

All 422 tests pass, coverage 98%, ruff/pyright clean.

Generated by Issue Implementer ·

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • astral.sh

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "astral.sh"

See Network Configuration for more information.

- Move _RESUME_INDICATOR_TYPES to module-level frozenset constant
- Replace ISO string sort key with datetime sentinel (_EPOCH)
- Add gpt-5.4-mini at 0.0× multiplier to _RAW_MULTIPLIERS
- Add test entries for gpt-5.4-mini multiplier and tier

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsasa microsasa added the aw Created by agentic workflow label Mar 21, 2026
Copilot AI review requested due to automatic review settings March 21, 2026 02:18
@microsasa microsasa enabled auto-merge March 21, 2026 02:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Housekeeping updates in copilot_usage to reduce per-call overhead in the session parser, make session sorting more explicit/robust, and extend the pricing registry for a newly observed model name.

Changes:

  • Moved resume-indicator event types to a module-level frozenset constant in parser.py.
  • Updated get_all_sessions() sorting to use a datetime sentinel (datetime.min w/ UTC) rather than ISO string keys.
  • Added gpt-5.4-mini to the pricing multipliers (0.0× → LIGHT) and extended existing parametrized tests accordingly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/copilot_usage/parser.py Avoids recreating invariant sets per call and replaces ISO-string sort keys with a UTC datetime sentinel.
src/copilot_usage/pricing.py Registers gpt-5.4-mini at 0.0× so lookups don’t fall back to the unknown-model 1× warning path.
tests/copilot_usage/test_pricing.py Extends existing parametrized coverage to include gpt-5.4-mini multiplier and tier expectations.

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

@microsasa microsasa added the aw-quality-gate-approved Quality gate approved the PR label Mar 21, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Quality Gate: APPROVED

Low-impact housekeeping PR (26 lines across 3 files). All changes verified:

  1. _RESUME_INDICATOR_TYPES → module-level frozenset — avoids per-call recreation, signals immutability. All referenced EventType members validated.
  2. _sort_key datetime sentinel — replaces ISO string comparison with proper datetime ordering. Existing test_sessions_without_start_time_sort_last validates behavior.
  3. gpt-5.4-mini at 0.0× — consistent with gpt-5-mini and gpt-4.1. Test parametrizations added for multiplier and tier.

No API changes, no business logic changes, no security implications. Auto-approving for merge.

@microsasa microsasa merged commit e29363b into main Mar 21, 2026
8 checks passed
@microsasa microsasa deleted the fix/182-parser-pricing-housekeeping-783fefca59f6f797 branch March 21, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow aw-quality-gate-approved Quality gate approved the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw][code health] parser.py / pricing.py housekeeping: module-level constant, sort sentinel, missing model

2 participants