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>3 Commits<br>3 Commits
bb
bb
schemas
schemas
scripts
scripts
specs/blind
specs/blind
src/llmisp
src/llmisp
README.md
README.md
bb.edn
bb.edn
View all files
Repository files navigation
JSON AST Agent Harness
This project is a local code-generation harness for turning business-rule text specs into Clojure programs. The validated local setup was tested with Gemma 4 E2B GGUF served by llama.cpp.
The core idea is to stop asking a small local model to write source code directly. Instead, the model emits a constrained JSON AST. The harness validates that AST, lowers it to Clojure forms, pretty-prints source, 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, but models other than Gemma 4 E2B have not been tested.
Uses a planner pass to derive a sanitized contract from a text spec.
Builds a deterministic skeleton AST before asking the model for detailed logic.
Uses micro-stepped passes for query filters and derived columns.
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.
Why JSON AST
Small local models are unreliable when asked to emit full source code. They drift on syntax, invent operations, or produce partial programs.
This harness makes the local program own structure:
The model translates one small semantic unit at a time.
The harness assembles larger structures programmatically.
Invalid logic is rejected before codegen.
Empty required filters and unfinished derived columns are hard failures.
Current Status
The harness has passed a blind batch of five business specs with no answer-bearing semantic fixtures:
dynamic pricing
fraud chargeback triage
logistics routing
support escalation
vendor payment risk
That proves structural generation and Clojure codegen across multiple domains. It does not prove independent semantic correctness unless you also provide clean held-out input/output tests.
Requirements
Babashka
Python 3
llama-server from llama.cpp, or another OpenAI-compatible chat endpoint
A Gemma 4 E2B GGUF model if running locally
The Gemma 4 E2B GGUF model is not included. Other models may work, but they are untested.
Smoke Test
bb json-smoke tmp/smoke
This validates the local Babashka classpath, JSON AST validation, and Clojure codegen path without calling a model.
Run One Spec With Local GGUF
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
Run Blind Batch
GGUF=/path/to/gemma4-e2b.gguf \<br>LLAMA_SERVER_BIN=/path/to/llama-server \<br>OUT_DIR=tmp/blind_specs \<br>PORT_START=18700...