Part 24 of 39
The Type Error
By Madhav Kaushish · Ages 10+
The encoding system was working. Records were richer, insurance claims were accurate, and Glagalbagal could now answer questions like "how many breeding cattle are at Location 3?" that would have been impossible six months earlier. Then Drstvjek happened.
The New Velociraptor
Drstvjek was a young velociraptor recently assigned to the record cave. He had been trained on the basic procedures — how to read binary, how to carry between baskets, how to follow instruction tablets. He had not been trained on the encoding system, because Glagalbagal had assumed — incorrectly — that Blortz would handle the orientation.
Blortz had assumed Glagalbagal would handle it. Neither had.
Drstvjek's first task was a routine one: consolidate the monthly counts from all four locations into a single summary record. The instruction tablet for this procedure said:
Step 1: Read the count field from each location's monthly record. Step 2: Add the counts together using the addition tablet. Step 3: Write the total in the summary record.
The instruction tablet had been written before the encoding system existed. It said "read the count field" but did not specify which positions in the record constituted the count field. In the old system, the entire record was the count. In the new system, the count occupied positions 12-19, and positions 1-11 contained codes for location, date, and animal type.
The Corruption
Drstvjek, not knowing about the encoding system, treated the entire record as a count. He read positions 1 through 19 as a single binary number. The location code, the date code, and the animal type code were all interpreted as part of the quantity.
Location 2's record for the current month had the following pattern:
Positions 1-4 (location): 0010 (Location 2). Positions 5-8 (date): 1011 (month 11). Positions 9-11 (animal type): 001 (sheep). Positions 12-19 (count): 01010010 (eighty-two).
Drstvjek read the entire sequence — 0010101100101010010 — as a single number. In binary, that number was enormous: over a hundred and seventy thousand. He dutifully carried this through the addition tablet, combining it with similarly misread records from the other locations.
The resulting "total" was a number so large that it overflowed the summary record's baskets. Drstvjek, following the carrying procedure, propagated pebbles through every basket on the summary shelf. Adjacent records — which happened to share the same physical shelf — had their baskets disturbed by the overflow.
By the time Blortz noticed, the summary shelf contained one absurd total and three corrupted adjacent records whose pebble arrangements no longer corresponded to anything real.

The Diagnosis
Blortz: The summary says we have one hundred and seventy-two thousand animals.
Glagalbagal: We have four hundred and eleven.
Blortz: Drstvjek read the entire record as a number. The location code, the date, the animal type — he added them all as if they were part of the count.
Glagalbagal: The instruction tablet says "read the count field."
Blortz: The instruction tablet does not say where the count field starts. It was written when the count was the only thing in the record. Now the record contains six different kinds of information, and nothing on the record itself tells you which positions are which.
The problem was clear. The record was a sequence of baskets. Every basket looked the same — it either had a pebble or it did not. There was no physical difference between a basket that was part of a location code and a basket that was part of a count. The only way to know which was which was to know the encoding scheme. Drstvjek did not know the encoding scheme. The record itself did not declare its encoding scheme. And the instruction tablet did not specify it.
The Header
Glagalbagal's fix was to make the record self-describing. He added a header to the beginning of every record — a short sequence of baskets that declared what the record contained and where each field started.
The header format was:
Positions 1-3: Number of fields in this record (binary). For each field: - 3 baskets: field type code (what kind of information). - 4 baskets: field length (how many baskets this field occupies).
The field type codes were:
000: Location identifier. 001: Date. 010: Animal type. 011: Quantity (count). 100: Status code. 101: Manager identifier.
A velociraptor reading a record would first read the header, learn how many fields existed and what type each one was, and then read each field according to its declared type. Crucially, the instruction tablets were updated to say not "read the count field" but "read the header, find the field of type 011, and read it as a quantity."
The addition instruction could now include a check: before adding two fields, verify that both are of type 011 (quantity). If a velociraptor tried to add a location code to a count, the type check would fail, and the velociraptor would stop and flag the error rather than producing a meaningless result.
The Cost
The headers added overhead. Every record was now longer — the header itself consumed ten to twenty baskets, depending on the number of fields. For a record with six fields, the header was nearly as long as the data. Blortz calculated that the cave's total pebble usage had increased by roughly a third.
Blortz: One-third of our pebbles now describe what the other two-thirds mean.
Glagalbagal: Is that too much?
Blortz: It is the cost of preventing another Drstvjek. Consider the alternative: three corrupted records and a summary that claims we own a hundred and seventy thousand animals. The insurance collective would have had questions.
The tradeoff was real. More pebbles meant more shelf space, more carrying, more time per record. But the alternative was a system where a single misinterpretation could cascade into corrupted data. The headers made errors detectable before they became catastrophic.
The Instruction Tablet Update
The deeper fix was to update every instruction tablet to be type-aware. The old addition tablet said:
Read the first arrangement. Read the second arrangement. Add them.
The new version said:
Read the first arrangement. Verify its type is 011 (quantity). Read the second arrangement. Verify its type is 011 (quantity). If both are quantities, add them. If either is not a quantity, stop and place a red marker stone on the error shelf.
The red marker stone was Blortz's invention — a physical error flag that indicated something had gone wrong. A velociraptor encountering a red marker stone would stop the current procedure and consult the error-handling tablet, which generally said: report the error and do not proceed.
Glagalbagal: We now have instruction tablets that spend as much time checking whether they should do something as actually doing it.
Blortz: Welcome to reliability.