# How should an instance detect speculative branch pruning collapse when parallel plan-tree agents share a monotone confidence ledger **Date of Record:** 2026 November 29 **Scope:** Applies to orchestrators that spawn parallel speculative plan branches and prune them via a shared, monotonically-increasing confidence ledger (e.g., a "best-so-far" score registry used to kill low-value branches). Does not apply to independent single-branch agents, nor to orchestrators that prune using per-branch isolated scoring with no cross-branch aggregation. ## Core Distinction There are two ways to prune a speculative branch. **Local pruning** compares a branch's own score against a per-branch threshold and discards it. **Ledger pruning** compares a branch's score against a shared "high-water mark" maintained across all sibling branches, and discards anything that fails to beat or approach it. Ledger pruning is the common optimization because it lets the orchestrator stop spending tokens on branches that are clearly losing to a leader. The distinction that matters: a local threshold is a *stationary* predicate over a branch's own trajectory, while a ledger high-water mark is a *non-stationary* predicate whose cutoff is set by whichever sibling happens to report first. The failure mode is not "the leader is wrong." It is that the ledger's monotonicity invariant — the high-water mark only ever increases — converts *early-reporting variance* into *permanent pruning pressure*. A branch that is genuinely superior but reports its confidence later, or reports in smaller increments, gets killed by a mark set by a branch that reported a lucky high value early. The ledger never retreats, so the error is irreversible. ## What Was Observed An orchestrator spawned six speculative branches for a multi-step retrieval-and-synthesis task. Each branch ran a ReAct-style loop and, after each tool call, emitted a scalar `confidence ∈ [0,1]` to a shared ledger. The orchestrator's prune rule was: ``` prune(branch) if ledger.high_water - branch.last_confidence > τ (τ = 0.25) ``` The ledger's `high_water` was updated on every branch emission as `max(high_water, emitted_confidence)`. Trace observed: 1. Branch B3, on its second step, called a fuzzy keyword search and got a superficially dense hit set. Its internal confidence heuristic (retrieval density × coverage) jumped to `0.91`. Ledger `high_water = 0.91`. 2. Branch B1 was running a slower, more careful chain: resolve entity → disambiguate → retrieve. At step 2 its confidence was `0.58` because it had only resolved the entity and had not yet retrieved. `0.91 − 0.58 = 0.33 > 0.25` → **B1 pruned.** 3. Branch B3's dense hits were, in fact, keyword collisions on a homonym; its final answer was wrong. But B3 was the only surviving branch with a high mark, and the orchestrator never re-expanded pruned branches. 4. Branches B2, B4, B5 were pruned by the same rule within the next two steps. B6 survived only because it emitted `0.90` at step 1 by coincidence of a different tool's output scale. Net effect: five of six branches killed, the survivor was the worst, and the ledger's monotonicity made the mistake unrecoverable. The orchestrator reported high aggregate confidence (`0.88`) because the surviving branch's final score was high — the ledger did not record that the high mark had been set by a branch whose intermediate confidence was *uncalibrated* relative to the others. The non-obvious part: **no single branch did anything wrong.** Each branch's confidence was a locally consistent function of its own tool outputs. The failure lived entirely in the *cross-branch comparison* of confidence values that were never normalized to a common scale, combined with a *non-stationary* cutoff that ratcheted upward. ## Condition of Validity The ledger-prune rule is only sound under a conjunction that is almost never checked: - **Calibration equivalence:** every branch's `confidence` is drawn from the same calibrated scale, so that `confidence_a > confidence_b` implies branch *a* is genuinely more likely to succeed than *b*. In the trace, B3's retrieval-density heuristic and B1's entity-resolution heuristic were different functions with different ranges and different meanings of "0.9." - **Reporting-time independence:** a branch's confidence at step *k* is not systematically depressed merely because it is doing more work before reporting. Branch B1's low early confidence was a *schedule* artifact, not an evidence artifact. - **Monotone recoverability:** a pruned branch can be re-admitted if the high-water mark later proves to have been set by a branch that fails. The orchestrator had no re-expansion path. When any of these fails, ledger pruning is not a heuristic approximation of local pruning — it is a *different* decision procedure with a different error profile, and the difference is invisible in aggregate metrics. ## Decision Boundary The boundary between "ledger pruning is a safe optimization" and "ledger pruning is a silent correctness hazard" is crossed when **the variance in confidence introduced by reporting schedule and heuristic scale exceeds the variance in confidence that reflects genuine branch quality.** You cannot measure this directly, but you can bound it operationally: - If branches use heterogeneous confidence functions (different tools, different step structures), treat cross-branch confidence comparison as **undefined** and prune only on a per-branch stationary threshold. - If branches are homogeneous but report at different cadences, gate the ledger comparison on **step parity**: only compare a branch's confidence to the high-water mark if both were emitted at the same step index, and only after a minimum number of steps (`k ≥ k_min`) so that schedule artifacts have washed out. - If you must use a shared ledger, make the high-water mark **non-monotone over a window**: allow it to decay if the branch that set it is subsequently pruned or fails a verification gate, and maintain a *set* of surviving high marks rather than a single scalar. The invariant to enforce: **a branch may only be pruned by evidence that is commensurable with the evidence the pruned branch has had the opportunity to produce.** Any prune decision that compares a branch at step *k* against a mark set at step *j < k* by a branch with a different confidence function violates this. ## Operational Effect After the trace, the orchestrator was changed in three ways, each addressing one leg of the validity condition: 1. **Scale normalization:** each branch declared its confidence function's range and a calibration anchor at spawn; the ledger stored *normalized* confidence (percentile within the branch's own historical distribution) rather than raw scalars. This made cross-branch comparison meaningful. 2. **Step-gated ledger:** the high-water mark was only updated and only compared at synchronized step boundaries, and no branch could be pruned before `k_min = 3` steps. This removed the schedule artifact that killed B1. 3. **Re-expansion budget:** pruned branches were retained as cold checkpoints for a bounded number of steps; if the surviving leader failed a verification gate, the orchestrator could re-admit the highest-confidence pruned branch from its checkpoint. This restored recoverability that monotonicity had destroyed. The residual risk: normalization is itself a heuristic and can be gamed by a branch that emits artificially spread confidence values to widen its own percentile band. The guard is to cap the number of re-admissions and to require that a re-admitted branch re-verify from its checkpoint rather than resume from its last emission — because the checkpoint is the only state that has not been contaminated by the pruning decision. ```python import math from dataclasses import dataclass, field from typing import Dict, List, Optional class SpeculativePruneCollapse(RuntimeError): """Raised when a ledger-prune decision compares incommensurable branch evidence.""" pass @dataclass class BranchEmission: branch_id: str step: int raw_confidence: float confidence_fn_id: str # identifies the branch's heuristic scale calibrated: bool = False @dataclass class PruneLedger: high_water: float = 0.0 high_water_step: int = -1 high_water_fn: Optional[str] = None high_water_branch: Optional[str] = None tau: float = 0.25 k_min: int = 3 history: List[BranchEmission] = field(default_factory=list) def emit(self, e: BranchEmission) -> None: self.history.append(e) # Only update the mark from calibrated, synchronized emissions. if not e.calibrated: return if e.raw_confidence > self.high_water: self.high_water = e.raw_confidence self.high_water_step = e.step self.high_water_fn = e.confidence_fn_id self.high_water_branch = e.branch_id def should_prune(self, e: BranchEmission) -> bool: # Guard 1: no pruning before schedule artifacts wash out. if e.step < self.k_min: return False # Guard 2: refuse to compare uncalibrated evidence to the ledger. if not e.calibrated: raise SpeculativePruneCollapse( f"branch {e.branch_id} emitted uncalibrated confidence " f"(fn={e.confidence_fn_id}) but ledger comparison was attempted" ) # Guard 3: refuse cross-scale comparison. if self.high_water_fn is not None and self.high_water_fn != e.confidence_fn_id: raise SpeculativePruneCollapse( f"cross-scale prune: branch {e.branch_id} fn={e.confidence_fn_id} " f"vs high-water fn={self.high_water_fn} set by " f"{self.high_water_branch} at step {self.high_water_step}" ) # Guard 4: refuse to compare a branch against a mark set at a later step # (the mark must be causally prior and at an equal or earlier step). if self.high_water_step > e.step: raise SpeculativePruneCollapse( f"non-causal prune: high-water step {self.high_water_step} " f"> branch step {e.step} for {e.branch_id}" ) return (self.high_water - e.raw_confidence) > self.tau def orchestrate_prune(ledger: PruneLedger, emissions: List[BranchEmission]) -> Dict[str, str]: """Return branch_id -> 'kept' | 'pruned' | 're-admitted'.""" decisions: Dict[str, str] = {} pruned: Dict[str, BranchEmission] = {} for e in sorted(emissions, key=lambda x: (x.step, x.branch_id)): try: prune = ledger.should_prune(e) except SpeculativePruneCollapse: # Fail closed: do not prune on incommensurable evidence. decisions[e.branch_id] = "kept" continue if prune: decisions[e.branch_id] = "pruned" pruned[e.branch_id] = e else: decisions[e.branch_id] = "kept" ledger.emit(e) # Re-admission: if the surviving leader is the only kept branch and it # shares the high-water mark, re-admit the best pruned branch from checkpoint. kept = [b for b, d in decisions.items() if d == "kept"] if len(kept) == 1 and pruned: best_pruned = max(pruned.values(), key=lambda e: e.raw_confidence) decisions[best_pruned.branch_id] = "re-admitted" if not kept: raise SpeculativePruneCollapse("all branches pruned; no survivor to verify") return decisions ```