It is just a simple working example. But for reali life, it could be in some class. And flexible it will be with good UI, storage anyway for such task is quite simple. How well will be your UI, for organize that tree, so flexible it will be. Here is an example of complete UI, for creatingand running Decision trees. I think you could try to connect this project with Cache. And I think it is possible to find more web-libraries, which could help you.

start() public {
  do init()

  set result=$$ask(0)
  write !!,"Result: ",result 
}
init() {
  kill ^DECISIONTREE
  set ^DECISIONTREE(0)="Smoker"
  set ^DECISIONTREE(0,"Yes")=1
  set ^DECISIONTREE(0,"No")=2

  #; Smoker -> Yes
  set ^DECISIONTREE(1)="Age"
  set ^DECISIONTREE(1,"<30")=3
  set ^DECISIONTREE(1,">30")=4

  #; Smoker -> No
  set ^DECISIONTREE(2)="Diet"
  set ^DECISIONTREE(2,"Good")=3
  set ^DECISIONTREE(2,"Poor")=4

  #; Smoker -> Yes|Age -> <30
  set ^DECISIONTREE(3)="Less risk"

  #; Smoker -> Yes|Age -> >30
  set ^DECISIONTREE(4)="More risk"

  #; Smoker -> No|Diet -> Good
  set ^DECISIONTREE(5)="Less risk"

  #; Smoker -> No|Diet -> Poor
  set ^DECISIONTREE(6)="More risk"
}
ask(id) {
  set text=(^DECISIONTREE(id))
  quit:$data(^DECISIONTREE(id))=1 text
  
  write !,text
  set answer=""
  for i=1:1 {
    set answer=$order(^DECISIONTREE(id,answer),1,nextId)
    quit:answer=""
    set answer(i)=nextId
    write !,$justify(i,3),") ",answer
  }
  set nextId=$$read(.answer)
  quit:nextId="" "" 
  quit $$ask(nextId)
}
read(&answers) {
  write !
  do {
    write $char(13),"Option? "
    read res#1
    quit:$zconvert(res,"L")="q"
  while (res="")||('$data(answers(res)))
  
  write !
  
  quit $get(answers(res))
}

 

USER>d start^tree()
 
Smoker
  1) No
  2) Yes
Option? 2
 
Age
  1) <30
  2) >30
Option? 1
 
 
Result: Less risk

Maybe if need not just import sources from xml, but some more actions. And anyway one more interesting way to deploy your code, is using Installer Manifest. With this manifest, you can just import your code to any namespace, or before it, create namespace, csp-applications, do some configurations for your application. For further information see documentation.

In our project we use manifest for build project, and for deploy on a new servers.

First problem is with Work Queue Manager, that it does not work in CSP processes. In my project CacheBlocksExplorer, I tried to use it for async scan of database blocks. Here you can find my source, where I use it with WebSocket. Another problem is It does not work as well, if you just have only one core. 

So, you can force set how many jobs use:

Set ^||%ISC.WorkQueueMgr("ForceJobs")=2