Typed JSON translation layer for natural-language static analysis
Static-analysis chat should stop asking the model to write Joern CPGQL directly. The better build is a two-step translator: the model fills a small typed JSON form for query intent, then deterministic code maps that form into the final query and runs validation before execution. The evidence is unusually concrete. In a 20-task benchmark over Apache Commons Lang and OWASP WebGoat, the schema-bound JSON design beat direct query generation for every tested model, with gains of 15.0 points for Qwen 72B and 25.0 points for Llama 70B. It also beat an agentic tool loop that used about 8 times more tokens per task and still produced worse results.
The operational pain is familiar to teams building natural-language access for static analysis: generated queries often execute but answer the wrong question, while free-form agent loops add latency and failure modes without solving DSL correctness. A typed intermediate gives product teams a place to enforce allowed query types, required fields, and schema checks before anything touches the analysis engine.
A cheap validation path is straightforward. Take a backlog of real English analysis requests from security or AppSec users, define a narrow JSON schema for the top query families, and compare result-match rate, execution success, and token cost against direct query generation. If the tool already logs failed or misleading CPGQL generations, those requests are the right starting set.