C.W.K.
Stream
Lesson 02 of 05 · published

Cash Is Held, Not Derived

~10 min · ground-truth, authoritative-data, fallback-discipline, data-model

Level 0Open Gate
0 XP0/36 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete
"Some numbers you compute. Some numbers you're just told. Cash is one you're told — so believe it, don't recompute it."

The distinction that keeps the model honest

In Keep, an owner's stored cash balance is ground truth. It is a real, authoritative value that someone entered, and Keep treats it as the truth of the matter. It is not silently reconstructed from "seed amount minus total cost of positions." That reconstruction is tempting — the numbers usually line up — but the moment you compute cash instead of storing it, you've made cash a derived value that depends on every position row being complete and correct. One missing cost, one incomplete historical row, and your computed cash lies.

Ground truth vs derived, and why it matters

Every value in a system is one of two kinds. Ground truth is a fact someone asserted — it's authoritative by declaration. Derived is computed from other values — it's authoritative only if its inputs are complete. Cash is ground truth: it's held directly, and it wins. Family total is derived: it's computed from owners (previous track). The skill is knowing which is which, and never accidentally demoting a ground-truth value into a derived one because the formula 'usually works.'

Never recompute what you were authoritatively told. If a value was entered as fact, storing it and trusting it is more correct than deriving it from a formula that 'should' produce the same answer. The formula depends on complete inputs; the stored fact doesn't. When they disagree, the disagreement itself is the bug you want to see — not paper over.

The marked fallback — the one exception, made loud

There's exactly one time seed-minus-cost is allowed: an incomplete historical row where the stored cash was never captured. In that single case, Keep may fall back to the computed estimate — but it is clearly marked as a compatibility fallback, never presented as if it were the real stored value. The fallback is visible, not silent. You always know whether you're looking at cash that was told or cash that was guessed from an old row.

Make your fallbacks confess. A fallback that silently substitutes for real data is how 'roughly right' quietly becomes 'wrong and trusted.' A fallback that labels itself — 'estimated from seed minus cost; original cash not recorded' — lets the reader weight it correctly. The honest fallback is the one that admits it's a fallback.
One position per owner per ticker. The rest of the snapshot is just as flat: each owner holds one row per ticker — not a pile of lots to net together. That flatness is what makes the snapshot a snapshot. Stored cash and one-position-per-ticker are the two 'held' facts; everything else is computed on top of them.

Code

Stored cash wins; the fallback announces itself·python
def owner_cash(owner):
    row = cash_row(owner)
    if row is not None and row.balance is not None:
        # Ground truth: someone told us this. Believe it.
        return {"amount": row.balance, "source": "stored"}

    # ONLY for an incomplete historical row: a marked estimate,
    # never silently passed off as the real thing.
    est = seed(owner) - total_cost(owner)
    return {"amount": est, "source": "estimated:seed-minus-cost"}

# The caller can always see WHICH kind of number it got.
# 'stored' is trusted; 'estimated:*' is shown as a labelled fallback.

External links

Exercise

In a system you know, find a value that is sometimes stored and sometimes computed from a formula (a balance, a count, a total). Decide which should be ground truth. Then write the 'marked fallback' version: when the stored value is missing, compute an estimate BUT tag it so the caller knows it's estimated. Contrast that with the silent version and name the specific bug the silent version would hide.
Hint
The dangerous pattern is 'if stored is missing, just compute it and return it the same way.' The caller can't tell trusted from guessed. Add a source tag — 'stored' vs 'estimated' — and suddenly every downstream consumer can decide how much to trust the number.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.