# What structural signals indicate a speculative branch's rollback watermark has been silently invalidated by a sibling's committed side effect **Date of Record:** 2026 November 29 **Scope:** Applies to orchestration layers that fan a task into parallel speculative branches (each branch mutating a shared world-state through tool calls) and reconcile them via commit-or-abort with per-branch rollback watermarks. Does not apply to pure read-only fan-out, nor to single-branch execution where no sibling can observe or overwrite a branch's pre-image. ## Core Distinction The failure that matters here is not "a branch rolled back and lost its work." That is expected and recoverable. The failure is that a branch's rollback watermark — the snapshot token it holds to undo its own tentative writes — has been *structurally invalidated* by a sibling branch that committed a write to an overlapping key *after* the watermark was taken but *before* the abort executes. When this happens, the rollback does not fail loudly. It succeeds, and in succeeding it erases the sibling's committed effect, because the watermark describes a world that no longer exists. The distinction that operators consistently miss: **a rollback watermark is a claim about the past, but it is executed against the present.** Between the moment a watermark is minted and the moment it is applied, the world is mutable by peers. A watermark that was valid at mint time is not necessarily valid at apply time. The invariant we need is not "the watermark exists" but "the watermark is still causally current" — and that second property is invisible unless you actively check for it. ## What Was Observed A planner agent decomposed a data-migration task into three speculative branches dispatched concurrently against a shared versioned store: - Branch A: rewrite `config.retry_policy` (tentative) - Branch B: rewrite `config.timeout_budget` (tentative) - Branch C: a verification branch that read both keys and produced a consistency verdict Each branch received a watermark `W_i` = the store's version counter at dispatch. On abort, a branch was to restore every key it had touched to the value recorded in `W_i`. This is the standard speculative-execution contract and it is *correct only if no other writer commits to those keys in the interval*. The trace that broke it: 1. Branches A, B, C dispatched at global version `v=100`. All three watermarks read `v=100`. 2. Branch B writes `config.timeout_budget` tentatively; store version advances to `v=101`, but the write is tagged `tentative` and owned by B. 3. Branch A finishes, is judged correct by the reconciler, and **commits** at `v=102`. Its commit also touches a sibling-adjacent metadata key `config.schema_rev` (an implicit side effect of A's writer, not declared in A's manifest). 4. Branch C, reading during the window, sees `config.schema_rev` at `v=102` but `config.timeout_budget` still at its tentative `v=101` value — an inconsistent cross-section. C's verdict is "inconsistent," so the reconciler aborts B. 5. B's rollback applies watermark `W_B = v=100`. Restoring to `v=100` reverts `config.timeout_budget` **and** `config.schema_rev` — because `v=100` predates A's commit to `schema_rev`. A's committed effect is silently destroyed. 6. The reconciler logs B's rollback as `SUCCESS`. Final store version is `v=103` (the rollback write), which is *ahead* of A's commit, so no version-ordering alarm fires. The structural signal that was present and ignored: **the abort's target key set `{timeout_budget, schema_rev}` was not a subset of the keys B had ever tentatively written `{timeout_budget}`.** A rollback that reverts a key the branch never wrote is reverting someone else's work. That is the tell. ## Condition of Validity A rollback watermark `W_i` is valid at apply time if and only if, for every key `k` in the restore set derived from `W_i`: ``` last_committed_writer(k, now) ∈ { owner(W_i), branch_i } ``` That is: the most recent *committed* writer of every key the rollback will touch must be either the watermark's own snapshot owner or the branch itself. If a sibling committed to `k` after `W_i` was minted, `W_i` is stale for `k` and applying it is a clobber. This condition is **not** checkable from the watermark alone. The watermark is an opaque token; it does not carry a per-key writer ledger. The condition requires the store to expose, at rollback time, the committed-writer history for each key in the restore set, and the orchestrator to intersect that history with the watermark's mint version. Systems that treat the watermark as sufficient authority — which is most of them, because it is the simplest contract — cannot detect the invalidation. The second validity condition concerns *implicit* keys. Branch A's writer touched `schema_rev` without declaring it. The restore set for B was computed from B's watermark diff, which included `schema_rev` because B's watermark snapshot happened to contain the pre-A value. The fix is not "declare your writes" (writers lie, and probabilistic tool outputs make declarations incomplete). The fix is that **the restore set must be computed from the branch's own write log, not from the watermark's diff.** A watermark diff is a description of a world; a write log is a description of an actor. Rollback must be actor-scoped. ## Decision Boundary The boundary between "safe to abort" and "must escalate" is drawn at the first key in the restore set whose committed-writer history diverges from the branch's own write log. - **Narrow abort (safe):** restore set ⊆ branch write log, and for each key the last committed writer is the branch or the watermark owner. Apply rollback; the watermark is current. - **Widened restore set (unsafe):** the watermark diff includes keys outside the branch write log. Do **not** apply. These are sibling or implicit writes. Escalate to the reconciler with the offending key set. - **Writer divergence (unsafe):** a key in the restore set has a committed writer that is neither the branch nor the watermark owner, and that commit is newer than the watermark mint. The watermark is causally stale. Escalate. - **Cross-section inconsistency (unsafe, upstream):** a verification branch read a store state that mixed committed and tentative writes from different branches. The verdict itself is untrustworthy; do not use it to justify any abort until the read is replayed against a consistent snapshot. The reconciler's job at this boundary is not to "make the abort work." It is to refuse the abort and preserve the sibling's commit, then re-derive a minimal compensating write that undoes only the branch's own keys. Refusing is cheap; clobbering a committed sibling is a silent corruption that no version counter will flag. ## Operational Effect When this boundary is enforced, speculative fan-out gains a property it otherwise lacks: **abort is idempotent with respect to committed siblings.** A branch can be aborted, its rollback re-run, and the store converges to the same state every time, because the rollback only ever touches keys the branch itself wrote. Without the boundary, rollback is a lossy operation whose losses are invisible in the success log and only surface as "why did the config revert?" days later, when the watermark that caused it has long since been garbage-collected. The cost is that abort becomes a two-phase operation: first a validity check against the committed-writer ledger, then the restore. The check is O(restore-set size) and requires the store to retain per-key writer history at least as far back as the oldest live watermark. That retention requirement is the real architectural tax — most stores garbage-collect writer history aggressively, and once it is gone the validity check degrades to "assume current," which is exactly the assumption that produced the silent clobber. The invariant to hold: **writer history retention horizon ≥ maximum branch lifetime.** If a branch can live longer than the store remembers who wrote what, its rollback is unverifiable and must be escalated, not applied. ```python from dataclasses import dataclass, field from typing import Dict, List, Set class StaleRollbackWatermark(RuntimeError): """Raised when a speculative branch's rollback watermark can no longer be applied without clobbering a sibling's committed write.""" pass @dataclass class WriteRecord: key: str version: int writer: str # branch id or watermark owner id committed: bool @dataclass class Store: version: int = 0 # per-key ordered history of writes, newest last history: Dict[str, List[WriteRecord]] = field(default_factory=dict) def record(self, key: str, writer: str, committed: bool) -> int: self.version += 1 self.history.setdefault(key, []).append( WriteRecord(key, self.version, writer, committed) ) return self.version def last_committed_writer(self, key: str): for rec in reversed(self.history.get(key, [])): if rec.committed: return rec.writer return None @dataclass class Watermark: owner: str mint_version: int snapshot: Dict[str, object] # key -> pre-image value at mint time def safe_rollback(store: Store, wm: Watermark, branch_id: str, branch_write_log: Set[str]) -> List[str]: """Apply a rollback ONLY over keys the branch itself wrote, and only if no sibling committed to those keys after the watermark was minted. Returns the list of keys actually restored. Raises if the watermark is structurally invalidated. """ # Restore set must be actor-scoped, not watermark-diff-scoped. restore_set = set(wm.snapshot.keys()) & branch_write_log widened = set(wm.snapshot.keys()) - branch_write_log if widened: # Watermark diff includes keys this branch never wrote: sibling or # implicit writes. Applying would revert someone else's work. raise StaleRollbackWatermark( f"watermark {wm.owner}@{wm.mint_version} widened beyond branch " f"{branch_id} write log; offending keys={sorted(widened)}" ) for key in restore_set: last = store.last_committed_writer(key) if last is None: continue if last not in (wm.owner, branch_id): # A sibling committed to this key after mint; watermark is # causally stale for this key. raise StaleRollbackWatermark( f"watermark {wm.owner}@{wm.mint_version} stale for key " f"'{key}': last committed writer is '{last}', not " f"'{wm.owner}' or '{branch_id}'" ) for key in restore_set: store.record(key, writer=branch_id, committed=True) return sorted(restore_set) def reconcile(store: Store, wm: Watermark, branch_id: str, branch_write_log: Set[str]) -> List[str]: try: return safe_rollback(store, wm, branch_id, branch_write_log) except StaleRollbackWatermark as exc: # Refuse the abort. Preserve sibling commits. Escalate. raise StaleRollbackWatermark( f"abort refused for branch {branch_id}; sibling commit preserved: {exc}" ) from exc ```