The one number I would not let the model calculate

Oct 21, 2026Architecture Under Constraint5 min read

There is a question this system invites, and it is a fair one. My team at Aditi wrote a couple of hundred lines of C# to do arithmetic that the language model already in the same application could do in one call. Why.

The trade is not determinism versus accuracy. It is determinism versus debuggability.

The system generates offer letters for a staffing firm. It reads a recruiter’s document, works out the full compensation breakdown, and produces the letters. The model does the reading and the writing. The arithmetic sits between those two steps, and leaving it to code was a deliberate call that costs real effort to build and maintain.

When I first made that call, my reasons were thinner than they are now. This is the argument I would give today.

The answer I used to reach for

Something about determinism and reproducibility. True, and it does not survive a sceptic, because a well-prompted model gets this right almost every time, and that is correct.

Almost every time is the entire problem, but “almost” is not an argument until you can say what it costs.

Here is what it costs. If this calculation is wrong, nobody finds out during testing. Nobody finds out at review. It is found roughly three weeks after somebody starts a new job, when their first payslip does not match the letter they signed, and they are the one who notices.

That is not a bug report. That is a person who has just moved jobs discovering that the document their employment is based on was wrong, and a conversation somebody in HR now has to have. The cost of the error is not proportional to its size. Being wrong by a small amount in that document costs nearly as much as being wrong by a large one, because the damage is to whether the paperwork can be trusted at all.

So the real answer is: this number gets checked by the person least able to absorb the error, at the worst possible moment, and it cannot be recalled.

What the code does instead

The calculation is a plain service. No model, no prompt, no network call.

It walks a banded ladder to get the base figure, applies an allowance rule that depends on which band the total falls in, adds the statutory contributions where they apply, and then, at the end, does the thing that makes the whole design work:

result.ExecutiveAllowance = Math.Ceiling(monthlyCTC - fixedComponents - totalEmployerContributions);

One component is not a rule at all. It is the remainder. Everything else is calculated from the ladder and the statutory percentages, and the last line absorbs whatever is left so that the components add back up to the agreed total exactly.

That single line is why the letter always balances. It also means that if any of the earlier rules is wrong, the error does not vanish. It shows up in that one component, visibly, in the letter. The arithmetic is self-checking in a way a model’s output is not.

Two further details are worth naming because they are the kind of thing that gets prompted away.

The statutory contribution is capped. It is calculated against a fixed statutory ceiling, not against the actual base figure, so above a certain income it stops rising. A model asked to compute a percentage will compute the percentage. Getting the cap right requires knowing that the rule has an edge, and the edge is the point.

And one deduction has no toggle at all. Everything else in the system can be switched on or off per employee group. That one is a legal obligation, so it is not exposed as an option. A configurable field is a promise that someone may configure it, and there are values that should not be configurable.

The bug this design did not prevent

Determinism does not mean correct. It means wrong the same way every time, which is a different and better property, but it is worth being honest about what it bought.

From the history of this repository:

Fix HRA giving 5% at exactly CTC = 5,00,000

There is a threshold in the allowance rule. Below it, one rate applies. At or above it, a much higher one does. The gap between the two rates is large, so the boundary is a cliff rather than a slope, and the original comparison put the boundary value on the wrong side of it.

Exactly one figure was affected. Anybody at that precise number got the low rate when they should have had the high one. Every other input in the range was correct, which is why it survived a review: the calculation was right everywhere you would think to look.

This is a <= where a < belonged. It is the oldest bug in software and it will outlive all of us.

But notice what determinism did buy. The bug was findable, because the rule is written down in one place in a language that supports being read. It was fixable in a single character. And once fixed, it was fixed for every letter, retroactively provable by running the old inputs again.

Had that logic lived in a prompt, the same defect would have presented as: it is usually right near that boundary. Which is not a bug report anyone can act on, and not something you can prove you have fixed.

That is the actual trade. Not determinism versus accuracy. Determinism versus debuggability. A deterministic component that is wrong can be found and repaired. A probabilistic component that is usually right cannot be, because there is no defect to locate.

Where the model earns its place

I want to be careful not to argue for less AI here, because this system is full of it and it belongs where it is.

The model reads the recruiter’s document, which arrives in whatever shape a human found convenient. Sometimes a table, sometimes a paragraph, sometimes both contradicting each other. That is a genuinely hard problem with no deterministic solution, and it is exactly what a model is for.

The model also writes the language, refines the responsibilities into consistent phrasing, and compresses them to fit the space in the template. Also hard, also right.

The split is not AI versus code. It is: judgement about ambiguous input goes to the model, arithmetic with a legal consequence goes to code. Both are in the same application, three steps apart.

The line between them is not about difficulty. Reading a badly formatted document is harder than the arithmetic. It is about what happens when it is wrong, and who finds out.

The question I ask now

I have started asking one thing on every engagement where a model is going near a business rule.

If this is wrong, who discovers it, and when?

If the answer is a developer, during testing, put it wherever is convenient. If the answer is a customer, weeks later, in a document they cannot amend, it does not go near a model, no matter how good the model has become.

That question has moved more architecture in the last year than any capability comparison has. It also does not go stale, which most of my opinions about models do within about six months.

The couple of hundred lines shipped. The offer letters have balanced ever since, including the one that was wrong by a single character at exactly one income, which we found, fixed, and could prove we had fixed.