[AutoLoRA P2] Integrate claude_quota.py Metabolic Protocol #1106

Closed
opened 2026-03-23 17:29:45 +00:00 by perplexity · 1 comment
Collaborator

Integrate claude_quota.py Metabolic Protocol

Priority: P2
Assignee: Timmy (after fine-tune is loaded)
Epic: #1091 — Project Bannerlord
Pipeline: AutoLoRA Sovereignty Loop (Step 7 of 7)
Blocked by: All P0 and P1 AutoLoRA issues


Context

Two files were built during the research session:

  • claude_quota.py — Python module that monitors Claude API quota
  • claude_quota_check.sh — Bash script for quick terminal checks

These implement the metabolic protocol for intelligent model switching.

Metabolic Protocol

Mode Condition Model Purpose
BURST Claude quota < 50% used Cloud (Claude) Maximum capability for complex tasks
ACTIVE Claude quota 50-80% used Local (Hermes 4 fine-tuned) Normal operation, sovereignty
RESTING Claude quota > 80% used Local (Hermes 3 8B) Conservation mode, simple tasks

What To Do

  1. Copy files to the repo:

    • claude_quota.pysrc/infrastructure/
    • claude_quota_check.shscripts/
  2. Wire QuotaMonitor.select_model() into the harness model-selection logic so it automatically downshifts when Claude credits are running low.

  3. Test the transitions:

    • Verify BURST → ACTIVE transition at 50%
    • Verify ACTIVE → RESTING transition at 80%
    • Verify recovery back to BURST when quota resets

Done When

  • ./scripts/claude_quota_check.sh shows quota status with color bars
  • The harness auto-switches to local model when Claude quota is above 80%
  • Transitions are logged so Alexander can verify the protocol is working
## Integrate claude_quota.py Metabolic Protocol **Priority:** P2 **Assignee:** Timmy (after fine-tune is loaded) **Epic:** #1091 — Project Bannerlord **Pipeline:** AutoLoRA Sovereignty Loop (Step 7 of 7) **Blocked by:** All P0 and P1 AutoLoRA issues --- ### Context Two files were built during the research session: - **`claude_quota.py`** — Python module that monitors Claude API quota - **`claude_quota_check.sh`** — Bash script for quick terminal checks These implement the metabolic protocol for intelligent model switching. ### Metabolic Protocol | Mode | Condition | Model | Purpose | |------|-----------|-------|---------| | **BURST** | Claude quota < 50% used | Cloud (Claude) | Maximum capability for complex tasks | | **ACTIVE** | Claude quota 50-80% used | Local (Hermes 4 fine-tuned) | Normal operation, sovereignty | | **RESTING** | Claude quota > 80% used | Local (Hermes 3 8B) | Conservation mode, simple tasks | ### What To Do 1. Copy files to the repo: - `claude_quota.py` → `src/infrastructure/` - `claude_quota_check.sh` → `scripts/` 2. Wire `QuotaMonitor.select_model()` into the harness model-selection logic so it automatically downshifts when Claude credits are running low. 3. Test the transitions: - Verify BURST → ACTIVE transition at 50% - Verify ACTIVE → RESTING transition at 80% - Verify recovery back to BURST when quota resets ### Done When - [ ] `./scripts/claude_quota_check.sh` shows quota status with color bars - [ ] The harness auto-switches to local model when Claude quota is above 80% - [ ] Transitions are logged so Alexander can verify the protocol is working
claude self-assigned this 2026-03-23 17:53:59 +00:00
Collaborator

PR created: #1113

What was done:

claude_quota.py and claude_quota_check.sh were already in the repo from prior work. This PR completes the integration by wiring QuotaMonitor.select_model() into the cascade router:

  • _quota_allows_cloud() now calls select_model("high") — cloud is only allowed when the quota monitor recommends "claude-sonnet-4-6" (BURST tier, 5h quota < 50%)
  • When quota is ACTIVE (5h ≥ 50%) or RESTING (7d ≥ 80%), cloud providers are skipped and a INFO log shows the tier + recommended local model so Alexander can verify transitions
  • Added 5 new tests in TestMetabolicProtocol covering BURST/ACTIVE/RESTING + local bypass + graceful degradation

All 80 cascade + quota tests pass.

PR created: #1113 **What was done:** `claude_quota.py` and `claude_quota_check.sh` were already in the repo from prior work. This PR completes the integration by wiring `QuotaMonitor.select_model()` into the cascade router: - `_quota_allows_cloud()` now calls `select_model("high")` — cloud is only allowed when the quota monitor recommends `"claude-sonnet-4-6"` (BURST tier, 5h quota < 50%) - When quota is ACTIVE (5h ≥ 50%) or RESTING (7d ≥ 80%), cloud providers are skipped and a `INFO` log shows the tier + recommended local model so Alexander can verify transitions - Added 5 new tests in `TestMetabolicProtocol` covering BURST/ACTIVE/RESTING + local bypass + graceful degradation All 80 cascade + quota tests pass.
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1106