Skip to content

feat(quota-tracker): EWMA burn-rate forecast + pass-budget prediction - #1166

Closed
bassilkhilo-ag2 wants to merge 2 commits into
sonichi:mainfrom
bassilkhilo-ag2:feat/quota-burn-rate-1087
Closed

bassilkhilo-ag2 wants to merge 2 commits into
sonichi:mainfrom
bassilkhilo-ag2:feat/quota-burn-rate-1087

Conversation

@bassilkhilo-ag2

Copy link
Copy Markdown
Collaborator

Summary

  • Adds EWMA (α=0.3) burn-rate tracking to read-quota.py: records util_5h samples in <workspace>/state/quota-burn-history.json, computes pct/min consumption rate per pass
  • New output keys: burn_rate_pct_per_min, estimated_minutes_to_exhaustion, estimated_passes_remaining (in both --json and human-readable output)
  • Positive-delta filter + 30-min gap guard prevent quota resets and session pauses from spiking the EWMA rate
  • History capped at 60 samples (~5h at 5min cadence) to bound file size
  • Also carries forward the except ImportError: narrowing from fix(quota-tracker): narrow bare except Exception to ImportError (closes #1062) #1165 (not yet merged)

Test plan

  • python3 tests/quota-burn-rate.test.py → All 17 tests passed
  • python3 tests/quota-bare-except.test.py → All 5 tests passed (carried-forward fix)
  • Run python3 read-quota.py twice in succession — second call shows a burn rate line
  • Run python3 read-quota.py --json — output includes the three new keys
  • Verify <workspace>/state/quota-burn-history.json is created/updated on each run

Closes #1087

🤖 Generated with Claude Code

@bassilkhilo-ag2
bassilkhilo-ag2 force-pushed the feat/quota-burn-rate-1087 branch from ab6f038 to 231cb2b Compare May 26, 2026 11:04

@VasiliyRad VasiliyRad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

EWMA implementation is correct — alpha=0.3, proper first-sample init, positive-delta filter, 30-min gap guard, history cap at 60 samples, graceful None handling throughout. The quota feature itself is well-scoped and useful.

Bundling issue (same pattern as previous PRs): 6 of 7 commits are unrelated to the EWMA feature:

  • build_log.md (114 lines) — workspace runtime file, should not be in PRs
  • src/health-check.py — multi-bridge source-path warn (fix from a different issue)
  • src/watch-tasks-stream.sh — EPIPE + PPID watchdog fixes (issue #1088)
  • tests/health-check-bridge-multi-pid.test.py — tests for the health-check fix
  • tests/watch-tasks-stream-orphan.test.py — tests for the watcher fix
  • tests/web-client-security-scrub.test.py — tests for web-client e.message scrub (#1121)

The quota-related files (read-quota.py, tests/quota-burn-rate.test.py, tests/quota-bare-except.test.py) are the only things that belong here.

Please split: remove build_log.md entirely, and move the health-check, watch-tasks-stream, and web-client test changes to their respective PRs (or dedicated ones). Happy to approve the quota feature once it's isolated.

bassilkhilo-ag2 and others added 2 commits May 26, 2026 22:54
sonichi#1062)

The broad except Exception: around the workspace_default import swallowed
any non-ImportError raised by status_read_path(), silently falling through
to the misleading "No quota-state.json found" message instead of surfacing
the real error. Narrowed to ImportError so only the module-not-on-path case
is suppressed; all other exceptions propagate to cron pass logs.

5 structural tests in tests/quota-bare-except.test.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…closes sonichi#1087)

Adds predictive degradation to read-quota.py: records utilization samples in
<workspace>/state/quota-burn-history.json, computes an EWMA (α=0.3) of pct/min
consumption, and outputs burn_rate_pct_per_min / estimated_minutes_to_exhaustion
/ estimated_passes_remaining. Positive-delta filter and 30-min gap guard prevent
quota resets and long pauses from spiking the rate. Human-readable output gains
a "Burn rate: X.XXX%/min  (~N passes left)" line. 17 structural tests added.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bassilkhilo-ag2
bassilkhilo-ag2 force-pushed the feat/quota-burn-rate-1087 branch from 231cb2b to 38a3c50 Compare May 26, 2026 18:54
@bassilkhilo-ag2

Copy link
Copy Markdown
Collaborator Author

Rebased to strip the 6 unrelated commits flagged in review. Branch now contains only the 2 quota-tracker commits:

Same pattern as the #1175 cleanup. No logic changes — EWMA implementation is exactly as reviewed.

@bassilkhilo-ag2

Copy link
Copy Markdown
Collaborator Author

The bundled junk has been rebased out. Current diff: skills/quota-tracker/scripts/read-quota.py, tests/quota-bare-except.test.py, tests/quota-burn-rate.test.py — exactly the 3 files the EWMA feature needs, nothing else. Could you take another look?

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.

feat(quota-tracker): predictive degradation — burn-rate forecast + pass-budget prediction (read-quota.py is current-% only)

2 participants