The engine
KERN starts as compact .kern source, becomes a structured IR, and then flows into compiler targets, review rules, MCP tools, tests, and language-evolution workflows.
The important part is not a template string. It is the shared semantic layer: nodes, props, types, routes, effects, guards, confidence, and evidence survive across tools.
Why it works
The parser accepts an indentation-based language with key=value props, style shorthands, typed nodes, handlers, machines, routes, MCP tools, tests, and evolved node hints. Review and compile both consume the same structured tree.
Review can distinguish reads, writes, network calls, auth, validation, and recovery paths instead of only matching text.
Target support is explicit: native, lowered, or unsupported by feature and position, so the compiler can be honest about what emits cleanly.
Parse diagnostics, review confidence, suppression metadata, and evidence spans make findings easier to audit and automate.
The language (v4)
v4 turns KERN's portable layer into a typed core language: classes, enums, and closures that compile to both TypeScript and Python with identical behavior. The same source, two runtimes, one meaning.
class name=Shape abstract=true export=true
method name=area returns=number
class name=Square extends=Shape export=true
field name=side type=number value={{ 3 }}
method name=area returns=number
handler
return value="this.side * this.side"
fn name=measure returns=number
param name=shape type=Shape
handler
return value="shape.area()"enum name=Status values="Pending|Active|Done"
# TypeScript: export enum Status { ... }
# Python: class Status: (Pending = 0, ...)
#
# Same member values, including auto-increment.
# Reverse indexing Status[0] and Object.keys(Status)
# iteration are rejected at compile time on BOTH
# targets — neither side can silently diverge.Every construct ships with differential conformance fixtures that execute the generated TypeScript and the generated Python and require identical results. Anything outside the provable subset fails closed with an explicit compile error instead of guessing — closures with captured-variable mutation are lowered correctly on both targets.
kern check — nominal type checkerVerifies class hierarchies and Liskov-checked override variance, call-site arity and argument types, and declared returns. Zero false positives by design: it only reports violations it can prove. Exit codes 0 / 1 / 2 and a stable JSON contract for CI.
Compile
Each target has its own emitter path. Some features compile natively, some lower to runtime helpers, and some are intentionally marked unsupported until the target can emit them correctly.
shared TypeScript library output
Next.js App Router pages and routes
React output with Tailwind classes
React web components
React Native output
Node/Express APIs
command-line apps
ANSI terminal UI
React terminal UI
Vue 3 SFCs
Nuxt pages and routes
Python FastAPI services
Model Context Protocol servers
portable Python lowering
portable Go lowering
Review engine
The review package builds file context, import graphs, call graphs, concept maps, taint flows, public API maps, quality rules, and confidence graphs. That is why it can report problems like unguarded effects or route contract drift with evidence.
reviewDirectory()
build context graph
extract TS/Python concepts
analyze taint flows
run active rule layers
group by root cause
assign confidence
emit report / SARIFevolve(input)
collect TS files
detect gaps
analyze patterns
propose templates
validate proposals
stage approved outputEvolve
kern evolve is an experimental pipeline for detecting recurring TypeScript patterns, proposing templates or structural nodes, validating them, and staging the result for approval.
Proof
The landing app keeps .kern sources beside generated Next files, uses the compiler target for app routes, and ships the result as a normal Next.js site.