# Token-Optimization Techniques — Research Dossier (https://jackin.tailrocks.com/reference/research/token-optimization-techniques/)



# Token-Optimization Techniques — Research Dossier [#token-optimization-techniques--research-dossier]

Definitive research dossier on extreme token-optimization **techniques** for coding-agent usage at zero quality
loss. Every external claim carries a source URL; every local number carries its method.
Specification: [`prompt.md`](prompt/). This dossier is one of three separated researches: techniques (this folder), the [token-optimization tools hub](/reference/research/token-optimization-tools/) (per-tool teardowns, including the former Volume III chapters, now tools-hub chapters [19 — Code-intelligence tools](/reference/research/token-optimization-tools/19-code-intelligence-tools/) through [25 — sem and mq](/reference/research/token-optimization-tools/25-sem-and-mq-structural-and-markdown-retrieval/)), and the [jackin❯ Context Engine spec](/reference/research/jackin-context-engine/).

## Headline numbers [#headline-numbers]

* **10x verdict: not defensible at zero quality loss today.*&#x2A; Defensible: **≈2.5x*&#x2A; with
  validation (Aggressive stack; ≈2.4x on code-heavy mixes), **≈5–6.2x** if the Sonnet-main+advisor routing flip passes the
  harness on your tasks. Binding constraints: frontier-model thinking output, then the
  cache-read floor of genuinely-used context. (15)
* Where money went in the measured heavy session: &#x2A;*cache reads 32% / cache writes 29% /
  thinking \~20% / visible output \~17% / uncached 2%**; an independent session measured
  output-heavy instead. Stable invariant: cache reads dominate token volume, while output +
  cache writes dominate dollars. (02, 28)
* **Defaults already bank \~4–5x**: caching measured −86.3% input-side this very session; MCP
  schemas defer by default; Edit-diffs are default. Much of the market re-sells these. (07, 06)
* Caveman-ultra measured &#x2A;*58.5%** token cut on visible prose (claims say 65–75%); wenyan's
  80.9% char cut collapses to 56.6% tokens. Style compression caps at \~17% of dollars — and at
  **1.4–1.5% of visible output** in tool-heavy sessions. (02, 04)
