Skip to content

feat(bearings): show Anthropic, OpenAI and Google quota on the fleet board - #43

Merged
alandomio merged 3 commits into
mainfrom
fm/bearings-quote
Sep 26, 2026
Merged

alandomio merged 3 commits into
mainfrom
fm/bearings-quote

Conversation

@alandomio

Copy link
Copy Markdown
Owner

Intent

Captain's request (26/09/2026, Italian): 'aggiorna la skill bearings in modo che inserisca le quote anthropic, openai e google nella board' - update the bearings skill so the /bearings lavish fleet board shows the Anthropic, OpenAI and Google quota. Providers map to quota-axi providers claude (Anthropic), codex (OpenAI) and agy (Google, the Antigravity CLI; locally patched quota-axi reads agy's own /quota so Gemini Flash model rows appear). For each provider show the current windows from quota-axi: used/remaining percentage per window (5-hour, weekly, per-model where given), reset time, and any attention line (stale, auth_required, headroom_unknown) in plain words. The board must stay correct when quota-axi is missing, a provider is signed out, or a value is unknown: show 'non disponibile' with the reason, never invent numbers, never block the board build. This is firstmate's own shared tracked material: follow firstmate-coding-guidelines (one owner per concern). Design decisions: a small dedicated reader bin/fm-bearings-quota.sh gathers quota once, deterministically and bounded (quota-axi --provider claude,codex,agy --json --no-credential-refresh under fm_run_timed, FM_BEARINGS_QUOTA_TIMEOUT default 20s), always exits 0 and prints the payload's optional 'quota' section; it is deliberately kept separate from bin/fm-bearings-snapshot.sh because that snapshot's default must stay local-only with zero network calls, and quota-axi may fetch. Degraded paths (tool_missing, timeout, failed, unreadable) emit every provider unavailable with a status code; a readable providers array wins over a non-zero quota-axi exit; unreported percentages stay null; a provider absent from quota-axi output is not_reported. The reader header owns the section shape; bin/fm-bearings-board.sh validates the optional quota section (payload without quota must still validate - backward compatible - and a malformed one is refused). The board template renders the panel in Italian ('Quote dei fornitori', 'non disponibile - ', 'usato X% · restante Y%', 'si azzera '), translating status codes to Italian while vendor error text stays verbatim; the panel renders inside its own guard so a missing or malformed quota section degrades to 'non disponibile' without taking the rest of the board down. Only the quota panel is Italian: the brief claimed the rest of the board is Italian but it is actually English, so the existing English board text was left unchanged. The skill's lavish-mode rules tell the composer to copy the reader output verbatim into the payload and never write quota values itself. The chat digest's four-section contract is unchanged (quota is board-only, not requested for chat). Tests: payload validation with and without quota, rendering through the existing Node DOM harness (added a quota mode), and missing-tool/timeout/failed/unreadable/unknown-value paths with a mocked quota-axi and no network; tests that build a board stub lavish-axi so no real Lavish session starts. New test file registered in bin/fm-test-run.sh's family mapping; docs/scripts.md lists the new script.

What Changed

  • Added bin/fm-bearings-quota.sh, a dedicated reader that runs quota-axi --provider claude,codex,agy --json --no-credential-refresh once. Each run is capped by fm_run_timed with FM_BEARINGS_QUOTA_TIMEOUT, which defaults to 20s. The reader always exits 0 and prints an optional quota section for the board payload. When quota-axi is missing, times out, fails or returns output that can't be read, every provider is reported unavailable with a status code. A provider that quota-axi doesn't mention is marked not_reported, and any percentage it doesn't report stays null.
  • bin/fm-bearings-board.sh now validates the optional quota section. A payload without quota still validates, and a malformed section is refused. The board template gets an Italian "Quote dei fornitori" panel showing, per window, used/remaining %, reset time and any attention line. The panel renders inside its own guard, so a missing or bad section shows "non disponibile - " and the rest of the board still renders. The bearings skill's lavish-mode rules tell the composer to copy the reader output into the payload word for word and never write quota values itself.
  • Tests were added for payload validation with and without quota and for the degraded and unknown-value paths, using a mocked quota-axi. A quota mode was added to the Node DOM harness so the panel rendering is tested too. The new test file is registered in bin/fm-test-run.sh, and the new script and FM_BEARINGS_QUOTA_TIMEOUT are documented in docs/scripts.md and docs/configuration.md.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The fix round is small and correct. Every access in the projection is now type-guarded, and a failing or empty projection falls back to 'degraded unreadable', so the reader always exits 0. A reported percentUsed is kept and only the missing value is derived. Grouped agy labels such as 'Gemini 5-hour' and codex's 'code review session' keep their own label. The new tests check the observable output and rendering.

