Skip to content

fix(plugins): keep Gateway responsive during capture and restore failed reloads - #176192

Open
ExoHumann wants to merge 9 commits into
openclaw:mainfrom
ExoHumann:codex/gateway-plugin-capture-recovery
Open

ExoHumann wants to merge 9 commits into
openclaw:mainfrom
ExoHumann:codex/gateway-plugin-capture-recovery

Conversation

@ExoHumann

@ExoHumann ExoHumann commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Related: #172750, #174681, #175761.

What Problem This Solves

Dependency-heavy external plugins could block Gateway HTTP requests during startup and reload. Failed replacement could also leave Windows recovery captures pointing into a retired directory.

User Impact

Gateway health requests remain responsive within the existing 15-second probe deadline in the tested installed workload. Syntax-invalid and registration-failing replacements are rejected while the last working plugin remains callable, and subsequent healthy replacements succeed.

Startup is still slow: 120.539 seconds in this run, with multi-second response delays. This fixes the measured availability regression; it is not a fast-startup or universal latency claim. No configuration changes are required.

Why This Change Was Made

Capture runs in the existing retained preparation worker, with source custody transferred to the plugin instance and module-resolution hooks kept local. Host receipt validation processes 32 ordered events per batch and yields between batches; the synchronous CLI drains the same validation steps synchronously. Windows recovery links relocate into the new capture.

Existing instance/registry ownership, retirement checks, byte hashes, containment checks, native admission, publisher context, and joined shutdown remain intact. Root handles close before yielding. Main's selected-root ownership and receipt scoping (#176280, b81e502) are preserved.

This revision also addresses ClawSweeper's two P2 findings: the recovery test now injects failure at the actual source-preparation owner, and the unused remote-artifact mode/callback protocol is removed. Native-load tracking remains connected to its existing owner. No plugin-specific production directories are hardcoded.

Evidence

CI test-type correction — 91a4d78

CI caught four TS2532 errors in our registration-gate test: a mapped array did not guarantee elements 0 and 1 under the test project's strict indexed-access checking. This was a test typing defect in this PR, missed by the earlier scoped lint/runtime checks. The gates are now constructed as a fixed two-element tuple; all registration, timing, failure, and cleanup assertions remain unchanged. Production code is unchanged.

Reproduced all four errors locally with node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.plugins-platform.json --noEmit (exit 2); the identical command passes after the correction (exit 0). node scripts/run-vitest.mjs run src/plugins/loader.async-preparation.test.ts --maxWorkers=1 passed 5/5 tests, wrapper 109.32 s. Formatting and diff checks passed. No package rebuild or installed-probe rerun for this test-only correction. New-head CI is pending.

Conflict resolution — 4926f18

Integrated main at 00575be. The sole manual resolution is in loader.async-preparation.test.ts: retain per-plugin registration gates and main's injected preparation delay plus both timing assertions (modulePreparationMs >= 1000 and modulePreparationMs <= loadMs). Main's runtime timing implementation is unchanged.

Affected-file validation: 5/5 tests passed (131.35 s through the repository runner), formatting and whitespace checks passed. Direct node node_modules/oxlint/bin/oxlint --type-aware src/plugins/loader.async-preparation.test.ts exited 0. The wrapper's declaration-preparation stage stalled and was stopped; it is not claimed as a passing wrapper run.

Only affected-file checks were rerun as requested; no package rebuild or installed-probe rerun. The full build and installed results below belong specifically to 9168e9f, not this newer integration head. ClawSweeper's completed review of that head found no actionable correctness findings and identified this conflict as its sole merge blocker; its receipt-digest suggestion was explicitly optional.

Verified candidate: 9168e9fa3b61620429b14dc1c01cadc1df9e8ce1, integrating main at de42210. Final validation completed 2026-10-18 23:48 UTC.

  • 81 focused tests across 10 files passed, including cooperative preparation, worker/native admission, receipt tamper rejection, retirement, recovery and installed-package coverage.
  • Formatting, typed lint (0 warnings/errors), core types and diff checks passed.
  • Full build passed in 11m24s. Canonical package preflight, extraction, npm inventory and dist import-graph checks passed.
  • Fresh isolated installation and explicit OpenClaw postinstall passed.
  • Independent local review: scoped-clean through P2, final source verification passed. Reviewer did not execute tests; installed results are separate evidence.

Windows 11 x64, Node 24.21.0; installed package entry point; synthetic retained config/workspace/data; 100 dependency packages with 1,000 actually imported leaves. Codex and dependency-proof loaded. Separate-process HTTP/authenticated WebSocket probes ran every 250 ms, unchanged 15-second deadlines, up to 64 concurrent requests per kind.

Phase Operation HTTP successes / attempts after first success Max HTTP WS successes / attempts Max WS Probe timeouts
Startup 120.539 s 410 / 410 4.768 s 12 / 12 0.031 s 0
Changed-source reload 32.526 s 140 / 140 2.645 s 139 / 139 2.673 s 0
Retained-state restart 87.561 s 287 / 287 3.328 s 12 / 12 0.013 s 0

