Tool Library: Choose Storage by What It Must Promise
Design problem and decision
- Design problem Each feature saves something different: a loan book read in date order, a shelf per branch, a published catalog, a history that only grows, and a question that only needs "probably".
- Viewer's decision For each feature, what must the stored data promise, and which storage makes that promise?
- Outcome The viewer can write a storage requirement as three lines, holds, answers and costs, and match it to one of five choices. They can say that Nyxus or Hylix is chosen per module memory, that Minima collections are experimental and live inside a Nyxus memory, and that every collection needs a bound set by the app.
- Starting point Lesson 4 left the app running on release 2.
- Handoff Lesson 6 shows that every choice made here becomes part of a contract.
- Pacing Four and a half minutes.
Worked design
Tool Library is illustrative. Two of the five choices are already in the app. Three belong to features on its roadmap, drawn as outlined capsules beside the tree. The roadmap features are not part of releases 1 to 3.
| Feature | Must promise | Choice | Status in the SDK |
|---|---|---|---|
| Overdue list (Loans) | Exact. Oldest due day first. | Nyxus Map keyed by (due day, loan) |
Current |
| Branch shelves (Branches) | Each branch sealed, removed as a whole | Keyed child modules | Current |
| Model catalog (roadmap) | Same table for every reader until the next publication | Minima FrozenSortedMap |
Experimental |
| First-time borrower check (roadmap) | "Never borrowed this tool" must be certain. "Borrowed before" may be checked. | Minima BlockedBloomFilter in front of an exact map |
Experimental |
| Loan history (roadmap) | Keeps every returned loan. Grows without end. Rarely read. | A memory declared on Hylix | Current, harder to write for |
Numbers used on screen:
- Day 120. All five open loans are overdue: (103, 3), (105, 5), (108, 4), (110, 6), (114, 7).
overdue(120, start, 2)returns the first two and the key to continue from. - Catalog season 1: model 1700 → deposit class 2, model 2200 → class 1, model 3000 → class 1. Season 2 adds model 4000 → class 3.
- First-time check: member 502 and tool 17 answers "maybe", and the history confirms yes. Member 502 and tool 22 answers "no".
The story in one pass
Lay out five cards beside the app. Fill each one from the feature's promise, then name the storage. Walk the overdue list in order and stop at a page limit. Recall the shelves. Publish a catalog as one piece and replace it as one piece. Ask a filter a question and confirm its yes. Put the growing history on a different engine. Close on the three things that apply to every card.
Views and visual objects
Use the shared visual language. This film introduces ChoiceCard.
| View | Framing and anchor |
|---|---|
board |
The fixed app layout at left, slightly reduced. A column of five ChoiceCards at right. Three outlined roadmap capsules, Catalog, Seen and History, sit between the tree and the cards, unattached. |
card_close |
One card and the vault it points to, enlarged. |
Each ChoiceCard has a title and three rows:
holds what is saved
answers which questions, and how exactly
costs what the app must accept
Scene exact_and_owned — Choices already in the app
Already on screen The app on release 2, values as at the end of lesson 4.
Beat board — A promise before a structure
View and focus board.
Narration
Every vault holds some kind of collection. We do not start from a list of data structures. We start from what the feature must promise. What does it hold? Which questions must it answer, and how exactly? What are we willing to accept in return?
Cue and animation On “Every vault”, each vault table pulses. On “what the feature must promise”, five empty cards draw at right. On “What does it hold”, “Which questions” and “willing to accept”, the row labels holds, answers, costs appear on every card.
Leaves with Five empty cards.
Beat due_dates — Exact and in order
View and focus card_close on card 1 and the Loans vault.
Narration
Staff need the overdue list, oldest first, and it must be exact. So the loan book is an ordered map, keyed by due day and then loan number. The list is a walk from the start of the map up to today. It answers in pages. Each page returns two loans and the key to continue from. The next call starts there. The map can change between calls, so a page is never a saved copy.
Cue and animation On “oldest first”, the Loans rows sort visibly by key: (103,3) (105,5) (108,4) (110,6) (114,7). On “ordered map”, card 1 fills: holds: open loans / answers: exact, in due order, by range / costs: bounded pages, at most 10,000 open loans. On “up to today”, a marker day 120 sits below the last row. On “two loans”, a bracket takes the first two rows and an OutcomeCard shows [3, 5], next (105, 5). On “starts there”, a second bracket takes the next two. On “never a saved copy”, row (108, 4) flickers once.
Leaves with Card 1 filled and joined to the Loans vault by a leader.
Beat shelves — One module per branch
View and focus card_close on card 2 and the Branches fan.
Narration
The second choice we already made. Each branch owns its shelf as a module. The promise is the seal and the whole-branch lifetime. The cost is a limit on branches and a rule for closing one.
Cue and animation On “owns its shelf”, card 2 starts to fill: holds: one Shelf per branch. On “The promise”, it adds answers: only through Branches, by number. On “The cost”, it adds costs: at most 32, closing removes everything, and the ribs 3 and 5 pulse.
Leaves with Cards 1 and 2 filled.
Scene whole_and_approximate — Two roadmap features
Already on screen board with two filled cards. Roadmap capsules outlined.
Beat catalog — Published as a whole
View and focus card_close on card 3 and the Catalog outline.
Narration
Next season the library publishes a catalog: model number to deposit class. Every reader must see the same table until the next publication. Nobody edits one line. So the catalog is a frozen table. It is built once from the full sorted list. To change it, we build a new one and swap it in. The price is fixed-size entries. A number fits. A free-text description does not, and would live in an ordinary map.
Cue and animation On “model number to deposit class”, three rows appear in the Catalog outline: 1700 → 2, 2200 → 1, 3000 → 1, and a thin band closes around them as one block. On “Nobody edits one line”, a grey pill set(2200, 3) stops at the band. On “build a new one”, a second block with four rows, adding 4000 → 3, assembles beside the first. On “swap it in”, the blocks trade places and the old one fades. Card 3 fills: holds: model → deposit class / answers: exact lookups and ordered scans / costs: fixed-size entries, rebuild to change, experimental. On “does not”, a small tag description: text bounces off the block.
Leaves with Card 3 filled. Catalog block shows four rows.
Beat borrowed_before — A no is exact, a yes needs a check
View and focus card_close on card 4, the Seen outline and the History outline.
Narration
Desk asks for a safety briefing until a member has completed a loan of that kind of tool. The filter covers every completed loan in the exact history. Ask about a ladder. It says no. Briefing required. Now ask about the drill. The filter says maybe. Desk checks the exact history and finds a completed loan. No briefing required for the drill. This filter only gains entries.
Cue and animation On “filter covers every completed loan”, show a single filter glyph with a leader to History. On “about a ladder”, the pill seen(502, 22) enters the filter and returns no in a solid outline. On “Briefing required”, an OutcomeCard BriefingNeeded leaves. On “about the drill”, seen(502, 17) returns maybe in a dashed outline. On “checks the exact history”, the pill continues into History and returns found. Card 4 fills with holds: marks for (member, tool), answers: no or maybe, and costs: keep exact history, add only, experimental. On “only gains entries”, show the filter accepting a new pair.
Hold PauseAndExplain pointing at the dashed maybe. The balloon reads:
Approximate answers come in two kinds
a filter its yes can be confirmed against exact data
a counter "about 240 different borrowers" cannot be confirmed
Use the second only where an estimate is the requirement.
Leaves with Card 4 filled.
Scene engines — Where a whole memory lives
Already on screen board with four filled cards.
Beat history — A different engine for one module
View and focus card_close on card 5 and the History outline.
Narration
History records completed loans for later lookup. It grows faster than the active loan book. We want those records in stable memory, so History selects Hylix for its memory declaration. Loans keeps its own storage choice. History's implementation has an extra responsibility. It must explicitly transfer or retire each stored value it removes.
Cue and animation On “grows faster”, rows stack in the History outline and scroll. On “selects Hylix”, the History tab reads v1 · hylix. On “its own storage choice”, the Loans tab v1 pulses. Card 5 fills with holds: completed loans, answers: exact, by loan number, and costs: explicit ownership of stored values. On “transfer or retire”, a stored-value token follows the handoff to its destination.
Leaves with Five filled cards.
Beat status_and_bounds — Three things on every card
View and focus board. PauseAndExplain pointing at the column of cards.
Hold The balloon reads:
Engine Nyxus by default. Hylix where one module asks for it.
Minima experimental collections inside a Nyxus memory,
with one-time setup in the root
Bound the app sets a limit on every collection
Speed not promised by any choice. Measure your own load.
Narration
Three things apply to every card. Each module memory picks its engine, and the default is fine until a requirement says otherwise. The frozen table and the filter come from Minima, which is experimental and needs setup in the root. And every collection gets a limit, written in the brief. None of these choices is a promise of speed. That, you measure on your own data.
Cue and animation All motion holds. The balloon opens on “Three things apply”, and its rows appear in step. On “experimental”, cards 3 and 4 show a small experimental tag. On “a limit”, the costs row on every card underlines its number. On “a promise of speed”, the last balloon row appears.
Leaves with The app and five filled cards. Lesson 6 opens on the vaults' v1 tabs.
Brief to hand over
Illustrative.
Loans. An exact map ordered by (due day, loan number). At most 10,000 open loans.
overdue(today, after, limit)returns at mostlimitloans due beforetoday, in order, starting after the keyafter, plus the key to continue from.limitis at most 50.Catalog, roadmap. A frozen sorted table from model number to deposit class, both fixed-size numbers.
publish(list)refuses an unsorted list or a duplicate model, builds a new table and replaces the old one whole. No single-entry edit exists. Uses the experimental Minima library. Ask for its root setup.First-time check, roadmap. A filter over (member, tool) built from the exact completed-loan records. Each history update includes its filter update. A "no" returns
BriefingNeededif the filter covers the current history. A "maybe" needs exact confirmation. Use the exact history during a rebuild. Uses the experimental Minima library.History, roadmap. Its own module on Hylix. Adds completed loans and reads by loan number. Decide the capacity and how the app keeps the history it promises before the feature ships.
Acceptance test, expected and not run
| Given | Command | Expect |
|---|---|---|
| five loans above, day 120 | overdue(120, start, 2) |
[3, 5], next (105, 5) |
| same | overdue(120, (105, 5), 2) |
[4, 6], next (110, 6) |
| loan 4 returned between the two calls | overdue(120, (105, 5), 2) |
[6, 7], no next |
| same, day 104 | overdue(104, start, 50) |
[3] |
| season 1 catalog | deposit_class(2200) |
1 |
| season 1 catalog | publish with 4000 before 3000 |
refused, catalog unchanged |
| season 2 published | deposit_class(4000), deposit_class(9999) |
3, none |
| History holds (502, 17) only | first-time check for (502, 22) | BriefingNeeded, History not read |
| same | first-time check for (502, 17) | no briefing, History read once |
| a filter "maybe" for a pair not in History | first-time check | BriefingNeeded |
The last row is the one that proves the confirmation exists. Build the filter small for this test so that false positives occur.
Production and source notes
- Tool Library and the three roadmap modules are illustrative. Keep the roadmap capsules outlined and unattached. They do not appear in lessons 6 to 8.
- Nyxus
Mapis a B-tree ordered by the key'sOrd, with range iteration. "Range iterators provide no persistent snapshot; client pagination should carry owned keys and bound the work per call." Collections, lines 16 to 17 and 29 to 32. A tuple of admitted values is itself admitted as saved data. Nyxus data, lines 200 to 210. - Engine per memory declaration, Nyxus default,
hylixoption: Engines, lines 5 to 14. Ahylixdeclaration: Hylix probe records, line 17. - Hylix ownership is explicit and a dropped owner can leak. Collections, lines 119 to 122. The status page calls it "a more demanding authoring model". Status, lines 43 to 46.
- The reason given for History is where its data lives. Nyxus data shares the canister's main memory, which has a fixed maximum. Keep the figure off screen. Runtime memory, lines 32 to 37. Hylix still keeps small anchors in main memory and uses the same upgrade path. Engines, lines 41 to 48.
- Minima is "an implemented experimental stable-storage foundation" and "not a third Memory selector". Minima guide, lines 3 to 8. Root setup and the rule of one stable provider: lines 196 to 202. A root that does this: Composition probe root, lines 31 to 53.
FrozenSortedMap: frozen ordered keys, duplicates reject,from_sortedrequires increasing keys.BlockedBloomFilter: "Additive approximate membership; positives require exact lookup; no deletion". "Frozen indexes are rebuilt for changed content; they do not support point insertion." Minima collections, lines 14 to 36.- Fixed-size entries: text has an exact byte width with no padding, and text up to a bound "is a different representation". Minima guide, lines 36 to 42.
- Confirming each filter positive with an exact lookup is how the Minima benchmark uses its filter. It also builds its frozen tables in one
freezestep. Minima benchmark tables, lines 62 to 124 and 453 to 490. - The counter in the balloon stands for
MinimaHll, whose "nominal error is statistical, not an exact-count guarantee". The figure 240 is illustrative. - Each populated Minima collection reserves whole storage blocks even when it holds little. Leave this in the notes. Say only "experimental" and "setup in the root" on screen.
- "None of these choices is a promise of speed" follows the guides: "Correctness, lifecycle support and performance are separate questions." Engines, lines 82 to 86.
- There is no native hash map, radix tree or spatial tree in the current library. Do not draw one. Collections, line 214.
- Draw no blocks, pages, nodes or byte widths. The band around the catalog is a single outline.