Introduction
Program synthesis—the automated generation of executable code from high-level specifications—has long been considered a "holy grail" of computer science. However, the barrier to entry remains high: users often find it more difficult to provide a formal specification than to write the code themselves. This paper introduces Syren, a synthesis technique designed to bridge this gap by utilizing a specification format that users already possess: execution traces (logs).
Syren focuses on automating complex administrative tasks, such as cloud infrastructure management and filesystem operations, by observing the API calls made during manual execution. By transforming these "partial traces" into generalized, robust scripts, Syren automates the automators.
The Challenge: The "Hidden Logic" of Partial Traces
Existing Programming-By-Demonstration (PBD) tools often struggle with real-world automation because logs are inherently incomplete. While a cloud provider’s log might show a sequence of API calls (e.g., StopInstance, DeleteVolume), it obscures the internal logic that connects them.
For example, an administrator might take an ID from the output of the first call, manipulate that string to create a policy name, and then pass that new string into a second call. This "pure" logic—data transformations, JSON manipulation, and control flow—is invisible in the trace. Syren’s primary contribution is its ability to infer these hidden functions and control structures to produce programs that are correct by construction.
Methodology: The Syren Workflow
Syren avoids the computational pitfalls of monolithic SMT solving by employing an iterative, rewrite-based approach. The synthesis process follows four key stages:
1. The Trivial Solution
Syren begins by generating a "correct but useless" program. This initial script simply branches on an input variable to replay the provided traces exactly. While this satisfies the requirement of reproducing the input, it lacks any generalization.
2. Iterative Rewriting
The core of the system is a library of rewrite rules. These rules are categorized into refinements, which simplify the program structure (e.g., hoisting common function calls out of conditional branches), and synthesis rules, which introduce generalized logic.
3. Filling Gaps with SyGuS
When a rewrite rule identifies a missing data transformation—a "hidden function"—Syren treats this sub-problem as a Syntax-Guided Synthesis (SyGuS) task. Using the Rosette solver, Syren attempts to synthesize the specific logic (such as a JSONPath query) required to link two API calls. This modular approach allows Syren to solve complex data-flow problems that would be intractable for a single solver.
4. Cost-Directed Search
To ensure the final program is the most general and concise version possible, Syren uses a cost function based on Occam’s Razor. It explores the space of possible rewrites, favoring shorter programs that maintain "trace subsumption"—the guarantee that the synthesized program can still reproduce all original input traces.
Evaluation and Results
The authors evaluated Syren against a suite of 54 benchmarks spanning cloud infrastructure (AWS Runbooks), security automation (Blink), shell scripts, and SVG manipulation. Each benchmark was provided with a small set of traces (median of 4).
Key Performance Metrics
- Success Rate: Syren successfully synthesized optimal scripts for 39 out of 54 (72%) benchmarks.
- Efficiency: The majority of scripts were generated in under 5 minutes on standard hardware, demonstrating the feasibility of the iterative rewriting approach.
- Comparison with LLMs: When compared against Claude 3.5 Sonnet, Syren proved more reliable. While the LLM was faster, it achieved only a 53% success rate and frequently produced "silently incorrect" code. Syren, by contrast, ensures correctness relative to the input traces by design.
Discussion and Future Work
Syren’s strength lies in its "correctness by construction." Unlike stochastic models, Syren will not hallucinate logic; if it cannot find a provably correct way to link API calls, it will not produce a broken script.
However, limitations remain. Syren currently struggles with complex date/time arithmetic and highly sophisticated nested loops. Future iterations of the tool could benefit from more expressive JSONPath synthesis and the ability to incorporate error-handling logic by observing traces that include failed API calls. By refining the ability to infer logic from partial data, Syren moves us closer to a future where manual tasks are automatically transformed into robust, reusable code.
Summary updated