HTTP p95: startup 2.079 s, reload 1.627 s, restart 1.556 s. Reload WS p95: 1.658 s. Pre-listener connection failures are excluded from post-success HTTP counts. Startup WS authentication becomes available near readiness; HTTP provides startup availability evidence. Readiness polling has its own shorter timeout and is not the 15-second availability metric.

Syntax rejection preserved revision 2 / total 1000, then healthy revision 3 succeeded. Registration rejection preserved revision 3 / total 1000, then healthy revision 4 succeeded. Retained synthetic settings/workspace/data assertions passed, allowing the documented Codex enablement migration. Final wrapper exit 0, ok=true, lifecycleOk=true, responsivenessOk=true, shutdown joined.

Resolution: this exact source tree passes the requested local gates and the installed startup/reload/restart/recovery workload without availability deadline misses. Before cooperative validation, an installed candidate exceeded that deadline; its diagnostic profile attributed 14.638 s to binding/receipt validation, including 11.742 s in native file opening. These sequential observations establish the tested regression outcome, not a controlled statistical speedup. Fresh CI/review and mergeability remain separate gates; no merge clearance or label removal is claimed.

Artifact provenance, commands, and coverage limits

Tested Git tree and committed tree are identical: 14f3f2e9beb14bb4cc08f45d44d65537d569fab9.
Main-to-candidate patch SHA-256: 02C9B63424544790DE9AB259923FF06203B9E7F61A256E49647C6211242C6F42.
Artifact: openclaw-cutover-v5.tgz.
SHA-256: 90023EF13A43A534702F1731027EA8483763C178F31C9E80C02EE5662EAAAC91.
Installed build ID: 2026.10.4-042015f8c38b-2026-10-18T23-12-24.982Z.
The build preceded the commit and embeds parent 042015f; the tested tree identity above binds the artifact to the published source. Committing did not change source or require rebuilding.

Commands (Node 24.21.0 first in PATH; isolated paths represented by placeholders):

# OPENCLAW_LOCAL_CHECK_MODE=full
node scripts/run-format.mts --check <16 changed TypeScript files>
node scripts/run-vitest.mjs run src/plugins/plugin-generation-receipt.test.ts src/plugins/loader.async-preparation.test.ts src/plugins/plugin-generation-worker.test.ts src/plugins/plugin-generation-worker-codec.test.ts src/plugins/plugin-generation-artifact.admission.test.ts src/plugins/loader.instance-cleanup.test.ts src/plugins/plugin-module-loader-recovery.test.ts src/plugins/plugin-generation-source-lookup.test.ts src/gateway/server-plugin-reload-recovery.test.ts src/gateway/server-plugin-reload.installed-package.test.ts --maxWorkers=1
node scripts/run-oxlint.mjs --type-aware <16 changed TypeScript files>
node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
# OPENCLAW_RUN_NODE_SKIP_DTS_BUILD unset
node --import ./scripts/tsx.mjs scripts/build-all.mts
# process-local npm_config_allow_remote=all
node scripts/package-openclaw-for-docker.mjs --skip-build --allow-unreleased-changelog --output-dir <artifacts> --output-name openclaw-cutover-v5.tgz
node <node-root>/node_modules/npm/bin/npm-cli.js install -g --prefix <isolated-prefix> --allow-scripts=openclaw <artifact> --no-fund --no-audit
node <installed-package>/scripts/postinstall-bundled-plugins.mjs
node --import ./scripts/tsx.mjs <repair-cutover-v5-fixture.mjs> <repo>
node --import ./scripts/tsx.mjs <post-merge-probe.mjs> <repo> <fresh-output> 100 <installed-package> <retained-upgrade-result.json> --recovery
git diff --cached --check

The synthetic Codex peer junction initially targeted an older temporary host. The fixture repair invokes the existing linkOpenClawPeerDependencies owner, checks the known synthetic junction/old target, and verifies its new canonical target: repaired 1, skipped 0. Those explicit directories belong only to the external test fixture. Host SDK peer linking and retained worker source custody have different responsibilities. No admission bypass was used.

npm 12.0.2 still reported blocked lifecycle scripts despite the allow-scripts option; the OpenClaw hook was explicitly executed successfully. Other dependency hooks were not validated. The full build emitted a nonfatal UI gzip-size warning (1456.3 KiB against 1455.1 KiB); build exit was 0.

This is one host observation without OS cache flushing. No Linux/Bun, native-service activation, updater-backup rollback, or every-plugin coverage is claimed. The earlier updater attempt installed the package but exceeded its 600-second activation budget after 398 seconds retaining the old runtime; that remains a failed updater result. Fresh-prefix installed Gateway validation and manual synthetic peer repair do not prove stock updater activation/peer repair. No live Gateway, real user state or provider credentials were used.

