Measured, not asserted

Does obfuscation break energy cost allocation?

A shared bill divided between tenants is always divided in full. That is a property of the code, not evidence about the division -- and it is why the check most people would run here cannot tell a correct split from one nobody chose.

The total is an invariant, not a result

A multi-tenant building has one meter for its common areas -- lifts, corridors, car park, plant -- and that bill is divided between the tenants on an agreed basis: leased area, submetered consumption, or an equal split. The engine measured here allocates in cents and lets the last tenant absorb the rounding remainder, which is how essentially every such engine is built, because a division that does not add back up to the bill is a defect nobody tolerates.

The consequence is that the allocated total equals the billed total on every basis, including bases that are wrong for this building. The sample prints that check on every run: allocated=$11,625.00 billed=$11,625.00 reconciles=true. It was true in every single arm measured, including the ones below where money moved between tenants.

Protection alone changed nothing here or in the four other areas, across all five presets.

The division changed and the books still balanced

The building's leases divide by area. One anchor tenant holds 24,000 of the 36,000 square feet; three small units hold the rest. On that basis the anchor pays $7,750.00 of the $11,625.00 bill and the cafe pays $1,033.33.

Renaming allocationBasis replaced the agreed basis with the library's equal-share default. Every tenant was then charged $2,906.25. The anchor tenant's share fell by $4,843.75 and the three small tenants paid that between them -- the cafe's bill nearly tripled. The total was $11,625.00 before and after, to the cent, and the reconciliation line still read true.

This is the shape worth taking away from the whole article. Every amount was correct. Every rate was correct. Nothing was unreadable, nothing was refused, no threshold was crossed, and the books balanced exactly. The only thing that moved was which population each correct rule was applied to, and money changed hands between four parties as a result.

A prediction that did not survive contact

Going in, the expectation was that renaming the record field the division reads -- areaSqft -- would produce the same collapse. It did not. The allocation stayed exactly correct, and the only thing that changed was the library's own display of the weights, which read g-01-anchor#undefined while every tenant was still charged the right amount.

The reason is that the caller supplies its own weighting rule, and that rule reads the field from records the caller also owns. Both sides were renamed together, consistently, so nothing crossed the boundary. The library only reads that field itself when it is computing the weights -- which happens when the basis check is off.

So the arm that actually takes the record-field route is the pair. With the basis check and the field renamed together, the division silently fell back to an equal split -- and this is the version that should worry anyone, because the configuration screen still read basis=submetered-area and still reported the caller's own weighting rule as installed and in use. The correct basis, named correctly, on screen, while the bill was divided a different way entirely.

It is worth recording that this cuts both ways. A configuration dump full of undefined values is not proof that a computation is broken -- in the first arm above, everything printed wrong and every tenant was billed correctly. And a configuration dump that reads perfectly is not proof that anything is right.

One rename, one building wrong and one building fine

The sample allocates the same bill twice: once on the area basis and once on the submetered-kilowatt basis some leases in the portfolio use. Renaming the weighting rule together with the area field left the first division as an equal split and the second one completely correct, because it reads a different field that the pattern did not reach.

That is a measurement warning as much as a finding. Spot-checking one building in a portfolio proves nothing about the others, even when they run identical code on the same day, because which records a rename touches depends on which fields those records happen to use.

The money, as everywhere else this pass, failed loudly. Renaming the common consumption or the rate produced ALLOCATED=false non-finite-common-bill(refused before allocation), and renaming the field the weights arrive in threw a TypeError before any tenant was charged. The engine's guard is on the amount, and the amount was never the thing at risk.

What to check instead of the total

Stop treating the reconciliation as evidence. It is worth running, because a division that does not add up is a real defect -- but it is closed by construction here, so it can only ever tell you the code still works, never that the division is the one the leases specify.

Check the shares instead. Each tenant's proportion of the bill is derivable from the lease independently of the billing code, and comparing the two is a few lines. An allocation where every tenant's share is within a rounding cent of every other tenant's is either a genuinely equal-share building or a fault, and the leases say which.

Make an unreadable weighting an error rather than a fallback. Falling back to an equal split is a reasonable-looking design decision that converts a loud failure into a silent transfer of money between customers, and refusing to allocate without a basis costs nothing.

And scope the rename pattern to names your own code owns on both sides. Every failure in this article needed a name to cross into code that was not rebuilt with the bundle -- and none of them could have happened to a pattern that stayed inside.

Frequently asked questions

Does obfuscation change how a shared bill is divided?

Not on its own. Protection alone left every measured output identical across five presets and five areas this pass. The differences here come from member renaming, which is opt-in and uses a pattern you write yourself.

What was the measured effect?

Renaming the option key naming the allocation basis replaced the leases' area basis with the library's equal-share default. One anchor tenant's share fell by $4,843.75 and three smaller tenants paid it between them.

Did the totals still add up?

Yes, exactly. The allocated total equalled the billed $11,625.00 to the cent in every arm measured, because the last tenant absorbs the rounding remainder. The reconciliation is closed by construction, so it cannot distinguish a correct division from an incorrect one.

Was the configuration screen wrong?

In the worst arm it was not. The screen still read the correct basis and still reported the caller's own weighting rule as installed and in use, while the bill was divided by an equal split instead.

Did renaming the record field alone break the division?

No, and that prediction failing is worth reporting. The caller's own rule reads that field from records the caller owns, so both sides were renamed together and nothing crossed the boundary. Only the pair -- the field and the basis check -- took the record-field route.

Can I spot-check one building to be sure?

No. In the measured pair one building's division collapsed to an equal split while a second building on a different basis stayed exactly correct, from the same rename on the same run.

What should be checked instead of the total?

Each tenant's share against the proportion their lease specifies, which is derivable without the billing code. Also treat an unreadable weighting as an error rather than falling back to an equal split, which quietly moves money between customers.

Related reading