What does Lazy Tool Hubs conclude, in numbers, about “Closing the Loop: a Monthly Report on Catalogue Layering and Call Frequency”?
Answer: Chapter 8 gives a monthly report on catalogue layering and call frequency, the distilled "Tool Routing-Tree Cost Calculator", a pre-registered test plan and the conditions that would overturn the book. Marked boxes separate published evidence, runnable Python calculations (17 programs), classical sources and the author's hypotheses.
Scope of the numbers: Selection accuracy lacks reliable peer-reviewed primary evidence and is demoted to an author's hypothesis. Marked boxes separate published evidence, runnable Python calculations (17 programs), classical sources and the author's hypotheses.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python only
calls 2400, leaf tools 160, called at least once 48, dormant 112 entropy 3.716 bits; 8-ary layout 1.343 decisions (bound 1.239) session tokens: flat 80000, lazy 4875.0 pin if P(called in a session) > 0.862: gate share 0.300 P(session) 0.986 PIN kit_run share 0.154 P(session) 0.865 PIN kit_info share 0.105 P(session) 0.735 route price_calc share 0.084 P(session) 0.653 route held-out gain of a rebuild 0.118 decisions: REBUILD
Show the full program
# Chapter 8. p81: a monthly layering report for a private tool hub.
# Catalogue shaped like the case of this book: 11 top-level tools, one
# of which (book_tool) routes to 150 distilled book tools. The month's
# call log is SYNTHETIC (seeded shares, 2400 calls), not usage data.
# Steps: count, smooth (add one), entropy, 8-ary Huffman layout, flat
# versus lazy session tokens (C = 500, S = 25, HOP = 80, M = 12 calls),
# pin list (P(called in a session) > C / (HOP + C)), dormant tools,
# and a held-out check whether last month's layout (built when the
# book-tool ranking was reversed, illustrative) should be rebuilt.
import heapq
import math
import random
rng = random.Random(20261113)
C, S, HOP, M, K, CALLS = 500, 25, 80, 12, 8, 2400
TOP = ["gate", "kit_run", "kit_info", "price_calc", "canon", "redlines",
"book_tool", "arena", "radar", "prune", "tollbooth"]
BOOK = ["book%03d" % i for i in range(1, 151)]
def zipf(n, a):
w = [1.0 / (i ** a) for i in range(1, n + 1)]
t = math.fsum(w)
return [x / t for x in w]
def huffman(p, k):
items = [(x, i, i) for i, x in enumerate(p)]
seq, pad = len(p), 0
while (len(items) + pad - 1) % (k - 1):
pad += 1
for _ in range(pad):
items.append((0.0, seq, None))
seq += 1
heapq.heapify(items)
while len(items) > 1:
kids = [heapq.heappop(items) for _ in range(min(k, len(items)))]
node = tuple(c[2] for c in kids if c[2] is not None)
heapq.heappush(items, (math.fsum(c[0] for c in kids), seq, node))
seq += 1
return items[0][2]
def walk(t, p, d, inner, depth):
if isinstance(t, int):
depth[t] = d
return p[t]
m = math.fsum(walk(c, p, d + 1, inner, depth) for c in t)
inner.append((m, len(t), d))
return m
def layout(p):
inner, depth = [], {}
walk(huffman(p, K), p, 0, inner, depth)
return inner, [depth[i] for i in range(len(p))]
def session(p, inner):
terms = [(1.0 - (1.0 - x) ** M) * (HOP + C) for x in p]
for mass, k, d in inner:
terms.append(k * S if d == 0 else
(1.0 - (1.0 - mass) ** M) * (HOP + k * S))
return math.fsum(terms)
names = [t for t in TOP if t != "book_tool"] + BOOK
top = zipf(len(TOP), 1.0)
bshare = top[TOP.index("book_tool")]
true = [top[TOP.index(t)] for t in TOP if t != "book_tool"]
true += [bshare * x for x in zipf(len(BOOK), 1.2)]
n = len(names)
calls = rng.choices(range(n), weights=true, k=CALLS)
cnt = [0] * n
for c in calls:
cnt[c] += 1
est = [(c + 1) / (CALLS + n) for c in cnt]
inner, dep = layout(est)
h = -math.fsum(x * math.log2(x) for x in est)
print("calls %d, leaf tools %d, called at least once %d, dormant %d"
% (CALLS, n, len([c for c in cnt if c]), len([c for c in cnt
if not c])))
print("entropy %.3f bits; 8-ary layout %.3f decisions (bound %.3f)"
% (h, math.fsum(x * d for x, d in zip(est, dep)), h / 3))
print("session tokens: flat %d, lazy %.1f" % (n * C, session(est, inner)))
gate = C / (HOP + C)
print("pin if P(called in a session) > %.3f:" % gate)
for i in sorted(range(n), key=lambda i: -est[i])[:4]:
pc = 1.0 - (1.0 - est[i]) ** M
print(" %-10s share %.3f P(session) %.3f %s"
% (names[i], est[i], pc, "PIN" if pc > gate else "route"))
# 上月布局:假设上月最热的书中小工具排序与本月相反(示意漂移)
last = true[:len(TOP) - 1] + [bshare * x for x in
zipf(len(BOOK), 1.2)[::-1]]
odd = [(c + 1) / (CALLS // 2 + n) for c in
[calls[1::2].count(i) for i in range(n)]]
even = [(c + 1) / (CALLS // 2 + n) for c in
[calls[0::2].count(i) for i in range(n)]]
gain = math.fsum(x * d for x, d in zip(even, layout(last)[1])) - \
math.fsum(x * d for x, d in zip(even, layout(odd)[1]))
print("held-out gain of a rebuild %.3f decisions: %s"
% (gain, "REBUILD" if gain > 0.02 else "keep layout"))Single source and citation
Fan, Y. (2026). A Lazy-Loading Private Tool Hub: Near-Zero Opening Context for Hundreds of Checkers and On-Demand Routing Trees (Version 1.0.0), Chapter 8: Closing the Loop: a Monthly Report on Catalogue Layering and Call Frequency. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-257 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026257,
author = {Fan, Yafu},
title = {A Lazy-Loading Private Tool Hub: Near-Zero Opening Context for Hundreds of Checkers and On-Demand Routing Trees},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · The Linear Bill: Context Cost of Loading Everything and the Entropy Bound
- Chapter 2 · Building Huffman Trees: Many-Way Merging, Dummy Leaves and the Price of a Menu
- Chapter 3 · Navigable Trees: the Price of Alphabetic Order and the Accumulation of Wrong Turns
- Chapter 4 · The Branching Factor: Depth against Width, and Hanging Popular Tools on the Root
- Chapter 5 · Queueing with Cold Starts: the Delay Bill of Lazy Loading and How Long to Stay Warm
- Chapter 6 · Frequency Drift: the Cost of Wrong Frequencies and When to Rebuild the Routing Tree
- Chapter 7 · Classical Sources East and West: Offices and Duties in the Rites of Zhou and Dewey's Decimal Scheme