Repository navigation
feat(bearings): show Anthropic, OpenAI and Google quota on the fleet board - #43
Merged
Merged
Conversation
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.
…ation env inventory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
bin/fm-bearings-quota.sh, a dedicated reader that runsquota-axi --provider claude,codex,agy --json --no-credential-refreshonce. Each run is capped byfm_run_timedwithFM_BEARINGS_QUOTA_TIMEOUT, which defaults to 20s. The reader always exits 0 and prints an optionalquotasection 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 markednot_reported, and any percentage it doesn't report stays null.bin/fm-bearings-board.shnow validates the optionalquotasection. A payload withoutquotastill 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.bin/fm-test-run.sh, and the new script andFM_BEARINGS_QUOTA_TIMEOUTare documented indocs/scripts.mdanddocs/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)
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
Evidence: Quota section printed by the reader when quota-axi is missing
Source: Quota section printed by the reader when quota-axi is missing
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
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-levelprovidersarray. 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 noquotasection to paste. Reproduced with a fake quota-axi:{"providers":[{"provider":"claude","state":"fresh"}]}givesCannot index string with string "status"."windows":"x"and"quotaSemantics":{"effectiveAvailability":"x"}both giveCannot iterate over string, each with empty output and a non-zero exit. Fix: run the projection so that a jq failure falls back todegraded unreadable ..., for example by capturing its output and rc. Also make the accessors type-safe: use($p.state | objects | .status), and iterate.windowsandeffectiveAvailabilityonly when they are arrays..agents/skills/bearings/assets/board-template.html:774- The window label usesKIND_IT[w.kind] || w.label, so any window whose kind issessionorweeklyloses its own label. quota-axi's agy provider (providers/agy.js normalizeQuotaSummaryBucket/agyWindowGroup) sends per-group windows labelledGemini 5-hour,Claude/GPT 5-hour,Gemini weeklyandClaude/GPT weekly, with kindsessionorweekly. The Google card would show two rows labelled5 oreand two labelledsettimanawith 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 exampleGemini · 5 ore.bin/fm-bearings-quota.sh:126-percent_usedis always recomputed as100 - $rem, even when quota-axi reportedpercentUseddirectly. When onlypercentUsedis reported and it is not an integer, the double subtraction adds float noise that the board then prints:percentUsed: 0.1comes out aspercent_used: 0.09999999999999432, shown asusato 0.09999999999999432%. It also overwrites a reportedpercentUsedwhenever both values are present. quota-axi's shared clampPercent rounds to integers today, so real impact is low. Fix: keep a valid reportedpercentUsed, 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'slabel || KIND_IT[kind] || idchain 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 fakequota-axion 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) ->.quotaadded to a sample payload ->FM_HOME=<tmp> bin/fm-bearings-board.sh buildwith a stubbedlavish-axi->google-chrome --headless --screenshotof the published bearings-board.htmlManual degraded E2E:bin/fm-bearings-quota.shrun 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.