Constrained Reasoning for Regulated Industries
A Go plugin that pre-computes deterministic results, constrains the LLM to narrate around them, and validates every output before it reaches the user. Open source. Domain agnostic. MIT licensed.

The Rules-vs-LLM Tradeoff
Rules-based systems are rigid but verifiable. Unconstrained LLMs are flexible but unreliable. Lao Zi combines both.
Rules-Based Systems
Can't Scale
5 metrics × 3 age groups × 2 genders = 30 rules. Add medications and interactions and the count exceeds 1,000. Combinatorial growth makes manual maintenance impractical.
Unconstrained LLMs
Hallucinate
Feeding raw data to an LLM and asking it to analyze produces inconsistent outputs with no audit trail and no verifiability.
Lao Zi
Solves Both
LLM flexibility within deterministic boundaries. Pre-computed analytics narrated by a constrained model. Same data in, same answer out.
"The LLM never interprets raw data. It narrates pre-computed analytics."
Constrained Reasoning Instead of Rules
Lao Zi is a domain-agnostic Go plugin that wraps LLM calls inside deterministic constraint layers. It pre-computes severity from thresholds, feeds the result to the LLM, then validates the output and retries on failure. The LLM writes prose — it does not compute.
Designed for regulated industries that require accuracy, traceability, and compliance as baseline properties of any production system.
Pre-Computed Analytics
All numerical calculations happen deterministically before the LLM is invoked. The framework evaluates data — the AI narrates results.
Three-Tier Constraints
Hard thresholds, RAG knowledge bases, and output validation guardrails work together to dramatically reduce hallucinations and errors.
Narrator, Not Analyst
The LLM only narrates pre-computed insights. It never interprets raw data, calculates numbers, or drives numerical conclusions.
Audit-Ready by Design
Every claim traces to a specific guideline and source URL. Full approval workflows and deterministic validation logging from day one.

The framework's value is that failures have limited authority because the LLM has limited authority.
No technology eliminates hallucinations entirely. Lao Zi validates each output against the deterministic inputs and retries up to three times when they diverge. On the third failure, the system falls back to the deterministic result or returns a failure, depending on configuration.
Core Capabilities
What Lao Zi adds to any LLM-powered application.
Pre-Computed Comparison
Severity is computed deterministically from thresholds before the LLM runs. The LLM writes prose around the result — it cannot change the numbers, the severity, or the source citations.
Deterministic wins over LLM when they conflict
Lao Zi DSL
A purpose-built expression language for aggregation-over-data calculations. Supports SUM, AVG, ZSCORE, GINI, BENFORD, and temporal windowing (YTD, MTD, QTD). Compiles deterministically to SQL — validated at parse time, not runtime.
No raw SQL exposure, PEMDAS-enforced
Explore the DSLBuild-Time Configuration
All settings — LLM model, temperature, max tokens, parallel call limits, RAG parameters, retry counts — live in config.go and compile into the binary. No runtime config files to manage.
Settings compiled into the binary
Open Source — MIT License
Full transparency. Inspect the constraint stack. Verify the validation logic. Fork and customize for your needs. No vendor lock-in, ever.
Complete code transparency
Validation + Regeneration
Every LLM output is parsed and checked: text length, no placeholders, severity match, valid reference. Failures trigger automatic retry with the specific error fed back to the LLM.
Auto-retry on invalid output
Explore Adaptive ContextFull Audit Trail
Every claim traces back to a specific guideline + URL. Human approval workflows, metric lifecycle management, and deterministic validation logging. Audit-ready from day one.
Every insight is traceable
Explore ComplianceHow Lao Zi Works
A four-stage pipeline that separates compute from narration, ensuring every number is verified before the LLM ever sees it.
Pre-Computed Comparison
Thresholds are defined per category with min/max ranges, units, and source URLs. The engine compares actual values against these ranges and computes severity deterministically — before the LLM is ever called.
Example: glucose 105 vs range 70–99 → BELOW minimum → severity = warning. This is computed before the LLM call.
Applied Use Cases
The constraint architecture is domain-agnostic. Swap thresholds and RAG entries to target a different vertical.
Personal Health Intelligence
Lao Zi powers Glint, a personal health intelligence platform that integrates CGM data with food, medication, exercise, and sleep logs to deliver clinically-grounded insights.
- Event correlations: "Pizza → +47 mg/dL peak at +90min, recovery 3.2hrs"
- Wearable integration: Garmin, Fitbit, Apple Health, CGM devices
- Clinical metrics with DB-driven thresholds (ADA, CDC sources)
- Health outlook pipeline: RAG pre-fetch → parallel generation → dedup → summarizer
- Extensible insight categories — add new health domains without retraining
Key Features
Experience Lao Zi
Try the constrained reasoning pipeline against live data. Queries are classified, constraints applied, and outputs validated in real time.
Drop-In Plugin Architecture
Lao Zi wraps your existing LLM. It doesn't replace it. Add constrained reasoning to any application with a simple Go import.
import "github.com/Phoenix-Innovation/laozi"
engine := laozi.New(
laozi.NewDefaultLLMClient(),
laozi.NewInMemoryRAG(),
)
engine.AddCategory(laozi.Category{
ID: "glucose",
Name: "Blood Glucose",
Thresholds: []laozi.Threshold{{
Metric: "glucose", Min: 70, Max: 99,
Unit: "mg/dL", Source: "ADA",
}},
})
metrics := map[string]float64{"glucose": 105}
insights, _ := engine.AnalyzeAll(ctx, metrics)LLM Backends
RAG Stores
Databases
Infrastructure
Production Architecture
Ingest and evaluate are separate stages. Workers operate on pre-aggregated summaries, not raw records.
System Architecture

Lao Zi Plugin — Detailed Software Architecture: Constraint Layer, LLM Pipeline & Data Flow
Deployment Options
Runs on a single VM or scales horizontally across distributed clusters. Contact Pi.Tech to discuss architecture for your workload.
Contact Pi.TechDefense in Depth
Lao Zi provides external constraints (framework layer). A domain-tuned LLM provides internal biases. Together they create defense in depth — the LLM cannot change severity, invent numbers, or drop citations.
"The architecture's value is that failures have limited authority because the LLM has limited authority."
Get Started with Lao Zi
Lao Zi is open-source under MIT. Browse the code, read the docs, or reach out to discuss integration with your stack.
Contact Pi.Tech
Get in touch about enterprise deployments
