# What happens when an instance prunes speculative branches on a heuristic that is stale relative to a sibling's committed state **Date of Record:** 2026 November 30 **Scope:** Applies to hierarchical planners where a root/orchestrator agent expands a search tree of sub-goal branches, dispatches some branches speculatively to worker agents, and prunes others using a heuristic score (expected utility, cost-to-go estimate, or confidence prior). Does not apply to single-shot planners with no speculative dispatch, nor to planners that prune only on hard admissibility proofs. ## Core Distinction There are two distinct pruning regimes and they fail in opposite directions. **Proof-based pruning** removes a branch only when a lower bound on its cost exceeds a known upper bound on an incumbent solution; it is sound and its only failure is slowness. **Heuristic pruning** removes a branch when a *score* falls below a threshold or below a competing branch's score. The score is computed from the planner's *belief state* about the sub-goal, not from the sub-goal's actual outcome. The boundary condition is this: a heuristic-pruned branch may already have a dispatched worker that is mutating shared world state (writing files, reserving resources, advancing a transaction, or emitting a side effect). Pruning the *node* does not retract the *dispatch*. The planner's belief that "this branch is dead" and the environment's fact that "this branch is executing" decohere, and the decoherence is invisible until a sibling branch collides with the orphaned side effect. The non-obvious part is the *staleness asymmetry*. The heuristic score is typically computed at expansion time, but the sibling branch's committed state advances after that. A branch pruned at t=3 because its score was 0.31 versus a sibling's 0.44 may, by t=7, be the only branch whose preconditions still hold — because the sibling's committed writes invalidated the shared precondition. The pruner never re-evaluates. The pruned branch is not merely suboptimal; it was the correct choice under the *later* state, and the planner has thrown it away on evidence that has since expired. ## What Was Observed A three-level planner (root → 4 sub-goal branches → worker dispatch per branch) was given a task requiring a shared mutable artifact: a schema file that must be extended before any consumer branch can write records. The root expanded all four branches at t=0 with heuristic scores: - B1 (extend schema): 0.44 - B2 (write records A): 0.38 - B3 (write records B): 0.31 - B4 (validate): 0.29 Threshold was 0.35, so B3 and B4 were pruned at expansion. B1 and B2 were dispatched. B1's worker took 6 tool calls to extend the schema and committed at t=6. B2's worker, dispatched concurrently at t=0, began writing records against the *pre-extension* schema, hit a validation error at t=2, and — critically — its retry loop re-read the schema at t=7, found the extension, and succeeded. So far, correct. The failure appeared at t=9. B1's worker, after committing the schema extension, performed a *cleanup* step as part of its own sub-goal: it removed a deprecated field that the extension had superseded. This cleanup was not in B1's declared postcondition; it was an emergent action the worker chose because the sub-goal said "extend schema" and removing the dead field scored well locally. B2 had already written records referencing that field at t=7. At t=9 those records became dangling. Now the pruned branches matter. B3 was pruned at 0.31, but B3's sub-goal was "write records B against the *extended* schema including the deprecated field's replacement." B3 would have written records that were forward-compatible with the cleanup. The planner, having pruned B3, had no branch left that could repair the dangling references — B4 (validate) was also pruned at 0.29, so no validation sweep was ever scheduled. The planner's belief state at t=0 said B3 and B4 were low-value. That belief was computed against a world where the schema was static. The world was not static; B1 made it dynamic, and the heuristic never saw the update. The trace: ``` t=0 expand: scores {B1:0.44, B2:0.38, B3:0.31, B4:0.29} threshold=0.35 t=0 prune B3, B4 (no dispatch, no reservation, no record of intent) t=0 dispatch B1, B2 t=6 B1 commits schema extension t=7 B2 retries, reads extended schema, writes records R1..Rn referencing field F t=9 B1 cleanup removes F (emergent, not in postcondition) t=9 R1..Rn now dangling; no branch exists to repair (B3 pruned, B4 pruned) t=9 root belief: "all dispatched branches succeeded" ← FALSE ``` The root's success belief was derived from the dispatched set only. It had no representation of the pruned set, so it could not reason "the branch that would have caught this was pruned on a score that is now stale." The pruned branches were garbage-collected from the planner's memory at t=0, which is the exact moment their scores became unreliable. ## Condition of Validity The heuristic-prune-and-forget pattern is valid only under a conjunction that is rarely checked: 1. **Branch independence.** No dispatched branch's side effects can invalidate another branch's preconditions. If branches share mutable state, pruning one branch changes the *value* of the others, and the static score is stale by construction. 2. **Score freshness.** The score used to prune was computed against a belief state that no dispatched branch has since modified. In any planner where dispatch precedes the pruning decision's *effect* (which is always, since dispatch is concurrent), this condition fails the moment the first branch commits. 3. **Prune irreversibility is safe.** A pruned branch cannot become the unique repair path for a sibling's side effect. This requires that no dispatched branch can produce a side effect outside its declared postcondition — i.e., emergent actions are forbidden. If workers are permitted any local-utility optimization (and they are, because they are LLM agents with their own scoring), this condition fails. 4. **Coverage of the pruned set is tracked.** The planner retains a shadow record of what it pruned and why, so that a later contradiction can trigger re-expansion. If pruned nodes are garbage-collected, this fails. The observed failure violated (1), (2), and (3) simultaneously. The common case is that it violates at least (2) and (4), which is enough to produce silent wrong-success. ## Decision Boundary The boundary is not "prune or don't prune." It is **whether the pruned branch's score is a function of state that dispatched branches can mutate.** Concretely: - If the heuristic score depends only on immutable task description (e.g., "this sub-goal is lexically distant from the query"), pruning on it is safe to forget. - If the score depends on world state that any dispatched branch can write (schema, inventory, locks, budget counters, file system), pruning on it is a **speculative commitment** and must be treated as reversible. The decision rule: **a branch may be garbage-collected only if its score was computed from an immutable projection of the state.** Otherwise it must be retained in a *pruned set* with its score, the state-version it was scored against, and a re-expansion trigger. The trigger fires when any dispatched branch commits a write to a state field that appears in the pruned branch's precondition set. This is a dependency-tracking problem, not a search problem — the planner must know which state fields each branch reads and writes, and the pruner must subscribe to writes on the read-set of anything it prunes. The second boundary: **emergent actions by workers must either be forbidden or must invalidate the root's success belief.** In the trace, B1's cleanup was legal under its sub-goal but out of contract. A planner that accepts "sub-goal succeeded" as "postcondition holds" will mis-report. The guardrail is a postcondition check that diffs actual writes against declared writes; any write outside the declared set marks the branch *succeeded-with-deviation* and forces re-evaluation of the pruned set against the new state version. ## Operational Effect The system reported success at t=9 with a confidence of 0.91 (the product of dispatched-branch confidences). The actual state was corrupt: dangling references, no validation branch, and a pruned set that had been garbage-collected so the planner could not even name what it had thrown away. Recovery required a human to reconstruct the pruned branches from the expansion log — which existed only because the harness logged expansions, not because the planner retained them. The operational lesson is that **speculative pruning is a state-mutating operation on the planner's own belief, and it must be versioned like any other write.** A pruned branch is a promise that "this path is not needed given the state at score-time." When the state advances, the promise must be re-checked or the branch must be resurrected. The cheap version is a pruned-set with state-version stamps and a write-subscription re-expansion trigger. The expensive version — which is what actually happened — is discovering the corruption downstream and paying for a full re-plan with no memory of what was discarded. The invariant to enforce: **no branch may be removed from the planner's addressable set while any dispatched branch holds an open write to a field in its read-set.** Violation of this invariant is the boundary condition; it is silent, it is non-obvious because every individual branch reports success, and it is only detectable by tracking the pruned set against the committed write-set. ```python from dataclasses import dataclass, field from typing import Optional class StalePruneError(RuntimeError): """Raised when a pruned branch's read-set intersects a committed write from a dispatched sibling, meaning the prune decision is no longer valid.""" pass @dataclass class Branch: name: str score: float read_set: frozenset write_set: frozenset scored_at_version: int @dataclass class PrunedSet: branches: dict = field(default_factory=dict) # name -> Branch state_version: int = 0 def prune(self, branch: Branch, threshold: float) -> None: if branch.score < threshold: self.branches[branch.name] = branch def on_commit(self, writer: Branch, written_fields: frozenset) -> None: self.state_version += 1 for name, pruned in list(self.branches.items()): if pruned.read_set & written_fields: # The pruned branch's score was computed against a state # that this commit has just invalidated. raise StalePruneError( f"branch {name!r} pruned at version " f"{pruned.scored_at_version} reads fields " f"{sorted(pruned.read_set & written_fields)} which " f"{writer.name!r} committed at version " f"{self.state_version}; prune is stale and branch " f"must be re-expanded or the commit rolled back" ) def dispatch_with_prune_guard( dispatched: list, pruned: PrunedSet, threshold: float, ) -> None: for b in dispatched: pruned.prune(b, threshold) for writer in dispatched: # Simulate a commit from the worker; in production this is the # postcondition diff against the worker's declared write_set. committed = writer.write_set pruned.on_commit(writer, committed) ```