Installed-package probe source

Save as post-merge-probe.mjs outside the checkout. The retained-result JSON supplies upgrade.configPath, upgrade.stateDir, and upgrade.before.{plugins,workspace,dataSha256} from the synthetic pre-update fixture; the hash covers upgrade-survivor.txt. Use synthetic credentials, loopback settings, the repaired synthetic peer link described above, and a new output directory. This script launches the installed entry point with repository test helpers.

import fs from 'node:fs';
import {createHash} from 'node:crypto';
import path from 'node:path';
import assert from 'node:assert/strict';
import {pathToFileURL} from 'node:url';
import {setTimeout as delay} from 'node:timers/promises';
const [repo,outArg,packagesArg='100',packageRoot,priorResultPath]=process.argv.slice(2);
const prior=JSON.parse(fs.readFileSync(priorResultPath,'utf8'));
const actualConfig=JSON.parse(fs.readFileSync(prior.upgrade.configPath,'utf8'));
const expected=structuredClone(prior.upgrade.before.plugins);
expected.allow.push('codex');expected.entries.codex={enabled:true};
assert.deepEqual(actualConfig.plugins,expected,'only the documented Codex migration may differ');
assert.equal(actualConfig.agents.defaults.workspace,prior.upgrade.before.workspace);
assert.equal(createHash('sha256').update(fs.readFileSync(path.join(prior.upgrade.before.workspace,'upgrade-survivor.txt'))).digest('hex'),prior.upgrade.before.dataSha256);
assert.equal(JSON.parse(fs.readFileSync(path.join(packageRoot,'dist/build-info.json'),'utf8')).commit,'042015f8c38b4685d0f6b21c3018419cd6d0b66f');
const {collectDisabledCodexPluginRouteHits}=await import(pathToFileURL(path.join(repo,'src/commands/doctor/shared/codex-route-config-scan.ts')));
const priorConfig=structuredClone(actualConfig);priorConfig.plugins=prior.upgrade.before.plugins;
const migrationHits=collectDisabledCodexPluginRouteHits(priorConfig,{});
assert.ok(migrationHits.length>0,'source must independently explain required Codex route');
const out=path.resolve(outArg);fs.mkdirSync(out,{recursive:true});
const {createOpenClawTestInstance}=await import(pathToFileURL(path.join(repo,'test/helpers/openclaw-test-instance.ts')));
const {acquireGatewayTestClient}=await import(pathToFileURL(path.join(repo,'test/helpers/gateway-client.ts')));
const count=Number(packagesArg), plugin=actualConfig.plugins.load.paths[0],home=path.dirname(prior.upgrade.stateDir),workspace=prior.upgrade.before.workspace;
for(const p of [plugin,home,workspace])fs.mkdirSync(p,{recursive:true});
const write=(p,v)=>fs.writeFileSync(p,typeof v==='string'?v:JSON.stringify(v,null,2));
write(path.join(plugin,'package.json'),{name:'dependency-proof',version:'1.0.0',type:'commonjs',openclaw:{extensions:['./index.cjs']},dependencies:Object.fromEntries(Array.from({length:count},(_,i)=>['proof-dep-'+i,'1.0.0']))});
write(path.join(plugin,'openclaw.plugin.json'),{id:'dependency-proof',name:'Dependency proof',activation:{onStartup:true},configSchema:{type:'object',additionalProperties:false,properties:{}}});
for(let i=0;i<count;i++){const d=path.join(plugin,'node_modules','proof-dep-'+i);fs.mkdirSync(d,{recursive:true});write(path.join(d,'package.json'),{name:'proof-dep-'+i,version:'1.0.0',main:'index.cjs'});write(path.join(d,'index.cjs'),'module.exports='+Array.from({length:10},(_,j)=>`require('./part-${j}.cjs')`).join('+')+';');for(let j=0;j<10;j++)write(path.join(d,`part-${j}.cjs`),'module.exports=1;\n//'+ 'x'.repeat(4096)+'\n');}
function entry(revision){write(path.join(plugin,'index.cjs'),`const total=${Array.from({length:count},(_,i)=>`require('proof-dep-${i}')`).join('+')||'0'};module.exports={id:'dependency-proof',register(api){api.registerGatewayMethod('proof.echo',r=>r.respond(true,{revision:${revision},total,capture:__filename}),{scope:'operator.read'});}};`);}
const recoveryOnly=process.argv.includes('--recovery-only');
entry(recoveryOnly?2:1);
const env={};for(const key of Object.keys(process.env))if(/^(OPENCLAW_|CODEX_|ANTHROPIC_|OPENAI_|GOOGLE_|GCP_|AWS_|AZURE_|VERTEX_|WHATSAPP_|XAI_|GROQ_|MISTRAL_|DEEPSEEK_|HF_|OLLAMA_|PI_)/i.test(key)||/(API_KEY|ACCESS_TOKEN|AUTH_TOKEN|SECRET|CREDENTIAL)/i.test(key))env[key]=undefined;
Object.assign(env,{HOME:home,USERPROFILE:home,APPDATA:path.join(home,'roaming'),LOCALAPPDATA:path.join(home,'local'),CODEX_HOME:path.join(home,'.codex'),XDG_CONFIG_HOME:path.join(home,'.config'),XDG_CACHE_HOME:path.join(home,'.cache'),OPENCLAW_STATE_DIR:prior.upgrade.stateDir,OPENCLAW_CONFIG_PATH:prior.upgrade.configPath,OPENCLAW_PROFILE:'upgrade-proof-075f3b0d',OPENCLAW_DEBUG:'1',OPENCLAW_SKIP_CHANNELS:'0',OPENCLAW_SKIP_PROVIDERS:'0',OPENCLAW_TEST_MINIMAL_GATEWAY:'0',VITEST:undefined,NODE_OPTIONS:undefined});
const instance=await createOpenClawTestInstance({name:'upgrade-continuation',reserveIdlePort:false,cwd:packageRoot,entrypoint:[path.join(packageRoot,'openclaw.mjs')],port:actualConfig.gateway.port,gatewayToken:actualConfig.gateway.auth.token,startTimeoutMs:600000,stopTimeoutMs:30000,gracefulShutdownTimeoutMs:20000,env,config:actualConfig});
const result={repo,node:process.version,pid:process.pid,startedAt:new Date().toISOString(),fixture:{packages:count,importedLeafModules:count*10,leafBytes:count*10*4116},port:instance.port,state:instance.stateDir,methodology:{cadenceMs:250,deadlineMs:15000,maxConcurrentPerKind:64,startupBudgetMs:600000,cache:'fresh application state; no OS cache flush',probes:'driver process separate from Gateway; fixed cadence HTTP and authenticated WS'},phases:[]};
result.upgradePreservation={passed:true,priorResultPath,retainedStateDir:prior.upgrade.stateDir,documentedAddition:{codex:{enabled:true}},migrationHits,dataSha256:prior.upgrade.before.dataSha256};
let client,connecting,phaseName='setup';
for(const stream of ['stdout','stderr']){instance[stream].push=function(...chunks){for(const chunk of chunks)fs.appendFileSync(path.join(out,`${phaseName}-${stream}.log`),String(chunk));return Array.prototype.push.apply(this,chunks);};}
const save=()=>write(path.join(out,'result.json'),result);
const connect=()=>acquireGatewayTestClient({url:instance.url,token:instance.gatewayToken,clientName:'gateway-client',clientVersion:'1.0.0',platform:'test',mode:'backend',deviceIdentity:null,scopes:['operator.admin'],hostDeps:{loadDeviceAuthToken:()=>null,storeDeviceAuthToken:()=>{},clearDeviceAuthToken:()=>{}}},{timeoutMs:20000,timeoutMessage:'connect timeout',closeMessage:'connect closed'});
function ensure(){return client?Promise.resolve(client):(connecting??=(connect().then(c=>client=c).finally(()=>connecting=undefined)));}
function summarize(rows){const successes=rows.filter(r=>r.ok).map(r=>r.ms).sort((a,b)=>a-b);return {attempts:rows.length,successes:successes.length,failures:rows.filter(r=>!r.ok).length,timeouts:rows.filter(r=>/timeout|abort/i.test(r.error??'')).length,maxSuccessfulMs:successes.at(-1)??null,p95SuccessfulMs:successes[Math.floor(successes.length*.95)]??null};}
async function phase(name,action){phaseName=name;const t=performance.now(),rows=[],pending=new Set(),inflight={http:0,ws:0};let done=false;const p={name,startedAt:new Date().toISOString()};result.phases.push(p);save();
 const sample=(kind)=>{if(inflight[kind]>=64)return;inflight[kind]++;const at=performance.now();const row={kind,scheduledMs:at-t};const task=(async()=>{try{if(kind==='http'){const r=await fetch(`http://127.0.0.1:${instance.port}/healthz`,{signal:AbortSignal.timeout(15000)});await r.text();assert.equal(r.status,200);if(!client&&!connecting)void ensure().catch(()=>{});}else await client.request('health',{}, {timeoutMs:15000});row.ok=true;}catch(e){row.ok=false;row.error=String(e);}finally{row.ms=performance.now()-at;rows.push(row);fs.appendFileSync(path.join(out,name+'-probes.jsonl'),JSON.stringify(row)+'\n');inflight[kind]--;}})();pending.add(task);void task.finally(()=>pending.delete(task));};
 const timer=setInterval(()=>{if(!done){sample('http');if(client)sample('ws');}},250);sample('http');
 try{p.receipt=await action();p.operationMs=performance.now()-t;await delay(3000);p.ok=true;}catch(e){p.ok=false;p.error=String(e);throw e;}finally{done=true;clearInterval(timer);await Promise.all(pending);p.totalMs=performance.now()-t;p.http=summarize(rows.filter(r=>r.kind==='http'));p.ws=summarize(rows.filter(r=>r.kind==='ws'));const first=rows.filter(r=>r.kind==='http'&&r.ok).sort((a,b)=>a.scheduledMs-b.scheduledMs)[0]?.scheduledMs;p.firstHttpSuccessMs=first??null;p.httpAfterFirstSuccess=summarize(rows.filter(r=>r.kind==='http'&&r.scheduledMs>=(first??Infinity)));p.readiness=structuredClone(instance.readiness);save();console.log(JSON.stringify(p));}}
async function echo(revision){const value=await client.request('proof.echo',{}, {timeoutMs:30000});assert.equal(value.revision,revision);assert.equal(value.total,count*10);return value;}
async function stop(){await connecting?.catch(()=>{});await client?.stopAndWait({timeoutMs:1000});client=undefined;await instance.stopGateway();}
try{await phase('startup',async()=>{await instance.startGateway();await ensure();return {pid:instance.child?.pid,echo:await echo(recoveryOnly?2:1)};});if(!recoveryOnly){await delay(5000);entry(2);await phase('reload',async()=>{const receipt=await client.request('plugins.reload',{plugins:[{pluginId:'dependency-proof'}]},{timeoutMs:600000});return {receipt,echo:await echo(2)};});await stop();await phase('restart-retained-state',async()=>{await instance.startGateway();await ensure();return {pid:instance.child?.pid,echo:await echo(2)};});}result.lifecycleOk=true;
 if(process.argv.includes('--recovery')){await delay(5000);result.recovery=[];for(const [kind,revision] of [['syntax',2],['registration',3]]){write(path.join(plugin,'index.cjs'),kind==='syntax'?'module.exports = !!!':"module.exports={id:'dependency-proof',register(){throw new Error('synthetic registration refusal')}};");let rejection;try{await client.request('plugins.reload',{plugins:[{pluginId:'dependency-proof'}]},{timeoutMs:600000});}catch(e){rejection=String(e);}const attempt={kind,rejection};result.recovery.push(attempt);save();assert.ok(rejection,kind+' replacement must be rejected');const recovered=await echo(revision);entry(revision+1);const receipt=await client.request('plugins.reload',{plugins:[{pluginId:'dependency-proof'}]},{timeoutMs:600000});const replacement=await echo(revision+1);Object.assign(attempt,{recovered,replacement,receipt});save();}}
 result.responsivenessOk=result.phases.every(p=>p.httpAfterFirstSuccess.timeouts===0&&p.ws.timeouts===0);assert.equal(result.responsivenessOk,true,'Gateway health probes exceeded the inherited 15-second deadline during dependency loading');result.ok=true;}catch(e){result.ok=false;result.error=String(e);process.exitCode=1;}finally{try{await stop();result.shutdown='joined';}catch(e){result.shutdownError=String(e);process.exitCode=1;}result.finishedAt=new Date().toISOString();write(path.join(out,'gateway.log'),instance.logs());save();console.log(JSON.stringify({ok:result.ok,error:result.error,shutdown:result.shutdown}));}

