Skip to content

[NO-JIRA] Add fleet k (k_local/s) behind --fleet-k in quota-watch - #1051

Merged
johnnymo87 merged 2 commits into
mainfrom
feat/fleet-k
Dec 1, 2026
Merged

johnnymo87 merged 2 commits into
mainfrom
feat/fleet-k

Conversation

@johnnymo87

Copy link
Copy Markdown
Owner

Summary

Implements Phase 2 fleet k (k_local / s) behind --fleet-k per docs/plans/2026-11-23-fleet-llm-ledger-design.md §2 (bead eng-agent-platform-ul4.26.8).

  • Fleet share & k_fleet: k_fleet = k_local / s using oc_tags.opus_list_cost on both local (hourly, minus excluded teamclaude_hourly) and remote (remote_hourly, backend='max') over [max(w_end - 7d, max_first_hour), w_end) (minimum 24h overlap), where w_end is the oldest gated remote watermark (--alert-stale-hosts, default devbox, so a sleeping Mac does not trigger holds).
  • Account map: --account-map /var/lib/llm-fleet/telemetry/account-map.json (stored in private johnnymo87/quota-telemetry; null = explicit ignore for the usage seat; unmapped warns once and is excluded; only active pool members with non-null u7d count).
  • 48h hold & safety guards: When gated watermarks lag (>3h) or share computation cannot produce a plausible value (empty pool, non-ignored remote rows with zero pool matches, or s < 0.01), hold the last good k_fleet in state.json for up to 48h without refreshing its timestamp, then fall back to k_local.
  • Schema: k_fleet and k_scope added as the last two columns of quota_watch_runs (columns 15 & 16, preserving verdict at r[14]) with idempotent ALTER TABLE migration. vertex_usd continues to use k_local; only burn_rate uses k_fleet when --fleet-k is set.
  • Flag state on cloudbox: OFF. k_fleet and k_scope (local(fleet) / local(fleet-held) / local) are still recorded for live observation.

7-day forward replay (2026-11-24..2026-12-01, 2139 ticks)

Metric --fleet-k OFF --fleet-k ON
Verdict diffs — 0 / 2139
Tight episodes 11-24 15:20 ET..11-25 00:45 ET (9.4h) identical
Max |burn_h diff| — 0.0013 / h
Max |zero_h diff| — 0.083 h (1 tick)
k_local range 368.7 .. 842.2 (latest 373.4) same
k_fleet range — 1898.6 .. 2362.1 (latest 2348.6)
1/s range — 2.28× .. 6.34× (latest 6.29×, s = 0.159)

Because spillover over the week was ≤ $3.51, fleet k did not change any verdict; shipped OFF per the bead's gate.

Verification

  • python3 -m unittest test_quota_watch.py test_llm_ledger.py: 227 tests pass (including 8 new TestFleetK tests covering calculation, vertex_usd keeping k_local, account map ignore/unmapped/non-pool, window coverage clipping, sleeping Mac, empty pool / tiny share hold preservation, 48h hold persistence in state.json, schema migration, and replay --fleet-k).
  • python3 hosts/cloudbox/check_grafana_dashboards.py: 31 self-tests + 5 dashboards pass.
  • Adversarial review run and all 4 actionable code findings addressed.

@johnnymo87
johnnymo87 marked this pull request as ready for review December 1, 2026 15:22
@johnnymo87
johnnymo87 enabled auto-merge (squash) December 1, 2026 15:22
… quota-replay

Implements Phase 2 fleet k from docs/plans/2026-11-23-fleet-llm-ledger-design.md §2:
- Compute k_fleet = k_local / s using oc_tags.opus_list_cost on both local and
  remote Max usage over [max(w_end - 7d, max_first_hour), w_end), where w_end
  is the oldest gated remote watermark (default --alert-stale-hosts = devbox so
  a sleeping Mac does not force holds).
- Map remote emails to pool short names via --account-map (JSON in private
  quota-telemetry repo; null = explicit ignore for usage seat; unmapped warns
  and is excluded; only active pool members with non-null u7d count).
- Hold last good k_fleet for up to 48h when a gated watermark lags (>3h) or
  when share computation fails (empty pool, unmatched remote rows, s < 1%),
  without refreshing its timestamp, then fall back to k_local.
- Add k_fleet and k_scope as the last two columns of quota_watch_runs (preserving
  verdict at r[14]) with idempotent migration. k_scope distinguishes fresh vs
  held even when --fleet-k is off (local(fleet) / local(fleet-held)).
- Keep vertex_usd on k_local; only burn_rate uses k_fleet when --fleet-k is set.
- Ship --fleet-k OFF on cloudbox: 7-day forward replay (2026-11-24..2026-12-01,
  2139 ticks) showed 0 verdict diffs (max |burn_h| diff 0.0013/h, max |zero_h|
  diff 0.083h) with k_fleet 1899..2362 (1/s = 2.28x..6.34x, latest s=0.159),
  because spillover was <=.51.
@johnnymo87
johnnymo87 merged commit a1b7283 into main Dec 1, 2026
2 checks passed
@johnnymo87
johnnymo87 deleted the feat/fleet-k branch December 1, 2026 15:56
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