Cost-Margin Asymmetry

detected 2026-03-02

trigger

"computeCostGbp includes platform margin. computeCostUsd does not. Same file, side by side. Analytics and billing disagree on what 'cost' means."

what it is

Two functions in the same file compute costs from the same base pricing but apply business rules inconsistently. The billing function includes the 10% platform margin. The analytics function does not. A business analyst looking at PostHog would conclude margins are 0%. The LLM created both side by side, applied the margin to one and forgot it in the other because the second function has a different return shape that pulled attention toward structuring the return value rather than verifying the formula matched.

what it signals

Two functions in the same file that compute the same base value with different transformations applied. The inconsistency is invisible at the function level — each looks correct in isolation.

instead

Factor the base computation into a shared helper. Apply margin and currency as separate, composable transformations. The margin inclusion becomes explicit at each call site.

refs

  • wake:lib/credits.ts — computeCostGbp vs computeCostUsd

← all patterns