arborist/docs
russell@unturf.com 967fedbbe0
#000065: pin M=4 + bench script + SQLite-alternative decision tree
Pinned the canonical shard count at M = 4 based on real-Wikipedia
ingest + query benchmark (bench/shard_count_sweep.py). Captured the
"when does SQLite stop being the right substrate" decision tree so
future operators know what bench would justify a fork or replacement.

Bench numbers (Wikipedia 2003 cur dump, 2000 docs, 4 cells of
M ∈ {1, 2, 4, 8}, 50 FTS queries per cell):

     M   chunks/s    q_p50_ms    q_p99_ms   attach_ms
     1    3,648        0.05        0.20        1.61
     2    5,649        0.03        0.19        3.24
     4    6,405        0.07        0.30        9.00
     8    6,959        0.03        0.28        9.65

Key observations:
- M=1→M=2 is the biggest ingest win (+55%). Most gain happens there.
- M=2→M=4 is +13%. M=4→M=8 is only +9% — diminishing returns.
- Real wikitext canonicalization is per-worker Python CPU bound, not
  SQLite-writer-lock bound. More shards don't unlock more CPU.
- Query p50/p99 is flat across M within noise (50 queries small).
- ATTACH cost grows linearly: 1.6 / 3.2 / 9.0 / 9.7 ms.

Why M=4 specifically:
- Captures 92% of peak ingest throughput (6,405 / 6,959).
- 6 ATTACH slots free under SQLite's 10 ceiling for aux DBs
  (qa.db, snapshots.db, selfmodel-chain.db, crawl_*.db, future
  mesh_*.db) — comfortable headroom. M=8 leaves only 2 slots.
- Mobile-tolerable: phone NAND attach is 5-10x slower than NVMe;
  M=4 = 45-90 ms cold start (instant), M=8 = 50-100 ms (sluggish
  with no headroom).
- Matches fox's current 4-shard layout = cheapest migration.

Decision tree for when SQLite stops being right (full text in
ticket §"When the SQLite-default substrate stops being right"):

A. ATTACH ceiling pressure (auxiliary DBs grow past 5) → bench
   forked SQLite with SQLITE_MAX_ATTACHED=125, M ∈ {16, 32, 64};
   if attach cost stays linear past M=10, fork viable but pays
   permanent "no longer stock sqlite3" tax.