Testing

Both targeted test files pass: tests/fm-bearings-quota.test.sh and tests/fm-bearings-board.test.sh. I also ran a manual end-to-end check: a mocked quota-axi feeds the real reader, the real board build publishes the page with lavish-axi stubbed, and headless Chrome takes the screenshots. The rendered board shows the 'Quote dei fornitori' panel. Anthropic shows 5 ore and settimana usage bars with 'usato X% · restante Y%' and 'si azzera' times, 'non disponibile' for the model window that had no value, and the stale and unknown-headroom attention lines in Italian. OpenAI shows 'non disponibile - accesso richiesto' followed by the vendor's error text unchanged. Google keeps its grouped window labels (Gemini 5-hour, Claude/GPT 5-hour, Gemini weekly) and the Gemini 3 Flash model row. With quota-axi missing, the reader still exits 0 and all three providers show 'non disponibile - quota-axi non è installato'. The rest of the board is intact in both cases. The temporary files are removed and the worktree is clean.

Evidence: Rendered board HTML (published by fm-bearings-board.sh build)

Source: Rendered board HTML (published by fm-bearings-board.sh build)

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Bearings - fleet board</title>
<style>
/* ============================================================
   Bearings board - Firstmate Design System, inlined for portability.
   Tokens copied verbatim from myfirstmate priv/static/assets/app.css
   (the compiled adoption of .agents/skills/firstmate-design).
   ============================================================ */
@import url("https://fonts.googleapis.com/css2?family=Chango&family=Jost:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap");

:root {
  --rust-700: #8f2f17; --rust-600: #a93a1f; --rust-500: #c0452a;
  --rust-400: #d35f3f; --rust-300: #e08365; --rust-100: #f4d8c9; --rust-050: #fbece3;
  --navy-700: #1a2238; --navy-600: #222c49; --navy-500: #2a3656;
  --navy-300: #6c7796; --navy-100: #d9deea;
  --gold-600: #b5791c; --gold-500: #e0a52e; --gold-300: #f0d38c; --gold-100: #f8ecc9;
  --ocean-600: #2f6688; --ocean-500: #3c7ea6; --ocean-200: #b6d4e2; --ocean-050: #e8f1f5;
  --sea-700: #234e3a; --sea-500: #2f6b4f; --sea-200: #b9d4c5; --sea-050: #e9f2ec;
  --paper-000: #fbf4e2; --paper-100: #f6ecd3; --paper-200: #f0e3c4; --paper-300: #e7d6ae;
  --cream-line: #ddc89c;
  --ink-900: #241c14; --ink-700: #3f3224; --ink-500: #6f5e46; --ink-300: #9c8a6c;
  --white: #fffdf7;
  --bg-page: var(--paper-100);
  --surface-card: var(--white);
  --surface-card-warm: var(--paper-000);
  --text-strong: var(--ink-900); --text-body: var(--ink-700);
  --text-muted: var(--ink-500); --text-faint: var(--ink-300);
  --border-default: var(--cream-line); --border-soft: var(--paper-300);
  --status-online: var(--sea-500); --status-online-soft: var(--sea-050);
  --status-warn: var(--gold-600); --status-warn-soft: var(--gold-100);
  --status-danger: var(--rust-600); --status-danger-soft: var(--rust-050);
  --status-info: var(--ocean-500); --status-info-soft: var(--ocean-050);
  --font-display: "Chango", "Cooper Black", Rockwell, Georgia, serif;
  --font-sans: "Jost", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-h3: 1.4rem; --fs-h4: 1.15rem; --fs-base: 1rem; --fs-sm: 0.9375rem;
  --fs-xs: 0.8125rem; --fs-2xs: 0.6875rem;
  --ls-caps: 0.16em;
  --radius-xs: 6px; --radius-sm: 9px; --radius-md: 12px; --radius-banner: 7px;
  --radius-lg: 18px; --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(36, 28, 20, 0.06), 0 4px 10px rgba(36, 28, 20, 0.06);
  --shadow-hard: 4px 4px 0 var(--ink-900);
  --shadow-hard-sm: 3px 3px 0 var(--ink-900);
  --texture-paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
  --focus-ring: 0 0 0 3px var(--gold-300);
  --container-app: 1180px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--text-body);
  background: var(--bg-page);
  background-image: var(--texture-paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---- fm-badge (enamel sign-pin), verbatim contract ---- */
.fm-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-2xs); font-weight: 800; line-height: 1;
  padding: 5px 9px 4px; text-transform: uppercase; letter-spacing: 0.07em;
  border-radius: var(--radius-xs); border: 1.5px solid var(--ink-900);
  box-shadow: 2px 2px 0 var(--ink-900); white-space: nowrap;
}
.fm-badge--online  { background: var(--sea-500);  color: var(--paper-000); }
.fm-badge--warn    { background: var(--gold-500); color: var(--navy-700); }
.fm-badge--danger  { background: var(--rust-600); color: var(--paper-000); }
.fm-badge--info    { background: var(--ocean-500); color: var(--paper-000); }
.fm-badge--neutral { background: var(--paper-000); color: var(--ink-900); }
.fm-badge--solid   { background: var(--rust-500); color: var(--paper-000); }

