Skip to content

feat(gateway): tell bouncer when a request runs on a ChatGPT subscription - #7820

Merged
iscekic merged 1 commit into
mainfrom
feat/bouncer-siwc-flag
Oct 19, 2026
Merged

iscekic merged 1 commit into
mainfrom
feat/bouncer-siwc-flag

Conversation

@iscekic

@iscekic iscekic commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Bouncer is adding a siwc_pool rule. It flags payers who run on their own ChatGPT subscription ("Sign in with ChatGPT") and share one IP or JA4 digest. Bouncer can only learn that a request is SIWC from the usage event that Cloud sends. This PR makes Cloud send that fact.

  • The signed-in usage event gets an optional siwc field.
  • The gateway sets siwc: true only when the request routed to the openai-chatgpt provider. Other requests omit the field. The wire body never sends false.
  • Anonymous usage events never carry the field.

The deployed bouncer validates with typia createValidate, so it accepts the extra field and ignores it until the bouncer change deploys. Cloud can ship first.

Verification

  • New test in processUsage.test.ts: a request with provider openai-chatgpt reports siwc: true; the existing non-SIWC test now asserts that the field is absent.
  • New test in bouncer/client.test.ts: the wire body sends siwc only when it is true.
  • These suites need Postgres, so they run in CI.

Visual Changes

N/A

Reviewer Notes

No decide payload, UI, or DB change.

@kilo-code-bot

kilo-code-bot Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The PR adds an optional siwc flag to signed-in bouncer usage events, set only when the request routed to the openai-chatgpt provider; reviewed all four changed files and found no bugs, security, or reliability issues.

Verification notes

  • bouncerUsageEvent (packages/web-shared/src/lib/ai-gateway/processUsage.ts:1473) sets siwc: true only when usageContext.provider === OPENAI_CHATGPT_PROVIDER_ID; usageContext.provider is populated from the effective routed provider id (handlers/llm-proxy.ts:829), so the flag tracks the delegated ChatGPT connection.
  • The anonymous branch returns before the siwc spread, so anonymous events never carry the field, matching the stated intent.
  • usageEventWireBody (packages/web-shared/src/lib/bouncer/client.ts:638) uses event.siwc === true || undefined, and compact drops undefined, so the wire body never sends false.
  • OPENAI_CHATGPT_PROVIDER_ID ('openai-chatgpt') is a member of ProviderId and is already imported elsewhere in this package with the same specifier form, so the comparison is type-safe and cycle-free.
  • New tests assert siwc: true for the SIWC path, absence for the non-SIWC and wire-body cases.
Files Reviewed (4 files)
  • packages/web-shared/src/lib/ai-gateway/processUsage.ts
  • packages/web-shared/src/lib/ai-gateway/processUsage.test.ts
  • packages/web-shared/src/lib/bouncer/client.ts
  • packages/web-shared/src/lib/bouncer/client.test.ts

Reviewed by deepseek-v4.1-flash · Input: 53.5K · Output: 7.5K · Cached: 593.8K

Review guidance: REVIEW.md from base branch main

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.

2 participants