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

Nine Is Seed, Not Cardinality

~9 min · seed-not-cardinality, dynamic-membership, replace, magic-numbers

Level 0Lone Machine
0 XP0/37 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete
"Nine is where the roll starts. It is not a number the code is allowed to believe in."

A starting count, not a shape

The fleet begins at nine Macs. That nine is inventory — a fact about today — not cardinality, a constant baked into the design. The moment a line of code assumes there are nine, a tenth machine becomes a bug instead of an enrollment. Seed numbers belong in the data; they must never leak into the schema.

Membership is dynamic by construction

The roll grows and shrinks through explicit transitions — add, suspend, retire, restore, replace. Crucially, the tenth Mac enrolls through the exact same contract that seeded the first nine. There's no special initial fleet path and a separate add one later path; there's one way in, used from the very first machine, so the hundredth is no more special than the second.

Replace: the role outlives the box

Hardware dies and gets swapped. replace_host_device deliberately moves a logical role onto new hardware while keeping both sides of the binding history — the old machine, the new one, and the fact that one took over from the other. The role (the always-on server) is durable; the physical box under it is replaceable. Confusing the two is how you lose a machine's history the day its logic board fails.

Roles are assigned, never inferred

A machine's role is policy you wrote, not a guess from behavior. Always-on server is a promise you made about that host — not whichever Mac happened to post the best uptime this month. Infer topology from who answered today, and your fleet's shape quietly rearranges itself every time the network hiccups.

Seed the data, not the schema. Any number your design is allowed to believe in is a number your design can't outgrow.

Code

One enrollment contract, from the first machine to the tenth·python
# The first nine were seeded through enroll_host -- the SAME call used
# for every machine after them. There is no separate 'initial fleet' path.
for mac in initial_nine:
    enroll_host(**mac)                    # seed inventory

enroll_host(host_id="new-mini", role="always_on")   # the 10th: identical path

# A hardware swap keeps the role and both sides of the binding history:
replace_host_device(host_id="server", new_hardware_id="...")
#   the logical 'server' role continues; the old box is retained in history.

# Nowhere is there an `assert len(fleet) == 9`. A count baked into the
# schema is a fleet that cannot grow -- and it always breaks on the day
# you finally add the machine that makes it wrong.

External links

Exercise

Find a place in something you've built where a count is hardcoded — a fixed-size array, a 'top 5', an assumed number of servers. Ask what happens on the N+1th. Rewrite one so the number lives in the data instead of the code, and note what got easier.
Hint
The tell is any literal that describes 'how many of a thing there are.' If adding one more of that thing requires editing code rather than adding a row, the count is in the wrong layer.

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.