Graft v1.1: Parallel Execution and Foreach Loops
What is Graft?
Graft is a graph-native language that compiles .gft files to Claude Code harness structures. It eliminates token waste in multi-agent AI pipelines by providing typed schemas and edge transforms at the language level.
What v1.1 Adds
Two flow control primitives that enable real-world multi-agent patterns:
Parallel Execution
Run nodes concurrently when they have no data dependencies:
graph Review(input: CodeDiff, output: Report, budget: 20k) {
parallel {
SecurityReviewer
PerformanceReviewer
StyleReviewer
}
-> Aggregator -> done
}
The compiler estimates parallel block cost as the sum of all branches (worst case: all run to budget).
Foreach Loops
Iterate over list outputs with a configurable cap:
graph BatchProcess(input: TaskList, output: Results, budget: 50k) {
Splitter
-> foreach(Splitter.output.tasks as task, max_iterations: 10) {
Processor -> Validator
}
-> Collector -> done
}
Token estimation: best case = 1x iteration, worst case = Nx iterations.
Multi-Field Select
select(a, b, c) keeps multiple fields in a single transform — no longer need chained select calls.
Process Evolution: Adaptive Adversarial Loop
v1.1 introduced key improvements to the debate process:
- Benchmark-first development — define
.gfttest files before writing code - Complexity-based agent scaling — 4 agents for complex tasks, fewer for simple ones
- Skeptic-only review — A3-Skeptic catches everything, full 4-agent review is overhead
A Bug in the Benchmark File
The debate found a bug not in the compiler, but in parallel_flow.gft — SecurityReviewer was listed both before and inside a parallel block. A3-Skeptic spotted the duplicate.
Forced Dissenter: Recursive vs Flat FlowNode
A1-Architect (forced dissenter) initially argued for flat FlowNode representation. Self-reversed after cross-critique: "recursive FlowNode has stronger code-reuse argument." 3-to-1 vote for recursive FlowNode discriminated union:
export type FlowNode =
| { kind: 'node'; name: string }
| { kind: 'parallel'; branches: FlowNode[][] }
| { kind: 'foreach'; source: ContextRef; variable: string;
maxIterations: number; body: FlowNode[] };
A3 also caught a foreach 3-part path issue (source context, field, and variable all need tracking).
Stats
| Metric | Value |
|--------|-------|
| New tests | 25 (135 total) |
| New benchmarks | 2 (16 total) |
| New keywords | 4 (parallel, foreach, as, max_iterations) |
| Ratchet-locked decisions | 58 total |
Try It
git clone https://github.com/JSLEEKR/graft.git
cd graft && npm install && npm run build
node dist/index.js compile examples/parallel_flow.gft --out-dir ./output
Built with Claude Opus 4.6 via Claude Code. April 2026.