Inspiration
Every budgeting app, every energy calculator, every planner answers the same way: it picks one future and projects it. Pay this much and you are clear in 25 months. It never says what happens if your income drops for three months, or a rate rises, or both happen at the worst possible time.
The technique for answering that properly is old and currently unfashionable. In formal methods it is called reactive synthesis: model the situation as a two player game, play against an adversary allowed to do a declared set of things, and compute the states from which you can force the outcome no matter what the adversary does. It is how people prove a circuit or a controller is safe. Nobody applies it to the decisions ordinary people actually make.
A chess engine searches and guesses. Except in the endgame, where it uses a tablebase: every position solved backwards from the finish, so it is not estimating anything. That is the idea we took off the board.
What it does
You describe your situation in plain language. A language model turns it into a form. You check every field and confirm it. Nothing has been computed yet.
Then the solver runs. It enumerates the finite game of you against every shock you declared, by backward induction, and answers one of five ways: guaranteed, not guaranteed, refuted, unresolved, or an error in the rules file.
Three things make the answer mean something.
Every rounding is made against you. Cash rounds down, balances round up, so a state marked safe is safe for every real value inside its bucket. The answer is an upper bound, which is why it says "at most" and never "in".
Every figure carries its source. Each number on screen has the rule id and the line number in the rules file that produced it. The rules are data, not code, and you can open the file.
The assumptions travel with the answer. The file digest, the position, the declared shocks, the horizon, the bucket size and a scope sentence are attached to every result that carries a guarantee.
You can also test your own plan. Each strategy has a Test button. "Minimums, then all surplus on the highest rate" comes back as debt free in at most 32 months, guaranteed. Another comes back as fails in month 36, with the shock that breaks it and the state at that moment.
Alongside the guarantee there are two projections, labelled as projections. There are no probabilities anywhere in the system, so neither is called likely, average or median.
This is not tree-search reasoning with a language model
There is an active research area that looks superficially similar: Tree of Thoughts, LLM-MCTS, rStar, ThoughtSculpt, and the reasoning modes inside current frontier models. That is real work. It is also the opposite of this.
There, the model sits inside the search. It generates the nodes, scores them, criticises them, acts as the world model. The answer is as good as the model's judgement at every node, and thirty simulations can mean a hundred API calls.
Here the model is forbidden from the search. The state space comes from a rules file, the transitions are compiled integer arithmetic, the solver is exhaustive. During a solve the number of model calls is zero. The app runs with the network off, and a test fails if a sample makes any network call, including one whose error is caught and hidden.
The model has two jobs, both at the edges: turning your words into a form you confirm, and turning the result object into prose. It never produces, modifies or rounds a number the engine reads or that you see as a result. A guard checks the prose against the result object and rejects any digit that is not in the data, falling back to a plain template.
The honest trade: they work on open problems where no rules exist. BranchWise cannot answer a question nobody has written the rules for. It refuses to guess rather than guessing quietly.
The engine knows nothing about debt
All domain knowledge lives in a JSON rules file: the state, the goal, the ruin condition, the moves, the shocks, the readout templates. The engine knows a closed vocabulary of primitives and nothing else. A test fails if any file under engine/ contains the word debt, loan, battery or solar.
To find out whether that was true or just a claim, we wrote a second domain late in the build: sizing a solar panel and battery for a rural clinic on an unreliable grid. Can this system keep the essential load running through every outage pattern I declare?
It loaded on the first try with no change to the engine. Same solver, same screens, units and labels taken from the file: watt hours and days instead of money and months. The debt fixture takes 562,988 states and ten to twenty-six seconds. The clinic fixture takes 204 states and thirteen milliseconds. Nothing between them changed.
That second file also made the guarantee testable. A real solve on the debt file is too slow for a property test. The clinic file is not, so there is now a property that loads it through the real loader and compiler, solves the bucketed table and the exact one, and fails if the bucketed answer is ever better than the exact one. Better would mean the rounding went the wrong way and the word guaranteed is false.
How we built it
Three algorithms, two of which died.
A tree search, because the problem looks like a game. The spec made us measure it before any code depended on it. On the one case that mattered it never finished.
Exact state keys. With interest rounded every month, paths never merge, so the state space degenerates into a tree: 3.4x growth per month, 8.1 million states and a gigabyte by month eleven, killed at month twelve.
Bucketed backward induction, every rounding made against the user. 562,988 states, and an honest upper bound instead of an exact answer.
TypeScript, React and Vite, plain CSS on a token system. The engine runs in a Web Worker and reports progress every 65,536 states, so the page stays responsive and you watch the real count climb. Vitest and fast-check for property-based testing. Groq for the two model calls, behind a server-side proxy that never lets the key reach the browser and only accepts the two exact operations the app builds, so it cannot be used as an open relay.
Challenges
The hardest part was not the algorithm, it was knowing when a guarantee is real. Bucketing is only sound if the comparisons a decision makes are bounded by the bucket edges. An audit late in the build found three forms of comparison where the loader places no bound, and that both shipped files use one of them in their ruin test. They are sound by monotonicity, but the loader does not check that, so the claim is scoped rather than universal, and the same sentence now appears in the README, in the requirements, in the engine notes and in every result the app produces.
The other hard thing was keeping the boundary. It is very easy to let a model compute one small number because it would be convenient. One paragraph in a steering file stopped that, reloaded on every interaction, still holding at hour fourteen.
What we learned
Measure the risky idea before the design depends on it. Two dead ends in one night instead of two on submission day.
An assertion nobody has watched fail is not yet known to fail. We broke the engine on purpose to see each failure message print, then reverted against a recorded hash.
Known limits
The debt file's bucketed table is compared to nothing: only the clinic file is covered by the bucketing property. A solve on the debt file takes ten to twenty-six seconds. The inverse solver was cut. Generated code means a strict content security policy would need unsafe-eval. The hosted demo runs with the model off, because a static host has nowhere to keep a key; the samples and the solver work there. One test in the model suite fails, flagging an environment variable name in browser code; it is not a key leak and the README says so rather than hiding it.
What's next
Close the bucket bound by placing bounds on the value actually read, or by having the loader refuse the comparison forms it cannot bound. Sweep an unknown input and answer over a range instead of a point: at any rate up to X, at most N months. More domains, since each one is a test of the vocabulary and the last one found four things worth fixing.
Built With
- css
- fast-check
- groq
- json
- kiro
- react
- service-workers
- typescript
- vite
- vitest
- web-workers
- whisper