/* ---- fm-btn ---- */
.fm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-sans); font-weight: 800; line-height: 1; white-space: nowrap;
  border: 2px solid transparent; border-radius: var(--radius-banner); cursor: pointer;
  text-decoration: none; transition: background 120ms, border-color 120ms, transform 120ms, box-shadow 120ms;
}
.fm-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.fm-btn:active { transform: translateY(1px); }
.fm-btn--sm { font-size: var(--fs-xs); padding: 8px 16px; }
.fm-btn--primary { background: var(--rust-500); color: var(--white); border-color: var(--ink-900); box-shadow: var(--shadow-hard-sm); }
.fm-btn--primary:hover { background: var(--rust-600); }
.fm-btn--gold { background: var(--gold-500); color: var(--navy-700); border-color: var(--ink-900); box-shadow: var(--shadow-hard-sm); }
.fm-btn--gold:hover { background: var(--gold-600); color: var(--white); }
.fm-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---- fm-card ---- */
.fm-card {
  background: var(--surface-card); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden;
}
.fm-card--poster { border: 2px solid var(--ink-900); box-shadow: var(--shadow-hard); border-radius: var(--radius-md); }
.fm-card--warm { background: var(--surface-card-warm); }

/* ---- fm-sign (eyebrow section label) ---- */
.fm-sign {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 800;
  text-transform: uppercase; letter-spacing: var(--ls-caps); font-size: var(--fs-xs);
  line-height: 1; white-space: nowrap;
}
.fm-sign--eyebrow { color: var(--rust-500); }
.fm-sign--muted { color: var(--ink-500); }
.fm-sign svg { width: 14px; height: 14px; }
.fm-ico { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.18em; }

/* ============================================================
   Board chrome (bb-*) - built on the same tokens
   ============================================================ */
.bb-nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper-100) 86%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border-default);
}
.bb-nav__inner {
  max-width: var(--container-app); margin: 0 auto; padding: 0 28px; height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.bb-brand { display: inline-flex; align-items: center; gap: 12px; }
.bb-brand__disc {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 999px; background: var(--rust-500); color: var(--paper-000);
  border: 2px solid var(--ink-900); box-shadow: var(--shadow-hard-sm);
}
.bb-brand__disc svg { width: 60%; height: 60%; }
.bb-brand__wm { font-family: var(--font-display); font-size: 23px; color: var(--text-strong); line-height: 1; }
.bb-meta-mono { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); white-space: nowrap; }

.bb-main {
  max-width: var(--container-app); margin: 0 auto;
  padding: 26px 28px 72px; display: flex; flex-direction: column; gap: 22px;
}

/* stat strip */
.bb-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.bb-stat {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; min-width: 0;
  background: var(--surface-card-warm); border: 1px solid var(--border-soft); border-radius: var(--radius-md);
}
.bb-stat--call { background: var(--rust-050); border: 2px solid var(--rust-500); }
.bb-stat__num { font-family: var(--font-mono); font-size: var(--fs-h3); font-weight: 600; line-height: 1; color: var(--text-strong); }
.bb-stat--call .bb-stat__num { color: var(--rust-600); }
.bb-stat__label { font-family: var(--fon

... [31893 bytes truncated] ...

o un errore",
      unreadable: "la risposta di quota-axi non è leggibile",
      unknown: "stato sconosciuto"
    };
    var KIND_IT = { session: "5 ore", weekly: "settimana" };
    var GENERIC_LABELS = { session: true, week: true, "5-hour": true, weekly: true };
    function windowLabel(w) {
      var label = typeof w.label === "string" ? w.label : "";
      if (label && !GENERIC_LABELS[label.toLowerCase()]) return label;
      return KIND_IT[w.kind] || label || w.id;
    }
    function plain(code) { return STATUS_IT[code] || String(code); }
    function withDetail(code, detail) {
      return plain(code) + (typeof detail === "string" && detail ? ": " + detail : "");
    }
    function isPct(v) { return typeof v === "number" && v >= 0 && v <= 100; }
    function when(iso) {
      var d = new Date(iso);
      if (isNaN(d.getTime())) return iso;
      try {
        return d.toLocaleString("it-IT",
          { weekday: "short", day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" });
      } catch (e) {
        return d.toISOString();
      }
    }
    function resetText(iso) { return "si azzera " + when(iso); }
    function unavailable(msg) {
      box.innerHTML = "";
      box.appendChild(el("div", "bb-empty", "Quote non disponibili - " + msg + "."));
      if (sub) sub.textContent = "non disponibile";
    }
    var q = data.quota;
    if (!q || typeof q !== "object") { unavailable("questa board non contiene i dati di quota"); return; }
    try {
      if (!Array.isArray(q.providers) || !q.providers.length) {
        unavailable(withDetail(q.status || "unknown", q.detail));
        return;
      }
      if (sub) sub.textContent = q.available && q.generated ? "letto " + when(q.generated) : "non disponibile";
      q.providers.forEach(function (p) {
        var card = el("div", "bb-quota__prov");
        var head = el("div", "bb-quota__head");
        head.appendChild(el("span", "bb-quota__name", p.label || p.provider));
        if (p.plan) head.appendChild(el("span", "bb-quota__plan", p.plan));
        card.appendChild(head);
        var windows = Array.isArray(p.windows) ? p.windows : [];
        if (!p.available || !windows.length) {
          card.appendChild(el("div", "bb-quota__na", "non disponibile - " + withDetail(p.status || "unknown", p.detail)));
          box.appendChild(card);
          return;
        }
        windows.forEach(function (w) {
          var win = el("div", "bb-quota__win");
          var line = el("div", "bb-quota__line");
          line.appendChild(el("span", "bb-quota__wlabel", windowLabel(w)));
          var used = isPct(w.percent_used) ? w.percent_used : null;
          var left = isPct(w.percent_remaining) ? w.percent_remaining : null;
          var pct = used == null && left == null ? "non disponibile" :
            (used == null ? "" : "usato " + used + "%") +
            (used != null && left != null ? " · " : "") +
            (left == null ? "" : "restante " + left + "%");
          line.appendChild(el("span", "bb-quota__pct", pct));
          win.appendChild(line);
          if (used != null) {
            var bar = el("div", "bb-quota__bar");
            var fill = el("div", "bb-quota__fill" +
              (used >= 90 ? " bb-quota__fill--danger" : used >= 70 ? " bb-quota__fill--warn" : ""));
            fill.setAttribute("style", "width:" + used + "%");
            bar.appendChild(fill);
            win.appendChild(bar);
          }
          if (typeof w.resets_at === "string" && w.resets_at) win.appendChild(el("div", "bb-quota__reset", resetText(w.resets_at)));
          card.appendChild(win);
        });
        (Array.isArray(p.attention) ? p.attention : []).forEach(function (a) {
          var note = el("div", "bb-quota__note", withDetail(a.kind, a.detail));
          note.title = note.textContent;
          card.appendChild(note);
        });
        box.appendChild(card);
      });
    } catch (e) {
      unavailable("i dati di quota non si possono mostrare");
    }
  })();

  /* Charted Next + dispatch picker */
  var ch = document.getElementById("bb-charted");
  var bar = document.getElementById("bb-dispatch");
  var barCount = document.getElementById("bb-dispatch-count");
  var barLimit = document.getElementById("bb-dispatch-limit");
  var barBtn = document.getElementById("bb-dispatch-btn");
  var anyPickable = false;

  function pickedIds() {
    return Array.prototype.map.call(ch.querySelectorAll(".bb-pick:checked"), function (c) { return c.value; });
  }
  /* the bar always describes the picks as they stand now, so a changed
     selection drops the mark and the alert left by the previous one */
  function refreshBar() {
    var n = pickedIds().length;
    barCount.textContent = n ? n + " picked for dispatch" : "pick queued work to dispatch";
    barBtn.disabled = !n;
    barLimit.classList.remove("is-visible");
    bar.classList.remove("is-queued");
  }
  /* the bar speaks its refusals through an alert of its own, so the count
     label never has to masquerade as an error */
  function refuseDispatch(message) {
    barLimit.textContent = message;
    barLimit.classList.add("is-visible");
  }
  /* same reason the card says reload rather than rebuild: a rebuild restarts
     the Lavish session that carries the queue, and that is what was seen
     orphaning an order live */
  var DISPATCH_BRIDGE_LOST = "Dispatch not sent - the board's connection is unavailable. Reload the board and try again.";

  if (!data.charted.length) ch.appendChild(el("div", "bb-empty", "Nothing is queued."));
  data.charted.forEach(function (t) {
    var row = el("div", "bb-row");
    if (t.dispatchable) {
      anyPickable = true;
      var pick = document.createElement("input");
      pick.type = "checkbox"; pick.className = "bb-pick"; pick.value = t.id;
      pick.setAttribute("aria-label", "Pick " + t.id + " for dispatch");
      pick.addEventListener("change", function () {
        if (pick.checked && utf8ByteLength(pickedIds().join(",")) > 512) {
          pick.checked = false;
          refreshBar();
          refuseDispatch("Selection limit reached (512 bytes maximum).");
          return;
        }
        refreshBar();
      });
      row.appendChild(pick);
    } else {
      row.appendChild(el("span", "bb-pick-spacer"));
    }
    var main = el("div", "bb-row__main");
    main.appendChild(el("div", "bb-row__title", t.title));
    /* second line keeps the title uncrowded in the half-width column */
    var chSub = t.repo || t.id;
    main.appendChild(el("div", "bb-row__sub", t.reason ? t.reason + " · " + chSub : chSub));
    row.appendChild(main);
    if (t.reason) row.appendChild(badge("warn", "waiting"));
    ch.appendChild(row);
  });
  var chartedTotal = data.charted.length + (data.charted_more || 0);
  document.getElementById("bb-charted-sub").textContent =
    data.charted_more ? "showing " + data.charted.length + " of " + chartedTotal : "";
  if (data.charted_more) {
    ch.appendChild(el("span", "bb-morechip", "+" + data.charted_more + " more queued - ask firstmate for the full chart"));
  }

  if (anyPickable) {
    bar.hidden = false;
    refreshBar();
    barBtn.addEventListener("click", function () {
      refreshBar();
      var ids = pickedIds();
      var dispatchAnswer = ids.join(",");
      if (!ids.length) return;
      if (utf8ByteLength(dispatchAnswer) > 512) {
        refuseDispatch("Selection is too long to queue (512 bytes maximum).");
        return;
      }
      if (!window.lavish || !window.lavish.queuePrompt) {
        refuseDispatch(DISPATCH_BRIDGE_LOST);
        return;
      }
      try {
        window.lavish.queuePrompt(
          "Dispatch order - start this queued work now: " + ids.join(", "),
          { tag: "choice", text: "Dispatch: " + ids.join(", "), element: bar,
            queueKey: "dispatch.charted",
            data: { question: "dispatch.charted", answer: dispatchAnswer } }
        );
      } catch (err) {
        refuseDispatch(DISPATCH_BRIDGE_LOST);
        return;
      }
      bar.classList.add("is-queued");
    });
  }
  } catch (e) {
    renderBoardError("The board data could not be rendered");
  }
})();
</script>
</body>
</html>
Evidence: Quota section printed by fm-bearings-quota.sh from mocked quota-axi

