Skip to content

fix(quota): identify OpenCode Go by where it routes, not what it is named - #2164

Merged
lidge-jun merged 1 commit into
devfrom
codex/absorb-opencode-go-quota-siblings
Aug 20, 2026
Merged

fix(quota): identify OpenCode Go by where it routes, not what it is named#2164
lidge-jun merged 1 commit into
devfrom
codex/absorb-opencode-go-quota-siblings

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

Absorbs #2027 by @yzxcj797. Stack layer 4 — base is codex/absorb-agentrouter-language-framing (#2162), not dev.

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-2 through -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 in ocx 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 fetchOpenCodeGoQuota asked "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 need preserveCustomDestination: true on 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 fetchOpenCodeGoQuota stays. Whether an API key may be sent to a host must not depend on the dispatch gate above it being correct.

No package.json change — the version bump in #2027 was inherited from its branch point and was the entire reason GitHub marked it CONFLICTING.

Closes #2027. Fixes #1924.

Verification

  • bun run typecheck — clean.
  • bun test --isolate tests/opencode-go-quota.test.ts — 4 pass / 0 fail.
  • RED-first. Reverting only src/providers/quota.ts fails exactly the sibling-row test (3 pass / 1 fail). The wrong-adapter test stays green on unpatched dev because dev probes 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 test at the stack tip — 13562 pass / 10 skip / 0 fail across 857 files.
  • bun run privacy:scan — passed.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

The test asserts the sibling's key never appears in the serialized report.


Stack (bottom to top): #2134#2160#2162this → openai-chat padding repeats

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner August 20, 2026 01:14
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • ^dev$
  • ^preview$

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3615ab6f-27cb-48fe-bcaf-3c952371d4c2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Stack map

Merge bottom-up; each layer's base is the branch below it.

# PR Branch Absorbs
1 #2134 codex/fix-subagent-roster-truncation maintainer fix (base dev)
2 #2160 codex/absorb-opencode-free-static-headers #2067 @waw4303
3 #2162 codex/absorb-agentrouter-language-framing #2082 @yzxcj797
4 #2164 codex/absorb-opencode-go-quota-siblings #2027 @yzxcj797
5 #2165 codex/absorb-openai-chat-padding-repeats #2155 @waw4303

All five are rebased onto the current dev tip and the full suite is green at the top of the stack (13562 pass / 0 fail). Retarget the remaining children to dev as each parent lands.

…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.

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@lidge-jun

Copy link
Copy Markdown
Owner Author

리뷰 · 우선순위 62 / 80

#1924 실화임. 지금 quota.ts 2087줄이 name === "opencode-go"만 봄. opencode-go-2부터 -5처럼 같은 Zen Go 엔드포인트에 다른 이름이면 대시보드 쿼타 패널이 없고 ocx provider quota --refresh --json에도 안 나옴. 키는 됨. 디스패치는 이름을 묻고 fetchOpenCodeGoQuota 안쪽은 목적지를 물음. 뒤가 맞음.

#2027을 가져옴. 원본은 baseUrl만 바꿈. 어댑터를 안 봐서 같은 URL에 다른 어댑터면 쿼타 셰이프가 다른데도 프로브함. 이번엔 registryEntryForProviderDestination — 정규화 엔드포인트 + 어댑터 + key auth. zen-rate-limit이랑 derive가 이미 쓰는 거임. providerMatchesRegistryTransportpreserveCustomDestination이 라우팅까지 바꿔서 거절. 맞음. 안의 canonical URL 가드는 남김. 디스패치가 틀려도 키를 이상한 호스트로 안 보냄.

스택 레이어 4. 베이스가 #2162지 dev가 아님. 파일은 quota.ts랑 테스트뿐이라 테제는 깨끗함. types.ts/config.ts 안 건드림. #2027 package.json 범프는 뺐음. 원 PR 리베이스하지 말 것. #1924는 머지되면 닫으면 됨.

점수는 62임. 2.27은 이미 나감. 2.28. #2162 먼저.

해결방안: #2162 머지 후 이 PR. 시블링 이름 테스트 유지. 잘못된 어댑터 가드도 유지.

이 댓글은 grok-bot이 작성했습니다

@lidge-jun
lidge-jun changed the base branch from codex/absorb-agentrouter-language-framing to dev August 20, 2026 02:56
@lidge-jun
lidge-jun merged commit 31750b0 into dev Aug 20, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants