Skip to content

feat(vault): read Claude quota from insula; adopt common-auth 0.19.1 - #389

Draft
antauth-alfonso[bot] wants to merge 9 commits into
mainfrom
feat/insula-quota-0.19.1
Draft

antauth-alfonso[bot] wants to merge 9 commits into
mainfrom
feat/insula-quota-0.19.1

Conversation

@antauth-alfonso

@antauth-alfonso antauth-alfonso Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Vault mode reads Claude quota from insula, the fleet's quota monitor, instead of every plugin polling Anthropic's usage endpoint itself, and adopts @cortexkit/common-auth@0.19.1 (gitHead 271bc3da, integrity matching the signed-off candidate), which makes insula's consumer-free reader public.

  • Vault mode only. Enrollment authority is read fresh on each background tick; local mode, or a missing or unreadable enrollment token, never touches insula.
  • Background tick: acquireInsulaQuotaSource (shared per connection file and enrollment token, one refresh a minute), then current('claude', accountId) per vault account, joined by the vault's account_id only. A current reading is published bound to the served credential version and our own usage poll is skipped for that account; anything else (missing, stale, errorClass, over four minutes, or a credential for a different account) falls back to our poll for that account immediately.
  • Request path: reads insula's cache only, never refreshes it, then our one-shot poll on a miss.
  • Mapping: five-hour and seven-day windows from primary/secondary, model-scoped weeklies (Fable) from extraRateWindows by id, usedPercent as is, and every window's reading time is insula's fetchedAt. A newer window on disk is never overwritten by an older insula one.
  • One info log line when an account's source switches between insula and our poll, with a fixed reason code and no identity.
  • The source is released when the vault runtime closes.

Mutation rows guard the account join, the poll skip and the release.


Summary by cubic

Vault mode reads Claude quota from insula, the fleet's quota monitor, instead of every plugin polling Anthropic's usage endpoint itself, and adopts @cortexkit/common-auth@0.19.1, which exposes the consumer-free insula reader. Local mode, or a missing or unreadable enrollment token, never touches insula.

  • Background sweeps refresh insula's cache (shared per connection file and enrollment token, once a minute) and use a current reading per account, skipping that account's usage GET; a missing, stale, failed, or foreign-account reading falls back to polling immediately.
  • Request-path (admission) lookups read insula's cache only, never refresh it, and poll on a miss.
  • Insula entries are mapped to the existing snapshot shape: five-hour and seven-day windows, model-scoped weeklies (such as Fable) from extraRateWindows, and the Extra usage pool; a newer stored window is never overwritten by an older insula one.
  • Source switches are logged once per change with a fixed reason code and no identity, and the insula source is released when the vault runtime closes.
  • Sidebar state writes now look up their test hooks at rename time, so a test that starts listening mid-write still hears the rename instead of timing out.

Written for commit 5f1724d. Summary will update on new commits.

View guided diff Turn on auto-fix

@socket-security

socket-security Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​cortexkit/​common-auth@​0.19.0 ⏵ 0.19.18510082 +196100

View full report

writeSidebarStateAtomic read its test hooks once, when the write began, and reused that snapshot after the rename. A test that installed its listener mid-write, after reading the old file, never heard the rename and waited until its 5 s timeout. That flaked "feed publication failure does not affect response, quota persistence, or sidebar update" about 3 in 40 runs on main and this branch alike. The after-rename hook is now looked up at rename time; production runs without hooks.
The shared-source test catches both mutants at its first assertion, a toBe on the reading time, so its failure message is toBe rather than toEqual.
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