fix(byok): a reader's own key never touches the deployment's bookkeeping (1.18.0) - #77
Merged
Merged
Conversation
…ing (1.18.0) byokChain links share their provider id with the deployment's link to the same vendor (groq is groq), and every shared ledger in this package keys on it. So: - Provider.byok marks an own-key link (set by byokChain). - dayCapacityTokens never counts it, even with a *_DAILY_TOKENS override. - createLinkCooldown never cools a link because of it — one reader's exhausted personal quota used to cool groq/<model> for everybody. - tryChain / walkChain / completeStream record no health for it: one reader's bad key says nothing about whether the site's AI works. - Quota readings about it carry byok: true, so an app's store can skip them. - dailyTokens is 0, not Infinity: a caller summing it by hand adds nothing. - New exports: isOwnKeyLink(link), healthFor(chain, health). No live app was exposed (checked loki, substrata, heidi, orangecat, evig, petvity: none fed an own-key chain into capacity); this closes the trap for the next one. Each guard mutation-checked. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Problem.
byokChainlinks share their provider id with the deployment's own link to the same vendor (groqisgroq), and every shared ledger in ai-kit keys on that id. So a reader's own key could:createLinkCooldown.recordon a reader's personal daily 429 coolsgroq/<model>until UTC midnight;dailyTokens: Infinitymakes any hand-rolled sum unlimited, and a*_DAILY_TOKENSoverride would be counted bydayCapacityTokens;Fix
Provider.byok, set bybyokChain. The id is unchanged, because apps show and log it.dayCapacityTokensskipsbyokproviders.createLinkCooldown.recordignoresbyoklinks.tryChain/walkChain/completeStreamrecord no health for them:QuotaReading.byok: trueon readings from own-key links.dailyTokens: 0instead ofInfinity.isOwnKeyLink,healthFor.Exposure today: none. I checked loki, substrata, heidi, orangecat, evig and petvity; none feeds an own-key chain into capacity, and Loki skips telemetry on its own-model path. This closes the trap for the next app. After it ships, Heidi can drop its local
dailyTokens: 0pin (heidi#138).Checked
pnpm run verifygreen (350 pass).test/byok-isolation.test.js(6 tests). Each guard was mutation-checked by removing it and rebuilding: capacity, cooldown, health, reading flag, and Infinity each turn a test red.Minor bump to 1.18.0. It publishes when the
v1.18.0tag is pushed after merge.🤖 Generated with Claude Code