Intent-Garden (S-OAK) Core
Deterministic verification engine for AI-generated C/C++ code.
We don't believe in "safe languages". We believe in safe intentions.
📖 About
Garden-Core is a Clojure engine that audits AI-generated C/C++ code through Clang AST and EDN contracts. It serves as the "last mile" between stochastic AI output and predictable code execution.
How It Works
We don't fix AI mistakes. We create an environment where invalid code physically cannot pass the build stage.
The engine eliminates hallucinations through strict division of labor:
- Intent Injection — AI agent receives specification from
rulerom/registry - Garden-Tagging — AI writes C code and marks it with
[[garden:intent(...)]]tags - AST Enforcement — Engine parses Clang JSON AST and validates against contracts
- Semantic Echo — Generates Markdown reports for human verification
🛠️ Technology Stack
| Component | Purpose |
|---|---|
| Clojure / Babashka | Fast data processing logic without JVM overhead |
| Clang LibTooling | Parses -ast-dump=json for honest code structure |
| EDN | Contract format understandable by humans and machines |
🔄 Semantic Anchor Lifecycle
graph TD
A["<b>1. Human Definition</b><br/>Architect Input / Task Description"] --> B{AI Scan}
B -->|Search| C["<b>Rule-Rom Library</b>"]
B -->|Generate| D["<b>Draft Intent</b>"]
C & D --> E["<b>2. Intent Formalization</b><br/>Lisp/EDN Contract"]
E --> F["<i>Semantic Echo</i><br/>Auto-generated Markdown Audit"]
F -->|Verification| G(("Human Approval"))
G -->|Fix| E
G -->|Approved| H["<b>3. Prompt Injection</b><br/>Contract + Requirements"]
H --> I["<b>AI Coding & Tagging</b><br/>C/C++ Code + garden-tags"]
I --> J["<b>4. AST Enforcement</b><br/>Clang JSON AST + Babashka"]
J --> K{Verification}
K -->|Violation| L["<b>Build Failed</b><br/>Retry Loop"]
L --> H
K -->|Success| M["<b>5. Certification</b><br/>Deterministic Safety Proof"]
M --> N["Production Ready Code"]
style A fill:#e1f5fe,stroke:#01579b
style E fill:#f3e5f5,stroke:#4a148c
style I fill:#fff3e0,stroke:#e65100
style J fill:#e8f5e9,stroke:#1b5e20
style M fill:#dcedc8,stroke:#33691e
style L fill:#ffebee,stroke:#b71c1c
🚀 Quick Start
1. Environment Setup (Windows / Scoop)
scoop install babashka llvm
2. Running Local Audit
Assume you have a test.c file with tags:
// [[garden:intent(safe-free)]]
free(p);
p = NULL;
// [[/garden:intent]]
Step 1: Generate AST
clang -Xclang -ast-dump=json -fsyntax-only test.c > ast.json
Step 2: Run Enforcer
bb -m garden.enforcer ast.json
3. Contract Example (EDN)
{:intent :safe-free
:entities [:ptr]
:must-set-null true
:description "After free(), pointer must be set to NULL"}
📋 Tagging Protocol (Garden-Tagging)
Every code block related to an Intent MUST be tagged:
// [[garden:intent(INTENT_ID)]]
void implementation_starts_here() {
// Your logic
}
// [[/garden:intent]]
Tagging Rules
| Rule | Description |
|---|---|
| No Orphans | Never place a tag without implementation |
| Exact ID | INTENT_ID must match the key in .edn file |
| Scope | Tags wrap the smallest logical unit |
| Vacuum Rule | Code outside [[garden:intent]] is considered dead and discarded |
📜 Manifest (Summary)
- Code is Cheap, Meaning is Expensive — value lies in intentions, not instructions
- AI is Gas, Formal Logic is Brakes — deterministic oversight over probabilistic execution
- Lisp is the Ideal Contract Language — homoiconicity for the "Constitution of the System"
- Semantic Cage — AI generates inside a DSL cage of safety rules
- Validation Instead of Hope-and-Pray — check at generation time, not after
- Zero-Cost Security — contract operates at metaprogramming stage
- Death of the "Black Box" — AI as black box implementation in a white box of intentions
📄 Documents
| Document | Description |
|---|---|
| AI Agent Contract | Tagging rules for AI agents |
| EDN Registry | Intent contract specifications |