Additional installed-package validation: ACPX passes; larger stress workload completes

The installed Windows package passes our isolated ACPX lifecycle workload. The additional owner-index correction also allows the larger 1,000-package / 10,000-module workload to complete startup and changed-source reload without exceeding the existing 15-second HTTP/WebSocket probe deadline.

Previously, that larger workload stopped before readiness after repeated HTTP deadline misses. The candidate now completes both operations, verifies all 10,000 imported values and the replacement revision, and joins shutdown successfully.

ACPX lifecycle — CI artifact 1cddad979

Config validation passed. Independent probes recorded zero HTTP failures, zero authenticated WebSocket failures and zero timeouts.

Phase Duration HTTP successes / attempts Max HTTP WS successes / attempts Max WS
Startup 125.574 s 473 / 473 5.015 s 13 / 13 0.123 s
Sentinel reload 2.469 s 21 / 21 0.233 s 20 / 20 0.229 s
ACPX reload 126.034 s 496 / 496 5.567 s 495 / 495 5.583 s
Retained-state restart 121.471 s 456 / 456 5.163 s 13 / 13 0.078 s

HTTP p95: startup 0.834 s, sentinel reload 0.226 s, ACPX reload 2.452 s, restart 1.150 s. ACPX reload WS p95: 2.524 s.

This uses real ACPX in isolated synthetic state; the reporter's own configuration remains separately unverified.

Larger dependency stress — owner-index correction 5455a2309

Phase Duration HTTP successes / attempts Max HTTP WS successes / attempts Max WS 15-second timeouts
Startup 74.895 s 262 / 263 6.372 s 11 / 11 0.036 s 0
Changed-source reload 67.845 s 271 / 273 7.544 s 272 / 272 8.081 s 0

