DEV Community

SUNGMIN BAE
SUNGMIN BAE

Posted on

Temporal Inversion for MiroFish: Bayesian DAG Reversal in ~46ms (0 LLM calls)

What I Built

I forked MiroFish (swarm intelligence prediction engine) and added Temporal Inversion — answering "What had to be true for this outcome?" by reversing the prediction DAG with Bayes' theorem. No LLM in the math core: ~46ms, 0 API calls.

Repo: github.com/BAESY2/MiroFish


The Idea

  • MiroFish simulates forward: seed → uncertainty grows → predictions.
  • This fork inverts backward: outcome ← certainty grows ← preconditions.
  • Temporal pincer: combine forward and inverted views; the Turnstile is where the outcome becomes effectively inevitable.

Inspired by Tenet’s temporal pincer: "What's happened, happened. But what had to be true?"


What You Get (math core only)

Analysis Question answered
Necessity What had to be true for this outcome?
Turnstile When does the outcome become inevitable?
Sensitivity Which single factor changes the outcome most?
Monte Carlo How stable is this prediction? (confidence intervals)
do-Calculus If we force this to change, what happens?
Markov Blanket Minimum set to monitor? (strong compression)

All of the above run in ~46ms with zero LLM calls. Optional: a 4-agent verification loop (Prosecutor, Defender, Devil’s Advocate, Judge) can debate findings and adjust the DAG.


Tech Stack

  • Python, Flask (existing MiroFish backend)
  • NetworkX for the causal DAG
  • Bayes’ theorem for edge reversal: P(Cause | Effect) from P(Effect | Cause)
  • Shannon entropy in both directions to find the Turnstile

Quick Start

git clone https://github.com/BAESY2/MiroFish.git
cd MiroFish/backend
pip install networkx
python test_inversion/test_true_inversion.py

Top comments (0)