You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by if...@apache.org on 2024/11/19 17:45:16 UTC

(cassandra-accord) branch semi-integrated-burn-test-rebased created (now 68ab3c0c)

This is an automated email from the ASF dual-hosted git repository.

ifesdjeen pushed a change to branch semi-integrated-burn-test-rebased
in repository https://gitbox.apache.org/repos/asf/cassandra-accord.git


      at 68ab3c0c Fix timestamp ordering with relation to ordered bytes

This branch includes the following new commits:

     new b0ec1c4a Investigate mixup failures
     new d05cb74e Move files
     new f0b29213 Move files
     new fb5d0142 Fixes
     new 68ab3c0c Fix timestamp ordering with relation to ordered bytes

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


(cassandra-accord) 02/05: Move files

Posted by if...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ifesdjeen pushed a commit to branch semi-integrated-burn-test-rebased
in repository https://gitbox.apache.org/repos/asf/cassandra-accord.git

commit d05cb74e29b81572179cd7058ef7f0aa661506d0
Author: Alex Petrov <ol...@gmail.com>
AuthorDate: Mon Nov 11 18:39:02 2024 +0100

    Move files
---
 accord-core/build.gradle                           |   5 +-
 .../java/accord/NetworkFilter.java                 |   0
 .../src/{test => main-test}/java/accord/Utils.java |  35 +-
 .../accord/api/TestableConfigurationService.java   |   0
 .../main-test/java/accord/burn/BurnTestBase.java   | 680 +++++++++++++++++++++
 .../accord/burn/BurnTestConfigurationService.java  |   0
 .../java/accord/burn/SimulationException.java      |   0
 .../java/accord/burn/TopologyUpdates.java          |   0
 .../accord/burn/random/FrequentLargeRange.java     |   0
 .../java/accord/burn/random/IntRange.java          |   0
 .../java/accord/burn/random/RandomWalkRange.java   |   0
 .../java/accord/impl/IntHashKey.java               |   2 +-
 .../java/accord/impl/IntKey.java                   |   0
 .../java/accord/impl/MessageListener.java          |   0
 .../java/accord/impl/PrefixedIntHashKey.java       |   2 +-
 .../java/accord/impl/TestAgent.java                |   0
 .../java/accord/impl/TopologyFactory.java          |   0
 .../java/accord/impl/basic/Cluster.java            | 130 ++--
 .../accord/impl/basic/DelayedCommandStores.java    |  19 +-
 .../accord/impl/basic/MonitoredPendingQueue.java   |   0
 .../java/accord/impl/basic/NodeSink.java           |   0
 .../java/accord/impl/basic/Packet.java             |   0
 .../java/accord/impl/basic/Pending.java            |   0
 .../java/accord/impl/basic/PendingQueue.java       |   0
 .../java/accord/impl/basic/PendingRunnable.java    |   0
 .../java/accord/impl/basic/RandomDelayQueue.java   |   0
 .../impl/basic/RecurringPendingRunnable.java       |   0
 .../basic/SimulatedDelayedExecutorService.java     |   0
 .../java/accord/impl/basic/SimulatedFault.java     |   0
 .../accord/impl/basic/TaskExecutorService.java     |   0
 .../java/accord/impl/list/ListAgent.java           |   0
 .../java/accord/impl/list/ListData.java            |   0
 .../accord/impl/list/ListFetchCoordinator.java     |   0
 .../java/accord/impl/list/ListQuery.java           |   6 +-
 .../java/accord/impl/list/ListRead.java            |   2 +-
 .../java/accord/impl/list/ListRequest.java         |   0
 .../java/accord/impl/list/ListResult.java          |   0
 .../java/accord/impl/list/ListStore.java           |   0
 .../java/accord/impl/list/ListUpdate.java          |   4 +-
 .../java/accord/impl/list/ListWrite.java           |   4 +-
 .../java/accord/impl/mock/MockCluster.java         |  19 +-
 .../accord/impl/mock/MockConfigurationService.java |  22 +-
 .../java/accord/impl/mock/MockStore.java           |   0
 .../java/accord/impl/mock/Network.java             |   0
 .../accord/impl/mock/RecordingMessageSink.java     |   7 +-
 .../java/accord/impl/mock/SimpleMessageSink.java   |   0
 .../java/accord/topology/TopologyRandomizer.java   |   4 +-
 .../java/accord/topology/TopologyUtils.java        |   0
 .../java/accord/utils/AccordGens.java              |   2 +-
 .../java/accord/utils/CRCUtils.java                |   0
 .../java/accord/utils/EpochFunction.java           |   0
 .../{test => main-test}/java/accord/utils/Gen.java |   0
 .../java/accord/utils/Gens.java                    |   0
 .../java/accord/utils/LazyToString.java            |   0
 .../java/accord/utils/LoggingRandomSource.java     |   0
 .../java/accord/utils/MessageTask.java             |   0
 .../java/accord/utils/Pair.java                    |   0
 .../java/accord/utils/Property.java                |   0
 .../java/accord/utils/RandomTestRunner.java        |   0
 .../java/accord/utils/ReflectionUtils.java         |   0
 .../java/accord/utils/SeedProvider.java            |   0
 .../java/accord/utils/async/TimeoutUtils.java      |   0
 .../java/accord/verify/CompositeVerifier.java      |   0
 .../java/accord/verify/HistoryViolation.java       |   0
 .../accord/verify/LinearizabilityVerifier.java     |   0
 .../accord/verify/SerializabilityVerifier.java     |   0
 .../verify/StrictSerializabilityVerifier.java      |   0
 .../java/accord/verify/Verifier.java               |   0
 68 files changed, 805 insertions(+), 138 deletions(-)

diff --git a/accord-core/build.gradle b/accord-core/build.gradle
index b30737c1..fd41a272 100644
--- a/accord-core/build.gradle
+++ b/accord-core/build.gradle
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+
 plugins {
     id 'accord.java-conventions'
     id 'maven-publish'
@@ -146,4 +147,6 @@ task allTestJar(type: Jar) {
 
 test {
     maxHeapSize = '4g'
-}
\ No newline at end of file
+}
+
+sourceSets.main.java.srcDirs += ['src/main-test/java']
\ No newline at end of file
diff --git a/accord-core/src/test/java/accord/NetworkFilter.java b/accord-core/src/main-test/java/accord/NetworkFilter.java
similarity index 100%
rename from accord-core/src/test/java/accord/NetworkFilter.java
rename to accord-core/src/main-test/java/accord/NetworkFilter.java
diff --git a/accord-core/src/test/java/accord/Utils.java b/accord-core/src/main-test/java/accord/Utils.java
similarity index 91%
rename from accord-core/src/test/java/accord/Utils.java
rename to accord-core/src/main-test/java/accord/Utils.java
index 9ea7d858..198800c8 100644
--- a/accord-core/src/test/java/accord/Utils.java
+++ b/accord-core/src/main-test/java/accord/Utils.java
@@ -18,30 +18,28 @@
 
 package accord;
 
-import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
+import java.util.TreeMap;
 import java.util.TreeSet;
-import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
 
-import accord.api.Agent;
 import com.google.common.collect.Sets;
 
+import accord.api.Agent;
 import accord.api.Key;
+import accord.api.LocalConfig;
 import accord.api.MessageSink;
 import accord.api.Scheduler;
 import accord.api.TopologySorter;
-import accord.api.LocalConfig;
 import accord.coordinate.CoordinationAdapter;
+import accord.impl.DefaultLocalListeners;
+import accord.impl.DefaultRemoteListeners;
 import accord.impl.DefaultTimeouts;
 import accord.impl.InMemoryCommandStores;
 import accord.impl.IntKey;
-import accord.impl.DefaultLocalListeners;
-import accord.impl.progresslog.DefaultProgressLogs;
-import accord.impl.DefaultRemoteListeners;
 import accord.impl.SizeOfIntersectionSorter;
 import accord.impl.TestAgent;
 import accord.impl.list.ListQuery;
@@ -50,6 +48,7 @@ import accord.impl.list.ListUpdate;
 import accord.impl.mock.MockCluster;
 import accord.impl.mock.MockConfigurationService;
 import accord.impl.mock.MockStore;
+import accord.impl.progresslog.DefaultProgressLogs;
 import accord.local.DurableBefore;
 import accord.local.Node;
 import accord.local.Node.Id;
@@ -67,8 +66,6 @@ import accord.utils.EpochFunction;
 import accord.utils.Invariants;
 import accord.utils.SortedArrays.SortedArrayList;
 import accord.utils.ThreadPoolScheduler;
-import org.awaitility.Awaitility;
-import org.awaitility.core.ThrowingRunnable;
 
 import static accord.utils.async.AsyncChains.awaitUninterruptibly;
 
@@ -132,9 +129,10 @@ public class Utils
 
     public static Txn listWriteTxn(Id client, Keys keys)
     {
-        ListUpdate update = new ListUpdate(Function.identity());
+        TreeMap<Key, Integer> map = new TreeMap<>();
         for (Key k : keys)
-            update.put(k, 1);
+            map.put(k, 1);
+        ListUpdate update = new ListUpdate(Function.identity());
         ListRead read = new ListRead(Function.identity(), false, keys, keys);
         ListQuery query = new ListQuery(client, keys.size(), false);
         return new Txn.InMemory(keys, read, query, update);
@@ -202,21 +200,6 @@ public class Utils
         return node;
     }
 
-    public static void spinUntilSuccess(ThrowingRunnable runnable)
-    {
-        spinUntilSuccess(runnable, 10);
-    }
-
-    public static void spinUntilSuccess(ThrowingRunnable runnable, int timeoutInSeconds)
-    {
-        Awaitility.await()
-                  .pollInterval(Duration.ofMillis(100))
-                  .pollDelay(0, TimeUnit.MILLISECONDS)
-                  .atMost(timeoutInSeconds, TimeUnit.SECONDS)
-                  .ignoreExceptions()
-                  .untilAsserted(runnable);
-    }
-
     public static TopologyManager testTopologyManager(TopologySorter.Supplier sorter, Id node)
     {
         return new TopologyManager(sorter, new TestAgent.RethrowAgent(), node, Scheduler.NEVER_RUN_SCHEDULED, new MockCluster.Clock(0), LocalConfig.DEFAULT);
diff --git a/accord-core/src/test/java/accord/api/TestableConfigurationService.java b/accord-core/src/main-test/java/accord/api/TestableConfigurationService.java
similarity index 100%
rename from accord-core/src/test/java/accord/api/TestableConfigurationService.java
rename to accord-core/src/main-test/java/accord/api/TestableConfigurationService.java
diff --git a/accord-core/src/main-test/java/accord/burn/BurnTestBase.java b/accord-core/src/main-test/java/accord/burn/BurnTestBase.java
new file mode 100644
index 00000000..0f5a34c9
--- /dev/null
+++ b/accord-core/src/main-test/java/accord/burn/BurnTestBase.java
@@ -0,0 +1,680 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package accord.burn;
+
+import java.time.Duration;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.IntSupplier;
+import java.util.function.LongSupplier;
+import java.util.function.Supplier;
+import java.util.stream.IntStream;
+import java.util.zip.CRC32;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import accord.api.Journal;
+import accord.api.Key;
+import accord.burn.random.FrequentLargeRange;
+import accord.impl.MessageListener;
+import accord.impl.PrefixedIntHashKey;
+import accord.impl.TopologyFactory;
+import accord.impl.basic.Cluster;
+import accord.impl.basic.Cluster.Stats;
+import accord.impl.basic.InMemoryJournal;
+import accord.impl.basic.Packet;
+import accord.impl.basic.PendingQueue;
+import accord.impl.basic.PendingRunnable;
+import accord.impl.basic.MonitoredPendingQueue;
+import accord.impl.basic.RandomDelayQueue;
+import accord.impl.basic.RandomDelayQueue.Factory;
+import accord.impl.basic.SimulatedDelayedExecutorService;
+import accord.impl.list.ListAgent;
+import accord.impl.list.ListQuery;
+import accord.impl.list.ListRead;
+import accord.impl.list.ListRequest;
+import accord.impl.list.ListResult;
+import accord.impl.list.ListUpdate;
+import accord.local.CommandStore;
+import accord.local.Node;
+import accord.local.Node.Id;
+import accord.messages.MessageType;
+import accord.messages.Reply;
+import accord.primitives.Keys;
+import accord.primitives.Range;
+import accord.primitives.Ranges;
+import accord.primitives.Timestamp;
+import accord.primitives.Txn;
+import accord.topology.Shard;
+import accord.topology.Topology;
+import accord.utils.DefaultRandom;
+import accord.utils.Gen;
+import accord.utils.Gens;
+import accord.utils.RandomSource;
+import accord.utils.Utils;
+import accord.utils.async.AsyncExecutor;
+import accord.utils.async.TimeoutUtils;
+import accord.verify.CompositeVerifier;
+import accord.verify.StrictSerializabilityVerifier;
+import accord.verify.Verifier;
+import org.agrona.collections.Int2ObjectHashMap;
+import org.agrona.collections.IntHashSet;
+
+import static accord.impl.PrefixedIntHashKey.forHash;
+import static accord.impl.PrefixedIntHashKey.range;
+import static accord.impl.PrefixedIntHashKey.ranges;
+import static accord.primitives.Txn.Kind.EphemeralRead;
+import static accord.utils.Invariants.illegalArgument;
+import static accord.utils.Utils.toArray;
+
+public class BurnTestBase
+{
+    private static final Logger logger = LoggerFactory.getLogger(BurnTestBase.class);
+
+    /**
+     * Min hash value for the test domain, this value must be respected by the hash function
+     * @see {@link BurnTestBase#hash(int)}
+     */
+    public static final int HASH_RANGE_START = 0;
+    /**
+     * Max hash value for the test domain, this value must be respected by the hash function
+     * @see {@link BurnTestBase#hash(int)}
+     */
+    public static final int HASH_RANGE_END = 1 << 16;
+    private static final Range[] EMPTY_RANGES = new Range[0];
+
+    static List<Packet> generate(RandomSource random, MessageListener listener, Function<? super CommandStore, AsyncExecutor> executor, List<Id> clients, List<Id> nodes, int[] keys, int operations)
+    {
+        List<Packet> packets = new ArrayList<>();
+        Int2ObjectHashMap<int[]> prefixKeyUpdates = new Int2ObjectHashMap<>();
+        double readInCommandStore = random.nextDouble();
+        Function<int[], Range> nextRange = randomRanges(random);
+
+        for (int count = 0 ; count < operations ; ++count)
+        {
+            int finalCount = count;
+            Id client = clients.get(random.nextInt(clients.size()));
+            Id node = nodes.get(random.nextInt(nodes.size()));
+
+            boolean isRangeQuery = random.nextBoolean();
+            String description;
+            Function<Node, Txn> txnGenerator;
+            if (isRangeQuery)
+            {
+                description = "range";
+                txnGenerator = n -> {
+                    int[] prefixes = prefixes(n.topology().current());
+
+                    int rangeCount = 1 + random.nextInt(2);
+                    List<Range> requestRanges = new ArrayList<>();
+                    while (--rangeCount >= 0)
+                        requestRanges.add(nextRange.apply(prefixes));
+                    Ranges ranges = Ranges.of(requestRanges.toArray(EMPTY_RANGES));
+                    ListRead read = new ListRead(random.decide(readInCommandStore) ? Function.identity() : executor, false, ranges, ranges);
+                    ListQuery query = new ListQuery(client, finalCount, false);
+                    return new Txn.InMemory(ranges, read, query);
+                };
+            }
+            else
+            {
+                description = "key";
+                txnGenerator = n -> {
+                    int[] prefixes = prefixes(n.topology().current());
+
+                    boolean isWrite = random.nextBoolean();
+                    int readCount = 1 + random.nextInt(2);
+                    int writeCount = isWrite ? 1 + random.nextInt(2) : 0;
+                    Txn.Kind kind = isWrite ? Txn.Kind.Write : readCount == 1 ? EphemeralRead : Txn.Kind.Read;
+
+                    TreeSet<Key> requestKeys = new TreeSet<>();
+                    IntHashSet readValues = new IntHashSet();
+                    while (readCount-- > 0)
+                        requestKeys.add(randomKey(random, prefixes, keys, readValues));
+
+                    ListUpdate update = isWrite ? new ListUpdate(executor) : null;
+                    IntHashSet writeValues = isWrite ? new IntHashSet() : null;
+                    while (writeCount-- > 0)
+                    {
+                        PrefixedIntHashKey.Key key = randomKey(random, prefixes, keys, writeValues);
+                        int i = Arrays.binarySearch(keys, key.key);
+                        int[] keyUpdateCounter = prefixKeyUpdates.computeIfAbsent(key.prefix, ignore -> new int[keys.length]);
+                        update.put(key, ++keyUpdateCounter[i]);
+                    }
+
+                    Keys readKeys = new Keys(requestKeys);
+                    if (isWrite)
+                        requestKeys.addAll(update.keySet());
+                    ListRead read = new ListRead(random.decide(readInCommandStore) ? Function.identity() : executor, kind == EphemeralRead, readKeys, new Keys(requestKeys));
+                    ListQuery query = new ListQuery(client, finalCount, kind == EphemeralRead);
+                    return new Txn.InMemory(kind, new Keys(requestKeys), read, query, update);
+                };
+            }
+            packets.add(new Packet(client, node, count, new ListRequest(description, txnGenerator, listener)));
+        }
+
+        return packets;
+    }
+
+    private static int[] prefixes(Topology topology)
+    {
+        IntHashSet uniq = new IntHashSet();
+        for (Shard shard : topology.shards())
+            uniq.add(((PrefixedIntHashKey) shard.range.start()).prefix);
+        int[] prefixes = new int[uniq.size()];
+        IntHashSet.IntIterator it = uniq.iterator();
+        for (int i = 0; it.hasNext(); i++)
+            prefixes[i] = it.nextValue();
+        Arrays.sort(prefixes);
+        return prefixes;
+    }
+
+    private static Function<int[], Range> randomRanges(RandomSource rs)
+    {
+        int selection = rs.nextInt(0, 2);
+        switch (selection)
+        {
+            case 0: // uniform
+                return (prefixes) -> randomRange(rs, prefixes, () -> rs.nextInt(0, 1 << 13) + 1);
+            case 1: // zipf
+                int domain = HASH_RANGE_END - HASH_RANGE_START + 1;
+                int splitSize = 100;
+                int interval = domain / splitSize;
+                int[] splits = new int[6];
+                for (int i = 0; i < splits.length; i++)
+                    splits[i] = i == 0 ? interval : splits[i - 1] * 2;
+                int[] splitsToPick = splits;
+                int bias = rs.nextInt(0, 3); // small, large, random
+                if (bias != 0)
+                    splitsToPick = Arrays.copyOf(splits, splits.length);
+                if (bias == 1)
+                    Utils.reverse(splitsToPick);
+                else if (bias == 2)
+                    Utils.shuffle(splitsToPick, rs);
+                Gen.IntGen zipf = Gens.pickZipf(splitsToPick);
+                return (prefixes) -> randomRange(rs, prefixes, () -> {
+                    int value = zipf.nextInt(rs);
+                    int idx = Arrays.binarySearch(splits, value);
+                    int min = idx == 0 ? 0 : splits[idx - 1];
+                    return rs.nextInt(min, value) + 1;
+                });
+            default:
+                throw new AssertionError("Unexpected value: " + selection);
+        }
+    }
+
+    private static Range randomRange(RandomSource random, int[] prefixes, IntSupplier rangeSizeFn)
+    {
+        int prefix = random.pickInt(prefixes);
+        int i = random.nextInt(HASH_RANGE_START, HASH_RANGE_END);
+        int rangeSize = rangeSizeFn.getAsInt();
+        int j = i + rangeSize;
+        if (j > HASH_RANGE_END)
+        {
+            int delta = j - HASH_RANGE_END;
+            j = HASH_RANGE_END;
+            i -= delta;
+            // saftey check, this shouldn't happen unless the configs were changed in an unsafe way
+            if (i < HASH_RANGE_START)
+                i = HASH_RANGE_START;
+        }
+        return range(forHash(prefix, i), forHash(prefix, j));
+    }
+
+    private static PrefixedIntHashKey.Key randomKey(RandomSource random, int[] prefixes, int[] keys, Set<Integer> seen)
+    {
+        int prefix = random.pickInt(prefixes);
+        int key;
+        do
+        {
+            key = random.pickInt(keys);
+        }
+        while (!seen.add(key));
+        return PrefixedIntHashKey.key(prefix, key, hash(key));
+    }
+
+    /**
+     * This class uses a limited range than the default for the following reasons:
+     *
+     * 1) easier to debug smaller numbers
+     * 2) adds hash collisions (multiple keys map to the same hash)
+     */
+    private static int hash(int key)
+    {
+        CRC32 crc32c = new CRC32();
+        crc32c.update(key);
+        crc32c.update(key >> 8);
+        crc32c.update(key >> 16);
+        crc32c.update(key >> 24);
+        return (int) crc32c.getValue() & 0xffff;
+    }
+
+    @SuppressWarnings("unused")
+    void reconcile(long seed, TopologyFactory topologyFactory, List<Id> clients, List<Id> nodes, int keyCount, int operations, int concurrency) throws ExecutionException, InterruptedException
+    {
+        RandomSource random1 = new DefaultRandom(), random2 = new DefaultRandom();
+
+        random1.setSeed(seed);
+        random2.setSeed(seed);
+        ExecutorService exec = Executors.newFixedThreadPool(2);
+        RandomDelayQueue.ReconcilingQueueFactory factory = new RandomDelayQueue.ReconcilingQueueFactory(seed);
+        Future<?> f1 = exec.submit(() -> burn(random1, topologyFactory, clients, nodes, keyCount, operations, concurrency, factory.get(true), InMemoryJournal::new));
+        Future<?> f2 = exec.submit(() -> burn(random2, topologyFactory, clients, nodes, keyCount, operations, concurrency, factory.get(false), InMemoryJournal::new));
+        exec.shutdown();
+        f1.get();
+        f2.get();
+    }
+
+    void burn(RandomSource random, TopologyFactory topologyFactory, List<Id> clients, List<Id> nodes, int keyCount, int operations, int concurrency, PendingQueue pendingQueue, Function<Id, Journal> journalFactory)
+    {
+        List<Throwable> failures = Collections.synchronizedList(new ArrayList<>());
+        AtomicLong progress = new AtomicLong();
+        MonitoredPendingQueue queue = new MonitoredPendingQueue(failures, progress, 5L, TimeUnit.MINUTES, pendingQueue);
+        long startNanos = System.nanoTime();
+        long startLogicalMillis = queue.nowInMillis();
+        Consumer<Runnable> retryBootstrap;
+        {
+            RandomSource retryRandom = random.fork();
+            retryBootstrap = retry -> {
+                long delay = retryRandom.nextInt(1, 15);
+                queue.add(PendingRunnable.create(retry::run), delay, TimeUnit.SECONDS);
+            };
+        }
+        IntSupplier coordinationDelays, progressDelays, timeoutDelays;
+        {
+            RandomSource rnd = random.fork();
+            coordinationDelays = delayGenerator(rnd, 1, 100, 100, 1000);
+            progressDelays = delayGenerator(rnd, 1, 100, 100, 1000);
+            timeoutDelays = delayGenerator(rnd, 500, 800, 1000, 10000);
+        }
+        Function<BiConsumer<Timestamp, Ranges>, ListAgent> agentSupplier = onStale -> new ListAgent(random.fork(), 1000L, failures::add, retryBootstrap, onStale, coordinationDelays, progressDelays, timeoutDelays);
+
+        Supplier<LongSupplier> nowSupplier = () -> {
+            RandomSource forked = random.fork();
+            // TODO (expected): meta-randomise scale of clock drift
+            return FrequentLargeRange.builder(forked)
+                                     .ratio(1, 5)
+                                     .small(50, 5000, TimeUnit.MICROSECONDS)
+                                     .large(1, 10, TimeUnit.MILLISECONDS)
+                                     .build()
+                                     .mapAsLong(j -> Math.max(0, queue.nowInMillis() + TimeUnit.NANOSECONDS.toMillis(j)))
+                                     .asLongSupplier(forked);
+        };
+
+        SimulatedDelayedExecutorService globalExecutor = new SimulatedDelayedExecutorService(queue, new ListAgent(random.fork(), 1000L, failures::add, retryBootstrap, (i1, i2) -> {
+            throw new IllegalAccessError("Global executor should enver get a stale event");
+        }, coordinationDelays, progressDelays, timeoutDelays));
+        Int2ObjectHashMap<Verifier> validators = new Int2ObjectHashMap<>();
+        Function<CommandStore, AsyncExecutor> executor = ignore -> globalExecutor;
+
+        MessageListener listener = MessageListener.get();
+
+        int[] keys = IntStream.range(0, keyCount).toArray();
+        Packet[] requests = toArray(generate(random, listener, executor, clients, nodes, keys, operations), Packet[]::new);
+        int[] starts = new int[requests.length];
+        Packet[] replies = new Packet[requests.length];
+
+        AtomicInteger acks = new AtomicInteger();
+        AtomicInteger nacks = new AtomicInteger();
+        AtomicInteger lost = new AtomicInteger();
+        AtomicInteger truncated = new AtomicInteger();
+        AtomicInteger recovered = new AtomicInteger();
+        AtomicInteger failedToCheck = new AtomicInteger();
+        AtomicInteger clock = new AtomicInteger();
+        AtomicInteger requestIndex = new AtomicInteger();
+        Queue<Packet> initialRequests = new ArrayDeque<>();
+        for (int max = Math.min(concurrency, requests.length) ; requestIndex.get() < max ; )
+        {
+            int i = requestIndex.getAndIncrement();
+            starts[i] = clock.incrementAndGet();
+            initialRequests.add(requests[i]);
+        }
+
+        // not used for atomicity, just for encapsulation
+        AtomicReference<Runnable> onSubmitted = new AtomicReference<>();
+        Consumer<Packet> responseSink = packet -> {
+            if (replies[(int)packet.replyId] != null)
+                return;
+
+            if (requestIndex.get() < requests.length)
+            {
+                int i = requestIndex.getAndIncrement();
+                starts[i] = clock.incrementAndGet();
+                queue.addNoDelay(requests[i]);
+                if (i == requests.length - 1)
+                    onSubmitted.get().run();
+            }
+            if (packet.message instanceof Reply.FailureReply)
+            {
+                failures.add(new AssertionError("Unexpected failure in list reply", ((Reply.FailureReply) packet.message).failure));
+                return;
+            }
+            ListResult reply = (ListResult) packet.message;
+
+            try
+            {
+                if (!reply.isSuccess() && reply.status() == ListResult.Status.HeartBeat)
+                    return; // interrupted; will fetch our actual reply once rest of simulation is finished (but wanted to send another request to keep correct number in flight)
+
+                int start = starts[(int)packet.replyId];
+                int end = clock.incrementAndGet();
+                logger.debug("{} at [{}, {}]", reply, start, end);
+                replies[(int)packet.replyId] = packet;
+
+                if (!reply.isSuccess())
+                {
+                    switch (reply.status())
+                    {
+                        case Lost:          lost.incrementAndGet();             break;
+                        case Invalidated:   nacks.incrementAndGet();            break;
+                        case Failure:       failedToCheck.incrementAndGet();    break;
+                        case Truncated:     truncated.incrementAndGet();        break;
+                        // txn was applied?, but client saw a timeout, so response isn't known
+                        case Other:                                             break;
+                        default:            throw new AssertionError("Unexpected fault: " + reply.status());
+                    }
+                    return;
+                }
+
+                progress.incrementAndGet();
+                switch (reply.status())
+                {
+                    default: throw new AssertionError("Unhandled status: " + reply.status());
+                    case Applied: acks.incrementAndGet(); break;
+                    case RecoveryApplied: recovered.incrementAndGet(); // NOTE: technically this might have been applied by the coordinator and it simply timed out
+                }
+                // TODO (correctness): when a keyspace is removed, the history/validator isn't cleaned up...
+                // the current logic for add keyspace only knows what is there, so a ABA problem exists where keyspaces
+                // may come back... logically this is a problem as the history doesn't get reset, but practically that
+                // is fine as the backing map and the validator are consistent
+                Int2ObjectHashMap<Verifier.Checker> seen = new Int2ObjectHashMap<>();
+                for (int i = 0 ; i < reply.read.length ; ++i)
+                {
+                    Key key = reply.responseKeys.get(i);
+                    int prefix = prefix(key);
+                    int keyValue = key(key);
+                    int k = Arrays.binarySearch(keys, keyValue);
+                    Verifier verifier = validators.computeIfAbsent(prefix, ignore -> createVerifier(Integer.toString(prefix), keyCount));
+                    Verifier.Checker check = seen.computeIfAbsent(prefix, ignore -> verifier.witness(start, end));
+
+                    int[] read = reply.read[i];
+                    int write = reply.update == null ? -1 : reply.update.getOrDefault(key, -1);
+
+                    if (read != null)
+                        check.read(k, read);
+                    if (write >= 0)
+                        check.write(k, write);
+                }
+                for (Verifier.Checker check : seen.values())
+                {
+                    check.close();
+                }
+            }
+            catch (Throwable t)
+            {
+                failures.add(t);
+            }
+        };
+
+        Map<MessageType, Stats> messageStatsMap;
+        try
+        {
+            messageStatsMap = Cluster.run(toArray(nodes, Id[]::new), listener, () -> queue,
+                                          (id, onStale) -> globalExecutor.withAgent(agentSupplier.apply(onStale)),
+                                          queue::checkFailures,
+                                          responseSink, random::fork, nowSupplier,
+                                          topologyFactory, initialRequests::poll,
+                                          onSubmitted::set,
+                                          ignore -> {},
+                                          journalFactory);
+            for (Verifier verifier : validators.values())
+                verifier.close();
+        }
+        catch (Throwable t)
+        {
+            for (int i = 0 ; i < requests.length ; ++i)
+            {
+                logger.info("{}", requests[i]);
+                logger.info("\t\t" + replies[i]);
+            }
+            throw t;
+        }
+
+        int observedOperations = acks.get() + recovered.get() + nacks.get() + lost.get() + truncated.get();
+        logger.info("nodes: {}, rf: {}. Received {} acks, {} recovered, {} nacks, {} lost, {} truncated ({} total) to {} operations", nodes.size(), topologyFactory.rf, acks.get(), recovered.get(), nacks.get(), lost.get(), truncated.get(), observedOperations, operations);
+        logger.info("Message counts: {}", statsInDescOrder(messageStatsMap));
+        logger.info("Took {} and in logical time of {}", Duration.ofNanos(System.nanoTime() - startNanos), Duration.ofMillis(queue.nowInMillis() - startLogicalMillis));
+        if (clock.get() != operations * 2 || observedOperations != operations)
+        {
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0 ; i < requests.length ; ++i)
+            {
+                // since this only happens when operations are lost, only log the ones without a reply to lower the amount of noise
+                if (replies[i] == null)
+                {
+                    sb.setLength(0);
+                    sb.append(requests[i]).append("\n\t\t").append(replies[i]);
+                    logger.info(sb.toString());
+                }
+            }
+            if (clock.get() != operations * 2) throw new AssertionError("Incomplete set of responses; clock=" + clock.get() + ", expected operations=" + (operations * 2));
+            else throw new AssertionError("Incomplete set of responses; ack+recovered+other+nacks+lost+truncated=" + observedOperations + ", expected operations=" + (operations * 2));
+        }
+    }
+
+    private static IntSupplier delayGenerator(RandomSource rnd, int absoluteMin, int absoluteMaxMin, int absoluteMinMax, int asoluteMax)
+    {
+        int minDelay = rnd.nextInt(absoluteMin, absoluteMaxMin);
+        int maxDelay = rnd.nextInt(Math.max(absoluteMinMax, minDelay), asoluteMax);
+        if (rnd.nextBoolean())
+        {
+            int medianDelay = rnd.nextInt(minDelay, maxDelay);
+            return () -> rnd.nextBiasedInt(minDelay, medianDelay, maxDelay);
+        }
+        return () -> rnd.nextInt(minDelay, maxDelay);
+    }
+
+    private static String statsInDescOrder(Map<MessageType, Stats> statsMap)
+    {
+        List<Stats> stats = new ArrayList<>(statsMap.values());
+        stats.sort(Comparator.comparingInt(s -> -s.count()));
+        return stats.toString();
+    }
+
+    protected Verifier createVerifier(String prefix, int keyCount)
+    {
+            return new StrictSerializabilityVerifier(prefix, keyCount);
+    }
+
+    public static void main(String[] args)
+    {
+        int count = 1;
+        int operations = 1000;
+        Long overrideSeed = null;
+        boolean reconcile = false;
+        LongSupplier seedGenerator = ThreadLocalRandom.current()::nextLong;
+        boolean hasOverriddenSeed = false;
+        for (int i = 0 ; i < args.length ; i += 2)
+        {
+            switch (args[i])
+            {
+                default: throw illegalArgument("Invalid option: " + args[i]);
+                case "-c":
+                    count = Integer.parseInt(args[i + 1]);
+                    if (hasOverriddenSeed)
+                        throw illegalArgument("Cannot override both seed (-s) and number of seeds to run (-c)");
+                    overrideSeed = null;
+                    break;
+                case "-s":
+                    overrideSeed = Long.parseLong(args[i + 1]);
+                    hasOverriddenSeed = true;
+                    count = 1;
+                    break;
+                case "-o":
+                    operations = Integer.parseInt(args[i + 1]);
+                    break;
+                case "-r":
+                    reconcile = true;
+                    --i;
+                    break;
+                case "--loop-seed":
+                    seedGenerator = new DefaultRandom(Long.parseLong(args[i + 1]))::nextLong;
+            }
+        }
+        while (count-- > 0)
+        {
+            if (!reconcile)
+            {
+                new BurnTestBase().run(overrideSeed != null ? overrideSeed : seedGenerator.getAsLong(), operations);
+            }
+            else
+            {
+                new BurnTestBase().reconcile(overrideSeed != null ? overrideSeed : seedGenerator.getAsLong(), operations);
+            }
+        }
+    }
+
+    void run(long seed)
+    {
+        Duration timeout = Duration.ofMinutes(3);
+        try
+        {
+            TimeoutUtils.runBlocking(timeout, "BurnTest with timeout", () -> run(seed, 1000));
+        }
+        catch (Throwable thrown)
+        {
+            Throwable cause = thrown;
+            if (cause instanceof ExecutionException)
+                cause = cause.getCause();
+            if (cause instanceof TimeoutException)
+            {
+                TimeoutException override = new TimeoutException("test did not complete within " + timeout);
+                override.setStackTrace(new StackTraceElement[0]);
+                cause = override;
+            }
+            logger.error("Exception running burn test for seed {}:", seed, cause);
+            throw SimulationException.wrap(seed, cause);
+        }
+    }
+
+    void run(long seed, int operations)
+    {
+        logger.info("Seed: {}", seed);
+        Cluster.trace.trace("Seed: {}", seed);
+        RandomSource random = new DefaultRandom(seed);
+        try
+        {
+            List<Id> clients = generateIds(true, 1 + random.nextInt(4));
+            int rf;
+            float chance = random.nextFloat();
+            if (chance < 0.2f)      { rf = random.nextInt(2, 9); }
+            else if (chance < 0.4f) { rf = 3; }
+            else if (chance < 0.7f) { rf = 5; }
+            else if (chance < 0.8f) { rf = 7; }
+            else                    { rf = 9; }
+
+            List<Id> nodes = generateIds(false, random.nextInt(rf, rf * 3));
+
+            burn(random, new TopologyFactory(rf, ranges(0, HASH_RANGE_START, HASH_RANGE_END, random.nextInt(Math.max(nodes.size() + 1, rf), nodes.size() * 3))),
+                 clients,
+                 nodes,
+                 5 + random.nextInt(15),
+                 operations,
+                 10 + random.nextInt(30),
+                 new Factory(random).get(),
+                 InMemoryJournal::new);
+        }
+        catch (Throwable t)
+        {
+            logger.error("Exception running burn test for seed {}:", seed, t);
+            throw SimulationException.wrap(seed, t);
+        }
+    }
+
+    void reconcile(long seed, int operations)
+    {
+        logger.info("Seed: {}", seed);
+        Cluster.trace.trace("Seed: {}", seed);
+        RandomSource random = new DefaultRandom(seed);
+        try
+        {
+            List<Id> clients = generateIds(true, 1 + random.nextInt(4));
+            int rf;
+            float chance = random.nextFloat();
+            if (chance < 0.2f)      { rf = random.nextInt(2, 9); }
+            else if (chance < 0.4f) { rf = 3; }
+            else if (chance < 0.7f) { rf = 5; }
+            else if (chance < 0.8f) { rf = 7; }
+            else                    { rf = 9; }
+
+            List<Id> nodes = generateIds(false, random.nextInt(rf, rf * 3));
+
+            reconcile(seed, new TopologyFactory(rf, ranges(0, HASH_RANGE_START, HASH_RANGE_END, random.nextInt(Math.max(nodes.size() + 1, rf), nodes.size() * 3))),
+                      clients,
+                      nodes,
+                      5 + random.nextInt(15),
+                      operations,
+                      10 + random.nextInt(30));
+        }
+        catch (Throwable t)
+        {
+            logger.error("Exception running burn test for seed {}:", seed, t);
+            throw SimulationException.wrap(seed, t);
+        }
+    }
+
+    private static List<Id> generateIds(boolean clients, int count)
+    {
+        List<Id> ids = new ArrayList<>();
+        for (int i = 1; i <= count ; ++i)
+            ids.add(new Id(clients ? -i : i));
+        return ids;
+    }
+
+    private static int key(Key key)
+    {
+        return ((PrefixedIntHashKey) key).key;
+    }
+
+    private static int prefix(Key key)
+    {
+        return ((PrefixedIntHashKey) key).prefix;
+    }
+}
diff --git a/accord-core/src/test/java/accord/burn/BurnTestConfigurationService.java b/accord-core/src/main-test/java/accord/burn/BurnTestConfigurationService.java
similarity index 100%
rename from accord-core/src/test/java/accord/burn/BurnTestConfigurationService.java
rename to accord-core/src/main-test/java/accord/burn/BurnTestConfigurationService.java
diff --git a/accord-core/src/test/java/accord/burn/SimulationException.java b/accord-core/src/main-test/java/accord/burn/SimulationException.java
similarity index 100%
rename from accord-core/src/test/java/accord/burn/SimulationException.java
rename to accord-core/src/main-test/java/accord/burn/SimulationException.java
diff --git a/accord-core/src/test/java/accord/burn/TopologyUpdates.java b/accord-core/src/main-test/java/accord/burn/TopologyUpdates.java
similarity index 100%
rename from accord-core/src/test/java/accord/burn/TopologyUpdates.java
rename to accord-core/src/main-test/java/accord/burn/TopologyUpdates.java
diff --git a/accord-core/src/test/java/accord/burn/random/FrequentLargeRange.java b/accord-core/src/main-test/java/accord/burn/random/FrequentLargeRange.java
similarity index 100%
rename from accord-core/src/test/java/accord/burn/random/FrequentLargeRange.java
rename to accord-core/src/main-test/java/accord/burn/random/FrequentLargeRange.java
diff --git a/accord-core/src/test/java/accord/burn/random/IntRange.java b/accord-core/src/main-test/java/accord/burn/random/IntRange.java
similarity index 100%
rename from accord-core/src/test/java/accord/burn/random/IntRange.java
rename to accord-core/src/main-test/java/accord/burn/random/IntRange.java
diff --git a/accord-core/src/test/java/accord/burn/random/RandomWalkRange.java b/accord-core/src/main-test/java/accord/burn/random/RandomWalkRange.java
similarity index 100%
rename from accord-core/src/test/java/accord/burn/random/RandomWalkRange.java
rename to accord-core/src/main-test/java/accord/burn/random/RandomWalkRange.java
diff --git a/accord-core/src/test/java/accord/impl/IntHashKey.java b/accord-core/src/main-test/java/accord/impl/IntHashKey.java
similarity index 99%
rename from accord-core/src/test/java/accord/impl/IntHashKey.java
rename to accord-core/src/main-test/java/accord/impl/IntHashKey.java
index 0585204e..1712b960 100644
--- a/accord-core/src/test/java/accord/impl/IntHashKey.java
+++ b/accord-core/src/main-test/java/accord/impl/IntHashKey.java
@@ -111,7 +111,7 @@ public abstract class IntHashKey implements RoutableKey
 
     public static final class Key extends IntHashKey implements accord.api.Key
     {
-        private Key(int key)
+        public Key(int key)
         {
             super(key);
         }
diff --git a/accord-core/src/test/java/accord/impl/IntKey.java b/accord-core/src/main-test/java/accord/impl/IntKey.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/IntKey.java
rename to accord-core/src/main-test/java/accord/impl/IntKey.java
diff --git a/accord-core/src/test/java/accord/impl/MessageListener.java b/accord-core/src/main-test/java/accord/impl/MessageListener.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/MessageListener.java
rename to accord-core/src/main-test/java/accord/impl/MessageListener.java
diff --git a/accord-core/src/test/java/accord/impl/PrefixedIntHashKey.java b/accord-core/src/main-test/java/accord/impl/PrefixedIntHashKey.java
similarity index 99%
rename from accord-core/src/test/java/accord/impl/PrefixedIntHashKey.java
rename to accord-core/src/main-test/java/accord/impl/PrefixedIntHashKey.java
index a6a8bc84..575ed6d1 100644
--- a/accord-core/src/test/java/accord/impl/PrefixedIntHashKey.java
+++ b/accord-core/src/main-test/java/accord/impl/PrefixedIntHashKey.java
@@ -157,7 +157,7 @@ public class PrefixedIntHashKey implements RoutableKey
 
     public static final class Hash extends PrefixedIntRoutingKey
     {
-        private Hash(int prefix, int hash)
+        public Hash(int prefix, int hash)
         {
             super(prefix, hash);
         }
diff --git a/accord-core/src/test/java/accord/impl/TestAgent.java b/accord-core/src/main-test/java/accord/impl/TestAgent.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/TestAgent.java
rename to accord-core/src/main-test/java/accord/impl/TestAgent.java
diff --git a/accord-core/src/test/java/accord/impl/TopologyFactory.java b/accord-core/src/main-test/java/accord/impl/TopologyFactory.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/TopologyFactory.java
rename to accord-core/src/main-test/java/accord/impl/TopologyFactory.java
diff --git a/accord-core/src/test/java/accord/impl/basic/Cluster.java b/accord-core/src/main-test/java/accord/impl/basic/Cluster.java
similarity index 92%
rename from accord-core/src/test/java/accord/impl/basic/Cluster.java
rename to accord-core/src/main-test/java/accord/impl/basic/Cluster.java
index 3dd73e6f..cf0604ad 100644
--- a/accord-core/src/test/java/accord/impl/basic/Cluster.java
+++ b/accord-core/src/main-test/java/accord/impl/basic/Cluster.java
@@ -46,11 +46,11 @@ import java.util.function.Predicate;
 import java.util.function.Supplier;
 import javax.annotation.Nullable;
 
-import org.junit.jupiter.api.Assertions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import accord.api.BarrierType;
+import accord.api.Journal;
 import accord.api.LocalConfig;
 import accord.api.MessageSink;
 import accord.api.RoutingKey;
@@ -66,32 +66,28 @@ import accord.coordinate.Invalidated;
 import accord.coordinate.Preempted;
 import accord.coordinate.Timeout;
 import accord.coordinate.Truncated;
-import accord.impl.DurabilityScheduling;
 import accord.impl.DefaultLocalListeners;
 import accord.impl.DefaultRemoteListeners;
 import accord.impl.DefaultTimeouts;
+import accord.impl.DurabilityScheduling;
 import accord.impl.InMemoryCommandStore.GlobalCommand;
 import accord.impl.MessageListener;
 import accord.impl.PrefixedIntHashKey;
 import accord.impl.SizeOfIntersectionSorter;
 import accord.impl.TopologyFactory;
-import accord.impl.basic.DelayedCommandStores.DelayedCommandStore;
 import accord.impl.list.ListAgent;
 import accord.impl.list.ListStore;
 import accord.impl.progresslog.DefaultProgressLogs;
 import accord.local.AgentExecutor;
 import accord.local.Command;
 import accord.local.CommandStore;
+import accord.local.CommandStores;
 import accord.local.DurableBefore;
 import accord.local.Node;
 import accord.local.Node.Id;
 import accord.local.RedundantBefore;
-import accord.local.TimeService;
-import accord.primitives.RoutableKey;
-import accord.primitives.SaveStatus;
 import accord.local.ShardDistributor;
-import accord.primitives.Seekables;
-import accord.primitives.Status;
+import accord.local.TimeService;
 import accord.local.cfk.CommandsForKey;
 import accord.messages.Message;
 import accord.messages.MessageType;
@@ -102,11 +98,16 @@ import accord.primitives.FullRoute;
 import accord.primitives.Keys;
 import accord.primitives.Range;
 import accord.primitives.Ranges;
+import accord.primitives.RoutableKey;
+import accord.primitives.SaveStatus;
+import accord.primitives.Seekables;
+import accord.primitives.Status;
 import accord.primitives.Timestamp;
 import accord.primitives.Txn;
 import accord.primitives.TxnId;
 import accord.topology.Topology;
 import accord.topology.TopologyRandomizer;
+import accord.utils.AccordGens;
 import accord.utils.Gens;
 import accord.utils.Invariants;
 import accord.utils.RandomSource;
@@ -117,11 +118,7 @@ import org.agrona.collections.Int2ObjectHashMap;
 
 import static accord.impl.basic.Cluster.OverrideLinksKind.NONE;
 import static accord.impl.basic.Cluster.OverrideLinksKind.RANDOM_BIDIRECTIONAL;
-import static accord.impl.basic.NodeSink.Action.DELIVER;
-import static accord.impl.basic.NodeSink.Action.DROP;
-import static accord.utils.AccordGens.keysInsideRanges;
-import static accord.utils.AccordGens.rangeInsideRange;
-import static accord.utils.Gens.mixedDistribution;
+import static accord.impl.basic.DelayedCommandStores.*;
 import static java.util.Collections.emptyMap;
 import static java.util.Collections.singletonMap;
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
@@ -418,37 +415,37 @@ public class Cluster
         };
         AtomicInteger counter = new AtomicInteger();
         AtomicReference<Map<Id, Node>> nodeMap = new AtomicReference<>();
-        Map<MessageType, Cluster.Stats> stats = Cluster.run(nodes.toArray(Node.Id[]::new),
-                                                            MessageListener.get(),
-                                                            () -> queue,
-                                                            (id, onStale) -> globalExecutor.withAgent(agentSupplier.apply(onStale)),
-                                                            queue::checkFailures,
-                                                            ignore -> {
-                                                            },
-                                                            randomSupplier,
-                                                            nowSupplier,
-                                                            topologyFactory,
-                                                            new Supplier<>()
+        Map<MessageType, Cluster.Stats> stats = run(nodes.toArray(Node.Id[]::new),
+                                                    MessageListener.get(),
+                                                    () -> queue,
+                                                    (id, onStale) -> globalExecutor.withAgent(agentSupplier.apply(onStale)),
+                                                    queue::checkFailures,
+                                                    ignore -> {
+                                                    },
+                                                    randomSupplier,
+                                                    nowSupplier,
+                                                    topologyFactory,
+                                                    new Supplier<>()
+                                                    {
+                                                        private Iterator<Request> requestIterator = null;
+                                                        private final RandomSource rs = randomSupplier.get();
+                                                        @Override
+                                                        public Packet get()
+                                                        {
+                                                            if (requestIterator == null)
                                                             {
-                                                                private Iterator<Request> requestIterator = null;
-                                                                private final RandomSource rs = randomSupplier.get();
-                                                                @Override
-                                                                public Packet get()
-                                                                {
-                                                                    // ((Cluster) node.scheduler()).onDone(() -> checkOnResult(homeKey, txnId, 0, null));
-                                                                    if (requestIterator == null)
-                                                                    {
-                                                                        Map<Node.Id, Node> nodes = nodeMap.get();
-                                                                        requestIterator = Collections.singleton(init.apply(nodes)).iterator();
-                                                                    }
-                                                                    if (!requestIterator.hasNext())
-                                                                        return null;
-                                                                    Node.Id id = rs.pick(nodes);
-                                                                    return new Packet(id, id, counter.incrementAndGet(), requestIterator.next());
-                                                                }
-                                                            },
-                                                            Runnable::run,
-                                                            nodeMap::set);
+                                                                Map<Node.Id, Node> nodes = nodeMap.get();
+                                                                requestIterator = Collections.singleton(init.apply(nodes)).iterator();
+                                                            }
+                                                            if (!requestIterator.hasNext())
+                                                                return null;
+                                                            Node.Id id = rs.pick(nodes);
+                                                            return new Packet(id, id, counter.incrementAndGet(), requestIterator.next());
+                                                        }
+                                                    },
+                                                    Runnable::run,
+                                                    nodeMap::set,
+                                                    InMemoryJournal::new);
         if (!failures.isEmpty())
         {
             AssertionError error = new AssertionError("Unexpected errors detected");
@@ -463,7 +460,7 @@ public class Cluster
                                               Runnable checkFailures, Consumer<Packet> responseSink,
                                               Supplier<RandomSource> randomSupplier, Supplier<LongSupplier> nowSupplierSupplier,
                                               TopologyFactory topologyFactory, Supplier<Packet> in, Consumer<Runnable> noMoreWorkSignal,
-                                              Consumer<Map<Id, Node>> readySignal)
+                                              Consumer<Map<Id, Node>> readySignal, Function<Node.Id, Journal> journalSupplier)
     {
         Topology topology = topologyFactory.toTopology(nodes);
         Map<Id, Node> nodeMap = new LinkedHashMap<>();
@@ -490,11 +487,10 @@ public class Cluster
                 ClusterScheduler scheduler = sinks.new ClusterScheduler(id.id);
                 MessageSink messageSink = sinks.create(id, randomSupplier.get());
                 LongSupplier nowSupplier = nowSupplierSupplier.get();
-                LocalConfig localConfig = LocalConfig.DEFAULT;
                 BiConsumer<Timestamp, Ranges> onStale = (sinceAtLeast, ranges) -> configRandomizer.onStale(id, sinceAtLeast, ranges);
                 AgentExecutor nodeExecutor = nodeExecutorSupplier.apply(id, onStale);
                 executorMap.put(id, nodeExecutor);
-                Journal journal = new Journal(id);
+                Journal journal = journalSupplier.apply(id);
                 journalMap.put(id, journal);
                 BurnTestConfigurationService configService = new BurnTestConfigurationService(id, nodeExecutor, randomSupplier, topology, nodeMap::get, topologyUpdates);
                 BooleanSupplier isLoadedCheck = Gens.supplier(Gens.bools().mixedDistribution().next(random), random);
@@ -503,7 +499,7 @@ public class Cluster
                                      nodeExecutor.agent(),
                                      randomSupplier.get(), scheduler, SizeOfIntersectionSorter.SUPPLIER, DefaultRemoteListeners::new, DefaultTimeouts::new,
                                      DefaultProgressLogs::new, DefaultLocalListeners.Factory::new, DelayedCommandStores.factory(sinks.pending, isLoadedCheck, journal), new CoordinationAdapter.DefaultFactory(),
-                                     DurableBefore.NOOP_PERSISTER, localConfig);
+                                     DurableBefore.NOOP_PERSISTER, LocalConfig.DEFAULT);
                 DurabilityScheduling durability = node.durabilityScheduling();
                 // TODO (desired): randomise
                 durability.setShardCycleTime(30, SECONDS);
@@ -535,7 +531,7 @@ public class Cluster
 
             AsyncResult<?> startup = AsyncChains.reduce(nodeMap.values().stream().map(Node::unsafeStart).collect(toList()), (a, b) -> null).beginAsResult();
             while (sinks.processPending());
-            Assertions.assertTrue(startup.isDone());
+            Invariants.checkArgument(startup.isDone());
 
             ClusterScheduler clusterScheduler = sinks.new ClusterScheduler(-1);
             List<Id> nodesList = new ArrayList<>(Arrays.asList(nodes));
@@ -556,22 +552,23 @@ public class Cluster
                     Predicate<Pending> pred = getPendingPredicate(id.id, stores);
                     while (sinks.drain(pred));
 
-                    // Journal cleanup is a rough equivalent of a node restart.
                     trace.debug("Triggering journal cleanup for node " + id);
                     CommandsForKey.disableLinearizabilityViolationsReporting();
                     ListStore listStore = (ListStore) nodeMap.get(id).commandStores().dataStore();
+
+                    // Data- store and CommandStore cleanup, followed by journal replay is a rough equivalent of a node restart.
                     NavigableMap<RoutableKey, Timestamped<int[]>> prevData = listStore.copyOfCurrentData();
                     listStore.clear();
                     listStore.restoreFromSnapshot();
-
-                    Journal journal = journalMap.get(id);
-                    Int2ObjectHashMap<NavigableMap<TxnId, Command>> beforeStores = copyCommands(stores);
                     for (CommandStore s : stores)
                     {
                         DelayedCommandStores.DelayedCommandStore store = (DelayedCommandStores.DelayedCommandStore) s;
                         store.clearForTesting();
-                        journal.reconstructAll(store.loader(), store.id());
                     }
+
+                    Journal journal = journalMap.get(id);
+                    Int2ObjectHashMap<NavigableMap<TxnId, Command>> beforeStores = copyCommands(stores);
+                    journal.replay(nodeMap.get(id).commandStores());
                     while (sinks.drain(pred));
                     CommandsForKey.enableLinearizabilityViolationsReporting();
                     Invariants.checkState(listStore.equals(prevData));
@@ -651,14 +648,16 @@ public class Cluster
             Node node = nodeMap.get(id);
 
             Journal journal = journalMap.get(node.id());
-            CommandStore[] stores = nodeMap.get(node.id()).commandStores().all();
+            CommandStores stores = nodeMap.get(node.id()).commandStores();
             // run on node scheduler so doesn't run during replay
             scheduled = node.scheduler().selfRecurring(() -> {
-                journal.purge(j -> j < stores.length ? stores[j] : null);
+                trace.debug("Starting purge.");
+                journal.purge(stores);
+                trace.debug("Finished purge.");
                 schedule(clusterScheduler, rs, nodes, nodeMap, journalMap);
+
             }, 0, SECONDS);
         }
-
     }
 
     private static Int2ObjectHashMap<NavigableMap<TxnId, Command>> copyCommands(CommandStore[] stores)
@@ -666,7 +665,7 @@ public class Cluster
         Int2ObjectHashMap<NavigableMap<TxnId, Command>> result = new Int2ObjectHashMap<>();
         for (CommandStore s : stores)
         {
-            DelayedCommandStores.DelayedCommandStore store = (DelayedCommandStores.DelayedCommandStore) s;
+            DelayedCommandStore store = (DelayedCommandStore) s;
             NavigableMap<TxnId, Command> commands = new TreeMap<>();
             result.put(store.id(), commands);
             for (Map.Entry<TxnId, GlobalCommand> e : store.unsafeCommands().entrySet())
@@ -679,7 +678,7 @@ public class Cluster
     {
         for (CommandStore s : stores)
         {
-            DelayedCommandStores.DelayedCommandStore store = (DelayedCommandStores.DelayedCommandStore) s;
+            DelayedCommandStore store = (DelayedCommandStore) s;
             NavigableMap<TxnId, Command> before = beforeStores.get(store.id());
             for (Map.Entry<TxnId, GlobalCommand> e : store.unsafeCommands().entrySet())
             {
@@ -687,7 +686,8 @@ public class Cluster
                 Command afterCommand = e.getValue().value();
                 if (beforeCommand == null)
                 {
-                    Invariants.checkArgument(afterCommand.is(Status.NotDefined));
+                    Invariants.checkArgument(afterCommand.is(Status.NotDefined),
+                                             "After command should have been not defined %s", afterCommand);
                     continue;
                 }
                 if (afterCommand.hasBeen(Status.Truncated))
@@ -828,7 +828,7 @@ public class Cluster
         private BarrierService(Node node, RandomSource rs)
         {
             super(node, rs);
-            this.typeSupplier = mixedDistribution(BarrierType.values()).next(rs).asSupplier(rs);
+            this.typeSupplier = Gens.mixedDistribution(BarrierType.values()).next(rs).asSupplier(rs);
             this.includeRangeSupplier = Gens.bools().mixedDistribution().next(rs).asSupplier(rs);
             this.wholeOrPartialSupplier = Gens.bools().mixedDistribution().next(rs).asSupplier(rs);
         }
@@ -843,7 +843,7 @@ public class Cluster
             BarrierType type = typeSupplier.get();
             if (type == BarrierType.local)
             {
-                Keys keys = Keys.of(keysInsideRanges(ranges).next(rs));
+                Keys keys = Keys.of(AccordGens.keysInsideRanges(ranges).next(rs));
                 run(node, keys, node.computeRoute(current.epoch(), keys), current.epoch(), type);
             }
             else
@@ -852,7 +852,7 @@ public class Cluster
                 for (Range range : ranges)
                 {
                     if (includeRangeSupplier.get())
-                        subset.add(wholeOrPartialSupplier.get() ? range : rangeInsideRange(range).next(rs));
+                        subset.add(wholeOrPartialSupplier.get() ? range : AccordGens.rangeInsideRange(range).next(rs));
                 }
                 if (subset.isEmpty())
                     return;
@@ -880,7 +880,7 @@ public class Cluster
         Collections.shuffle(nodes, random.asJdkRandom());
         int partitionSize = random.nextInt((rf+1)/2);
         Set<Id> partition = new LinkedHashSet<>(nodes.subList(0, partitionSize));
-        BiFunction<Id, Id, Link> down = (from, to) -> new Link(() -> DROP, up.apply(from, to).latencyMicros);
+        BiFunction<Id, Id, Link> down = (from, to) -> new Link(() -> NodeSink.Action.DROP, up.apply(from, to).latencyMicros);
         return (from, to) -> (partition.contains(from) == partition.contains(to) ? up : down).apply(from, to);
     }
 
@@ -931,12 +931,12 @@ public class Cluster
 
     private static Link healthy(LongSupplier latency)
     {
-        return new Link(() -> DELIVER, latency);
+        return new Link(() -> NodeSink.Action.DELIVER, latency);
     }
 
     private static Link down(LongSupplier latency)
     {
-        return new Link(() -> DROP, latency);
+        return new Link(() -> NodeSink.Action.DROP, latency);
     }
 
     private LongSupplier defaultRandomWalkLatencyMicros(RandomSource random)
diff --git a/accord-core/src/test/java/accord/impl/basic/DelayedCommandStores.java b/accord-core/src/main-test/java/accord/impl/basic/DelayedCommandStores.java
similarity index 93%
rename from accord-core/src/test/java/accord/impl/basic/DelayedCommandStores.java
rename to accord-core/src/main-test/java/accord/impl/basic/DelayedCommandStores.java
index 04ac085d..ede62de4 100644
--- a/accord-core/src/test/java/accord/impl/basic/DelayedCommandStores.java
+++ b/accord-core/src/main-test/java/accord/impl/basic/DelayedCommandStores.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.Queue;
 import java.util.concurrent.Callable;
 import java.util.function.BiConsumer;
@@ -34,6 +33,7 @@ import com.google.common.collect.Iterables;
 
 import accord.api.Agent;
 import accord.api.DataStore;
+import accord.api.Journal;
 import accord.api.LocalListeners;
 import accord.api.ProgressLog;
 import accord.impl.InMemoryCommandStore;
@@ -42,13 +42,14 @@ import accord.impl.InMemorySafeCommand;
 import accord.impl.InMemorySafeCommandsForKey;
 import accord.impl.InMemorySafeTimestampsForKey;
 import accord.impl.PrefixedIntHashKey;
-import accord.impl.basic.TaskExecutorService.Task;
 import accord.local.Command;
 import accord.local.CommandStore;
 import accord.local.CommandStores;
+import accord.local.DurableBefore;
 import accord.local.Node;
 import accord.local.NodeCommandStoreService;
 import accord.local.PreLoadContext;
+import accord.local.RedundantBefore;
 import accord.local.SafeCommandStore;
 import accord.local.ShardDistributor;
 import accord.primitives.Range;
@@ -105,7 +106,7 @@ public class DelayedCommandStores extends InMemoryCommandStores.SingleThread
 
     public static class DelayedCommandStore extends InMemoryCommandStore
     {
-        public class DelayedTask<T> extends Task<T>
+        public class DelayedTask<T> extends TaskExecutorService.Task<T>
         {
             private DelayedTask(Callable<T> fn)
             {
@@ -130,7 +131,7 @@ public class DelayedCommandStores extends InMemoryCommandStores.SingleThread
         }
 
         private final SimulatedDelayedExecutorService executor;
-        private final Queue<Task<?>> pending = new LinkedList<>();
+        private final Queue<TaskExecutorService.Task<?>> pending = new LinkedList<>();
         private final BooleanSupplier isLoadedCheck;
         private final Journal journal;
 
@@ -153,7 +154,8 @@ public class DelayedCommandStores extends InMemoryCommandStores.SingleThread
                 return;
 
             // Journal will not have result persisted. This part is here for test purposes and ensuring that we have strict object equality.
-            Command reconstructed = journal.reconstruct(id, current.txnId());
+            // TODO: redundant/durable before
+            Command reconstructed = journal.loadCommand(id, current.txnId(), RedundantBefore.EMPTY, DurableBefore.EMPTY);
             List<Difference<?>> diff = ReflectionUtils.recursiveEquals(current, reconstructed);
             Invariants.checkState(diff.isEmpty(), "Commands did not match: expected %s, given %s, node %s, store %d, diff %s", current, reconstructed, node, id(), new LazyToString(() -> String.join("\n", Iterables.transform(diff, Object::toString))));
         }
@@ -190,7 +192,7 @@ public class DelayedCommandStores extends InMemoryCommandStores.SingleThread
         @Override
         public <T> AsyncChain<T> submit(Callable<T> fn)
         {
-            Task<T> task = new DelayedTask<>(fn);
+            TaskExecutorService.Task<T> task = new DelayedTask<>(fn);
             if (Invariants.testParanoia(LINEAR, LINEAR, HIGH))
             {
                 return AsyncChains.detectLeak(agent::onUncaughtException, () -> {
@@ -223,7 +225,7 @@ public class DelayedCommandStores extends InMemoryCommandStores.SingleThread
 
         private void runNextTask()
         {
-            Task<?> next = pending.peek();
+            TaskExecutorService.Task<?> next = pending.peek();
             if (next == null)
                 return;
 
@@ -275,7 +277,8 @@ public class DelayedCommandStores extends InMemoryCommandStores.SingleThread
 
                 Command before = safe.original();
                 Command after = safe.current();
-                commandStore.journal.onExecute(commandStore.id(), before, after, Objects.equals(context.primaryTxnId(), after.txnId()));
+                // TODO: do we want to use AccordCommandStore, since it handles caches?
+                commandStore.journal.saveCommand(commandStore.id(), new Journal.CommandUpdate(before, after), () -> {});
                 commandStore.validateRead(safe.current());
             });
             super.postExecute();
diff --git a/accord-core/src/test/java/accord/impl/basic/MonitoredPendingQueue.java b/accord-core/src/main-test/java/accord/impl/basic/MonitoredPendingQueue.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/basic/MonitoredPendingQueue.java
rename to accord-core/src/main-test/java/accord/impl/basic/MonitoredPendingQueue.java
diff --git a/accord-core/src/test/java/accord/impl/basic/NodeSink.java b/accord-core/src/main-test/java/accord/impl/basic/NodeSink.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/basic/NodeSink.java
rename to accord-core/src/main-test/java/accord/impl/basic/NodeSink.java
diff --git a/accord-core/src/test/java/accord/impl/basic/Packet.java b/accord-core/src/main-test/java/accord/impl/basic/Packet.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/basic/Packet.java
rename to accord-core/src/main-test/java/accord/impl/basic/Packet.java
diff --git a/accord-core/src/test/java/accord/impl/basic/Pending.java b/accord-core/src/main-test/java/accord/impl/basic/Pending.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/basic/Pending.java
rename to accord-core/src/main-test/java/accord/impl/basic/Pending.java
diff --git a/accord-core/src/test/java/accord/impl/basic/PendingQueue.java b/accord-core/src/main-test/java/accord/impl/basic/PendingQueue.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/basic/PendingQueue.java
rename to accord-core/src/main-test/java/accord/impl/basic/PendingQueue.java
diff --git a/accord-core/src/test/java/accord/impl/basic/PendingRunnable.java b/accord-core/src/main-test/java/accord/impl/basic/PendingRunnable.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/basic/PendingRunnable.java
rename to accord-core/src/main-test/java/accord/impl/basic/PendingRunnable.java
diff --git a/accord-core/src/test/java/accord/impl/basic/RandomDelayQueue.java b/accord-core/src/main-test/java/accord/impl/basic/RandomDelayQueue.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/basic/RandomDelayQueue.java
rename to accord-core/src/main-test/java/accord/impl/basic/RandomDelayQueue.java
diff --git a/accord-core/src/test/java/accord/impl/basic/RecurringPendingRunnable.java b/accord-core/src/main-test/java/accord/impl/basic/RecurringPendingRunnable.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/basic/RecurringPendingRunnable.java
rename to accord-core/src/main-test/java/accord/impl/basic/RecurringPendingRunnable.java
diff --git a/accord-core/src/test/java/accord/impl/basic/SimulatedDelayedExecutorService.java b/accord-core/src/main-test/java/accord/impl/basic/SimulatedDelayedExecutorService.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/basic/SimulatedDelayedExecutorService.java
rename to accord-core/src/main-test/java/accord/impl/basic/SimulatedDelayedExecutorService.java
diff --git a/accord-core/src/test/java/accord/impl/basic/SimulatedFault.java b/accord-core/src/main-test/java/accord/impl/basic/SimulatedFault.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/basic/SimulatedFault.java
rename to accord-core/src/main-test/java/accord/impl/basic/SimulatedFault.java
diff --git a/accord-core/src/test/java/accord/impl/basic/TaskExecutorService.java b/accord-core/src/main-test/java/accord/impl/basic/TaskExecutorService.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/basic/TaskExecutorService.java
rename to accord-core/src/main-test/java/accord/impl/basic/TaskExecutorService.java
diff --git a/accord-core/src/test/java/accord/impl/list/ListAgent.java b/accord-core/src/main-test/java/accord/impl/list/ListAgent.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/list/ListAgent.java
rename to accord-core/src/main-test/java/accord/impl/list/ListAgent.java
diff --git a/accord-core/src/test/java/accord/impl/list/ListData.java b/accord-core/src/main-test/java/accord/impl/list/ListData.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/list/ListData.java
rename to accord-core/src/main-test/java/accord/impl/list/ListData.java
diff --git a/accord-core/src/test/java/accord/impl/list/ListFetchCoordinator.java b/accord-core/src/main-test/java/accord/impl/list/ListFetchCoordinator.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/list/ListFetchCoordinator.java
rename to accord-core/src/main-test/java/accord/impl/list/ListFetchCoordinator.java
diff --git a/accord-core/src/test/java/accord/impl/list/ListQuery.java b/accord-core/src/main-test/java/accord/impl/list/ListQuery.java
similarity index 96%
rename from accord-core/src/test/java/accord/impl/list/ListQuery.java
rename to accord-core/src/main-test/java/accord/impl/list/ListQuery.java
index de886b99..f10ac792 100644
--- a/accord-core/src/test/java/accord/impl/list/ListQuery.java
+++ b/accord-core/src/main-test/java/accord/impl/list/ListQuery.java
@@ -38,9 +38,9 @@ import javax.annotation.Nonnull;
 
 public class ListQuery implements Query
 {
-    final Id client;
-    final long requestId;
-    final boolean isEphemeralRead;
+    public final Id client;
+    public final long requestId;
+    public final boolean isEphemeralRead;
 
     public ListQuery(Id client, long requestId, boolean isEphemeralRead)
     {
diff --git a/accord-core/src/test/java/accord/impl/list/ListRead.java b/accord-core/src/main-test/java/accord/impl/list/ListRead.java
similarity index 99%
rename from accord-core/src/test/java/accord/impl/list/ListRead.java
rename to accord-core/src/main-test/java/accord/impl/list/ListRead.java
index 915442ad..b1ea3c7c 100644
--- a/accord-core/src/test/java/accord/impl/list/ListRead.java
+++ b/accord-core/src/main-test/java/accord/impl/list/ListRead.java
@@ -46,7 +46,7 @@ public class ListRead implements Read
     private static final Logger logger = LoggerFactory.getLogger(ListRead.class);
 
     private final Function<? super CommandStore, AsyncExecutor> executor;
-    private final boolean isEphemeralRead;
+    public final boolean isEphemeralRead;
     public final Seekables<?, ?> userReadKeys; // those only to be returned to user
     public final Seekables<?, ?> keys; // those including necessary for writes
 
diff --git a/accord-core/src/test/java/accord/impl/list/ListRequest.java b/accord-core/src/main-test/java/accord/impl/list/ListRequest.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/list/ListRequest.java
rename to accord-core/src/main-test/java/accord/impl/list/ListRequest.java
diff --git a/accord-core/src/test/java/accord/impl/list/ListResult.java b/accord-core/src/main-test/java/accord/impl/list/ListResult.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/list/ListResult.java
rename to accord-core/src/main-test/java/accord/impl/list/ListResult.java
diff --git a/accord-core/src/test/java/accord/impl/list/ListStore.java b/accord-core/src/main-test/java/accord/impl/list/ListStore.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/list/ListStore.java
rename to accord-core/src/main-test/java/accord/impl/list/ListStore.java
diff --git a/accord-core/src/test/java/accord/impl/list/ListUpdate.java b/accord-core/src/main-test/java/accord/impl/list/ListUpdate.java
similarity index 98%
rename from accord-core/src/test/java/accord/impl/list/ListUpdate.java
rename to accord-core/src/main-test/java/accord/impl/list/ListUpdate.java
index a3f8e17b..00de6f14 100644
--- a/accord-core/src/test/java/accord/impl/list/ListUpdate.java
+++ b/accord-core/src/main-test/java/accord/impl/list/ListUpdate.java
@@ -34,8 +34,8 @@ import accord.primitives.Ranges;
 import accord.primitives.Seekables;
 import accord.primitives.Timestamp;
 import accord.utils.Invariants;
-import accord.utils.async.AsyncExecutor;
 import accord.utils.Timestamped;
+import accord.utils.async.AsyncExecutor;
 
 public class ListUpdate extends TreeMap<Key, Integer> implements Update
 {
@@ -95,7 +95,7 @@ public class ListUpdate extends TreeMap<Key, Integer> implements Update
     {
         ListUpdate result = new ListUpdate(executor);
         result.putAll(this);
-        result.putAll((ListUpdate) other);
+        result.putAll(((ListUpdate) other));
         return result;
     }
 
diff --git a/accord-core/src/test/java/accord/impl/list/ListWrite.java b/accord-core/src/main-test/java/accord/impl/list/ListWrite.java
similarity index 92%
rename from accord-core/src/test/java/accord/impl/list/ListWrite.java
rename to accord-core/src/main-test/java/accord/impl/list/ListWrite.java
index aced2e04..79e0de5a 100644
--- a/accord-core/src/test/java/accord/impl/list/ListWrite.java
+++ b/accord-core/src/main-test/java/accord/impl/list/ListWrite.java
@@ -56,7 +56,7 @@ public class ListWrite extends TreeMap<Key, int[]> implements Write
         ListStore s = (ListStore) store;
         if (!containsKey(key))
             return Writes.SUCCESS;
-        TimestampsForKeys.updateLastExecutionTimestamps((AbstractSafeCommandStore<?, ?, ?>) safeStore, ((Key)key).toUnseekable(), txnId, executeAt, true);
+        TimestampsForKeys.updateLastExecutionTimestamps(safeStore, ((Key)key).toUnseekable(), txnId, executeAt, true);
 
         logger.trace("submitting WRITE on {} at {} key:{}", s.node, executeAt, key);
         return executor.apply(safeStore.commandStore()).submit(() -> {
@@ -73,7 +73,7 @@ public class ListWrite extends TreeMap<Key, int[]> implements Write
         if (!containsKey(key))
             return;
 
-        TimestampsForKeys.updateLastExecutionTimestamps((AbstractSafeCommandStore<?, ?, ?>) safeStore, ((Key)key).toUnseekable(), txnId, executeAt, true);
+        TimestampsForKeys.updateLastExecutionTimestamps(safeStore, ((Key)key).toUnseekable(), txnId, executeAt, true);
         logger.trace("unsafe applying WRITE on {} at {} key:{}", s.node, executeAt, key);
         int[] data = get(key);
         s.data.merge((Key)key, new Timestamped<>(executeAt, data, Arrays::toString), ListStore::merge);
diff --git a/accord-core/src/test/java/accord/impl/mock/MockCluster.java b/accord-core/src/main-test/java/accord/impl/mock/MockCluster.java
similarity index 98%
rename from accord-core/src/test/java/accord/impl/mock/MockCluster.java
rename to accord-core/src/main-test/java/accord/impl/mock/MockCluster.java
index 7604548b..6a266847 100644
--- a/accord-core/src/test/java/accord/impl/mock/MockCluster.java
+++ b/accord-core/src/main-test/java/accord/impl/mock/MockCluster.java
@@ -33,17 +33,18 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import accord.NetworkFilter;
-import accord.api.MessageSink;
+import accord.Utils;
 import accord.api.LocalConfig;
+import accord.api.MessageSink;
 import accord.coordinate.CoordinationAdapter;
+import accord.impl.DefaultLocalListeners;
+import accord.impl.DefaultRemoteListeners;
 import accord.impl.DefaultTimeouts;
 import accord.impl.InMemoryCommandStores;
 import accord.impl.IntKey;
-import accord.impl.DefaultLocalListeners;
-import accord.impl.progresslog.DefaultProgressLogs;
-import accord.impl.DefaultRemoteListeners;
 import accord.impl.SizeOfIntersectionSorter;
 import accord.impl.TestAgent;
+import accord.impl.progresslog.DefaultProgressLogs;
 import accord.local.AgentExecutor;
 import accord.local.DurableBefore;
 import accord.local.Node;
@@ -64,8 +65,6 @@ import accord.utils.Invariants;
 import accord.utils.RandomSource;
 import accord.utils.ThreadPoolScheduler;
 
-import static accord.Utils.id;
-import static accord.Utils.idList;
 import static accord.local.TimeService.elapsedWrapperFromNonMonotonicSource;
 import static accord.primitives.Routable.Domain.Key;
 import static accord.primitives.Txn.Kind.Write;
@@ -116,7 +115,7 @@ public class MockCluster implements Network, AutoCloseable, Iterable<Node>
 
     private synchronized Id nextNodeId()
     {
-        return id(nextNodeId++);
+        return Utils.id(nextNodeId++);
     }
 
     private synchronized long nextMessageId()
@@ -258,7 +257,7 @@ public class MockCluster implements Network, AutoCloseable, Iterable<Node>
 
     public Node get(int i)
     {
-        return get(id(i));
+        return get(Utils.id(i));
     }
 
     public static MockConfigurationService configService(Node node)
@@ -276,7 +275,7 @@ public class MockCluster implements Network, AutoCloseable, Iterable<Node>
 
     public MockConfigurationService configService(int i)
     {
-        return configService(id(i));
+        return configService(Utils.id(i));
     }
 
     public Iterable<MockConfigurationService> configServices(int... ids)
@@ -299,7 +298,7 @@ public class MockCluster implements Network, AutoCloseable, Iterable<Node>
     public Iterable<Node> nodes(int... ids)
     {
         assert ids.length > 0;
-        return nodes(idList(ids));
+        return nodes(Utils.idList(ids));
     }
 
     public static class Config
diff --git a/accord-core/src/test/java/accord/impl/mock/MockConfigurationService.java b/accord-core/src/main-test/java/accord/impl/mock/MockConfigurationService.java
similarity index 82%
rename from accord-core/src/test/java/accord/impl/mock/MockConfigurationService.java
rename to accord-core/src/main-test/java/accord/impl/mock/MockConfigurationService.java
index a892bb8a..09cd3b02 100644
--- a/accord-core/src/test/java/accord/impl/mock/MockConfigurationService.java
+++ b/accord-core/src/main-test/java/accord/impl/mock/MockConfigurationService.java
@@ -18,27 +18,27 @@
 
 package accord.impl.mock;
 
+import accord.api.ConfigurationService;
 import accord.api.MessageSink;
 import accord.api.TestableConfigurationService;
 import accord.local.Node;
 import accord.primitives.Ranges;
 import accord.topology.Topology;
 import accord.utils.EpochFunction;
+import accord.utils.Invariants;
 import accord.utils.async.AsyncChains;
 import accord.utils.async.AsyncResult;
 import accord.utils.async.AsyncResults;
 
-import org.junit.jupiter.api.Assertions;
-
 import java.util.*;
 
 public class MockConfigurationService implements TestableConfigurationService
 {
     private final MessageSink messageSink;
     private final List<Topology> epochs = new ArrayList<>();
-    private final Map<Long, EpochReady> acks = new HashMap<>();
+    private final Map<Long, ConfigurationService.EpochReady> acks = new HashMap<>();
     private final List<AsyncResult<Void>> syncs = new ArrayList<>();
-    private final List<Listener> listeners = new ArrayList<>();
+    private final List<ConfigurationService.Listener> listeners = new ArrayList<>();
     private final EpochFunction<MockConfigurationService> fetchTopologyHandler;
 
     public MockConfigurationService(MessageSink messageSink, EpochFunction<MockConfigurationService> fetchTopologyHandler)
@@ -55,7 +55,7 @@ public class MockConfigurationService implements TestableConfigurationService
     }
 
     @Override
-    public synchronized void registerListener(Listener listener)
+    public synchronized void registerListener(ConfigurationService.Listener listener)
     {
         listeners.add(listener);
     }
@@ -83,13 +83,13 @@ public class MockConfigurationService implements TestableConfigurationService
     }
 
     @Override
-    public synchronized void acknowledgeEpoch(EpochReady epoch, boolean startSync)
+    public synchronized void acknowledgeEpoch(ConfigurationService.EpochReady epoch, boolean startSync)
     {
-        Assertions.assertFalse(acks.containsKey(epoch.epoch));
+        Invariants.checkArgument(acks.containsKey(epoch.epoch));
         acks.put(epoch.epoch, epoch);
     }
 
-    public synchronized EpochReady ackFor(long epoch)
+    public synchronized ConfigurationService.EpochReady ackFor(long epoch)
     {
         return acks.get(epoch);
     }
@@ -110,11 +110,11 @@ public class MockConfigurationService implements TestableConfigurationService
         if (topology.epoch() > epochs.size())
             return;
 
-        Assertions.assertEquals(topology.epoch(), epochs.size());
+        Invariants.checkArgument(topology.epoch() == epochs.size());
         epochs.add(topology);
 
         List<AsyncResult<Void>> futures = new ArrayList<>();
-        for (Listener listener : listeners)
+        for (ConfigurationService.Listener listener : listeners)
             futures.add(listener.onTopologyUpdate(topology, false, true));
 
         AsyncResult<Void> result = futures.isEmpty()
@@ -126,7 +126,7 @@ public class MockConfigurationService implements TestableConfigurationService
 
     public synchronized void reportSyncComplete(Node.Id node, long epoch)
     {
-        for (Listener listener : listeners)
+        for (ConfigurationService.Listener listener : listeners)
             listener.onRemoteSyncComplete(node, epoch);
     }
 }
diff --git a/accord-core/src/test/java/accord/impl/mock/MockStore.java b/accord-core/src/main-test/java/accord/impl/mock/MockStore.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/mock/MockStore.java
rename to accord-core/src/main-test/java/accord/impl/mock/MockStore.java
diff --git a/accord-core/src/test/java/accord/impl/mock/Network.java b/accord-core/src/main-test/java/accord/impl/mock/Network.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/mock/Network.java
rename to accord-core/src/main-test/java/accord/impl/mock/Network.java
diff --git a/accord-core/src/test/java/accord/impl/mock/RecordingMessageSink.java b/accord-core/src/main-test/java/accord/impl/mock/RecordingMessageSink.java
similarity index 93%
rename from accord-core/src/test/java/accord/impl/mock/RecordingMessageSink.java
rename to accord-core/src/main-test/java/accord/impl/mock/RecordingMessageSink.java
index ef00df85..a6f48f78 100644
--- a/accord-core/src/test/java/accord/impl/mock/RecordingMessageSink.java
+++ b/accord-core/src/main-test/java/accord/impl/mock/RecordingMessageSink.java
@@ -24,8 +24,7 @@ import accord.messages.Callback;
 import accord.messages.Reply;
 import accord.messages.ReplyContext;
 import accord.messages.Request;
-
-import org.junit.jupiter.api.Assertions;
+import accord.utils.Invariants;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -78,8 +77,8 @@ public class RecordingMessageSink extends SimpleMessageSink
 
     public void assertHistorySizes(int requests, int responses)
     {
-        Assertions.assertEquals(requests, this.requests.size());
-        Assertions.assertEquals(responses, this.responses.size());
+        Invariants.checkArgument(requests == this.requests.size());
+        Invariants.checkArgument(responses == this.responses.size());
     }
 
     public void clearHistory()
diff --git a/accord-core/src/test/java/accord/impl/mock/SimpleMessageSink.java b/accord-core/src/main-test/java/accord/impl/mock/SimpleMessageSink.java
similarity index 100%
rename from accord-core/src/test/java/accord/impl/mock/SimpleMessageSink.java
rename to accord-core/src/main-test/java/accord/impl/mock/SimpleMessageSink.java
diff --git a/accord-core/src/test/java/accord/topology/TopologyRandomizer.java b/accord-core/src/main-test/java/accord/topology/TopologyRandomizer.java
similarity index 99%
rename from accord-core/src/test/java/accord/topology/TopologyRandomizer.java
rename to accord-core/src/main-test/java/accord/topology/TopologyRandomizer.java
index 4784d304..f8427c1f 100644
--- a/accord-core/src/test/java/accord/topology/TopologyRandomizer.java
+++ b/accord-core/src/main-test/java/accord/topology/TopologyRandomizer.java
@@ -52,8 +52,8 @@ import accord.utils.RandomSource;
 import accord.utils.SortedArrays.SortedArrayList;
 import org.agrona.collections.IntHashSet;
 
-import static accord.burn.BurnTest.HASH_RANGE_END;
-import static accord.burn.BurnTest.HASH_RANGE_START;
+import static accord.burn.BurnTestBase.HASH_RANGE_END;
+import static accord.burn.BurnTestBase.HASH_RANGE_START;
 
 
 // TODO (testing): add change replication factor
diff --git a/accord-core/src/test/java/accord/topology/TopologyUtils.java b/accord-core/src/main-test/java/accord/topology/TopologyUtils.java
similarity index 100%
rename from accord-core/src/test/java/accord/topology/TopologyUtils.java
rename to accord-core/src/main-test/java/accord/topology/TopologyUtils.java
diff --git a/accord-core/src/test/java/accord/utils/AccordGens.java b/accord-core/src/main-test/java/accord/utils/AccordGens.java
similarity index 99%
rename from accord-core/src/test/java/accord/utils/AccordGens.java
rename to accord-core/src/main-test/java/accord/utils/AccordGens.java
index 560caa11..ca3dc3f7 100644
--- a/accord-core/src/test/java/accord/utils/AccordGens.java
+++ b/accord-core/src/main-test/java/accord/utils/AccordGens.java
@@ -373,7 +373,7 @@ public class AccordGens
             else if (chance < 0.7f) { rf = 5; }
             else if (chance < 0.8f) { rf = 7; }
             else                    { rf = 9; }
-            Node.Id[] nodes = Utils.toArray(Gens.lists(nodeGen).unique().ofSizeBetween(rf, rf * 3).next(rs), Node.Id[]::new);
+            Node.Id[] nodes = toArray(Gens.lists(nodeGen).unique().ofSizeBetween(rf, rf * 3).next(rs), Node.Id[]::new);
             Ranges ranges = rangesGenFactory.apply(nodes.length, rf).next(rs);
 
             int numElectorate = nodes.length + rf - 1;
diff --git a/accord-core/src/test/java/accord/utils/CRCUtils.java b/accord-core/src/main-test/java/accord/utils/CRCUtils.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/CRCUtils.java
rename to accord-core/src/main-test/java/accord/utils/CRCUtils.java
diff --git a/accord-core/src/test/java/accord/utils/EpochFunction.java b/accord-core/src/main-test/java/accord/utils/EpochFunction.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/EpochFunction.java
rename to accord-core/src/main-test/java/accord/utils/EpochFunction.java
diff --git a/accord-core/src/test/java/accord/utils/Gen.java b/accord-core/src/main-test/java/accord/utils/Gen.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/Gen.java
rename to accord-core/src/main-test/java/accord/utils/Gen.java
diff --git a/accord-core/src/test/java/accord/utils/Gens.java b/accord-core/src/main-test/java/accord/utils/Gens.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/Gens.java
rename to accord-core/src/main-test/java/accord/utils/Gens.java
diff --git a/accord-core/src/test/java/accord/utils/LazyToString.java b/accord-core/src/main-test/java/accord/utils/LazyToString.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/LazyToString.java
rename to accord-core/src/main-test/java/accord/utils/LazyToString.java
diff --git a/accord-core/src/test/java/accord/utils/LoggingRandomSource.java b/accord-core/src/main-test/java/accord/utils/LoggingRandomSource.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/LoggingRandomSource.java
rename to accord-core/src/main-test/java/accord/utils/LoggingRandomSource.java
diff --git a/accord-core/src/test/java/accord/utils/MessageTask.java b/accord-core/src/main-test/java/accord/utils/MessageTask.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/MessageTask.java
rename to accord-core/src/main-test/java/accord/utils/MessageTask.java
diff --git a/accord-core/src/test/java/accord/utils/Pair.java b/accord-core/src/main-test/java/accord/utils/Pair.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/Pair.java
rename to accord-core/src/main-test/java/accord/utils/Pair.java
diff --git a/accord-core/src/test/java/accord/utils/Property.java b/accord-core/src/main-test/java/accord/utils/Property.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/Property.java
rename to accord-core/src/main-test/java/accord/utils/Property.java
diff --git a/accord-core/src/test/java/accord/utils/RandomTestRunner.java b/accord-core/src/main-test/java/accord/utils/RandomTestRunner.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/RandomTestRunner.java
rename to accord-core/src/main-test/java/accord/utils/RandomTestRunner.java
diff --git a/accord-core/src/test/java/accord/utils/ReflectionUtils.java b/accord-core/src/main-test/java/accord/utils/ReflectionUtils.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/ReflectionUtils.java
rename to accord-core/src/main-test/java/accord/utils/ReflectionUtils.java
diff --git a/accord-core/src/test/java/accord/utils/SeedProvider.java b/accord-core/src/main-test/java/accord/utils/SeedProvider.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/SeedProvider.java
rename to accord-core/src/main-test/java/accord/utils/SeedProvider.java
diff --git a/accord-core/src/test/java/accord/utils/async/TimeoutUtils.java b/accord-core/src/main-test/java/accord/utils/async/TimeoutUtils.java
similarity index 100%
rename from accord-core/src/test/java/accord/utils/async/TimeoutUtils.java
rename to accord-core/src/main-test/java/accord/utils/async/TimeoutUtils.java
diff --git a/accord-core/src/test/java/accord/verify/CompositeVerifier.java b/accord-core/src/main-test/java/accord/verify/CompositeVerifier.java
similarity index 100%
rename from accord-core/src/test/java/accord/verify/CompositeVerifier.java
rename to accord-core/src/main-test/java/accord/verify/CompositeVerifier.java
diff --git a/accord-core/src/test/java/accord/verify/HistoryViolation.java b/accord-core/src/main-test/java/accord/verify/HistoryViolation.java
similarity index 100%
rename from accord-core/src/test/java/accord/verify/HistoryViolation.java
rename to accord-core/src/main-test/java/accord/verify/HistoryViolation.java
diff --git a/accord-core/src/test/java/accord/verify/LinearizabilityVerifier.java b/accord-core/src/main-test/java/accord/verify/LinearizabilityVerifier.java
similarity index 100%
rename from accord-core/src/test/java/accord/verify/LinearizabilityVerifier.java
rename to accord-core/src/main-test/java/accord/verify/LinearizabilityVerifier.java
diff --git a/accord-core/src/test/java/accord/verify/SerializabilityVerifier.java b/accord-core/src/main-test/java/accord/verify/SerializabilityVerifier.java
similarity index 100%
rename from accord-core/src/test/java/accord/verify/SerializabilityVerifier.java
rename to accord-core/src/main-test/java/accord/verify/SerializabilityVerifier.java
diff --git a/accord-core/src/test/java/accord/verify/StrictSerializabilityVerifier.java b/accord-core/src/main-test/java/accord/verify/StrictSerializabilityVerifier.java
similarity index 100%
rename from accord-core/src/test/java/accord/verify/StrictSerializabilityVerifier.java
rename to accord-core/src/main-test/java/accord/verify/StrictSerializabilityVerifier.java
diff --git a/accord-core/src/test/java/accord/verify/Verifier.java b/accord-core/src/main-test/java/accord/verify/Verifier.java
similarity index 100%
rename from accord-core/src/test/java/accord/verify/Verifier.java
rename to accord-core/src/main-test/java/accord/verify/Verifier.java


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


(cassandra-accord) 03/05: Move files

Posted by if...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ifesdjeen pushed a commit to branch semi-integrated-burn-test-rebased
in repository https://gitbox.apache.org/repos/asf/cassandra-accord.git

commit f0b29213ab32d39e3b030bf217ee8b19836cdfff
Author: Alex Petrov <ol...@gmail.com>
AuthorDate: Fri Nov 15 16:46:07 2024 +0100

    Move files
---
 .../main-test/java/accord/impl/basic/Cluster.java  |   2 +-
 .../java/accord/impl/basic/InMemoryJournal.java}   | 340 ++++++------
 .../java/accord/impl/basic/LoggingJournal.java     | 120 +++++
 accord-core/src/main/java/accord/api/Journal.java  | 102 ++++
 .../src/main/java/accord/impl/CommandChange.java   | 598 +++++++++++++++++++++
 .../java/accord/impl/DurabilityScheduling.java     |  11 +-
 .../java/accord/impl/InMemoryCommandStore.java     | 152 +++---
 .../src/main/java/accord/local/CommandStore.java   |   3 +
 .../java/accord/messages/ReadEphemeralTxnData.java |   3 +-
 .../src/test/java/accord/burn/BurnTest.java        |  25 +-
 .../coordinate/CoordinateTransactionTest.java      |  19 +-
 .../test/java/accord/impl/RemoteListenersTest.java |   7 +
 .../java/accord/local/cfk/CommandsForKeyTest.java  |   6 +
 13 files changed, 1155 insertions(+), 233 deletions(-)

diff --git a/accord-core/src/main-test/java/accord/impl/basic/Cluster.java b/accord-core/src/main-test/java/accord/impl/basic/Cluster.java
index cf0604ad..bd2fb921 100644
--- a/accord-core/src/main-test/java/accord/impl/basic/Cluster.java
+++ b/accord-core/src/main-test/java/accord/impl/basic/Cluster.java
@@ -560,6 +560,7 @@ public class Cluster
                     NavigableMap<RoutableKey, Timestamped<int[]>> prevData = listStore.copyOfCurrentData();
                     listStore.clear();
                     listStore.restoreFromSnapshot();
+                    Int2ObjectHashMap<NavigableMap<TxnId, Command>> beforeStores = copyCommands(stores);
                     for (CommandStore s : stores)
                     {
                         DelayedCommandStores.DelayedCommandStore store = (DelayedCommandStores.DelayedCommandStore) s;
@@ -567,7 +568,6 @@ public class Cluster
                     }
 
                     Journal journal = journalMap.get(id);
-                    Int2ObjectHashMap<NavigableMap<TxnId, Command>> beforeStores = copyCommands(stores);
                     journal.replay(nodeMap.get(id).commandStores());
                     while (sinks.drain(pred));
                     CommandsForKey.enableLinearizabilityViolationsReporting();
diff --git a/accord-core/src/test/java/accord/impl/basic/Journal.java b/accord-core/src/main-test/java/accord/impl/basic/InMemoryJournal.java
similarity index 67%
rename from accord-core/src/test/java/accord/impl/basic/Journal.java
rename to accord-core/src/main-test/java/accord/impl/basic/InMemoryJournal.java
index 27f9cb19..a74232d4 100644
--- a/accord-core/src/test/java/accord/impl/basic/Journal.java
+++ b/accord-core/src/main-test/java/accord/impl/basic/InMemoryJournal.java
@@ -20,76 +20,156 @@ package accord.impl.basic;
 
 import java.util.AbstractList;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.NavigableMap;
 import java.util.Objects;
-import java.util.Set;
 import java.util.TreeMap;
 import java.util.function.Function;
-import java.util.function.IntFunction;
 import java.util.stream.Collectors;
 
+import com.google.common.collect.ImmutableSortedMap;
+
+import accord.api.Journal;
 import accord.api.Result;
 import accord.impl.InMemoryCommandStore;
 import accord.local.Cleanup;
 import accord.local.Command;
 import accord.local.CommandStore;
+import accord.local.CommandStores;
 import accord.local.Commands;
 import accord.local.CommonAttributes;
+import accord.local.DurableBefore;
 import accord.local.Node;
-import accord.primitives.Known;
-import accord.primitives.SaveStatus;
-import accord.primitives.Status;
+import accord.local.RedundantBefore;
 import accord.local.StoreParticipants;
 import accord.primitives.Ballot;
+import accord.primitives.Known;
 import accord.primitives.PartialDeps;
 import accord.primitives.PartialTxn;
+import accord.primitives.Ranges;
+import accord.primitives.SaveStatus;
+import accord.primitives.Status;
 import accord.primitives.Timestamp;
 import accord.primitives.TxnId;
 import accord.primitives.Writes;
 import accord.utils.Invariants;
-import org.agrona.collections.Long2ObjectHashMap;
+import org.agrona.collections.Int2ObjectHashMap;
 
-import static accord.primitives.SaveStatus.Erased;
 import static accord.primitives.SaveStatus.NotDefined;
 import static accord.primitives.SaveStatus.Stable;
 import static accord.primitives.Status.Invalidated;
 import static accord.primitives.Status.Truncated;
 import static accord.utils.Invariants.illegalState;
 
-public class Journal
+// TODO: looks like we also have accord via dependency here somehow?
+public class InMemoryJournal implements Journal
 {
-    private final Long2ObjectHashMap<NavigableMap<TxnId, List<Diff>>> diffsPerCommandStore = new Long2ObjectHashMap<>();
+    private final Int2ObjectHashMap<NavigableMap<TxnId, List<Diff>>> diffsPerCommandStore = new Int2ObjectHashMap<>();
+    private final FieldStates fieldStates;
+
+    private static class FieldStates
+    {
+        RedundantBefore redundantBefore = RedundantBefore.EMPTY;
+        NavigableMap<TxnId, Ranges> bootstrapBeganAt = ImmutableSortedMap.of(TxnId.NONE, Ranges.EMPTY);
+        NavigableMap<Timestamp, Ranges> safeToRead = ImmutableSortedMap.of(Timestamp.NONE, Ranges.EMPTY);
+        CommandStores.RangesForEpoch.Snapshot rangesForEpoch = null;
+    }
 
     private final Node.Id id;
 
-    public Journal(Node.Id id)
+    public InMemoryJournal(Node.Id id)
     {
         this.id = id;
+        this.fieldStates = new FieldStates();
     }
 
-    public void purge(IntFunction<CommandStore> storeSupplier)
+    @Override
+    public Command loadCommand(int commandStoreId, TxnId txnId,
+                               // TODO: currently unused!
+                               RedundantBefore redundantBefore, DurableBefore durableBefore)
     {
-        for (Map.Entry<Long, NavigableMap<TxnId, List<Diff>>> e : diffsPerCommandStore.entrySet())
+        List<Diff> diffs = this.diffsPerCommandStore.get(commandStoreId).get(txnId);
+        return reconstruct(diffs);
+    }
+
+    @Override
+    public void saveCommand(int store, CommandUpdate diff, Runnable onFlush)
+    {
+        if (diff == null)
+            return;
+
+       if (diff.after.saveStatus() == SaveStatus.Erased)
         {
-            int commandStoreId = e.getKey().intValue();
+            diffsPerCommandStore.computeIfAbsent(store, (k) -> new TreeMap<>())
+                                .remove(diff.after.txnId());
+            return;
+        }
+
+        diffsPerCommandStore.computeIfAbsent(store, (k) -> new TreeMap<>())
+                            .computeIfAbsent(diff.txnId, (k_) -> new ArrayList<>())
+                            .add(diff(diff.before, diff.after));
+
+        if (onFlush!= null)
+            onFlush.run();
+    }
+
+    @Override
+    public RedundantBefore loadRedundantBefore(int commandStoreId)
+    {
+        return fieldStates.redundantBefore;
+    }
+
+    @Override
+    public NavigableMap<TxnId, Ranges> loadBootstrapBeganAt(int commandStoreId)
+    {
+        return fieldStates.bootstrapBeganAt;
+    }
+
+    @Override
+    public NavigableMap<Timestamp, Ranges> loadSafeToRead(int commandStoreId)
+    {
+        return fieldStates.safeToRead;
+    }
+
+    @Override
+    public CommandStores.RangesForEpoch.Snapshot loadRangesForEpoch(int commandStoreId)
+    {
+        return fieldStates.rangesForEpoch;
+    }
+
+    public void saveStoreState(int store, FieldUpdates fieldUpdates, Runnable onFlush)
+    {
+        if (fieldUpdates.newRedundantBefore != null)
+            fieldStates.redundantBefore = fieldUpdates.newRedundantBefore;
+        if (fieldUpdates.newSafeToRead != null)
+            fieldStates.safeToRead = fieldUpdates.newSafeToRead;
+        if (fieldUpdates.newBootstrapBeganAt != null)
+            fieldStates.bootstrapBeganAt = fieldUpdates.newBootstrapBeganAt;
+        if (fieldUpdates.newRangesForEpoch != null)
+            fieldStates.rangesForEpoch = fieldUpdates.newRangesForEpoch;
+
+        if (onFlush!= null)
+            onFlush.run();
+    }
+
+    @Override
+    public void purge(CommandStores commandStores)
+    {
+        for (Map.Entry<Integer, NavigableMap<TxnId, List<Diff>>> e : diffsPerCommandStore.entrySet())
+        {
+            int commandStoreId = e.getKey();
             Map<TxnId, List<Diff>> localJournal = e.getValue();
-            CommandStore store = storeSupplier.apply(commandStoreId);
+            CommandStore store = commandStores.forId(commandStoreId);
             if (store == null)
                 continue;
 
-            Map<TxnId, List<Diff>> updates = new HashMap<>();
-            List<TxnId> removals = new ArrayList<>();
             for (Map.Entry<TxnId, List<Diff>> e2 : localJournal.entrySet())
             {
                 TxnId txnId = e2.getKey();
                 List<Diff> diffs = e2.getValue();
-                Command command = reconstruct(diffs, Reconstruct.Last).get(0);
+                Command command =  reconstruct(diffs);
                 if (command.status() == Truncated || command.status() == Invalidated)
                     continue; // Already truncated
                 Cleanup cleanup = Cleanup.shouldCleanup(store.agent(), command, store.unsafeGetRedundantBefore(), store.durableBefore());
@@ -117,30 +197,40 @@ public class Journal
         }
     }
 
-    public void reconstructAll(InMemoryCommandStore.Loader loader, int commandStoreId)
+    @Override
+    public void replay(CommandStores commandStores)
     {
-        // Nothing to do here, journal is empty for this command store
-        if (!diffsPerCommandStore.containsKey(commandStoreId))
-            return;
-
-        // copy to avoid concurrent modification when appending to journal
-        Map<TxnId, List<Diff>> diffs = new TreeMap<>(diffsPerCommandStore.get(commandStoreId));
-        for (Map.Entry<TxnId, List<Diff>> e : diffs.entrySet())
-            e.setValue(new ArrayList<>(e.getValue()));
+        OnDone sync = new OnDone() {
+            public void success() {}
+            public void failure(Throwable t) { throw new RuntimeException("Caught an exception during replay", t); }
+        };
 
-        List<Command> toApply = new ArrayList<>();
-        for (Map.Entry<TxnId, List<Diff>> e : diffs.entrySet())
+        for (Map.Entry<Integer, NavigableMap<TxnId, List<Diff>>> diffEntry : diffsPerCommandStore.entrySet())
         {
-            if (e.getValue().isEmpty()) continue;
-            Command command = reconstruct(commandStoreId, e.getKey(), e.getValue());
-            if (command.saveStatus().compareTo(Stable) >= 0 && !command.hasBeen(Truncated))
-                toApply.add(command);
-            loader.load(command);
-        }
+            int commandStoreId = diffEntry.getKey();
+            // copy to avoid concurrent modification when appending to journal
+            Map<TxnId, List<Diff>> diffs = new TreeMap<>(diffEntry.getValue());
+
+            InMemoryCommandStore commandStore = (InMemoryCommandStore) commandStores.forId(commandStoreId);
+            Loader loader = commandStore.loader();
+
+            for (Map.Entry<TxnId, List<Diff>> e : diffs.entrySet())
+                e.setValue(new ArrayList<>(e.getValue()));
 
-        toApply.sort(Comparator.comparing(Command::executeAt));
-        for (Command command : toApply)
-            loader.apply(command);
+            List<Command> toApply = new ArrayList<>();
+            for (Map.Entry<TxnId, List<Diff>> e : diffs.entrySet())
+            {
+                if (e.getValue().isEmpty()) continue;
+                Command command =  reconstruct(e.getValue());
+                if (command.saveStatus().compareTo(Stable) >= 0 && !command.hasBeen(Truncated))
+                    toApply.add(command);
+                loader.load(command, sync);
+            }
+
+            toApply.sort(Comparator.comparing(Command::executeAt));
+            for (Command command : toApply)
+                loader.apply(command, sync);
+        }
     }
 
     static class ErasedList extends AbstractList<Diff>
@@ -211,28 +301,10 @@ public class Journal
         }
     }
 
-    private enum Reconstruct
-    {
-        Each,
-        Last
-    }
-
-    public Command reconstruct(int commandStoreId, TxnId txnId)
-    {
-        return reconstruct(commandStoreId, txnId, diffsPerCommandStore.get(commandStoreId).get(txnId));
-    }
-
-    public Command reconstruct(int commandStoreId, TxnId txnId, List<Diff> diffs)
-    {
-        return reconstruct(diffs, Reconstruct.Last).get(0);
-    }
-
-    private List<Command> reconstruct(List<Diff> diffs, Reconstruct reconstruct)
+    private Command reconstruct(List<Diff> diffs)
     {
         Invariants.checkState(diffs != null && !diffs.isEmpty());
 
-        List<Command> results = new ArrayList<>();
-
         TxnId txnId = null;
         Timestamp executeAt = null;
         Timestamp executesAtLeast = null;
@@ -260,13 +332,7 @@ public class Journal
             if (diff.executesAtLeast != null)
                 executesAtLeast = diff.executesAtLeast.get();
             if (diff.saveStatus != null)
-            {
-                Set<SaveStatus> allowed = new HashSet<>();
-                allowed.add(SaveStatus.TruncatedApply);
-                allowed.add(SaveStatus.TruncatedApplyWithOutcome);
-
                 saveStatus = diff.saveStatus.get();
-            }
             if (diff.durability != null)
                 durability = diff.durability.get();
 
@@ -307,75 +373,68 @@ public class Journal
                     result = null;
                     break;
             }
+        }
 
-            CommonAttributes.Mutable attrs = new CommonAttributes.Mutable(txnId);
-            if (partialTxn != null)
-                attrs.partialTxn(partialTxn);
-            if (durability != null)
-                attrs.durability(durability);
-            if (participants != null) attrs.setParticipants(participants);
-            else attrs.setParticipants(StoreParticipants.empty(txnId));
-
-            // TODO (desired): we can simplify this logic if, instead of diffing, we will infer the diff from the status
-            if (partialDeps != null &&
-                (saveStatus.known.deps != Known.KnownDeps.NoDeps &&
-                 saveStatus.known.deps != Known.KnownDeps.DepsErased &&
-                 saveStatus.known.deps != Known.KnownDeps.DepsUnknown))
-                attrs.partialDeps(partialDeps);
-            Invariants.checkState(saveStatus != null,
-                                  "Save status is null after applying %s", diffs);
+        CommonAttributes.Mutable attrs = new CommonAttributes.Mutable(txnId);
+        if (partialTxn != null)
+            attrs.partialTxn(partialTxn);
+        if (durability != null)
+            attrs.durability(durability);
+        if (participants != null) attrs.setParticipants(participants);
+        else attrs.setParticipants(StoreParticipants.empty(txnId));
+
+        // TODO (desired): we can simplify this logic if, instead of diffing, we will infer the diff from the status
+        if (partialDeps != null &&
+            (saveStatus.known.deps != Known.KnownDeps.NoDeps &&
+             saveStatus.known.deps != Known.KnownDeps.DepsErased &&
+             saveStatus.known.deps != Known.KnownDeps.DepsUnknown))
+            attrs.partialDeps(partialDeps);
+
+        try
+        {
 
-            try
+            Command current;
+            switch (saveStatus.status)
             {
-                if (reconstruct == Reconstruct.Each ||
-                    (reconstruct == Reconstruct.Last && i == diffs.size() - 1))
-                {
-                    Command current;
-                    switch (saveStatus.status)
-                    {
-                        case NotDefined:
-                            current = saveStatus == SaveStatus.Uninitialised ? Command.NotDefined.uninitialised(attrs.txnId())
-                                                                             : Command.NotDefined.notDefined(attrs, promised);
-                            break;
-                        case PreAccepted:
-                            current = Command.PreAccepted.preAccepted(attrs, executeAt, promised);
-                            break;
-                        case AcceptedInvalidate:
-                        case Accepted:
-                        case PreCommitted:
-                            if (saveStatus == SaveStatus.AcceptedInvalidate)
-                                current = Command.AcceptedInvalidateWithoutDefinition.acceptedInvalidate(attrs, promised, acceptedOrCommitted);
-                            else
-                                current = Command.Accepted.accepted(attrs, saveStatus, executeAt, promised, acceptedOrCommitted);
-                            break;
-                        case Committed:
-                        case Stable:
-                            current = Command.Committed.committed(attrs, saveStatus, executeAt, promised, acceptedOrCommitted, waitingOn);
-                            break;
-                        case PreApplied:
-                        case Applied:
-                            current = Command.Executed.executed(attrs, saveStatus, executeAt, promised, acceptedOrCommitted, waitingOn, writes, result);
-                            break;
-                        case Invalidated:
-                        case Truncated:
-                            current = truncated(attrs, saveStatus, executeAt, executesAtLeast, writes, result);
-                            break;
-                        default:
-                            throw new IllegalStateException("Do not know " + saveStatus.status + " " + saveStatus);
-                    }
-
-                    results.add(current);
-                }
+                case NotDefined:
+                    current = saveStatus == SaveStatus.Uninitialised ? Command.NotDefined.uninitialised(attrs.txnId())
+                                                                     : Command.NotDefined.notDefined(attrs, promised);
+                    break;
+                case PreAccepted:
+                    current = Command.PreAccepted.preAccepted(attrs, executeAt, promised);
+                    break;
+                case AcceptedInvalidate:
+                case Accepted:
+                case PreCommitted:
+                    if (saveStatus == SaveStatus.AcceptedInvalidate)
+                        current = Command.AcceptedInvalidateWithoutDefinition.acceptedInvalidate(attrs, promised, acceptedOrCommitted);
+                    else
+                        current = Command.Accepted.accepted(attrs, saveStatus, executeAt, promised, acceptedOrCommitted);
+                    break;
+                case Committed:
+                case Stable:
+                    current = Command.Committed.committed(attrs, saveStatus, executeAt, promised, acceptedOrCommitted, waitingOn);
+                    break;
+                case PreApplied:
+                case Applied:
+                    current = Command.Executed.executed(attrs, saveStatus, executeAt, promised, acceptedOrCommitted, waitingOn, writes, result);
+                    break;
+                case Invalidated:
+                case Truncated:
+                    current = truncated(attrs, saveStatus, executeAt, executesAtLeast, writes, result);
+                    break;
+                default:
+                    throw new IllegalStateException("Do not know " + saveStatus.status + " " + saveStatus);
             }
-            catch (Throwable t)
-            {
 
-                throw new RuntimeException("Can not reconstruct from diff:\n" + diffs.stream().map(o -> o.toString())
-                                                                                     .collect(Collectors.joining("\n")),
-                                           t);
-            }
+            return current;
+        }
+        catch (Throwable t)
+        {
+            throw new RuntimeException("Can not reconstruct from diff:\n" + diffs.stream().map(o -> o.toString())
+                                                                                 .collect(Collectors.joining("\n")),
+                                       t);
         }
-        return results;
     }
 
     private static Command.Truncated truncated(CommonAttributes.Mutable attrs, SaveStatus status, Timestamp executeAt, Timestamp executesAtLeast, Writes writes, Result result)
@@ -397,23 +456,6 @@ public class Journal
         }
     }
 
-    public void onExecute(int commandStoreId, Command before, Command after, boolean isPrimary)
-    {
-        if (before == null && after == null)
-            return;
-
-        Diff diff = diff(before, after);
-        if (!isPrimary)
-            diff = diff.asNonPrimary();
-
-        if (diff != null)
-        {
-            diffsPerCommandStore.computeIfAbsent(commandStoreId, (k) -> new TreeMap<>())
-                                .computeIfAbsent(after.txnId(), (k_) -> new ArrayList<>())
-                                .add(diff);
-        }
-    }
-
     private static class Diff
     {
         public final TxnId txnId;
@@ -470,12 +512,6 @@ public class Journal
             this.result = result;
         }
 
-        // We allow only save status, and waitingOn to be updated by non-primary transactions
-        public Diff asNonPrimary()
-        {
-            return new Diff(txnId, null, null, saveStatus, null, null, null, null, null, null, waitingOn, null, null);
-        }
-
         public boolean allNulls()
         {
             if (txnId != null) return false;
@@ -546,7 +582,7 @@ public class Journal
                              ifNotEqual(before, after, Command::participants, true),
                              ifNotEqual(before, after, Command::partialTxn, false),
                              ifNotEqual(before, after, Command::partialDeps, false),
-                             ifNotEqual(before, after, Journal::getWaitingOn, true),
+                             ifNotEqual(before, after, InMemoryJournal::getWaitingOn, true),
                              ifNotEqual(before, after, Command::writes, false),
                              ifNotEqual(before, after, Command::result, false));
         if (diff.allNulls())
diff --git a/accord-core/src/main-test/java/accord/impl/basic/LoggingJournal.java b/accord-core/src/main-test/java/accord/impl/basic/LoggingJournal.java
new file mode 100644
index 00000000..012bbff7
--- /dev/null
+++ b/accord-core/src/main-test/java/accord/impl/basic/LoggingJournal.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package accord.impl.basic;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.util.NavigableMap;
+
+import accord.api.Journal;
+import accord.local.Command;
+import accord.local.CommandStores;
+import accord.local.DurableBefore;
+import accord.local.RedundantBefore;
+import accord.primitives.Ranges;
+import accord.primitives.Timestamp;
+import accord.primitives.TxnId;
+
+/**
+ * Logging journal, a wrapper over journal for debugging / inspecting history purposes
+ */
+public class LoggingJournal implements Journal
+{
+    private final BufferedWriter log;
+    private final Journal delegate;
+
+    public LoggingJournal(Journal delegate)
+    {
+        this.delegate = delegate;
+        File f = new File("journal.log");
+        try
+        {
+            log = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f)));
+        }
+        catch (FileNotFoundException e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private synchronized void log(String format, Object... objects)
+    {
+        try
+        {
+            log.write(String.format(format, objects));
+            log.flush();
+        }
+        catch (IOException e)
+        {
+            // ignore
+        }
+    }
+
+    public Command loadCommand(int commandStoreId, TxnId txnId, RedundantBefore redundantBefore, DurableBefore durableBefore)
+    {
+        return delegate.loadCommand(commandStoreId, txnId, redundantBefore, durableBefore);
+    }
+
+    public void saveCommand(int store, CommandUpdate update, Runnable onFlush)
+    {
+        log("%d: %s\n", store, update.after);
+        delegate.saveCommand(store, update, onFlush);
+    }
+
+    public void purge(CommandStores commandStores)
+    {
+        log("PURGE\n");
+        delegate.purge(commandStores);
+    }
+
+    public void replay(CommandStores commandStores)
+    {
+        delegate.replay(commandStores);
+    }
+
+    public RedundantBefore loadRedundantBefore(int commandStoreId)
+    {
+        return delegate.loadRedundantBefore(commandStoreId);
+    }
+
+    public NavigableMap<TxnId, Ranges> loadBootstrapBeganAt(int commandStoreId)
+    {
+        return delegate.loadBootstrapBeganAt(commandStoreId);
+    }
+
+    public NavigableMap<Timestamp, Ranges> loadSafeToRead(int commandStoreId)
+    {
+        return delegate.loadSafeToRead(commandStoreId);
+    }
+
+    public CommandStores.RangesForEpoch.Snapshot loadRangesForEpoch(int commandStoreId)
+    {
+        return delegate.loadRangesForEpoch(commandStoreId);
+    }
+
+    public void saveStoreState(int store, FieldUpdates fieldUpdates, Runnable onFlush)
+    {
+        log("%d: %s", store, fieldUpdates);
+        delegate.saveStoreState(store, fieldUpdates, onFlush);
+    }
+}
\ No newline at end of file
diff --git a/accord-core/src/main/java/accord/api/Journal.java b/accord-core/src/main/java/accord/api/Journal.java
new file mode 100644
index 00000000..1747c97f
--- /dev/null
+++ b/accord-core/src/main/java/accord/api/Journal.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package accord.api;
+
+import java.util.NavigableMap;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import accord.local.Command;
+import accord.local.CommandStores;
+import accord.local.DurableBefore;
+import accord.local.RedundantBefore;
+import accord.primitives.Ranges;
+import accord.primitives.Timestamp;
+import accord.primitives.TxnId;
+
+/**
+ * Persisted journal for transactional recovery.
+ */
+public interface Journal
+{
+    Command loadCommand(int commandStoreId, TxnId txnId, RedundantBefore redundantBefore, DurableBefore durableBefore);
+    // TODO: use OnDone instead of Runnable
+    void saveCommand(int store, CommandUpdate value, Runnable onFlush);
+
+    void purge(CommandStores commandStores);
+    void replay(CommandStores commandStores);
+
+    RedundantBefore loadRedundantBefore(int commandStoreId);
+    NavigableMap<TxnId, Ranges> loadBootstrapBeganAt(int commandStoreId);
+    NavigableMap<Timestamp, Ranges> loadSafeToRead(int commandStoreId);
+    CommandStores.RangesForEpoch.Snapshot loadRangesForEpoch(int commandStoreId);
+
+    void saveStoreState(int store, FieldUpdates fieldUpdates, Runnable onFlush);
+
+    // TODO (required): this class can be changed in favour of Writer as if/when we switch from DelayedCommandStore to AccordCommandStore
+    // TODO: move to a more appropriate spot?
+    class CommandUpdate
+    {
+        public final TxnId txnId;
+        public final Command before;
+        public final Command after;
+
+        public CommandUpdate(@Nullable Command before, @Nonnull Command after)
+        {
+            this.txnId = after.txnId();
+            this.before = before;
+            this.after = after;
+        }
+    }
+
+    class FieldUpdates
+    {
+        // TODO: use persisted field logic
+        public RedundantBefore newRedundantBefore;
+        public NavigableMap<TxnId, Ranges> newBootstrapBeganAt;
+        public NavigableMap<Timestamp, Ranges> newSafeToRead;
+        public CommandStores.RangesForEpoch.Snapshot newRangesForEpoch;
+
+        public String toString()
+        {
+            return "FieldUpdates{" +
+                   "newRedundantBefore=" + newRedundantBefore +
+                   ", newBootstrapBeganAt=" + newBootstrapBeganAt +
+                   ", newSafeToRead=" + newSafeToRead +
+                   ", newRangesForEpoch=" + newRangesForEpoch +
+                   '}';
+        }
+    }
+
+    /**
+     *
+     */
+    interface Loader
+    {
+        void load(Command next, OnDone onDone);
+        void apply(Command next, OnDone onDone);
+    }
+
+
+    interface OnDone
+    {
+        void success();
+        void failure(Throwable t);
+    }
+}
diff --git a/accord-core/src/main/java/accord/impl/CommandChange.java b/accord-core/src/main/java/accord/impl/CommandChange.java
new file mode 100644
index 00000000..60d1a209
--- /dev/null
+++ b/accord-core/src/main/java/accord/impl/CommandChange.java
@@ -0,0 +1,598 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package accord.impl;
+
+//import java.util.function.Function;
+//
+//import com.google.common.annotations.VisibleForTesting;
+//
+//import accord.api.Agent;
+//import accord.api.Result;
+//import accord.local.Cleanup;
+//import accord.local.Command;
+//import accord.local.CommonAttributes;
+//import accord.local.DurableBefore;
+//import accord.local.RedundantBefore;
+//import accord.local.StoreParticipants;
+//import accord.primitives.Ballot;
+//import accord.primitives.PartialDeps;
+//import accord.primitives.PartialTxn;
+//import accord.primitives.SaveStatus;
+//import accord.primitives.Status;
+//import accord.primitives.Timestamp;
+//import accord.primitives.TxnId;
+//import accord.primitives.Writes;
+//import accord.utils.Invariants;
+//
+//import static accord.impl.CommandChange.Fields.ACCEPTED;
+//import static accord.impl.CommandChange.Fields.CLEANUP;
+//import static accord.impl.CommandChange.Fields.DURABILITY;
+//import static accord.impl.CommandChange.Fields.EXECUTES_AT_LEAST;
+//import static accord.impl.CommandChange.Fields.EXECUTE_AT;
+//import static accord.impl.CommandChange.Fields.FIELDS;
+//import static accord.impl.CommandChange.Fields.PARTIAL_DEPS;
+//import static accord.impl.CommandChange.Fields.PARTIAL_TXN;
+//import static accord.impl.CommandChange.Fields.PARTICIPANTS;
+//import static accord.impl.CommandChange.Fields.PROMISED;
+//import static accord.impl.CommandChange.Fields.SAVE_STATUS;
+//import static accord.impl.CommandChange.Fields.WAITING_ON;
+//import static accord.impl.CommandChange.Fields.WRITES;
+//import static accord.impl.CommandChange.Load.ALL;
+//import static accord.local.Cleanup.NO;
+//import static accord.local.Cleanup.TRUNCATE_WITH_OUTCOME;
+//import static accord.primitives.Known.KnownDeps.DepsErased;
+//import static accord.primitives.Known.KnownDeps.DepsUnknown;
+//import static accord.primitives.Known.KnownDeps.NoDeps;
+//import static accord.primitives.SaveStatus.TruncatedApplyWithOutcome;
+//import static accord.primitives.Status.Durability.NotDurable;
+//import static accord.utils.Invariants.illegalState;
+//import static org.apache.cassandra.service.accord.SavedCommand.MinimalCommand;
+//
+///**
+// * Class representing a change in the Command after its execution by SafeCommandStore
+// */
+//public class CommandChange
+//{
+//    // This enum is order-dependent
+//    public enum Fields
+//    {
+//        PARTICIPANTS, // stored first so we can index it
+//        SAVE_STATUS,
+//        PARTIAL_DEPS,
+//        EXECUTE_AT,
+//        EXECUTES_AT_LEAST,
+//        DURABILITY,
+//        ACCEPTED,
+//        PROMISED,
+//        WAITING_ON,
+//        PARTIAL_TXN,
+//        WRITES,
+//        CLEANUP,
+//        ;
+//
+//        public static final Fields[] FIELDS = values();
+//    }
+//
+//    // TODO (required): calculate flags once
+//    private static boolean anyFieldChanged(int flags)
+//    {
+//        return (flags >>> 16) != 0;
+//    }
+//
+//    private static int validateFlags(int flags)
+//    {
+//        Invariants.checkState(0 == (~(flags >>> 16) & (flags & 0xffff)));
+//        return flags;
+//    }
+//
+//    /**
+//     * Collects flags
+//     */
+//    public static int getFlags(Command before, Command after)
+//    {
+//        int flags = 0;
+//
+//        flags = collectFlags(before, after, Command::executeAt, true, EXECUTE_AT, flags);
+//        flags = collectFlags(before, after, Command::executesAtLeast, true, EXECUTES_AT_LEAST, flags);
+//        flags = collectFlags(before, after, Command::saveStatus, false, SAVE_STATUS, flags);
+//        flags = collectFlags(before, after, Command::durability, false, DURABILITY, flags);
+//
+//        flags = collectFlags(before, after, Command::acceptedOrCommitted, false, ACCEPTED, flags);
+//        flags = collectFlags(before, after, Command::promised, false, PROMISED, flags);
+//
+//        flags = collectFlags(before, after, Command::participants, true, PARTICIPANTS, flags);
+//        flags = collectFlags(before, after, Command::partialTxn, false, PARTIAL_TXN, flags);
+//        flags = collectFlags(before, after, Command::partialDeps, false, PARTIAL_DEPS, flags);
+//
+//        // TODO: waitingOn vs WaitingOnWithExecutedAt?
+//        flags = collectFlags(before, after, CommandChange::getWaitingOn, true, WAITING_ON, flags);
+//
+//        flags = collectFlags(before, after, Command::writes, false, WRITES, flags);
+//
+//        return flags;
+//    }
+//
+//    private static Command.WaitingOn getWaitingOn(Command command)
+//    {
+//        if (command instanceof Command.Committed)
+//            return command.asCommitted().waitingOn();
+//
+//        return null;
+//    }
+//
+//    private static <OBJ, VAL> int collectFlags(OBJ lo, OBJ ro, Function<OBJ, VAL> convert, boolean allowClassMismatch, CommandChange.Fields field, int flags)
+//    {
+//        VAL l = null;
+//        VAL r = null;
+//        if (lo != null) l = convert.apply(lo);
+//        if (ro != null) r = convert.apply(ro);
+//
+//        if (l == r)
+//            return flags; // no change
+//
+//        if (r == null)
+//            flags = setFieldIsNull(field, flags);
+//
+//        if (l == null || r == null)
+//            return setFieldChanged(field, flags);
+//
+//        assert allowClassMismatch || l.getClass() == r.getClass() : String.format("%s != %s", l.getClass(), r.getClass());
+//
+//        if (l.equals(r))
+//            return flags; // no change
+//
+//        return setFieldChanged(field, flags);
+//    }
+//
+//    private static int setFieldChanged(CommandChange.Fields field, int oldFlags)
+//    {
+//        return oldFlags | (0x10000 << field.ordinal());
+//    }
+//
+//    @VisibleForTesting
+//    public static boolean getFieldChanged(CommandChange.Fields field, int oldFlags)
+//    {
+//        return (oldFlags & (0x10000 << field.ordinal())) != 0;
+//    }
+//
+//    static int toIterableSetFields(int flags)
+//    {
+//        return flags >>> 16;
+//    }
+//
+//    static CommandChange.Fields nextSetField(int iterable)
+//    {
+//        int i = Integer.numberOfTrailingZeros(Integer.lowestOneBit(iterable));
+//        return i == 32 ? null : FIELDS[i];
+//    }
+//
+//    static int unsetIterableFields(CommandChange.Fields field, int iterable)
+//    {
+//        return iterable & ~(1 << field.ordinal());
+//    }
+//
+//    @VisibleForTesting
+//    static boolean getFieldIsNull(CommandChange.Fields field, int oldFlags)
+//    {
+//        return (oldFlags & (1 << field.ordinal())) != 0;
+//    }
+//
+//    private static int setFieldIsNull(CommandChange.Fields field, int oldFlags)
+//    {
+//        return oldFlags | (1 << field.ordinal());
+//    }
+//
+//    public enum Load
+//    {
+//        ALL(0),
+//        PURGEABLE(SAVE_STATUS, PARTICIPANTS, DURABILITY, EXECUTE_AT, WRITES),
+//        MINIMAL(SAVE_STATUS, PARTICIPANTS, EXECUTE_AT);
+//
+//        final int mask;
+//
+//        Load(int mask)
+//        {
+//            this.mask = mask;
+//        }
+//
+//        Load(Fields ... fields)
+//        {
+//            int mask = -1;
+//            for (Fields field : fields)
+//                mask &= ~(1<< field.ordinal());
+//            this.mask = mask;
+//        }
+//    }
+//
+//    /**
+//     * Helper class for reconstructing Command from a sequence of logged CommandChanges
+//     */
+//    public static class CommandBuilder
+//    {
+//        final int mask;
+//        int flags;
+//
+//        TxnId txnId;
+//
+//        Timestamp executeAt;
+//        Timestamp executeAtLeast;
+//        SaveStatus saveStatus;
+//        Status.Durability durability;
+//
+//        Ballot acceptedOrCommitted;
+//        Ballot promised;
+//
+//        StoreParticipants participants;
+//        PartialTxn partialTxn;
+//        PartialDeps partialDeps;
+//
+//        byte[] waitingOnBytes;
+//        CommandChange.WaitingOnProvider waitingOn;
+//        Writes writes;
+//        Result result;
+//        Cleanup cleanup;
+//
+//        boolean nextCalled;
+//        int count;
+//
+//        public CommandBuilder(TxnId txnId, CommandChange.Load load)
+//        {
+//            this.mask = load.mask;
+//            init(txnId);
+//        }
+//
+//        public CommandBuilder(TxnId txnId)
+//        {
+//            this(txnId, ALL);
+//        }
+//
+//        public CommandBuilder(CommandChange.Load load)
+//        {
+//            this.mask = load.mask;
+//        }
+//
+//        public CommandBuilder()
+//        {
+//            this(ALL);
+//        }
+//
+//        public TxnId txnId()
+//        {
+//            return txnId;
+//        }
+//
+//        public Timestamp executeAt()
+//        {
+//            return executeAt;
+//        }
+//
+//        public Timestamp executeAtLeast()
+//        {
+//            return executeAtLeast;
+//        }
+//
+//        public SaveStatus saveStatus()
+//        {
+//            return saveStatus;
+//        }
+//
+//        public Status.Durability durability()
+//        {
+//            return durability;
+//        }
+//
+//        public Ballot acceptedOrCommitted()
+//        {
+//            return acceptedOrCommitted;
+//        }
+//
+//        public Ballot promised()
+//        {
+//            return promised;
+//        }
+//
+//        public StoreParticipants participants()
+//        {
+//            return participants;
+//        }
+//
+//        public PartialTxn partialTxn()
+//        {
+//            return partialTxn;
+//        }
+//
+//        public PartialDeps partialDeps()
+//        {
+//            return partialDeps;
+//        }
+//
+//        public CommandChange.WaitingOnProvider waitingOn()
+//        {
+//            return waitingOn;
+//        }
+//
+//        public Writes writes()
+//        {
+//            return writes;
+//        }
+//
+//        public Result result()
+//        {
+//            return result;
+//        }
+//
+//        public void clear()
+//        {
+//            flags = 0;
+//            txnId = null;
+//
+//            executeAt = null;
+//            executeAtLeast = null;
+//            saveStatus = null;
+//            durability = null;
+//
+//            acceptedOrCommitted = null;
+//            promised = null;
+//
+//            participants = null;
+//            partialTxn = null;
+//            partialDeps = null;
+//
+//            waitingOnBytes = null;
+//            waitingOn = null;
+//            writes = null;
+//            result = null;
+//            cleanup = null;
+//
+//            nextCalled = false;
+//            count = 0;
+//        }
+//
+//        public void reset(TxnId txnId)
+//        {
+//            clear();
+//            init(txnId);
+//        }
+//
+//        public void init(TxnId txnId)
+//        {
+//            this.txnId = txnId;
+//            durability = NotDurable;
+//            acceptedOrCommitted = promised = Ballot.ZERO;
+//            waitingOn = (txn, deps) -> null;
+//            // TODO
+//            //result = CommandSerializers.APPLIED;
+//        }
+//
+//        public boolean isEmpty()
+//        {
+//            return !nextCalled;
+//        }
+//
+//        public int count()
+//        {
+//            return count;
+//        }
+//
+//        public Cleanup shouldCleanup(Agent agent, RedundantBefore redundantBefore, DurableBefore durableBefore)
+//        {
+//            if (!nextCalled)
+//                return NO;
+//
+//            if (saveStatus == null || participants == null)
+//                return Cleanup.NO;
+//
+//            Cleanup cleanup = Cleanup.shouldCleanupPartial(agent, txnId, saveStatus, durability, participants, redundantBefore, durableBefore);
+//            if (this.cleanup != null && this.cleanup.compareTo(cleanup) > 0)
+//                cleanup = this.cleanup;
+//            return cleanup;
+//        }
+//
+//        // TODO (expected): avoid allocating new builder
+//        public CommandBuilder maybeCleanup(Cleanup cleanup)
+//        {
+//            if (saveStatus() == null)
+//                return this;
+//
+//            switch (cleanup)
+//            {
+//                case EXPUNGE:
+//                case ERASE:
+//                    return null;
+//
+//                case EXPUNGE_PARTIAL:
+//                    return expungePartial(cleanup, saveStatus, true);
+//
+//                case VESTIGIAL:
+//                case INVALIDATE:
+//                    return saveStatusOnly();
+//
+//                case TRUNCATE_WITH_OUTCOME:
+//                case TRUNCATE:
+//                    return expungePartial(cleanup, cleanup.appliesIfNot, cleanup == TRUNCATE_WITH_OUTCOME);
+//
+//                case NO:
+//                    return this;
+//                default:
+//                    throw new IllegalStateException("Unknown cleanup: " + cleanup);}
+//        }
+//
+//        public CommandBuilder expungePartial(Cleanup cleanup, SaveStatus saveStatus, boolean includeOutcome)
+//        {
+//            Invariants.checkState(txnId != null);
+//            CommandBuilder builder = new CommandBuilder(txnId, ALL);
+//
+//            builder.count++;
+//            builder.nextCalled = true;
+//
+//            Invariants.checkState(saveStatus != null);
+//            builder.flags = setFieldChanged(SAVE_STATUS, builder.flags);
+//            builder.saveStatus = saveStatus;
+//            builder.flags = setFieldChanged(CLEANUP, builder.flags);
+//            builder.cleanup = cleanup;
+//            if (executeAt != null)
+//            {
+//                builder.flags = setFieldChanged(EXECUTE_AT, builder.flags);
+//                builder.executeAt = executeAt;
+//            }
+//            if (durability != null)
+//            {
+//                builder.flags = setFieldChanged(DURABILITY, builder.flags);
+//                builder.durability = durability;
+//            }
+//            if (participants != null)
+//            {
+//                builder.flags = setFieldChanged(PARTICIPANTS, builder.flags);
+//                builder.participants = participants;
+//            }
+//            if (includeOutcome && builder.writes != null)
+//            {
+//                builder.flags = setFieldChanged(WRITES, builder.flags);
+//                builder.writes = writes;
+//            }
+//
+//            return builder;
+//        }
+//
+//        public CommandBuilder saveStatusOnly()
+//        {
+//            Invariants.checkState(txnId != null);
+//            CommandBuilder builder = new CommandBuilder(txnId, ALL);
+//
+//            builder.count++;
+//            builder.nextCalled = true;
+//
+//            // TODO: these accesses can be abstracted away
+//            if (saveStatus != null)
+//            {
+//                builder.flags = setFieldChanged(SAVE_STATUS, builder.flags);
+//                builder.saveStatus = saveStatus;
+//            }
+//
+//            return builder;
+//        }
+//
+//        public MinimalCommand asMinimal()
+//        {
+//            return new MinimalCommand(txnId, saveStatus, participants, durability, executeAt, writes);
+//        }
+//
+//        @VisibleForTesting
+//        public void forceResult(Result newValue)
+//        {
+//            this.result = newValue;
+//        }
+//
+//        public Command construct()
+//        {
+//            if (!nextCalled)
+//                return null;
+//
+//            Invariants.checkState(txnId != null);
+//            CommonAttributes.Mutable attrs = new CommonAttributes.Mutable(txnId);
+//            if (partialTxn != null)
+//                attrs.partialTxn(partialTxn);
+//            if (durability != null)
+//                attrs.durability(durability);
+//            if (participants != null)
+//                attrs.setParticipants(participants);
+//            if (partialDeps != null &&
+//                (saveStatus.known.deps != NoDeps &&
+//                 saveStatus.known.deps != DepsErased &&
+//                 saveStatus.known.deps != DepsUnknown))
+//                attrs.partialDeps(partialDeps);
+//
+//            Command.WaitingOn waitingOn = null;
+//            if (this.waitingOn != null)
+//                waitingOn = this.waitingOn.provide(txnId, partialDeps);
+//
+//            switch (saveStatus.status)
+//            {
+//                case NotDefined:
+//                    return saveStatus == SaveStatus.Uninitialised ? Command.NotDefined.uninitialised(attrs.txnId())
+//                                                                  : Command.NotDefined.notDefined(attrs, promised);
+//                case PreAccepted:
+//                    return Command.PreAccepted.preAccepted(attrs, executeAt, promised);
+//                case AcceptedInvalidate:
+//                case Accepted:
+//                case PreCommitted:
+//                    if (saveStatus == SaveStatus.AcceptedInvalidate)
+//                        return Command.AcceptedInvalidateWithoutDefinition.acceptedInvalidate(attrs, promised, acceptedOrCommitted);
+//                    else
+//                        return Command.Accepted.accepted(attrs, saveStatus, executeAt, promised, acceptedOrCommitted);
+//                case Committed:
+//                case Stable:
+//                    return Command.Committed.committed(attrs, saveStatus, executeAt, promised, acceptedOrCommitted, waitingOn);
+//                case PreApplied:
+//                case Applied:
+//                    return Command.Executed.executed(attrs, saveStatus, executeAt, promised, acceptedOrCommitted, waitingOn, writes, result);
+//                case Truncated:
+//                case Invalidated:
+//                    return truncated(attrs, saveStatus, executeAt, executeAtLeast, writes, result);
+//                default:
+//                    throw new IllegalStateException();
+//            }
+//        }
+//
+//        private static Command.Truncated truncated(CommonAttributes.Mutable attrs, SaveStatus status, Timestamp executeAt, Timestamp executesAtLeast, Writes writes, Result result)
+//        {
+//            switch (status)
+//            {
+//                default:
+//                    throw illegalState("Unhandled SaveStatus: " + status);
+//                case TruncatedApplyWithOutcome:
+//                case TruncatedApplyWithDeps:
+//                case TruncatedApply:
+//                    if (status != TruncatedApplyWithOutcome)
+//                        result = null;
+//                    if (attrs.txnId().kind().awaitsOnlyDeps())
+//                        return Command.Truncated.truncatedApply(attrs, status, executeAt, writes, result, executesAtLeast);
+//                    return Command.Truncated.truncatedApply(attrs, status, executeAt, writes, result, null);
+//                case ErasedOrVestigial:
+//                    return Command.Truncated.erasedOrInvalidOrVestigial(attrs.txnId(), attrs.durability(), attrs.participants());
+//                case Erased:
+//                    return Command.Truncated.erased(attrs.txnId(), attrs.durability(), attrs.participants());
+//                case Invalidated:
+//                    return Command.Truncated.invalidated(attrs.txnId());
+//            }
+//        }
+//
+//        public String toString()
+//        {
+//            return "Diff {" +
+//                   "txnId=" + txnId +
+//                   ", executeAt=" + executeAt +
+//                   ", saveStatus=" + saveStatus +
+//                   ", durability=" + durability +
+//                   ", acceptedOrCommitted=" + acceptedOrCommitted +
+//                   ", promised=" + promised +
+//                   ", participants=" + participants +
+//                   ", partialTxn=" + partialTxn +
+//                   ", partialDeps=" + partialDeps +
+//                   ", waitingOn=" + waitingOn +
+//                   ", writes=" + writes +
+//                   '}';
+//        }
+//    }
+//
+//    public interface WaitingOnProvider
+//    {
+//        Command.WaitingOn provide(TxnId txnId, PartialDeps deps);
+//    }
+//}
\ No newline at end of file
diff --git a/accord-core/src/main/java/accord/impl/DurabilityScheduling.java b/accord-core/src/main/java/accord/impl/DurabilityScheduling.java
index bd370b93..ada18fc9 100644
--- a/accord-core/src/main/java/accord/impl/DurabilityScheduling.java
+++ b/accord-core/src/main/java/accord/impl/DurabilityScheduling.java
@@ -36,6 +36,7 @@ import accord.api.Scheduler;
 import accord.coordinate.CoordinateGloballyDurable;
 import accord.coordinate.CoordinationFailed;
 import accord.coordinate.ExecuteSyncPoint.SyncPointErased;
+import accord.coordinate.Timeout;
 import accord.local.Node;
 import accord.local.ShardDistributor;
 import accord.primitives.FullRoute;
@@ -313,7 +314,10 @@ public class DurabilityScheduling implements ConfigurationService.Listener
                                 index *= 2;
                                 numberOfSplits *= 2;
                             }
-                            logger.warn("{}: Exception coordinating ExclusiveSyncPoint for {} durability. Increased numberOfSplits to " + numberOfSplits, syncId, ranges, fail);
+                            if (fail instanceof Timeout)
+                                logger.trace("{}: Exception coordinating ExclusiveSyncPoint for {} durability. Increased numberOfSplits to " + numberOfSplits, syncId, ranges, fail);
+                            else
+                                logger.debug("{}: Exception coordinating ExclusiveSyncPoint for {} durability. Increased numberOfSplits to " + numberOfSplits, syncId, ranges, fail);
                         }
                     }
                     else
@@ -335,7 +339,10 @@ public class DurabilityScheduling implements ConfigurationService.Listener
                     .addCallback((success, fail) -> {
                         if (fail != null && fail.getClass() != SyncPointErased.class)
                         {
-                            logger.debug("Exception coordinating shard durability for {}, will retry", exclusiveSyncPoint.route.toRanges(), fail);
+                            if (fail instanceof Timeout)
+                                logger.trace("Exception coordinating shard durability for {}, will retry", exclusiveSyncPoint.route.toRanges(), fail);
+                            else
+                                logger.debug("Exception coordinating shard durability for {}, will retry", exclusiveSyncPoint.route.toRanges(), fail);
                             retryCoordinateDurability(node, exclusiveSyncPoint, nextIndex);
                         }
                         else
diff --git a/accord-core/src/main/java/accord/impl/InMemoryCommandStore.java b/accord-core/src/main/java/accord/impl/InMemoryCommandStore.java
index e50998b4..2322186c 100644
--- a/accord-core/src/main/java/accord/impl/InMemoryCommandStore.java
+++ b/accord-core/src/main/java/accord/impl/InMemoryCommandStore.java
@@ -44,6 +44,7 @@ import javax.annotation.Nullable;
 
 import com.google.common.annotations.VisibleForTesting;
 
+import accord.api.Journal;
 import accord.api.LocalListeners;
 import accord.api.RoutingKey;
 import accord.impl.progresslog.DefaultProgressLog;
@@ -130,10 +131,12 @@ public abstract class InMemoryCommandStore extends CommandStore
     protected Timestamp maxRedundant = Timestamp.NONE;
 
     private InMemorySafeStore current;
+    private final Journal.Loader loader;
 
     public InMemoryCommandStore(int id, NodeCommandStoreService time, Agent agent, DataStore store, ProgressLog.Factory progressLogFactory, LocalListeners.Factory listenersFactory, EpochUpdateHolder epochUpdateHolder)
     {
         super(id, time, agent, store, progressLogFactory, listenersFactory, epochUpdateHolder);
+        this.loader = new CommandLoader(this);
     }
 
     protected boolean canExposeUnloaded()
@@ -1357,88 +1360,107 @@ public abstract class InMemoryCommandStore extends CommandStore
         unsafeSetRejectBefore(new RejectBefore());
     }
 
-    public interface Loader
+    public Journal.Loader loader()
     {
-        void load(Command next);
-        void apply(Command next);
+        return loader;
     }
 
-    public Loader loader()
+    private static class CommandLoader implements Journal.Loader
     {
-        return new Loader()
+        private final InMemoryCommandStore commandStore;
+
+        private CommandLoader(InMemoryCommandStore commandStore)
         {
-            private PreLoadContext context(Command command, KeyHistory keyHistory)
-            {
-                TxnId txnId = command.txnId();
-                AbstractUnseekableKeys keys = null;
+            this.commandStore = commandStore;
+        }
 
-                if (CommandsForKey.manages(txnId))
-                    keys = (AbstractUnseekableKeys) command.participants().hasTouched();
-                else if (!CommandsForKey.managesExecution(txnId) && command.hasBeen(Status.Stable) && !command.hasBeen(Status.Truncated))
-                    keys = command.asCommitted().waitingOn.keys;
+        private PreLoadContext context(Command command, KeyHistory keyHistory)
+        {
+            TxnId txnId = command.txnId();
+            AbstractUnseekableKeys keys = null;
 
-                if (keys != null)
-                {
-                    return PreLoadContext.contextFor(txnId, keys, keyHistory);
-                }
+            if (CommandsForKey.manages(txnId))
+                keys = (AbstractUnseekableKeys) command.participants().hasTouched();
+            else if (!CommandsForKey.managesExecution(txnId) && command.hasBeen(Status.Stable) && !command.hasBeen(Status.Truncated))
+                keys = command.asCommitted().waitingOn.keys;
 
-                return PreLoadContext.contextFor(txnId);
+            if (keys != null)
+            {
+                return PreLoadContext.contextFor(txnId, keys, keyHistory);
             }
 
-            public void load(Command command)
-            {
-                TxnId txnId = command.txnId();
-
-                executeInContext(InMemoryCommandStore.this,
-                                 context(command, ASYNC),
-                                 safeStore -> {
-                                     Command local = command;
-                                     if (local.status() != Truncated && local.status() != Invalidated)
-                                     {
-                                         Cleanup cleanup = Cleanup.shouldCleanup(safeStore, local, local.participants());
-                                         switch (cleanup)
-                                         {
-                                             case NO:
-                                                 break;
-                                             case INVALIDATE:
-                                             case TRUNCATE_WITH_OUTCOME:
-                                             case TRUNCATE:
-                                             case ERASE:
-                                                 local = Commands.purge(local, local.participants(), cleanup);
-                                         }
-                                     }
-
-                                     local = safeStore.unsafeGet(txnId).update(safeStore, local);
-                                     if (local.status() == Truncated)
-                                         safeStore.progressLog().clear(local.txnId());
-                                     return local;
-                                 });
+            return PreLoadContext.contextFor(txnId);
+        }
 
+        @Override
+        public void load(Command command, Journal.OnDone onDone)
+        {
+            TxnId txnId = command.txnId();
 
+            try
+            {
+                commandStore.executeInContext(commandStore,
+                                              context(command, ASYNC),
+                                              safeStore -> {
+                                                  Command local = command;
+                                                  if (local.status() != Truncated && local.status() != Invalidated)
+                                                  {
+                                                      Cleanup cleanup = Cleanup.shouldCleanup(safeStore, local, local.participants());
+                                                      switch (cleanup)
+                                                      {
+                                                          case NO:
+                                                              break;
+                                                          case INVALIDATE:
+                                                          case TRUNCATE_WITH_OUTCOME:
+                                                          case TRUNCATE:
+                                                          case ERASE:
+                                                              local = Commands.purge(local, local.participants(), cleanup);
+                                                      }
+                                                  }
+
+                                                  local = safeStore.unsafeGet(txnId).update(safeStore, local);
+                                                  if (local.status() == Truncated)
+                                                      safeStore.progressLog().clear(local.txnId());
+                                                  return local;
+                                              });
+                onDone.success();
             }
-
-            public void apply(Command command)
+            catch (Throwable t)
             {
-                TxnId txnId = command.txnId();
+                onDone.failure(t);
+            }
+        }
+
+        @Override
+        public void apply(Command command, Journal.OnDone onDone)
+        {
+            TxnId txnId = command.txnId();
 
+            try
+            {
                 PreLoadContext context = context(command, KeyHistory.TIMESTAMPS);
-                executeInContext(InMemoryCommandStore.this,
-                                 context,
-                                 safeStore -> {
-                                     SafeCommand safeCommand = safeStore.unsafeGet(txnId);
-                                     Command local = safeCommand.current();
-                                     if (local.is(Stable) || local.is(PreApplied))
-                                     {
-                                         Commands.maybeExecute(safeStore, safeCommand, local, true, true);
-                                     }
-                                     else if (local.saveStatus().compareTo(Applying) >= 0 && !local.hasBeen(Truncated))
-                                     {
-                                         unsafeApplyWrites(safeStore, safeCommand, local);
-                                     }
-                                     return null;
-                                 });
+                commandStore.executeInContext(commandStore,
+                                              context,
+                                              safeStore -> {
+                                                  SafeCommand safeCommand = safeStore.unsafeGet(txnId);
+                                                  Command local = safeCommand.current();
+                                                  if (local.is(Stable) || local.is(PreApplied))
+                                                  {
+                                                      Commands.maybeExecute(safeStore, safeCommand, local, true, true);
+                                                  }
+                                                  else if (local.saveStatus().compareTo(Applying) >= 0 && !local.hasBeen(Truncated))
+                                                  {
+                                                      unsafeApplyWrites(safeStore, safeCommand, local);
+                                                  }
+                                                  return null;
+                                              });
+                onDone.success();
             }
-        };
+            catch (Throwable t)
+            {
+                onDone.failure(t);
+            }
+        }
     }
 
     public static void unsafeApplyWrites(SafeCommandStore safeStore, SafeCommand safeCommand, Command command)
diff --git a/accord-core/src/main/java/accord/local/CommandStore.java b/accord-core/src/main/java/accord/local/CommandStore.java
index 6fb4ae04..f7eb397b 100644
--- a/accord-core/src/main/java/accord/local/CommandStore.java
+++ b/accord-core/src/main/java/accord/local/CommandStore.java
@@ -18,6 +18,7 @@
 
 package accord.local;
 
+import accord.api.Journal;
 import accord.api.LocalListeners;
 import accord.api.ProgressLog;
 import accord.api.DataStore;
@@ -207,6 +208,8 @@ public abstract class CommandStore implements AgentExecutor
         return id;
     }
 
+    public abstract Journal.Loader loader();
+
     @Override
     public Agent agent()
     {
diff --git a/accord-core/src/main/java/accord/messages/ReadEphemeralTxnData.java b/accord-core/src/main/java/accord/messages/ReadEphemeralTxnData.java
index e86a1805..1ee926df 100644
--- a/accord-core/src/main/java/accord/messages/ReadEphemeralTxnData.java
+++ b/accord-core/src/main/java/accord/messages/ReadEphemeralTxnData.java
@@ -75,7 +75,8 @@ public class ReadEphemeralTxnData extends ReadData
     private ReadEphemeralTxnData(TxnId txnId, Participants<?> readScope, Route<?> scope, long executeAtEpoch, @Nonnull Txn txn, @Nonnull Deps deps, @Nonnull FullRoute<?> route)
     {
         super(txnId, readScope.intersecting(scope), executeAtEpoch);
-        Invariants.checkState(executeAtEpoch == txnId.epoch());
+        Invariants.checkState(executeAtEpoch == txnId.epoch(),
+                              "Epoch for transaction %s (%d) did not match expected %d", txn, txnId.epoch(), executeAtEpoch);
         this.route = route;
         this.partialTxn = txn.intersecting(scope, false);
         this.partialDeps = deps.intersecting(scope);
diff --git a/accord-core/src/test/java/accord/burn/BurnTest.java b/accord-core/src/test/java/accord/burn/BurnTest.java
index bfbb7c7b..740b705d 100644
--- a/accord-core/src/test/java/accord/burn/BurnTest.java
+++ b/accord-core/src/test/java/accord/burn/BurnTest.java
@@ -52,6 +52,7 @@ import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import accord.api.Journal;
 import accord.api.Key;
 import accord.burn.random.FrequentLargeRange;
 import accord.impl.MessageListener;
@@ -59,6 +60,7 @@ import accord.impl.PrefixedIntHashKey;
 import accord.impl.TopologyFactory;
 import accord.impl.basic.Cluster;
 import accord.impl.basic.Cluster.Stats;
+import accord.impl.basic.InMemoryJournal;
 import accord.impl.basic.Packet;
 import accord.impl.basic.PendingQueue;
 import accord.impl.basic.PendingRunnable;
@@ -295,14 +297,14 @@ public class BurnTest
         random2.setSeed(seed);
         ExecutorService exec = Executors.newFixedThreadPool(2);
         RandomDelayQueue.ReconcilingQueueFactory factory = new RandomDelayQueue.ReconcilingQueueFactory(seed);
-        Future<?> f1 = exec.submit(() -> burn(random1, topologyFactory, clients, nodes, keyCount, operations, concurrency, factory.get(true)));
-        Future<?> f2 = exec.submit(() -> burn(random2, topologyFactory, clients, nodes, keyCount, operations, concurrency, factory.get(false)));
+        Future<?> f1 = exec.submit(() -> burn(random1, topologyFactory, clients, nodes, keyCount, operations, concurrency, factory.get(true), InMemoryJournal::new));
+        Future<?> f2 = exec.submit(() -> burn(random2, topologyFactory, clients, nodes, keyCount, operations, concurrency, factory.get(false), InMemoryJournal::new));
         exec.shutdown();
         f1.get();
         f2.get();
     }
 
-    static void burn(RandomSource random, TopologyFactory topologyFactory, List<Id> clients, List<Id> nodes, int keyCount, int operations, int concurrency, PendingQueue pendingQueue)
+    static void burn(RandomSource random, TopologyFactory topologyFactory, List<Id> clients, List<Id> nodes, int keyCount, int operations, int concurrency, PendingQueue pendingQueue, Function<Id, Journal> journalFactory)
     {
         List<Throwable> failures = Collections.synchronizedList(new ArrayList<>());
         AtomicLong progress = new AtomicLong();
@@ -462,8 +464,8 @@ public class BurnTest
                                           responseSink, random::fork, nowSupplier,
                                           topologyFactory, initialRequests::poll,
                                           onSubmitted::set,
-                                          ignore -> {}
-            );
+                                          ignore -> {},
+                                          journalFactory);
             for (Verifier verifier : validators.values())
                 verifier.close();
         }
@@ -622,12 +624,13 @@ public class BurnTest
             List<Id> nodes = generateIds(false, random.nextInt(rf, rf * 3));
 
             burn(random, new TopologyFactory(rf, ranges(0, HASH_RANGE_START, HASH_RANGE_END, random.nextInt(Math.max(nodes.size() + 1, rf), nodes.size() * 3))),
-                    clients,
-                    nodes,
-                    5 + random.nextInt(15),
-                    operations,
-                    10 + random.nextInt(30),
-                 new Factory(random).get());
+                 clients,
+                 nodes,
+                 5 + random.nextInt(15),
+                 operations,
+                 10 + random.nextInt(30),
+                 new Factory(random).get(),
+                 InMemoryJournal::new);
         }
         catch (Throwable t)
         {
diff --git a/accord-core/src/test/java/accord/coordinate/CoordinateTransactionTest.java b/accord-core/src/test/java/accord/coordinate/CoordinateTransactionTest.java
index 0688fa5a..dc8b553a 100644
--- a/accord-core/src/test/java/accord/coordinate/CoordinateTransactionTest.java
+++ b/accord-core/src/test/java/accord/coordinate/CoordinateTransactionTest.java
@@ -18,6 +18,7 @@
 
 package accord.coordinate;
 
+import java.time.Duration;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
@@ -67,7 +68,6 @@ import accord.utils.async.AsyncResult;
 import static accord.Utils.id;
 import static accord.Utils.ids;
 import static accord.Utils.ranges;
-import static accord.Utils.spinUntilSuccess;
 import static accord.Utils.writeTxn;
 import static accord.impl.IntKey.key;
 import static accord.impl.IntKey.keys;
@@ -87,6 +87,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
+import org.awaitility.Awaitility;
+import org.awaitility.core.ThrowingRunnable;
 
 public class CoordinateTransactionTest
 {
@@ -416,4 +418,19 @@ public class CoordinateTransactionTest
     {
         return keys.toRoute(keys.get(0).toUnseekable());
     }
+
+    public static void spinUntilSuccess(ThrowingRunnable runnable)
+    {
+        spinUntilSuccess(runnable, 10);
+    }
+
+    public static void spinUntilSuccess(ThrowingRunnable runnable, int timeoutInSeconds)
+    {
+        Awaitility.await()
+                  .pollInterval(Duration.ofMillis(100))
+                  .pollDelay(0, TimeUnit.MILLISECONDS)
+                  .atMost(timeoutInSeconds, TimeUnit.SECONDS)
+                  .ignoreExceptions()
+                  .untilAsserted(runnable);
+    }
 }
diff --git a/accord-core/src/test/java/accord/impl/RemoteListenersTest.java b/accord-core/src/test/java/accord/impl/RemoteListenersTest.java
index 7f1f81b8..9ea735c4 100644
--- a/accord-core/src/test/java/accord/impl/RemoteListenersTest.java
+++ b/accord-core/src/test/java/accord/impl/RemoteListenersTest.java
@@ -38,6 +38,7 @@ import org.junit.jupiter.api.Test;
 
 import accord.api.Agent;
 import accord.api.DataStore;
+import accord.api.Journal;
 import accord.api.ProgressLog;
 import accord.api.RemoteListeners;
 import accord.api.RemoteListeners.Registration;
@@ -394,6 +395,12 @@ public class RemoteListenersTest
             this.storeId = id;
         }
 
+        @Override
+        public Journal.Loader loader()
+        {
+            throw new UnsupportedOperationException();
+        }
+
         @Override public boolean inStore() { return false; }
         @Override public AsyncChain<Void> execute(PreLoadContext context, Consumer<? super SafeCommandStore> consumer) { return null; }
         @Override public <T> AsyncChain<T> submit(PreLoadContext context, Function<? super SafeCommandStore, T> apply) { return null; }
diff --git a/accord-core/src/test/java/accord/local/cfk/CommandsForKeyTest.java b/accord-core/src/test/java/accord/local/cfk/CommandsForKeyTest.java
index 50b2b97c..1123ab73 100644
--- a/accord-core/src/test/java/accord/local/cfk/CommandsForKeyTest.java
+++ b/accord-core/src/test/java/accord/local/cfk/CommandsForKeyTest.java
@@ -39,6 +39,7 @@ import org.slf4j.LoggerFactory;
 import accord.api.Agent;
 import accord.api.Data;
 import accord.api.DataStore;
+import accord.api.Journal;
 import accord.api.ProgressLog;
 import accord.api.ProgressLog.BlockedUntil;
 import accord.api.Query;
@@ -949,6 +950,11 @@ public class CommandsForKeyTest
             return true;
         }
 
+        public Journal.Loader loader()
+        {
+            throw new UnsupportedOperationException();
+        }
+
         @Override
         public Agent agent()
         {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


(cassandra-accord) 05/05: Fix timestamp ordering with relation to ordered bytes

Posted by if...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ifesdjeen pushed a commit to branch semi-integrated-burn-test-rebased
in repository https://gitbox.apache.org/repos/asf/cassandra-accord.git

commit 68ab3c0ce18dac733eef3a39f2ea11b5dde9c358
Author: Alex Petrov <ol...@gmail.com>
AuthorDate: Mon Nov 18 16:39:08 2024 +0100

    Fix timestamp ordering with relation to ordered bytes
---
 accord-core/src/main/java/accord/local/Node.java           | 4 +++-
 accord-core/src/main/java/accord/primitives/Timestamp.java | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/accord-core/src/main/java/accord/local/Node.java b/accord-core/src/main/java/accord/local/Node.java
index a213c112..38939974 100644
--- a/accord-core/src/main/java/accord/local/Node.java
+++ b/accord-core/src/main/java/accord/local/Node.java
@@ -671,7 +671,9 @@ public class Node implements ConfigurationService.Listener, NodeCommandStoreServ
      */
     public TxnId nextTxnId(Txn.Kind rw, Domain domain)
     {
-        return new TxnId(uniqueNow(), rw, domain);
+        TxnId txnId = new TxnId(uniqueNow(), rw, domain);
+        Invariants.checkState((txnId.lsb & (0xffff & ~TxnId.IDENTITY_FLAGS)) == 0);
+        return txnId;
     }
 
     public AsyncResult<Result> coordinate(Txn txn)
diff --git a/accord-core/src/main/java/accord/primitives/Timestamp.java b/accord-core/src/main/java/accord/primitives/Timestamp.java
index 0a9de552..f488ab8b 100644
--- a/accord-core/src/main/java/accord/primitives/Timestamp.java
+++ b/accord-core/src/main/java/accord/primitives/Timestamp.java
@@ -38,8 +38,8 @@ public class Timestamp implements Comparable<Timestamp>, EpochSupplier
      */
     private static final int MERGE_FLAGS = 0x8000;
     // TODO (testing): is this the correct set of identity bits?
-    private static final long IDENTITY_LSB = 0xFFFFFFFFFFFF001EL;
-    public static final int IDENTITY_FLAGS = 0x001E;
+    private static final long IDENTITY_LSB = 0xFFFFFFFF_FFFF001FL;
+    public static final int IDENTITY_FLAGS = 0x00000000_0000001F;
     public static final long MAX_EPOCH = (1L << 48) - 1;
     private static final long HLC_INCR = 1L << 16;
     static final long MAX_FLAGS = HLC_INCR - 1;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


(cassandra-accord) 01/05: Investigate mixup failures

Posted by if...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ifesdjeen pushed a commit to branch semi-integrated-burn-test-rebased
in repository https://gitbox.apache.org/repos/asf/cassandra-accord.git

commit b0ec1c4ab073600b2c749cbc0c1ad38369547fd5
Author: Benedict Elliott Smith <be...@apache.org>
AuthorDate: Tue Nov 12 13:04:37 2024 +0000

    Investigate mixup failures
---
 .../src/main/java/accord/api/ProgressLog.java      |   1 +
 .../accord/coordinate/CoordinateEphemeralRead.java |   2 +-
 .../accord/coordinate/CoordinateSyncPoint.java     |   2 +-
 .../accord/coordinate/CoordinationAdapter.java     |  18 +-
 .../java/accord/coordinate/FetchMaxConflict.java   |   2 +-
 .../src/main/java/accord/coordinate/Infer.java     |   4 +-
 .../src/main/java/accord/coordinate/Persist.java   |  15 +-
 .../java/accord/coordinate/PersistSyncPoint.java   |   4 +-
 .../main/java/accord/coordinate/PersistTxn.java    |   6 +-
 .../java/accord/coordinate/RecoverWithRoute.java   |   2 +-
 .../coordinate/tracking/FastPathTracker.java       | 113 ++++----
 .../java/accord/impl/AbstractSafeCommandStore.java |   4 +-
 .../java/accord/impl/DefaultLocalListeners.java    |   2 +-
 .../java/accord/impl/DurabilityScheduling.java     |   2 +-
 .../java/accord/impl/InMemoryCommandStore.java     |  20 +-
 .../java/accord/impl/progresslog/BaseTxnState.java |  15 +-
 .../impl/progresslog/DefaultProgressLog.java       |   4 +
 .../impl/progresslog/DefaultProgressLogs.java      |   2 +-
 .../java/accord/impl/progresslog/HomeState.java    |   8 +-
 .../java/accord/impl/progresslog/TxnState.java     |   5 +
 .../java/accord/impl/progresslog/WaitingState.java |   4 +-
 .../src/main/java/accord/local/Bootstrap.java      |   4 +-
 .../src/main/java/accord/local/Cleanup.java        |  26 +-
 .../src/main/java/accord/local/CommandStore.java   |   5 +-
 .../src/main/java/accord/local/Commands.java       |  13 +-
 .../src/main/java/accord/local/PreLoadContext.java |   7 +
 .../main/java/accord/local/RedundantBefore.java    |  37 ++-
 .../main/java/accord/local/RedundantStatus.java    |  37 +--
 .../main/java/accord/local/SafeCommandStore.java   |  24 +-
 .../main/java/accord/local/StoreParticipants.java  |   3 +-
 .../main/java/accord/local/cfk/CommandsForKey.java |  49 ++--
 .../src/main/java/accord/local/cfk/NotifySink.java |   2 +-
 .../main/java/accord/local/cfk/PostProcess.java    |  18 +-
 .../src/main/java/accord/local/cfk/Updating.java   |  65 ++---
 .../src/main/java/accord/messages/Apply.java       |  24 +-
 .../src/main/java/accord/messages/CheckStatus.java |   8 +-
 .../main/java/accord/messages/InformDurable.java   |   2 +
 .../src/main/java/accord/messages/PreAccept.java   |   3 +
 .../src/main/java/accord/messages/Propagate.java   |   2 +-
 .../src/main/java/accord/messages/ReadData.java    |   8 +-
 .../java/accord/primitives/AbstractRanges.java     |  25 +-
 .../src/main/java/accord/primitives/KeyRoute.java  |  31 +++
 .../src/main/java/accord/primitives/Keys.java      |  11 +-
 .../src/main/java/accord/primitives/Known.java     |   6 +-
 .../main/java/accord/primitives/LatestDeps.java    |   1 -
 .../src/main/java/accord/primitives/RangeDeps.java |   2 +-
 .../main/java/accord/primitives/RangeRoute.java    |  19 ++
 .../src/main/java/accord/primitives/Ranges.java    |  15 ++
 .../src/main/java/accord/primitives/Route.java     |   2 +
 .../main/java/accord/primitives/RoutingKeys.java   |   4 +
 .../src/main/java/accord/primitives/Timestamp.java |   2 +-
 .../src/main/java/accord/primitives/Txn.java       |  12 +-
 .../main/java/accord/topology/TopologyManager.java |   2 +-
 .../src/main/java/accord/utils/SortedArrays.java   |  10 +-
 .../java/accord/utils/ThreadPoolScheduler.java     |   2 +-
 .../src/main/java/accord/utils/Timestamped.java    |   5 +
 accord-core/src/test/java/accord/KeysTest.java     |  58 +++++
 .../src/test/java/accord/burn/BurnTest.java        |   2 +-
 .../tracking/FastPathTrackerReconciler.java        |   5 +-
 .../coordinate/tracking/ReadTrackerReconciler.java |   1 +
 .../coordinate/tracking/ReadTrackerTest.java       |   1 +
 .../test/java/accord/impl/RemoteListenersTest.java |   2 +-
 .../src/test/java/accord/impl/basic/Cluster.java   | 283 +++++++++++++++------
 .../accord/impl/basic/DelayedCommandStores.java    |  43 +---
 .../src/test/java/accord/impl/basic/Journal.java   | 167 ++++++++----
 .../src/test/java/accord/impl/basic/NodeSink.java  |  16 +-
 .../src/test/java/accord/impl/basic/Packet.java    |   7 +
 .../src/test/java/accord/impl/basic/Pending.java   |  22 ++
 .../java/accord/impl/basic/PendingRunnable.java    |  18 ++
 .../java/accord/impl/basic/RandomDelayQueue.java   |   8 +-
 .../impl/basic/RecurringPendingRunnable.java       |  16 +-
 .../accord/impl/basic/TaskExecutorService.java     |   6 +
 .../src/test/java/accord/impl/list/ListAgent.java  |   4 +-
 .../accord/impl/list/ListFetchCoordinator.java     |   2 +-
 .../test/java/accord/impl/list/ListRequest.java    |  10 +-
 .../src/test/java/accord/impl/list/ListResult.java |   2 +-
 .../src/test/java/accord/impl/list/ListStore.java  |  90 +++++--
 .../test/java/accord/impl/mock/MockCluster.java    |   6 +-
 .../src/test/java/accord/local/CommandsTest.java   |   5 +-
 .../java/accord/local/ImmutableCommandTest.java    |  26 +-
 .../java/accord/local/cfk/CommandsForKeyTest.java  |   4 +-
 .../test/java/accord/messages/PreAcceptTest.java   |   2 +-
 .../test/java/accord/messages/ReadDataTest.java    |   5 +-
 .../java/accord/primitives/AbstractRangesTest.java |   6 +
 .../test/java/accord/primitives/RangeDepsTest.java |   4 +-
 .../java/accord/topology/TopologyRandomizer.java   |   3 +-
 .../src/test/java/accord/utils/AccordGens.java     |   1 -
 .../test/java/accord/utils/LogGroupTimersTest.java |   3 +-
 .../verify/StrictSerializabilityVerifier.java      |   2 +-
 89 files changed, 1034 insertions(+), 517 deletions(-)

diff --git a/accord-core/src/main/java/accord/api/ProgressLog.java b/accord-core/src/main/java/accord/api/ProgressLog.java
index 3f1263cb..cb4cf154 100644
--- a/accord-core/src/main/java/accord/api/ProgressLog.java
+++ b/accord-core/src/main/java/accord/api/ProgressLog.java
@@ -26,6 +26,7 @@ import accord.local.Node;
 import accord.local.SafeCommand;
 import accord.local.SafeCommandStore;
 import accord.primitives.SaveStatus;
+import accord.primitives.Status;
 import accord.primitives.Status.Durability;
 import accord.primitives.Participants;
 import accord.primitives.Route;
diff --git a/accord-core/src/main/java/accord/coordinate/CoordinateEphemeralRead.java b/accord-core/src/main/java/accord/coordinate/CoordinateEphemeralRead.java
index ab571c70..565b3905 100644
--- a/accord-core/src/main/java/accord/coordinate/CoordinateEphemeralRead.java
+++ b/accord-core/src/main/java/accord/coordinate/CoordinateEphemeralRead.java
@@ -136,6 +136,6 @@ public class CoordinateEphemeralRead extends AbstractCoordinatePreAccept<Result,
     {
         Deps deps = Deps.merge(oks, oks.domainSize(), SortedListMap::getValue, ok -> ok.deps);
         topologies = node.topology().reselect(topologies, QuorumEpochIntersections.preaccept.include, route, executeAtEpoch, executeAtEpoch, Owned);
-        new ExecuteEphemeralRead(node, topologies, route, txnId, txn, executeAtEpoch, deps, this).start();
+        new ExecuteEphemeralRead(node, topologies, route, txnId.withEpoch(executeAtEpoch), txn, executeAtEpoch, deps, this).start();
     }
 }
diff --git a/accord-core/src/main/java/accord/coordinate/CoordinateSyncPoint.java b/accord-core/src/main/java/accord/coordinate/CoordinateSyncPoint.java
index 6f271cec..69b4d943 100644
--- a/accord-core/src/main/java/accord/coordinate/CoordinateSyncPoint.java
+++ b/accord-core/src/main/java/accord/coordinate/CoordinateSyncPoint.java
@@ -177,6 +177,6 @@ public class CoordinateSyncPoint<U extends Unseekable> extends CoordinatePreAcce
         Timestamp executeAt = txnId;
         Txn txn = node.agent().emptySystemTxn(txnId.kind(), txnId.domain());
         Deps deps = syncPoint.waitFor;
-        Apply.sendMaximal(node, to, txnId, syncPoint.route(), txn, executeAt, deps, txn.execute(txnId, executeAt, null), txn.result(txnId, executeAt, null));
+        Apply.sendMaximal(node, to, txnId, syncPoint.route(), txn, executeAt, deps, txn.execute(txnId, executeAt, null), txn.result(txnId, executeAt, null), syncPoint.route());
     }
 }
diff --git a/accord-core/src/main/java/accord/coordinate/CoordinationAdapter.java b/accord-core/src/main/java/accord/coordinate/CoordinationAdapter.java
index 3c52d0a2..66d61cba 100644
--- a/accord-core/src/main/java/accord/coordinate/CoordinationAdapter.java
+++ b/accord-core/src/main/java/accord/coordinate/CoordinationAdapter.java
@@ -34,6 +34,7 @@ import accord.primitives.Ballot;
 import accord.primitives.Deps;
 import accord.primitives.FullRoute;
 import accord.primitives.Participants;
+import accord.primitives.Route;
 import accord.primitives.SyncPoint;
 import accord.primitives.Timestamp;
 import accord.primitives.Txn;
@@ -59,7 +60,7 @@ public interface CoordinationAdapter<R>
     void propose(Node node, @Nullable Topologies preaccept, FullRoute<?> route, Ballot ballot, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, BiConsumer<? super R, Throwable> callback);
     void stabilise(Node node, @Nullable Topologies any, FullRoute<?> route, Ballot ballot, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, BiConsumer<? super R, Throwable> callback);
     void execute(Node node, @Nullable Topologies any, FullRoute<?> route, ExecutePath path, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, BiConsumer<? super R, Throwable> callback);
-    void persist(Node node, @Nullable Topologies any, FullRoute<?> route, Participants<?> sendTo, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, BiConsumer<? super R, Throwable> callback);
+    void persist(Node node, @Nullable Topologies any, FullRoute<?> route, Route<?> sendTo, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, BiConsumer<? super R, Throwable> callback);
     default void persist(Node node, @Nullable Topologies any, FullRoute<?> route, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, BiConsumer<? super R, Throwable> callback)
     {
         persist(node, any, route, route, txnId, txn, executeAt, deps, writes, result, callback);
@@ -159,13 +160,12 @@ public interface CoordinationAdapter<R>
             public static final StandardTxnAdapter INSTANCE = new StandardTxnAdapter();
 
             @Override
-            public void persist(Node node, Topologies any, FullRoute<?> route, Participants<?> sendTo, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, BiConsumer<? super Result, Throwable> callback)
+            public void persist(Node node, Topologies any, FullRoute<?> route, Route<?> sendTo, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, BiConsumer<? super Result, Throwable> callback)
             {
-                // TODO (required): we aren't using sendTo
                 Topologies all = execution(node, any, sendTo, txnId, executeAt);
 
                 if (callback != null) callback.accept(result, null);
-                new PersistTxn(node, all, txnId, route, txn, executeAt, deps, writes, result)
+                new PersistTxn(node, all, txnId, sendTo, txn, executeAt, deps, writes, result, route)
                     .start(Apply.FACTORY, Minimal, all, writes, result);
             }
         }
@@ -174,12 +174,12 @@ public interface CoordinationAdapter<R>
         {
             public static final RecoveryTxnAdapter INSTANCE = new RecoveryTxnAdapter();
             @Override
-            public void persist(Node node, Topologies any, FullRoute<?> route, Participants<?> participants, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, BiConsumer<? super Result, Throwable> callback)
+            public void persist(Node node, Topologies any, FullRoute<?> route, Route<?> sendTo, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, BiConsumer<? super Result, Throwable> callback)
             {
-                Topologies all = execution(node, any, participants, txnId, executeAt);
+                Topologies all = execution(node, any, sendTo, txnId, executeAt);
 
                 if (callback != null) callback.accept(result, null);
-                new PersistTxn(node, all, txnId, route, txn, executeAt, deps, writes, result)
+                new PersistTxn(node, all, txnId, sendTo, txn, executeAt, deps, writes, result, route)
                     .start(Apply.FACTORY, Maximal, all, writes, result);
             }
         }
@@ -224,7 +224,7 @@ public interface CoordinationAdapter<R>
             }
 
             @Override
-            public void persist(Node node, Topologies any, FullRoute<?> route, Participants<?> participants, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, BiConsumer<? super SyncPoint<U>, Throwable> callback)
+            public void persist(Node node, Topologies any, FullRoute<?> route, Route<?> participants, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, BiConsumer<? super SyncPoint<U>, Throwable> callback)
             {
                 Topologies all = forExecution(node, route, txnId, executeAt, deps);
 
@@ -335,7 +335,7 @@ public interface CoordinationAdapter<R>
             }
 
             @Override
-            public void persist(Node node, Topologies any, FullRoute<?> route, Participants<?> participants, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, BiConsumer<? super SyncPoint<U>, Throwable> callback)
+            public void persist(Node node, Topologies any, FullRoute<?> route, Route<?> participants, TxnId txnId, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, BiConsumer<? super SyncPoint<U>, Throwable> callback)
             {
                 throw new UnsupportedOperationException();
             }
diff --git a/accord-core/src/main/java/accord/coordinate/FetchMaxConflict.java b/accord-core/src/main/java/accord/coordinate/FetchMaxConflict.java
index 9fe651e1..b2038f2a 100644
--- a/accord-core/src/main/java/accord/coordinate/FetchMaxConflict.java
+++ b/accord-core/src/main/java/accord/coordinate/FetchMaxConflict.java
@@ -39,7 +39,7 @@ import static accord.coordinate.tracking.RequestStatus.Success;
  * Perform initial rounds of PreAccept and Accept until we have reached agreement about when we should execute.
  * If we are preempted by a recovery coordinator, we abort and let them complete (and notify us about the execution result)
  *
- * TODO (desired, testing): dedicated burn test to validate outcomes
+ * TODO (expected): we don't need this anymore, we can just use the local MaxConflicts collection when creating a snapshot for streaming
  */
 public class FetchMaxConflict extends AbstractCoordinatePreAccept<Timestamp, GetMaxConflictOk>
 {
diff --git a/accord-core/src/main/java/accord/coordinate/Infer.java b/accord-core/src/main/java/accord/coordinate/Infer.java
index 787e45a7..81c935f5 100644
--- a/accord-core/src/main/java/accord/coordinate/Infer.java
+++ b/accord-core/src/main/java/accord/coordinate/Infer.java
@@ -41,7 +41,7 @@ import static accord.primitives.Status.PreCommitted;
 import static accord.primitives.Route.castToRoute;
 import static accord.primitives.Route.isRoute;
 
-// TODO (required): dedicated randomised testing of all inferences
+// TODO (testing): dedicated randomised testing of all inferences
 public class Infer
 {
     public enum InvalidIf
@@ -73,7 +73,7 @@ public class Infer
 
         public boolean inferInvalidWithQuorum(Known known)
         {
-            return this == IfUncommitted && !known.isDecided();
+            return this == IfUncommitted && (!known.isDecided() || !known.definition.isOrWasKnown());
         }
     }
 
diff --git a/accord-core/src/main/java/accord/coordinate/Persist.java b/accord-core/src/main/java/accord/coordinate/Persist.java
index 042cb228..1082f631 100644
--- a/accord-core/src/main/java/accord/coordinate/Persist.java
+++ b/accord-core/src/main/java/accord/coordinate/Persist.java
@@ -31,6 +31,7 @@ import accord.messages.Callback;
 import accord.messages.InformDurable;
 import accord.primitives.Deps;
 import accord.primitives.FullRoute;
+import accord.primitives.Route;
 import accord.primitives.Timestamp;
 import accord.primitives.Txn;
 import accord.primitives.TxnId;
@@ -46,27 +47,29 @@ public abstract class Persist implements Callback<ApplyReply>
 {
     protected final Node node;
     protected final TxnId txnId;
-    protected final FullRoute<?> route;
+    protected final Route<?> sendTo;
     protected final Txn txn;
     protected final Timestamp executeAt;
     protected final Deps stableDeps;
     protected final Writes writes;
     protected final Result result;
+    protected final FullRoute<?> route;
     protected final Topologies topologies;
     protected final QuorumTracker tracker;
     protected final Set<Id> persistedOn;
     boolean isDone;
 
-    protected Persist(Node node, Topologies all, TxnId txnId, FullRoute<?> route, Txn txn, Timestamp executeAt, Deps stableDeps, Writes writes, Result result)
+    protected Persist(Node node, Topologies all, TxnId txnId, Route<?> sendTo, Txn txn, Timestamp executeAt, Deps stableDeps, Writes writes, Result result, FullRoute<?> route)
     {
         this.node = node;
         this.txnId = txnId;
-        this.route = route;
+        this.sendTo = sendTo;
         this.txn = txn;
         this.executeAt = executeAt;
         this.stableDeps = stableDeps;
         this.writes = writes;
         this.result = result;
+        this.route = route;
         this.topologies = all;
         this.tracker = new QuorumTracker(all);
         this.persistedOn = new HashSet<>();
@@ -81,7 +84,7 @@ public abstract class Persist implements Callback<ApplyReply>
             case Redundant:
             case Applied:
                 persistedOn.add(from);
-                if (tracker.recordSuccess(from) == Success)
+                if (sendTo == route && tracker.recordSuccess(from) == Success)
                 {
                     if (!isDone)
                     {
@@ -96,7 +99,7 @@ public abstract class Persist implements Callback<ApplyReply>
                 }
                 break;
             case Insufficient:
-                Apply.sendMaximal(node, from, txnId, route, txn, executeAt, stableDeps, writes, result);
+                Apply.sendMaximal(node, from, txnId, route, txn, executeAt, stableDeps, writes, result, route);
         }
     }
 
@@ -124,7 +127,7 @@ public abstract class Persist implements Callback<ApplyReply>
         }
         else
         {
-            node.send(contact, to -> factory.create(kind, to, all, txnId, route, txn, executeAt, stableDeps, writes, result), this);
+            node.send(contact, to -> factory.create(kind, to, all, txnId, sendTo, txn, executeAt, stableDeps, writes, result, route), this);
         }
     }
 }
diff --git a/accord-core/src/main/java/accord/coordinate/PersistSyncPoint.java b/accord-core/src/main/java/accord/coordinate/PersistSyncPoint.java
index f0be6f96..2eec31b6 100644
--- a/accord-core/src/main/java/accord/coordinate/PersistSyncPoint.java
+++ b/accord-core/src/main/java/accord/coordinate/PersistSyncPoint.java
@@ -34,7 +34,7 @@ public class PersistSyncPoint extends Persist
 {
     public PersistSyncPoint(Node node, Topologies topologies, TxnId txnId, FullRoute<?> route, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result)
     {
-        super(node, topologies, txnId, route, txn, executeAt, deps, writes, result);
+        super(node, topologies, txnId, route, txn, executeAt, deps, writes, result, route);
     }
 
     @Override
@@ -50,7 +50,7 @@ public class PersistSyncPoint extends Persist
         {
             for (Node.Id to : contact)
             {
-                Apply apply = factory.create(kind, to, all, txnId, route, txn, executeAt, stableDeps, writes, result);
+                Apply apply = factory.create(kind, to, all, txnId, route, txn, executeAt, stableDeps, writes, result, route);
                 if (apply == null)
                     tracker.recordSuccess(to);
                 else
diff --git a/accord-core/src/main/java/accord/coordinate/PersistTxn.java b/accord-core/src/main/java/accord/coordinate/PersistTxn.java
index b2db464c..c9139f01 100644
--- a/accord-core/src/main/java/accord/coordinate/PersistTxn.java
+++ b/accord-core/src/main/java/accord/coordinate/PersistTxn.java
@@ -22,6 +22,8 @@ import accord.api.Result;
 import accord.local.Node;
 import accord.primitives.Deps;
 import accord.primitives.FullRoute;
+import accord.primitives.Participants;
+import accord.primitives.Route;
 import accord.primitives.Timestamp;
 import accord.primitives.Txn;
 import accord.primitives.TxnId;
@@ -30,8 +32,8 @@ import accord.topology.Topologies;
 
 public class PersistTxn extends Persist
 {
-    public PersistTxn(Node node, Topologies topologies, TxnId txnId, FullRoute<?> route, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result)
+    public PersistTxn(Node node, Topologies topologies, TxnId txnId, Route<?> sendTo, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, FullRoute<?> route)
     {
-        super(node, topologies, txnId, route, txn, executeAt, deps, writes, result);
+        super(node, topologies, txnId, sendTo, txn, executeAt, deps, writes, result, route);
     }
 }
diff --git a/accord-core/src/main/java/accord/coordinate/RecoverWithRoute.java b/accord-core/src/main/java/accord/coordinate/RecoverWithRoute.java
index c8fae845..5647a41c 100644
--- a/accord-core/src/main/java/accord/coordinate/RecoverWithRoute.java
+++ b/accord-core/src/main/java/accord/coordinate/RecoverWithRoute.java
@@ -177,7 +177,7 @@ public class RecoverWithRoute extends CheckShards<FullRoute<?>>
                     {
                         // we might have only part of the full transaction, and a shard may have truncated;
                         // in this case we want to skip straight to apply, but only for the shards that haven't truncated
-                        Participants<?> sendTo = route.participants().without(full.truncatedResponse());
+                        Route<?> sendTo = route.without(full.truncatedResponse());
                         if (!sendTo.isEmpty())
                         {
                             known = full.knownFor(txnId, sendTo, sendTo);
diff --git a/accord-core/src/main/java/accord/coordinate/tracking/FastPathTracker.java b/accord-core/src/main/java/accord/coordinate/tracking/FastPathTracker.java
index d42e198a..d02d8bb6 100644
--- a/accord-core/src/main/java/accord/coordinate/tracking/FastPathTracker.java
+++ b/accord-core/src/main/java/accord/coordinate/tracking/FastPathTracker.java
@@ -22,6 +22,8 @@ import accord.coordinate.tracking.QuorumTracker.QuorumShardTracker;
 import accord.local.Node;
 import accord.topology.Shard;
 import accord.topology.Topologies;
+import accord.utils.Invariants;
+
 import com.google.common.annotations.VisibleForTesting;
 
 import javax.annotation.Nonnull;
@@ -43,6 +45,7 @@ public class FastPathTracker extends PreAcceptTracker<FastPathTracker.FastPathSh
         protected int fastPathAccepts;
         protected int fastPathFailures;
         protected int fastPathDelayed;
+        protected boolean complete;
 
         public FastPathShardTracker(Shard shard)
         {
@@ -51,19 +54,43 @@ public class FastPathTracker extends PreAcceptTracker<FastPathTracker.FastPathSh
 
         // return NewQuorumSuccess ONLY once fast path is rejected
         public abstract ShardOutcome<? super FastPathTracker> onQuorumSuccess(Node.Id node);
-        public abstract ShardOutcome<? super FastPathTracker> onMaybeFastPathSuccess(Node.Id node);
+        final ShardOutcome<? super FastPathTracker> complete(ShardOutcome<? super FastPathTracker> result)
+        {
+            Invariants.checkState(!complete);
+            complete = true;
+            return result;
+        }
+
+        public ShardOutcome<? super FastPathTracker> onMaybeFastPathSuccess(Node.Id node)
+        {
+            if (complete)
+                return NoChange;
+
+            ++successes;
+            if (shard.fastPathElectorate.contains(node))
+            {
+                ++fastPathAccepts;
+                if (hasMetFastPathCriteria())
+                    return complete(NewFastPathSuccess);
+            }
+
+            return quorumIfHasRejectedFastPath();
+        }
 
         public final ShardOutcome<? super FastPathTracker> onFailure(@Nonnull Node.Id from)
         {
+            if (complete)
+                return NoChange;
+
             if (++failures > shard.maxFailures)
-                return Fail;
+                return complete(Fail);
 
             if (shard.fastPathElectorate.contains(from))
             {
                 ++fastPathFailures;
 
-                if (isNewFastPathReject() && hasReachedQuorum())
-                    return Success;
+                if (hasRejectedFastPath() && hasReachedQuorum())
+                    return complete(Success);
             }
 
             return NoChange;
@@ -71,40 +98,28 @@ public class FastPathTracker extends PreAcceptTracker<FastPathTracker.FastPathSh
 
         public final ShardOutcome<? super FastPathTracker> onDelayed(@Nonnull Node.Id from)
         {
+            if (complete)
+                return NoChange;
+
             if (shard.fastPathElectorate.contains(from))
             {
                 ++fastPathDelayed;
 
-                if (isNewFastPathDelayed() && hasReachedQuorum())
-                    return Success;
+                if (isFastPathDelayed() && hasReachedQuorum())
+                    return complete(Success);
             }
 
             return NoChange;
         }
 
-        final ShardOutcome<? super FastPathTracker> quorumIfNewAndHasRejectedFastPath()
-        {
-            return isNewSlowPathSuccess() && hasRejectedFastPath() ? Success : NoChange;
-        }
-
-        final boolean isNewSlowPathSuccess()
-        {
-            return successes == shard.slowPathQuorumSize;
-        }
-
-        final boolean isNewFastPathReject()
+        final ShardOutcome<? super FastPathTracker> quorumIfHasRejectedFastPath()
         {
-            return fastPathFailures == shard.fastPathRejectSize && fastPathDelayed < shard.fastPathRejectSize;
+            return hasReachedQuorum() && hasRejectedFastPath() ? complete(Success) : NoChange;
         }
 
-        final boolean isNewFastPathDelayed()
+        final boolean isFastPathDelayed()
         {
-            return fastPathDelayed == shard.fastPathRejectSize && fastPathFailures < shard.fastPathRejectSize;
-        }
-
-        final boolean isNewFastPathSuccess()
-        {
-            return fastPathAccepts == shard.fastPathQuorumSize && (fastPathDelayed < shard.fastPathRejectSize || isNewSlowPathSuccess());
+            return fastPathDelayed >= shard.fastPathRejectSize;
         }
 
         @VisibleForTesting
@@ -116,7 +131,7 @@ public class FastPathTracker extends PreAcceptTracker<FastPathTracker.FastPathSh
         @VisibleForTesting
         public final boolean hasRejectedFastPath()
         {
-            return Math.max(fastPathFailures, fastPathDelayed) >= shard.fastPathRejectSize;
+            return fastPathFailures >= shard.fastPathRejectSize;
         }
     }
 
@@ -129,24 +144,7 @@ public class FastPathTracker extends PreAcceptTracker<FastPathTracker.FastPathSh
 
         public ShardOutcome<? super FastPathTracker> onQuorumSuccess(Node.Id node)
         {
-            ++successes;
-            if (!shard.fastPathElectorate.contains(node))
-                return quorumIfNewAndHasRejectedFastPath();
-
-            ++fastPathAccepts;
-            if (isNewFastPathSuccess())
-                return NewFastPathSuccess;
-
-            if (isNewSlowPathSuccess() && hasRejectedFastPath())
-                return Success;
-
-            return NoChange;
-        }
-
-        @Override
-        public ShardOutcome<? super FastPathTracker> onMaybeFastPathSuccess(Node.Id node)
-        {
-            return onQuorumSuccess(node);
+            return onMaybeFastPathSuccess(node);
         }
     }
 
@@ -159,31 +157,14 @@ public class FastPathTracker extends PreAcceptTracker<FastPathTracker.FastPathSh
 
         public ShardOutcome<? super FastPathTracker> onQuorumSuccess(Node.Id node)
         {
-            ++successes;
-            if (!shard.fastPathElectorate.contains(node))
-                return quorumIfNewAndHasRejectedFastPath();
-
-            ++fastPathFailures;
-            if (isNewFastPathReject() && hasReachedQuorum())
-                return Success;
+            if (complete)
+                return NoChange;
 
-            if (isNewSlowPathSuccess() && hasRejectedFastPath())
-                return Success;
-
-            return NoChange;
-        }
-
-        @Override
-        public ShardOutcome<? super FastPathTracker> onMaybeFastPathSuccess(Node.Id node)
-        {
             ++successes;
             if (shard.fastPathElectorate.contains(node))
-            {
-                ++fastPathAccepts;
-                if (isNewFastPathSuccess())
-                    return NewFastPathSuccess;
-            }
-            return quorumIfNewAndHasRejectedFastPath();
+                ++fastPathFailures;
+
+            return quorumIfHasRejectedFastPath();
         }
     }
 
diff --git a/accord-core/src/main/java/accord/impl/AbstractSafeCommandStore.java b/accord-core/src/main/java/accord/impl/AbstractSafeCommandStore.java
index 8a740873..ab2ed46c 100644
--- a/accord-core/src/main/java/accord/impl/AbstractSafeCommandStore.java
+++ b/accord-core/src/main/java/accord/impl/AbstractSafeCommandStore.java
@@ -67,10 +67,10 @@ public abstract class AbstractSafeCommandStore<CommandType extends SafeCommand,
     protected abstract CommandsForKeyType getCommandsForKeyIfUnsafe(RoutingKey key);
 
     @Override
-    protected CommandType ifLoadedAndInitialisedAndNotErasedInternal(TxnId txnId)
+    protected CommandType ifLoadedInternal(TxnId txnId)
     {
         CommandType command = getIfLoadedUnsafe(txnId, this::getCommandUnsafe, this::addCommandUnsafe, this::getIfLoadedUnsafe);
-        if (command == null || command.isUnset())
+        if (command == null)
             return null;
         return command;
     }
diff --git a/accord-core/src/main/java/accord/impl/DefaultLocalListeners.java b/accord-core/src/main/java/accord/impl/DefaultLocalListeners.java
index daa5593c..52fba403 100644
--- a/accord-core/src/main/java/accord/impl/DefaultLocalListeners.java
+++ b/accord-core/src/main/java/accord/impl/DefaultLocalListeners.java
@@ -84,7 +84,7 @@ public class DefaultLocalListeners implements LocalListeners
         @Override
         public void notify(SafeCommandStore safeStore, SafeCommand safeCommand, TxnId listenerId)
         {
-            SafeCommand listener = safeStore.ifLoadedAndInitialisedAndNotErased(listenerId);
+            SafeCommand listener = safeStore.ifLoadedAndInitialised(listenerId);
             if (listener != null) Commands.listenerUpdate(safeStore, listener, safeCommand);
             else
             {
diff --git a/accord-core/src/main/java/accord/impl/DurabilityScheduling.java b/accord-core/src/main/java/accord/impl/DurabilityScheduling.java
index 49e57cb1..bd370b93 100644
--- a/accord-core/src/main/java/accord/impl/DurabilityScheduling.java
+++ b/accord-core/src/main/java/accord/impl/DurabilityScheduling.java
@@ -306,7 +306,7 @@ public class DurabilityScheduling implements ConfigurationService.Listener
                     {
                         synchronized (ShardScheduler.this)
                         {
-                            // TODO (required): try to recover or invalidate prior sync point
+                            // TODO (expected): try to recover or invalidate prior sync point
                             retry();
                             if (numberOfSplits * 2 <= maxNumberOfSplits)
                             {
diff --git a/accord-core/src/main/java/accord/impl/InMemoryCommandStore.java b/accord-core/src/main/java/accord/impl/InMemoryCommandStore.java
index 69e547c5..e50998b4 100644
--- a/accord-core/src/main/java/accord/impl/InMemoryCommandStore.java
+++ b/accord-core/src/main/java/accord/impl/InMemoryCommandStore.java
@@ -195,7 +195,7 @@ public abstract class InMemoryCommandStore extends CommandStore
                         long epoch = cur.executeAt().epoch();
                         Ranges ranges = safeStore.ranges().allAt(epoch);
                         Participants<?> participants = cur.route().participants(ranges, Minimal);
-                        // TODO (required): look forwards also, but we only need to look at ?=ReadyToExecute transactions as they have already run their backwards checks
+                        // TODO (testing): look forwards also, but we only need to look at ?=ReadyToExecute transactions as they have already run their backwards checks
                         Iterator<GlobalCommand> iter = commandsByExecuteAt.descendingMap().tailMap(cur.executeAt(), false).values().iterator();
                         while (iter.hasNext())
                         {
@@ -391,16 +391,18 @@ public abstract class InMemoryCommandStore extends CommandStore
             List<TxnId> resubmit = new ArrayList<>();
             for (TxnId txnId : txnIds)
             {
-                Command command = commands.get(txnId).value();
-                if (!command.hasBeen(PreCommitted)) return;
-                if (!command.txnId().isVisible()) return;
+                GlobalCommand globalCommand = commands.get(txnId);
+                if (globalCommand == null) continue;
+                Command command = globalCommand.value();
+                if (!command.hasBeen(PreCommitted)) continue;
+                if (!command.txnId().isVisible()) continue;
 
                 Ranges allRanges = unsafeRangesForEpoch().allBetween(txnId.epoch(), command.executeAtOrTxnId().epoch());
                 boolean done = command.hasBeen(Truncated);
                 if (!done)
                 {
                     if (unsafeGetRedundantBefore().status(txnId, command.route()) == RedundantStatus.PRE_BOOTSTRAP_OR_STALE)
-                        return;
+                        continue;
 
                     Route<?> route = command.route().slice(allRanges);
                     done = !route.isEmpty() && ranges.containsAll(route);
@@ -423,7 +425,7 @@ public abstract class InMemoryCommandStore extends CommandStore
             if (!resubmit.isEmpty())
             {
                 txnIds = resubmit;
-                node.scheduler().once(this, 5L, TimeUnit.SECONDS);
+                node.scheduler().selfRecurring(this, 5L, TimeUnit.SECONDS);
             }
         }
     }
@@ -1194,7 +1196,7 @@ public abstract class InMemoryCommandStore extends CommandStore
         @Override
         public void shutdown()
         {
-            executor.shutdown();
+            executor.shutdownNow();
         }
     }
 
@@ -1213,10 +1215,10 @@ public abstract class InMemoryCommandStore extends CommandStore
             }
 
             @Override
-            public InMemorySafeCommand ifLoadedAndInitialisedAndNotErasedInternal(TxnId txnId)
+            public InMemorySafeCommand ifLoadedInternal(TxnId txnId)
             {
                 assertThread();
-                return super.ifLoadedAndInitialisedAndNotErasedInternal(txnId);
+                return super.ifLoadedInternal(txnId);
             }
 
             @Override
diff --git a/accord-core/src/main/java/accord/impl/progresslog/BaseTxnState.java b/accord-core/src/main/java/accord/impl/progresslog/BaseTxnState.java
index 2c20c6e6..140d5015 100644
--- a/accord-core/src/main/java/accord/impl/progresslog/BaseTxnState.java
+++ b/accord-core/src/main/java/accord/impl/progresslog/BaseTxnState.java
@@ -39,11 +39,11 @@ import static accord.impl.progresslog.TxnStateKind.Waiting;
  * - WaitingState defines the methods for updating the WaitingState state machine (i.e. for local commands that are waiting on a dependency's outcome)
  * - HomeState defines the methods for updating the HomeState state machine (i.e. for coordinators ensuring a transaction completes)
  * <p>
- * TODO (required): unit test all bit fiddling methods
+ * TODO (testing): unit test all bit fiddling methods
  */
 abstract class BaseTxnState extends LogGroupTimers.Timer implements Comparable<BaseTxnState>
 {
-    private static final int PENDING_TIMER_SHIFT = 53;
+    private static final int PENDING_TIMER_SHIFT = HomeState.HOME_STATE_END_SHIFT;
     private static final int PENDING_TIMER_BITS = 9;
     private static final int PENDING_TIMER_LOW_BITS = PackedLogLinearInteger.validateLowBits(4, PENDING_TIMER_BITS);
     private static final long PENDING_TIMER_MASK = (1L << PENDING_TIMER_BITS) - 1;
@@ -51,22 +51,27 @@ abstract class BaseTxnState extends LogGroupTimers.Timer implements Comparable<B
     private static final int SCHEDULED_TIMER_SHIFT = 62;
     private static final int CONTACT_ALL_SHIFT = 63;
 
+    static
+    {
+        Invariants.checkState(PENDING_TIMER_SHIFT + PENDING_TIMER_BITS <= SCHEDULED_TIMER_SHIFT);
+    }
+
     public final TxnId txnId;
 
     /**
-     * bits [0..40) encode WaitingState
+     * bits [0..43) encode WaitingState
      * 2 bits for Progress
      * 3 bits for BlockedUntil target
      * 3 bits for BlockedUntil that home shard can satisfy
      * 32 bits for remote progress key counter [note: if we need to in future we can safely and easily reclaim bits here]
      * 3 bits for retry counter
      * <p>
-     * bits [40..45) encode HomeState
+     * bits [43..51) encode HomeState
      * 2 bits for Progress
      * 3 bits for CoordinatePhase
      * 3 bits for retry counter
      * <p>
-     * bits [53..62) for pending timer delay
+     * bits [51..60) for pending timer delay
      * bit 62 for which kind of timer is scheduled
      * bit 63 for whether we should contact all candidate replicas (rather than just our preferred group)
      */
diff --git a/accord-core/src/main/java/accord/impl/progresslog/DefaultProgressLog.java b/accord-core/src/main/java/accord/impl/progresslog/DefaultProgressLog.java
index 41c7c7e7..1d75196e 100644
--- a/accord-core/src/main/java/accord/impl/progresslog/DefaultProgressLog.java
+++ b/accord-core/src/main/java/accord/impl/progresslog/DefaultProgressLog.java
@@ -459,6 +459,10 @@ public class DefaultProgressLog implements ProgressLog, Runnable
             if (safeCommand == null)
                 return;
 
+            // check this after fetching SafeCommand, as doing so can erase the command (and invalidate our state)
+            if (run.isDone(runKind))
+                return;
+
             Invariants.checkState(get(run.txnId) == run, "Transaction state for %s does not match expected one %s", run.txnId, run);
             Invariants.checkState(run.scheduledTimer() != runKind, "We are actively executing %s, but we are also scheduled to run this same TxnState later. This should not happen.", runKind);
             Invariants.checkState(run.pendingTimer() != runKind, "We are actively executing %s, but we also have a pending scheduled task to run this same TxnState later. This should not happen.", runKind);
diff --git a/accord-core/src/main/java/accord/impl/progresslog/DefaultProgressLogs.java b/accord-core/src/main/java/accord/impl/progresslog/DefaultProgressLogs.java
index 7f4fceaa..8ca59d6c 100644
--- a/accord-core/src/main/java/accord/impl/progresslog/DefaultProgressLogs.java
+++ b/accord-core/src/main/java/accord/impl/progresslog/DefaultProgressLogs.java
@@ -28,7 +28,7 @@ import accord.local.Node;
 
 // TODO (desired, consider): consider propagating invalidations in the same way as we do applied
 // TODO (expected): report transactions not making progress
-// TODO (required): evict to disk
+// TODO (expected): evict to disk
 public class DefaultProgressLogs implements ProgressLog.Factory
 {
     static ConcurrentHashMap<DefaultProgressLog, Runnable> PAUSE_FOR_TEST;
diff --git a/accord-core/src/main/java/accord/impl/progresslog/HomeState.java b/accord-core/src/main/java/accord/impl/progresslog/HomeState.java
index d8378f53..f8302f6d 100644
--- a/accord-core/src/main/java/accord/impl/progresslog/HomeState.java
+++ b/accord-core/src/main/java/accord/impl/progresslog/HomeState.java
@@ -41,7 +41,7 @@ import static accord.impl.progresslog.Progress.Queued;
 import static accord.impl.progresslog.TxnStateKind.Home;
 
 /**
- * TODO (required): describe state machine
+ * TODO (documentation): describe state machine
  *
  * TODO (expected): do not attempt recovery every run; simply check the coordinator is still active
  * TODO (expected): do not attempt execution until all shards are ready; use the WaitingState to achieve this
@@ -52,11 +52,11 @@ abstract class HomeState extends WaitingState
     private static final long PROGRESS_MASK = 0x3;
     private static final int STATUS_SHIFT = PROGRESS_SHIFT + 2;
     private static final long STATUS_MASK = 0x7;
-    private static final int RETRY_COUNTER_SHIFT = PROGRESS_SHIFT + 3;
+    private static final int RETRY_COUNTER_SHIFT = STATUS_SHIFT + 3;
     private static final long RETRY_COUNTER_MASK = 0x7;
     private static final long SET_MASK = ~((PROGRESS_MASK << PROGRESS_SHIFT)
                                            | (STATUS_MASK << STATUS_SHIFT));
-    final int HOME_STATE_END_SHIFT = RETRY_COUNTER_SHIFT + 3;
+    static final int HOME_STATE_END_SHIFT = RETRY_COUNTER_SHIFT + 3;
 
     HomeState(TxnId txnId)
     {
@@ -141,7 +141,7 @@ abstract class HomeState extends WaitingState
 
         Invariants.checkState(command.durability() != null);
         // TODO (expected): when invalidated, safer to maintain HomeState until known to be globally invalidated
-        // TODO (now): validate that we clear HomeState when we receive a Durable reply, to replace the token check logic
+        // TODO (expected): validate that we clear HomeState when we receive a Durable reply, to replace the token check logic
         Invariants.checkState(!command.durability().isDurableOrInvalidated(), "Command is durable or invalidated, but we have not cleared the ProgressLog");
 
         ProgressToken maxProgressToken = instance.savedProgressToken(txnId).merge(command);
diff --git a/accord-core/src/main/java/accord/impl/progresslog/TxnState.java b/accord-core/src/main/java/accord/impl/progresslog/TxnState.java
index c189f6a2..e5441995 100644
--- a/accord-core/src/main/java/accord/impl/progresslog/TxnState.java
+++ b/accord-core/src/main/java/accord/impl/progresslog/TxnState.java
@@ -154,4 +154,9 @@ final class TxnState extends HomeState
     {
         return txnId + ": " + toStateString();
     }
+
+    public boolean isDone(TxnStateKind runKind)
+    {
+        return runKind == TxnStateKind.Home ? isHomeDone() : isWaitingDone();
+    }
 }
diff --git a/accord-core/src/main/java/accord/impl/progresslog/WaitingState.java b/accord-core/src/main/java/accord/impl/progresslog/WaitingState.java
index 87c90ae3..35e80b8a 100644
--- a/accord-core/src/main/java/accord/impl/progresslog/WaitingState.java
+++ b/accord-core/src/main/java/accord/impl/progresslog/WaitingState.java
@@ -87,13 +87,13 @@ abstract class WaitingState extends BaseTxnState
     private static final long BLOCKED_UNTIL_MASK = 0x7;
     private static final int HOME_SATISFIES_SHIFT = 5;
     private static final long HOME_SATISFIES_MASK = 0x7;
-    private static final int AWAIT_BITS = 32;
     private static final int AWAIT_SHIFT = 8;
+    private static final int AWAIT_BITS = 32;
     private static final long AWAIT_MASK = (1L << AWAIT_BITS) - 1;
     private static final long SET_MASK = ~((PROGRESS_MASK << PROGRESS_SHIFT) | (BLOCKED_UNTIL_MASK << BLOCKED_UNTIL_SHIFT));
     private static final long INITIALISED_MASK = (PROGRESS_MASK << PROGRESS_SHIFT) | (BLOCKED_UNTIL_MASK << BLOCKED_UNTIL_SHIFT) | (HOME_SATISFIES_MASK << HOME_SATISFIES_SHIFT);
 
-    private static final int RETRY_COUNTER_SHIFT = 40;
+    private static final int RETRY_COUNTER_SHIFT = AWAIT_SHIFT + AWAIT_BITS;
     private static final long RETRY_COUNTER_MASK = 0x7;
     static final int WAITING_STATE_END_SHIFT = RETRY_COUNTER_SHIFT + 3;
 
diff --git a/accord-core/src/main/java/accord/local/Bootstrap.java b/accord-core/src/main/java/accord/local/Bootstrap.java
index 2c9799e8..459952aa 100644
--- a/accord-core/src/main/java/accord/local/Bootstrap.java
+++ b/accord-core/src/main/java/accord/local/Bootstrap.java
@@ -44,7 +44,6 @@ import accord.utils.async.AsyncResults;
 import static accord.local.PreLoadContext.empty;
 import static accord.primitives.Routables.Slice.Minimal;
 import static accord.primitives.Txn.Kind.ExclusiveSyncPoint;
-import static accord.primitives.Txn.Kind.LocalOnly;
 import static accord.utils.Invariants.illegalState;
 
 /**
@@ -109,7 +108,7 @@ class Bootstrap
         boolean fetchCompleted;
         boolean completed; // we have finished fetching all the data we are able to, but we may still have in-flight fetches
         Throwable fetchOutcome;
-        TxnId globalSyncId, localSyncId;
+        TxnId globalSyncId;
 
         Attempt(Ranges ranges)
         {
@@ -125,7 +124,6 @@ class Bootstrap
             }
 
             globalSyncId = node.nextTxnId(ExclusiveSyncPoint, Routable.Domain.Range);
-            localSyncId = globalSyncId.as(LocalOnly).withEpoch(epoch);
             Invariants.checkArgument(epoch <= globalSyncId.epoch(), "Attempting to use local epoch %d which is larger than global epoch %d", epoch, globalSyncId.epoch());
 
             if (!node.topology().hasEpoch(globalSyncId.epoch()))
diff --git a/accord-core/src/main/java/accord/local/Cleanup.java b/accord-core/src/main/java/accord/local/Cleanup.java
index 195f9fd6..78a4dea2 100644
--- a/accord-core/src/main/java/accord/local/Cleanup.java
+++ b/accord-core/src/main/java/accord/local/Cleanup.java
@@ -33,6 +33,7 @@ import static accord.local.RedundantBefore.PreBootstrapOrStale.FULLY;
 import static accord.local.RedundantStatus.LIVE;
 import static accord.local.RedundantStatus.NOT_OWNED;
 import static accord.local.RedundantStatus.SHARD_REDUNDANT;
+import static accord.local.RedundantStatus.WAS_OWNED_CLOSED;
 import static accord.primitives.SaveStatus.Erased;
 import static accord.primitives.SaveStatus.ErasedOrVestigial;
 import static accord.primitives.SaveStatus.Invalidated;
@@ -111,7 +112,7 @@ public enum Cleanup
     private static Cleanup shouldCleanupInternal(Agent agent, TxnId txnId, SaveStatus saveStatus, Durability durability, StoreParticipants participants, RedundantBefore redundantBefore, DurableBefore durableBefore)
     {
         if (txnId.kind() == EphemeralRead)
-            return NO; // TODO (required): clean-up based on timeout
+            return NO;
 
         if (expunge(txnId, saveStatus, durableBefore, redundantBefore))
             return EXPUNGE;
@@ -199,17 +200,23 @@ public enum Cleanup
             case REDUNDANT_PRE_BOOTSTRAP_OR_STALE:
             case LOCALLY_REDUNDANT:
                 return Cleanup.NO;
+
             case SHARD_REDUNDANT:
-                if (!isPartial && saveStatus.hasBeen(PreCommitted) && !saveStatus.hasBeen(Applied) && redundantBefore.preBootstrapOrStale(txnId, participants.owns) != FULLY)
+                if (!isPartial)
                 {
-                    agent.onViolation(String.format("Loading SHARD_REDUNDANT command %s with status %s (that should have been Applied). Expected to be witnessed and executed by %s.", txnId, saveStatus, redundantBefore.max(participants.route, e -> e.shardAppliedOrInvalidatedBefore)));
-                    return TRUNCATE;
+                    if (!saveStatus.hasBeen(PreCommitted))
+                        return INVALIDATE;
+
+                    if (!saveStatus.hasBeen(Applied) && redundantBefore.preBootstrapOrStale(txnId, participants.owns) != FULLY)
+                    {
+                        agent.onViolation(String.format("Loading SHARD_REDUNDANT command %s with status %s (that should have been Applied). Expected to be witnessed and executed by %s.", txnId, saveStatus, redundantBefore.max(participants.route, e -> e.shardAppliedOrInvalidatedBefore)));
+                        return TRUNCATE;
+                    }
                 }
-            case WAS_OWNED:
-        }
+                break;
 
-        if (!isPartial && !saveStatus.hasBeen(PreCommitted))
-            return INVALIDATE;
+            case WAS_OWNED_CLOSED:
+        }
 
         Durability min = durableBefore.min(txnId, participants.route);
         switch (min)
@@ -219,6 +226,9 @@ public enum Cleanup
                 throw new AssertionError("Unexpected durability: " + min);
 
             case NotDurable:
+                if (redundant == WAS_OWNED_CLOSED)
+                    return NO;
+
                 if (durability == Majority)
                     return Cleanup.TRUNCATE;
                 return Cleanup.TRUNCATE_WITH_OUTCOME;
diff --git a/accord-core/src/main/java/accord/local/CommandStore.java b/accord-core/src/main/java/accord/local/CommandStore.java
index bcd175cb..6fb4ae04 100644
--- a/accord-core/src/main/java/accord/local/CommandStore.java
+++ b/accord-core/src/main/java/accord/local/CommandStore.java
@@ -165,6 +165,7 @@ public abstract class CommandStore implements AgentExecutor
      * But they may still be ordered for other key ranges they participate in.
      *
      * TODO (expected): merge with redundantBefore
+     * TODO (required): if we ever actually erase data on disk (after losing ownership), make sure to mark the range unsafe to read
      */
     private NavigableMap<Timestamp, Ranges> safeToRead = ImmutableSortedMap.of(Timestamp.NONE, Ranges.EMPTY);
     private final Set<Bootstrap> bootstraps = Collections.synchronizedSet(new DeterministicIdentitySet<>());
@@ -592,7 +593,7 @@ public abstract class CommandStore implements AgentExecutor
             e.getValue().ranges = remaining = remaining.without(ranges);
             if (e.getValue().ranges.isEmpty())
             {
-                logger.info("Completed full sync for {} on epoch {} using {}", e.getValue().allRanges, e.getKey(), syncId);
+                logger.debug("Completed full sync for {} on epoch {} using {}", e.getValue().allRanges, e.getKey(), syncId);
                 e.getValue().whenDone.trySuccess(null);
                 if (remove == null)
                     remove = new LongHashSet();
@@ -600,7 +601,7 @@ public abstract class CommandStore implements AgentExecutor
             }
             else
             {
-                logger.info("Completed partial sync for {} on epoch {} using {}; {} still to sync", synced, e.getKey(), syncId, remaining);
+                logger.debug("Completed partial sync for {} on epoch {} using {}; {} still to sync", synced, e.getKey(), syncId, remaining);
             }
         }
         if (remove != null)
diff --git a/accord-core/src/main/java/accord/local/Commands.java b/accord-core/src/main/java/accord/local/Commands.java
index 3974d86d..39866a12 100644
--- a/accord-core/src/main/java/accord/local/Commands.java
+++ b/accord-core/src/main/java/accord/local/Commands.java
@@ -573,7 +573,7 @@ public class Commands
         if (logger.isTraceEnabled())
             logger.trace("{}: Maybe executing with status {}. Will notify listeners on noop: {}", command.txnId(), command.status(), alwaysNotifyListeners);
 
-        if (command.status() != Stable && command.status() != PreApplied)
+        if (command.status() != Stable && command.saveStatus() != SaveStatus.PreApplied)
         {
             if (alwaysNotifyListeners)
                 safeStore.notifyListeners(safeCommand, command);
@@ -648,7 +648,7 @@ public class Commands
             redundantBefore.removeRedundantDependencies(participants, update);
 
         update.forEachWaitingOnId(safeStore, update, waiting, executeAt, (store, upd, w, exec, i) -> {
-            SafeCommand dep = store.ifLoadedAndInitialisedAndNotErased(upd.txnId(i));
+            SafeCommand dep = store.ifLoadedAndInitialised(upd.txnId(i));
             if (dep == null || !dep.current().hasBeen(PreCommitted))
                 return;
             updateWaitingOn(store, w, exec, upd, dep);
@@ -870,7 +870,7 @@ public class Commands
         return result;
     }
 
-    private static boolean validateSafeToCleanup(SafeCommandStore safeStore, Command command, StoreParticipants participants)
+    private static boolean validateSafeToCleanup(SafeCommandStore safeStore, Command command, @Nullable StoreParticipants participants)
     {
         TxnId txnId = command.txnId();
         participants = command.participants().supplement(participants);
@@ -879,13 +879,13 @@ public class Commands
         {
             default: throw new AssertionError("Unhandled RedundantStatus: " + status);
             case LIVE:
+            case WAS_OWNED_CLOSED:
             case REDUNDANT_PRE_BOOTSTRAP_OR_STALE:
             case PARTIALLY_PRE_BOOTSTRAP_OR_STALE:
                 return false;
             case LOCALLY_REDUNDANT:
             case SHARD_REDUNDANT:
                 Invariants.checkState(!command.hasBeen(PreCommitted));
-            case WAS_OWNED:
             case PRE_BOOTSTRAP_OR_STALE:
             case NOT_OWNED:
                 return true;
@@ -894,7 +894,8 @@ public class Commands
 
     public static boolean maybeCleanup(SafeCommandStore safeStore, SafeCommand safeCommand, Command command, @Nonnull StoreParticipants participants)
     {
-        Cleanup cleanup = shouldCleanup(safeStore, command, participants);
+        // TODO (desired): cheaper version of supplement for here
+        Cleanup cleanup = shouldCleanup(safeStore, command, command.participants().supplement(participants));
         if (cleanup == NO)
             return false;
 
@@ -998,7 +999,7 @@ public class Commands
                         }
                     }
 
-                    depSafe = safeStore.ifLoadedAndInitialisedAndNotErased(directlyBlockedOn);
+                    depSafe = safeStore.ifLoadedAndInitialised(directlyBlockedOn);
                     if (depSafe == null)
                     {
                         loadDepId = directlyBlockedOn;
diff --git a/accord-core/src/main/java/accord/local/PreLoadContext.java b/accord-core/src/main/java/accord/local/PreLoadContext.java
index 97697d06..b4d5e15b 100644
--- a/accord-core/src/main/java/accord/local/PreLoadContext.java
+++ b/accord-core/src/main/java/accord/local/PreLoadContext.java
@@ -156,6 +156,13 @@ public interface PreLoadContext
         return new Standard(primary, additional, keys, keyHistory);
     }
 
+    default boolean contains(TxnId txnId)
+    {
+        TxnId primaryTxnId = primaryTxnId();
+        return primaryTxnId != null && (txnId.equals(primaryTxnId) || txnId.equals(additionalTxnId()));
+    }
+
+
     class Standard implements PreLoadContext
     {
         private final @Nullable TxnId primary;
diff --git a/accord-core/src/main/java/accord/local/RedundantBefore.java b/accord-core/src/main/java/accord/local/RedundantBefore.java
index 4aef63a2..7dcae0c8 100644
--- a/accord-core/src/main/java/accord/local/RedundantBefore.java
+++ b/accord-core/src/main/java/accord/local/RedundantBefore.java
@@ -38,6 +38,7 @@ import accord.primitives.Ranges;
 import accord.primitives.Routables;
 import accord.primitives.RoutingKeys;
 import accord.primitives.Timestamp;
+import accord.primitives.Txn;
 import accord.primitives.TxnId;
 import accord.primitives.Unseekables;
 import accord.utils.Invariants;
@@ -53,7 +54,7 @@ import static accord.local.RedundantStatus.LOCALLY_REDUNDANT;
 import static accord.local.RedundantStatus.NOT_OWNED;
 import static accord.local.RedundantStatus.PRE_BOOTSTRAP_OR_STALE;
 import static accord.local.RedundantStatus.SHARD_REDUNDANT;
-import static accord.local.RedundantStatus.WAS_OWNED;
+import static accord.local.RedundantStatus.WAS_OWNED_CLOSED;
 import static accord.utils.Invariants.illegalState;
 
 public class RedundantBefore extends ReducingRangeMap<RedundantBefore.Entry>
@@ -155,14 +156,27 @@ public class RedundantBefore extends ReducingRangeMap<RedundantBefore.Entry>
             this.gcBefore = gcBefore;
             this.bootstrappedAt = bootstrappedAt;
             this.staleUntilAtLeast = staleUntilAtLeast;
-            Invariants.checkArgument(locallyWitnessedOrInvalidatedBefore.equals(TxnId.NONE) || locallyWitnessedOrInvalidatedBefore.domain().isRange());
-            Invariants.checkArgument(locallyAppliedOrInvalidatedBefore.equals(TxnId.NONE) || locallyAppliedOrInvalidatedBefore.domain().isRange());
-            Invariants.checkArgument(locallyDecidedAndAppliedOrInvalidatedBefore.equals(TxnId.NONE) || locallyDecidedAndAppliedOrInvalidatedBefore.domain().isRange());
-            Invariants.checkArgument(shardAppliedOrInvalidatedBefore.equals(TxnId.NONE) || shardAppliedOrInvalidatedBefore.domain().isRange());
-            Invariants.checkArgument(gcBefore.equals(TxnId.NONE) || gcBefore.domain().isRange());
-            Invariants.checkArgument(locallyDecidedAndAppliedOrInvalidatedBefore.compareTo(locallyAppliedOrInvalidatedBefore) <= 0);
-            Invariants.checkArgument(shardAppliedOrInvalidatedBefore.compareTo(shardOnlyAppliedOrInvalidatedBefore) <= 0);
-            Invariants.checkArgument(gcBefore.compareTo(shardAppliedOrInvalidatedBefore) <= 0);
+            checkNoneOrRX(locallyWitnessedOrInvalidatedBefore, locallyAppliedOrInvalidatedBefore, locallyDecidedAndAppliedOrInvalidatedBefore,
+                          shardAppliedOrInvalidatedBefore, gcBefore);
+            checkPartiallyOrdered(locallyDecidedAndAppliedOrInvalidatedBefore, locallyAppliedOrInvalidatedBefore);
+            checkPartiallyOrdered(shardAppliedOrInvalidatedBefore, locallyAppliedOrInvalidatedBefore);
+            checkPartiallyOrdered(gcBefore, shardAppliedOrInvalidatedBefore, shardOnlyAppliedOrInvalidatedBefore);
+        }
+
+        private static void checkPartiallyOrdered(TxnId ... txnIds)
+        {
+            for (int i = 1 ; i < txnIds.length ; ++i)
+                Invariants.checkArgument(txnIds[i - 1].compareTo(txnIds[i]) <= 0);
+        }
+
+        private static void checkNoneOrRX(TxnId ... txnIds)
+        {
+            for (TxnId txnId : txnIds)
+                checkNoneOrRX(txnId);
+        }
+        private static void checkNoneOrRX(TxnId txnId)
+        {
+            Invariants.checkArgument(txnId.equals(TxnId.NONE) || (txnId.domain().isRange() && txnId.is(Txn.Kind.ExclusiveSyncPoint)));
         }
 
         public static Entry reduce(Entry a, Entry b)
@@ -201,7 +215,6 @@ public class RedundantBefore extends ReducingRangeMap<RedundantBefore.Entry>
             TxnId gcBefore = cg >= 0 ? cur.gcBefore : add.gcBefore;
             TxnId bootstrappedAt = cb >= 0 ? cur.bootstrappedAt : add.bootstrappedAt;
             Timestamp staleUntilAtLeast = csu >= 0 ? cur.staleUntilAtLeast : add.staleUntilAtLeast;
-            TxnId shardAppliedOrInvalidatedBefore = TxnId.min(shardOnlyAppliedOrInvalidatedBefore, locallyAppliedOrInvalidatedBefore);
 
             // if a NEW redundantBefore predates our current bootstrappedAt, we should not update it to avoid erroneously
             // treating transactions prior as locally redundant when they may simply have not applied yet, since we may
@@ -212,6 +225,8 @@ public class RedundantBefore extends ReducingRangeMap<RedundantBefore.Entry>
             // TODO (desired): revisit later as semantics here evolve
             if (bootstrappedAt.compareTo(locallyAppliedOrInvalidatedBefore) >= 0)
                 locallyAppliedOrInvalidatedBefore = cur.locallyAppliedOrInvalidatedBefore;
+
+            TxnId shardAppliedOrInvalidatedBefore = TxnId.min(shardOnlyAppliedOrInvalidatedBefore, locallyAppliedOrInvalidatedBefore);
             if (bootstrappedAt.compareTo(shardAppliedOrInvalidatedBefore) >= 0)
                 locallyDecidedAndAppliedOrInvalidatedBefore = cur.locallyDecidedAndAppliedOrInvalidatedBefore;
             if (staleUntilAtLeast != null && bootstrappedAt.compareTo(staleUntilAtLeast) >= 0)
@@ -364,7 +379,7 @@ public class RedundantBefore extends ReducingRangeMap<RedundantBefore.Entry>
         RedundantStatus get(TxnId txnId)
         {
             if (wasOwned(txnId) && isComplete())
-                return WAS_OWNED;
+                return WAS_OWNED_CLOSED;
             return getIgnoringOwnership(txnId);
         }
 
diff --git a/accord-core/src/main/java/accord/local/RedundantStatus.java b/accord-core/src/main/java/accord/local/RedundantStatus.java
index 3ecdc073..a9944b66 100644
--- a/accord-core/src/main/java/accord/local/RedundantStatus.java
+++ b/accord-core/src/main/java/accord/local/RedundantStatus.java
@@ -30,9 +30,10 @@ public enum RedundantStatus
     NOT_OWNED,
 
     /**
-     * None of the relevant ranges are owned by the command store anymore
+     * None of the relevant ranges are owned by the command store anymore, and all of those ranges are closed
+     * (i.e. we should not participate in any decisions)
      */
-    WAS_OWNED,
+    WAS_OWNED_CLOSED,
 
     /**
      * Some of the relevant ranges are owned by the command store and valid for execution
@@ -84,25 +85,25 @@ public enum RedundantStatus
     {
         NOT_OWNED.merge = new EnumMap<>(RedundantStatus.class);
         NOT_OWNED.merge.put(NOT_OWNED, NOT_OWNED);
-        NOT_OWNED.merge.put(WAS_OWNED, WAS_OWNED);
+        NOT_OWNED.merge.put(WAS_OWNED_CLOSED, WAS_OWNED_CLOSED);
         NOT_OWNED.merge.put(LIVE, LIVE);
         NOT_OWNED.merge.put(PARTIALLY_PRE_BOOTSTRAP_OR_STALE, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
         NOT_OWNED.merge.put(PRE_BOOTSTRAP_OR_STALE, PRE_BOOTSTRAP_OR_STALE);
         NOT_OWNED.merge.put(REDUNDANT_PRE_BOOTSTRAP_OR_STALE, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
         NOT_OWNED.merge.put(LOCALLY_REDUNDANT, LOCALLY_REDUNDANT);
         NOT_OWNED.merge.put(SHARD_REDUNDANT, SHARD_REDUNDANT);
-        WAS_OWNED.merge = new EnumMap<>(RedundantStatus.class);
-        WAS_OWNED.merge.put(NOT_OWNED, NOT_OWNED);
-        WAS_OWNED.merge.put(WAS_OWNED, WAS_OWNED);
-        WAS_OWNED.merge.put(LIVE, LIVE);
-        WAS_OWNED.merge.put(PARTIALLY_PRE_BOOTSTRAP_OR_STALE, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
-        WAS_OWNED.merge.put(PRE_BOOTSTRAP_OR_STALE, PRE_BOOTSTRAP_OR_STALE);
-        WAS_OWNED.merge.put(REDUNDANT_PRE_BOOTSTRAP_OR_STALE, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
-        WAS_OWNED.merge.put(LOCALLY_REDUNDANT, LOCALLY_REDUNDANT);
-        WAS_OWNED.merge.put(SHARD_REDUNDANT, SHARD_REDUNDANT);
+        WAS_OWNED_CLOSED.merge = new EnumMap<>(RedundantStatus.class);
+        WAS_OWNED_CLOSED.merge.put(NOT_OWNED, NOT_OWNED);
+        WAS_OWNED_CLOSED.merge.put(WAS_OWNED_CLOSED, WAS_OWNED_CLOSED);
+        WAS_OWNED_CLOSED.merge.put(LIVE, LIVE);
+        WAS_OWNED_CLOSED.merge.put(PARTIALLY_PRE_BOOTSTRAP_OR_STALE, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
+        WAS_OWNED_CLOSED.merge.put(PRE_BOOTSTRAP_OR_STALE, PRE_BOOTSTRAP_OR_STALE);
+        WAS_OWNED_CLOSED.merge.put(REDUNDANT_PRE_BOOTSTRAP_OR_STALE, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
+        WAS_OWNED_CLOSED.merge.put(LOCALLY_REDUNDANT, LOCALLY_REDUNDANT);
+        WAS_OWNED_CLOSED.merge.put(SHARD_REDUNDANT, SHARD_REDUNDANT);
         LIVE.merge = new EnumMap<>(RedundantStatus.class);
         LIVE.merge.put(NOT_OWNED, LIVE);
-        LIVE.merge.put(WAS_OWNED, LIVE);
+        LIVE.merge.put(WAS_OWNED_CLOSED, LIVE);
         LIVE.merge.put(LIVE, LIVE);
         LIVE.merge.put(PARTIALLY_PRE_BOOTSTRAP_OR_STALE, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
         LIVE.merge.put(PRE_BOOTSTRAP_OR_STALE, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
@@ -111,7 +112,7 @@ public enum RedundantStatus
         LIVE.merge.put(SHARD_REDUNDANT, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
         PARTIALLY_PRE_BOOTSTRAP_OR_STALE.merge = new EnumMap<>(RedundantStatus.class);
         PARTIALLY_PRE_BOOTSTRAP_OR_STALE.merge.put(NOT_OWNED, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
-        PARTIALLY_PRE_BOOTSTRAP_OR_STALE.merge.put(WAS_OWNED, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
+        PARTIALLY_PRE_BOOTSTRAP_OR_STALE.merge.put(WAS_OWNED_CLOSED, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
         PARTIALLY_PRE_BOOTSTRAP_OR_STALE.merge.put(LIVE, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
         PARTIALLY_PRE_BOOTSTRAP_OR_STALE.merge.put(PARTIALLY_PRE_BOOTSTRAP_OR_STALE, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
         PARTIALLY_PRE_BOOTSTRAP_OR_STALE.merge.put(PRE_BOOTSTRAP_OR_STALE, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
@@ -120,7 +121,7 @@ public enum RedundantStatus
         PARTIALLY_PRE_BOOTSTRAP_OR_STALE.merge.put(SHARD_REDUNDANT, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
         PRE_BOOTSTRAP_OR_STALE.merge = new EnumMap<>(RedundantStatus.class);
         PRE_BOOTSTRAP_OR_STALE.merge.put(NOT_OWNED, PRE_BOOTSTRAP_OR_STALE);
-        PRE_BOOTSTRAP_OR_STALE.merge.put(WAS_OWNED, PRE_BOOTSTRAP_OR_STALE);
+        PRE_BOOTSTRAP_OR_STALE.merge.put(WAS_OWNED_CLOSED, PRE_BOOTSTRAP_OR_STALE);
         PRE_BOOTSTRAP_OR_STALE.merge.put(LIVE, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
         PRE_BOOTSTRAP_OR_STALE.merge.put(PARTIALLY_PRE_BOOTSTRAP_OR_STALE, PARTIALLY_PRE_BOOTSTRAP_OR_STALE);
         PRE_BOOTSTRAP_OR_STALE.merge.put(PRE_BOOTSTRAP_OR_STALE, PRE_BOOTSTRAP_OR_STALE);
@@ -129,7 +130,7 @@ public enum RedundantStatus
         PRE_BOOTSTRAP_OR_STALE.merge.put(SHARD_REDUNDANT, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
         REDUNDANT_PRE_BOOTSTRAP_OR_STALE.merge = new EnumMap<>(RedundantStatus.class);
         REDUNDANT_PRE_BOOTSTRAP_OR_STALE.merge.put(NOT_OWNED, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
-        REDUNDANT_PRE_BOOTSTRAP_OR_STALE.merge.put(WAS_OWNED, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
+        REDUNDANT_PRE_BOOTSTRAP_OR_STALE.merge.put(WAS_OWNED_CLOSED, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
         REDUNDANT_PRE_BOOTSTRAP_OR_STALE.merge.put(LIVE, REDUNDANT_PRE_BOOTSTRAP_OR_STALE); // TODO (expected): should this be an invalid combination?
         REDUNDANT_PRE_BOOTSTRAP_OR_STALE.merge.put(PARTIALLY_PRE_BOOTSTRAP_OR_STALE, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
         REDUNDANT_PRE_BOOTSTRAP_OR_STALE.merge.put(PRE_BOOTSTRAP_OR_STALE, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
@@ -138,7 +139,7 @@ public enum RedundantStatus
         REDUNDANT_PRE_BOOTSTRAP_OR_STALE.merge.put(SHARD_REDUNDANT, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
         LOCALLY_REDUNDANT.merge = new EnumMap<>(RedundantStatus.class);
         LOCALLY_REDUNDANT.merge.put(NOT_OWNED, LOCALLY_REDUNDANT);
-        LOCALLY_REDUNDANT.merge.put(WAS_OWNED, LOCALLY_REDUNDANT);
+        LOCALLY_REDUNDANT.merge.put(WAS_OWNED_CLOSED, LOCALLY_REDUNDANT);
         LOCALLY_REDUNDANT.merge.put(LIVE, REDUNDANT_PRE_BOOTSTRAP_OR_STALE); // TODO (expected): should this be an invalid combination?
         LOCALLY_REDUNDANT.merge.put(PARTIALLY_PRE_BOOTSTRAP_OR_STALE, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
         LOCALLY_REDUNDANT.merge.put(PRE_BOOTSTRAP_OR_STALE, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
@@ -147,7 +148,7 @@ public enum RedundantStatus
         LOCALLY_REDUNDANT.merge.put(SHARD_REDUNDANT, LOCALLY_REDUNDANT);
         SHARD_REDUNDANT.merge = new EnumMap<>(RedundantStatus.class);
         SHARD_REDUNDANT.merge.put(NOT_OWNED, SHARD_REDUNDANT);
-        SHARD_REDUNDANT.merge.put(WAS_OWNED, SHARD_REDUNDANT);
+        SHARD_REDUNDANT.merge.put(WAS_OWNED_CLOSED, SHARD_REDUNDANT);
         SHARD_REDUNDANT.merge.put(LIVE, REDUNDANT_PRE_BOOTSTRAP_OR_STALE); // TODO (expected): should this be an invalid combination?
         SHARD_REDUNDANT.merge.put(PARTIALLY_PRE_BOOTSTRAP_OR_STALE, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
         SHARD_REDUNDANT.merge.put(PRE_BOOTSTRAP_OR_STALE, REDUNDANT_PRE_BOOTSTRAP_OR_STALE);
diff --git a/accord-core/src/main/java/accord/local/SafeCommandStore.java b/accord-core/src/main/java/accord/local/SafeCommandStore.java
index 72fb5bed..54639392 100644
--- a/accord-core/src/main/java/accord/local/SafeCommandStore.java
+++ b/accord-core/src/main/java/accord/local/SafeCommandStore.java
@@ -164,17 +164,18 @@ public abstract class SafeCommandStore
      *
      * This permits efficient operation when a transaction involved in processing another transaction happens to be in memory.
      */
-    public SafeCommand ifLoadedAndInitialisedAndNotErased(TxnId txnId)
+    public SafeCommand ifLoadedAndInitialised(TxnId txnId)
     {
         SafeCommand safeCommand = getInternal(txnId);
-        if (safeCommand != null)
-            return safeCommand.current().saveStatus().isUninitialised() ? null : safeCommand;
-
-        safeCommand = ifLoadedAndInitialisedAndNotErasedInternal(txnId);
-        if (safeCommand == null || safeCommand.current().saveStatus().isUninitialised())
-            return null;
+        if (safeCommand == null)
+        {
+            safeCommand = ifLoadedInternal(txnId);
+            if (safeCommand == null)
+                return null;
+        }
 
-        return maybeCleanup(safeCommand, safeCommand.current(), StoreParticipants.empty(txnId));
+        safeCommand = maybeCleanup(safeCommand, safeCommand.current(), StoreParticipants.empty(txnId));
+        return safeCommand.isUnset() ? null : safeCommand;
     }
 
     protected SafeCommandsForKey maybeCleanup(SafeCommandsForKey safeCfk)
@@ -220,8 +221,8 @@ public abstract class SafeCommandStore
 
     /** Get anything already referenced (should include anything in PreLoadContext). If returned, should be initialised. */
     protected abstract SafeCommand getInternal(TxnId txnId);
-    /** Get if available and initialised */
-    protected abstract SafeCommand ifLoadedAndInitialisedAndNotErasedInternal(TxnId txnId);
+    /** Get if available */
+    protected abstract SafeCommand ifLoadedInternal(TxnId txnId);
     /** Get anything already referenced (should include anything in PreLoadContext) */
     protected abstract SafeCommandsForKey getInternal(RoutingKey key);
     /** Get if available */
@@ -412,7 +413,8 @@ public abstract class SafeCommandStore
         CommandStore commandStore = safeStore.commandStore();
         Ranges ranges = next.participants().touches.toRanges();
         commandStore.registerTransitive(safeStore, next.partialDeps().rangeDeps);
-        commandStore.markSynced(safeStore, txnId, ranges);
+        if (txnId.is(Kind.ExclusiveSyncPoint))
+            commandStore.markSynced(safeStore, txnId, ranges);
     }
 
     /**
diff --git a/accord-core/src/main/java/accord/local/StoreParticipants.java b/accord-core/src/main/java/accord/local/StoreParticipants.java
index 7c8a319b..564b2b87 100644
--- a/accord-core/src/main/java/accord/local/StoreParticipants.java
+++ b/accord-core/src/main/java/accord/local/StoreParticipants.java
@@ -126,8 +126,9 @@ public class StoreParticipants
         return new StoreParticipants(route, owns, touches, touches);
     }
 
-    public final StoreParticipants supplement(StoreParticipants that)
+    public final StoreParticipants supplement(@Nullable StoreParticipants that)
     {
+        if (that == null) return this;
         if (this == that) return this;
         return supplement(that.route, that.owns, that.hasTouched);
     }
diff --git a/accord-core/src/main/java/accord/local/cfk/CommandsForKey.java b/accord-core/src/main/java/accord/local/cfk/CommandsForKey.java
index 428d2ca0..84d50d77 100644
--- a/accord-core/src/main/java/accord/local/cfk/CommandsForKey.java
+++ b/accord-core/src/main/java/accord/local/cfk/CommandsForKey.java
@@ -312,13 +312,13 @@ public class CommandsForKey extends CommandsForKeyUpdate implements CommandsSumm
     {
         public static CommandsForKey create(RoutingKey key, TxnInfo[] txns, Unmanaged[] unmanageds, TxnId prunedBefore, RedundantBefore.Entry boundsInfo)
         {
-            return reconstruct(key, boundsInfo, txns, prunedBefore, unmanageds);
+            return reconstruct(key, boundsInfo, true, txns, prunedBefore, unmanageds);
         }
     }
 
     interface Updater<O>
     {
-        O update(RoutingKey key, RedundantBefore.Entry boundsInfo, TxnInfo[] byId, TxnInfo[] committedByExecuteAt, int minUndecidedById, int maxAppliedWriteByExecuteAt, Object[] loadingPruned, int newPrunedBeforeById, Unmanaged[] unmanageds);
+        O update(RoutingKey key, RedundantBefore.Entry boundsInfo, boolean isNewBoundsInfo, TxnInfo[] byId, TxnInfo[] committedByExecuteAt, int minUndecidedById, int maxAppliedWriteByExecuteAt, Object[] loadingPruned, int newPrunedBeforeById, Unmanaged[] unmanageds);
     }
 
     /**
@@ -391,6 +391,11 @@ public class CommandsForKey extends CommandsForKeyUpdate implements CommandsSumm
             return (encodedStatus & 0xf) == status.ordinal();
         }
 
+        boolean hasBeen(InternalStatus status)
+        {
+            return (encodedStatus & 0xf) >= status.ordinal();
+        }
+
         boolean is(TestStatus testStatus)
         {
             InternalStatus status = status();
@@ -677,7 +682,7 @@ public class CommandsForKey extends CommandsForKeyUpdate implements CommandsSumm
         {
             this.pending = pending;
             this.txnId = txnId;
-            this.waitingUntil = waitingUntil;
+            this.waitingUntil = Invariants.checkArgument(waitingUntil, waitingUntil != null);
         }
 
         @Override
@@ -829,6 +834,10 @@ public class CommandsForKey extends CommandsForKeyUpdate implements CommandsSumm
 
     final Unmanaged[] unmanageds;
 
+    CommandsForKey(RoutingKey key, RedundantBefore.Entry boundsInfo, boolean isNewBoundsInfo, TxnInfo[] byId, TxnInfo[] committedByExecuteAt, int minUndecidedById, int maxAppliedWriteByExecuteAt, Object[] loadingPruned, int prunedBeforeById, Unmanaged[] unmanageds)
+    {
+        this(key, boundsInfo, byId, committedByExecuteAt, minUndecidedById, maxAppliedWriteByExecuteAt, loadingPruned, prunedBeforeById, unmanageds);
+    }
     CommandsForKey(RoutingKey key, RedundantBefore.Entry boundsInfo, TxnInfo[] byId, TxnInfo[] committedByExecuteAt, int minUndecidedById, int maxAppliedWriteByExecuteAt, Object[] loadingPruned, int prunedBeforeById, Unmanaged[] unmanageds)
     {
         this.key = key;
@@ -1335,24 +1344,24 @@ public class CommandsForKey extends CommandsForKeyUpdate implements CommandsSumm
     CommandsForKeyUpdate update(TxnInfo[] newById, int newMinUndecidedById, TxnInfo[] newCommittedByExecuteAt, int newMaxAppliedWriteByExecuteAt, Object[] newLoadingPruned, int newPrunedBeforeById, @Nullable TxnInfo curInfo, @Nonnull TxnInfo newInfo)
     {
         Invariants.checkState(prunedBeforeById < 0 || newById[newPrunedBeforeById].equals(byId[prunedBeforeById]));
-        return updateAndNotifyUnmanageds(key, boundsInfo,
+        return updateAndNotifyUnmanageds(key, boundsInfo, false,
                                          newById, newCommittedByExecuteAt, newMinUndecidedById, newMaxAppliedWriteByExecuteAt,
                                          newLoadingPruned, newPrunedBeforeById, unmanageds, curInfo, newInfo);
     }
 
-    static CommandsForKey reconstruct(RoutingKey key, RedundantBefore.Entry boundsInfo, TxnInfo[] byId, TxnId prunedBefore, Unmanaged[] unmanageds)
+    static CommandsForKey reconstruct(RoutingKey key, RedundantBefore.Entry boundsInfo, boolean isNewBoundsInfo, TxnInfo[] byId, TxnId prunedBefore, Unmanaged[] unmanageds)
     {
         int prunedBeforeById = Arrays.binarySearch(byId, prunedBefore);
         Invariants.checkState(prunedBeforeById >= 0 || prunedBefore.equals(TxnId.NONE));
-        return reconstruct(key, boundsInfo, byId, BTree.empty(), prunedBeforeById, unmanageds);
+        return reconstruct(key, boundsInfo, isNewBoundsInfo, byId, BTree.empty(), prunedBeforeById, unmanageds);
     }
 
-    static CommandsForKey reconstruct(RoutingKey key, RedundantBefore.Entry newBoundsInfo, TxnInfo[] byId, Object[] loadingPruned, int newPrunedBeforeById, Unmanaged[] unmanageds)
+    static CommandsForKey reconstruct(RoutingKey key, RedundantBefore.Entry boundsInfo, boolean isNewBoundsInfo, TxnInfo[] byId, Object[] loadingPruned, int newPrunedBeforeById, Unmanaged[] unmanageds)
     {
-        return reconstruct(key, newBoundsInfo, byId, loadingPruned, newPrunedBeforeById, unmanageds, CommandsForKey::new);
+        return reconstruct(key, boundsInfo, isNewBoundsInfo, byId, loadingPruned, newPrunedBeforeById, unmanageds, CommandsForKey::new);
     }
 
-    static <O> O reconstruct(RoutingKey key, RedundantBefore.Entry newBoundsInfo, TxnInfo[] byId, Object[] loadingPruned, int newPrunedBeforeById, Unmanaged[] unmanageds, Updater<O> updater)
+    static <O> O reconstruct(RoutingKey key, RedundantBefore.Entry boundsInfo, boolean isNewBoundsInfo, TxnInfo[] byId, Object[] loadingPruned, int newPrunedBeforeById, Unmanaged[] unmanageds, Updater<O> updater)
     {
         int countCommitted = 0;
         int minUndecidedById = -1;
@@ -1376,26 +1385,26 @@ public class CommandsForKey extends CommandsForKeyUpdate implements CommandsSumm
         while (--maxAppliedWriteByExecuteAt >= 0)
         {
             TxnInfo txn = committedByExecuteAt[maxAppliedWriteByExecuteAt];
-            if (txn.kind() == Write && (txn.status() == APPLIED || isPreBootstrap(txn, newBoundsInfo)))
+            if (txn.kind() == Write && (txn.status() == APPLIED || isPreBootstrap(txn, boundsInfo)))
                 break;
         }
 
-        return updater.update(key, newBoundsInfo, byId, committedByExecuteAt, minUndecidedById, maxAppliedWriteByExecuteAt, loadingPruned, newPrunedBeforeById, unmanageds);
+        return updater.update(key, boundsInfo, isNewBoundsInfo, byId, committedByExecuteAt, minUndecidedById, maxAppliedWriteByExecuteAt, loadingPruned, newPrunedBeforeById, unmanageds);
     }
 
-    static CommandsForKeyUpdate reconstructAndUpdateUnmanaged(RoutingKey key, RedundantBefore.Entry boundsInfo, TxnInfo[] byId, Object[] loadingPruned, int newPrunedBeforeById, Unmanaged[] unmanageds)
+    static CommandsForKeyUpdate reconstructAndUpdateUnmanaged(RoutingKey key, RedundantBefore.Entry boundsInfo, boolean isNewBoundsInfo, TxnInfo[] byId, Object[] loadingPruned, int newPrunedBeforeById, Unmanaged[] unmanageds)
     {
-        return reconstruct(key, boundsInfo, byId, loadingPruned, newPrunedBeforeById, unmanageds, CommandsForKey::updateAndNotifyUnmanageds);
+        return reconstruct(key, boundsInfo, isNewBoundsInfo, byId, loadingPruned, newPrunedBeforeById, unmanageds, CommandsForKey::updateAndNotifyUnmanageds);
     }
 
-    static CommandsForKeyUpdate updateAndNotifyUnmanageds(RoutingKey key, RedundantBefore.Entry boundsInfo, TxnInfo[] byId, TxnInfo[] committedByExecuteAt, int minUndecidedById, int maxAppliedWriteByExecuteAt, Object[] loadingPruned, int newPrunedBeforeById, Unmanaged[] unmanageds)
+    static CommandsForKeyUpdate updateAndNotifyUnmanageds(RoutingKey key, RedundantBefore.Entry boundsInfo, boolean isNewBoundsInfo, TxnInfo[] byId, TxnInfo[] committedByExecuteAt, int minUndecidedById, int maxAppliedWriteByExecuteAt, Object[] loadingPruned, int newPrunedBeforeById, Unmanaged[] unmanageds)
     {
-        return updateAndNotifyUnmanageds(key, boundsInfo, byId, committedByExecuteAt, minUndecidedById, maxAppliedWriteByExecuteAt, loadingPruned, newPrunedBeforeById, unmanageds, null, null);
+        return updateAndNotifyUnmanageds(key, boundsInfo, isNewBoundsInfo, byId, committedByExecuteAt, minUndecidedById, maxAppliedWriteByExecuteAt, loadingPruned, newPrunedBeforeById, unmanageds, null, null);
     }
 
-    static CommandsForKeyUpdate updateAndNotifyUnmanageds(RoutingKey key, RedundantBefore.Entry boundsInfo, TxnInfo[] byId, TxnInfo[] committedByExecuteAt, int minUndecidedById, int maxAppliedWriteByExecuteAt, Object[] loadingPruned, int newPrunedBeforeById, Unmanaged[] unmanageds, @Nullable TxnInfo curInfo, @Nullable TxnInfo newInfo)
+    static CommandsForKeyUpdate updateAndNotifyUnmanageds(RoutingKey key, RedundantBefore.Entry boundsInfo, boolean isNewBoundsInfo, TxnInfo[] byId, TxnInfo[] committedByExecuteAt, int minUndecidedById, int maxAppliedWriteByExecuteAt, Object[] loadingPruned, int newPrunedBeforeById, Unmanaged[] unmanageds, @Nullable TxnInfo curInfo, @Nullable TxnInfo newInfo)
     {
-        NotifyUnmanagedResult notifyUnmanaged = PostProcess.notifyUnmanaged(unmanageds, byId, minUndecidedById, committedByExecuteAt, maxAppliedWriteByExecuteAt, loadingPruned, boundsInfo, curInfo, newInfo);
+        NotifyUnmanagedResult notifyUnmanaged = PostProcess.notifyUnmanaged(unmanageds, byId, minUndecidedById, committedByExecuteAt, maxAppliedWriteByExecuteAt, loadingPruned, boundsInfo, isNewBoundsInfo, curInfo, newInfo);
         if (notifyUnmanaged != null)
             unmanageds = notifyUnmanaged.newUnmanaged;
         CommandsForKey result = new CommandsForKey(key, boundsInfo, byId, committedByExecuteAt, minUndecidedById, maxAppliedWriteByExecuteAt, loadingPruned, newPrunedBeforeById, unmanageds);
@@ -1599,7 +1608,6 @@ public class CommandsForKey extends CommandsForKeyUpdate implements CommandsSumm
         switch (kind)
         {
             default: throw new AssertionError("Unhandled Txn.Kind: " + kind);
-            case LocalOnly:
             case EphemeralRead:
                 throw illegalState("Invalid Txn.Kind for CommandsForKey: " + kind);
 
@@ -1620,7 +1628,6 @@ public class CommandsForKey extends CommandsForKeyUpdate implements CommandsSumm
         switch (kind)
         {
             default: throw new AssertionError("Unhandled Txn.Kind: " + kind);
-            case LocalOnly:
             case EphemeralRead:
             case ExclusiveSyncPoint:
                 throw illegalState("Invalid Txn.Kind for CommandsForKey: " + kind);
@@ -1668,7 +1675,7 @@ public class CommandsForKey extends CommandsForKeyUpdate implements CommandsSumm
         int newPrunedBeforeById = prunedBeforeId(newById, prunedBefore(), redundantBefore(newBoundsInfo));
         Object[] newLoadingPruned = Pruning.removeRedundantLoadingPruned(loadingPruned, redundantBefore(newBoundsInfo));
 
-        return notifyManagedPreBootstrap(this, newBoundsInfo, reconstructAndUpdateUnmanaged(key, newBoundsInfo, newById, newLoadingPruned, newPrunedBeforeById, unmanageds));
+        return notifyManagedPreBootstrap(this, newBoundsInfo, reconstructAndUpdateUnmanaged(key, newBoundsInfo, true, newById, newLoadingPruned, newPrunedBeforeById, unmanageds));
     }
 
     /**
@@ -1685,7 +1692,7 @@ public class CommandsForKey extends CommandsForKeyUpdate implements CommandsSumm
         int newPrunedBeforeById = prunedBeforeId(newById, prunedBefore(), newRedundantBefore);
         Object[] newLoadingPruned = Pruning.removeRedundantLoadingPruned(loadingPruned, newRedundantBefore);
 
-        return reconstruct(key, newBoundsInfo, newById, newLoadingPruned, newPrunedBeforeById, unmanageds);
+        return reconstruct(key, newBoundsInfo, true, newById, newLoadingPruned, newPrunedBeforeById, unmanageds);
     }
 
     /**
diff --git a/accord-core/src/main/java/accord/local/cfk/NotifySink.java b/accord-core/src/main/java/accord/local/cfk/NotifySink.java
index b6a415df..a869e8f0 100644
--- a/accord-core/src/main/java/accord/local/cfk/NotifySink.java
+++ b/accord-core/src/main/java/accord/local/cfk/NotifySink.java
@@ -49,7 +49,7 @@ interface NotifySink
         @Override
         public void notWaiting(SafeCommandStore safeStore, TxnId txnId, RoutingKey key)
         {
-            SafeCommand safeCommand = safeStore.ifLoadedAndInitialisedAndNotErased(txnId);
+            SafeCommand safeCommand = safeStore.ifLoadedAndInitialised(txnId);
             if (safeCommand != null) notWaiting(safeStore, safeCommand, key);
             else
             {
diff --git a/accord-core/src/main/java/accord/local/cfk/PostProcess.java b/accord-core/src/main/java/accord/local/cfk/PostProcess.java
index 1c187a00..2dc9a916 100644
--- a/accord-core/src/main/java/accord/local/cfk/PostProcess.java
+++ b/accord-core/src/main/java/accord/local/cfk/PostProcess.java
@@ -91,7 +91,7 @@ abstract class PostProcess
             for (TxnId txnId : load)
             {
                 safeStore = safeStore; // make it unsafe for use in lambda
-                SafeCommand safeCommand = safeStore.ifLoadedAndInitialisedAndNotErased(txnId);
+                SafeCommand safeCommand = safeStore.ifLoadedAndInitialised(txnId);
                 if (safeCommand != null) load(safeStore, safeCommand, safeCfk, notifySink);
                 else
                     safeStore.commandStore().execute(PreLoadContext.contextFor(txnId, RoutingKeys.of(key), SYNC), safeStore0 -> {
@@ -196,7 +196,7 @@ abstract class PostProcess
             List<PostProcess> nestedNotify = new ArrayList<>();
             for (TxnId txnId : notify)
             {
-                SafeCommand safeCommand = safeStore.ifLoadedAndInitialisedAndNotErased(txnId);
+                SafeCommand safeCommand = safeStore.ifLoadedAndInitialised(txnId);
                 if (safeCommand != null)
                 {
                     CommandsForKeyUpdate update = updateUnmanaged(cfk, safeCommand, UPDATE, addUnmanageds);
@@ -246,6 +246,7 @@ abstract class PostProcess
                                                  int maxAppliedWriteByExecuteAt,
                                                  Object[] loadingPruned,
                                                  RedundantBefore.Entry boundsInfo,
+                                                 boolean isNewBoundsInfo,
                                                  @Nullable TxnInfo curInfo,
                                                  @Nullable TxnInfo newInfo)
     {
@@ -283,7 +284,18 @@ abstract class PostProcess
                 TxnInfo maxContiguousApplied = CommandsForKey.maxContiguousManagedApplied(committedByExecuteAt, maxAppliedWriteByExecuteAt, bootstrappedAt);
                 if (maxContiguousApplied != null)
                     applyTo = maxContiguousApplied.executeAt;
-                // if we're updating bootstrappedAt, we can fire anyone waiting on an executeAt before the bootstrappedAt
+
+                // if we're updating bootstrappedAt, we can notify anyone waiting on an executeAt before the bootstrappedAt
+                if (applyTo == null && bootstrappedAt != null && isNewBoundsInfo)
+                {
+                    // there's a special edge case here also, which is where we have removed entries from committedByExecuteAt because they're no longer owned
+                    // but they could be waiting on Apply of some transaction with a higher executeAt
+                    for (int i = byId.length - 1; i >= 0; --i)
+                    {
+                        TxnInfo txn = byId[i];
+                        applyTo = Timestamp.nonNullOrMax(applyTo, txn.executeAt);
+                    }
+                }
                 applyTo = Timestamp.nonNullOrMax(applyTo, TxnId.nonNullOrMax(redundantBefore, bootstrappedAt));
             }
 
diff --git a/accord-core/src/main/java/accord/local/cfk/Updating.java b/accord-core/src/main/java/accord/local/cfk/Updating.java
index 079f8b45..0fa684d1 100644
--- a/accord-core/src/main/java/accord/local/cfk/Updating.java
+++ b/accord-core/src/main/java/accord/local/cfk/Updating.java
@@ -760,6 +760,7 @@ class Updating
             Txn.Kind waitingKind = waitingTxnId.kind();
             boolean readyToApply = true; // our dependencies have applied, so we are ready to apply
             boolean waitingToApply = true; // our dependencies have committed, so we know when we execute and are waiting
+            boolean hasFutureDependency = false;
             Timestamp executesAt = null;
             int j = SortedArrays.binarySearch(byId, 0, byId.length, txnIds.get(i), Timestamp::compareTo, FAST);
 
@@ -774,44 +775,28 @@ class Updating
                     {
                         if (txn.status().compareTo(COMMITTED) < 0) waitingToApply = readyToApply = false;
                         else if (txn.status() != INVALID_OR_TRUNCATED_OR_PRUNED
-                                 && (txn.executeAt.compareTo(waitingExecuteAt) < 0
-                                     || waitingKind == EphemeralRead
-                                     || (waitingKind == ExclusiveSyncPoint && txn.compareTo(waitingTxnId) < 0)
-                                 ))
+                                 && (txn.executeAt.compareTo(waitingExecuteAt) < 0 || waitingKind.awaitsOnlyDeps))
                         {
-                            readyToApply &= txn.is(APPLIED);
-                            executesAt = Timestamp.nonNullOrMax(executesAt, txn.executeAt);
-                        }
-                    }
-                    ++i;
-                    ++j;
-                }
-                else if (c > 0)
-                {
-                    if (waitingKind.isSyncPoint())
-                    {
-                        // we special-case sync points to handle pruning of transactions they should have witnessed as dependencies.
-                        // We require all earlier TxnId to be decided before we can execute; we must be informed of all the necessary TxnId
-                        // transitively by the "future" dependency provided for this purpose in mapReduceActive, so simply ensuring
-                        // all earlier TxnId are committed is sufficient to compute the correct executeAt.
-                        TxnInfo txn = byId[j];
-                        if (txn.mayExecute())
-                        {
-                            if (txn.status().compareTo(COMMITTED) < 0) readyToApply = waitingToApply = false;
-                            else if (txn.status() != INVALID_OR_TRUNCATED_OR_PRUNED
-                                     && cfk.executes(txn.executeAt)
-                                     && (txn.executeAt.compareTo(waitingExecuteAt) < 0
-                                         || waitingKind == EphemeralRead
-                                         || (waitingKind == ExclusiveSyncPoint && txn.compareTo(waitingTxnId) < 0)
-                                     ))
+                            if (waitingKind == ExclusiveSyncPoint && txn.compareTo(waitingTxnId) > 0)
+                            {
+                                // we don't wait for this txn itself to apply, but we do require it to be transitively committed
+                                // (i.e., not just it must be committed, but all of its transitive dependencies;
+                                // and then for the highest committed transaction < waitingTxnId to apply
+                                if (cfk.minUndecidedById >= 0 && cfk.minUndecidedById <= j)
+                                    waitingToApply = readyToApply = false;
+                                hasFutureDependency = true;
+                            }
+                            else
                             {
                                 readyToApply &= txn.is(APPLIED);
                                 executesAt = Timestamp.nonNullOrMax(executesAt, txn.executeAt);
                             }
                         }
                     }
+                    ++i;
                     ++j;
                 }
+                else if (c > 0) ++j;
                 else if (!cfk.mayExecute(txnIds.get(i))) ++i;
                 else if (register)
                 {
@@ -826,8 +811,26 @@ class Updating
                 }
             }
 
-            if (waitingKind.isSyncPoint() && Pruning.isAnyPredecessorWaitingOnPruned(cfk.loadingPruned, waitingTxnId))
-                readyToApply = waitingToApply = false;
+            if (waitingKind.isSyncPoint())
+            {
+                if (Pruning.isAnyPredecessorWaitingOnPruned(cfk.loadingPruned, waitingTxnId))
+                {
+                    readyToApply = waitingToApply = false;
+                }
+                else if (waitingKind == ExclusiveSyncPoint && hasFutureDependency && readyToApply)
+                {
+                    int w = Arrays.binarySearch(byId, waitingTxnId);
+                    if (w < 0) w = -1 - w;
+                    while (--w >= 0)
+                    {
+                        TxnInfo txn = byId[w];
+                        if (!txn.mayExecute()) continue;
+                        readyToApply &= txn.hasBeen(APPLIED);
+                        if (txn.isCommittedToExecute())
+                            executesAt = Timestamp.nonNullOrMax(executesAt, byId[w].executeAt);
+                    }
+                }
+            }
 
             if (!readyToApply)
             {
diff --git a/accord-core/src/main/java/accord/messages/Apply.java b/accord-core/src/main/java/accord/messages/Apply.java
index 862e2658..0288dfce 100644
--- a/accord-core/src/main/java/accord/messages/Apply.java
+++ b/accord-core/src/main/java/accord/messages/Apply.java
@@ -57,12 +57,12 @@ public class Apply extends TxnRequest<ApplyReply>
 
     public interface Factory
     {
-        Apply create(Kind kind, Id to, Topologies participates, TxnId txnId, FullRoute<?> route, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result);
+        Apply create(Kind kind, Id to, Topologies participates, TxnId txnId, Route<?> scope, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, FullRoute<?> fullRoute);
     }
 
     public static Factory wrapForExclusiveSyncPoint(Factory factory)
     {
-        return (kind, to, participates, txnId, route, txn, executeAt, deps, writes, result) -> {
+        return (kind, to, participates, txnId, sendTo, txn, executeAt, deps, writes, result, fullRoute) -> {
             while (true)
             {
                 long minEpoch = participates.oldestEpoch();
@@ -81,7 +81,7 @@ public class Apply extends TxnRequest<ApplyReply>
                     break;
             }
 
-            return factory.create(kind, to, participates, txnId, route, txn, executeAt, deps, writes, result);
+            return factory.create(kind, to, participates, txnId, sendTo, txn, executeAt, deps, writes, result, fullRoute);
         };
     }
 
@@ -95,26 +95,26 @@ public class Apply extends TxnRequest<ApplyReply>
 
     public enum Kind { Minimal, Maximal }
 
-    protected Apply(Kind kind, Id to, Topologies participates, TxnId txnId, FullRoute<?> route, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result)
+    protected Apply(Kind kind, Id to, Topologies participates, TxnId txnId, Route<?> sendTo, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, FullRoute<?> fullRoute)
     {
-        super(to, participates, route, txnId);
+        super(to, participates, sendTo, txnId);
         Invariants.checkState(txnId.kind() != Txn.Kind.Write || writes != null);
         // TODO (desired): it's wasteful to encode the full set of ranges owned by the recipient node;
         //     often it will be cheaper to include the FullRoute for Deps scope (or come up with some other safety-preserving encoding scheme)
         this.kind = kind;
         this.deps = deps.intersecting(scope);
         this.txn = kind == Kind.Maximal ? txn.intersecting(scope, true) : null;
-        this.fullRoute = kind == Kind.Maximal ? route : null;
+        this.fullRoute = kind == Kind.Maximal ? fullRoute : null;
         this.executeAt = executeAt;
         this.writes = writes;
         this.result = result;
     }
 
-    public static void sendMaximal(Node node, Id to, TxnId txnId, FullRoute<?> route, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result)
+    public static void sendMaximal(Node node, Id to, TxnId txnId, Route<?> sendTo, Txn txn, Timestamp executeAt, Deps deps, Writes writes, Result result, FullRoute<?> fullRoute)
     {
-        Topologies executes = executes(node, route, executeAt);
-        Topologies participates = participates(node, route, txnId, executeAt, executes);
-        node.send(to, applyMaximal(FACTORY, to, participates, txnId, route, txn, executeAt, deps, writes, result));
+        Topologies executes = executes(node, sendTo, executeAt);
+        Topologies participates = participates(node, sendTo, txnId, executeAt, executes);
+        node.send(to, applyMaximal(FACTORY, to, participates, txnId, sendTo, txn, executeAt, deps, writes, result, fullRoute));
     }
 
     public static Topologies executes(Node node, Unseekables<?> route, Timestamp executeAt)
@@ -127,9 +127,9 @@ public class Apply extends TxnRequest<ApplyReply>
         return txnId.epoch() == executeAt.epoch() ? executes : node.topology().preciseEpochs(route, txnId.epoch(), executeAt.epoch());
     }
 
-    public static Apply applyMaximal(Factory factory, Id to, Topologies participates, TxnId txnId, FullRoute<?> route, Txn txn, Timestamp executeAt, Deps stableDeps, Writes writes, Result result)
+    public static Apply applyMaximal(Factory factory, Id to, Topologies participates, TxnId txnId, Route<?> sendTo, Txn txn, Timestamp executeAt, Deps stableDeps, Writes writes, Result result, FullRoute<?> fullRoute)
     {
-        return factory.create(Kind.Maximal, to, participates, txnId, route, txn, executeAt, stableDeps, writes, result);
+        return factory.create(Kind.Maximal, to, participates, txnId, sendTo, txn, executeAt, stableDeps, writes, result, fullRoute);
     }
 
     protected Apply(Kind kind, TxnId txnId, Route<?> route, long waitForEpoch, Timestamp executeAt, PartialDeps deps, @Nullable PartialTxn txn, @Nullable FullRoute<?> fullRoute, Writes writes, Result result)
diff --git a/accord-core/src/main/java/accord/messages/CheckStatus.java b/accord-core/src/main/java/accord/messages/CheckStatus.java
index 24a32e0d..e4e5a0a8 100644
--- a/accord-core/src/main/java/accord/messages/CheckStatus.java
+++ b/accord-core/src/main/java/accord/messages/CheckStatus.java
@@ -64,6 +64,7 @@ import static accord.primitives.Status.Durability.Universal;
 import accord.primitives.Known;
 import accord.utils.async.Cancellable;
 
+import static accord.primitives.Status.Invalidated;
 import static accord.primitives.Status.NotDefined;
 import static accord.primitives.Status.Stable;
 import static accord.primitives.Status.Truncated;
@@ -310,7 +311,7 @@ public class CheckStatus extends AbstractRequest<CheckStatus.CheckStatusReply>
             }
 
             Known validForAll = map.computeValidForAll(routeOrParticipants);
-            if (withQuorum == HasQuorum && invalidIf.inferInvalidWithQuorum(finished.maxKnown()))
+            if (withQuorum == HasQuorum && invalidIf.inferInvalidWithQuorum(finished.minKnown()))
                 validForAll = validForAll.atLeast(Known.Invalidated);
 
             return finished.with(map.with(validForAll));
@@ -447,6 +448,11 @@ public class CheckStatus extends AbstractRequest<CheckStatus.CheckStatusReply>
             return map.foldl(Known::atLeast, Known.Nothing, i -> false);
         }
 
+        public Known minKnown()
+        {
+            return map.foldl(Known::nonNullOrMin, null, i -> false);
+        }
+
         @Override
         public MessageType type()
         {
diff --git a/accord-core/src/main/java/accord/messages/InformDurable.java b/accord-core/src/main/java/accord/messages/InformDurable.java
index 061849a9..7a9f76a3 100644
--- a/accord-core/src/main/java/accord/messages/InformDurable.java
+++ b/accord-core/src/main/java/accord/messages/InformDurable.java
@@ -75,6 +75,8 @@ public class InformDurable extends TxnRequest<Reply> implements PreLoadContext
     public Reply apply(SafeCommandStore safeStore)
     {
         StoreParticipants participants = StoreParticipants.update(safeStore, scope, txnId.epoch(), txnId, txnId.epoch());
+        if (txnId.toString().equals("[7,12610,9(RX),2]") && safeStore.commandStore().toString().equals("DelayedCommandStore{id=0,node=1}"))
+            System.out.println();
         SafeCommand safeCommand = safeStore.get(txnId, participants);
         if (safeCommand.current().is(Status.Truncated))
             return Ok;
diff --git a/accord-core/src/main/java/accord/messages/PreAccept.java b/accord-core/src/main/java/accord/messages/PreAccept.java
index 8a5fbf59..0b7a0efb 100644
--- a/accord-core/src/main/java/accord/messages/PreAccept.java
+++ b/accord-core/src/main/java/accord/messages/PreAccept.java
@@ -127,6 +127,9 @@ public class PreAccept extends WithUnsynced<PreAccept.PreAcceptReply>
                 if (command.saveStatus().compareTo(SaveStatus.PreAccepted) > 0)
                     return PreAcceptNack.INSTANCE;
 
+                if (command.executeAt().isRejected())
+                    return new PreAcceptOk(txnId, command.executeAt(), Deps.NONE);
+
                 Deps deps = calculateDeps(safeStore, txnId, participants, EpochSupplier.constant(minEpoch), txnId);
                 // NOTE: we CANNOT test whether we adopt a future dependency here because it might be that this command
                 // is guaranteed to not reach agreement, but that this replica is unaware of that fact and has pruned
diff --git a/accord-core/src/main/java/accord/messages/Propagate.java b/accord-core/src/main/java/accord/messages/Propagate.java
index f872d08b..c6df62bf 100644
--- a/accord-core/src/main/java/accord/messages/Propagate.java
+++ b/accord-core/src/main/java/accord/messages/Propagate.java
@@ -417,7 +417,7 @@ public class Propagate implements PreLoadContext, MapReduceConsume<SafeCommandSt
         {
             default: throw new AssertionError("Unhandled RedundantStatus: " + status);
             case NOT_OWNED:
-            case WAS_OWNED:
+            case WAS_OWNED_CLOSED:
             case SHARD_REDUNDANT:
             case LOCALLY_REDUNDANT:
                 purge(safeStore, safeCommand, null, ERASE, true);
diff --git a/accord-core/src/main/java/accord/messages/ReadData.java b/accord-core/src/main/java/accord/messages/ReadData.java
index 5e1d4635..1d40b8f9 100644
--- a/accord-core/src/main/java/accord/messages/ReadData.java
+++ b/accord-core/src/main/java/accord/messages/ReadData.java
@@ -63,7 +63,7 @@ public abstract class ReadData implements PreLoadContext, Request, MapReduceCons
 {
     private static final Logger logger = LoggerFactory.getLogger(ReadData.class);
 
-    private enum State { PENDING, RETURNED, OBSOLETE }
+    private enum State { PENDING, PENDING_OBSOLETE, RETURNED, OBSOLETE }
     protected enum StoreAction { WAIT, EXECUTE, OBSOLETE }
 
     public enum ReadType
@@ -176,6 +176,7 @@ public abstract class ReadData implements PreLoadContext, Request, MapReduceCons
                     this.cancel = cancel;
                     this.timeout = timeout;
                     return;
+                case PENDING_OBSOLETE:
                 case OBSOLETE:
                     timeout = null;
                 case RETURNED:
@@ -228,7 +229,7 @@ public abstract class ReadData implements PreLoadContext, Request, MapReduceCons
                     return status.compareTo(SaveStatus.Stable) >= 0 ? null : Insufficient;
 
                 case OBSOLETE:
-                    state = State.OBSOLETE;
+                    state = State.PENDING_OBSOLETE;
                     return Redundant;
 
                 case EXECUTE:
@@ -400,6 +401,7 @@ public abstract class ReadData implements PreLoadContext, Request, MapReduceCons
             case RETURNED:
                 throw illegalState("ReadOk was sent, yet ack called again");
 
+            case PENDING_OBSOLETE:
             case OBSOLETE:
                 logger.debug("Before the read completed successfully for txn {}, the result was marked obsolete", txnId);
                 return null;
@@ -418,7 +420,7 @@ public abstract class ReadData implements PreLoadContext, Request, MapReduceCons
         Cancellable clear;
         synchronized (this)
         {
-            if (state != State.PENDING)
+            if (state.compareTo(State.PENDING_OBSOLETE) > 0)
                 return false;
 
             state = State.OBSOLETE;
diff --git a/accord-core/src/main/java/accord/primitives/AbstractRanges.java b/accord-core/src/main/java/accord/primitives/AbstractRanges.java
index 141bded3..873e8c52 100644
--- a/accord-core/src/main/java/accord/primitives/AbstractRanges.java
+++ b/accord-core/src/main/java/accord/primitives/AbstractRanges.java
@@ -181,13 +181,6 @@ public abstract class AbstractRanges implements Iterable<Range>, Routables<Range
         }
     }
 
-    public Ranges without(Unseekables<?> keysOrRanges)
-    {
-        if (keysOrRanges.domain() == Routable.Domain.Key)
-            keysOrRanges = ((AbstractUnseekableKeys)keysOrRanges).toRanges();
-        return without((AbstractRanges) keysOrRanges);
-    }
-
     // returns ri in low 32 bits, ki in top, or -1 if no match found
     @Override
     public final long findNextIntersection(int ri, AbstractKeys<?> keys, int ki)
@@ -240,21 +233,13 @@ public abstract class AbstractRanges implements Iterable<Range>, Routables<Range
     /**
      * Subtracts the given set of ranges from this
      */
-    public Ranges without(Ranges that)
-    {
-        return without((AbstractRanges) that);
-    }
-
-    /**
-     * Subtracts the given set of ranges from this
-     */
-    private Ranges without(AbstractRanges that)
+    Range[] withoutInternal(AbstractRanges that)
     {
         if (that.isEmpty())
-            return this instanceof Ranges ? (Ranges)this : ofSortedAndDeoverlappedUnchecked(ranges);
+            return ranges;
 
         if (isEmpty() || that == this)
-            return EMPTY;
+            return EMPTY.ranges;
 
         ObjectBuffers<Range> cachedRanges = cachedRanges();
         Range[] result = null;
@@ -310,9 +295,9 @@ public abstract class AbstractRanges implements Iterable<Range>, Routables<Range
         }
 
         if (count == 0)
-            return EMPTY;
+            return EMPTY.ranges;
 
-        return ofSortedAndDeoverlappedUnchecked(cachedRanges.completeAndDiscard(result, count));
+        return cachedRanges.completeAndDiscard(result, count);
     }
 
     /**
diff --git a/accord-core/src/main/java/accord/primitives/KeyRoute.java b/accord-core/src/main/java/accord/primitives/KeyRoute.java
index 7970ccad..b03b64c2 100644
--- a/accord-core/src/main/java/accord/primitives/KeyRoute.java
+++ b/accord-core/src/main/java/accord/primitives/KeyRoute.java
@@ -57,6 +57,37 @@ public abstract class KeyRoute extends AbstractUnseekableKeys implements Route<R
         return new PartialKeyRoute(homeKey, mergedKeys);
     }
 
+    @Override
+    public KeyRoute without(Unseekables<?> keysOrRanges)
+    {
+        switch (keysOrRanges.domain())
+        {
+            default: throw new AssertionError("Unhandled domain: " + keysOrRanges.domain());
+            case Key:
+            {
+                AbstractUnseekableKeys that = (AbstractUnseekableKeys) keysOrRanges;
+                RoutingKey[] newKeys = SortedArrays.linearSubtract(this.keys, that.keys, cachedRoutingKeys());
+                return newKeys == keys ? this : new PartialKeyRoute(homeKey, newKeys);
+            }
+            case Range:
+            {
+                return without((AbstractRanges)keysOrRanges);
+            }
+        }
+    }
+
+    @Override
+    public KeyRoute without(Ranges ranges)
+    {
+        return without((AbstractRanges) ranges);
+    }
+
+    private KeyRoute without(AbstractRanges ranges)
+    {
+        RoutingKey[] newKeys = subtract(ranges, keys, RoutingKey[]::new);
+        return newKeys == keys ? this : new PartialKeyRoute(homeKey, newKeys);
+    }
+
     @SuppressWarnings("unchecked")
     @Override
     public Participants<RoutingKey> participants()
diff --git a/accord-core/src/main/java/accord/primitives/Keys.java b/accord-core/src/main/java/accord/primitives/Keys.java
index abfd62b5..3469db7d 100644
--- a/accord-core/src/main/java/accord/primitives/Keys.java
+++ b/accord-core/src/main/java/accord/primitives/Keys.java
@@ -262,16 +262,22 @@ public class Keys extends AbstractKeys<Key> implements Seekables<Key, Keys>
 
     public static Keys of(Set<? extends Key> keys)
     {
+        if (keys.size() == 0)
+            return EMPTY;
         return ofUnique(keys.toArray(new Key[0]));
     }
 
     public static Keys ofSorted(Key ... keys)
     {
+        if (keys.length == 0)
+            return EMPTY;
         return new Keys(SortedArrays.toUnique(keys));
     }
 
     public static Keys ofSortedUnique(Key ... keys)
     {
+        if (keys.length == 0)
+            return EMPTY;
         if (!isSortedUnique(keys))
             throw new IllegalArgumentException(Arrays.toString(keys) + " is not sorted");
         return new Keys(keys);
@@ -282,11 +288,6 @@ public class Keys extends AbstractKeys<Key> implements Seekables<Key, Keys>
         return ofSortedUnique(keys.toArray(new Key[0]));
     }
 
-    static Keys ofSortedUnchecked(Key ... keys)
-    {
-        return new Keys(keys);
-    }
-
     private Keys wrap(Key[] wrap, AbstractKeys<Key> that)
     {
         return wrap == keys ? this : wrap == that.keys && that instanceof Keys ? (Keys)that : new Keys(wrap);
diff --git a/accord-core/src/main/java/accord/primitives/Known.java b/accord-core/src/main/java/accord/primitives/Known.java
index 4b5fc6c5..0b934fa0 100644
--- a/accord-core/src/main/java/accord/primitives/Known.java
+++ b/accord-core/src/main/java/accord/primitives/Known.java
@@ -96,6 +96,10 @@ public class Known
         return selectOrCreate(that, maxRoute, maxDefinition, maxExecuteAt, maxDeps, maxOutcome);
     }
 
+    public static Known nonNullOrMin(Known a, Known b)
+    {
+        return a == null | b == null ? a == null ? b : a : a.min(b);
+    }
     public Known min(Known that)
     {
         Invariants.checkArgument(compatibleWith(that));
@@ -613,7 +617,7 @@ public class Known
 
         public boolean isOrWasKnown()
         {
-            return this == DefinitionKnown;
+            return this != DefinitionUnknown;
         }
 
         public Definition atLeast(Definition that)
diff --git a/accord-core/src/main/java/accord/primitives/LatestDeps.java b/accord-core/src/main/java/accord/primitives/LatestDeps.java
index 313eddb3..adae0e37 100644
--- a/accord-core/src/main/java/accord/primitives/LatestDeps.java
+++ b/accord-core/src/main/java/accord/primitives/LatestDeps.java
@@ -381,7 +381,6 @@ public class LatestDeps extends ReducingRangeMap<LatestDeps.LatestEntry>
             };
         }
 
-        // TODO (now): override tryMergeEqual
         static class MergeBuilder extends AbstractIntervalBuilder<RoutingKey, MergeEntry, Merge>
         {
             protected MergeBuilder(boolean inclusiveEnds, int capacity)
diff --git a/accord-core/src/main/java/accord/primitives/RangeDeps.java b/accord-core/src/main/java/accord/primitives/RangeDeps.java
index 4f8a8811..2ea91e46 100644
--- a/accord-core/src/main/java/accord/primitives/RangeDeps.java
+++ b/accord-core/src/main/java/accord/primitives/RangeDeps.java
@@ -80,7 +80,7 @@ import static accord.utils.SortedArrays.Search.FAST;
  * TODO (expected): keep only the latest exclusive sync point for a given range
  * TODO (expected): permit building out-of-order
  * TODO (expected): currently permitting duplicates
- * TODO (required): randomised testing of all iteration methods (just found a double increment bug)
+ * TODO (testing): randomised testing of all iteration methods
  */
 public class RangeDeps implements Iterable<Map.Entry<Range, TxnId>>
 {
diff --git a/accord-core/src/main/java/accord/primitives/RangeRoute.java b/accord-core/src/main/java/accord/primitives/RangeRoute.java
index 808461fc..cbc74d3e 100644
--- a/accord-core/src/main/java/accord/primitives/RangeRoute.java
+++ b/accord-core/src/main/java/accord/primitives/RangeRoute.java
@@ -19,6 +19,7 @@
 package accord.primitives;
 
 import accord.api.RoutingKey;
+import accord.primitives.Routable.Domain;
 import accord.utils.Invariants;
 
 import javax.annotation.Nonnull;
@@ -59,6 +60,24 @@ public abstract class RangeRoute extends AbstractRanges implements Route<Range>,
         return with((Unseekables<Range>) Ranges.of(withKey.asRange()));
     }
 
+    @Override
+    public RangeRoute without(Unseekables<?> keysOrRanges)
+    {
+        return without(keysOrRanges.domain() == Domain.Range ? (AbstractRanges) keysOrRanges : ((AbstractUnseekableKeys)keysOrRanges).toRanges());
+    }
+
+    @Override
+    public RangeRoute without(Ranges that)
+    {
+        return without((AbstractRanges) that);
+    }
+
+    private RangeRoute without(AbstractRanges that)
+    {
+        Range[] newRanges = withoutInternal(that);
+        return newRanges == ranges ? this : new PartialRangeRoute(homeKey, newRanges);
+    }
+
     @Override
     public Route<Range> withHomeKey()
     {
diff --git a/accord-core/src/main/java/accord/primitives/Ranges.java b/accord-core/src/main/java/accord/primitives/Ranges.java
index ed536abb..9e87c38f 100644
--- a/accord-core/src/main/java/accord/primitives/Ranges.java
+++ b/accord-core/src/main/java/accord/primitives/Ranges.java
@@ -175,6 +175,21 @@ public class Ranges extends AbstractRanges implements Iterable<Range>, Seekables
         return with(Ranges.of(withKey.asRange()));
     }
 
+    public Ranges without(Unseekables<?> keysOrRanges)
+    {
+        if (keysOrRanges.domain() == Routable.Domain.Key)
+            keysOrRanges = ((AbstractUnseekableKeys)keysOrRanges).toRanges();
+        return ofSortedAndDeoverlappedUnchecked(withoutInternal((AbstractRanges) keysOrRanges));
+    }
+
+    /**
+     * Subtracts the given set of ranges from this
+     */
+    public Ranges without(Ranges that)
+    {
+        return ofSortedAndDeoverlappedUnchecked(withoutInternal(that));
+    }
+
     @Override
     public UnseekablesKind kind()
     {
diff --git a/accord-core/src/main/java/accord/primitives/Route.java b/accord-core/src/main/java/accord/primitives/Route.java
index 63d85808..fb75ad4a 100644
--- a/accord-core/src/main/java/accord/primitives/Route.java
+++ b/accord-core/src/main/java/accord/primitives/Route.java
@@ -38,6 +38,8 @@ public interface Route<K extends Unseekable> extends Participants<K>
      */
     @Override
     Route<K> with(Participants<K> participants);
+    @Override Route<K> without(Ranges ranges);
+    @Override Route<K> without(Unseekables<?> without);
 
     @Override
     Route<K> slice(int from, int to);
diff --git a/accord-core/src/main/java/accord/primitives/RoutingKeys.java b/accord-core/src/main/java/accord/primitives/RoutingKeys.java
index c9f67cac..25e40d97 100644
--- a/accord-core/src/main/java/accord/primitives/RoutingKeys.java
+++ b/accord-core/src/main/java/accord/primitives/RoutingKeys.java
@@ -49,6 +49,8 @@ public class RoutingKeys extends AbstractUnseekableKeys implements Unseekables<R
 
     public static RoutingKeys of(RoutingKey ... keys)
     {
+        if (keys.length == 0)
+            return EMPTY;
         return new RoutingKeys(toUnique(sort(keys)));
     }
 
@@ -68,6 +70,8 @@ public class RoutingKeys extends AbstractUnseekableKeys implements Unseekables<R
 
     public static RoutingKeys ofSortedUnique(RoutingKey ... keys)
     {
+        if (keys.length == 0)
+            return EMPTY;
         checkArgument(isSortedUnique(keys));
         return new RoutingKeys(keys);
     }
diff --git a/accord-core/src/main/java/accord/primitives/Timestamp.java b/accord-core/src/main/java/accord/primitives/Timestamp.java
index da8cb733..0a9de552 100644
--- a/accord-core/src/main/java/accord/primitives/Timestamp.java
+++ b/accord-core/src/main/java/accord/primitives/Timestamp.java
@@ -37,7 +37,7 @@ public class Timestamp implements Comparable<Timestamp>, EpochSupplier
      * which we may also want to retain when merging in other contexts (such as in Deps).
      */
     private static final int MERGE_FLAGS = 0x8000;
-    // TODO (required): is this the correct set of identity bits?
+    // TODO (testing): is this the correct set of identity bits?
     private static final long IDENTITY_LSB = 0xFFFFFFFFFFFF001EL;
     public static final int IDENTITY_FLAGS = 0x001E;
     public static final long MAX_EPOCH = (1L << 48) - 1;
diff --git a/accord-core/src/main/java/accord/primitives/Txn.java b/accord-core/src/main/java/accord/primitives/Txn.java
index 99e18979..55645602 100644
--- a/accord-core/src/main/java/accord/primitives/Txn.java
+++ b/accord-core/src/main/java/accord/primitives/Txn.java
@@ -103,12 +103,7 @@ public interface Txn
         // TODO (expected): introduce a special kind of visible ExclusiveSyncPoint that creates a precise moment,
         //    and is therefore visible to all transactions.
         ExclusiveSyncPoint('X', true, true, true, true),
-
-        /**
-         * Used for local book-keeping only, not visible to any other replica or directly to other transactions.
-         * This is used to create pseudo transactions that take the place of dependencies that will be fulfilled by a bootstrap.
-         */
-        LocalOnly('L', false, false, true, false);
+        ;
 
         public enum Kinds
         {
@@ -198,11 +193,6 @@ public interface Txn
             return this == Read;
         }
 
-        public boolean isLocal()
-        {
-            return this == LocalOnly;
-        }
-
         public boolean isDurable()
         {
             return this != EphemeralRead;
diff --git a/accord-core/src/main/java/accord/topology/TopologyManager.java b/accord-core/src/main/java/accord/topology/TopologyManager.java
index da310314..8825fceb 100644
--- a/accord-core/src/main/java/accord/topology/TopologyManager.java
+++ b/accord-core/src/main/java/accord/topology/TopologyManager.java
@@ -638,7 +638,7 @@ public class TopologyManager
         return new Single(sorter, epochs.get(epoch).global);
     }
 
-    // TODO (required): test all of these methods when asking for epochs that have been cleaned up (and other code paths)
+    // TODO (testing): test all of these methods when asking for epochs that have been cleaned up (and other code paths)
     public Topologies withUnsyncedEpochs(Unseekables<?> select, Timestamp min, Timestamp max)
     {
         return withUnsyncedEpochs(select, min.epoch(), max.epoch());
diff --git a/accord-core/src/main/java/accord/utils/SortedArrays.java b/accord-core/src/main/java/accord/utils/SortedArrays.java
index f6d5e714..a1cfe6ef 100644
--- a/accord-core/src/main/java/accord/utils/SortedArrays.java
+++ b/accord-core/src/main/java/accord/utils/SortedArrays.java
@@ -748,15 +748,15 @@ public class SortedArrays
 
         while (keepFrom < keepTo && subtractFrom < subtractTo)
         {
-            I leftKey = keep[keepFrom];
-            I rightKey = subtract[subtractFrom];
-            int cmp = leftKey == rightKey ? 0 : comparator.compare(leftKey, rightKey);
+            I keepKey = keep[keepFrom];
+            I subtractKey = subtract[subtractFrom];
+            int cmp = keepKey == subtractKey ? 0 : comparator.compare(keepKey, subtractKey);
 
-            if (cmp > 0)
+            if (cmp < 0)
             {
                 result[resultSize++] = keep[keepFrom++];
             }
-            else if (cmp < 0)
+            else if (cmp > 0)
             {
                 ++subtractFrom;
             }
diff --git a/accord-core/src/main/java/accord/utils/ThreadPoolScheduler.java b/accord-core/src/main/java/accord/utils/ThreadPoolScheduler.java
index f26a94fd..f2409f41 100644
--- a/accord-core/src/main/java/accord/utils/ThreadPoolScheduler.java
+++ b/accord-core/src/main/java/accord/utils/ThreadPoolScheduler.java
@@ -101,7 +101,7 @@ public class ThreadPoolScheduler implements Scheduler
 
     public void stop()
     {
-        exec.shutdown();
+        exec.shutdownNow();
         try
         {
             if (!exec.awaitTermination(1L, TimeUnit.MINUTES))
diff --git a/accord-core/src/main/java/accord/utils/Timestamped.java b/accord-core/src/main/java/accord/utils/Timestamped.java
index fad231f2..3b7f60a3 100644
--- a/accord-core/src/main/java/accord/utils/Timestamped.java
+++ b/accord-core/src/main/java/accord/utils/Timestamped.java
@@ -73,4 +73,9 @@ public class Timestamped<T>
     {
         return toString.apply(data);
     }
+
+    public boolean equals(Timestamped<T> that, BiPredicate<T, T> equality)
+    {
+        return this.timestamp.equals(that.timestamp) && equality.test(this.data, that.data);
+    }
 }
diff --git a/accord-core/src/test/java/accord/KeysTest.java b/accord-core/src/test/java/accord/KeysTest.java
index 138de0d3..dcc3c3c6 100644
--- a/accord-core/src/test/java/accord/KeysTest.java
+++ b/accord-core/src/test/java/accord/KeysTest.java
@@ -19,19 +19,32 @@
 package accord;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.IntFunction;
 import java.util.stream.IntStream;
 
 import accord.api.Key;
+import accord.api.RoutingKey;
 import accord.impl.IntKey;
 import accord.impl.IntKey.Raw;
+import accord.primitives.AbstractKeys;
+import accord.primitives.Participants;
 import accord.primitives.Range;
 import accord.primitives.Ranges;
 import accord.primitives.Keys;
 
+import accord.primitives.RoutableKey;
+import accord.primitives.Routables;
+import accord.primitives.RoutingKeys;
 import accord.utils.Gen;
 import accord.utils.Gens;
+import accord.utils.RandomTestRunner;
+import org.agrona.collections.IntHashSet;
+
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
@@ -225,6 +238,51 @@ public class KeysTest
         });
     }
 
+    @Test
+    public void keysWithout()
+    {
+        without(IntKey::key, Key[]::new, Keys::of, Keys::without);
+    }
+
+    @Test
+    public void routingKeysWithout()
+    {
+        without(IntKey::routing, RoutingKey[]::new, RoutingKeys::of, RoutingKeys::without);
+    }
+
+    private <K extends RoutableKey, KS extends AbstractKeys<K>> void without(IntFunction<K> keyFactory,
+                                                                             IntFunction<K[]> arrayFactory,
+                                                                             Function<K[], KS> keysFactory,
+                                                                             BiFunction<KS, KS, Routables<K>> without)
+    {
+        final int maxSize = 100;
+        final int maxKey = 1000;
+        for (int test = 0 ; test < 10000 ; ++test)
+        {
+            RandomTestRunner.test().check(rs -> {
+                K[] keys = arrayFactory.apply(rs.nextInt(2, maxSize));
+                IntHashSet used = new IntHashSet();
+                for (int i = 0 ; i < keys.length ; ++i)
+                {
+                    int k = rs.nextInt(maxKey);
+                    while (!used.add(k)) k = rs.nextInt(maxKey);
+                    keys[i] = keyFactory.apply(k);
+                }
+                int addTo = rs.nextInt(1, keys.length);
+                int removeFrom = addTo - rs.nextInt(addTo);
+                KS add = keysFactory.apply(Arrays.copyOf(keys, addTo));
+                KS remove = keysFactory.apply(Arrays.copyOfRange(keys, removeFrom, keys.length));
+                Routables<K> result = without.apply(add, remove);
+                Assertions.assertEquals(removeFrom, result.size());
+                if (removeFrom == addTo)
+                    Assertions.assertSame(result, add);
+                Arrays.sort(keys, 0, removeFrom);
+                for (int i = 0 ; i < removeFrom ; ++i)
+                    Assertions.assertEquals(keys[i], result.get(i));
+            });
+        }
+    }
+
     @Test
     public void foldl()
     {
diff --git a/accord-core/src/test/java/accord/burn/BurnTest.java b/accord-core/src/test/java/accord/burn/BurnTest.java
index 4678cec3..bfbb7c7b 100644
--- a/accord-core/src/test/java/accord/burn/BurnTest.java
+++ b/accord-core/src/test/java/accord/burn/BurnTest.java
@@ -314,7 +314,7 @@ public class BurnTest
             RandomSource retryRandom = random.fork();
             retryBootstrap = retry -> {
                 long delay = retryRandom.nextInt(1, 15);
-                queue.add((PendingRunnable) retry::run, delay, TimeUnit.SECONDS);
+                queue.add(PendingRunnable.create(retry::run), delay, TimeUnit.SECONDS);
             };
         }
         IntSupplier coordinationDelays, progressDelays, timeoutDelays;
diff --git a/accord-core/src/test/java/accord/coordinate/tracking/FastPathTrackerReconciler.java b/accord-core/src/test/java/accord/coordinate/tracking/FastPathTrackerReconciler.java
index 95517ae0..ab39e5ad 100644
--- a/accord-core/src/test/java/accord/coordinate/tracking/FastPathTrackerReconciler.java
+++ b/accord-core/src/test/java/accord/coordinate/tracking/FastPathTrackerReconciler.java
@@ -28,7 +28,7 @@ import java.util.ArrayList;
 
 public class FastPathTrackerReconciler extends TrackerReconciler<FastPathShardTracker, FastPathTracker, FastPathTrackerReconciler.Rsp>
 {
-    enum Rsp { FAST, SLOW, FAIL }
+    enum Rsp { FAST, SLOW, DELAY, FAIL }
 
     FastPathTrackerReconciler(RandomSource random, Topologies topologies)
     {
@@ -48,6 +48,7 @@ public class FastPathTrackerReconciler extends TrackerReconciler<FastPathShardTr
             default: throw new AssertionError();
             case FAST: inflight.remove(from); return tracker.recordSuccess(from, true);
             case SLOW: inflight.remove(from); return tracker.recordSuccess(from, false);
+            case DELAY: return tracker.recordDelayed(from);
             case FAIL: inflight.remove(from); return tracker.recordFailure(from);
         }
     }
@@ -64,7 +65,7 @@ public class FastPathTrackerReconciler extends TrackerReconciler<FastPathShardTr
 
             case Success:
                 Assertions.assertTrue(tracker.all(FastPathShardTracker::hasReachedQuorum));
-                Assertions.assertTrue(tracker.all(shard -> shard.hasRejectedFastPath() || shard.hasMetFastPathCriteria()));
+                Assertions.assertTrue(tracker.all(shard -> shard.hasRejectedFastPath() || shard.hasMetFastPathCriteria() || shard.isFastPathDelayed()));
                 Assertions.assertFalse(tracker.any(FastPathShardTracker::hasFailed));
                 break;
 
diff --git a/accord-core/src/test/java/accord/coordinate/tracking/ReadTrackerReconciler.java b/accord-core/src/test/java/accord/coordinate/tracking/ReadTrackerReconciler.java
index 0f53bd48..13810a8e 100644
--- a/accord-core/src/test/java/accord/coordinate/tracking/ReadTrackerReconciler.java
+++ b/accord-core/src/test/java/accord/coordinate/tracking/ReadTrackerReconciler.java
@@ -37,6 +37,7 @@ public class ReadTrackerReconciler extends TrackerReconciler<ReadShardTracker, R
         public InFlightCapturingReadTracker(Topologies topologies)
         {
             super(topologies);
+            initialise();
         }
 
         @Override
diff --git a/accord-core/src/test/java/accord/coordinate/tracking/ReadTrackerTest.java b/accord-core/src/test/java/accord/coordinate/tracking/ReadTrackerTest.java
index 04eecf14..348cc6eb 100644
--- a/accord-core/src/test/java/accord/coordinate/tracking/ReadTrackerTest.java
+++ b/accord-core/src/test/java/accord/coordinate/tracking/ReadTrackerTest.java
@@ -62,6 +62,7 @@ public class ReadTrackerTest
         public TestReadTracker(Topologies topologies)
         {
             super(topologies);
+            Assertions.assertTrue(initialise());
         }
 
         @Override
diff --git a/accord-core/src/test/java/accord/impl/RemoteListenersTest.java b/accord-core/src/test/java/accord/impl/RemoteListenersTest.java
index 2b12039c..7f1f81b8 100644
--- a/accord-core/src/test/java/accord/impl/RemoteListenersTest.java
+++ b/accord-core/src/test/java/accord/impl/RemoteListenersTest.java
@@ -414,7 +414,7 @@ public class RemoteListenersTest
         @Override public CommandStore commandStore() { return commandStore; }
 
         @Override protected SafeCommand getInternal(TxnId txnId) { return null; }
-        @Override protected SafeCommand ifLoadedAndInitialisedAndNotErasedInternal(TxnId txnId) { return null; }
+        @Override protected SafeCommand ifLoadedInternal(TxnId txnId) { return null; }
         @Override protected SafeCommandsForKey getInternal(RoutingKey key) { return null;}
         @Override protected SafeCommandsForKey ifLoadedInternal(RoutingKey key) { return null;}
         @Override public SafeTimestampsForKey timestampsForKey(RoutingKey key) { return null; }
diff --git a/accord-core/src/test/java/accord/impl/basic/Cluster.java b/accord-core/src/test/java/accord/impl/basic/Cluster.java
index 56b7a970..3dd73e6f 100644
--- a/accord-core/src/test/java/accord/impl/basic/Cluster.java
+++ b/accord-core/src/test/java/accord/impl/basic/Cluster.java
@@ -29,7 +29,9 @@ import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.NavigableMap;
 import java.util.Set;
+import java.util.TreeMap;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
@@ -53,6 +55,7 @@ import accord.api.LocalConfig;
 import accord.api.MessageSink;
 import accord.api.RoutingKey;
 import accord.api.Scheduler;
+import accord.api.Scheduler.Scheduled;
 import accord.burn.BurnTestConfigurationService;
 import accord.burn.TopologyUpdates;
 import accord.burn.random.FrequentLargeRange;
@@ -82,7 +85,9 @@ import accord.local.CommandStore;
 import accord.local.DurableBefore;
 import accord.local.Node;
 import accord.local.Node.Id;
+import accord.local.RedundantBefore;
 import accord.local.TimeService;
+import accord.primitives.RoutableKey;
 import accord.primitives.SaveStatus;
 import accord.local.ShardDistributor;
 import accord.primitives.Seekables;
@@ -105,8 +110,10 @@ import accord.topology.TopologyRandomizer;
 import accord.utils.Gens;
 import accord.utils.Invariants;
 import accord.utils.RandomSource;
+import accord.utils.Timestamped;
 import accord.utils.async.AsyncChains;
 import accord.utils.async.AsyncResult;
+import org.agrona.collections.Int2ObjectHashMap;
 
 import static accord.impl.basic.Cluster.OverrideLinksKind.NONE;
 import static accord.impl.basic.Cluster.OverrideLinksKind.RANDOM_BIDIRECTIONAL;
@@ -122,7 +129,7 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS;
 import static java.util.concurrent.TimeUnit.SECONDS;
 import static java.util.stream.Collectors.toList;
 
-public class Cluster implements Scheduler
+public class Cluster
 {
     public static final Logger trace = LoggerFactory.getLogger("accord.impl.basic.Trace");
 
@@ -164,6 +171,56 @@ public class Cluster implements Scheduler
         }
     }
 
+    public class ClusterScheduler implements Scheduler
+    {
+        final int source;
+
+        ClusterScheduler(int source)
+        {
+            this.source = source;
+        }
+
+        @Override
+        public void now(Runnable run)
+        {
+            run.run();
+        }
+
+        @Override
+        public Scheduled recurring(Runnable run, long delay, TimeUnit units)
+        {
+            return recurring(run, () -> delay, units);
+        }
+
+        @Override
+        public Scheduled once(Runnable run, long delay, TimeUnit units)
+        {
+            RecurringPendingRunnable result = new RecurringPendingRunnable(source, null, run, () -> delay, units, false);
+            pending.add(result, delay, units);
+            return result;
+        }
+
+        @Override
+        public Scheduled selfRecurring(Runnable run, long delay, TimeUnit units)
+        {
+            RecurringPendingRunnable result = new RecurringPendingRunnable(source, null, run, () -> delay, units, true);
+            pending.add(result, delay, units);
+            return result;
+        }
+
+        public Scheduled recurring(Runnable run, LongSupplier delay, TimeUnit units)
+        {
+            RecurringPendingRunnable result = new RecurringPendingRunnable(source, pending, run, delay, units, true);
+            pending.add(result, delay.getAsLong(), units);
+            return result;
+        }
+
+        public void onDone(Runnable run)
+        {
+            Cluster.this.onDone(run);
+        }
+    }
+
     final Map<MessageType, Stats> statsMap = new HashMap<>();
 
     final RandomSource random;
@@ -177,7 +234,6 @@ public class Cluster implements Scheduler
     final Map<Id, NodeSink> sinks = new HashMap<>();
     final MessageListener messageListener;
     int clock;
-    int recurring;
     BiFunction<Id, Id, Link> links;
 
     public Cluster(RandomSource random, MessageListener messageListener, Supplier<PendingQueue> queueSupplier, Runnable checkFailures, Function<Id, Node> lookup, Function<Id, Journal> journalLookup, IntSupplier rf, Consumer<Packet> responseSink)
@@ -224,34 +280,36 @@ public class Cluster implements Scheduler
 
     boolean hasNonRecurring()
     {
-        boolean hasNonRecurring = false;
+        if (pending.hasNonRecurring())
+            return true;
+
         for (Pending p : pending)
         {
             if (!(p instanceof RecurringPendingRunnable))
                 continue;
-            RecurringPendingRunnable r = (RecurringPendingRunnable) p;
-            if (r.requeue.hasNonRecurring())
-            {
-                hasNonRecurring = true;
-                break;
-            }
+
+            RecurringPendingRunnable r = (RecurringPendingRunnable) p.origin();
+            if (r.requeue != null && r.requeue.hasNonRecurring())
+                return true;
         }
 
-        return hasNonRecurring;
+        return false;
     }
 
     public boolean processPending()
     {
         checkFailures.run();
         // All remaining tasks are recurring
-        if (recurring > 0 && pending.size() == recurring && !hasNonRecurring())
+        if (!hasNonRecurring())
             return false;
 
         Pending next = pending.poll();
         if (next == null)
             return false;
 
+        Pending.Global.setActiveOrigin(next);
         processNext(next);
+        Pending.Global.clearActiveOrigin();
 
         checkFailures.run();
         return true;
@@ -308,49 +366,11 @@ public class Cluster implements Scheduler
             trace.trace("{} DROP[{}] (from:{}, to:{}, {}:{}, body:{})", clock++, lookup.apply(to).epoch(), from, to, message instanceof Reply ? "replyTo" : "id", id, message);
     }
 
-    @Override
-    public Scheduled recurring(Runnable run, long delay, TimeUnit units)
-    {
-        return recurring(run, () -> delay, units);
-    }
-
-    @Override
-    public Scheduled once(Runnable run, long delay, TimeUnit units)
-    {
-        RecurringPendingRunnable result = new RecurringPendingRunnable(null, run, () -> delay, units, false);
-        pending.add(result, delay, units);
-        return result;
-    }
-
-    @Override
-    public Scheduled selfRecurring(Runnable run, long delay, TimeUnit units)
-    {
-        RecurringPendingRunnable result = new RecurringPendingRunnable(null, run, () -> delay, units, true);
-        pending.add(result, delay, units);
-        return result;
-    }
-
-    public Scheduled recurring(Runnable run, LongSupplier delay, TimeUnit units)
-    {
-        RecurringPendingRunnable result = new RecurringPendingRunnable(pending, run, delay, units, true);
-        ++recurring;
-        result.onCancellation(() -> --recurring);
-        pending.add(result, delay.getAsLong(), units);
-        return result;
-
-    }
-
     public void onDone(Runnable run)
     {
         onDone.add(run);
     }
 
-    @Override
-    public void now(Runnable run)
-    {
-        run.run();
-    }
-
     // TODO (expected): merge with BurnTest.burn
     public static Map<MessageType, Cluster.Stats> run(Supplier<RandomSource> randomSupplier,
                                                       List<Node.Id> nodes,
@@ -364,7 +384,7 @@ public class Cluster implements Scheduler
             RandomSource rnd = randomSupplier.get();
             retryBootstrap = retry -> {
                 long delay = rnd.nextInt(1, 15);
-                queue.add((PendingRunnable) retry::run, delay, TimeUnit.SECONDS);
+                queue.add(PendingRunnable.create(retry::run), delay, TimeUnit.SECONDS);
             };
         }
         IntSupplier coordinationDelays, progressDelays, timeoutDelays;
@@ -376,7 +396,7 @@ public class Cluster implements Scheduler
         RandomSource nowRandom = randomSupplier.get();
         Supplier<LongSupplier> nowSupplier = () -> {
             RandomSource forked = nowRandom.fork();
-            // TODO (now): meta-randomise scale of clock drift
+            // TODO (testing): meta-randomise scale of clock drift
             return FrequentLargeRange.builder(forked)
                                      .ratio(1, 5)
                                      .small(50, 5000, TimeUnit.MICROSECONDS)
@@ -467,6 +487,7 @@ public class Cluster implements Scheduler
             List<Service> services = new ArrayList<>();
             for (Id id : nodes)
             {
+                ClusterScheduler scheduler = sinks.new ClusterScheduler(id.id);
                 MessageSink messageSink = sinks.create(id, randomSupplier.get());
                 LongSupplier nowSupplier = nowSupplierSupplier.get();
                 LocalConfig localConfig = LocalConfig.DEFAULT;
@@ -478,9 +499,9 @@ public class Cluster implements Scheduler
                 BurnTestConfigurationService configService = new BurnTestConfigurationService(id, nodeExecutor, randomSupplier, topology, nodeMap::get, topologyUpdates);
                 BooleanSupplier isLoadedCheck = Gens.supplier(Gens.bools().mixedDistribution().next(random), random);
                 Node node = new Node(id, messageSink, configService, TimeService.ofNonMonotonic(nowSupplier, MILLISECONDS),
-                                     () -> new ListStore(sinks, random, id), new ShardDistributor.EvenSplit<>(8, ignore -> new PrefixedIntHashKey.Splitter()),
+                                     () -> new ListStore(scheduler, random, id), new ShardDistributor.EvenSplit<>(8, ignore -> new PrefixedIntHashKey.Splitter()),
                                      nodeExecutor.agent(),
-                                     randomSupplier.get(), sinks, SizeOfIntersectionSorter.SUPPLIER, DefaultRemoteListeners::new, DefaultTimeouts::new,
+                                     randomSupplier.get(), scheduler, SizeOfIntersectionSorter.SUPPLIER, DefaultRemoteListeners::new, DefaultTimeouts::new,
                                      DefaultProgressLogs::new, DefaultLocalListeners.Factory::new, DelayedCommandStores.factory(sinks.pending, isLoadedCheck, journal), new CoordinationAdapter.DefaultFactory(),
                                      DurableBefore.NOOP_PERSISTER, localConfig);
                 DurabilityScheduling durability = node.durabilityScheduling();
@@ -516,44 +537,35 @@ public class Cluster implements Scheduler
             while (sinks.processPending());
             Assertions.assertTrue(startup.isDone());
 
+            ClusterScheduler clusterScheduler = sinks.new ClusterScheduler(-1);
             List<Id> nodesList = new ArrayList<>(Arrays.asList(nodes));
-            Scheduled chaos = sinks.recurring(() -> {
+            Scheduled chaos = clusterScheduler.recurring(() -> {
                 sinks.links = sinks.linkConfig.overrideLinks.apply(nodesList);
                 if (random.decide(0.1f))
                     updateDurabilityRate.run();
             }, 5L, SECONDS);
 
-            Scheduled reconfigure = sinks.recurring(configRandomizer::maybeUpdateTopology, 1, SECONDS);
-
-            Scheduled purge = sinks.recurring(() -> {
-                trace.debug("Triggering purge.");
-                int numNodes = random.nextInt(1, nodeMap.size());
-                for (int i = 0; i < numNodes; i++)
-                {
-                    Id id = random.pick(nodes);
-                    Node node = nodeMap.get(id);
+            Scheduled reconfigure = clusterScheduler.recurring(configRandomizer::maybeUpdateTopology, 1, SECONDS);
 
-                    Journal journal = journalMap.get(node.id());
-                    CommandStore[] stores = nodeMap.get(node.id()).commandStores().all();
-                    journal.purge((j) -> stores[j]);
-                }
-            }, () -> random.nextInt(1, 10), SECONDS);
+            Purge purge = new Purge(clusterScheduler, random, nodesList, nodeMap, journalMap);
 
-            Scheduled restart = sinks.recurring(() -> {
+            Scheduled restart = clusterScheduler.recurring(() -> {
                 Id id = random.pick(nodes);
                 CommandStore[] stores = nodeMap.get(id).commandStores().all();
                 ((DelayedCommandStore)stores[0]).unsafeRunIn(() -> {
-                    Predicate<Pending> pred = getPendingPredicate(stores);
+                    Predicate<Pending> pred = getPendingPredicate(id.id, stores);
                     while (sinks.drain(pred));
 
                     // Journal cleanup is a rough equivalent of a node restart.
                     trace.debug("Triggering journal cleanup for node " + id);
                     CommandsForKey.disableLinearizabilityViolationsReporting();
                     ListStore listStore = (ListStore) nodeMap.get(id).commandStores().dataStore();
+                    NavigableMap<RoutableKey, Timestamped<int[]>> prevData = listStore.copyOfCurrentData();
                     listStore.clear();
                     listStore.restoreFromSnapshot();
 
                     Journal journal = journalMap.get(id);
+                    Int2ObjectHashMap<NavigableMap<TxnId, Command>> beforeStores = copyCommands(stores);
                     for (CommandStore s : stores)
                     {
                         DelayedCommandStores.DelayedCommandStore store = (DelayedCommandStores.DelayedCommandStore) s;
@@ -562,6 +574,8 @@ public class Cluster implements Scheduler
                     }
                     while (sinks.drain(pred));
                     CommandsForKey.enableLinearizabilityViolationsReporting();
+                    Invariants.checkState(listStore.equals(prevData));
+                    verifyConsistentRestore(beforeStores, stores);
                     trace.debug("Done with cleanup.");
                 });
             }, () -> random.nextInt(1, 10), SECONDS);
@@ -612,7 +626,128 @@ public class Cluster implements Scheduler
         }
     }
 
-    private static Predicate<Pending> getPendingPredicate(CommandStore[] stores)
+    private static class Purge
+    {
+        Scheduled scheduled;
+
+        Purge(Scheduler clusterScheduler, RandomSource rs, List<Id> nodes, Map<Id, Node> nodeMap, Map<Id, Journal> journalMap)
+        {
+            schedule(clusterScheduler, rs, nodes, nodeMap, journalMap);
+        }
+
+        void cancel()
+        {
+            scheduled.cancel();
+        }
+
+        private void schedule(Scheduler clusterScheduler, RandomSource rs, List<Id> nodes, Map<Id, Node> nodeMap, Map<Id, Journal> journalMap)
+        {
+            scheduled = clusterScheduler.selfRecurring(() -> run(clusterScheduler, rs, nodes, nodeMap, journalMap), rs.nextInt(1, 30), SECONDS);
+        }
+
+        private void run(Scheduler clusterScheduler, RandomSource rs, List<Id> nodes, Map<Id, Node> nodeMap, Map<Id, Journal> journalMap)
+        {
+            Id id = rs.pick(nodes);
+            Node node = nodeMap.get(id);
+
+            Journal journal = journalMap.get(node.id());
+            CommandStore[] stores = nodeMap.get(node.id()).commandStores().all();
+            // run on node scheduler so doesn't run during replay
+            scheduled = node.scheduler().selfRecurring(() -> {
+                journal.purge(j -> j < stores.length ? stores[j] : null);
+                schedule(clusterScheduler, rs, nodes, nodeMap, journalMap);
+            }, 0, SECONDS);
+        }
+
+    }
+
+    private static Int2ObjectHashMap<NavigableMap<TxnId, Command>> copyCommands(CommandStore[] stores)
+    {
+        Int2ObjectHashMap<NavigableMap<TxnId, Command>> result = new Int2ObjectHashMap<>();
+        for (CommandStore s : stores)
+        {
+            DelayedCommandStores.DelayedCommandStore store = (DelayedCommandStores.DelayedCommandStore) s;
+            NavigableMap<TxnId, Command> commands = new TreeMap<>();
+            result.put(store.id(), commands);
+            for (Map.Entry<TxnId, GlobalCommand> e : store.unsafeCommands().entrySet())
+                commands.put(e.getKey(), e.getValue().value());
+        }
+        return result;
+    }
+
+    private static void verifyConsistentRestore(Int2ObjectHashMap<NavigableMap<TxnId, Command>> beforeStores, CommandStore[] stores)
+    {
+        for (CommandStore s : stores)
+        {
+            DelayedCommandStores.DelayedCommandStore store = (DelayedCommandStores.DelayedCommandStore) s;
+            NavigableMap<TxnId, Command> before = beforeStores.get(store.id());
+            for (Map.Entry<TxnId, GlobalCommand> e : store.unsafeCommands().entrySet())
+            {
+                Command beforeCommand = before.get(e.getKey());
+                Command afterCommand = e.getValue().value();
+                if (beforeCommand == null)
+                {
+                    Invariants.checkArgument(afterCommand.is(Status.NotDefined));
+                    continue;
+                }
+                if (afterCommand.hasBeen(Status.Truncated))
+                {
+                    if (afterCommand.is(Status.Invalidated))
+                        Invariants.checkState(beforeCommand.hasBeen(Status.Truncated) || !beforeCommand.hasBeen(Status.PreCommitted)
+                                              && store.unsafeGetRedundantBefore().max(beforeCommand.participants().touches(), RedundantBefore.Entry::shardRedundantBefore).compareTo(beforeCommand.txnId()) >= 0);
+                    continue;
+                }
+                if (beforeCommand.hasBeen(Status.Truncated))
+                {
+                    Invariants.checkState(!beforeCommand.is(Status.Invalidated) || afterCommand.is(Status.Invalidated));
+                    Invariants.checkState(beforeCommand.is(Status.Invalidated) || afterCommand.is(Status.Truncated) || afterCommand.is(Status.Applied));
+                    continue;
+                }
+                Invariants.checkState(isConsistent(beforeCommand.saveStatus(), afterCommand.saveStatus())
+                    && beforeCommand.executeAtOrTxnId().equals(afterCommand.executeAtOrTxnId())
+                    && beforeCommand.acceptedOrCommitted().equals(afterCommand.acceptedOrCommitted())
+                    && beforeCommand.promised().equals(afterCommand.promised())
+                    && beforeCommand.durability().equals(afterCommand.durability()));
+            }
+            if (before.size() > store.unsafeCommands().size())
+            {
+                for (TxnId txnId : before.keySet())
+                {
+                    if (!store.unsafeCommands().containsKey(txnId))
+                    {
+                        Command beforeCommand = before.get(txnId);
+                        if (beforeCommand.saveStatus() == SaveStatus.Erased)
+                            continue;
+
+                        if (store.unsafeGetRedundantBefore().min(beforeCommand.participants().owns(), RedundantBefore.Entry::shardRedundantBefore).compareTo(txnId) > 0)
+                            continue;
+
+                        Invariants.checkState(false);
+                    }
+                }
+            }
+        }
+    }
+
+    private static boolean isConsistent(SaveStatus before, SaveStatus after)
+    {
+        if (before == after)
+            return true;
+
+        if (before == SaveStatus.Uninitialised || before == SaveStatus.NotDefined)
+            return after == SaveStatus.Uninitialised || after == SaveStatus.NotDefined;
+
+        // depending on arrival order, an unmanaged txn may be ready to execute immediately or have to wait for another transaction to commit
+        if (before == SaveStatus.Stable || before == SaveStatus.ReadyToExecute)
+            return after == SaveStatus.Stable || after == SaveStatus.ReadyToExecute;
+
+        if (before == SaveStatus.PreApplied || before == SaveStatus.Applying || before == SaveStatus.Applied)
+            return after == SaveStatus.PreApplied || after == SaveStatus.Applying || after == SaveStatus.Applied;
+
+        return false;
+    }
+
+    private static Predicate<Pending> getPendingPredicate(int nodeId, CommandStore[] stores)
     {
         Set<CommandStore> nodeStores = new HashSet<>(Arrays.asList(stores));
         return item -> {
@@ -621,6 +756,12 @@ public class Cluster implements Scheduler
                 DelayedCommandStore.DelayedTask<?> task = (DelayedCommandStore.DelayedTask<?>) item;
                 if (nodeStores.contains(task.parent()))
                     return true;
+                item = item.origin();
+            }
+            if (item instanceof RecurringPendingRunnable)
+            {
+                RecurringPendingRunnable recurring = (RecurringPendingRunnable) item;
+                return recurring.source == nodeId && (!recurring.isRecurring || recurring.origin() != recurring);
             }
             return false;
         };
diff --git a/accord-core/src/test/java/accord/impl/basic/DelayedCommandStores.java b/accord-core/src/test/java/accord/impl/basic/DelayedCommandStores.java
index e5cf16d5..04ac085d 100644
--- a/accord-core/src/test/java/accord/impl/basic/DelayedCommandStores.java
+++ b/accord-core/src/test/java/accord/impl/basic/DelayedCommandStores.java
@@ -29,12 +29,8 @@ import java.util.function.BiConsumer;
 import java.util.function.BooleanSupplier;
 import java.util.function.Consumer;
 import java.util.function.Function;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.google.common.collect.Iterables;
 
 import accord.api.Agent;
 import accord.api.DataStore;
@@ -74,40 +70,6 @@ import static accord.utils.Invariants.ParanoiaCostFactor.HIGH;
 
 public class DelayedCommandStores extends InMemoryCommandStores.SingleThread
 {
-    private static final Logger logger = LoggerFactory.getLogger(DelayedCommandStores.class);
-
-    //TODO (correctness): remove once we have a Journal integration that does not change the values of a command...
-    // There are known issues due to Journal, so exclude known problamtic fields
-    private static class ValidationHack
-    {
-        private static Pattern field(String path)
-        {
-            path = path.replace(".", "\\.");
-            path += ".*";
-            return Pattern.compile(path);
-        }
-
-        private static final List<Pattern> KNOWN_ISSUES = List.of(
-                                                                  // when a new epoch is detected and the execute ranges have more than the coordinating ranges,
-                                                                  // and the coordinating ranges doesn't include the home key... we drop the query...
-                                                                  // The logic to stitch messages together is not able to handle this as it doesn't know the original Topologies
-                                                                  // TODO (required): test int if this is still true
-//                                                                  field(".partialTxn.query."),
-                                                                  // cmd.mutable().build() != cmd.  This is due to Command.durability changing NotDurable to Local depending on the status
-                                                                  field(".durability."));
-    }
-
-    private static boolean hasKnownIssue(String path)
-    {
-        for (Pattern p : ValidationHack.KNOWN_ISSUES)
-        {
-            Matcher m = p.matcher(path);
-            if (m.find())
-                return true;
-        }
-        return false;
-    }
-
     private DelayedCommandStores(NodeCommandStoreService time, Agent agent, DataStore store, RandomSource random, ShardDistributor shardDistributor, ProgressLog.Factory progressLogFactory, LocalListeners.Factory listenersFactory, SimulatedDelayedExecutorService executorService, BooleanSupplier isLoadedCheck, Journal journal)
     {
         super(time, agent, store, random, shardDistributor, progressLogFactory, listenersFactory, DelayedCommandStore.factory(executorService, isLoadedCheck, journal));
@@ -193,8 +155,7 @@ public class DelayedCommandStores extends InMemoryCommandStores.SingleThread
             // Journal will not have result persisted. This part is here for test purposes and ensuring that we have strict object equality.
             Command reconstructed = journal.reconstruct(id, current.txnId());
             List<Difference<?>> diff = ReflectionUtils.recursiveEquals(current, reconstructed);
-            List<String> filteredDiff = diff.stream().filter(d -> !DelayedCommandStores.hasKnownIssue(d.path)).map(Object::toString).collect(Collectors.toList());
-            Invariants.checkState(filteredDiff.isEmpty(), "Commands did not match: expected %s, given %s, node %s, store %d, diff %s", current, reconstructed, node, id(), new LazyToString(() -> String.join("\n", filteredDiff)));
+            Invariants.checkState(diff.isEmpty(), "Commands did not match: expected %s, given %s, node %s, store %d, diff %s", current, reconstructed, node, id(), new LazyToString(() -> String.join("\n", Iterables.transform(diff, Object::toString))));
         }
 
         @Override
diff --git a/accord-core/src/test/java/accord/impl/basic/Journal.java b/accord-core/src/test/java/accord/impl/basic/Journal.java
index 66052112..27f9cb19 100644
--- a/accord-core/src/test/java/accord/impl/basic/Journal.java
+++ b/accord-core/src/test/java/accord/impl/basic/Journal.java
@@ -18,7 +18,9 @@
 
 package accord.impl.basic;
 
+import java.util.AbstractList;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -53,6 +55,8 @@ import accord.primitives.Writes;
 import accord.utils.Invariants;
 import org.agrona.collections.Long2ObjectHashMap;
 
+import static accord.primitives.SaveStatus.Erased;
+import static accord.primitives.SaveStatus.NotDefined;
 import static accord.primitives.SaveStatus.Stable;
 import static accord.primitives.Status.Invalidated;
 import static accord.primitives.Status.Truncated;
@@ -76,6 +80,8 @@ public class Journal
             int commandStoreId = e.getKey().intValue();
             Map<TxnId, List<Diff>> localJournal = e.getValue();
             CommandStore store = storeSupplier.apply(commandStoreId);
+            if (store == null)
+                continue;
 
             Map<TxnId, List<Diff>> updates = new HashMap<>();
             List<TxnId> removals = new ArrayList<>();
@@ -94,55 +100,114 @@ public class Journal
                     case INVALIDATE:
                     case TRUNCATE_WITH_OUTCOME:
                     case TRUNCATE:
+                    case ERASE:
+                        if (commandStoreId == 0 && id.id == 1 && txnId.toString().equals("[7,12610,9(RX),2]"))
+                            cleanup = Cleanup.shouldCleanup(store.agent(), command, store.unsafeGetRedundantBefore(), store.durableBefore());
                         command = Commands.purge(command, command.participants(), cleanup);
                         Invariants.checkState(command.saveStatus() != SaveStatus.Uninitialised);
-                        List<Diff> arr = new ArrayList<>();
-                        arr.add(diff(null, command));
-                        updates.put(txnId, arr);
+                        Diff diff = diff(null, command);
+                        e2.setValue(cleanup == Cleanup.ERASE ? new ErasedList(diff) : new TruncatedList(diff));
                         break;
-                    case ERASE:
-                        removals.add(txnId);
+
+                    case EXPUNGE:
+                        e2.setValue(new PurgedList());
                         break;
                 }
             }
-
-            for (TxnId removal : removals)
-                localJournal.remove(removal);
-            localJournal.putAll(updates);
         }
     }
 
-    // TODO (required): this might be a good first approximation, but maybe we need to make a better distinction between
-    // when we want to produce side-effects.
-    private boolean loading = false;
-
     public void reconstructAll(InMemoryCommandStore.Loader loader, int commandStoreId)
     {
-        Map<TxnId, List<Diff>> diffs = diffsPerCommandStore.get(commandStoreId);
-
         // Nothing to do here, journal is empty for this command store
-        if (diffs == null)
+        if (!diffsPerCommandStore.containsKey(commandStoreId))
             return;
 
-        loading = true;
-        try
+        // copy to avoid concurrent modification when appending to journal
+        Map<TxnId, List<Diff>> diffs = new TreeMap<>(diffsPerCommandStore.get(commandStoreId));
+        for (Map.Entry<TxnId, List<Diff>> e : diffs.entrySet())
+            e.setValue(new ArrayList<>(e.getValue()));
+
+        List<Command> toApply = new ArrayList<>();
+        for (Map.Entry<TxnId, List<Diff>> e : diffs.entrySet())
         {
-            List<Command> toApply = new ArrayList<>();
-            for (TxnId txnId : diffs.keySet())
-            {
-                Command command = reconstruct(commandStoreId, txnId);
-                if (command.saveStatus().compareTo(Stable) >= 0 && !command.hasBeen(Truncated))
-                    toApply.add(command);
-                loader.load(command);
-            }
+            if (e.getValue().isEmpty()) continue;
+            Command command = reconstruct(commandStoreId, e.getKey(), e.getValue());
+            if (command.saveStatus().compareTo(Stable) >= 0 && !command.hasBeen(Truncated))
+                toApply.add(command);
+            loader.load(command);
+        }
+
+        toApply.sort(Comparator.comparing(Command::executeAt));
+        for (Command command : toApply)
+            loader.apply(command);
+    }
+
+    static class ErasedList extends AbstractList<Diff>
+    {
+        final Diff erased;
+
+        ErasedList(Diff erased)
+        {
+            Invariants.checkArgument(erased.saveStatus.value == SaveStatus.Erased);
+            this.erased = erased;
+        }
+
+        @Override
+        public Diff get(int index)
+        {
+            if (index != 0)
+                throw new IndexOutOfBoundsException();
+            return erased;
+        }
+
+        @Override
+        public int size()
+        {
+            return 1;
+        }
 
-            toApply.sort(Comparator.comparing(Command::executeAt));
-            for (Command command : toApply)
-                loader.apply(command);
+        @Override
+        public boolean add(Diff diff)
+        {
+            if (diff.saveStatus != null && diff.saveStatus.value == SaveStatus.Erased)
+                return false;
+            throw illegalState();
         }
-        finally
+    }
+
+    static class TruncatedList extends ArrayList<Diff>
+    {
+        TruncatedList(Diff truncated)
         {
-            loading = false;
+            add(truncated);
+        }
+    }
+
+    static class PurgedList extends AbstractList<Diff>
+    {
+        PurgedList()
+        {
+        }
+
+        @Override
+        public Diff get(int index)
+        {
+            throw new IndexOutOfBoundsException();
+        }
+
+        @Override
+        public int size()
+        {
+            return 0;
+        }
+
+        @Override
+        public boolean add(Diff diff)
+        {
+            if (diff.saveStatus != null && diff.saveStatus.value == SaveStatus.Erased)
+                return false;
+            throw illegalState();
         }
     }
 
@@ -154,7 +219,11 @@ public class Journal
 
     public Command reconstruct(int commandStoreId, TxnId txnId)
     {
-        List<Diff> diffs = this.diffsPerCommandStore.get(commandStoreId).get(txnId);
+        return reconstruct(commandStoreId, txnId, diffsPerCommandStore.get(commandStoreId).get(txnId));
+    }
+
+    public Command reconstruct(int commandStoreId, TxnId txnId, List<Diff> diffs)
+    {
         return reconstruct(diffs, Reconstruct.Last).get(0);
     }
 
@@ -167,7 +236,7 @@ public class Journal
         TxnId txnId = null;
         Timestamp executeAt = null;
         Timestamp executesAtLeast = null;
-        SaveStatus saveStatus = null;
+        SaveStatus saveStatus = NotDefined;
         Status.Durability durability = Status.Durability.NotDurable;
 
         Ballot acceptedOrCommitted = Ballot.ZERO;
@@ -185,7 +254,7 @@ public class Journal
         {
             Diff diff = diffs.get(i);
             if (diff.txnId != null)
-                txnId = diff.txnId.get();
+                txnId = diff.txnId;
             if (diff.executeAt != null)
                 executeAt = diff.executeAt.get();
             if (diff.executesAtLeast != null)
@@ -229,6 +298,7 @@ public class Journal
             {
                 t.printStackTrace();
             }
+
             switch (saveStatus.known.outcome)
             {
                 case Erased:
@@ -329,15 +399,9 @@ public class Journal
 
     public void onExecute(int commandStoreId, Command before, Command after, boolean isPrimary)
     {
-        if (loading || (before == null && after == null))
+        if (before == null && after == null)
             return;
 
-        if (after.saveStatus() == SaveStatus.Erased)
-        {
-            diffsPerCommandStore.computeIfAbsent(commandStoreId, (k) -> new TreeMap<>())
-                                .remove(after.txnId());
-            return;
-        }
         Diff diff = diff(before, after);
         if (!isPrimary)
             diff = diff.asNonPrimary();
@@ -352,7 +416,7 @@ public class Journal
 
     private static class Diff
     {
-        public final NewValue<TxnId> txnId;
+        public final TxnId txnId;
 
         public final NewValue<Timestamp> executeAt;
         public final NewValue<Timestamp> executesAtLeast;
@@ -371,7 +435,7 @@ public class Journal
 
         public final NewValue<Result> result; // temporarily here for sakes for reloads
 
-        public Diff(NewValue<TxnId> txnId,
+        public Diff(TxnId txnId,
                     NewValue<Timestamp> executeAt,
                     NewValue<Timestamp> executesAtLeast,
                     NewValue<SaveStatus> saveStatus,
@@ -470,7 +534,7 @@ public class Journal
         if (Objects.equals(before, after))
             return null;
 
-        Diff diff = new Diff(ifNotEqual(before, after, Command::txnId, false),
+        Diff diff = new Diff(after.txnId(),
                              ifNotEqual(before, after, Command::executeAt, true),
                              ifNotEqual(before, after, Command::executesAtLeast, true),
                              ifNotEqual(before, after, Command::saveStatus, false),
@@ -543,6 +607,21 @@ public class Journal
         {
             return "" + value;
         }
+
+        @Override
+        public boolean equals(Object o)
+        {
+            if (this == o) return true;
+            if (o == null || getClass() != o.getClass()) return false;
+            NewValue<?> newValue = (NewValue<?>) o;
+            return Objects.equals(value, newValue.value);
+        }
+
+        @Override
+        public int hashCode()
+        {
+            throw new UnsupportedOperationException();
+        }
     }
 
 }
\ No newline at end of file
diff --git a/accord-core/src/test/java/accord/impl/basic/NodeSink.java b/accord-core/src/test/java/accord/impl/basic/NodeSink.java
index bfa4b3c9..8bd61a03 100644
--- a/accord-core/src/test/java/accord/impl/basic/NodeSink.java
+++ b/accord-core/src/test/java/accord/impl/basic/NodeSink.java
@@ -79,14 +79,14 @@ public class NodeSink implements MessageSink
         callbacks.put(messageId, sc);
         if (maybeEnqueue(to, messageId, send, sc))
         {
-            parent.pending.add((PendingRunnable) () -> {
+            parent.pending.add(PendingRunnable.create(() -> {
                 if (sc == callbacks.get(messageId))
                     sc.slowResponse(to);
-            }, 100 + random.nextInt(200), MILLISECONDS);
-            parent.pending.add((PendingRunnable) () -> {
+            }), 100 + random.nextInt(200), MILLISECONDS);
+            parent.pending.add(PendingRunnable.create(() -> {
                 if (sc == callbacks.remove(messageId))
                     sc.timeout(to);
-            }, 1000 + random.nextInt(1000), MILLISECONDS);
+            }), 1000 + random.nextInt(1000), MILLISECONDS);
         }
     }
 
@@ -120,12 +120,12 @@ public class NodeSink implements MessageSink
                     parent.notifyDropped(self, to, id, message);
                 if (callback != null)
                 {
-                    parent.pending.add((PendingRunnable) () -> {
+                    parent.pending.add(PendingRunnable.create(() -> {
                         if (callback == callbacks.remove(id))
                         {
                             try
                             {
-                                // TODO (now): we MUST drop any ACTUAL reply now
+                                // TODO (required): we MUST drop any ACTUAL reply now
                                 callback.failure(to, new SimulatedFault("Simulation Failure; src=" + self + ", to=" + to + ", id=" + id + ", message=" + message));
                             }
                             catch (Throwable t)
@@ -134,11 +134,11 @@ public class NodeSink implements MessageSink
                                 lookup.apply(self).agent().onUncaughtException(t);
                             }
                         }
-                    }, 1000 + random.nextInt(1000), MILLISECONDS);
+                    }), 1000 + random.nextInt(1000), MILLISECONDS);
                 }
                 return false;
             case DROP:
-                // TODO (consistency): parent.notifyDropped is a trace logger that is very similar in spirit to MessageListener; can we unify?
+                // TODO (desired): parent.notifyDropped is a trace logger that is very similar in spirit to MessageListener; can we unify?
                 parent.notifyDropped(self, to, id, message);
                 return true;
             default:
diff --git a/accord-core/src/test/java/accord/impl/basic/Packet.java b/accord-core/src/test/java/accord/impl/basic/Packet.java
index dc7fd567..698552b6 100644
--- a/accord-core/src/test/java/accord/impl/basic/Packet.java
+++ b/accord-core/src/test/java/accord/impl/basic/Packet.java
@@ -29,6 +29,7 @@ public class Packet implements Pending, ReplyContext
 {
     static final int SENTINEL_MESSAGE_ID = Integer.MIN_VALUE;
 
+    final Pending origin = Pending.Global.activeOrigin();
     public final Id src;
     public final Id dst;
     public final long requestId; // if message is Reply, this is the id of the message we are replying to
@@ -53,6 +54,12 @@ public class Packet implements Pending, ReplyContext
         this.message = reply;
     }
 
+    @Override
+    public Pending origin()
+    {
+        return origin;
+    }
+
     @Override
     public String toString()
     {
diff --git a/accord-core/src/test/java/accord/impl/basic/Pending.java b/accord-core/src/test/java/accord/impl/basic/Pending.java
index 7aadb5c9..8acfd5b4 100644
--- a/accord-core/src/test/java/accord/impl/basic/Pending.java
+++ b/accord-core/src/test/java/accord/impl/basic/Pending.java
@@ -18,6 +18,28 @@
 
 package accord.impl.basic;
 
+import accord.utils.Invariants;
+
 public interface Pending
 {
+    Pending origin();
+
+    // a slightly hacky but easy way to track transitive recurring tasks
+    class Global
+    {
+        private static Pending activeOrigin;
+        public static void setActiveOrigin(Pending newActive)
+        {
+            Invariants.checkState(activeOrigin == null);
+            activeOrigin = newActive.origin();
+        }
+        public static void clearActiveOrigin()
+        {
+            activeOrigin = null;
+        }
+        public static Pending activeOrigin()
+        {
+            return activeOrigin;
+        }
+    }
 }
diff --git a/accord-core/src/test/java/accord/impl/basic/PendingRunnable.java b/accord-core/src/test/java/accord/impl/basic/PendingRunnable.java
index 0ef0c989..15a0eb7f 100644
--- a/accord-core/src/test/java/accord/impl/basic/PendingRunnable.java
+++ b/accord-core/src/test/java/accord/impl/basic/PendingRunnable.java
@@ -20,4 +20,22 @@ package accord.impl.basic;
 
 public interface PendingRunnable extends Pending, Runnable
 {
+    static PendingRunnable create(Runnable run)
+    {
+        Pending origin = Global.activeOrigin();
+        return new PendingRunnable()
+        {
+            @Override
+            public Pending origin()
+            {
+                return origin;
+            }
+
+            @Override
+            public void run()
+            {
+                run.run();
+            }
+        };
+    }
 }
diff --git a/accord-core/src/test/java/accord/impl/basic/RandomDelayQueue.java b/accord-core/src/test/java/accord/impl/basic/RandomDelayQueue.java
index a90f150a..3708c8cf 100644
--- a/accord-core/src/test/java/accord/impl/basic/RandomDelayQueue.java
+++ b/accord-core/src/test/java/accord/impl/basic/RandomDelayQueue.java
@@ -32,6 +32,7 @@ import accord.impl.basic.DelayedCommandStores.DelayedCommandStore.DelayedTask;
 import accord.utils.DefaultRandom;
 import accord.utils.RandomSource;
 
+import static accord.impl.basic.RecurringPendingRunnable.isRecurring;
 import static accord.utils.Invariants.illegalArgument;
 import static accord.utils.Invariants.illegalState;
 
@@ -169,7 +170,9 @@ public class RandomDelayQueue implements PendingQueue
         for (Item item : items)
         {
             if (toDrain.test(item.item))
+            {
                 ret.add(item.item);
+            }
             else
             {
                 queue.add(item);
@@ -301,9 +304,4 @@ public class RandomDelayQueue implements PendingQueue
             this.seed = seed;
         }
     }
-
-    private static boolean isRecurring(Pending pending)
-    {
-        return pending instanceof RecurringPendingRunnable && ((RecurringPendingRunnable) pending).isRecurring;
-    }
 }
diff --git a/accord-core/src/test/java/accord/impl/basic/RecurringPendingRunnable.java b/accord-core/src/test/java/accord/impl/basic/RecurringPendingRunnable.java
index 6dbfd754..257f6387 100644
--- a/accord-core/src/test/java/accord/impl/basic/RecurringPendingRunnable.java
+++ b/accord-core/src/test/java/accord/impl/basic/RecurringPendingRunnable.java
@@ -25,6 +25,7 @@ import accord.api.Scheduler.Scheduled;
 
 class RecurringPendingRunnable implements PendingRunnable, Scheduled
 {
+    final int source;
     final PendingQueue requeue;
     final LongSupplier delay;
     final TimeUnit units;
@@ -32,8 +33,9 @@ class RecurringPendingRunnable implements PendingRunnable, Scheduled
     Runnable run;
     Runnable onCancellation;
 
-    RecurringPendingRunnable(PendingQueue requeue, Runnable run, LongSupplier delay, TimeUnit units, boolean isRecurring)
+    RecurringPendingRunnable(int source, PendingQueue requeue, Runnable run, LongSupplier delay, TimeUnit units, boolean isRecurring)
     {
+        this.source = source;
         this.requeue = requeue;
         this.run = run;
         this.delay = delay;
@@ -41,6 +43,12 @@ class RecurringPendingRunnable implements PendingRunnable, Scheduled
         this.isRecurring = isRecurring;
     }
 
+    @Override
+    public Pending origin()
+    {
+        return this;
+    }
+
     @Override
     public void run()
     {
@@ -87,4 +95,10 @@ class RecurringPendingRunnable implements PendingRunnable, Scheduled
 
         return run + " with " + delay + " " + units + " delay";
     }
+
+    public static boolean isRecurring(Pending pending)
+    {
+        Pending origin = pending.origin();
+        return origin instanceof RecurringPendingRunnable && ((RecurringPendingRunnable) origin).isRecurring;
+    }
 }
diff --git a/accord-core/src/test/java/accord/impl/basic/TaskExecutorService.java b/accord-core/src/test/java/accord/impl/basic/TaskExecutorService.java
index 0e733095..286d34da 100644
--- a/accord-core/src/test/java/accord/impl/basic/TaskExecutorService.java
+++ b/accord-core/src/test/java/accord/impl/basic/TaskExecutorService.java
@@ -34,11 +34,17 @@ public abstract class TaskExecutorService extends AbstractExecutorService implem
 {
     public static class Task<T> extends AsyncResults.RunnableResult<T> implements Pending, RunnableFuture<T>
     {
+        final Pending origin = Pending.Global.activeOrigin();
         public Task(Callable<T> fn)
         {
             super(fn);
         }
 
+        public Pending origin()
+        {
+            return origin;
+        }
+
         @Override
         public boolean cancel(boolean mayInterruptIfRunning)
         {
diff --git a/accord-core/src/test/java/accord/impl/list/ListAgent.java b/accord-core/src/test/java/accord/impl/list/ListAgent.java
index bb1b04c8..6fcfb181 100644
--- a/accord-core/src/test/java/accord/impl/list/ListAgent.java
+++ b/accord-core/src/test/java/accord/impl/list/ListAgent.java
@@ -152,7 +152,7 @@ public class ListAgent implements Agent
     @Override
     public long attemptCoordinationDelay(Node node, SafeCommandStore safeStore, TxnId txnId, TimeUnit units, int retryCount)
     {
-        // TODO (required): meta randomise
+        // TODO (testing): meta randomise
         return units.convert(rnd.nextInt(100, 1000), MILLISECONDS);
     }
 
@@ -172,7 +172,7 @@ public class ListAgent implements Agent
     @Override
     public long expiresAt(ReplyContext replyContext, TimeUnit unit)
     {
-        // TODO (required): implement this (add it to the replyContext)
+        // TODO (testing): implement this (add it to the replyContext)
         return -1;
     }
 
diff --git a/accord-core/src/test/java/accord/impl/list/ListFetchCoordinator.java b/accord-core/src/test/java/accord/impl/list/ListFetchCoordinator.java
index c7ffc2c6..340b6077 100644
--- a/accord-core/src/test/java/accord/impl/list/ListFetchCoordinator.java
+++ b/accord-core/src/test/java/accord/impl/list/ListFetchCoordinator.java
@@ -65,7 +65,7 @@ public class ListFetchCoordinator extends AbstractFetchCoordinator
         ListData listData = (ListData) data;
         persisting.add(commandStore.execute(PreLoadContext.empty(), safeStore -> {
             listData.forEach((key, value) -> listStore.data.merge(key, value, Timestamped::merge));
-        }).flatMap(ignore -> listStore.snapshot(received, syncPoint.syncId)).addCallback((success, fail) -> {
+        }).flatMap(ignore -> listStore.snapshot(true, received, syncPoint.syncId)).addCallback((success, fail) -> {
             if (fail == null) success(from, received);
             else fail(from, received, fail);
         }).beginAsResult());
diff --git a/accord-core/src/test/java/accord/impl/list/ListRequest.java b/accord-core/src/test/java/accord/impl/list/ListRequest.java
index 46ac4c2b..acb9270e 100644
--- a/accord-core/src/test/java/accord/impl/list/ListRequest.java
+++ b/accord-core/src/test/java/accord/impl/list/ListRequest.java
@@ -226,7 +226,15 @@ public class ListRequest implements Request
                         node.reply(client, replyContext, ListResult.lost(client, ((Packet)replyContext).requestId, txnId), null);
                         break;
                     case Other:
-                        node.reply(client, replyContext, ListResult.other(client, ((Packet)replyContext).requestId, txnId), null);
+                        if (attempt < 100)
+                        {
+                            node.reply(client, replyContext, ListResult.heartBeat(client, ((Packet)replyContext).requestId, txnId), null);
+                            node.scheduler().once(() -> checkOnResult(finalHomeKey, txnId, attempt + 1, null), 5L, TimeUnit.MINUTES);
+                        }
+                        else
+                        {
+                            node.reply(client, replyContext, ListResult.other(client, ((Packet)replyContext).requestId, txnId), null);
+                        }
                         break;
                     default:
                         node.agent().onUncaughtException(new AssertionError("Unknown outcome: " + s));
diff --git a/accord-core/src/test/java/accord/impl/list/ListResult.java b/accord-core/src/test/java/accord/impl/list/ListResult.java
index c9da1719..adfa1fe3 100644
--- a/accord-core/src/test/java/accord/impl/list/ListResult.java
+++ b/accord-core/src/test/java/accord/impl/list/ListResult.java
@@ -155,7 +155,7 @@ public class ListResult implements Result, Reply
                + "requestId:" + requestId + ", "
                + "txnId:" + txnId + ", "
                + (responseKeys == null
-                  ? (read == null ? "invalidated!}" : read.length == 0 ? "unknown}" : "lost}")
+                  ? status.toString() + '}'
                   : "reads:" + IntStream.range(0, responseKeys.size())
                                       .mapToObj(i -> responseKeys.get(i) + ":" + Arrays.toString(read[i]))
                                       .collect(Collectors.joining(", ", "{", "}")) + ", "
diff --git a/accord-core/src/test/java/accord/impl/list/ListStore.java b/accord-core/src/test/java/accord/impl/list/ListStore.java
index 3671e3b6..179d00d1 100644
--- a/accord-core/src/test/java/accord/impl/list/ListStore.java
+++ b/accord-core/src/test/java/accord/impl/list/ListStore.java
@@ -22,6 +22,7 @@ import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Deque;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.NavigableMap;
@@ -179,27 +180,44 @@ public class ListStore implements DataStore
 
     private static final class PendingSnapshot
     {
+        // we don't restart bootstraps after clearing journal state and replaying, so must finish snapshots
+        final boolean runBeforeRestart;
         final long delay;
         final Consumer<Boolean> onCompletion;
 
-        private PendingSnapshot(long delay, Consumer<Boolean> onCompletion)
+        private PendingSnapshot(boolean runBeforeRestart, long delay, Consumer<Boolean> onCompletion)
         {
+            this.runBeforeRestart = runBeforeRestart;
             this.delay = delay;
             this.onCompletion = onCompletion;
         }
     }
 
     private Snapshot snapshot;
+    private Scheduler.Scheduled scheduled;
     private final Deque<PendingSnapshot> pendingSnapshots = new ArrayDeque<>();
     private long pendingDelay = 0;
 
+    @Override
     public AsyncResult<Void> snapshot(Ranges ranges, TxnId before)
+    {
+        return snapshot(false, ranges, before);
+    }
+
+    public AsyncResult<Void> snapshot(boolean runBeforeRestart, Ranges ranges, TxnId before)
     {
         Snapshot snapshot = new Snapshot(data, addedAts, removedAts, purgedAts, fetchCompletes, pendingRemoves);
         AsyncResult.Settable<Void> result = new AsyncResults.SettableResult<>();
         long delay = Math.max(1, random.nextBiasedLong(100, 1000, 5000) - pendingDelay);
         pendingDelay += delay;
-        pendingSnapshots.add(new PendingSnapshot(delay, success -> {
+
+        if (scheduled != null && runBeforeRestart && !pendingSnapshots.stream().anyMatch(p -> p.runBeforeRestart))
+        {
+            scheduled.cancel();
+            scheduled = null;
+        }
+
+        pendingSnapshots.add(new PendingSnapshot(runBeforeRestart, delay, success -> {
             if (success)
             {
                 this.snapshot = snapshot;
@@ -211,7 +229,7 @@ public class ListStore implements DataStore
             }
         }));
 
-        if (pendingSnapshots.size() == 1)
+        if (scheduled == null)
             scheduleRunSnapshot();
         return result;
     }
@@ -219,7 +237,9 @@ public class ListStore implements DataStore
     private void scheduleRunSnapshot()
     {
         Invariants.checkState(!pendingSnapshots.isEmpty());
-        scheduler.once(() -> {
+        // schedule as recurring so that we don't run them
+        Runnable run = () -> {
+            scheduled = null;
             if (pendingSnapshots.isEmpty())
                 return;
 
@@ -228,7 +248,10 @@ public class ListStore implements DataStore
             pendingDelay -= pendingSnapshot.delay;
             if (!pendingSnapshots.isEmpty())
                 scheduleRunSnapshot();
-        }, pendingSnapshots.peekFirst().delay, TimeUnit.MILLISECONDS);
+        };
+
+        if (pendingSnapshots.stream().anyMatch(p -> p.runBeforeRestart)) scheduled = scheduler.once(run, pendingSnapshots.peekFirst().delay, TimeUnit.MILLISECONDS);
+        else scheduled = scheduler.selfRecurring(run, pendingSnapshots.peekFirst().delay, TimeUnit.MILLISECONDS);
     }
 
     public void restoreFromSnapshot()
@@ -297,10 +320,16 @@ public class ListStore implements DataStore
     private void checkAccess(Timestamp executeAt, Key key)
     {
         if (!allowed.contains(key))
-            throw new IllegalStateException(String.format("Attempted to access key %s on node %s, which is not in the range %s;\nexecuteAt = %s\n%s",
-                                                          key, node, allowed,
-                                                          executeAt,
-                                                          history(key)));
+        {
+            // TODO (expected): improve this validation logic
+            // but in the meantime, whitelist valid things, e.g. ephemeral reads can access data that has been retired
+            if (executeAt instanceof TxnId && ((TxnId) executeAt).awaitsOnlyDeps()
+                && removedAts.stream().anyMatch(r -> r.ranges.contains(key) && r.epoch > executeAt.epoch()))
+                return;
+
+            throw illegalState("Attempted to access key %s on node %s, which is not in the range %s;\nexecuteAt = %s\n%s",
+                               key, node, allowed, executeAt, history(key));
+        }
     }
 
     private void checkAccess(Timestamp executeAt, Range range)
@@ -462,6 +491,34 @@ public class ListStore implements DataStore
         return Timestamped.mergeEqual(a, b, Arrays::equals);
     }
 
+    public NavigableMap<RoutableKey, Timestamped<int[]>> copyOfCurrentData()
+    {
+        return new TreeMap<>(data);
+    }
+
+    public boolean equals(NavigableMap<RoutableKey, Timestamped<int[]>> a)
+    {
+        return equal(a, data);
+    }
+
+    public static boolean equal(NavigableMap<RoutableKey, Timestamped<int[]>> a, NavigableMap<RoutableKey, Timestamped<int[]>> b)
+    {
+        Iterator<Map.Entry<RoutableKey, Timestamped<int[]>>> aiter = a.entrySet().iterator();
+        Iterator<Map.Entry<RoutableKey, Timestamped<int[]>>> biter = b.entrySet().iterator();
+        while (aiter.hasNext() && biter.hasNext())
+        {
+            Map.Entry<RoutableKey, Timestamped<int[]>> av = aiter.next();
+            Map.Entry<RoutableKey, Timestamped<int[]>> bv = biter.next();
+            if (!av.getKey().equals(bv.getKey()))
+                return false;
+            if (!av.getValue().equals(bv.getValue(), Arrays::equals))
+                return false;
+        }
+        if (aiter.hasNext() || biter.hasNext())
+            return false;
+        return true;
+    }
+
     private static boolean isStrictPrefix(int[] a, int[] b)
     {
         if (a.length >= b.length)
@@ -531,7 +588,7 @@ public class ListStore implements DataStore
     private void runWhenReady(Node node, long epoch, Runnable whenKnown)
     {
         if (node.topology().epoch() >= epoch) whenKnown.run();
-        else                                  node.scheduler().once(() -> runWhenReady(node, epoch, whenKnown), 10, TimeUnit.SECONDS);
+        else                                  node.scheduler().selfRecurring(() -> runWhenReady(node, epoch, whenKnown), 10, TimeUnit.SECONDS);
     }
 
     private void removeLocalWhenReady(Node node, long epoch, Ranges removed)
@@ -567,16 +624,9 @@ public class ListStore implements DataStore
         pendingRemoves.remove(epoch);
         this.allowed = this.allowed.without(removed);
         purgedAts.add(new PurgeAt(s, epoch, removed));
-        // C* encodes keyspace/table within a Range, so Ranges being added/removed to the cluster are expected behaviors and not just local range movements.  To better simulate that
-        // this logic attempts to purge the data once we know its "safe" (no read/writes pending).
-        // The assumption in the C* case is that we will be able to do similar logic when integrating with Transactional Cluster Metadata (TCM).  The case there is that Epoch is owned by TCM
-        // and C* will start applying changes outside the context of Accord (hence why this logic uses callbacks before Accord sees the topology), so there exists an assumption: we will be able
-        // to delay local removal of data (drop keyspace/table) on accord txn state!
-        for (Range range : removed)
-        {
-            NavigableMap<RoutableKey, Timestamped<int[]>> historicData = data.subMap(range.start(), range.startInclusive(), range.end(), range.endInclusive());
-            historicData.clear();
-        }
+        // C* encodes keyspace/table within a Range, so Ranges being added/removed to the cluster are expected behaviors and not just local range movements.
+        // however, there is no reason to erase old data as it being used should be detected as a violation due to being stale,
+        // and clearing data unnecessarily complicates journal replay
 
         List<Runnable> callbacks = new ArrayList<>(onRemovalDone);
         onRemovalDone.clear();
diff --git a/accord-core/src/test/java/accord/impl/mock/MockCluster.java b/accord-core/src/test/java/accord/impl/mock/MockCluster.java
index c125f9e1..7604548b 100644
--- a/accord-core/src/test/java/accord/impl/mock/MockCluster.java
+++ b/accord-core/src/test/java/accord/impl/mock/MockCluster.java
@@ -107,7 +107,11 @@ public class MockCluster implements Network, AutoCloseable, Iterable<Node>
     @Override
     public void close()
     {
-        nodes.values().forEach(Node::shutdown);
+        nodes.values().forEach(n -> {
+            n.shutdown();
+            ((ThreadPoolScheduler)n.scheduler()).stop();
+        });
+
     }
 
     private synchronized Id nextNodeId()
diff --git a/accord-core/src/test/java/accord/local/CommandsTest.java b/accord-core/src/test/java/accord/local/CommandsTest.java
index 073b2f7b..a823e0aa 100644
--- a/accord-core/src/test/java/accord/local/CommandsTest.java
+++ b/accord-core/src/test/java/accord/local/CommandsTest.java
@@ -83,7 +83,7 @@ class CommandsTest
             {
                 {
                     // the node selected does not matter and should not impact determinism, they all share the same scheduler
-                    ((Cluster) nodeMap.values().stream().findFirst().get().scheduler()).onDone(() -> checkState(0, nodeMap.values()));
+                    ((Cluster.ClusterScheduler) nodeMap.values().stream().findFirst().get().scheduler()).onDone(() -> checkState(0, nodeMap.values()));
                 }
 
                 @Override
@@ -142,6 +142,9 @@ class CommandsTest
                     if (cmd.value() == null) // empty isn't public
                         continue;
                     Command command = cmd.value();
+                    if (command.txnId().isSyncPoint())
+                        continue;
+
                     if (command.status() == Status.Invalidated || command.status() == Status.AcceptedInvalidate)
                         continue;
                     // current limitation of SimpleProgressLog is that only the home shard will attempt to recover, so
diff --git a/accord-core/src/test/java/accord/local/ImmutableCommandTest.java b/accord-core/src/test/java/accord/local/ImmutableCommandTest.java
index b5958276..58cb6cbb 100644
--- a/accord-core/src/test/java/accord/local/ImmutableCommandTest.java
+++ b/accord-core/src/test/java/accord/local/ImmutableCommandTest.java
@@ -118,7 +118,7 @@ public class ImmutableCommandTest
     void noConflictWitnessTest()
     {
         CommandStoreSupport support = new CommandStoreSupport();
-        InMemoryCommandStore commands = createStore(support);
+        InMemoryCommandStore.Synchronized commands = (InMemoryCommandStore.Synchronized) createStore(support);
         MockCluster.Clock clock = new MockCluster.Clock(100);
         TxnId txnId = clock.idForNode(1, 1);
         Keys keys = Keys.of(KEY);
@@ -130,13 +130,23 @@ public class ImmutableCommandTest
             Assertions.assertEquals(Status.NotDefined, command.status());
             Assertions.assertNull(command.executeAt());
         }
-        SafeCommandStore safeStore = commands.beginOperation(PreLoadContext.contextFor(txnId, keys.toParticipants()));
-        StoreParticipants participants = StoreParticipants.update(safeStore, ROUTE, txnId.epoch(), txnId, txnId.epoch());
-        SafeCommand  safeCommand = safeStore.get(txnId, participants);
-        Commands.preaccept(safeStore, safeCommand, participants, txnId, txnId.epoch(), txn.slice(FULL_RANGES, true), ROUTE);
-        Command command = safeStore.get(txnId).current();
-        Assertions.assertEquals(Status.PreAccepted, command.status());
-        Assertions.assertEquals(txnId, command.executeAt());
+
+        commands.execute(() -> {
+            SafeCommandStore safeStore = commands.beginOperation(PreLoadContext.contextFor(txnId, keys.toParticipants()));
+            try
+            {
+                StoreParticipants participants = StoreParticipants.update(safeStore, ROUTE, txnId.epoch(), txnId, txnId.epoch());
+                SafeCommand  safeCommand = safeStore.get(txnId, participants);
+                Commands.preaccept(safeStore, safeCommand, participants, txnId, txnId.epoch(), txn.slice(FULL_RANGES, true), ROUTE);
+                Command command = safeStore.get(txnId).current();
+                Assertions.assertEquals(Status.PreAccepted, command.status());
+                Assertions.assertEquals(txnId, command.executeAt());
+            }
+            finally
+            {
+                commands.completeOperation(safeStore);
+            }
+        });
     }
 
     @Test
diff --git a/accord-core/src/test/java/accord/local/cfk/CommandsForKeyTest.java b/accord-core/src/test/java/accord/local/cfk/CommandsForKeyTest.java
index dfe37867..50b2b97c 100644
--- a/accord-core/src/test/java/accord/local/cfk/CommandsForKeyTest.java
+++ b/accord-core/src/test/java/accord/local/cfk/CommandsForKeyTest.java
@@ -719,7 +719,7 @@ public class CommandsForKeyTest
         }
 
         @Override
-        protected SafeCommand ifLoadedAndInitialisedAndNotErasedInternal(TxnId txnId)
+        protected SafeCommand ifLoadedInternal(TxnId txnId)
         {
             return getInternal(txnId);
         }
@@ -757,7 +757,7 @@ public class CommandsForKeyTest
         }
 
         @Override
-        public SafeCommand ifLoadedAndInitialisedAndNotErased(TxnId txnId)
+        public SafeCommand ifLoadedAndInitialised(TxnId txnId)
         {
             if (txnId.compareTo(cfk.current.prunedBefore()) < 0)
                 return null;
diff --git a/accord-core/src/test/java/accord/messages/PreAcceptTest.java b/accord-core/src/test/java/accord/messages/PreAcceptTest.java
index c07e8252..fb5e5667 100644
--- a/accord-core/src/test/java/accord/messages/PreAcceptTest.java
+++ b/accord-core/src/test/java/accord/messages/PreAcceptTest.java
@@ -165,7 +165,7 @@ public class PreAcceptTest
             invalidate.process(node, ID2, REPLY_CONTEXT);
 
             messageSink.assertHistorySizes(0, 1);
-            assertThat(messageSink.responses.get(0).payload).isEqualTo(new BeginInvalidation.InvalidateReply(null, Ballot.ZERO, SaveStatus.NotDefined, false, null, null, null));
+            assertThat(messageSink.responses.get(0).payload).isEqualTo(new BeginInvalidation.InvalidateReply(null, Ballot.ZERO, SaveStatus.Uninitialised, false, null, null, null));
             messageSink.clearHistory();
 
             PreAccept preAccept = preAccept(txnId, txn, key.toUnseekable());
diff --git a/accord-core/src/test/java/accord/messages/ReadDataTest.java b/accord-core/src/test/java/accord/messages/ReadDataTest.java
index d118bf8e..c72022ff 100644
--- a/accord-core/src/test/java/accord/messages/ReadDataTest.java
+++ b/accord-core/src/test/java/accord/messages/ReadDataTest.java
@@ -185,8 +185,9 @@ class ReadDataTest
             store = stores.get(1);
             check(store.execute(PreLoadContext.contextFor(state.txnId, state.route), safeStore -> {
                 StoreParticipants participants = StoreParticipants.invalidate(safeStore, state.route, state.txnId);
-                SafeCommand command = safeStore.get(state.txnId, participants);
-                command.commitInvalidated(safeStore);
+                SafeCommand safeCommand = safeStore.get(state.txnId, participants);
+                Command prev = safeCommand.current();
+                safeCommand.commitInvalidated(safeStore);
             }));
 
             ReplyContext replyContext = state.process();
diff --git a/accord-core/src/test/java/accord/primitives/AbstractRangesTest.java b/accord-core/src/test/java/accord/primitives/AbstractRangesTest.java
index bb243399..68965df7 100644
--- a/accord-core/src/test/java/accord/primitives/AbstractRangesTest.java
+++ b/accord-core/src/test/java/accord/primitives/AbstractRangesTest.java
@@ -127,6 +127,12 @@ class AbstractRangesTest
             throw new UnsupportedOperationException();
         }
 
+        @Override
+        public Routables<Range> without(accord.primitives.Ranges ranges)
+        {
+            return new Ranges(withoutInternal(ranges));
+        }
+
         @Override
         public Ranges intersecting(Seekables<?, ?> intersecting)
         {
diff --git a/accord-core/src/test/java/accord/primitives/RangeDepsTest.java b/accord-core/src/test/java/accord/primitives/RangeDepsTest.java
index cf03e41c..dd3ca9f9 100644
--- a/accord-core/src/test/java/accord/primitives/RangeDepsTest.java
+++ b/accord-core/src/test/java/accord/primitives/RangeDepsTest.java
@@ -237,7 +237,7 @@ public class RangeDepsTest
     }
 
 
-    // TODO (now): broaden patterns of random contents, sizes of collection etc.
+    // TODO (testing): broaden patterns of random contents, sizes of collection etc.
     @Test
     public void testRandom()
     {
@@ -296,7 +296,7 @@ public class RangeDepsTest
             {
                 for (int txnIdCount = 1; txnIdCount < 100 ; txnIdCount *= 2)
                 {
-                    // TODO (now): verify that we write only a small number of checkpoints
+                    // TODO (testing): verify that we write only a small number of checkpoints
                     generateNemesisRanges(width, txnIdCount, 1000, nonNemesisEntryPerNemesisEntry)
                             .validate(random);
                 }
diff --git a/accord-core/src/test/java/accord/topology/TopologyRandomizer.java b/accord-core/src/test/java/accord/topology/TopologyRandomizer.java
index 135eb91b..4784d304 100644
--- a/accord-core/src/test/java/accord/topology/TopologyRandomizer.java
+++ b/accord-core/src/test/java/accord/topology/TopologyRandomizer.java
@@ -56,7 +56,7 @@ import static accord.burn.BurnTest.HASH_RANGE_END;
 import static accord.burn.BurnTest.HASH_RANGE_START;
 
 
-// TODO (required, testing): add change replication factor
+// TODO (testing): add change replication factor
 public class TopologyRandomizer
 {
     public interface Listener
@@ -453,7 +453,6 @@ public class TopologyRandomizer
             state.shards = newShards;
             Shard[] testShards = type.apply(state, random);
             if (!everyShardHasOverlaps(current.epoch, oldShards, testShards)
-                // TODO (now): I don't think it is necessary to prevent re-replicating ranges any longer
                 || reassignsRanges(current, testShards, previouslyReplicated)
             )
             {
diff --git a/accord-core/src/test/java/accord/utils/AccordGens.java b/accord-core/src/test/java/accord/utils/AccordGens.java
index eda147a8..560caa11 100644
--- a/accord-core/src/test/java/accord/utils/AccordGens.java
+++ b/accord-core/src/test/java/accord/utils/AccordGens.java
@@ -585,7 +585,6 @@ public class AccordGens
             break;
             case ExclusiveSyncPoint:
             case SyncPoint:
-            case LocalOnly:
                 //TODO (coverage, now):
                 keyDepsGen = i -> KeyDeps.NONE;
                 rangeDepsGen = i -> RangeDeps.NONE;
diff --git a/accord-core/src/test/java/accord/utils/LogGroupTimersTest.java b/accord-core/src/test/java/accord/utils/LogGroupTimersTest.java
index bb09b65b..8fbadf04 100644
--- a/accord-core/src/test/java/accord/utils/LogGroupTimersTest.java
+++ b/accord-core/src/test/java/accord/utils/LogGroupTimersTest.java
@@ -38,7 +38,7 @@ public class LogGroupTimersTest
     public void test()
     {
         Random random = new Random();
-        for (int i = 0 ; i < 10000 ; ++i)
+        for (int i = 0 ; i < 1000 ; ++i)
             testOne(random.nextLong(), 1000, 100);
     }
 
@@ -95,6 +95,7 @@ public class LogGroupTimersTest
 
     private void testOne(long seed, int rounds, int maxBatchSize)
     {
+        System.out.printf("Seed %d\n", seed);
         RandomTestRunner.test().withSeed(seed).check(rnd -> {
             TimeUnit scale = rnd.randomWeightedPicker(new TimeUnit[] { MINUTES, HOURS, DAYS }).get();
             long globalMaxDeadline = scale.toMicros(rnd.nextInt(1, 8));
diff --git a/accord-core/src/test/java/accord/verify/StrictSerializabilityVerifier.java b/accord-core/src/test/java/accord/verify/StrictSerializabilityVerifier.java
index c0cb6b95..a39c566d 100644
--- a/accord-core/src/test/java/accord/verify/StrictSerializabilityVerifier.java
+++ b/accord-core/src/test/java/accord/verify/StrictSerializabilityVerifier.java
@@ -53,7 +53,7 @@ import static java.util.stream.Collectors.joining;
  * find a path of predecessors that would witness us.
  * <p>
  * TODO (low priority): find and report a path when we encounter a violation
- * TODO (required): validate we only witness values we may have written (this is a post-processing step to just validate all steps have an associated write that may have succeeded)
+ * TODO (testing): validate we only witness values we may have written (this is a post-processing step to just validate all steps have an associated write that may have succeeded)
  */
 public class StrictSerializabilityVerifier implements Verifier
 {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


(cassandra-accord) 04/05: Fixes

Posted by if...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ifesdjeen pushed a commit to branch semi-integrated-burn-test-rebased
in repository https://gitbox.apache.org/repos/asf/cassandra-accord.git

commit fb5d014247e0ca7f82f89b031fac4918d4fcb512
Author: Alex Petrov <ol...@gmail.com>
AuthorDate: Fri Nov 15 20:25:52 2024 +0100

    Fixes
---
 .../main-test/java/accord/burn/BurnTestBase.java   |  7 +-
 .../main-test/java/accord/impl/basic/Cluster.java  |  2 +-
 .../java/accord/impl/basic/VerifyingJournal.java   | 94 ++++++++++++++++++++++
 .../java/accord/impl/list/ListResult.java          |  2 +-
 .../main/java/accord/coordinate/PersistTxn.java    |  1 -
 .../java/accord/impl/DurabilityScheduling.java     | 11 +--
 .../src/main/java/accord/local/Command.java        |  8 +-
 .../src/main/java/accord/messages/CheckStatus.java | 22 +++--
 8 files changed, 115 insertions(+), 32 deletions(-)

diff --git a/accord-core/src/main-test/java/accord/burn/BurnTestBase.java b/accord-core/src/main-test/java/accord/burn/BurnTestBase.java
index 0f5a34c9..8f2389f1 100644
--- a/accord-core/src/main-test/java/accord/burn/BurnTestBase.java
+++ b/accord-core/src/main-test/java/accord/burn/BurnTestBase.java
@@ -92,7 +92,6 @@ import accord.utils.RandomSource;
 import accord.utils.Utils;
 import accord.utils.async.AsyncExecutor;
 import accord.utils.async.TimeoutUtils;
-import accord.verify.CompositeVerifier;
 import accord.verify.StrictSerializabilityVerifier;
 import accord.verify.Verifier;
 import org.agrona.collections.Int2ObjectHashMap;
@@ -302,7 +301,7 @@ public class BurnTestBase
         f2.get();
     }
 
-    void burn(RandomSource random, TopologyFactory topologyFactory, List<Id> clients, List<Id> nodes, int keyCount, int operations, int concurrency, PendingQueue pendingQueue, Function<Id, Journal> journalFactory)
+    protected void burn(RandomSource random, TopologyFactory topologyFactory, List<Id> clients, List<Id> nodes, int keyCount, int operations, int concurrency, PendingQueue pendingQueue, Function<Id, Journal> journalFactory)
     {
         List<Throwable> failures = Collections.synchronizedList(new ArrayList<>());
         AtomicLong progress = new AtomicLong();
@@ -520,7 +519,7 @@ public class BurnTestBase
 
     protected Verifier createVerifier(String prefix, int keyCount)
     {
-            return new StrictSerializabilityVerifier(prefix, keyCount);
+        return new StrictSerializabilityVerifier(prefix, keyCount);
     }
 
     public static void main(String[] args)
@@ -660,7 +659,7 @@ public class BurnTestBase
         }
     }
 
-    private static List<Id> generateIds(boolean clients, int count)
+    protected static List<Id> generateIds(boolean clients, int count)
     {
         List<Id> ids = new ArrayList<>();
         for (int i = 1; i <= count ; ++i)
diff --git a/accord-core/src/main-test/java/accord/impl/basic/Cluster.java b/accord-core/src/main-test/java/accord/impl/basic/Cluster.java
index bd2fb921..e9c9d9ed 100644
--- a/accord-core/src/main-test/java/accord/impl/basic/Cluster.java
+++ b/accord-core/src/main-test/java/accord/impl/basic/Cluster.java
@@ -716,7 +716,7 @@ public class Cluster
                     if (!store.unsafeCommands().containsKey(txnId))
                     {
                         Command beforeCommand = before.get(txnId);
-                        if (beforeCommand.saveStatus() == SaveStatus.Erased)
+                        if (beforeCommand.saveStatus() == SaveStatus.Erased || beforeCommand.saveStatus() == SaveStatus.Uninitialised)
                             continue;
 
                         if (store.unsafeGetRedundantBefore().min(beforeCommand.participants().owns(), RedundantBefore.Entry::shardRedundantBefore).compareTo(txnId) > 0)
diff --git a/accord-core/src/main-test/java/accord/impl/basic/VerifyingJournal.java b/accord-core/src/main-test/java/accord/impl/basic/VerifyingJournal.java
new file mode 100644
index 00000000..0c2f80bd
--- /dev/null
+++ b/accord-core/src/main-test/java/accord/impl/basic/VerifyingJournal.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package accord.impl.basic;
+
+import java.util.NavigableMap;
+
+import accord.api.Journal;
+import accord.local.Command;
+import accord.local.CommandStores;
+import accord.local.DurableBefore;
+import accord.local.RedundantBefore;
+import accord.primitives.Ranges;
+import accord.primitives.Timestamp;
+import accord.primitives.TxnId;
+import accord.utils.Invariants;
+
+public class VerifyingJournal implements Journal
+{
+    private final Journal model;
+    private final Journal sut;
+
+    public VerifyingJournal(Journal model, Journal sut)
+    {
+        this.model = model;
+        this.sut = sut;
+    }
+
+    public Command loadCommand(int commandStoreId, TxnId txnId, RedundantBefore redundantBefore, DurableBefore durableBefore)
+    {
+        Command res = sut.loadCommand(commandStoreId, txnId, redundantBefore, durableBefore);
+        Command model = this.model.loadCommand(commandStoreId, txnId, redundantBefore, durableBefore);
+        Invariants.checkState(res.equals(model));
+        return res;
+    }
+
+    public void saveCommand(int store, CommandUpdate update, Runnable onFlush)
+    {
+        model.saveCommand(store, update, null);
+        sut.saveCommand(store, update, onFlush);
+    }
+
+    public void purge(CommandStores commandStores)
+    {
+        model.purge(commandStores);
+        sut.purge(commandStores);
+    }
+
+    public void replay(CommandStores commandStores)
+    {
+        sut.replay(commandStores);
+    }
+
+    // TODO (required): model loading
+    public RedundantBefore loadRedundantBefore(int commandStoreId)
+    {
+        return sut.loadRedundantBefore(commandStoreId);
+    }
+
+    public NavigableMap<TxnId, Ranges> loadBootstrapBeganAt(int commandStoreId)
+    {
+        return sut.loadBootstrapBeganAt(commandStoreId);
+    }
+
+    public NavigableMap<Timestamp, Ranges> loadSafeToRead(int commandStoreId)
+    {
+        return sut.loadSafeToRead(commandStoreId);
+    }
+
+    public CommandStores.RangesForEpoch.Snapshot loadRangesForEpoch(int commandStoreId)
+    {
+        return sut.loadRangesForEpoch(commandStoreId);
+    }
+
+    public void saveStoreState(int store, FieldUpdates fieldUpdates, Runnable onFlush)
+    {
+        sut.saveStoreState(store, fieldUpdates, onFlush);
+    }
+}
diff --git a/accord-core/src/main-test/java/accord/impl/list/ListResult.java b/accord-core/src/main-test/java/accord/impl/list/ListResult.java
index adfa1fe3..c752bd0b 100644
--- a/accord-core/src/main-test/java/accord/impl/list/ListResult.java
+++ b/accord-core/src/main-test/java/accord/impl/list/ListResult.java
@@ -42,7 +42,7 @@ public class ListResult implements Result, Reply
     public final Keys responseKeys;
     public final int[][] read; // equal in size to keys.size()
     public final ListUpdate update;
-    private final Status status;
+    public final Status status;
 
     public ListResult(Status status, Id client, long requestId, TxnId txnId, Seekables<?, ?> readKeys, Keys responseKeys, int[][] read, ListUpdate update)
     {
diff --git a/accord-core/src/main/java/accord/coordinate/PersistTxn.java b/accord-core/src/main/java/accord/coordinate/PersistTxn.java
index c9139f01..797e8363 100644
--- a/accord-core/src/main/java/accord/coordinate/PersistTxn.java
+++ b/accord-core/src/main/java/accord/coordinate/PersistTxn.java
@@ -22,7 +22,6 @@ import accord.api.Result;
 import accord.local.Node;
 import accord.primitives.Deps;
 import accord.primitives.FullRoute;
-import accord.primitives.Participants;
 import accord.primitives.Route;
 import accord.primitives.Timestamp;
 import accord.primitives.Txn;
diff --git a/accord-core/src/main/java/accord/impl/DurabilityScheduling.java b/accord-core/src/main/java/accord/impl/DurabilityScheduling.java
index ada18fc9..329ba009 100644
--- a/accord-core/src/main/java/accord/impl/DurabilityScheduling.java
+++ b/accord-core/src/main/java/accord/impl/DurabilityScheduling.java
@@ -314,10 +314,8 @@ public class DurabilityScheduling implements ConfigurationService.Listener
                                 index *= 2;
                                 numberOfSplits *= 2;
                             }
-                            if (fail instanceof Timeout)
-                                logger.trace("{}: Exception coordinating ExclusiveSyncPoint for {} durability. Increased numberOfSplits to " + numberOfSplits, syncId, ranges, fail);
-                            else
-                                logger.debug("{}: Exception coordinating ExclusiveSyncPoint for {} durability. Increased numberOfSplits to " + numberOfSplits, syncId, ranges, fail);
+
+                            logger.trace("{}: Exception coordinating ExclusiveSyncPoint for {} durability. Increased numberOfSplits to " + numberOfSplits, syncId, ranges, fail);
                         }
                     }
                     else
@@ -339,10 +337,7 @@ public class DurabilityScheduling implements ConfigurationService.Listener
                     .addCallback((success, fail) -> {
                         if (fail != null && fail.getClass() != SyncPointErased.class)
                         {
-                            if (fail instanceof Timeout)
-                                logger.trace("Exception coordinating shard durability for {}, will retry", exclusiveSyncPoint.route.toRanges(), fail);
-                            else
-                                logger.debug("Exception coordinating shard durability for {}, will retry", exclusiveSyncPoint.route.toRanges(), fail);
+                            logger.trace("Exception coordinating shard durability for {}, will retry", exclusiveSyncPoint.route.toRanges(), fail);
                             retryCoordinateDurability(node, exclusiveSyncPoint, nextIndex);
                         }
                         else
diff --git a/accord-core/src/main/java/accord/local/Command.java b/accord-core/src/main/java/accord/local/Command.java
index cf64e6cd..a089036a 100644
--- a/accord-core/src/main/java/accord/local/Command.java
+++ b/accord-core/src/main/java/accord/local/Command.java
@@ -328,8 +328,8 @@ public abstract class Command implements CommonAttributes
                 {
                     default: throw new AssertionError("Unhandled Outcome: " + known.outcome);
                     case Apply:
-                        Invariants.checkState(writes != null, "Writes is null");
-                        Invariants.checkState(result != null, "Result is null");
+                        Invariants.checkState(writes != null, "Writes is null %s", validate);
+                        Invariants.checkState(result != null, "Result is null %s", validate);
                         break;
                     case Invalidated:
                         Invariants.checkState(validate.durability().isMaybeInvalidated(), "%s is not invalidated", validate.durability());
@@ -337,8 +337,8 @@ public abstract class Command implements CommonAttributes
                         Invariants.checkState(validate.durability() != Local);
                     case Erased:
                     case WasApply:
-                        Invariants.checkState(writes == null, "Writes exist");
-                        Invariants.checkState(result == null, "Results exist");
+                        Invariants.checkState(writes == null, "Writes exist for %s", validate);
+                        Invariants.checkState(result == null, "Results exist %s", validate);
                         break;
                 }
             }
diff --git a/accord-core/src/main/java/accord/messages/CheckStatus.java b/accord-core/src/main/java/accord/messages/CheckStatus.java
index e4e5a0a8..ca2ea321 100644
--- a/accord-core/src/main/java/accord/messages/CheckStatus.java
+++ b/accord-core/src/main/java/accord/messages/CheckStatus.java
@@ -18,6 +18,7 @@
 
 package accord.messages;
 
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import accord.api.Result;
@@ -30,48 +31,43 @@ import accord.local.Node.Id;
 import accord.local.PreLoadContext;
 import accord.local.SafeCommand;
 import accord.local.SafeCommandStore;
-import accord.primitives.SaveStatus;
-import accord.primitives.Status;
 import accord.local.StoreParticipants;
 import accord.primitives.Ballot;
+import accord.primitives.Known;
 import accord.primitives.KnownMap;
-import accord.primitives.WithQuorum;
 import accord.primitives.PartialDeps;
 import accord.primitives.PartialTxn;
 import accord.primitives.Participants;
 import accord.primitives.ProgressToken;
 import accord.primitives.Ranges;
 import accord.primitives.Route;
+import accord.primitives.SaveStatus;
+import accord.primitives.Status;
 import accord.primitives.Timestamp;
 import accord.primitives.TxnId;
 import accord.primitives.Unseekables;
+import accord.primitives.WithQuorum;
 import accord.primitives.Writes;
 import accord.topology.Topologies;
 import accord.utils.Invariants;
 import accord.utils.MapReduceConsume;
-
-import javax.annotation.Nonnull;
+import accord.utils.async.Cancellable;
 
 import static accord.coordinate.Infer.InvalidIf.IfUncommitted;
 import static accord.coordinate.Infer.InvalidIf.IsNotInvalid;
 import static accord.coordinate.Infer.InvalidIf.NotKnownToBeInvalid;
+import static accord.messages.TxnRequest.computeScope;
+import static accord.primitives.Route.castToRoute;
+import static accord.primitives.Route.isRoute;
 import static accord.primitives.Status.Durability;
 import static accord.primitives.Status.Durability.Local;
 import static accord.primitives.Status.Durability.Majority;
 import static accord.primitives.Status.Durability.ShardUniversal;
 import static accord.primitives.Status.Durability.Universal;
-
-import accord.primitives.Known;
-import accord.utils.async.Cancellable;
-
-import static accord.primitives.Status.Invalidated;
 import static accord.primitives.Status.NotDefined;
 import static accord.primitives.Status.Stable;
 import static accord.primitives.Status.Truncated;
-import static accord.messages.TxnRequest.computeScope;
 import static accord.primitives.WithQuorum.HasQuorum;
-import static accord.primitives.Route.castToRoute;
-import static accord.primitives.Route.isRoute;
 
 public class CheckStatus extends AbstractRequest<CheckStatus.CheckStatusReply>
         implements Request, PreLoadContext, MapReduceConsume<SafeCommandStore, CheckStatus.CheckStatusReply>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org