HTTP p95: startup 3.669 s, reload 4.946 s. Reload WS p95: 5.224 s.

Remaining limitation: three HTTP connection resets (ECONNRESET) mean the strict zero-failure responsiveness assertion failed. A diagnostic replay also reproduced reload failures. Their baseline attribution remains unverified. Profiling identifies remaining synchronous dependency reconstruction before cooperative receipt validation; it does not independently establish the reset mechanism.

The tests retained 250 ms probe cadence, 15-second deadlines, separate Gateway/probe processes and isolated state. Pre-listener refusals are excluded from post-success HTTP counts.

Head 3a79375b5f79519b15274c0f998eaa9fce7eb496 corrects the helper's type-import cycle and tooling inventory entry. Emitted runtime JavaScript is unchanged. Focused lookup tests, tooling tests, affected types, typed lint and the import-cycle guard pass locally. CI run 39310916846 and build-artifact run 39310916858 completed successfully for this head.

Result: the ACPX workload passes, and the larger workload's observed deadline failures are eliminated in these runs. Complete HTTP reliability under the larger stress workload remains unresolved. Earlier evidence remains applicable to its explicitly recorded revisions.

Main integration and passing CI — a36e7e15605b8007369056d3b9cc64d85363139f

Integrated main at 097a2f70d0c4ea0751346d5b50dd7d677744fa74. The conflict resolution retains cooperative capture and Windows recovery-link relocation while adopting main's typed inventory-retirement errors, canonical path containment, restrictive recovery-directory permissions, and callback-release regression coverage.

Exact-head CI passed: 81 successful checks, 53 skipped, and 1 neutral; no failed or pending check runs at verification. The openclaw/ci-gate, dependency-review, and security-sensitive-review statuses all pass. CI gate results · Revision checks.

Local validation on Windows with Node 24.21.0:

  • 27/27 tests passed across plugin-generation-source-lookup.test.ts, loader.async-preparation.test.ts, and plugin-generation-worker.test.ts, using node scripts/run-vitest.mjs src/plugins/plugin-generation-source-lookup.test.ts src/plugins/loader.async-preparation.test.ts src/plugins/plugin-generation-worker.test.ts --maxWorkers=1.
  • Plugin-platform types passed: node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.plugins-platform.json --pretty false.
  • Repository lint and formatting passed for the four edited plugin files.
  • Independent local review reported no actionable P0/P1 findings in the supplied patch; unchanged implementation context was limited.

The latest completed ClawSweeper review reports no findings, sufficient proof, and readiness for maintainer review. It reviewed 3a79375b5, not this integration head. Its receipt-digest self-comparison suggestion remains an optional test-quality improvement.

No new installed-package startup/reload measurements are claimed for this integration. All earlier package, lifecycle, stress metrics, and limitations above remain attributed to their original tested revisions.

@clawsweeper

clawsweeper Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@ExoHumann
ExoHumann marked this pull request as ready for review October 18, 2026 11:17

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR keeps module-resolution hooks local, batches capture validation cooperatively, and repairs Windows recovery links.

Example: A Windows Gateway loads an external plugin with 100 dependency packages and 1,000 imported leaves.

  • Before: Plugin loading can exceed the 15-second health-probe deadline, and a failed replacement can leave recovery links pointing into retired captures.
  • After: The supplied installed-package run completed startup, reload, restart, and failed-replacement recovery without a 15-second probe timeout.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful and supported by installed-entry-point evidence, with no discrete correctness finding; the redundant receipt oracle keeps test quality below A.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Installed Windows Gateway evidence exercises external-plugin startup, reload, retained-state restart, syntax and registration rejection, subsequent healthy replacement, and joined shutdown through the shipped entry point; results remain attributed to their tested revisions, with current-head integration supported by targeted checks and green CI. Larger-workload HTTP resets and the earlier updater activation timeout remain explicitly disclosed and are not represented as passing results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Large external plugins can make Gateway requests time out, and failed replacements can break access to the last working plugin.
Reason: The patch restores the existing responsiveness and recovery intent without introducing configuration, public SDK contracts, or shared module identity.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

This PR provides a useful repair for the plugin-loading regression still present on main; no actionable correctness or security findings remain.

Priority: P1
Reviewed head: a36e7e15605b8007369056d3b9cc64d85363139f

Before merge

None.

Findings

None.

Tests

  • Low-value test src/plugins/plugin-generation-receipt.test.ts: The digest comparison at lines 35–45 derives its expected value through finish(), which now drains finishSteps(); replace that assertion with an independent oracle or remove the redundant case, as previously suggested.
  • Missing end-to-end proof: A red-on-base run of the new cooperative-binding and recovery-link regressions is not documented.
Agent review details

How this fits together

Gateway startup and reload send external plugin sources through preparation workers, then bind captured modules to plugin instances; recovery snapshots preserve working code when replacement fails.

