This page is no longer maintained — Please continue to the home page at www.scala-lang.org

[ANN] XTrace -- an XML-validation-based trace validator

1 reply
Meredith Gregory
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Dear Scalarazzi,

i've put up a little toy on github, here, that might be of interest. There's nothing new here except the idea of appropriating existing technologies to do old jobs.

Motivation

Message-passing concurrency is actually quite hard. It's very easy to get into race conditions and deadlocks. One approach to this problem is to analyze traces for properties. How to do this in today's ecosystem of tools and technologies?

Approach

It turns out that XML validation is a poor man's model checker. With this idea in mind then a property (or collection of properties) that might be used to probe a trace is a(n XSD) schema and a trace is an XML document. So, what we build is
  • a trace monitor
    • message-passing components log messages with the trace monitor
    • the interface to the trace monitor is functional (really it should be transactional, but that's a longer story)
  • a trace validator
    • the trace validator is given an XSD schema with which to probe a given trace
    • it will return true or false and display an explication of why the trace does not exhibit the property
Caveats

This is a toy. It is not production code. It's just a sketch of an idea that might be fun for someone to play with and make into something more real. The pom.xml currently uses a privately held snapshot of Scala 2.8. However, there should be no reason why this won't compile on Scala 2.75 - 2.77. If you roll back the scala version be sure the remove the delimited continuations dependency in the pom.xml file.

Best wishes,

--greg

Welcome to Scala version 2.8.0.r18915-b20091004170819 (Java HotSpot(TM) Client VM, Java 1.5.0_20).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import com.biosimilarity.validation._
import com.biosimilarity.validation._
import com.biosimilarity.validation._

scala> Cabal.hookup()
Cabal.hookup()
res0: com.biosimilarity.validation. OpenSession = OpenSession(MessengerFour)

scala> Cabal.activate()
Cabal.activate()
res1: scala.actors.Actor = com.biosimilarity.validation.ATraceMonitor$@6f43dc

scala> Cabal.mix()
Cabal.mix()
logging event to console: <conversation id="9d1b0da1-be5f-11de-9a91-001f5bf23e38"><requester conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">Harry</requester><request conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">bean?</request>
calling handle on JustifiedRequest(0,bean?,None,wizard:Hogwarts#Herminone,wizard:Hogwarts#Harry,9d1b0da1-be5f-11de-9a91-001f5bf23e38)
logging event to console: <waiting>Ron 1</waiting>
logging event to console: <conversation id="9d1b0da4-be5f-11de-9a91-001f5bf23e38"><requester conversation="9d1b0da4-be5f-11de-9a91-001f5bf23e38">Harry</requester><request conversation="9d1b0da4-be5f-11de-9a91-001f5bf23e38">expelliarmus</request>
calling handle on JustifiedRequest(0,expelliarmus,None,wizard:Hogwarts#Draco,wizard:Hogwarts#Harry,9d1b0da4-be5f-11de-9a91-001f5bf23e38)
handling: JustifiedRequest(0,expelliarmus,None,wizard:Hogwarts#Draco,wizard:Hogwarts#Harry,9d1b0da4-be5f-11de-9a91-001f5bf23e38)
matched Harry case
logging event to console: <responder conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">Herminone</responder><response conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">bean.</response></conversation>
calling handle on JustifiedResponse(1,bean.,Some(JustifiedRequest(0,bean?,None,wizard:Hogwarts#Herminone,wizard:Hogwarts#Harry,9d1b0da1-be5f-11de-9a91-001f5bf23e38)),wizard:Hogwarts#Harry,wizard:Hogwarts#Herminone,9d1b0da1-be5f-11de-9a91-001f5bf23e38)
logging event to console: <conversation id="9d1b0da0-be5f-11de-9a91-001f5bf23e38"><requester conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">Ron</requester><request conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">chocolateFrog?</request>
calling handle on JustifiedRequest(0,chocolateFrog?,None,wizard:Hogwarts#Herminone,wizard:Hogwarts#Ron,9d1b0da0-be5f-11de-9a91-001f5bf23e38)
logging event to console: <responder conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">Herminone</responder><response conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">chocolateFrog!</response></conversation>
calling handle on JustifiedResponse(1,chocolateFrog!,Some(JustifiedRequest(0,chocolateFrog?,None,wizard:Hogwarts#Herminone,wizard:Hogwarts#Ron,9d1b0da0-be5f-11de-9a91-001f5bf23e38)),wizard:Hogwarts#Ron,wizard:Hogwarts#Herminone,9d1b0da0-be5f-11de-9a91-001f5bf23e38)
logging event to console: <responder conversation="9d1b0da5-be5f-11de-9a91-001f5bf23e38">Draco</responder><response conversation="9d1b0da5-be5f-11de-9a91-001f5bf23e38">finiteIncantatem</response></conversation>

scala> calling handle on JustifiedResponse(0,finiteIncantatem,Some(JustifiedRequest(0,expelliarmus,None,wizard:Hogwarts#Draco,wizard:Hogwarts#Harry,9d1b0da4-be5f-11de-9a91-001f5bf23e38)),wizard:Hogwarts#Harry,wizard:Hogwarts#Draco,9d1b0da5-be5f-11de-9a91-001f5bf23e38)
ATraceMonitor.showLog
ATraceMonitor.showLog
<execution><conversation id="9d1b0da1-be5f-11de-9a91-001f5bf23e38"><requester conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">Harry</requester><request conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">bean?</request><waiting>Ron 1</waiting><conversation id="9d1b0da4-be5f-11de-9a91-001f5bf23e38"><requester conversation="9d1b0da4-be5f-11de-9a91-001f5bf23e38">Harry</requester><request conversation="9d1b0da4-be5f-11de-9a91-001f5bf23e38">expelliarmus</request><responder conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">Herminone</responder><response conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">bean.</response></conversation><conversation id="9d1b0da0-be5f-11de-9a91-001f5bf23e38"><requester conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">Ron</requester><request conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">chocolateFrog?</request><responder conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">Herminone</responder><response conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">chocolateFrog!</response></conversation><responder conversation="9d1b0da5-be5f-11de-9a91-001f5bf23e38">Draco</responder><response conversation="9d1b0da5-be5f-11de-9a91-001f5bf23e38">finiteIncantatem</response></conversation></execution>

scala> ATraceValidator.validate( "/Users/lgm/work/src/projex/biosimilarity/trace/src/main/resources/trace.xsd" )
ATraceValidator.validate( "/Users/lgm/work/src/projex/biosimilarity/trace/src/main/resources/trace.xsd" )
res4: Boolean = true

scala>

--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com
Meredith Gregory
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: [ANN] XTrace -- an XML-validation-based trace validator
Dear Scalarazzi,

Here's a chat with Tony Garnock-Jones, one of the core RabbitMQ team, about how XTrace is intended to be used. You might find it amusing.

Best wishes,

--greg

10:09 AM me: http://github.com/leithaus/XTrace   You might like that one Tony: /me clicks 10:10 AM me: the main idea is to use XML schema validation as a trace validator  Tony: heh :)  so wrt XTrace   "trace" in the sense of trace-tree-of-actions-taken-by-a-process?  me: that's correct 10:13 AM Tony: then the schema would be a kind of type for the process   cool me: that's the idea  Tony: with subsequent actions being tags leading off a node   containing in turn subsequent actions  very interesting  me: that's the idea   the aikido move here is this Tony: ... and of course there's always relaxng :)   ok me: you don't get coverage of all possible traces  Tony: (i'm wondering what kinds of xml documents are naturally viewed as traces) 10:14 AM me: but the use case is you've get a trace that is puzzling you   so you probe it for different properties  until you narrowed down to surprising behavior  Tony: right ok  incrementally refining the type   and checking it as you go10:15 AM me: that's it  Tony: til you get to a type you expect that it doesn't inhabit  me: that's it exactly  Tony: neat  /me . o O ( potential approaches to automatic search of the space for interesting boundary conditions ) 10:16 AM me: yeah  which connects to principal types 10:17 AM hey -- can i put this chat up on the project page as a kind of description of the intended use case?  Tony: sure! me: sweet!

On Wed, Oct 21, 2009 at 10:02 AM, Meredith Gregory <lgreg.meredith@gmail.com> wrote:
Dear Scalarazzi,

i've put up a little toy on github, here, that might be of interest. There's nothing new here except the idea of appropriating existing technologies to do old jobs.

Motivation

Message-passing concurrency is actually quite hard. It's very easy to get into race conditions and deadlocks. One approach to this problem is to analyze traces for properties. How to do this in today's ecosystem of tools and technologies?

Approach

It turns out that XML validation is a poor man's model checker. With this idea in mind then a property (or collection of properties) that might be used to probe a trace is a(n XSD) schema and a trace is an XML document. So, what we build is
  • a trace monitor
    • message-passing components log messages with the trace monitor
    • the interface to the trace monitor is functional (really it should be transactional, but that's a longer story)
  • a trace validator
    • the trace validator is given an XSD schema with which to probe a given trace
    • it will return true or false and display an explication of why the trace does not exhibit the property
Caveats

This is a toy. It is not production code. It's just a sketch of an idea that might be fun for someone to play with and make into something more real. The pom.xml currently uses a privately held snapshot of Scala 2.8. However, there should be no reason why this won't compile on Scala 2.75 - 2.77. If you roll back the scala version be sure the remove the delimited continuations dependency in the pom.xml file.

Best wishes,

--greg

Welcome to Scala version 2.8.0.r18915-b20091004170819 (Java HotSpot(TM) Client VM, Java 1.5.0_20).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import com.biosimilarity.validation._
import com.biosimilarity.validation._
import com.biosimilarity.validation._

scala> Cabal.hookup()
Cabal.hookup()
res0: com.biosimilarity.validation. OpenSession = OpenSession(MessengerFour)

scala> Cabal.activate()
Cabal.activate()
res1: scala.actors.Actor = com.biosimilarity.validation.ATraceMonitor$@6f43dc

scala> Cabal.mix()
Cabal.mix()
logging event to console: <conversation id="9d1b0da1-be5f-11de-9a91-001f5bf23e38"><requester conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">Harry</requester><request conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">bean?</request>
calling handle on JustifiedRequest(0,bean?,None,wizard:Hogwarts#Herminone,wizard:Hogwarts#Harry,9d1b0da1-be5f-11de-9a91-001f5bf23e38)
logging event to console: <waiting>Ron 1</waiting>
logging event to console: <conversation id="9d1b0da4-be5f-11de-9a91-001f5bf23e38"><requester conversation="9d1b0da4-be5f-11de-9a91-001f5bf23e38">Harry</requester><request conversation="9d1b0da4-be5f-11de-9a91-001f5bf23e38">expelliarmus</request>
calling handle on JustifiedRequest(0,expelliarmus,None,wizard:Hogwarts#Draco,wizard:Hogwarts#Harry,9d1b0da4-be5f-11de-9a91-001f5bf23e38)
handling: JustifiedRequest(0,expelliarmus,None,wizard:Hogwarts#Draco,wizard:Hogwarts#Harry,9d1b0da4-be5f-11de-9a91-001f5bf23e38)
matched Harry case
logging event to console: <responder conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">Herminone</responder><response conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">bean.</response></conversation>
calling handle on JustifiedResponse(1,bean.,Some(JustifiedRequest(0,bean?,None,wizard:Hogwarts#Herminone,wizard:Hogwarts#Harry,9d1b0da1-be5f-11de-9a91-001f5bf23e38)),wizard:Hogwarts#Harry,wizard:Hogwarts#Herminone,9d1b0da1-be5f-11de-9a91-001f5bf23e38)
logging event to console: <conversation id="9d1b0da0-be5f-11de-9a91-001f5bf23e38"><requester conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">Ron</requester><request conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">chocolateFrog?</request>
calling handle on JustifiedRequest(0,chocolateFrog?,None,wizard:Hogwarts#Herminone,wizard:Hogwarts#Ron,9d1b0da0-be5f-11de-9a91-001f5bf23e38)
logging event to console: <responder conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">Herminone</responder><response conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">chocolateFrog!</response></conversation>
calling handle on JustifiedResponse(1,chocolateFrog!,Some(JustifiedRequest(0,chocolateFrog?,None,wizard:Hogwarts#Herminone,wizard:Hogwarts#Ron,9d1b0da0-be5f-11de-9a91-001f5bf23e38)),wizard:Hogwarts#Ron,wizard:Hogwarts#Herminone,9d1b0da0-be5f-11de-9a91-001f5bf23e38)
logging event to console: <responder conversation="9d1b0da5-be5f-11de-9a91-001f5bf23e38">Draco</responder><response conversation="9d1b0da5-be5f-11de-9a91-001f5bf23e38">finiteIncantatem</response></conversation>

scala> calling handle on JustifiedResponse(0,finiteIncantatem,Some(JustifiedRequest(0,expelliarmus,None,wizard:Hogwarts#Draco,wizard:Hogwarts#Harry,9d1b0da4-be5f-11de-9a91-001f5bf23e38)),wizard:Hogwarts#Harry,wizard:Hogwarts#Draco,9d1b0da5-be5f-11de-9a91-001f5bf23e38)
ATraceMonitor.showLog
ATraceMonitor.showLog
<execution><conversation id="9d1b0da1-be5f-11de-9a91-001f5bf23e38"><requester conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">Harry</requester><request conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">bean?</request><waiting>Ron 1</waiting><conversation id="9d1b0da4-be5f-11de-9a91-001f5bf23e38"><requester conversation="9d1b0da4-be5f-11de-9a91-001f5bf23e38">Harry</requester><request conversation="9d1b0da4-be5f-11de-9a91-001f5bf23e38">expelliarmus</request><responder conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">Herminone</responder><response conversation="9d1b0da1-be5f-11de-9a91-001f5bf23e38">bean.</response></conversation><conversation id="9d1b0da0-be5f-11de-9a91-001f5bf23e38"><requester conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">Ron</requester><request conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">chocolateFrog?</request><responder conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">Herminone</responder><response conversation="9d1b0da0-be5f-11de-9a91-001f5bf23e38">chocolateFrog!</response></conversation><responder conversation="9d1b0da5-be5f-11de-9a91-001f5bf23e38">Draco</responder><response conversation="9d1b0da5-be5f-11de-9a91-001f5bf23e38">finiteIncantatem</response></conversation></execution>

scala> ATraceValidator.validate( "/Users/lgm/work/src/projex/biosimilarity/trace/src/main/resources/trace.xsd" )
ATraceValidator.validate( "/Users/lgm/work/src/projex/biosimilarity/trace/src/main/resources/trace.xsd" )
res4: Boolean = true

scala>

--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland