@@ -52,7 +52,7 @@ import { TraceAttr } from '@/lib/mothership/generated/trace-attributes-v1'
5252import { TraceSpan } from '@/lib/mothership/generated/trace-spans-v1'
5353import { recordJobRunSpend } from '@/lib/mothership/jobs/budget'
5454import { checkInternalApiKey } from '@/lib/mothership/request/http'
55- import { withIncomingGoSpan } from '@/lib/mothership/request/otel'
55+ import { withIncomingWorkerSpan } from '@/lib/mothership/request/otel'
5656
5757const logger = createLogger ( 'BillingUpdateCostAPI' )
5858/**
@@ -174,13 +174,13 @@ function getBillingResolution(
174174 * POST /api/billing/update-cost
175175 * Update user cost with a pre-calculated cost value (internal API key auth required)
176176 *
177- * Parented under the Go-side `sim.update_cost` span via W3C traceparent
178- * propagation. Every mothership request that bills should therefore show
179- * the Go client span AND this Sim server span sharing one trace, with
177+ * Parented under the worker's span via W3C traceparent propagation. Every
178+ * mothership request that bills should therefore show the worker's span AND
179+ * this Sim server span sharing one trace, with
180180 * the actual usage/overage work nested below.
181181 */
182182export const POST = withRouteHandler ( ( req : NextRequest ) =>
183- withIncomingGoSpan (
183+ withIncomingWorkerSpan (
184184 req . headers ,
185185 TraceSpan . CopilotBillingUpdateCost ,
186186 {
@@ -417,7 +417,7 @@ async function updateCostInner(req: NextRequest, span: Span): Promise<NextRespon
417417 } )
418418
419419 /**
420- * Go sends cumulative cost across partial, terminal, and retry flushes.
420+ * The worker sends cumulative cost across partial, terminal, and retry flushes.
421421 * Every accepted callback has a stable key, so the maximum cumulative cost
422422 * converges on one ledger event without underbilling or double-billing.
423423 */
@@ -456,7 +456,7 @@ async function updateCostInner(req: NextRequest, span: Span): Promise<NextRespon
456456
457457 // Reconcile the payer's ledger-backed threshold after every cumulative
458458 // callback, including duplicate retries after a prior settlement failure.
459- // Strict error handling lets Go retry until the committed usage is settled.
459+ // Strict error handling lets the worker retry until the committed usage is settled.
460460 if ( billingContext ) {
461461 try {
462462 await checkAndBillPayerOverageThreshold ( billingContext . billingEntity , {
@@ -492,7 +492,7 @@ async function updateCostInner(req: NextRequest, span: Span): Promise<NextRespon
492492 const duration = Date . now ( ) - startTime
493493
494494 // Same-or-lower cumulative than already recorded: nothing new to bill.
495- // Reconciliation has completed, so preserve Go's established 409 outcome .
495+ // Reconciliation has completed, so return the 409 the worker reads as already settled .
496496 if ( ! billed ) {
497497 logger . info ( 'Duplicate/non-increasing cumulative cost; no new charge' , {
498498 idempotencyKey,
0 commit comments