* Strongest sanctioned lever on thinking: **effort** (T1: Opus 4.5 medium = equal SWE-bench at
  **76% fewer output tokens**). Strongest input lever: context architecture (tool search &#x2A;*85%**
  cut with accuracy &#x2A;*49%→74%**; context editing &#x2A;*84%*&#x2A; cut with &#x2A;*+29%** performance). (09, 06)
* Fable 5/Opus 4.8 tokenizer bills **\~30% more tokens** on English/ASCII-heavy text, but the
  premium is near-neutral on code/CJK probes — cross-tier routing saves list price on code-heavy
  work (Fable→Sonnet ≈ ÷3.3) and up to ≈÷4.3 on prose/markdown-heavy text. (05, 10, 28)

## How to read [#how-to-read]

* Start: [00 — Executive Summary](/reference/research/token-optimization-techniques/00-executive-summary/) — the stack, the math, the
  verdict, the graveyard.
* Foundations: [01 — Token Economics and Measurement](01-economics-and-measurement/) economics + instruments,
  [02 — Baseline Audit of This Environment (Phase 0)](02-baseline-audit/) measured baseline of this environment,
  [03 — Prior art and market scan](03-prior-art-and-market-scan/) market scan (incl. operator-named caveman / cavemem /
  cavekit / fff).
* Research areas `04`–`14`: one file per area, every technique in a fixed record schema
  (110 techniques cataloged, all with validation protocols).
* Synthesis: [15 — Composed Stacks: Conservative / Aggressive / Unbelievable](15-composed-stacks/) composed stacks with dollar math,
  [16 — Validation Harness: the No-Quality-Loss Proof Protocol](16-validation-harness/) runnable no-quality-loss protocol,
  [17 — Adoption Roadmap: Day 1 / Week 1 / Month 1](17-adoption-roadmap/) day-1/week-1/month-1 with automatic-vs-disciplined split.

## Numbering map [#numbering-map]

All dossier files were renumbered to a strictly sequential scheme on 2026-07-05, and every in-prose file reference in this research now uses the new numbers. The frozen brief ([`prompt.md`](prompt/)) and any external citations written before that date still use the original scheme — translate via the table below (files `00`–`03` are unchanged).

| Old | New |
| --- | --- |
| 10  | 04  |
| 11  | 05  |
| 12  | 06  |
| 13  | 07  |
| 14  | 08  |
| 15  | 09  |
| 16  | 10  |
| 17  | 11  |
| 18  | 12  |
| 19  | 13  |
| 20  | 14  |
| 30  | 15  |
| 31  | 16  |
| 32  | 17  |
| 40  | 18  |
| 41  | 19  |
| 42  | 20  |
| 43  | 21  |
| 44  | 22  |
| 45  | 23  |
| 46  | 24  |
| 47  | 25  |
| 48  | 26  |
| 49  | 27  |
| 50  | 28  |

The former Volume III chapters 51–57 left this dossier entirely and now live in the [token-optimization tools hub](/reference/research/token-optimization-tools/) as chapters [19 — Code-intelligence tools](/reference/research/token-optimization-tools/19-code-intelligence-tools/) through [25 — sem and mq](/reference/research/token-optimization-tools/25-sem-and-mq-structural-and-markdown-retrieval/).

## Tier list [#tier-list]

`value = expected $ saving on the modeled profile × confidence (evidence tier) ÷ adoption effort`

| Tier  | Techniques (file)                                                                                                                                                                                                                                                                                                                                                     |
| ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **S** | Tool search / MCP schema deferral (06) · context editing + observation masking (06/08/12) · effort tiering incl. max→high (09) · subagent model+effort pinning (10) · Edit-over-Write + no-restatement guards (09) · advisor-pattern escalation (10) — *all NEGATIVE-COST or vendor-validated*                                                                        |
| **A** | Cache hygiene: task-boundary model/effort switching only (10/07) · batch lane for offline work (12) · repo-maps/outlines instead of file dumps (06) · structured-output sidecars (09) · state-file session resume (08) · register compression in chat-heavy workflows (04)                                                                                            |
| **B** | Structured-data format choice — CSV/compact lines/TOON (05) · pointer architecture & lazy instruction loading (08) · session codebooks (14) · ID/timestamp hygiene — epoch, surrogate IDs (05) · hook dedup and prefix audits (02/06) · CI token-budget linter (14)                                                                                                   |
| **C** | Register compression in tool-heavy workflows — ceiling \~0.4% of output (02/04) · identifier-casing policy, design-time only (05) · instruction-side register compression — 50x less valuable per token than output side (04) · prefill for non-thinking sidecars, dying (09)                                                                                         |
| **F** | Wenyan registers — no token gain over ultra, higher risk (02/04) · LLMLingua-style proxy for coding (13) · semantic response caches for agents (08) · cache-keepalive pingers for Claude Code (14) · base64/gzip "compression" — costs 2.7–4.3x MORE (13) · cl100k-based "Claude calculators" (05) · max\_tokens as an optimizer (09) · glyph/symbol prompt DSLs (04) |

## Assumptions (judgment calls made during the run) [#assumptions-judgment-calls-made-during-the-run]

1. **All "current" claims were verified against live provider documentation.**
2. No `ANTHROPIC_API_KEY` present; the free `count_tokens` endpoint was called with the Claude
   Code OAuth credential already on this machine (no billable usage). The brief explicitly
   mandates count\_tokens use.
3. Only this run's transcripts existed locally; thinking-share and session decomposition are
   n=1-environment measurements (max-effort main loop + a 25-agent fleet), labeled as such
   wherever used.
4. "Deliverables exactly as specified" = the 19 files of §10 and nothing else in the folder;
   measurement scripts are embedded in reports as reproducible snippets.
5. **Operator mid-run instructions** were folded in: (a) cavemem / cavekit / fff and the
   industry-standard/proven/engineer-verified buckets → [03 — Prior art and market scan](/reference/research/token-optimization-techniques/03-prior-art-and-market-scan/);
   (b) the request to "add this to token-optimization.md" was interpreted as the
   dossier (the brief forbids modifying pre-existing repo files, including the brief itself);
   (c) chat output kept in caveman-ultra; dossier files follow the brief's own writing rules
   (plain language, full sentences) as the deliverable spec.
6. **Heavy-day profile band**: $17/day (5 sessions, 45% thinking) floor and $22/day (6 sessions,
   55% thinking) working figure; area files and stack math use $22; ratios are
   profile-invariant. (01 §5)
7. Mid-run, five workflow draft agents died on a session rate limit (reset 19:20 UTC); the run
   continued on usage credits per the operator's local action. [11 — Multi-agent protocols](/reference/research/token-optimization-techniques/11-multi-agent-protocols/) and [14 — Frontier](/reference/research/token-optimization-techniques/14-frontier-ideas/) were re-drafted
   from the already-completed research JSON by follow-up agents.
8. An environment quirk repeatedly deleted freshly-written untracked files in the worktree
   (subagent cleanup race). Countermeasure: every artifact was committed from the main process
   within seconds of landing, and two files were restored from agent-transcript payloads.
   No content was lost; the incident is noted because it shaped the commit cadence.

## Self-audit against the Definition of Done [#self-audit-against-the-definition-of-done]

* [x] **All 19 files of §10 exist** and follow the writing rules (TL;DR ≤5 bullets with
  numbers, tables, tiers on every claim); README carries tier list, headline numbers, Assumptions.
* [x] **≥40 techniques** across files [04 — Style and Language Compression — Beyond Caveman](/reference/research/token-optimization-techniques/04-style-and-language-compression/) through [13 — Infrastructure-level (self-hosted / gateway tier)](/reference/research/token-optimization-techniques/13-infrastructure-level/): **110 cataloged**, every one carrying the full
  record schema including a validation protocol (≥15 complete required — far exceeded).
* [x] **≥10 frontier ideas**: 12 in [14 — Frontier — unrealistic but maybe real](/reference/research/token-optimization-techniques/14-frontier-ideas/), each with mechanism → math →
  feasibility verdict.
* [x] **Phase-0 baseline audit with real measured numbers**: agent rule chain token masses, the
  6×7 caveman/wenyan tokenizer table, MCP schema costs, hook-duplication waste,
  thinking-vs-visible decomposition (54.8%) with the transcript-redaction workaround documented
  ([02 — Baseline Audit of This Environment (Phase 0)](/reference/research/token-optimization-techniques/02-baseline-audit/)).
* [x] **Headline numbers survived the adversarial pass**: agent-reported local measurements
  spot-reproduced (arrow/casing/epoch checks — 3/3 confirmed), primary sources re-fetched
  independently (pricing, caching, CoD, RouteLLM, LLMLingua, aider, multi-agent 15x), internal
  contradictions reconciled (profile band, tokenizer-gap range stated as range). **Claim
  graveyard included** (00 §graveyard + per-file kill tables, incl. corrections to the
  operator's own plugin claims: 75%→58.5% visible-prose, cavecrew 60%→43.9%).
* [x] **Three composed stacks with end-to-end dollar math** and an explicit 10x verdict + named
  binding constraint ([15 — Composed Stacks: Conservative / Aggressive / Unbelievable](/reference/research/token-optimization-techniques/15-composed-stacks/)).
* [x] **Negative-cost set explicitly identified** (15 §4: eight techniques).
* [x] **[16 — Validation Harness: the No-Quality-Loss Proof Protocol](/reference/research/token-optimization-techniques/16-validation-harness/) runnable as written**: task table with objective checkers,
  six canary classes with assertions, headless runner script, bootstrap decision rule.
* [x] **[17 — Adoption Roadmap: Day 1 / Week 1 / Month 1](/reference/research/token-optimization-techniques/17-adoption-roadmap/)** separates automatic (hooks/skills/plugin/jackin❯-baked, with
  in-repo insertion points) from discipline-dependent adoption, day-1/week-1/month-1.
* [x] **Every external claim has source + access date; every measurement has its method**
  (per-file Verification ledgers).
* [x] **Every artifact landed as an incremental commit pushed to `origin` on
  `chore/token-optimization`** — 20+ commits over the run, no end-of-run dump; final
  state pushed.
* [x] This self-audit appended to README with each box checked honestly. Known limits, stated:
  thinking-share is n=1-environment; the 76% effort figure is Opus 4.5-only pending local
  transfer validation; stack totals are ESTIMATE arithmetic on a modeled profile — the harness
  in 16 exists precisely to convert them into your numbers.

***

## Volume II — Extension [#volume-ii--extension]

\*\*(Volume I froze; all Volume II claims pinned to 06-13
with drift delta, sources + access dates in each file's ledger). Volume II is an additive
layer on top of the frozen Volume I (files [00 — Executive Summary](/reference/research/token-optimization-techniques/00-executive-summary/) through [17 — Adoption Roadmap: Day 1 / Week 1 / Month 1](/reference/research/token-optimization-techniques/17-adoption-roadmap/) unedited); it fills the gaps Volume I left blank or
drew too thin. Governing gap audit and extension scope: [18 — Volume II extension: gap audit and blind-spot map](/reference/research/token-optimization-techniques/18-extension-overview/).

### Volume II index (18–27 band) [#volume-ii-index-1827-band]

* [18 — Volume II extension: gap audit and blind-spot map](18-extension-overview/) — gap audit: independent six-axis taxonomy overlaid on Volume I,
  the blind-spot map with `file:line` evidence, and the Volume II index.
* [19 — Subscription & quota economics: the metric Volume I optimized was the wrong one for a subscriber](19-subscription-and-quota-economics/) — the quota-weighted cost model for a capped
  subscriber (blind spot 1).
* [20 — Multimodal token economics: images, screenshots, PDFs](20-multimodal-token-economics/) — image/screenshot/PDF token costs, measured locally
  (blind spot 2).
* [21 — Latency, wall-clock, and human-time as a second cost axis](21-latency-and-time-economics/) — wall-clock/human-time as a second cost axis (blind spot 3).
* [22 — Fleet, team & multi-tenant cache economics (hosted)](22-fleet-and-multitenant-cache/) — hosted cross-container/fleet cache economics (blind spot 4).
* [23 — Cross-agent / cross-provider portability matrix](23-cross-agent-portability/) — portability matrix across coding agents (blind spot 5).
* [24 — Fresh literature & market delta (clean-room re-sweep)](24-fresh-literature-and-market-delta/) — clean-room re-sweep; KV-eviction family, CAG,
  changelog drift (blind spot 6).
* [25 — Meta layer: the cost of optimizing, budget governance, and online quality guarding](25-meta-cost-governance-and-online-quality/) — cost of optimizing, budget governance,
  online quality guards (blind spot 8).
* \[26 — Volume II frontier: new ]\(26-extension-frontier/) — 8 new frontier ideas (not duplicating K1–K16).
* [27 — Volume II: coverage-delta ledger, verdict delta, and corrections](27-extension-stacks-and-verdict/) — coverage-delta ledger, verdict delta, Corrections to
  Volume I, stack/tier updates, Volume II graveyard.

### Volume II headline numbers [#volume-ii-headline-numbers]

* **10x dollar verdict unchanged: ≈2.5× / ≈5–6.2× with validated routing / no true 10×.** No Volume II
  lever removes Volume I's binding constraints (frontier-model thinking output; the cache-read floor).
  (27)
* **The metric is wrong for a subscriber.** The local credential is **Max**; below the cap dollars are
  sunk and the objective is **tasks-per-cap**. Volume II ships a second (quota) cost model alongside
  the dollar model. Cap cache-read weight ≈ &#x2A;*0.1×** (community-triangulated, T3); the cap token
  **denominator is unpublished** (bounded INCOMPLETE). (19)
* **Multimodal, measured (`count_tokens`):** image = `⌈w/28⌉·⌈h/28⌉&#x60; visual tokens, with high-resolution
  caps around **\~4,760 (Opus/Fable) vs \~1,520–1,570 (Sonnet/Haiku), a \~3.0–3.1× per-image divergence**; PDFs cost \~**3,150 tok/page*&#x2A;
  and **\~2× the equivalent text** (the "PDF tax"); a screenshot of textual content is **2–6× the text**
  it shows. (20)
* **Latency is priceable:** the same Opus 4.8 spans **4× on the latency axis** (batch $2.50 / standard
  $5 / fast $10 input); buy speed only when a human is blocked (`v·t·s > Δ$`). (21)
* **Drift since 06-12** (Volume II state; the current picture is in 28): at Volume II research time `count_tokens` rejected Fable 5 (Opus 4.8 was the tokenizer-twin proxy; it accepts `claude-fable-5` directly as of 2026-07-05) and **Fable 5 was slated to leave the subscription 06-23** (it was instead suspended 06-12→30 under an export-control directive, then restored 07-01 with 50%-of-weekly-cap plan inclusion through 07-07); 5-hour limits **doubled** (effective 2026-05-06); the announced **headless/SDK off-cap billing split was paused before rollout** — headless still draws the interactive cap; KV-eviction
  family (SnapKV/H2O/PyramidKV/KVQuant) and CAG are real but **self-host-only** on hosted Claude. (19, 24, 28)
* **50 genuinely-new techniques** (42 in files [19 — Subscription & quota economics: the metric Volume I optimized was the wrong one for a subscriber](/reference/research/token-optimization-techniques/19-subscription-and-quota-economics/) through [25 — Meta layer: the cost of optimizing, budget governance, and online quality guarding](/reference/research/token-optimization-techniques/25-meta-cost-governance-and-online-quality/) with the full §10 record + 8 frontier), each with
  a coverage-delta note proving absence from 00–17. (27)

### Blind-spot map (summary) [#blind-spot-map-summary]

Eight seeded blind spots audited by overlaying an independent taxonomy on Volume I (14-agent coverage
sweep + grep). Five confirmed thin/absent → full area files: **quota** (19), **multimodal**
(20), **latency-axis** (21), **portability** (23 — no matrix existed), **governance + online-quality**
(25). Three partial → sharpened: **fleet** (22 — self-host done in 13; hosted sharing was thin),
**fresh-lit** (24 — strong scan, specific holes), and **Volume I's own open questions** (worked and
distributed, collected in 27). Full map with `file:line` evidence and per-cell stake: [18 — Volume II extension](/reference/research/token-optimization-techniques/18-extension-overview/).

### Verdict delta (one line) [#verdict-delta-one-line]

**Dollars: no change** (≈2.5× / ≈5–6.2× / no 10×, arithmetic in 27/28). **Metric: changed** — for a
subscriber optimize tasks-per-cap, where the lever order re-sorts (prefix stability, window size,
request-volume up; subagent fan-out partially inverts; style compression matters even less). Volume I's
Fable-priced dollars are \~2× high for the operator's actual Opus 4.8, but ratios/tiers are unchanged.

### Volume II Assumptions (judgment calls) [#volume-ii-assumptions-judgment-calls]

1. **Research date.** Drift delta done; the load-bearing drift (Fable 5 not
   `count_tokens`-able; Fable promo ends 06-23; 5-hour doubling; 06-15 SDK split) is flagged where used.
2. **Instrument:** `count_tokens` via the OAuth credential (`claudeAiOauth.accessToken`),
   free/non-billable, rebuilt at `/tmp/ct.py` (Volume I's copy did not persist — fresh container).
   &#x2A;*Fable-family tokenizer measured on `claude-opus-4-8`** (its documented twin), labeled wherever used.
3. **Local environment:** Opus 4.8 main + Haiku 4.5 subagents, effort=max, **Max subscription**
   (`~/.claude/.credentials.json`). Token-class decomposition from 31 transcripts / 560 calls.
4. **Test media** (images/PDFs) generated from the Python stdlib (`zlib`) — no PIL/ImageMagick on the
   box — and validated against 5 real repo PNGs and Anthropic's published cost table; the image curve
   was adversarially re-confirmed with a max-entropy noise image (content-independent).
5. **Quota model carries a bounded INCOMPLETE:** the cap token **denominator** and the exact cap
   cache-read **weighting** are unpublished (confirmed across 6 primary pages + 3 GitHub issues). The
   \~0.1× weight is community-triangulated (T3); true cap-% needs the `unified-*` response headers
   (`/usage` or a proxy), not run this pass (frontier V2).
6. **Open questions still open** (honestly): the effort→thinking-share curve (all local transcripts are
   a single effort level — unmeasurable this run), the per-account cap denominator (needs a header-
   reading proxy), and the exact SDK `excludeDynamicSections` byte size (reconstructed estimate \~111
   tokens). Each is flagged in its file.
7. **Seven area files (19–25)** were written, exceeding the ≥5 floor; fleet (22) was kept distinct
   (not merged) because the hosted-fleet material proved genuinely separate from [13 — Infrastructure-level](/reference/research/token-optimization-techniques/13-infrastructure-level/)'s
   self-host tier.
8. **Multi-agent machinery:** an E0 coverage-map workflow (14 read-only readers) and an E1 fresh-sweep
   workflow (11 web-research streams); all deliverables were written and committed from the main
   process within seconds of landing (Volume I's file-deletion-race countermeasure).
9. **Cache-layer and subagent-caching caveats** (22/27): the hosted server prompt cache is
   workspace-scoped, not machine/dir-keyed; subagent caching can be version-dependent — audit your
   own JSONL before relying on it.

### Volume II self-audit against the Definition of Done [#volume-ii-self-audit-against-the-definition-of-done]

* [x] **Blind-spot map** built by overlaying an independent taxonomy on Volume I with `file:line`
  evidence of thin/absent coverage ([18 — Volume II extension](/reference/research/token-optimization-techniques/18-extension-overview/)).
* [x] **≥5 new area files*&#x2A; (19–25 = seven), writing rules followed; **≥25 new techniques*&#x2A; (50, each
  with a coverage-delta note); **≥10 with the full record** (all 42 in [19 — Subscription & quota economics](/reference/research/token-optimization-techniques/19-subscription-and-quota-economics/) through [25 — Meta layer](/reference/research/token-optimization-techniques/25-meta-cost-governance-and-online-quality/) carry it). ([27 — Volume II capstone](/reference/research/token-optimization-techniques/27-extension-stacks-and-verdict/) ledger)
* [x] **≥6 new frontier ideas** with feasibility verdicts + math (8 in [26 — Volume II frontier](/reference/research/token-optimization-techniques/26-extension-frontier/)).
* [x] **Subscription/quota cost model delivered** with an explicit bounded **INCOMPLETE** naming the
  unpublished denominator and what was measured instead ([19 — Subscription & quota economics](/reference/research/token-optimization-techniques/19-subscription-and-quota-economics/)).
* [x] **Multimodal/vision/PDF token costs measured locally via `count_tokens`** with the method shown
  (zlib-generated assets, validated against real PNGs + the published table) ([20 — Multimodal token economics](/reference/research/token-optimization-techniques/20-multimodal-token-economics/)).
* [x] **Every Volume II headline number survived the adversarial pass**; the two most novel were
  re-attacked (noise-image content-independence; PDF tax across content). **Volume II graveyard**
  included ([27 — Volume II capstone](/reference/research/token-optimization-techniques/27-extension-stacks-and-verdict/)).
* [x] **Verdict delta with arithmetic** — dollars unchanged, metric reframed for a subscriber ([27 — Volume II capstone](/reference/research/token-optimization-techniques/27-extension-stacks-and-verdict/)).
* [x] **Cross-layer caveats captured** in [27 — Volume II capstone](/reference/research/token-optimization-techniques/27-extension-stacks-and-verdict/) (cache scope, subagent caching).
* [x] **Every external claim has a source; every measurement its method** (per-file Verification ledgers).
* [x] **Every artifact committed and pushed to `origin` on `chore/token-optimization` as it
  landed** — `docs(research): …` Conventional Commits with DCO sign-off, no CI wait, no end-of-run dump.
* [x] **Volume II self-audit appended here**, each box checked; judgment calls in the Volume II
  Assumptions section above. Honest residual gaps named in Assumption 6.

***

## Volume III — tooling and external-tool comparison [#volume-iii--tooling-and-external-tool-comparison]

Adds runnable measurement scripts and a comparison of external code-search / code-intelligence tools.

> **The Volume III per-tool chapters (19–25) now live in the dedicated [token-optimization tools](/reference/research/token-optimization-tools/) research** as part of the three-way research split (techniques / tools / engine spec). That hub consolidates the equal-depth design teardowns of caveman, headroom, RTK, **and lean-ctx** (the integrated context runtime added in a later round), a feature has/lacks matrix, best-case-of-each, and a straight answer to whether one product can combine them all. The summaries below link to the chapters' new homes; only the runnable `tools/` instruments remain in this folder.

* **Runnable [`tools/`](tools/)** — `count_tokens.py`, `image_tokens.py`, `session_cost.py`
  reproduce the dossier's core numbers against the live Anthropic tokenizer: real token counts, the
  image-token formula, and the dollar/token split deduplicated by `message.id`.
* **[19 — Code-intelligence tools: codedb, fff, CodeGraff, and alternatives](/reference/research/token-optimization-tools/19-code-intelligence-tools/)** — deep dive comparing
  **codedb**, **Codegraff**, and **fff** — whether they help AI coding agents and save tokens. They
  productize the same context-architecture lever (serve outlines/symbols, not whole files), measured
  locally at ≈91% (outline) / 98% (symbol search) fewer tokens than reading the file; with setup
  recipes and the MCP-schema-overhead caveat.
* **[20 — Qdrant and vector databases for agent context](/reference/research/token-optimization-tools/20-qdrant-and-vector-databases/)** — Qdrant/vector DB
  follow-up: vector search is an optional semantic-memory/RAG backend, not a replacement for fff or
  codedb. Default recommendation remains `rust-analyzer + ast-grep + codedb + fff`; pilot Qdrant only
  for docs/examples/decisions/pattern recall and accept it only if it beats that planned stack by
  ≥20% tokens per solved task at equal quality.
* **[21 — Headroom and the context-compression layer (vs the caveman ecosystem)](/reference/research/token-optimization-tools/21-headroom-and-context-compression/)** — deep dive on
  `chopratejas/headroom` (the input-side context-compression layer); the cross-tool comparison to the
  caveman ecosystem and RTK is consolidated in the dedicated [token-optimization tools](/reference/research/token-optimization-tools/) folder. Headroom compresses what the model *reads* (tool outputs/logs/RAG/files, the 61%
  cache buckets); caveman compresses what the model *writes* (prose, 17%) — orthogonal, they stack,
  neither touches thinking (20%). Headroom's **live-zone** design (stabilize the cached prefix,
  compress only the volatile tail) is the cache-safe input-compression design that refines the
  record-19/FL3 "no compressor in the hot path" kill; its "60–95%"/"96.2%" headlines are
  per-payload/double-counted and corrected here (K1-style). Verdict: pilot MCP mode as an A/B arm
  against existing hooks (record 20) + code-intelligence (19) + serialization (record 14); never
  default the whole-prompt proxy in a jackin❯ container.
* **[22 — Context-compression literature and market delta (2024–2026)](/reference/research/token-optimization-tools/22-context-compression-literature-and-market/)** —
  the compression-layer internet re-sweep (other projects) + fresh literature (2024–2026), companion to 21.
  Headline: a **cache-safety classification** of every compression move (output brevity = cache-neutral;
  write-time observation compression = safe; whole-prompt input compression = breaks the cache, must beat
  \~10×). The frontier moved to code-domain, hosted-viable, write-time compressors that *raise* SWE-bench
  accuracy (Squeez, AgentDiet, SWEzze, SWE-Pruner, LongCodeZip) — refuting [24 — Fresh literature & market delta (clean-room re-sweep)](/reference/research/token-optimization-techniques/24-fresh-literature-and-market-delta/)'s "no compressor safe
  for code." Stars are a PR artifact in this niche; rank by evidence. Credible challengers (the-complexity-trap,
  OpenHands batched condensation, ACON, llmtrim, claw-compactor) ranked by evidence, not stars.
* **[23 — Token observability and session visualization (token-optimizer and peers)](/reference/research/token-optimization-tools/23-token-observability-and-visualization/)** — the
  *observability* layer (distinct from compression): a deep dive on `alexgreensh/token-optimizer` and a
  survey of full-per-token-visibility / session-visualization tools. token-optimizer reads Claude Code
  JSONL transcripts locally (no proxy, cache-safe) and renders the dossier's own per-turn
  input/output/cache-read/cache-write decomposition as a web dashboard + status line — it productizes
  `tools/session_cost.py` with a UI. Key limit: thinking stays invisible in any JSONL-only tool (must be
  inferred via `count_tokens`). Caveats: PolyForm-Noncommercial license; dollar views assume API pricing,
  not a Max subscription ([19 — Subscription & quota economics: the metric Volume I optimized was the wrong one for a subscriber](/reference/research/token-optimization-techniques/19-subscription-and-quota-economics/)). The JSONL-reading, no-proxy class is the safe measurement front-end of
  the validation harness.
* **[24 — RTK and write-time observation compression](/reference/research/token-optimization-tools/24-rtk-and-write-time-observation-compression/)** —
  deep dive on `rtk-ai/rtk` ("Rust Token Killer") — the dossier's RTK record. The cross-tool
  comparison it originally carried now lives, expanded to four tools (adds **lean-ctx**), in the dedicated [token-optimization tools](/reference/research/token-optimization-tools/) folder (single source of truth). RTK is the deterministic, Claude-Code-native productization of the
  cache-safe **write-time observation-compression** design point [21 — Headroom and the context-compression layer](/reference/research/token-optimization-tools/21-headroom-and-context-compression/) (H1) and [22 — Context-compression literature and market delta](/reference/research/token-optimization-tools/22-context-compression-literature-and-market/) named: it compresses
  shell-command output (tests/git/logs/builds) at the tool boundary via a PreToolUse hook — no ML, no MCP
  rent, cache-safe by construction — but reaches only Bash calls (not native `Read`/`Grep`). The "60–90%"
  is a per-command best case (no whole-session telemetry, no independent benchmark; 63.5k★ is PR-inflated
  per [22 — Fleet, team & multi-tenant cache economics (hosted)](/reference/research/token-optimization-techniques/22-fleet-and-multitenant-cache/) §A), corrected to low-double-digit whole-bill, same as the caveman K1 / headroom H-K1 moves.
  Verdict: caveman for output; RTK and headroom are **complementary input-side layers** (RTK = Bash output
  at the tool boundary, headroom = API-layer everything-else) the community stacks — a published month-long
  head-to-head measured RTK 1.33B + headroom 0.19B → 1.52B tokens, headroom at 96% prefix-cache-hit
  (confirming the live-zone design); adopt in risk/reach order. RTK is the most container-adoptable of the
  three, pilot it role-scoped with the host-write/hook-conflict guardrails. [19 — Subscription & quota economics](/reference/research/token-optimization-techniques/19-subscription-and-quota-economics/)'s ast-grep coverage was
  also extended into a full verdict (structural-search token economics + the skill-vs-MCP-vs-CLI
  form-factor analysis).
* **[25 — sem and mq: entity-level retrieval and structural markdown queries](/reference/research/token-optimization-tools/25-sem-and-mq-structural-and-markdown-retrieval/)** —
  2026-07-03 addendum covering two tools the dossier had missed: **sem** (entity-level diff/impact/context on tree-sitter entities; `sem-core` is a real crates.io library; its **attention ledger** — tracking what the agent's context already holds and suppressing re-sends with `≡ unchanged` stubs and entity-level delta-fills — is the one genuinely novel mechanism in the 2026 tool wave) and **mq** (jq for Markdown; `mq-lang`/`mq-markdown` crates, nushell-proven), whose TOC-then-section retrieval (measured 12–53× on 11–15 KB docs) is the first surveyed lever for the docs/prose read bucket that dominates this repo's own measured observation traffic (76.2% native reads). Reuse verdicts feed the [jackin❯ Context Engine spec](/reference/research/jackin-context-engine/); same-date deltas for caveman/headroom/RTK/lean-ctx live in [tools hub 13](/reference/research/token-optimization-tools/13-reuse-surfaces-and-deltas/).

## Volume IV — drift delta (2026-07-05) [#volume-iv--drift-delta-2026-07-05]

Chapter [28 — Drift delta](/reference/research/token-optimization-techniques/28-drift-delta/) is a drift pass: the dossier's load-bearing external claims (model lineup, pricing, tokenizer families, `count_tokens` behaviour, context-management betas, subscription/quota rules, Claude Code changelog) checked against live sources on 2026-07-05. The pass found nine load-bearing deltas — headline items: Claude Sonnet 5 shipped 2026-06-30 (new tokenizer family, $2/$10 intro pricing, new Claude Code default), the 2026-06-15 headless/SDK quota split was paused before rollout, the Explore subagent no longer defaults to haiku as of 2.1.198, and the memory tool went GA. The dossier's headline verdict — no defensible 10x at zero quality loss — stands; the deltas change model-tiering, tokenizer-arbitrage, and quota-routing arithmetic in [05 — Tokenizer arbitrage](/reference/research/token-optimization-techniques/05-tokenizer-arbitrage/), [06 — Context architecture](/reference/research/token-optimization-techniques/06-context-architecture/), [08 — Retrieval, memory, and state offloading](/reference/research/token-optimization-techniques/08-retrieval-memory-and-state/), [10 — Model routing and tiered delegation](/reference/research/token-optimization-techniques/10-model-routing-and-delegation/), [19 — Subscription & quota economics](/reference/research/token-optimization-techniques/19-subscription-and-quota-economics/), and [24 — Fresh literature & market delta](/reference/research/token-optimization-techniques/24-fresh-literature-and-market-delta/), and every Sonnet-based arbitrage claim must now be pinned explicitly to Sonnet 4.6/Haiku 4.5.

### Final completion audit [#final-completion-audit]

* [x] **All 19 required §10 files exist**; Volume II/III addenda are extra, not replacements.
* [x] **Writing-rule checks passed:** every Markdown report has an early TL;DR/summary surface; files [04 — Style and Language Compression — Beyond Caveman](/reference/research/token-optimization-techniques/04-style-and-language-compression/) through [13 — Infrastructure-level (self-hosted / gateway tier)](/reference/research/token-optimization-techniques/13-infrastructure-level/) carry 110 technique records with all required fields.
* [x] **Technique floors exceeded:** ≥40 required, 110 in files [04 — Style and Language Compression — Beyond Caveman](/reference/research/token-optimization-techniques/04-style-and-language-compression/) through [13 — Infrastructure-level (self-hosted / gateway tier)](/reference/research/token-optimization-techniques/13-infrastructure-level/); ≥15 complete records required, 110 complete; frontier floor exceeded with 16 K-ideas in [14 — Frontier](/reference/research/token-optimization-techniques/14-frontier-ideas/) plus 8 Volume II ideas in [26 — Volume II frontier](/reference/research/token-optimization-techniques/26-extension-frontier/).
* [x] **Phase-0 audit complete:** environment instruction mass, MCP schema overhead, caveman/wenyan tokenizer table, hook waste, and thinking-vs-visible decomposition are in [02 — Baseline Audit](/reference/research/token-optimization-techniques/02-baseline-audit/).
* [x] **Adversarial validation applied:** the independent [28 — Drift delta](/reference/research/token-optimization-techniques/28-drift-delta/) pass found arithmetic/tokenizer/profile/cap issues; load-bearing corrections are now applied in the live summaries and affected reports.
* [x] **Composed stacks and 10x verdict are current:** [15 — Composed Stacks](/reference/research/token-optimization-techniques/15-composed-stacks/) carries corrected ≈2.4–2.5x aggressive math, ≈5–6.2x validated-routing ceiling, and no defensible 10x at zero quality loss.
* [x] **Negative-cost set, graveyards, harness, and roadmap are present:** negative-cost set in [15 — Composed Stacks](/reference/research/token-optimization-techniques/15-composed-stacks/), claim graveyards in [00 — Executive Summary](/reference/research/token-optimization-techniques/00-executive-summary/), area files, and [27 — Volume II capstone](/reference/research/token-optimization-techniques/27-extension-stacks-and-verdict/), runnable validation protocol in [16 — Validation Harness](/reference/research/token-optimization-techniques/16-validation-harness/), adoption sequence in [17 — Adoption Roadmap](/reference/research/token-optimization-techniques/17-adoption-roadmap/).
* [x] **Evidence discipline holds by audit:** external claims are cited with access dates or ledgers; local measurements name their method; bounded unknowns remain explicitly labeled `INCOMPLETE`.
* [x] **All artifacts are committed and pushed** to `origin/chore/token-optimization`; latest verification showed a clean worktree after pushed commits.

***

## Addendum — Code Intelligence Tools [#addendum--code-intelligence-tools]

Focused live analysis requested after the final audit, then expanded with an internet re-sweep for
alternatives:
[19 — Code-intelligence tools: codedb, fff, CodeGraff, and alternatives](/reference/research/token-optimization-tools/19-code-intelligence-tools/) compares `codedb`, `fff`, the
CodeGraff codedb article, the CodeGraff product/toolchain, and stronger alternatives such as
Serena, Code Context Engine, Augment Context Engine, Sourcegraph MCP, Qodo Context Engine,
Claude Context, and CodeGraphContext.

* **Verdict:** these tools can save tokens only when they replace blind grep/read loops with bounded,
  precise retrieval. `codedb` has the strongest public token-saving case; `fff` has a strong latency
  case and plausible but unquantified token savings; **Serena is the strongest local open-source
  semantic-navigation challenger**, **Code Context Engine has the strongest local open-source
  token-savings headline with baseline caveats**, and **Augment/Sourcegraph/Qodo are stronger
  commercial or enterprise context systems** if vendor dependency is acceptable.
* **jackin❯ recommendation:** keep the existing the-architect `fff` pilot, add a measured `codedb`
  A/B arm if MCP schema overhead is deferred or bounded, add Serena/Claude Context competitor arms
  where installable, include Code Context Engine in the token benchmark, and treat CodeGraff
  Pro/Augment/Sourcegraph/Qodo as explicit opt-in agent-stack
  experiments rather than default jackin-core dependencies.
* **Qdrant follow-up:** [20 — Qdrant and vector databases for agent context](/reference/research/token-optimization-tools/20-qdrant-and-vector-databases/)
  concludes Qdrant is a credible backend for semantic memory/RAG but should stay optional and scoped;
  a live check found Milvus/Zilliz, Vespa, Turbopuffer, LanceDB, Chroma, Pinecone, and pgvector
  are real alternatives, but none proves better coding-agent token economy than `fff + codedb`.
  The useful local case is a bounded hybrid docs/decision index over the repo's large documentation
  surface, not default code navigation. Qdrant should not become a default third tool unless a harness
  proves a ≥20% token-per-solved-task reduction against the planned stack.