Source: Quota section printed by fm-bearings-quota.sh from mocked quota-axi

{
  "source": "quota-axi",
  "generated": "2026-09-26T14:35:03.033Z",
  "available": true,
  "status": "ok",
  "providers": [
    {
      "provider": "claude",
      "label": "Anthropic",
      "available": true,
      "status": "stale",
      "plan": "max",
      "windows": [
        {
          "id": "five_hour",
          "label": "session",
          "kind": "session",
          "percent_used": 52,
          "percent_remaining": 48,
          "resets_at": "2026-09-26T16:40:00Z"
        },
        {
          "id": "seven_day",
          "label": "week",
          "kind": "weekly",
          "percent_used": 33,
          "percent_remaining": 67,
          "resets_at": "2026-10-02T07:00:00Z"
        },
        {
          "id": "model:fable",
          "label": "Fable week",
          "kind": "model",
          "percent_used": null,
          "percent_remaining": null,
          "resets_at": null
        }
      ],
      "attention": [
        {
          "kind": "stale",
          "detail": "fetch failed"
        },
        {
          "kind": "headroom_unknown",
          "detail": "all_models"
        }
      ],
      "detail": "fetch failed"
    },
    {
      "provider": "codex",
      "label": "OpenAI",
      "available": false,
      "status": "auth_required",
      "plan": null,
      "windows": [],
      "attention": [
        {
          "kind": "auth_required",
          "detail": "Codex sign-in required"
        }
      ],
      "detail": "Codex sign-in required"
    },
    {
      "provider": "agy",
      "label": "Google",
      "available": true,
      "status": "fresh",
      "plan": "pro",
      "windows": [
        {
          "id": "gemini_5h",
          "label": "Gemini 5-hour",
          "kind": "session",
          "percent_used": 12,
          "percent_remaining": 88,
          "resets_at": "2026-09-26T18:00:00Z"
        },
        {
          "id": "cg_5h",
          "label": "Claude/GPT 5-hour",
          "kind": "session",
          "percent_used": 35,
          "percent_remaining": 65,
          "resets_at": "2026-09-26T18:00:00Z"
        },
        {
          "id": "gemini_w",
          "label": "Gemini weekly",
          "kind": "weekly",
          "percent_used": 6,
          "percent_remaining": 94,
          "resets_at": "2026-10-01T00:00:00Z"
        },
        {
          "id": "flash",
          "label": "Gemini 3 Flash",
          "kind": "model",
          "percent_used": 0,
          "percent_remaining": 100,
          "resets_at": null
        }
      ],
      "attention": []
    }
  ]
}
Evidence: Quota section printed by the reader when quota-axi is missing