flowchart TD
A[Gateway startup or reload] --> B[Preparation worker]
B --> C[Retained source custody]
C --> D[Local module binding]
D --> E[Plugin registration]
D --> F[Recovery snapshot]
F --> D
A --> G[HTTP and WebSocket service]
Loading

Technical review

Best possible solution:

Retain worker-owned capture custody while existing plugin instances own local module hooks, cooperative validation, and independent recovery snapshots.

Do we have a high-confidence way to reproduce the issue?

Current main exposes synchronous worker proxies to module loading, matching the mechanism documented in #174681; this read-only review did not execute target code.

Is this the best way to solve the issue?

The patch addresses the blocking RPC boundary through existing capture and instance owners, removes the replaced callback protocol, and preserves synchronous CLI and recovery contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d6e3a30c0bfc.

Provenance checked

  • Preparation-worker artifact and module-resolution callbacks changes intended behavior with a stated reason (a99f797: Move external source capture off the Gateway thread while preserving per-instance ownership, recovery, and synchronous CLI behavior.)
  • Receipt validation and guarded file opening keeps the original intent (9faa93d: Reuse admitted native artifacts while independently checking copied metadata and source bytes; subsequent guarded-open batching reduced repeated filesystem work.)
  • Windows recovery dependency links keeps the original intent (4d7db24: Keep dependency links usable across Doctor custody phases after predecessor captures are disposed.)
  • Host-owned native custody and publication keeps the original intent (99f5d0f: Keep native leases and deferred publication with the host admission owner rather than retaining whole workers for native-only custody.)
  • Captured-package lookup keeps the original intent (c7436e7: Reject unrelated imports cheaply while retaining package/link precedence, containment, deferred materialization, and disposal behavior.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced change and current-main behavior: The pinned introduced diff replaces worker-backed module hooks with retained source custody and local binding; fetched main still returns the remote artifact and retains synchronous worker waits during module loading. (src/plugins/plugin-generation-worker.ts:65, a36e7e15605b)
  • Cooperative binding and retirement: Binding yields between receipt batches and checks registry/cache retirement before continuing; synchronous CLI loading drains the same generator without asynchronous waits. (src/plugins/plugin-instance-module-loader.ts:180, a36e7e15605b)
  • Recovery ownership: Internal dependency links are relocated into the recovery directory while canonical containment and native-reference validation remain; the regression reads the dependency after disposing both predecessor captures. (src/plugins/plugin-generation-source-lookup.ts:272, a36e7e15605b)
  • Installed behavior evidence: The complete PR body supplies Windows Node 24.21.0 installed-entry-point output, artifact identity, probe source, retained-state checks, consecutive syntax/registration recovery, and joined shutdown for recorded revisions. Later ACPX results pass; the larger stress run records three unattributed HTTP resets rather than claiming complete reliability. (9168e9fa3b61)
  • Exact-head gates: Paginated check-run inspection found completed checks without failures or pending runs; openclaw/ci-gate, dependency-review, and security-sensitive-review statuses pass for the reviewed head. GitHub reports mergeability as unknown. (a36e7e15605b)
  • Owned regression and related work: Regression: #172750 plugin preparation blocks the Gateway main thread for minutes (sync worker proxy) #174681 documents the synchronous proxy regression and requests a redesign or revert. fix(plugins): release preparation workers after plugin startup #177141 targets worker retirement and is explicitly held for failed performance acceptance, so it does not supersede this repair.

Likely related people:

  • Krzysztof Kisiel: Raw commit a99f797 adds src/plugins/plugin-generation-preparation.worker.ts:67 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a99f797f39ce; files: src/plugins/plugin-generation-preparation.worker.ts)
  • Vincent Koc: Raw commit 99f5d0f adds src/plugins/plugin-generation-preparation.worker.ts:103 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 99f5d0f8e4e0; files: src/plugins/plugin-generation-preparation.worker.ts)
  • Peter Steinberger: Raw commit 29f7652 adds src/plugins/plugin-generation-worker.ts:37 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 29f765226d7b; files: src/plugins/plugin-generation-worker.ts)
  • Patrick Erichsen: Raw commit 967a868 adds src/plugins/plugin-module-loader-recovery.ts:103 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 967a8681d0d5; files: src/plugins/plugin-module-loader-recovery.ts)

PR surface

Source +159, Tests +490, Other +1. Total +650 across 20 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 13 320 161 +159
Tests 6 893 403 +490
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 20 1214 564 +650

Review metrics

