@@ -105,7 +105,7 @@ const ATTRIBUTION = {
105105 payerSubscription : null ,
106106}
107107
108- const OLD_GO_HOSTED_UPDATE_COST_BODY = {
108+ const SELF_HOSTED_UPDATE_COST_BODY = {
109109 userId : 'user-1' ,
110110 cost : 0.4662453 ,
111111 model : 'claude-opus-4.8' ,
@@ -117,11 +117,11 @@ const OLD_GO_HOSTED_UPDATE_COST_BODY = {
117117} as const
118118
119119const EXPLICIT_LEGACY_HOSTED_UPDATE_COST_BODY = {
120- ...OLD_GO_HOSTED_UPDATE_COST_BODY ,
120+ ...SELF_HOSTED_UPDATE_COST_BODY ,
121121 idempotencyKey : 'explicit-legacy-billing-id' ,
122122} as const
123123
124- const OLD_GO_WORKSPACELESS_UPDATE_COST_BODY = {
124+ const SELF_HOSTED_WORKSPACELESS_UPDATE_COST_BODY = {
125125 userId : 'user-1' ,
126126 cost : 0.5 ,
127127 model : 'gpt' ,
@@ -131,8 +131,8 @@ const OLD_GO_WORKSPACELESS_UPDATE_COST_BODY = {
131131 idempotencyKey : 'random-old-go-direct-billing-id' ,
132132} as const
133133
134- const OLD_GO_OPAQUE_WORKSPACE_UPDATE_COST_BODY = {
135- ...OLD_GO_WORKSPACELESS_UPDATE_COST_BODY ,
134+ const SELF_HOSTED_OPAQUE_WORKSPACE_UPDATE_COST_BODY = {
135+ ...SELF_HOSTED_WORKSPACELESS_UPDATE_COST_BODY ,
136136 workspaceId : 'local-self-hosted-workspace' ,
137137} as const
138138
@@ -148,7 +148,7 @@ const KEYLESS_UPDATE_COST_BODY = {
148148describe ( 'POST /api/billing/update-cost — workspaceId attribution' , ( ) => {
149149 beforeEach ( ( ) => {
150150 vi . clearAllMocks ( )
151- setEnvFlags ( { isBillingEnabled : true , isCopilotBillingProtocolRequired : false } )
151+ setEnvFlags ( { isBillingEnabled : true , isHosted : false } )
152152 mockCheckInternalApiKey . mockReturnValue ( { success : true } )
153153 mockRecordCumulativeUsage . mockResolvedValue ( { billed : true , delta : 0.5 , total : 0.5 } )
154154 mockCheckAndBillOverageThreshold . mockResolvedValue ( undefined )
@@ -187,7 +187,7 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
187187 expect ( mockRecordCumulativeUsage ) . not . toHaveBeenCalled ( )
188188 } )
189189
190- it ( 'returns no-op success for old markerless Go when billing is disabled' , async ( ) => {
190+ it ( 'returns no-op success for markerless local self-hosted Go when billing is disabled' , async ( ) => {
191191 setEnvFlags ( { isBillingEnabled : false } )
192192
193193 const res = await POST (
@@ -213,13 +213,13 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
213213 expect ( mockRecordCumulativeUsage ) . not . toHaveBeenCalled ( )
214214 } )
215215
216- it ( 'keeps the exact old-Go callback bodies contract-compatible' , ( ) => {
217- expect ( billingUpdateCostBodySchema . safeParse ( OLD_GO_HOSTED_UPDATE_COST_BODY ) . success ) . toBe ( true )
216+ it ( 'keeps local self-hosted callback bodies contract-compatible' , ( ) => {
217+ expect ( billingUpdateCostBodySchema . safeParse ( SELF_HOSTED_UPDATE_COST_BODY ) . success ) . toBe ( true )
218218 expect (
219- billingUpdateCostBodySchema . safeParse ( OLD_GO_WORKSPACELESS_UPDATE_COST_BODY ) . success
219+ billingUpdateCostBodySchema . safeParse ( SELF_HOSTED_WORKSPACELESS_UPDATE_COST_BODY ) . success
220220 ) . toBe ( true )
221221 expect (
222- billingUpdateCostBodySchema . safeParse ( OLD_GO_OPAQUE_WORKSPACE_UPDATE_COST_BODY ) . success
222+ billingUpdateCostBodySchema . safeParse ( SELF_HOSTED_OPAQUE_WORKSPACE_UPDATE_COST_BODY ) . success
223223 ) . toBe ( true )
224224 } )
225225
@@ -234,9 +234,9 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
234234 expect ( mockCheckAndBillPayerOverageThreshold ) . not . toHaveBeenCalled ( )
235235 } )
236236
237- it ( 'bills the routed workspace payer for the exact markerless hosted callback' , async ( ) => {
237+ it ( 'bills the routed workspace payer for a markerless self- hosted callback' , async ( ) => {
238238 const res = await POST (
239- createMockRequest ( 'POST' , OLD_GO_HOSTED_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
239+ createMockRequest ( 'POST' , SELF_HOSTED_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
240240 )
241241
242242 expect ( res . status ) . toBe ( 200 )
@@ -277,7 +277,7 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
277277 )
278278
279279 const res = await POST (
280- createMockRequest ( 'POST' , OLD_GO_HOSTED_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
280+ createMockRequest ( 'POST' , SELF_HOSTED_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
281281 )
282282
283283 expect ( res . status ) . toBe ( 503 )
@@ -290,10 +290,10 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
290290 } )
291291 } )
292292
293- it ( 'rejects markerless callbacks only when protocol-required is explicitly enabled ' , async ( ) => {
294- setEnvFlags ( { isCopilotBillingProtocolRequired : true } )
293+ it ( 'rejects markerless callbacks on hosted Sim ' , async ( ) => {
294+ setEnvFlags ( { isHosted : true } )
295295 const res = await POST (
296- createMockRequest ( 'POST' , OLD_GO_HOSTED_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
296+ createMockRequest ( 'POST' , SELF_HOSTED_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
297297 )
298298
299299 expect ( res . status ) . toBe ( 400 )
@@ -303,7 +303,7 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
303303
304304 it ( 'does not let markerless legacy traffic fall through to a modern attribution envelope' , async ( ) => {
305305 const res = await POST (
306- createMockRequest ( 'POST' , OLD_GO_HOSTED_UPDATE_COST_BODY , {
306+ createMockRequest ( 'POST' , SELF_HOSTED_UPDATE_COST_BODY , {
307307 'x-api-key' : 'internal' ,
308308 'x-sim-billing-attribution' : 'serialized-attribution' ,
309309 } )
@@ -316,7 +316,7 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
316316 } )
317317
318318 it ( 'rejects explicitly labeled legacy callbacks without admission attribution' , async ( ) => {
319- setEnvFlags ( { isCopilotBillingProtocolRequired : true } )
319+ setEnvFlags ( { isHosted : true } )
320320 const res = await POST (
321321 createMockRequest ( 'POST' , EXPLICIT_LEGACY_HOSTED_UPDATE_COST_BODY , {
322322 'x-api-key' : 'internal' ,
@@ -331,7 +331,7 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
331331 } )
332332
333333 it ( 'bills explicitly labeled legacy callbacks from their admission attribution' , async ( ) => {
334- setEnvFlags ( { isCopilotBillingProtocolRequired : true } )
334+ setEnvFlags ( { isHosted : true } )
335335 const res = await POST (
336336 createMockRequest ( 'POST' , EXPLICIT_LEGACY_HOSTED_UPDATE_COST_BODY , {
337337 'x-api-key' : 'internal' ,
@@ -507,13 +507,13 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
507507 expect ( mockRecordCumulativeUsage ) . not . toHaveBeenCalled ( )
508508 } )
509509
510- it ( 'does not expose context-mismatch 409 to markerless old Go' , async ( ) => {
510+ it ( 'does not expose context-mismatch 409 to markerless self-hosted Go' , async ( ) => {
511511 mockRecordCumulativeUsage . mockRejectedValue (
512512 new MockCumulativeUsageContextMismatchError ( 'different billing context' )
513513 )
514514
515515 const res = await POST (
516- createMockRequest ( 'POST' , OLD_GO_HOSTED_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
516+ createMockRequest ( 'POST' , SELF_HOSTED_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
517517 )
518518
519519 expect ( res . status ) . toBe ( 500 )
@@ -525,10 +525,10 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
525525 expect ( mockCheckAndBillPayerOverageThreshold ) . not . toHaveBeenCalled ( )
526526 } )
527527
528- it ( 'preserves old Go duplicate-compatible 409 semantics for markerless callbacks' , async ( ) => {
528+ it ( 'preserves duplicate-compatible 409 semantics for markerless self-hosted callbacks' , async ( ) => {
529529 mockRecordCumulativeUsage . mockResolvedValue ( { billed : false , delta : 0 , total : 0.4662453 } )
530530 const res = await POST (
531- createMockRequest ( 'POST' , OLD_GO_HOSTED_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
531+ createMockRequest ( 'POST' , SELF_HOSTED_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
532532 )
533533 expect ( res . status ) . toBe ( 409 )
534534 await expect ( res . json ( ) ) . resolves . toMatchObject ( {
@@ -558,7 +558,7 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
558558 . mockRejectedValueOnce ( new Error ( 'Threshold settlement unavailable' ) )
559559 . mockResolvedValueOnce ( undefined )
560560 const createRequest = ( ) =>
561- createMockRequest ( 'POST' , OLD_GO_HOSTED_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
561+ createMockRequest ( 'POST' , SELF_HOSTED_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
562562
563563 const firstResponse = await POST ( createRequest ( ) )
564564 const retryResponse = await POST ( createRequest ( ) )
@@ -669,9 +669,11 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
669669 )
670670 } )
671671
672- it ( 'preserves account-ledger ownership for the exact workspace-less old-Go callback' , async ( ) => {
672+ it ( 'preserves account-ledger ownership for a workspace-less self-hosted callback' , async ( ) => {
673673 const res = await POST (
674- createMockRequest ( 'POST' , OLD_GO_WORKSPACELESS_UPDATE_COST_BODY , { 'x-api-key' : 'internal' } )
674+ createMockRequest ( 'POST' , SELF_HOSTED_WORKSPACELESS_UPDATE_COST_BODY , {
675+ 'x-api-key' : 'internal' ,
676+ } )
675677 )
676678
677679 expect ( res . status ) . toBe ( 200 )
@@ -691,7 +693,7 @@ describe('POST /api/billing/update-cost — workspaceId attribution', () => {
691693 it ( 'preserves account-ledger ownership for an opaque direct legacy workspace' , async ( ) => {
692694 mockResolveLegacyV0BillingAttribution . mockResolvedValueOnce ( null )
693695 const res = await POST (
694- createMockRequest ( 'POST' , OLD_GO_OPAQUE_WORKSPACE_UPDATE_COST_BODY , {
696+ createMockRequest ( 'POST' , SELF_HOSTED_OPAQUE_WORKSPACE_UPDATE_COST_BODY , {
695697 'x-api-key' : 'internal' ,
696698 } )
697699 )
0 commit comments