@@ -279,6 +279,49 @@ async function hotPublishGeneration(params: {
279279 return { pidBefore : before . pid ! , pidAfter : after . pid ! } ;
280280}
281281
282+ async function hotPublishChannelCredential ( params : {
283+ gateway : WireGateway ;
284+ generation : Generation ;
285+ } ) : Promise < { pidBefore : number ; pidAfter : number } > {
286+ const before = ( await params . gateway . call ( "system.info" , { } ) ) as { pid ?: number } ;
287+ const previous = ( await params . gateway . call ( "config.get" , { } ) ) as { hash ?: string } ;
288+ const config = JSON . parse ( await fs . readFile ( params . gateway . configPath , "utf8" ) ) as OpenClawConfig ;
289+ const providerConfig = config . models ?. providers ?. [ PROVIDER_ID ] ;
290+ if ( ! providerConfig ) {
291+ throw new Error ( "worker generation provider was missing before credential reload" ) ;
292+ }
293+ const next : OpenClawConfig = {
294+ ...config ,
295+ models : {
296+ ...config . models ,
297+ providers : {
298+ ...config . models ?. providers ,
299+ [ PROVIDER_ID ] : {
300+ ...providerConfig ,
301+ apiKey : `${ SOURCE_CREDENTIAL_PREFIX } -${ params . generation } ` ,
302+ } ,
303+ } ,
304+ } ,
305+ } ;
306+ await fs . writeFile ( params . gateway . configPath , `${ JSON . stringify ( next , null , 2 ) } \n` , "utf8" ) ;
307+ await waitFor ( `generation ${ params . generation } credential publication` , async ( ) => {
308+ const current = ( await params . gateway . call ( "config.get" , { } ) ) as {
309+ hash ?: string ;
310+ appliedConfigHash ?: string ;
311+ configRevisionHash ?: string ;
312+ } ;
313+ return current . hash !== previous . hash &&
314+ current . appliedConfigHash === current . configRevisionHash
315+ ? current
316+ : undefined ;
317+ } ) ;
318+ const after = ( await params . gateway . call ( "system.info" , { } ) ) as { pid ?: number } ;
319+ if ( ! Number . isSafeInteger ( before . pid ) || after . pid !== before . pid ) {
320+ throw new Error ( `credential hot publish replaced the Gateway: ${ before . pid } -> ${ after . pid } ` ) ;
321+ }
322+ return { pidBefore : before . pid ! , pidAfter : after . pid ! } ;
323+ }
324+
282325async function startTurn ( operator : GatewayClient , reply : string ) : Promise < string > {
283326 const runId = `${ SCENARIO_ID } -${ randomUUID ( ) } ` ;
284327 const started = await operator . request < TurnResult > ( "chat.send" , {
@@ -419,7 +462,12 @@ async function runProof(options: ProducerOptions) {
419462 published = await createPublishedWireWorkspace ( root ) ;
420463 gateway = await startQaGatewayChild ( {
421464 repoRoot : options . repoRoot ,
422- useRepoCli : true ,
465+ command : {
466+ executablePath : process . execPath ,
467+ argsPrefix : [ path . join ( options . repoRoot , "dist" , "index.js" ) ] ,
468+ cwd : options . repoRoot ,
469+ usePackagedPlugins : true ,
470+ } ,
423471 providerBaseUrl : `${ authProxy . baseUrl } /v1` ,
424472 providerMode : "mock-openai" ,
425473 primaryModel : MODEL_REF ,
@@ -436,6 +484,15 @@ async function runProof(options: ProducerOptions) {
436484 barrierPath,
437485 mockProviderBaseUrl : `${ authProxy . baseUrl } /v1` ,
438486 } ) ,
487+ channels : {
488+ ...config . channels ,
489+ "qa-channel" : {
490+ ...config . channels ?. [ "qa-channel" ] ,
491+ accounts : {
492+ parallel : { enabled : true , baseUrl : channelBus . baseUrl , allowFrom : [ "*" ] } ,
493+ } ,
494+ } ,
495+ } ,
439496 session : { ...config . session , dmScope : "per-peer" } ,
440497 } ) ,
441498 } ) ;
@@ -543,8 +600,9 @@ async function runProof(options: ProducerOptions) {
543600 admitted : "CHANNEL-GENERATION-C-ADMITTED-OK" ,
544601 current : "CHANNEL-GENERATION-D-CURRENT-OK" ,
545602 } ;
546- const sendChannelTurn = ( conversationId : string , reply : string ) =>
603+ const sendChannelTurn = ( conversationId : string , reply : string , accountId = "default" ) =>
547604 channelState . addInboundMessage ( {
605+ accountId,
548606 conversation : { id : conversationId , kind : "direct" } ,
549607 senderId : conversationId ,
550608 text : `Reply exactly: ${ reply } ` ,
@@ -571,7 +629,9 @@ async function runProof(options: ProducerOptions) {
571629 event . event === "auth-prepare" && event . generation === "C" && event . waited === true ,
572630 ) ,
573631 ) ;
574- sendChannelTurn ( "generation-admitted" , channelReplies . admitted ) ;
632+ // Each QA account serializes its own inbound stream, so use a second account
633+ // to admit the victim while the first account's turn still holds the main lane.
634+ sendChannelTurn ( "generation-admitted" , channelReplies . admitted , "parallel" ) ;
575635 const activeGateway = gateway ;
576636 const queuedMainLane = await waitFor (
577637 "admitted generation C turn waiting for the global lane" ,
@@ -584,7 +644,9 @@ async function runProof(options: ProducerOptions) {
584644 ) ;
585645 } ,
586646 ) ;
587- const hotPublishD = await hotPublishGeneration ( { gateway, tracePath, generation : "D" } ) ;
647+ // A provider-only config reload replaces prepared owners without stopping
648+ // the active channel accounts, unlike a whole plugin-generation reload.
649+ const hotPublishD = await hotPublishChannelCredential ( { gateway, generation : "D" } ) ;
588650 await fs . writeFile ( barrierPath , "released\n" , "utf8" ) ;
589651 await waitForChannelReply ( "generation-blocker" , channelReplies . blocker ) ;
590652 await waitForChannelReply ( "generation-admitted" , channelReplies . admitted ) ;
@@ -688,7 +750,7 @@ async function runProducer(options: ProducerOptions): Promise<QaEvidenceSummaryJ
688750 { filePath : `${ SCENARIO_ID } -trace.jsonl` , kind : "trace" } ,
689751 ] ,
690752 details :
691- "A baseline worker turn established the placement lifecycle; generation B then retained factory, policy, wrapper, and execution ownership while C hot-published , and the next turn used C " ,
753+ "Worker generations A, B, and C preserved provider ownership across plugin reload; two concurrent channel turns retained C while credential generation D committed , and the next channel turn used D " ,
692754 durationMs : Math . max ( 1 , Date . now ( ) - startedAt ) ,
693755 status : "pass" ,
694756 } ) ;
0 commit comments