Skip to content

Implementation Plan: T5-P4-A7-WP1 Eliminate 'anthropic'.casefold() from _quota_refresh_loop and resolve_provider() from _prime_quota_cache#4098

Merged
Trecek merged 5 commits into
developfrom
t5-p4-a7-wp1-eliminate-the-anthropic-casefold-string-compari/4025
Jun 13, 2026
Merged

Implementation Plan: T5-P4-A7-WP1 Eliminate 'anthropic'.casefold() from _quota_refresh_loop and resolve_provider() from _prime_quota_cache#4098
Trecek merged 5 commits into
developfrom
t5-p4-a7-wp1-eliminate-the-anthropic-casefold-string-compari/4025

Conversation

@Trecek

@Trecek Trecek commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Replace the hardcoded 'anthropic'.casefold() string comparison in _quota_refresh_loop and the resolve_provider() call in _prime_quota_cache with a typed QuotaPolicy frozen dataclass carrying a supports_quota_check: bool field. Call sites derive the bool from ctx.backend.capabilities.anthropic_provider_capable, removing all raw provider string passing to quota functions. resolve_provider() is deleted from _misc.py.

Closes #4025

Implementation Plan

Plan file: /home/talon/projects/autoskillit-runs/impl-20260612-160904-076305/.autoskillit/temp/make-plan/t5_p4_a7_wp1_quota_policy_plan_2026-06-12_161500.md

🤖 Generated with Claude Code via AutoSkillit

Token Usage Summary

Step Model count uncached output cache_read peak_ctx turns cache_write time
plan* opus[1m] 1 79 31.4k 2.0M 114.7k 63 105.3k 19m 25s
verify* sonnet 1 52 5.7k 233.5k 53.6k 17 32.7k 5m 8s
implement* MiniMax-M3 1 7.3M 18.0k 0 0 179 0 10m 15s
fix* sonnet 1 182 8.7k 1.2M 72.1k 54 51.2k 8m 8s
audit_impl* sonnet 1 36 12.3k 134.2k 46.5k 13 40.3k 6m 42s
prepare_pr* MiniMax-M3 1 200.0k 2.1k 0 0 12 0 40s
compose_pr* MiniMax-M3 1 215.9k 1.6k 0 0 14 0 40s
review_pr* sonnet 1 180 30.3k 1.3M 86.7k 53 66.4k 7m 54s
resolve_review* sonnet 1 847 47.9k 10.7M 142.7k 227 122.7k 20m 45s
Total 7.7M 158.1k 15.6M 142.7k 418.7k 1h 19m

* Step used a non-Anthropic provider; caching behavior may differ.

Token Efficiency

Step LoC Changed cache_read/LoC cache_write/LoC output/LoC
plan 0
verify 0
implement 135 0.0 0.0 133.7
fix 16 76366.2 3197.8 545.6
audit_impl 0
prepare_pr 0
compose_pr 0
review_pr 0
resolve_review 52 205852.2 2360.3 921.2
Total 203 76743.5 2062.4 778.8

Model Usage Breakdown

Model steps uncached output cache_read cache_write time
opus[1m] 1 79 31.4k 2.0M 105.3k 19m 25s
sonnet 5 1.3k 104.9k 13.6M 313.3k 48m 38s
MiniMax-M3 3 7.7M 21.8k 0 0 11m 35s

Trecek and others added 5 commits June 12, 2026 16:42
…a_check bool

- Add QuotaPolicy frozen dataclass to _type_protocols_infra.py
- Add QuotaPolicy to core/__init__.pyi stub
- Migrate _quota_refresh_loop and _prime_quota_cache signatures
  to accept supports_quota_check: bool keyword
- Delete resolve_provider() from server/_misc.py
- Update tools_kitchen.py call sites (2) to derive bool from
  ctx.backend.capabilities.anthropic_provider_capable
- Update _lifespan.py call sites (_fleet_auto_gate_boot,
  _pre_reveal_kitchen, _food_truck_auto_gate_boot,
  _skill_auto_gate_boot) to use new signature
- Update tools_fleet_dispatch.py quota_checker lambda
- Update test stubs and assertions to match new signature
- Add test_quota_refresh_loop_returns_immediately_when_unsupported
  and test_prime_quota_cache_skips_when_unsupported tests
- Update test_quota_capability_isolation.py docstring and
  assertion message to reference supports_quota_check bool
…uotaPolicy addition

- test_schema_version_convention.py: update _LEGACY_JSON_WRITES line numbers for
  tools_kitchen.py (shifted by new _supports_quota computation lines)
- test_type_protocol_shards.py: add QuotaPolicy to test_infra_shard_all expected set
- test_subpackage_isolation.py: raise tools_kitchen.py line limit 1275→1280 to
  accommodate supports_quota_check bool computation at call sites

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…icate expressions

Adds _backend_supports_quota(ctx) to server/_guards.py and replaces the verbatim
4-location repetition of ctx.backend.capabilities.anthropic_provider_capable in
_lifespan.py and 2-location repetition in tools_kitchen.py with calls to the helper.

Addresses reviewer findings: cohesion/_lifespan.py:271, arch/_lifespan.py:347,
cohesion/tools_kitchen.py:273.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ools_fleet_dispatch

Precomputes _supports_quota as a named bool before the execute_dispatch call, matching
the pattern used in _lifespan.py and tools_kitchen.py. The quota_checker lambda now
captures _supports_quota by closure, removing the inline ternary inside it.

Addresses reviewer findings: arch/tools_fleet_dispatch.py:372,
cohesion/tools_fleet_dispatch.py:375.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…and tools_kitchen.py edits

The _backend_supports_quota import insertion shifted json.dumps write sites by 1 line in
_lifespan.py and by -5 lines in tools_kitchen.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Trecek Trecek added this pull request to the merge queue Jun 13, 2026
Merged via the queue into develop with commit e6995ae Jun 13, 2026
3 checks passed
@Trecek Trecek deleted the t5-p4-a7-wp1-eliminate-the-anthropic-casefold-string-compari/4025 branch June 13, 2026 00:49
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.

1 participant