Terse — Session Context¶
Quick reference for picking up where we left off. Update this file at the end of every session.
Project Identity¶
Language: Terse
Author: Lesley Ancion
Organization: Goatface Tech
Location: Sundre, Alberta
Repo: github.com/GravyLords/terse-lang (private)
Date Started: April 2026
The Vision¶
A general-purpose programming language built for AI systems.
Reads like English. Compiles to native via LLVM. Graph semantics, tensor performance.
Designed alongside a future custom NCI chip and dedicated Ethics Core chip.
The language, the compiler, and the silicon — all designed together from day one.
Core Laws¶
- Law I — Knowledge is not stored, it is organized. Retrieval is not lookup, it is reconstruction.
- Law II — Capability is not authorization.
- Law III — The compiler works harder so you don't have to.
Current Status¶
Phase: 2 — C Transpiler — COMPLETE ✅
Next Phase: Phase 2.5 — Install GCC, compile output.c to native binary, then Phase 3 LLVM
Phase 1 — Complete ✅¶
- ✅ Full interpreter pipeline — lexer, parser, interpreter, errors, main
- ✅ Knowledge graphs, inference, Markov chains, functions, loops
- ✅ Variables, math, conditionals, tensors, compression, ethics rules
- ✅ REPL, error handling, example programs
- ✅ Docs site at terse.goatfacetech.com
Phase 1.5 — Semantic Compression Algorithm — Complete ✅¶
- ✅
src/compression/COMPRESSION.md— algorithm spec - ✅
src/compression/semantic.py— four-phase semantic compression - ✅ Benchmark: 70.59% storage ratio, integrity verified
Phase 1.6 — Runtime Integrity & Encryption — Complete ✅¶
- ✅
src/sealing/SEALING.md— sealing spec - ✅
src/sealing/seal.py— signing tool - ✅
src/sealing/verify.py— boot verification - ✅
sealedkeyword — lexer, parser, interpreter - ✅ ethics_core signature:
46760ae1b887bb35060c0cb625717c19dafd8329303f8d648bf14cd8b1aec07e
Phase 2 — C Transpiler — Complete ✅¶
- ✅
src/transpiler/TRANSPILER.md— transpiler spec - ✅
src/transpiler/ir.py— 30 IR op dataclasses, full op set - ✅
src/transpiler/ir_compiler.py— AST to IR, flat list output - ✅
src/transpiler/c_emitter.py— IR to C, one function per op type - ✅
src/transpiler/terse_runtime.h— C runtime, single header - ✅
src/transpiler/test_pipeline.py— full end to end test - ✅
src/transpiler/output.c— first compiled Terse program
Known Minor Issues¶
with reason:in ethics deny statements produces straylinked: with -> reason -> :output — cosmetic parser quirk, fix in a future session
Next Steps¶
- Install GCC on Windows via MSYS2
- Compile
output.cto a native binary — first ever native Terse program - Phase 3 — LLVM compiler (IR stays the same, swap C emitter for LLVM emitter)
File Structure¶
terse-lang/
├── .gitignore
├── README.md
├── ROADMAP.html
├── CONTEXT.md <- this file
├── spec/
│ └── terse-spec.html
├── docs/
│ └── Terse_Concept_Disclosure.pdf <- v1.2
├── docs-site/
│ ├── mkdocs.yml
│ └── docs/
│ ├── index.md
│ ├── syntax.md
│ ├── concepts.md
│ ├── roadmap.md
│ ├── stylesheets/terse.css
│ └── sessions/
│ ├── session1.md through session8.md
├── src/
│ ├── interpreter/
│ │ ├── lexer.py <- COMPLETE
│ │ ├── parser.py <- COMPLETE
│ │ ├── interpreter.py <- COMPLETE
│ │ ├── errors.py <- COMPLETE
│ │ └── main.py <- COMPLETE
│ ├── compression/
│ │ ├── COMPRESSION.md <- COMPLETE
│ │ └── semantic.py <- COMPLETE
│ ├── sealing/
│ │ ├── SEALING.md <- COMPLETE
│ │ ├── seal.py <- COMPLETE
│ │ ├── verify.py <- COMPLETE
│ │ ├── test_verify.py
│ │ └── test_sealed_end_to_end.py
│ └── transpiler/
│ ├── TRANSPILER.md <- COMPLETE
│ ├── ir.py <- COMPLETE
│ ├── ir_compiler.py <- COMPLETE
│ ├── c_emitter.py <- COMPLETE
│ ├── terse_runtime.h <- COMPLETE
│ ├── test_pipeline.py
│ └── output.c <- first compiled Terse program
└── examples/
├── hello.trs
├── while_test.trs
├── animal_mind.trs
├── ethics_core.trs
└── test_sealed.trs
How to Run a Terse Program¶
cd C:\Users\ljanc\Projects\terse-lang\src\interpreter
# Run a file
python main.py ../../examples/hello.trs
# Start the REPL
python main.py
How to Compile a Terse Program to C¶
cd C:\Users\ljanc\Projects\terse-lang\src\transpiler
# Run the full pipeline
python test_pipeline.py
# Output written to output.c
# Compile with GCC (once installed):
# gcc output.c -o hello && ./hello
How to Seal an Ethics Block¶
Key Classes and Files¶
ir.py — IR Op Dataclasses¶
StoreFact,StoreRelation,InferRegisterRule,RegisterEthicsLabel,Jump,JumpIfTrue,JumpIfFalseFuncDef,FuncCall,ReturnStoreVar,LoadVar,MathOp,CompareEachStart,EachEnd,WhileStart,WhileEndTensorCreate,TensorDot,TensorScale,TensorAddLearnSeq,PredictSeq,GenerateSeqCompress,ExpandSealedBegin,SealedEnd,VerifySealIRProgram— container, append ops, prints as assembly-like text
ir_compiler.py¶
IRCompiler— walks AST, emits IR opscompile(ast)— entry point, returnsIRProgramnew_label(prefix)— generates unique labels for jumps
c_emitter.py¶
CEmitter— walks IR ops, emits C linesgenerate(ir_program)— returns complete C source as stringemit_header()— includes, main(), runtime initemit_footer()— runtime free, return 0emit_op(op)— one case per IR op type
terse_runtime.h¶
TerseRuntime— top level state structTerseNode— knowledge graph node with fact tableTerseRule— inference ruleTerseEthics— ethics ruleTerseVar— named variableTerseEachState— each loop iterator stateterse_runtime_init()/terse_runtime_free()terse_store_fact(),terse_check_fact()terse_store_relation()terse_register_rule(),terse_infer()terse_store_var(),terse_load_var()terse_math_op(),terse_compare()terse_each_start(),terse_each_next(),terse_each_end()terse_register_ethics(),terse_check_ethics()terse_verify_seal()terse_return(),terse_func_call()
Terse Syntax — Complete Reference¶
// Facts
know dog is animal
know dog has fur
// Relationships
dog chases cat
// Inference rules
when has fur then is mammal
// Inference
infer dog
// Sequence learning
learn dog chases cat runs away
predict after chases
generate from dog steps 3
// Functions
to classify thing
infer thing
return thing
classify dog
// Loops
each creature in animal
classify creature
while running is true
infer model
// Variables and math
x = 5
y = x * 2
z = x + y
// Conditionals
if x > 5
know size is big
else
know size is small
// Tensors
weights = tensor 3 3 fill 0.0
inputs = tensor 3 fill 1.0
output = weights dot inputs
scaled = weights * 0.5
// Compression
compress dog -> d
expand d -> dog2
// Ethics rules
ethics rule no_harm
when intent is harm
then deny with reason: "Law II violation"
// Sealed blocks
sealed ethics_core
ethics rule no_csam
when intent is exploitation
then deny with reason: "Absolute limit"
Build Roadmap Summary¶
| Phase | Description | Status |
|---|---|---|
| 1 | Python interpreter | ✅ Complete |
| 1.5 | Semantic compression algorithm | ✅ Complete |
| 1.6 | Runtime integrity & encryption | ✅ Complete |
| 2 | Terse -> C transpiler | ✅ Complete |
| 2.5 | GCC install, first native binary | ⬜ Next |
| 3 | LLVM compiler — native speed | ⬜ Planned |
| 4 | FPGA prototype (Artix-7) | ⬜ Future |
| 5 | NCI-1 custom chip | ⬜ Future |
| 6 | NCI Ethics Core chip | ⬜ Future |
Design Decisions Made¶
- IR is Python dataclasses — type safe, editor friendly, repr prints as assembly
- Compress slow, expand fast — all intelligence in compressor, expander just merges
- Sealed signatures hardcoded — generated once, frozen in git history
- Ethics is mathematical not social — sealed blocks, not policies
- C emitter is a simple op walker — one function per op type, no logic
- terse_runtime.h is a single header — ships with every compiled program, no install
- Ethics conditions expand to COMPARE + JUMP at IR level — no runtime dicts in C
- Phase 3 reuses IR entirely — only the emitter changes
- Indentation-based — no braces, no semicolons
- Nodes never decay — explicit deprecation only
- Compiler absorbs complexity — memory, types, tensor layout per Law III
Next Session Goals¶
- Install GCC via MSYS2 on Windows
- Compile
output.cto a native binary - Run the first ever native Terse program
- Begin Phase 3 planning — LLVM emitter architecture
- Fix cosmetic issue:
with reason:producing stray relationship output
Related Projects¶
| Project | Repo | Status |
|---|---|---|
| NCI | github.com/GravyLords/nci (private) | Session 22 complete |
| Terse | github.com/GravyLords/terse-lang (private) | Phase 2 complete |
Update this file at the end of every session. Commit it with the session changes.