Files
arah2/docs/ALT-DIRECTION-SPLIT.md
T

73 lines
8.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ALT Direction-Split Potentials — Research Handoff
**Status:** OPEN EXPERIMENT — deliberately deferred from Phase 8 (2026-10-25)
**Purpose:** a self-contained document so the direction-split experiment can be picked up — by us, a fork, or a different LLM/harness — and solved *straight away* without re-deriving any of this.
**Author context:** distilled from Phase 8's campaign, debug session `.planning/debug/alt-potential-4x-slowdown.md`, and the verification record. All numbers below are MEASURED on this repo's gates/benches, not estimated.
---
## 1. Problem statement
The routing engine (`routing/src/`) runs **bidirectional A\* (BH, Ikeda shared-average construction)** over a CSR road graph. ALT landmark potentials were integrated (Phase 8) and made *sound* via the F1 clean-columns law, but on the real KL binary **0/24 landmark columns are sentinel-clean** (a 6,285-node disconnected island makes every to-column carry a `0xffff` cell), so sound ALT degrades to haversine in production.
The **direction-split question**: can the potential use BOTH table families soundly — `h_f` from to-tables (forward search), `h_b` from from-tables (backward search) — with a re-proven meet rule, and does that reach the free-plan CPU budget?
## 2. What is already proven / shipped (do not re-derive)
| Fact | Evidence |
|---|---|
| toTable triangle bounds are one-directional Lipschitz: the u-side term needs the reverse edge; a oneway doesn't provide one. Two-sided mixing inside the shared Ikeda average `p = (h_f − h_b)/2` is INCONSISTENT on graphs with oneways. | D-03 gate's Rule-1 catch: suboptimal routes x038 (1234.6 s vs 1214.8 s oracle), x045 (1475.5 vs 1460.6) |
| F1 containment (SHIPPED, commit `2a5a0b5`): per-graph WeakMap `cleanColumnsFor`; per-search `activeL` = clean columns only; `bound()` has NO per-node sentinel branch (inline `=== 0xffff` compares are BANNED — A11 pins this). Consistency violations went 334 fwd / 11,369 bwd → 0. | routing 82/82; oracle sweep 0/200 |
| Tables are triangle-exact (0 violations in an all-edges unit-correct sweep) — the bug was always the per-node family switching, never the data. | debug session bench5 |
| The tables PRUNE WELL: unidirectional control with these tables = **0.59× expansions** of haversine-only. The data is good; the BH configuration eats it. | debug bench (uni control) |
| The BH shared-Ikeda average FLATTENS the composite bound: expansions INCREASED +15.7% with ALT (66,286 → 76,671/route; +51% on mid-valley→bukit-bintang) despite the bound being pointwise-tighter on 99.7% of nodes. | debug bench7-class runs |
| Costlier nodes, not fewer nodes, dominated the regression: each `bound()` = 2 passes × 24 scattered u16 reads, row-major `[ℓ·n+v]` (622 KB stride) into a 14.9 MB table > 12 MB L3 → ~2.5 µs/node (vs 0.31 µs transposed, 0.26 µs 2× haversine). ~85% of the delta. L=32 worse than L=24 because reads scale with L. | debug microbenches |
| F2 (transposed toTable `[v·L+l]` + merged single-pass): mean 332.7 → **197.3 ms (−41%)**, bit-identical potentials, NOT shipped (out of scope — only useful for future clean-column binaries). | debug bench (F2) |
| Pre-ALT band: bidirectional A\* + haversine, p95 ≈ 38 ms on the campaign host (~107–152 ms on slower hosts — host-relative; gate = p95 8 ms budget, free-plan Worker ceiling 10 ms). | `routing/scripts/measure-route-cpu.mjs`, D-04 extended verdict |
**Shipped posture today:** toTable-only steering (sound), clean-columns containment, haversine max-fallback, ALT live in the suite (A12/A13) and inert in production. Optimality: D-03 gate + 200-pair oracle sweep, both green.
## 3. The theory gap — what must be proven
ALT's correctness inside BH requires the potential pair to satisfy the Ikeda condition (the average `(h_f − h_b)/2` is consistent iff both families are *two-sided* consistent). With sentinel fringes, to-tables and from-tables each carry holes in DIFFERENT places, so any two-sided combination needs either:
- **P-1 (per-direction consistency):** `h_f` built ONLY from to-tables, `h_b` ONLY from from-tables, each individually consistent across every relaxable edge. Sentinels inside ONE direction must degrade that direction's bound at that node (to haversine max-fallback) WITHOUT changing the active family set mid-search (the F1 lesson — per-node ℓ-masking is banned; the skip must be search-scoped per direction).
- **P-2 (the meet rule, THE hard part):** BH's stop rule (`μ + top_f + top_b ≥ bound`) is proven for symmetric-consistent potentials. Direction-split potentials break the symmetry — re-prove (or re-derive) a sound stopping criterion for the asymmetric case, OR prove the standard condition still holds under the split. Get this wrong and routes are silently suboptimal (the exact bug class D-03 was built to catch).
- **P-3 (optimality, empirical):** the 200-pair seeded Dijkstra-oracle sweep (`routing/scripts/measure-astar-oracle-sweep.mjs`, seed `0x08f1`, |Δ| both directions) must show 0 violations; A1's 625-pair fixture equivalence stays green.
- **P-4 (steering, empirical):** expansions with direction-split ALT < expansions haversine-only, on the extended 100-pair seeded verdict — this is where the 0.59× uni prize must survive the bidirectional setting.
## 4. Constraints (non-negotiable)
- Optimality non-negotiable: admissibility/consistency proofs precede any speed claim
- $0 runtime (free-plan Worker); JS typed arrays; pure modules (no I/O in routing/src)
- The ARG2 layout may gain fields (ARG3) if needed — but one decode path, fail-honest, exact-size law (D-01 family)
- Named constants; print-the-measurement gates; honest FAIL records (no retirement theater)
- The phase-8 "untouchable lines" (stop rule/reductions/alternation) are untouchable WITHIN phase 8 — a direction-split experiment's whole point is re-proving them; that work belongs in its own phase with its own gates
## 5. Candidate approaches to experiment with
- **A. Direction-split + meet-rule re-proof** — the mainline (Section 3). Highest prize, highest proof burden.
- **B. Unidirectional ALT** — drop BH for the ALT path: uni control already measured 0.59× expansions; simpler correctness (no meet rule); cost: lose BH's radius-halving. Measure both bands.
- **C. BH with per-direction haversine + ALT only as a unidirectional pruning filter** — hybrid: prune the unidirectional side's frontier with table bounds while BH runs haversine. Correctness via dominance, not potentials.
- **D. Min-combination variants** — the Ikeda average is one of several consistent combinations; `min(h_f-bound, h_b-bound)` asymmetric forms have literature precedent (need the consistency proof for the chosen form).
- **E. Different L / quantum / column-hygiene binary** — rebuild with anchors chosen so more columns are sentinel-clean (e.g., anchors constrained to the giant SCC's "well-connected side") — changes the DATA to fit the algorithm instead of the reverse.
## 6. Verification assets (all exist, all re-runnable)
- `routing/scripts/measure-astar-oracle-sweep.mjs` — 200-pair fresh oracle (the gate that catches suboptimality fixtures can't)
- `routing/scripts/measure-optimality-gate.mjs` + frozen `routing/test/fixtures/alt-baseline.json` — D-03
- `routing/scripts/measure-route-cpu.mjs` (+ `--extended`) — the CPU verdicts
- `routing/test/astar.test.mjs` — A1 (625-pair equivalence), A9–A13 (containment/island/structural)
- The debug session's bench harnesses were throwaway (/tmp) — re-derive per Section 2's calibration method (within-session ratios only; hosts differ ~7×)
## 7. Success criteria for the experiment
1. A written proof (or literature citation + adaptation argument) for P-1 and P-2 BEFORE implementation
2. Oracle sweep 0/200 + A1 green + full battery
3. Expanded-measurement: expansions ratio AND p95 vs haversine-only, same seeded pairs
4. Honest verdict: p95 under the 8 ms budget on the free-plan host class → a real phase proposal; documented shortfall → the wall is proven, CH remains the lever, this document gets its closure record
---
*Research handoff written: 2026-10-25 (Phase 8 close; lever decision: CH as Phase 08.1)*