fix(quota): identify OpenCode Go by where it routes, not what it is named - #2164
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
Stack mapMerge bottom-up; each layer's base is the branch below it.
All five are rebased onto the current |
…amed A multi-account setup points several provider rows at the same OpenCode Go endpoint under names the registry has never heard of -- opencode-go-2 through -5. Quota dispatch gated on the literal name "opencode-go", so those rows had no dashboard quota panel and no report in `ocx provider quota --refresh --json` even though each one holds a working key for the same upstream (#1924). Identity is now answered by registryEntryForProviderDestination, the predicate this repository already uses for renamed fixed-key rows: it matches on normalized endpoint plus adapter plus key auth. A bare URL comparison would have been enough for the reported symptom but would also probe a row that points at that host through a different adapter, which speaks a different protocol and is not the provider whose quota shape we parse. The defensive canonical-URL check inside fetchOpenCodeGoQuota stays. Whether an API key may be sent to a host must not depend on the dispatch gate above it being correct. Absorbed from #2027 by @yzxcj797.
4ee6161 to
293494c
Compare
Ingwannu
left a comment
There was a problem hiding this comment.
Approved for this layer only, relative to codex/absorb-agentrouter-language-framing. The destination predicate is stricter than the original URL-only proposal: normalized endpoint, matching adapter, and key auth must all resolve to the canonical opencode-go registry row, while fetchOpenCodeGoQuota retains its own defensive destination check before sending the bearer credential. The renamed-sibling and wrong-adapter regressions both pass; the exact current layer CI is green.
Merge/retarget bottom-up only after the lower stack blockers are resolved, then preserve exact-head CI on the dev comparison.
리뷰 · 우선순위 62 / 80#1924 실화임. 지금 #2027을 가져옴. 원본은 baseUrl만 바꿈. 어댑터를 안 봐서 같은 URL에 다른 어댑터면 쿼타 셰이프가 다른데도 프로브함. 이번엔 스택 레이어 4. 베이스가 #2162지 점수는 62임. 2.27은 이미 나감. 2.28. #2162 먼저. 해결방안: #2162 머지 후 이 PR. 시블링 이름 테스트 유지. 잘못된 어댑터 가드도 유지. 이 댓글은 grok-bot이 작성했습니다 |
Summary
Absorbs #2027 by @yzxcj797. Stack layer 4 — base is
codex/absorb-agentrouter-language-framing(#2162), notdev.The defect (#1924). A multi-account setup points several provider rows at the same OpenCode Go endpoint under names the registry has never heard of —
opencode-go-2through-5. Quota dispatch gated on the literal name"opencode-go"(src/providers/quota.ts), so those rows had no dashboard quota panel and no report inocx provider quota --refresh --json, even though each holds a working key for the same upstream.Worth naming: identity was already answered inconsistently here. Dispatch asked "what is this row called"; the credential-safety check inside
fetchOpenCodeGoQuotaasked "where does it actually route". The second question is the right one.The correction on top of #2027. The original swaps the name for a base-URL comparison. That fixes the reported symptom but does not check the adapter, so a row pointing at the canonical URL through a different adapter would be probed — a different protocol to that host, and not the provider whose quota shape we parse.
This uses
registryEntryForProviderDestination, which this repository already uses for renamed fixed-key rows (opencode-zen-rate-limit.ts,derive.ts): normalized endpoint + adapter + key auth.Rejected alternative, recorded.
providerMatchesRegistryTransport("opencode-go", provider)would needpreserveCustomDestination: trueon the registry entry, which also changes routing for a same-named custom row. That may be worth doing on its own merits; it is not something a quota fix should do as a side effect.The defensive canonical-URL check inside
fetchOpenCodeGoQuotastays. Whether an API key may be sent to a host must not depend on the dispatch gate above it being correct.No
package.jsonchange — the version bump in #2027 was inherited from its branch point and was the entire reason GitHub marked itCONFLICTING.Closes #2027. Fixes #1924.
Verification
bun run typecheck— clean.bun test --isolate tests/opencode-go-quota.test.ts— 4 pass / 0 fail.src/providers/quota.tsfails exactly the sibling-row test (3 pass / 1 fail). The wrong-adapter test stays green on unpatcheddevbecausedevprobes nothing but the literal name — which is what makes it a guard against the URL-only predicate rather than a restatement of the fix.bun run testat the stack tip — 13562 pass / 10 skip / 0 fail across 857 files.bun run privacy:scan— passed.Checklist
The test asserts the sibling's key never appears in the serialized report.
Stack (bottom to top): #2134 → #2160 → #2162 → this → openai-chat padding repeats