B. Ingest hits >10k chunks/s sustained ceiling → first tune
   page_size / WAL checkpoint / mmap_size / synchronous. If
   tuning gets 2-5x, stay on SQLite. If still ceiling-limited,
   candidates: DuckDB (columnar, MVCC, FTS), libmdbx (B+tree no
   FTS; we'd build it). In-house DB rejected without specific
   failure of those.

C. Federation needs multi-writer-same-shard → SQLite writer-lock
   serializes peers, becomes federation bottleneck. First try
   leader-election (single-writer-per-shard with WAL replication
   to followers). If true multi-writer required, SQLite is wrong;
   candidates: FoundationDB, CRDT-on-KV-store. DuckDB does NOT
   solve this — its MVCC is single-process.

Honest verdict: for current arborist workload (single-writer-per-
shard, read-mostly federation), stock python3 sqlite3 is the right
substrate. None of A/B/C are close to firing. The bench discipline
exists to know what to measure when something changes.

bench/results/shard-count-sweep-2026-05-26T16-20-48Z.csv (synthetic
baseline) + 2026-05-26T16-31-34Z.csv (real Wikipedia) committed as
the load-bearing measurement for the M=4 choice.
2026-05-26 12:40:48 -04:00
..
_source docs: 3 concepts diagrams + Python-library cookbook recipes 2026-05-24 14:12:26 -04:00
diagrams docs: 3 concepts diagrams + Python-library cookbook recipes 2026-05-24 14:12:26 -04:00
posts docs: draft COGS tweet — cost of a grounded answer (Hermes ~9c, Qwen ~16c per 1k) 2026-05-21 13:52:20 -04:00
tickets #000065: pin M=4 + bench script + SQLite-alternative decision tree 2026-05-26 12:40:48 -04:00
bench-maxing.md aborist/arborist 2026-05-07 09:31:49 -04:00
benchmark-matrix.md docs(#000057): capture known-good serving invocations for the salt buildout 2026-05-20 15:20:34 -04:00
benchmarks.md docs+code: ground §12 judge pipeline in the actual judge_code.py 2026-05-22 19:17:28 -04:00
calculator-test-patterns.md ticket #000036 Tier-2: dav1d Option B (conservative B1 envelope) applied in v1 2026-05-11 07:06:50 -04:00
cold-object-store.md #000061: pack format v2 — self-sufficient new-peer hydration 2026-05-25 22:21:45 -04:00
crawler.md docs: web crawler guide — discovery, fast mode, dedupe, orphans 2026-05-22 07:38:37 -04:00
cti-architecture.md aborist/arborist 2026-05-07 09:31:49 -04:00
embedding.md feat: arborist.embed — supported library-embedding surface 2026-05-22 13:03:15 -04:00
energy-cogs-benchmark.md docs(#000057): correct cost claim — <$0.10/1k-q is hermes-8B only, not qwen 2026-05-21 13:50:01 -04:00
lexical-first-rationale.md docs: lexical-first-rationale.md — why the cheap retrieval path is the default 2026-05-12 09:23:50 -04:00
mesh.md aborist/arborist 2026-05-07 09:31:49 -04:00
onnx-vendor-capture-immunity.md feat(#000049 §7 #28): tinygrad NLI backend + deterministic engine-agreement A/B; ONNX-immunity rationale 2026-05-19 12:34:04 -04:00
pager.style docs: arborist-one-pager + arborist-two-pager — Dav1d/fox-signoff summaries with letterhead, license, and 2 strategic appendix diagrams 2026-05-14 09:48:50 -04:00
pi-star-composition.md pi_star: land ticket #000015 (π* domain library + composition algebra) 2026-05-07 16:51:33 -04:00
qa-modes-bench.md docs(#000057): Addendum 8 — control sweep retrieval × model × framing × reasoning 2026-05-20 06:52:42 -04:00
relevance-and-veto-synthesis-for-dav1d.md docs: relevance-and-veto-synthesis-for-dav1d.md — single decision brief synthesizing #000049 + #000052 §3.1 + §3.2 for forward review 2026-05-13 15:34:21 -04:00
seven-point-program.md tests/doc_counts: regression test for numeric claims in docs/ (4x drift fix) 2026-05-10 16:15:52 -04:00
soft-hash-channel-analysis.md docs/#000018 §9.2: mark resolved — φ_PRG = HMAC-SHA-512 (#000035 closed) 2026-05-11 17:20:48 -04:00
soft-hash-channel-t3-bound.md ticket #000036: add KAT-regen tooling + close 2026-05-11 08:02:25 -04:00
spec-methodology.md docs: land ticket #000019 (spec methodology for π*, V, policy fields) 2026-05-07 16:53:28 -04:00
stock-v1-config.md fix(#000057): GPU COGS = generation only — retrieval/verify don't touch the card 2026-05-21 11:07:37 -04:00
TICKETS.md #000065: pin M=4 + bench script + SQLite-alternative decision tree 2026-05-26 12:40:48 -04:00
tool-action-dag-design.md docs: add tool-action-dag-design.md research path (pre-ticket) 2026-05-07 19:47:50 -04:00
v7w-frontier-catalog.md #000013 closed: v7-W spatial-temporal substrate paper + namespace 2026-05-09 15:00:05 -04:00
v8-fork-score.md CLI: arborist v8 score → arborist substrate score 2026-05-10 09:12:34 -04:00
warrant-substrate-cookbook.md docs: bump warrant-substrate-cookbook AUTOCOUNT 20 -> 28 for #000054 tests 2026-05-13 07:01:02 -04:00
zk-frontier-bench.md #000016 parked: ZK frontier-proof bench plan + wire protocol 2026-05-09 15:05:08 -04:00
zk-wire-protocol.md #000016 parked: ZK frontier-proof bench plan + wire protocol 2026-05-09 15:05:08 -04:00