Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2249,8 +2249,8 @@
}

python3 pkgs/llm-ledger/test_quota_watch.py 2>&1 | tee "$TMPDIR/qw.txt"
grep -q '^Ran 96 tests' "$TMPDIR/qw.txt" || {
echo "GATE FAILURE: expected 'Ran 96 tests' from test_quota_watch.py. If you" >&2
grep -q '^Ran 104 tests' "$TMPDIR/qw.txt" || {
echo "GATE FAILURE: expected 'Ran 104 tests' from test_quota_watch.py. If you" >&2
echo "added or removed tests deliberately, update the count here in the same commit." >&2
exit 1
}
Expand Down
4 changes: 3 additions & 1 deletion hosts/cloudbox/llm-ledger.nix
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ Check:
TimeoutStartSec = "5min";
StateDirectory = "llm-quota-watch";
StateDirectoryMode = "0700";
ExecStart = "${llmLedger}/bin/llm-ledger quota-watch --state-dir /var/lib/llm-quota-watch --alert-cmd ${driftAlert} --outlook-pushed-file /var/lib/llm-fleet/outlook-pushed --alert-stale-hosts devbox";
# --fleet-k is intentionally OFF: 2026-12-01 7d replay showed 0/2139 verdict diffs
# (k_fleet is still computed and recorded in quota_watch_runs for observation).
ExecStart = "${llmLedger}/bin/llm-ledger quota-watch --state-dir /var/lib/llm-quota-watch --alert-cmd ${driftAlert} --outlook-pushed-file /var/lib/llm-fleet/outlook-pushed --alert-stale-hosts devbox --account-map /var/lib/llm-fleet/telemetry/account-map.json";
ExecStartPost = "${pkgs.coreutils}/bin/rm -f /var/lib/llm-quota-watch-failure/alerted";
Environment = [ "HOME=/home/dev" ];
NoNewPrivileges = true;
Expand Down
11 changes: 10 additions & 1 deletion pkgs/llm-ledger/llm_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
burn_6h REAL, burn_24h REAL, spill_6h REAL, spill_24h REAL,
k REAL, zero_h REAL NOT NULL, vertex_usd REAL,
next_refill_ts INTEGER, next_refill_amt REAL,
pool_n INTEGER NOT NULL, source TEXT NOT NULL, verdict TEXT); -- 'live' | 'replay'
pool_n INTEGER NOT NULL, source TEXT NOT NULL, verdict TEXT,
k_fleet REAL, k_scope TEXT);

CREATE TABLE IF NOT EXISTS quota_forecast (
ts INTEGER PRIMARY KEY, headroom REAL NOT NULL, run_ts INTEGER NOT NULL);
Expand Down Expand Up @@ -3862,6 +3863,8 @@ def main(argv: list[str] | None = None) -> int:
qw_parser.add_argument("--host", default=socket.gethostname())
qw_parser.add_argument("--alert-stale-hosts", default="devbox", help="Comma-separated list of hosts to check for stale telemetry (default: devbox; empty string disables)")
qw_parser.add_argument("--outlook-pushed-file", default=None, help="Path to file touched on successful outlook push; alerts if missing or older than 15 min")
qw_parser.add_argument("--fleet-k", action="store_true", default=False, help="Use fleet k (k_local/s) for spillover-to-burn conversion")
qw_parser.add_argument("--account-map", default="/var/lib/llm-fleet/telemetry/account-map.json", help="Path to JSON map of remote email -> short account name (null to ignore)")

# quota-replay subcommand
qr_parser = subparsers.add_parser("quota-replay")
Expand All @@ -3871,6 +3874,8 @@ def main(argv: list[str] | None = None) -> int:
qr_parser.add_argument("--exclude-account", action="append", default=None)
qr_parser.add_argument("--host", default=socket.gethostname())
qr_parser.add_argument("--record", action="store_true", default=False, help="Record evaluated runs into quota_watch_runs")
qr_parser.add_argument("--fleet-k", action="store_true", default=False, help="Use fleet k (k_local/s) for spillover-to-burn conversion")
qr_parser.add_argument("--account-map", default="/var/lib/llm-fleet/telemetry/account-map.json", help="Path to JSON map of remote email -> short account name (null to ignore)")

# quota-outlook subcommand
qo_parser = subparsers.add_parser("quota-outlook")
Expand Down Expand Up @@ -4037,6 +4042,8 @@ def _make_fallback(err_str: str) -> dict[str, Any]:
host=args.host,
alert_stale_hosts=args.alert_stale_hosts,
outlook_pushed_file=args.outlook_pushed_file,
fleet_k=args.fleet_k,
account_map=args.account_map,
)

if args.command == "quota-replay":
Expand All @@ -4052,6 +4059,8 @@ def _make_fallback(err_str: str) -> dict[str, Any]:
excluded=excluded,
host=args.host,
record=args.record,
fleet_k=args.fleet_k,
account_map=args.account_map,
)
except quota_watch.QuotaRecordError:
return 1
Expand Down
Loading
Loading