Semantic Execution Graph
What the SEG is, the four properties every graph has, and how Atracode turns source code into one.
Every program Atracode compiles becomes a Semantic Execution Graph, or SEG. The SEG is a typed dataflow graph of what the program computes. It has no hidden state, no side effects it doesn’t declare, and limits that are known before it runs.
The SEG is the center of everything else. The RAVEN hash is a hash of the SEG. Verification checks the SEG against the native toolchain. The runtime executes the SEG directly.
Properties
Pure dataflow
Every value has exactly one producer and explicit consumers. There are no variables that change behind the graph’s back, so you can trace any node to everything that fed it. A loop in the source becomes a node whose inputs and outputs are explicit, with the state it carries between iterations visible as edges.
Memory as one value
All memory is modeled as a single value threaded through the graph, called the membrane. Every read and write is an explicit edge, which makes aliasing and out-of-bounds effects visible.
Closed world
A program can only touch what it declares. Reading the clock, the network or an environment variable has to come in as an input, or the compiler refuses it. This is what makes a SEG reproducible: given the same inputs, it gives the same result on every machine.
Bounded before it runs
Integer widths, types and resource use are fixed at compile time. A 32-bit wrapping add in Java and an i32 add in Rust become nodes with the same exact width, and a COBOL COMP-3 field keeps its exact decimal overflow behavior. Every execution also runs on a fuel budget, so nothing loops forever.
From source to graph
Each compile goes through four stages.
| Stage | What happens |
|---|---|
| Parse | The source is read with the language’s own grammar and semantics, so a ROUNDED clause in COBOL or >>> in Java means exactly what it means to that language’s compiler. |
| Width model | Every integer, decimal and float gets its exact width, signedness and overflow behavior: wrapping, trapping or checked, depending on the language and the operator. |
| Membrane | Every memory access is rewritten as an explicit read or write on the membrane value, including pointers, arrays, fields and parameters written back to the caller. |
| SEG | The result is the finished graph, in a form that doesn’t depend on the source language. RAVEN serializes it and hashes it. |
If any stage meets something it can’t model exactly, the compile stops there with a refusal at the exact file, line and column.
Example: compound interest
Here is the compound interest program from the quickstart. It grows a balance in cents by a rate in basis points for a number of years, rounding half away from zero.
PROCEDURE DIVISION.
PERFORM VARYING Y FROM 1 BY 1 UNTIL Y > YEARS
COMPUTE BALANCE ROUNDED =
BALANCE + BALANCE * RATE-BP / 10000
END-PERFORM
DISPLAY BALANCE
GOBACK.
Its SEG has five layers, read left to right:
balance rate_bp years inputs
mul loop ×n multiply, repeated once per year
div 10⁴ round ½↑ divide by 10,000, round half away from zero
add add the interest to the balance
membrane.store the single write of the result
A few things are worth noticing:
- The inputs are named.
balance,rate_bpandyearsare the only things the graph depends on. In the COBOL source they areWORKING-STORAGEfields; in Python and Rust they are function parameters. All three lower to the same input nodes. - The rounding is a node.
round ½↑is an explicit operation. The Python version’s(delta + 5_000) // 10_000and COBOL’sROUNDEDboth become it. A version that rounds half to even would use a different node, and the graph and its hash would change. - There is one memory effect. The program writes its result once, through
membrane.store. Nothing else touches memory, andatracode inspectwould show exactly that.
Because the COBOL, Python and Rust versions all produce this graph, they share one RAVEN hash.
Seeing a graph
atracode inspect prints a summary of a SEG: its inputs, its membrane reads and writes, and its bounds (fuel and integer widths). Agents get the same information from the atracode_inspect_seg MCP tool.