Skip to main content
coreydaley.dev

Turning a DOT graph back into English

Say I ask Attractor for a pipeline that builds a Go CLI, tests it, and stops for my review before packaging. A few seconds later I have a dozen nodes of DOT, each with a paragraph-long prompt=. Did it include the review step? I could read every node. Or I could have a model tell me, in two sentences, what the graph does.

As of this afternoon, the Create page does the second thing. Upload a .dot file, and while the graph renders, a second stream fills the “Describe your pipeline” box with a short plain-English description of the pipeline. It’s one commit and about 160 lines. I think it may end up being the more useful of the page’s two directions: generation saves me typing, and description might save me from running the wrong thing.

First, the upload

Until today, the Create page had two ways in. Type what you want in English and, three seconds after you stop typing, an LLM streams a DOT pipeline into the box beside it. Or write DOT directly.

This afternoon’s sprint added a third: load a .dot file from disk. It’s a hidden <input type="file" accept=".dot"> and a FileReader. The file’s text goes into the DOT textarea, the graph preview re-renders, the Run button lights up, and the original filename is kept for the run. The handler also cancels any pending auto-generate first, a race Codex caught during planning: without that, a half-typed description could fire three seconds later and overwrite the file you just loaded.

The planning also had to decide what happens to the English box on upload. The first draft of the intent said leave it alone. I chose to clear it, for a clean state: an uploaded graph sitting next to a leftover description of some other pipeline is confusing.

That left an empty box next to a graph. Fourteen minutes after the upload commit landed, the box wasn’t empty anymore.

How the reverse direction works

The new server piece is DotGenerator.describeStream(). It sends a single user message, and the whole prompt fits here:

Given the following Attractor pipeline DOT source, write a concise natural
language description of what this pipeline does. The description should be
1-3 sentences, specific about the workflow steps and overall goal, and
suitable as a prompt to regenerate a similar pipeline.

DOT source:
$dotSource

Output ONLY the description — no labels, no headers, no markdown formatting.

“Suitable as a prompt to regenerate a similar pipeline” is the important line. The output is meant to go back into the same box that drives generation, so it’s written in the voice of a request, not a report.

The settings say what kind of call this is:

Generate (English → DOT)Describe (DOT → English)
System promptA long one teaching Attractor’s DOT dialectNone
Max output tokens8,192512
Temperature0.20.3

Generating DOT is structured output, so it gets a full system prompt with node shapes, attributes, rules, and worked examples, plus a low temperature. Describing a graph is summarization, so it gets a tight budget and a little more room to phrase things naturally.

The transport reuses what was already there. A new endpoint, POST /api/describe-dot/stream, speaks the same Server-Sent Events protocol as the generator: a stream of {"delta": ...} lines, then {"done": true} or {"error": ...}. In the browser, describeUploadedDot() reads the stream with fetch and a ReadableStream reader and appends each delta to the prompt box. It starts right after the graph render is requested. The graph comes from a separate request (the server shells out to Graphviz’s dot -Tsvg), so neither waits on the other, and the picture and the words fill in together.

One subtle detail matters. The description is written into the textarea by setting its value from JavaScript, which doesn’t fire an input event, so it doesn’t trip the three-second auto-generate. Your uploaded DOT stays exactly as you loaded it. If you then edit the description, auto-generate runs as usual and replaces the graph with a fresh one built from your edited words. That makes the page an editing loop too: upload, read, adjust the English, get a new graph.

The upload control moved as well, from a button beside Run Pipeline to an inline “or upload an existing .dot file” link next to the “Describe your pipeline” heading, since uploading now fills both halves of the page.

Why back-translation helps

Attractor’s whole bet is that the graph is the contract. The graph is what runs, so the graph is what you should review. The catch is that a generated graph is dense. Nodes with multi-sentence prompts, conditional edges, retry targets: reading all of it carefully every time is exactly the kind of review that quietly stops happening.

Translators have a cheaper check, called back-translation. Translate a sentence into another language, translate it back, and compare. If the meaning survived, the translation is probably fine. If it didn’t, you know where to look.

Here’s how that works today, friction included. I generate a pipeline from my description. The same commit added “Download .dot” buttons to the Create page and the run monitor, so I download the graph, clear the page, and upload it again. The description that streams in is the model’s account of what the graph does, and I compare it with what I asked for. If I asked for a review step before packaging and the description never mentions a human, I don’t need to read the DOT line by line to know something went wrong. The gap between what I asked for and what came back is the review.

The download-and-re-upload step is clumsy. A “describe this” button on a freshly generated graph is the obvious next step. But the check already earns its keep for graphs I didn’t just generate: a .dot file from someone else, or one of mine from last week, gets a summary before I run it, and running a pipeline costs real tokens.

What it can’t tell you

A one-to-three-sentence description is lossy on purpose, and it has blind spots.

It describes intent, not semantics. The describer gets no system prompt, so it reads a graph the way a person skimming it would: labels, prompts, overall shape. It doesn’t know which conditions Attractor can evaluate. Here’s a real example, and it’s a bug in my own generator: its system prompt offers score>80 as a sample edge condition, but the condition evaluator only understands =, !=, and &&. A description of a graph using that condition would likely say something like “loops back until the score passes 80” and sound perfectly reasonable. The linter is what catches it, by rejecting the clause before the pipeline runs. That example needs to come out of the generator’s prompt. Round trips check meaning. Validators check syntax. You want both.

It’s the same model in both directions. Both calls use whichever provider is enabled first in Settings: Anthropic, then OpenAI, then Gemini. If the model misreads a pattern when generating, it may misread it the same way when describing. Back-translation works best when the second translator is independent, and this one isn’t. Letting the describer use a different provider than the generator would help.

It isn’t a security review. A pipeline can contain parallelogram tool nodes that run shell commands, and LLM stages whose models get a shell tool of their own. A friendly summary of an untrusted .dot file is not a reason to run it. And because the describer is an LLM reading text someone else wrote, a crafted prompt= attribute can steer what the summary says. Read the tool nodes yourself.

The endpoints aren’t locked down. The new endpoint copies the generator’s Access-Control-Allow-Origin: * header, so the problem predates this commit, but it’s worth stating plainly. Running on localhost doesn’t protect you here, because a wildcard CORS header is precisely what lets a page on some other site call your local server from your browser. Any page you have open could ask your Attractor to generate or describe pipelines and spend your API tokens. The page is same-origin, so it doesn’t need these headers at all; they should go.

Two views, checked against each other

This is a small commit: one Kotlin function, one endpoint, one stream reader, a moved link. But it changes what the Create page is for. It used to be a place where English goes in and DOT comes out. Now each side is a check on the other: the graph says what will run, and the description says what it appears to be for. The web app docs cover all three ways to start a pipeline.

When you check an AI’s output by asking an AI to explain it back, how independent does that second opinion need to be before you trust it?

Related posts