Metric Value Why it matters
Production versus test change Production +159 lines (+320/-161); tests +490 (+893/-403). Production growth supports local reconstruction, cooperative validation, and ownership indexing; most test churn migrates existing worker/native lifetime coverage to the new custody boundary.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The repair addresses an owned Gateway availability regression that can stall health requests and plugin startup or reload.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Replace the receipt digest self-comparison with an independent expected digest, or remove that redundant case.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (8 earlier review cycles)
  • reviewed 2026-10-18T11:32:38.118Z sha 075f3b0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-18T14:34:22.663Z sha 075f3b0 :: blocked before merge. :: none
  • reviewed 2026-10-18T22:27:11.928Z sha 042015f :: needs changes before merge. :: [P2] Reconnect the missing-capture recovery test to the new preparation owner | [P2] Remove the replaced remote-artifact preparation mode
  • reviewed 2026-10-18T23:58:16.854Z sha 9168e9f :: needs changes before merge. :: none
  • reviewed 2026-10-19T00:10:41.734Z sha 4926f18 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-19T00:32:07.483Z sha 91a4d78 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-19T00:42:07.318Z sha 91a4d78 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-19T19:53:34.103Z sha 3a79375 :: needs maintainer review before merge. :: none

Reviewed October 20, 2026, 8:01 PM ET / October 21, 2026, 00:01 UTC (Revision 9).

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now includes verified full-build/package evidence, the published v2026.10.4 updater result, preservation checks, and post-upgrade reload/recovery results. It also explicitly records the remaining startup/restart deadline misses and coverage limits. Please reassess against this updated evidence; the code head remains 075f3b0.

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 18, 2026
@ExoHumann ExoHumann changed the title fix(plugins): reduce dependency-heavy Gateway stalls and restore failed reloads fix(plugins): keep Gateway responsive during capture and restore failed reloads Oct 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please reassess the availability risk on head 042015f. The updated PR body includes the installed-package harness, artifact provenance, recovery results, and limitations.

The fix moves capture custody into the retained worker and cooperatively batches host receipt admission while preserving the existing digest, path, native-admission, ownership, retirement, and cleanup checks. Regression coverage now exercises actual binding, event-loop progress, tampering between batches, and retirement before publication.

The corrected isolated installed-package run passed startup, reload, and retained-state restart with zero 15-second HTTP/WebSocket deadline misses. HTTP success counts were 298/298, 139/139, and 290/290; maximum HTTP latency was 3.407 seconds. Syntax and registration failure recovery passed, and shutdown joined. Startup still took roughly 80 seconds; this is not a claim of stall-free or fast startup.

The fixture's Codex peer junction was repaired through the existing peer-link owner to reference the newly installed host; security checks were not bypassed. The earlier failed runs and separate updater activation timeout remain explicitly documented and are not reclassified as passing. Packaging passed; independent local P0/P1 review found no actionable findings. Please evaluate whether the current evidence resolves the previous availability concern. Do not merge.

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 18, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review 9168e9f against the refreshed four-section PR evidence. Both prior P2 findings are addressed: recovery injection targets preparePluginGenerationSource; the unused remote-artifact mode is removed while native-load tracking and custody ownership remain intact. Main's selected-root/native-admission scoping is preserved.

The exact committed tree passed 81 tests, formatting, typed lint, core types, full build, canonical packaging, fresh isolated installation, and independent local review through P2. Installed startup/reload/restart HTTP counts: 410/410, 140/140, 287/287; WS: 12/12, 139/139, 12/12; zero 15-second probe deadline misses. Both failed-replacement recovery cases and joined shutdown passed. Startup still took 120.539 seconds; the separate earlier updater activation timeout remains a documented coverage gap.

Please reassess the availability advisory using these verified results. Newer main has since changed loader.async-preparation.test.ts and GitHub reports a conflict; this is not represented as merge-ready. The tested integration base is de42210. Do not merge.

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated evidence is appended without removing the earlier revision-specific results. Head 3a79375 has passing CI and build-artifact workflows. The isolated ACPX lifecycle passed; the 10,000-module stress workload completed startup and reload with zero 15-second deadline misses, with the remaining HTTP resets and strict-probe failure explicitly recorded. The helper dependency cycle and wrapper inventory omissions are corrected.

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Preserve cooperative capture and Windows recovery links while adopting main's typed inventory retirement errors, canonical containment, and callback-release checks. Validation: 27 targeted tests, plugin-platform types, and focused lint passed on Node 24.21.0.

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review current head a36e7e15605b8007369056d3b9cc64d85363139f, integrating main 097a2f70d0c4ea0751346d5b50dd7d677744fa74.

Exact-head CI passed: 81 successful checks, 53 skipped, 1 neutral; CI, dependency-review, and security-sensitive-review gates are green. Local Windows validation on Node 24.21.0 passed all 27 targeted source-lookup, asynchronous-preparation, and worker tests, plus plugin-platform types, focused lint, and formatting.

The conflict resolution preserves cooperative capture and Windows recovery links while incorporating main’s typed retirement errors, canonical containment, restrictive recovery-directory permissions, and callback-release tests. Please assess the integration against those ownership, security, and recovery contracts.

The new results are appended to the PR body. All previous revision-specific evidence and limitations remain intact; the earlier installed startup/reload and stress measurements are not presented as new measurements for this head.

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant