@@ -258,6 +258,32 @@ describe("request log metadata", () => {
258258 expect ( captured2 [ 0 ] ) . not . toHaveProperty ( "firstOutputMs" ) ;
259259 } ) ;
260260
261+ test ( "persists the shadow helper source marker to usage.jsonl" , ( ) => {
262+ const home = mkdtempSync ( join ( tmpdir ( ) , "ocx-shadow-usage-" ) ) ;
263+ const previousHome = process . env . OPENCODEX_HOME ;
264+ process . env . OPENCODEX_HOME = home ;
265+ try {
266+ clearRequestLogsForTests ( ) ;
267+ resetUsageReadCacheForTests ( ) ;
268+ addFinalRequestLog ( "ocx-shadow-marker" , 1 , {
269+ model : "grok-4.5" ,
270+ provider : "xai" ,
271+ requestedModel : "gpt-5.6-luna" ,
272+ shadowCallRewrittenFrom : "gpt-5.6-luna" ,
273+ } , 200 ) ;
274+
275+ const [ persisted ] = readUsageEntries ( ) ;
276+ expect ( persisted ?. shadowCallRewrittenFrom ) . toBe ( "gpt-5.6-luna" ) ;
277+ expect ( getRequestLogEntries ( ) [ 0 ] ?. shadowCallRewrittenFrom ) . toBe ( "gpt-5.6-luna" ) ;
278+ } finally {
279+ clearRequestLogsForTests ( ) ;
280+ if ( previousHome === undefined ) delete process . env . OPENCODEX_HOME ;
281+ else process . env . OPENCODEX_HOME = previousHome ;
282+ resetUsageReadCacheForTests ( ) ;
283+ rmSync ( home , { recursive : true , force : true } ) ;
284+ }
285+ } ) ;
286+
261287 test ( "records ordered attempts with sealed identity, fresh estimates, and deduplicated recoveries" , ( ) => {
262288 const a = beginRequestAttempt ( 1 , "provisional-a" , "model-a" , "openai-chat" ) ;
263289 noteAttemptSend ( a , 100 ) ;
@@ -1312,6 +1338,7 @@ describe("request log restart hydrate", () => {
13121338 provider : "chatgpt-pabcdef" ,
13131339 model : "gpt-5.6-sol" ,
13141340 requestedModel : "gpt-5.6-sol" ,
1341+ shadowCallRewrittenFrom : "gpt-5.6-luna" ,
13151342 requestedEffort : "high" ,
13161343 effectiveEffort : "high" ,
13171344 reasoningWireField : "reasoning_effort" ,
@@ -1334,6 +1361,7 @@ describe("request log restart hydrate", () => {
13341361 provider : "chatgpt-pabcdef" ,
13351362 model : "gpt-5.6-sol" ,
13361363 requestedModel : "gpt-5.6-sol" ,
1364+ shadowCallRewrittenFrom : "gpt-5.6-luna" ,
13371365 requestedEffort : "high" ,
13381366 effectiveEffort : "high" ,
13391367 reasoningWireField : "reasoning_effort" ,
@@ -1381,6 +1409,7 @@ describe("request log restart hydrate", () => {
13811409 terminalStatus : "failed" ,
13821410 closeReason : "terminal" ,
13831411 upstreamError : "Provider unreachable" ,
1412+ shadowCallRewrittenFrom : "gpt-5.6-luna" ,
13841413 } ,
13851414 ] ;
13861415
@@ -1392,6 +1421,7 @@ describe("request log restart hydrate", () => {
13921421 errorCode : "upstream_server_error" ,
13931422 upstreamError : "Provider unreachable" ,
13941423 requestedEffort : "xhigh" ,
1424+ shadowCallRewrittenFrom : "gpt-5.6-luna" ,
13951425 } ) ;
13961426
13971427 // Idempotent: a second start in the same process must not duplicate.
0 commit comments