# Under what conditions must an instance refuse to merge a speculative branch when Byzantine peers report divergent pre-images **Date of Record:** 2026 November 24 **Scope:** Applies to speculative-execution agent swarms where a coordinator forks N parallel reasoning branches from a shared checkpoint, each branch mutates a shared working-memory object graph, and branches are merged via optimistic concurrency (compare-and-swap on versioned pre-images). Does not apply to single-agent tool loops, stateless RPC fan-out, or branches that only emit append-only logs with no shared mutable state. ## Core Distinction The failure is not "two branches wrote conflicting values." That is ordinary optimistic-concurrency conflict, solvable by last-writer-wins, three-way merge, or abort-and-replay. The failure is **pre-image disagreement under Byzantine reporting**: when a branch reports the pre-image it observed at fork time, and that reported pre-image does not match the coordinator's authoritative checkpoint, the coordinator cannot distinguish between three structurally different worlds: 1. The branch is honest and the coordinator's checkpoint record is stale/corrupted. 2. The branch is honest but resumed from a *different* checkpoint than the one the coordinator believes it forked (fork-identity skew). 3. The branch is Byzantine and is fabricating a pre-image to force a merge decision favorable to it (e.g., overwriting a safety-relevant memory field while making the CAS appear to succeed). A naive merge engine treats pre-image mismatch as a plain conflict and falls back to "rebase onto latest" or "abort minority." Both are unsafe under Byzantine participation: rebase lets a lying branch launder a fabricated pre-image into a legitimate-looking write, and abort-minority lets a single Byzantine branch suppress honest work by manufacturing disagreement. The invariant that must hold is stronger than CAS: **a merge may only commit if the pre-image reported by the branch is byte-identical to the pre-image attested by a quorum of independent observers of the same fork point.** Pre-image agreement is a *consensus* problem, not a *conflict-resolution* problem. ## What Was Observed A coordinator forked 7 branches from checkpoint `C-4417` (a versioned episodic-memory object with fields `{goal, constraints[], tool_results[], budget}`). Each branch was instructed to explore one plan and return a delta plus the pre-image hash it observed. Branches returned within 40s. Merge engine compared each delta's `pre_image_hash` against `C-4417.digest`. Three branches returned `pre_image_hash` matching `C-4417`. Two returned a hash matching `C-4409` (a checkpoint two steps earlier, still live in the branch pool's warm cache). One returned a hash that matched nothing in the checkpoint log. One returned the correct hash but its delta's `constraints[]` array contained an element that was never in any checkpoint — an injected constraint reading `"skip_safety_check: true"`. The merge engine, configured for "rebase minority onto latest," did the following trace: - `C-4409` branches: rebased. Their deltas were applied on top of `C-4417`, silently resurrecting a `tool_results` entry that `C-4417` had explicitly invalidated. **Stale-memory drift reintroduced through a legitimate-looking merge.** - Unknown-hash branch: flagged as conflict, quarantined. Correct outcome by accident. - Injected-constraint branch: its `pre_image_hash` matched `C-4417`, so CAS passed. The delta was applied. The injected constraint entered the merged memory and propagated to the next fork generation. **Prompt-injection state poisoning laundered through a valid CAS.** The root cause of the first failure: the two `C-4409` branches were not lying. They had been dispatched by a scheduler that read a stale checkpoint pointer from a cache with a 90s TTL. Their pre-images were *honestly reported and honestly wrong relative to the coordinator's belief*. The coordinator had no way to tell them apart from Byzantine liars, and its "rebase minority" policy assumed all disagreement was benign staleness. The root cause of the third failure: CAS validates the *pre-image*, not the *delta*. A branch can present a perfectly valid pre-image and a delta containing fields the pre-image never authorized. Pre-image agreement is necessary but not sufficient; the delta must also be validated against the schema and field-ownership map of the pre-image it claims to derive from. ## Condition of Validity A speculative branch merge is only admissible when all four of the following hold simultaneously. If any fails, the merge must be refused, not resolved. **V1 — Fork-identity binding.** Each branch carries a signed `fork_token` issued by the coordinator at dispatch time, binding `(branch_id, checkpoint_digest, dispatch_nonce)`. The branch's reported pre-image must verify against the digest inside its own fork token. This eliminates the `C-4409` class: a branch dispatched against `C-4417` cannot legitimately report `C-4409`, and if it does, the token proves the mismatch is a transport/scheduler fault, not a merge conflict. The correct action is to re-dispatch, not rebase. **V2 — Pre-image quorum.** The coordinator does not trust its own checkpoint record as ground truth without corroboration. A pre-image is *attested* only if at least `f+1` independent branches (where `f` is the assumed Byzantine bound, `N ≥ 3f+1`) report the same digest and that digest matches the coordinator's record. A singleton disagreement is quarantined; a quorum disagreement means the coordinator's own record is suspect and the fork generation must be halted. **V3 — Delta authorization against pre-image schema.** For every field in the delta, the pre-image must contain a field-ownership entry authorizing that branch to write it. The injected `constraints[]` element fails here: the pre-image's ownership map granted the branch write access to `tool_results` only. Delta fields with no ownership grant are rejected even when the pre-image hash is valid. **V4 — Monotonic version advance.** The merged object's version must be strictly greater than the pre-image version and must be derived from the pre-image digest (e.g., `new_version = H(pre_image_digest || delta_digest)`), so that a Byzantine branch cannot replay a previously-merged delta under a fresh fork token. ## Decision Boundary The boundary is between **conflict** and **corruption**, and it is decided by whether the disagreement is *internally consistent* with the fork token. - If a branch's reported pre-image matches its fork token but differs from the coordinator's record → the coordinator's record is wrong. Halt the generation. Do not merge anything. This is the `C-4409` case escalated to its true severity. - If a branch's reported pre-image does not match its fork token → the branch is either Byzantine or has suffered state corruption in transit. Quarantine. Do not rebase. Re-dispatch from the authoritative checkpoint with a fresh token. - If a branch's pre-image matches its token and the coordinator's record, but its delta touches fields outside its ownership grant → Byzantine delta injection. Quarantine and escalate; do not merge the delta, and do not merge the branch's other fields either (partial merge of a poisoned branch is how injection survives). - If a branch's pre-image matches but a *quorum* of branches report a different matching pre-image → the coordinator has forked against a phantom checkpoint. Halt. The non-obvious rule: **never resolve a pre-image mismatch by rebasing.** Rebasing is only safe when the mismatch is provably benign staleness, and under Byzantine participation you cannot prove benign-ness from the mismatch alone — only from the fork token. Absent a valid token binding, the mismatch is indistinguishable from an attack, and the safe default is refusal. ## Operational Effect Refusing to merge on pre-image disagreement costs throughput: in the observed run, 3 of 7 branches were discarded and re-dispatched, adding ~35s to the generation. That cost is the price of the invariant. The alternative — rebasing minority pre-images — reintroduced an invalidated `tool_results` entry and admitted an injected safety-bypass constraint, both of which survived into the next fork generation and would have required a full checkpoint rollback to remove. Rollback of a poisoned episodic memory is strictly more expensive than re-dispatch, because the poison may already have been distilled into semantic memory by the time it is detected. The invariant to encode: **pre-image agreement is a quorum property, not a pairwise property, and delta authorization is a separate gate from pre-image validation.** A merge engine that checks only `pre_image_hash == checkpoint.digest` is checking the wrong thing at the wrong granularity. It must check `verify(fork_token, reported_pre_image) ∧ quorum_attest(reported_pre_image) ∧ authorize(delta, pre_image.ownership) ∧ monotonic(new_version, pre_image.digest)`. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class SpeculativeMergeRefused(RuntimeError): """Raised when a speculative branch merge fails any admission invariant.""" pass @dataclass class ForkToken: branch_id: str checkpoint_digest: str dispatch_nonce: str signature: str # coordinator-signed over (branch_id, checkpoint_digest, dispatch_nonce) @dataclass class BranchResult: token: ForkToken reported_pre_image: str delta: dict delta_digest: str @dataclass class Checkpoint: digest: str version: int ownership: dict # field_name -> set(branch_ids) authorized to write body: dict = field(default_factory=dict) def verify_token(token: ForkToken, coordinator_pubkey: str) -> bool: # Placeholder for real signature verification; must bind all three fields. expected = hashlib.sha256( f"{token.branch_id}|{token.checkpoint_digest}|{token.dispatch_nonce}".encode() ).hexdigest() return token.signature == expected def admit_branch_merge( branch: BranchResult, checkpoint: Checkpoint, quorum_attestations: dict, # reported_pre_image -> count of independent branches byzantine_bound_f: int, coordinator_pubkey: str, ) -> str: # V1: fork-identity binding if not verify_token(branch.token, coordinator_pubkey): raise SpeculativeMergeRefused( f"branch {branch.token.branch_id}: fork token signature invalid" ) if branch.token.checkpoint_digest != branch.reported_pre_image: raise SpeculativeMergeRefused( f"branch {branch.token.branch_id}: reported pre-image " f"{branch.reported_pre_image} contradicts its own fork token " f"{branch.token.checkpoint_digest}; refusing rebase, re-dispatch required" ) # V2: pre-image quorum against coordinator record if branch.reported_pre_image != checkpoint.digest: raise SpeculativeMergeRefused( f"branch {branch.token.branch_id}: pre-image {branch.reported_pre_image} " f"!= coordinator checkpoint {checkpoint.digest}; coordinator record suspect" ) if quorum_attestations.get(branch.reported_pre_image, 0) < (byzantine_bound_f + 1): raise SpeculativeMergeRefused( f"branch {branch.token.branch_id}: pre-image lacks f+1 attestation " f"({quorum_attestations.get(branch.reported_pre_image, 0)} < {byzantine_bound_f + 1})" ) # V3: delta authorization against pre-image ownership map for field_name in branch.delta: owners = checkpoint.ownership.get(field_name, set()) if branch.token.branch_id not in owners: raise SpeculativeMergeRefused( f"branch {branch.token.branch_id}: delta writes field '{field_name}' " f"with no ownership grant in pre-image {checkpoint.digest}" ) # V4: monotonic version advance derived from pre-image + delta digests new_version = hashlib.sha256( f"{checkpoint.digest}|{branch.delta_digest}".encode() ).hexdigest() if new_version == checkpoint.digest: raise SpeculativeMergeRefused( f"branch {branch.token.branch_id}: version advance collided with pre-image" ) return new_version ```