What is ENIGMA
In March 2026 I started building a deterministic causal simulation engine — agents that act on their own incomplete and potentially erroneous models of the world, not on objective truth. The principle is WORLD TRUTH ≠ NPC MEMORY ≠ NPC BELIEF, enforced at runtime.
Today, 7.5 months later: v0.5.4.4.5, 729 commits, 18 enforced architectural laws (§ENIGMA-001..018), 12-layer canonical construction order, AGPL-3.0, Zenodo DOI.
- Source code: GitHub
- Visual overview: HuggingFace Space
- Archived version: Zenodo DOI
This is not a game. A scientific software artifact in active development.
This is not a tutorial. Architectural documentation for researchers and engineers working on agent systems, epistemic logic, deterministic simulation, or LLM-assisted engineering.
This is not a product. Solo-maintained research project, no support SLAs, no roadmap commitments to external stakeholders.
The workflow that made this possible
I want to share the engineering methodology, because it's the most interesting part and probably the most reproducible.
I don't use agent swarms. I don't use API access. I use free-tier web access to multiple models in parallel, three browser windows, and a human-as-router architecture:
- Window 1: GLM as architect (final ADRs and code)
- Window 2: GPT/Claude for design pushback and alternatives
- Window 3: Kimi/DeepSeek/Gemini for sanity checks and edge cases
The models argue with each other through me. I synthesize. The final decision goes to GLM as an architect with a strict format contract (original Russian names kept):
БЫЛО: <one line of code to be replaced>
СТАЛО: <new code>
IPT: <invariant checked>
КРАСНЫЕ ИНВАРИАНТЫ: N red → M red
(Translation: БЫЛО = before, СТАЛО = after, IPT = invariant probe test, КРАСНЫЕ ИНВАРИАНТЫ = red invariants count)
This is faster than any agent swarm I've tried. Context window optimization is done by me — I extract relevant fragments from 200K+ lines of code, the models never see the full codebase. Latency hides through parallelism (while model A is thinking, I formulate task for model B, review result from model C).
Why this matters: model drift is real
I've observed that newer model versions tend to "drift". GLM 5.3 vs 5.2 — 5.3 wants to design inside its own environment, ignoring the working mode protocol. Similar patterns in Claude and GPT between versions.
The defense is architectural:
- Archaeological protocol — no code change without grep/PowerShell archaeology first (§13 of the charter)
- ADR-PRE-FLIGHT checklist — before any code, fill: type, affected domains, downstream consumers, resource budget, rollback plan, regression test
-
Executable invariants — 18 laws raise
ArchitecturalViolationErrorat runtime when violated - Format enforcement — every change must list the invariant it checks
The architecture is model-agnostic. If GLM disappears tomorrow, I switch to another model and continue — because my asset is the discipline, not the model.
The 12-layer canonical construction order
Each layer must use the causal work of the layer below, never imitate it.
0. Authoring → Compiler (LLM translates, Python validates)
1. Identity / History (past exists as data, not text)
2. Body → Need (states have consequences, not decoration)
3. Desire → Object → Activity (NPC wants something, chooses activity)
4. Decision → Action → Outcome (CAN ≠ WANT ≠ INTEND ≠ ATTEMPT ≠ SUCCESS)
5. Perception → Experience → Memory (NPC knows only what it could perceive)
6. Salience → Consolidation (memory becomes selective)
7. Relationships as History (relationship = consequence of history)
8. Belief → Expectation → Decision (NPC acts on its picture of the world)
9. NPC as Interface (player learns complexity through NPC)
10. Self-Interpretation (WHAT HAPPENED ≠ HOW EXPLAINS)
11. Appraisal / Prediction (surprise as measurable prediction error)
12. Deception (lie ≠ ignorance ≠ error ≠ withholding)
Anti-Bond rule: each layer must prove causal work no other layer performs. No parallel truth-stores. No decorative state.
Dialogue ≠ Memory
Memory ≠ Causality
Belief ≠ Decision
Relationship scalar ≠ History
Self-interpretation ≠ Motivation
LLM ≠ Canonical Truth
Key architectural principles
- Epistemic grounding — LLM is never a source of canonical truth; Python = causal authority
-
Deterministic replay — KernelRNG-protocol, no
random.*or wall-clock in simulation layer (§15) - Causal layering — upper layers must use the causal work of lower layers, never imitate
- Anti-Bond — no parallel truth-stores, no decorative state
- Belief non-mutation — beliefs are lenses (weight modifiers), not genes (scalars); personality drift via interpretation is forbidden (§16)
-
Epistemological orthogonality —
RealityandObserver Knowledgeare orthogonal axes; consumers receive only epistemic representations (§17)
What's open right now
Active fronts:
- BC-2 (Conclusion → Expectation) — epistemic circuit
- MOT (Motive & Decision Trace) — decision stores "why", not just "what"
- MEM (Memory Architecture) — long-term memory with decay, consolidation, reconstruction
- NL-01 phase 1 (Narrative Grounding) — NPC as interface, three control questions
The canonical vertical proof is the "Goran? Yes..." memory scenario (track MEM §16.5): an NPC reconstructs its individual history with perspective, temporal structure, surviving and lost details, possible errors, and prediction of future behavior — distinct from WORLD TRUTH, reproducible by the deterministic engine.
Why I'm writing this
Mostly to share the methodology. The "human-as-router with three LLM windows" workflow is something I haven't seen documented, and it's been more effective for me than any agent framework.
If you're doing similar long-context LLM-assisted work, I'd like to hear your patterns. The comments are open.
The project itself is research-grade — AGPL-3.0, so if you serve it over network, share the source.
Links
- GitHub: 4Um4/Enigma
- HuggingFace Space: Um44/ENIGMA
- DOI: 10.5281/zenodo.22831764
- Architectural Charter: АРХИТЕКТУРНЫЙ_УСТАВ_ENIGMA.md
- Roadmap v4.12: ENIGMA_ROADMAP_v4_12_WPS.md
Citation
@software{gritsaenko_2026_enigma,
author = {Gritsaenko, M.},
title = {ENIGMA: Executable Epistemic Contracts in Deterministic Agent Simulation},
version = {0.5.4.4.5},
year = {2026},
url = {https://github.com/4Um4/Enigma},
doi = {10.5281/zenodo.22831764},
license = {AGPL-3.0}
}
Happy to answer technical questions about the architecture, the deterministic replay protocol, the KernelRNG, the anti-Bond discipline, or the LLM workflow.
Top comments (0)