Source: Quota section printed by the reader when quota-axi is missing

{
  "source": "quota-axi",
  "generated": null,
  "available": false,
  "status": "tool_missing",
  "detail": "quota-axi is not installed",
  "providers": [
    {
      "provider": "claude",
      "label": "Anthropic",
      "available": false,
      "status": "tool_missing",
      "detail": "quota-axi is not installed",
      "plan": null,
      "windows": [],
      "attention": []
    },
    {
      "provider": "codex",
      "label": "OpenAI",
      "available": false,
      "status": "tool_missing",
      "detail": "quota-axi is not installed",
      "plan": null,
      "windows": [],
      "attention": []
    },
    {
      "provider": "agy",
      "label": "Google",
      "available": false,
      "status": "tool_missing",
      "detail": "quota-axi is not installed",
      "plan": null,
      "windows": [],
      "attention": []
    }
  ]
}

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ⚠️ bin/fm-bearings-quota.sh:118 - The reader does not always exit 0 as its header and the intent require. The readability guard only checks the top-level providers array. The final jq projection has no guard, so a provider entry with an unexpected field shape makes jq error out. The script then prints nothing and exits 5, and the composer has no quota section to paste. Reproduced with a fake quota-axi: {&#34;providers&#34;:[{&#34;provider&#34;:&#34;claude&#34;,&#34;state&#34;:&#34;fresh&#34;}]} gives Cannot index string with string &#34;status&#34;. &#34;windows&#34;:&#34;x&#34; and &#34;quotaSemantics&#34;:{&#34;effectiveAvailability&#34;:&#34;x&#34;} both give Cannot iterate over string, each with empty output and a non-zero exit. Fix: run the projection so that a jq failure falls back to degraded unreadable ..., for example by capturing its output and rc. Also make the accessors type-safe: use ($p.state | objects | .status), and iterate .windows and effectiveAvailability only when they are arrays.
  • ⚠️ .agents/skills/bearings/assets/board-template.html:774 - The window label uses KIND_IT[w.kind] || w.label, so any window whose kind is session or weekly loses its own label. quota-axi's agy provider (providers/agy.js normalizeQuotaSummaryBucket/agyWindowGroup) sends per-group windows labelled Gemini 5-hour, Claude/GPT 5-hour, Gemini weekly and Claude/GPT weekly, with kind session or weekly. The Google card would show two rows labelled 5 ore and two labelled settimana with different percentages, and nothing to tell the Gemini budget from the Claude/GPT one. That is a wrong label rendered with no error. Fix: use the Italian kind translation only when the vendor label is the generic one (session, week, 5-hour, weekly). Otherwise keep the group or model prefix, for example Gemini · 5 ore.
  • ℹ️ bin/fm-bearings-quota.sh:126 - percent_used is always recomputed as 100 - $rem, even when quota-axi reported percentUsed directly. When only percentUsed is reported and it is not an integer, the double subtraction adds float noise that the board then prints: percentUsed: 0.1 comes out as percent_used: 0.09999999999999432, shown as usato 0.09999999999999432%. It also overwrites a reported percentUsed whenever both values are present. quota-axi's shared clampPercent rounds to integers today, so real impact is low. Fix: keep a valid reported percentUsed, and derive only the value that is missing.

🔧 Fix: Harden quota reader shapes and keep grouped window labels
1 info still open:

  • ℹ️ .agents/skills/bearings/assets/board-template.html:733 - The board is meant to fall back to the Italian kind name ('5 ore' / 'settimana') when a window's label is missing. That fallback can't be reached through the reader. The reader (bin/fm-bearings-quota.sh, window def) replaces a missing label with the window id, or with 'window', before the board sees it. So a quota-axi window with no label, id 'five_hour' and kind 'session' shows as 'five_hour' instead of '5 ore'. Impact is low: every current quota-axi provider (claude, codex, agy) always sends a label. A fix would be to let the reader emit an empty or null label when quota-axi gives none, so the template's label || KIND_IT[kind] || id chain decides. It could also add 'window' to the generic-label set.
✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-bearings-quota.test.sh (7 cases: projection, tool_missing, timeout, failed/unreadable, a readable report winning over a non-zero exit, malformed provider entries, percentUsed kept when reported)
  • bash tests/fm-bearings-board.test.sh (all 21 cases, including the new quota validation and quota DOM-rendering cases)
  • Manual E2E: a fake quota-axi on PATH returns claude (stale, plus unknown headroom and a model window with no value), codex (auth_required) and agy (grouped Gemini/Claude-GPT 5-hour and weekly windows, plus a Gemini 3 Flash model row) -> bin/fm-bearings-quota.sh (rc=0; args checked as --provider claude,codex,agy --json --no-credential-refresh) -> .quota added to a sample payload -> FM_HOME=&lt;tmp&gt; bin/fm-bearings-board.sh build with a stubbed lavish-axi -> google-chrome --headless --screenshot of the published bearings-board.html
  • Manual degraded E2E: bin/fm-bearings-quota.sh run with no quota-axi on PATH (rc=0, status tool_missing) -> board build -> headless Chrome screenshot
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Alan Domio added 3 commits September 26, 2026 16:46
… board

Add bin/fm-bearings-quota.sh, a bounded one-shot quota-axi reader that
prints the board payload's optional quota section and degrades to an
unavailable section (tool missing, timeout, failed, unreadable, signed
out, not reported) instead of failing or inventing numbers. The board
validates the optional section, the template renders it as an Italian
panel isolated from the rest of the board, and the bearings skill tells
the composer to copy the reader output verbatim.
@alandomio
alandomio merged commit ab9a9c1 into main Sep 26, 2026
24 of 25 checks passed
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