Local LLM code-generation with Gemma 4 e2B via JSON AST to Clojure

vegnus1 pts0 comments

GitHub - quadracollision/llmisp: JSON AST > Clojure · GitHub

/" data-turbo-transient="true" />

Clojure. Contribute to quadracollision/llmisp development by creating an account on GitHub.">

Clojure" /> Clojure. Contribute to quadracollision/llmisp development by creating an account on GitHub." /><br>Clojure. Contribute to quadracollision/llmisp development by creating an account on GitHub." /> Clojure" /> Clojure. Contribute to quadracollision/llmisp development by creating an account on GitHub." />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

quadracollision

llmisp

Public

Notifications<br>You must be signed in to change notification settings

Fork

Star

main

BranchesTags

Go to file

CodeOpen more actions menu

Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit

History<br>4 Commits<br>4 Commits

bb

bb

schemas

schemas

scripts

scripts

specs

specs

src/llmisp

src/llmisp

README.md

README.md

bb.edn

bb.edn

deps.edn

deps.edn

plugins.edn

plugins.edn

View all files

Repository files navigation

JSON AST Agent Harness

This project is a local code-generation harness for turning text specs into Clojure programs. The validated local setup was tested with Gemma 4 E2B GGUF served by llama.cpp. Other models may work, but they are untested.

The core idea is to stop asking a small local model to write full source code directly. Instead, the model emits constrained JSON AST fragments. The harness validates those fragments, assembles larger structures programmatically, lowers the accepted AST to Clojure, and records every generation/repair artifact in SQLite.

What It Does

Runs a local Gemma 4 E2B GGUF model through llama-server.

Can target another OpenAI-compatible chat endpoint experimentally.

Uses a planner pass to derive a sanitized contract from a text spec.

Builds deterministic skeleton ASTs before asking the model for detailed logic.

Uses micro-stepped passes for query filters, derived columns, and GUI components.

Validates generated JSON AST with Malli, JSON Schema/GBNF-compatible constraints, field provenance checks, type-flow checks, and semantic structure guards.

Compiles accepted JSON AST into Clojure source.

Logs prompts, raw model output, accepted ASTs, rejected attempts, and execution traces into a per-run SQLite DB.

Business Logic Path

The business-rule plugin generates Clojure data-transformation functions.

bb json-run \<br>--self-plan \<br>--skeleton-first \<br>--where-pass \<br>--column-pass \<br>--gguf /path/to/gemma4-e2b.gguf \<br>--llama-server-bin /path/to/llama-server \<br>--llama-port 18700 \<br>--llama-ctx-size 4096 \<br>--llama-gpu-layers 24 \<br>--task-file specs/blind/dynamic_pricing_matrix_spec.txt \<br>--project-dir tmp/dynamic_pricing \<br>--repair-attempts 0 \<br>--max-tokens 4096 \<br>--where-max-tokens 2048 \<br>--column-max-tokens 2048

Outputs are written under the project directory:

candidate.ast.json

candidate.clj

report.json

session.sqlite3

llama-server.log

Native Swing GUI Path

The :gui-page plugin generates simple native Java Swing programs. The model emits a sanitized GUI contract and component subtrees; the harness owns Swing lowering, safe event wiring, and jar packaging.

bb gui-run \<br>--self-plan \<br>--component-pass \<br>--gguf /path/to/gemma4-e2b.gguf \<br>--llama-server-bin /path/to/llama-server \<br>--task-file specs/gui/inventory_dashboard_spec.txt \<br>--project-dir tmp/gui_inventory

Build the generated Swing program into a runnable jar:

bb gui-jar tmp/gui_inventory/candidate.clj tmp/gui_inventory/app.jar

Run it manually when you want to open the desktop window:

java -jar tmp/gui_inventory/app.jar

GUI actions are intentionally closed and deterministic. Buttons can use safe action maps such as show-message and clear-form; the model cannot emit arbitrary Java, Swing listener code, Clojure forms, file actions, network actions, or shell commands.

Smoke Tests

bb json-smoke tmp/json_smoke<br>bb gui-smoke tmp/gui_smoke

These validate the local Babashka classpath, JSON AST validation, Clojure codegen path, Swing AST validation, and Swing source load path without calling a model or opening a GUI window.

Benchmark Honesty

By default, json-run is text-only generation. Semantic fixtures are not...

clojure json llama llmisp model path

Related Articles