feat(orchestrator): show token and commit rates in the header
rates.py folds the token, commit and score journals into per-hour and per-day rates for the header chips and the rates page; /api/rates drops from about 1950 ms to 380-830 ms on a year of data. Tests run once on unify/skills-20261114 after the merge (operator order 2026-11-14). 🎯 Fix: 75 % 💥 Break: 10 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 95 % 🏆 Score: 64 🚦 Gate: ⛔ fix 75 % < 90, break 10 % > 5; security 95 % < 100: ask the operator before the commit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a2a03995cb
commit
652bc817c1
28 files changed
+1449
-102
No files matched your search
@@ -8,6 +8,8 @@ const Resources = (() => {
|
||||
const HOUR = 3600;
|
||||
const COUNTS = ["input", "output", "cache_read", "cache_write"];
|
||||
const ZONES = [{kind: "idle", from: 0, to: IDLE}, {kind: "saturated", from: SATURATED, to: 100}];
|
||||
const COUNT_UNITS = [[1e12, "T"], [1e9, "B"], [1e6, "M"], [1e3, "k"]];
|
||||
const ROUNDS_UP = 0.99995;
|
||||
const finite = (value) => typeof value === "number" && Number.isFinite(value);
|
||||
const share = (part, whole) => (finite(part) && finite(whole) && whole > 0 ? Math.round((1000 * part) / whole) / 10 : null);
|
||||
const listOf = (row, key) => (Array.isArray(row[key]) ? row[key].filter((item) => item && typeof item === "object") : []);
|
||||
@@ -178,7 +180,17 @@ const Resources = (() => {
|
||||
return {top, done: points.map((point) => [point.t, percent(point.done)]), scope: points.map((point) => [point.t, percent(point.scope)])};
|
||||
}
|
||||
|
||||
return {IDLE, SATURATED, CALM, GAP, HOUR, COUNTS, ZONES, lines, hardware, segments, spans, waits, asleep, unknown, stack, accumulate, burnup};
|
||||
/**
|
||||
* @param value - a count.
|
||||
* @returns the count with one decimal in the largest of k, M, B and T it reaches once rounded to that decimal,
|
||||
* else as a whole number.
|
||||
*/
|
||||
function compact(value) {
|
||||
const unit = COUNT_UNITS.find(([size]) => value >= size * ROUNDS_UP);
|
||||
return unit ? `${(value / unit[0]).toFixed(1)}${unit[1]}` : String(Math.round(value));
|
||||
}
|
||||
|
||||
return {IDLE, SATURATED, CALM, GAP, HOUR, COUNTS, ZONES, lines, hardware, segments, spans, waits, asleep, unknown, stack, accumulate, burnup, compact};
|
||||
})();
|
||||
if (typeof module === "object" && module.exports) {
|
||||
module.exports = Resources;
|
||||
|
||||
Reference in new issue
Block a user