# R1-B Route Selection Gate **Status: CLOSED.** Baseline `12a5842`; R1-A `ae37d44`; R1-B `7c2e21d`. Every number below is machine-generated by `tests/r1b-roi.spec.ts` and is reproducible keylessly (`npx vitest run tests/r1b-roi.spec.ts`). This gate exists to answer docs/11 §27's question — *what should we build next?* — from measured ROI rather than from milestone numbering. Its output is a decision, not a feature. --- ## 1. What dominates context cost is regime-dependent Measured across W1–W5 at 64 steps. Shares are of total prompt tokens. | Workload | Folds | Total tokens | Dominant source | Share | |---|---:|---:|---|---:| | W1 narrative-heavy | 18 | 58,342 | `checkpoint-framing` | 51.1% | | W2 state-rich | 3 | 47,112 | `raw-assistant` | 41.3% | | W3 tool-heavy | 31 | 115,677 | `checkpoint-framing` | 56.6% | | W4 recall-heavy | 5 | 44,251 | `recall` | 31.3% | | W5 multi-agent | 27 | 90,455 | `checkpoint-framing` | 56.6% | The same workload flips its dominant source when fold pressure changes: | W1 regime | Folds | `checkpoint-framing` | raw history | |---|---:|---:|---:| | aggressive (`thresholdRatio` 0.15) | 50 | 74.4% | 14.9% | | realistic (`thresholdRatio` 0.6) | 4 | 5.2% | 94.0% | **Consequence for the project.** R0-C's single narrative fixture could not see this, and any report quoting one of these numbers alone would be a threshold artifact. Attribution must always be reported with its fold regime. --- ## 2. The structural finding: the frozen-prefix feedback loop Two measurements, each independently gated: 1. **~87% of a leaf checkpoint node is fixed overhead.** A node prices at 151 tokens: 13 state + 6 rationale + ~132 repeated preamble and wrapper. The framing scales linearly with fold count while carrying no state. 2. **EF folds strictly more often than Basic — 51 vs 21 folds** on an identical workload *and identical digest text*, so this is architectural, not a narrative-length artifact. At a tight threshold that is 245,885 vs 73,878 total tokens, a **3.3× gap** on the same conversation. **Root cause.** EF may never re-fold a frozen checkpoint (plan §13), so the frozen prefix is monotonically non-decreasing. Once that prefix alone exceeds the pressure threshold, *every* subsequent step is over threshold, each fold can only compact the newly appended tail, and one checkpoint is produced per step — each paying the full preamble. Measured: the frozen prefix reaches 7,550 tokens against a 2,400-token threshold. This is a genuine architectural cost of the frontier invariant, not a bug in it. It is the cost of "frozen checkpoints are never re-folded," and it is exactly what the R1-D rebase policy exists to amortize. --- ## 3. Counterfactual upper bounds Measured at 64 steps, aggressive regime, as a fraction of total prompt tokens. These are **upper bounds under stated idealizations**, never achievements. | Candidate | W1 | W2 | W3 | W4 | W5 | Risk | Kind | |---|---:|---:|---:|---:|---:|---|---| | Adaptive Root | 77.9% | 23.2% | 74.3% | 39.3% | 76.6% | low | policy change | | Framing dedup | 70.8% | 15.9% | 66.9% | 37.6% | 69.1% | low | policy change | | M5 generational | 63.6% | 33.4% | 59.3% | 37.5% | 61.4% | high | new mechanism | | M1 ingress | 0.0% | 0.0% | 19.5% | 0.0% | 16.6% | high | new mechanism | | Delta Leaf | 7.0% | 16.6% | 6.6% | 3.7% | 6.8% | medium | new mechanism | Two rows carry most of the decision: - **M1 is worthless where there is no tool output** (0.0% on W1 and W2) and modest where there is (~19.5% on W3). An M1 decision made from a single workload would have been wrong in either direction. - **Delta Leaf, the mechanism R1 was expected to justify, is the weakest candidate on every workload.** The full-state payload it removes is 2–11% of spend; the recurring framing it does *not* address is the larger cost. --- ## 4. Decision **Delta Leaf is NOT productionized.** Its measured upper bound (3.7–16.6%) does not justify a new correctness seam at medium implementation risk, and it addresses the smaller half of the checkpoint cost. Per docs/11 §26, the gate before writing production Delta Leaf is exactly this table, and it does not pass. **Routed to R1-D: provider-aware amortized root.** Highest measured bound (23.2–77.9%), lowest risk, and — decisively — a *policy change over existing machinery* rather than a new mechanism. It requires no new fold mode, no new state representation, and no new way to lose state. It also directly targets the structural loop in §2: a rebase is the only mechanism that can shrink the frozen prefix. **Framing deduplication is recorded as a follow-up, not a stage.** Its bound is comparable to R1-D's and its risk is low, but it changes the checkpoint surface format, so it belongs behind the same evidence gate that R1-D must pass. It is not started here. **M5 generational merge is deferred.** High bound (33–64%) but high risk and a new mechanism; docs/11 §31 routes to it only if hierarchy still fails to scale *after* Delta and Root work. Delta was rejected, so that precondition is not met yet. --- ## 5. What this gate does not establish - **No behavioral evidence.** These are token economics, not task success. A 78% cheaper policy that loses 5% of task success may be worthless. Live paired validation remains ⏸ OPEN (requires provider credentials) and is what R1-E records; no production default may be flipped on economics alone. - **No provider cache realization.** The keyless tier has no provider to report `cacheReadTokens`, so realization is treated as a parameter, not a measurement. `eval/src/provider-telemetry.ts` computes it when a live run supplies usage; until then every money figure is conditional on `h`. - **Synthetic window.** All runs use a 16,000-token window to force pressure at tractable step counts. Absolute costs are not production-scale; the comparisons and the structural finding are.