You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2026/04/16 11:59:59 UTC

(causeway) branch 3989-v2-cmd-io created (now 974770d4ede)

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

ahuber pushed a change to branch 3989-v2-cmd-io
in repository https://gitbox.apache.org/repos/asf/causeway.git


      at 974770d4ede CAUSEWAY-3989: [v2] backport of command replay feature

This branch includes the following new commits:

     new 974770d4ede CAUSEWAY-3989: [v2] backport of command replay feature

The 1 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.



(causeway) 01/01: CAUSEWAY-3989: [v2] backport of command replay feature

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

ahuber pushed a commit to branch 3989-v2-cmd-io
in repository https://gitbox.apache.org/repos/asf/causeway.git

commit 974770d4ede550919b1820b6bb3c6691465cdc2b
Author: andi-huber <ah...@apache.org>
AuthorDate: Thu Apr 16 13:59:49 2026 +0200

    CAUSEWAY-3989: [v2] backport of command replay feature
---
 api/applib/src/main/java/module-info.java          |   1 +
 .../applib/util/schema/CommandDtoUtils.java        |  63 ++++
 .../org/apache/causeway/commons/io/YamlUtils.java  |  26 +-
 .../DomainObjectAnnotationFacetFactoryTest.java    |  21 +-
 extensions/core/commandlog/applib/pom.xml          |  10 +
 .../applib/CausewayModuleExtCommandLogApplib.java  |  33 +-
 .../commandlog/applib/app/CommandLogMenu.java      |  37 +-
 .../commandlog/applib/dom/CommandLogEntry.java     |  41 ++-
 .../applib/dom/CommandLogEntryRepository.java      |  29 +-
 .../dom/CommandLogEntryRepositoryAbstract.java     | 114 +++---
 .../commandlog/applib/dom/ReplayState.java         |  51 ++-
 .../applib/dom/replay/CommandExportManager.java    | 185 ++++++++++
 .../CommandExportManager.layout.fallback.xml       |  52 +++
 .../applib/dom/replay/CommandReplayManager.java    | 187 ++++++++++
 .../CommandReplayManager.layout.fallback.xml       |  52 +++
 .../applib/dom/replay/ReplayContext.java           |  40 ++
 .../applib/dom/replay/ReplayableCommand.java       | 406 +++++++++++++++++++++
 .../replay/ReplayableCommand.layout.fallback.xml   |  45 +++
 .../integtest/CommandLog_IntegTestAbstract.java    |   4 +-
 .../commandlog/jdo/dom/CommandLogEntry.java        |   2 +-
 .../commandlog/jpa/dom/CommandLogEntry.java        |   2 +-
 .../jobcallables/ReplicateAndRunCommands.java      |   2 +-
 .../mixins/CommandLogEntry_replayQueue.java        |   2 +-
 23 files changed, 1268 insertions(+), 137 deletions(-)

diff --git a/api/applib/src/main/java/module-info.java b/api/applib/src/main/java/module-info.java
index 488891760ce..4131e569bcf 100644
--- a/api/applib/src/main/java/module-info.java
+++ b/api/applib/src/main/java/module-info.java
@@ -146,6 +146,7 @@
     requires transitive spring.core;
     requires spring.tx;
     requires org.apache.logging.log4j.core;
+	requires com.fasterxml.jackson.annotation;
 
     // JAXB viewmodels
     opens org.apache.causeway.applib.annotation;
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/util/schema/CommandDtoUtils.java b/api/applib/src/main/java/org/apache/causeway/applib/util/schema/CommandDtoUtils.java
index 935fb354918..83372393da9 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/util/schema/CommandDtoUtils.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/util/schema/CommandDtoUtils.java
@@ -18,18 +18,33 @@
  */
 package org.apache.causeway.applib.util.schema;
 
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
 import org.apache.causeway.applib.services.bookmark.Bookmark;
 import org.apache.causeway.commons.internal.base._Lazy;
+import org.apache.causeway.commons.internal.base._NullSafe;
 import org.apache.causeway.commons.internal.base._Strings;
+import org.apache.causeway.commons.io.DataSource;
 import org.apache.causeway.commons.io.DtoMapper;
 import org.apache.causeway.commons.io.JaxbUtils;
+import org.apache.causeway.commons.io.JsonUtils;
+import org.apache.causeway.commons.io.JsonUtils.JacksonCustomizer;
+import org.apache.causeway.commons.io.YamlUtils;
 import org.apache.causeway.schema.cmd.v2.ActionDto;
 import org.apache.causeway.schema.cmd.v2.CommandDto;
 import org.apache.causeway.schema.cmd.v2.MapDto;
+import org.apache.causeway.schema.cmd.v2.MemberDto;
 import org.apache.causeway.schema.cmd.v2.ParamsDto;
+import org.apache.causeway.schema.cmd.v2.PropertyDto;
 import org.apache.causeway.schema.common.v2.OidsDto;
 import org.apache.causeway.schema.common.v2.PeriodDto;
 
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.jsontype.NamedType;
+
 import lombok.experimental.UtilityClass;
 
 /**
@@ -117,4 +132,52 @@ private MapDto userDataFor(final CommandDto commandDto) {
         return userData;
     }
 
+    // -- YAML SUPPORT
+
+    public String toYaml(final Iterable<CommandDto> commandDtos) {
+    	final JsonUtils.JacksonCustomizer customizer = new JacksonCustomizer() {
+			@Override
+			public ObjectMapper apply(ObjectMapper mapper) {
+				JsonUtils.jaxbAnnotationSupport(mapper);
+				CommandDtoUtils.memberDtoSupport(mapper);
+				JsonUtils.onlyIncludeNonNull(mapper);
+				return mapper;
+			}
+		}; 
+        return YamlUtils.toStringUtf8(
+            _NullSafe.stream(commandDtos)
+                .collect(Collectors.toList()),
+            customizer);
+    }
+
+    public List<CommandDto> fromYaml(final DataSource commandDtosYaml) {
+    	final JsonUtils.JacksonCustomizer customizer = new JacksonCustomizer() {
+			@Override
+			public ObjectMapper apply(ObjectMapper mapper) {
+				JsonUtils.jaxbAnnotationSupport(mapper);
+				CommandDtoUtils.memberDtoSupport(mapper);
+				return mapper;
+			}
+		};
+        return YamlUtils.tryReadAsList(CommandDto.class, commandDtosYaml, customizer)
+            .ifFailureFail()
+            .getValue()
+            .orElseGet(Collections::emptyList);
+    }
+
+    // Mix-in to add type metadata to MemberDto
+    @JsonTypeInfo(
+            use = JsonTypeInfo.Id.NAME,
+            include = JsonTypeInfo.As.PROPERTY,
+            property = "type")
+    private abstract class AbstractDtoMixIn {}
+
+    private void memberDtoSupport(final ObjectMapper mb) {
+        // add mix-in so MemberDto carries @JsonTypeInfo without modifying source
+        mb.addMixIn(MemberDto.class, AbstractDtoMixIn.class);
+        // register concrete sub-types with logical names
+        mb.registerSubtypes(new NamedType(ActionDto.class, "ACT"));
+        mb.registerSubtypes(new NamedType(PropertyDto.class, "PROP"));
+    }
+    
 }
diff --git a/commons/src/main/java/org/apache/causeway/commons/io/YamlUtils.java b/commons/src/main/java/org/apache/causeway/commons/io/YamlUtils.java
index 9e7d3a79820..c8bc8ac187e 100644
--- a/commons/src/main/java/org/apache/causeway/commons/io/YamlUtils.java
+++ b/commons/src/main/java/org/apache/causeway/commons/io/YamlUtils.java
@@ -19,18 +19,17 @@
 package org.apache.causeway.commons.io;
 
 import java.io.InputStream;
+import java.util.List;
 import java.util.Optional;
 
+import org.apache.causeway.commons.functional.Try;
+import org.springframework.lang.Nullable;
+import org.yaml.snakeyaml.DumperOptions;
+
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
 import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
 
-import org.yaml.snakeyaml.DumperOptions;
-
-import org.springframework.lang.Nullable;
-
-import org.apache.causeway.commons.functional.Try;
-
 import lombok.NonNull;
 import lombok.SneakyThrows;
 import lombok.experimental.UtilityClass;
@@ -69,6 +68,21 @@ public <T> Try<T> tryRead(
                     .readValue(is, mappedType));
         });
     }
+    
+    /**
+     * Tries to deserialize YAML content from given {@link DataSource} into a {@link List}
+     * with given {@code elementType}.
+     */
+    public <T> Try<List<T>> tryReadAsList(
+            final @NonNull Class<T> elementType,
+            final @NonNull DataSource source,
+            final JsonUtils.JacksonCustomizer ... customizers) {
+        return source.tryReadAll((final InputStream is) -> Try.call(()->{
+            var mapper = createJacksonReader(customizers);
+            var collectionType = mapper.getTypeFactory().constructCollectionType(List.class, elementType);
+            return mapper.readValue(is, collectionType);
+        }));
+    }
 
     // -- WRITING
 
diff --git a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/object/domainobject/DomainObjectAnnotationFacetFactoryTest.java b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/object/domainobject/DomainObjectAnnotationFacetFactoryTest.java
index 6448a0b53a7..1c82976bb51 100644
--- a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/object/domainobject/DomainObjectAnnotationFacetFactoryTest.java
+++ b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/object/domainobject/DomainObjectAnnotationFacetFactoryTest.java
@@ -18,17 +18,6 @@
  */
 package org.apache.causeway.core.metamodel.facets.object.domainobject;
 
-import java.util.UUID;
-
-import javax.inject.Named;
-
-import org.apache.causeway.applib.annotation.Publishing;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Nested;
-import org.junit.jupiter.api.Test;
-
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -37,16 +26,20 @@
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import java.util.UUID;
+
+import javax.inject.Named;
+
 import org.apache.causeway.applib.annotation.Bounding;
 import org.apache.causeway.applib.annotation.DomainObject;
 import org.apache.causeway.applib.annotation.DomainService;
+import org.apache.causeway.applib.annotation.Publishing;
 import org.apache.causeway.applib.id.LogicalType;
 import org.apache.causeway.applib.mixins.system.HasInteractionId;
 import org.apache.causeway.commons.collections.Can;
 import org.apache.causeway.core.config.metamodel.facets.DomainObjectConfigOptions;
 import org.apache.causeway.core.metamodel._testing.MetaModelContext_forTesting;
 import org.apache.causeway.core.metamodel.facetapi.Facet;
-import org.apache.causeway.core.metamodel.facets.AbstractTestWithMetaModelContext;
 import org.apache.causeway.core.metamodel.facets.FacetFactoryTestAbstract;
 import org.apache.causeway.core.metamodel.facets.object.autocomplete.AutoCompleteFacet;
 import org.apache.causeway.core.metamodel.facets.object.domainobject.autocomplete.AutoCompleteFacetForDomainObjectAnnotation;
@@ -65,6 +58,10 @@
 import org.apache.causeway.core.metamodel.facets.objectvalue.choices.ChoicesFacet;
 import org.apache.causeway.core.metamodel.spec.IntrospectionState;
 import org.apache.causeway.core.metamodel.specloader.validator.ValidationFailures;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
 
 class DomainObjectAnnotationFacetFactoryTest
 extends FacetFactoryTestAbstract {
diff --git a/extensions/core/commandlog/applib/pom.xml b/extensions/core/commandlog/applib/pom.xml
index a6336d913d1..5fbf47564bb 100644
--- a/extensions/core/commandlog/applib/pom.xml
+++ b/extensions/core/commandlog/applib/pom.xml
@@ -76,6 +76,16 @@
             <artifactId>causeway-core-runtimeservices</artifactId>
         </dependency>
 
+        <!-- uses Ascii-Doc in support of pretty CommandDTO rendering -->
+		<dependency>
+			<groupId>org.apache.causeway.valuetypes</groupId>
+			<artifactId>causeway-valuetypes-asciidoc-applib</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.causeway.valuetypes</groupId>
+			<artifactId>causeway-valuetypes-asciidoc-builder</artifactId>
+		</dependency>
+		
         <dependency>
             <groupId>org.quartz-scheduler</groupId>
             <artifactId>quartz</artifactId>
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/CausewayModuleExtCommandLogApplib.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/CausewayModuleExtCommandLogApplib.java
index dc025903595..d8837822808 100644
--- a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/CausewayModuleExtCommandLogApplib.java
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/CausewayModuleExtCommandLogApplib.java
@@ -18,11 +18,10 @@
  */
 package org.apache.causeway.extensions.commandlog.applib;
 
-import org.apache.causeway.extensions.commandlog.applib.spi.RunBackgroundCommandsJobListener;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-
+import org.apache.causeway.applib.services.bookmark.BookmarkService;
+import org.apache.causeway.applib.services.command.CommandExecutorService;
+import org.apache.causeway.applib.services.iactnlayer.InteractionService;
+import org.apache.causeway.applib.services.repository.RepositoryService;
 import org.apache.causeway.core.config.util.SpringProfileUtil;
 import org.apache.causeway.extensions.commandlog.applib.app.CommandLogMenu;
 import org.apache.causeway.extensions.commandlog.applib.contributions.HasInteractionId_commandLogEntry;
@@ -30,19 +29,31 @@
 import org.apache.causeway.extensions.commandlog.applib.contributions.Object_recentCommands;
 import org.apache.causeway.extensions.commandlog.applib.dom.BackgroundService;
 import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntry;
+import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntryRepository;
 import org.apache.causeway.extensions.commandlog.applib.dom.mixins.CommandLogEntry_childCommands;
 import org.apache.causeway.extensions.commandlog.applib.dom.mixins.CommandLogEntry_openResultObject;
 import org.apache.causeway.extensions.commandlog.applib.dom.mixins.CommandLogEntry_siblingCommands;
+import org.apache.causeway.extensions.commandlog.applib.dom.replay.CommandExportManager;
+import org.apache.causeway.extensions.commandlog.applib.dom.replay.CommandReplayManager;
+import org.apache.causeway.extensions.commandlog.applib.dom.replay.ReplayContext;
 import org.apache.causeway.extensions.commandlog.applib.fakescheduler.FakeScheduler;
 import org.apache.causeway.extensions.commandlog.applib.job.BackgroundCommandsJobControl;
 import org.apache.causeway.extensions.commandlog.applib.job.RunBackgroundCommandsJob;
+import org.apache.causeway.extensions.commandlog.applib.spi.RunBackgroundCommandsJobListener;
 import org.apache.causeway.extensions.commandlog.applib.subscriber.CommandSubscriberForCommandLog;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
 
-@Configuration
+@Configuration(proxyBeanMethods = false)
 @Import({
         // @DomainService's
         CommandLogMenu.class,
 
+        // viewmodels
+        CommandExportManager.class,
+        CommandReplayManager.class,
+
         // mixins
         HasInteractionId_commandLogEntry.class,
         HasUsername_recentCommandsByUser.class,
@@ -108,4 +119,14 @@ public static void honorSystemEnvironment() {
         }
     }
 
+    @Bean ReplayContext replayContext(
+            final BookmarkService bookmarkService,
+            final RepositoryService repositoryService,
+            final InteractionService interactionService,
+            final CommandLogEntryRepository commandLogEntryRepository,
+            final CommandExecutorService commandExecutorService) {
+        return new ReplayContext(bookmarkService, repositoryService, interactionService,
+                commandLogEntryRepository, commandExecutorService);
+    }
+
 }
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/app/CommandLogMenu.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/app/CommandLogMenu.java
index 6f2be45e9ac..607bd8e4583 100644
--- a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/app/CommandLogMenu.java
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/app/CommandLogMenu.java
@@ -25,8 +25,6 @@
 import javax.inject.Inject;
 import javax.inject.Named;
 
-import org.springframework.lang.Nullable;
-
 import org.apache.causeway.applib.annotation.Action;
 import org.apache.causeway.applib.annotation.ActionLayout;
 import org.apache.causeway.applib.annotation.DomainService;
@@ -40,6 +38,10 @@
 import org.apache.causeway.extensions.commandlog.applib.CausewayModuleExtCommandLogApplib;
 import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntry;
 import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntryRepository;
+import org.apache.causeway.extensions.commandlog.applib.dom.replay.CommandExportManager;
+import org.apache.causeway.extensions.commandlog.applib.dom.replay.CommandReplayManager;
+import org.apache.causeway.extensions.commandlog.applib.dom.replay.ReplayContext;
+import org.springframework.lang.Nullable;
 
 import lombok.RequiredArgsConstructor;
 
@@ -68,7 +70,7 @@ public static abstract class ActionDomainEvent<T>
 
     final CommandLogEntryRepository commandLogEntryRepository;
     final ClockService clockService;
-
+    final ReplayContext replayContext;
 
     @Action(
             commandPublishing = Publishing.DISABLED,
@@ -147,8 +149,37 @@ public class DomainEvent extends ActionDomainEvent<findAll> { }
         }
     }
 
+    @Action(
+            commandPublishing = Publishing.DISABLED,
+            domainEvent = exportManager.DomainEvent.class,
+            executionPublishing = Publishing.DISABLED,
+            restrictTo = RestrictTo.PROTOTYPING,
+            semantics = SemanticsOf.SAFE
+    )
+    @ActionLayout(cssClassFa = "solid share-from-square", sequence="50")
+    public class exportManager {
+        public class DomainEvent extends ActionDomainEvent<exportManager> { }
 
+        @MemberSupport public CommandExportManager act() {
+            return new CommandExportManager(null, replayContext);
+        }
+    }
 
+    @Action(
+            commandPublishing = Publishing.DISABLED,
+            domainEvent = replayManager.DomainEvent.class,
+            executionPublishing = Publishing.DISABLED,
+            restrictTo = RestrictTo.PROTOTYPING,
+            semantics = SemanticsOf.SAFE
+    )
+    @ActionLayout(cssClassFa = "solid circle-play", sequence="51")
+    public class replayManager {
+        public class DomainEvent extends ActionDomainEvent<replayManager> { }
+
+        @MemberSupport public CommandReplayManager act() {
+            return new CommandReplayManager(null, replayContext);
+        }
+    }
 
     private LocalDate now() {
         return clockService.getClock().nowAsLocalDate(ZoneId.systemDefault());
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/CommandLogEntry.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/CommandLogEntry.java
index 328fd600797..e3ca1d877b7 100644
--- a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/CommandLogEntry.java
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/CommandLogEntry.java
@@ -26,6 +26,7 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.UUID;
 import java.util.function.Consumer;
 
@@ -170,8 +171,6 @@ public void sync(final Command command) {
 
         setResult(command.getResult());
         setException(command.getException());
-
-        setReplayState(org.apache.causeway.extensions.commandlog.applib.dom.ReplayState.UNDEFINED);
     }
 
 
@@ -182,7 +181,8 @@ public void sync(final Command command) {
      * @param replayState - controls whether this is to be replayed
      * @param targetIndex - if the command represents a bulk action, then it is flattened out when replayed; this indicates which target to execute against.
      */
-    public CommandLogEntry(
+    @Programmatic
+    protected void init(
             final CommandDto commandDto,
             final org.apache.causeway.extensions.commandlog.applib.dom.ReplayState replayState,
             final int targetIndex) {
@@ -198,8 +198,11 @@ public CommandLogEntry(
         // the hierarchy of commands calling other commands is only available on the primary system.
         setParentInteractionId(null);
 
-        setStartedAt(JavaSqlXMLGregorianCalendarMarshalling.toTimestamp(commandDto.getTimings().getStartedAt()));
-        setCompletedAt(JavaSqlXMLGregorianCalendarMarshalling.toTimestamp(commandDto.getTimings().getCompletedAt()));
+        Optional.ofNullable(commandDto.getTimings())
+            .ifPresent(timings->{
+                setStartedAt(JavaSqlXMLGregorianCalendarMarshalling.toTimestamp(timings.getStartedAt()));
+                setCompletedAt(JavaSqlXMLGregorianCalendarMarshalling.toTimestamp(timings.getCompletedAt()));
+            });
 
         copyOver(commandDto, UserDataKeys.RESULT, value -> this.setResult(Bookmark.parse(value).orElse(null)));
         copyOver(commandDto, UserDataKeys.EXCEPTION, this::setException);
@@ -210,23 +213,25 @@ public CommandLogEntry(
     static void copyOver(
             final CommandDto commandDto,
             final String key, final Consumer<String> consume) {
-        commandDto.getUserData().getEntry()
-                .stream()
-                .filter(x -> Objects.equals(x.getKey(), key))
-                .map(MapDto.Entry::getValue)
-                .filter(Objects::nonNull)
-                .filter(x -> x.length() > 0)
-                .findFirst()
-                .ifPresent(consume);
-    }
-
-
-    private static final DateTimeFormatter formatter =
+        Optional.ofNullable(commandDto.getUserData())
+            .ifPresent(userdata->{
+                userdata.getEntry()
+                    .stream()
+                    .filter(x -> Objects.equals(x.getKey(), key))
+                    .map(MapDto.Entry::getValue)
+                    .filter(Objects::nonNull)
+                    .filter(x -> x.length() > 0)
+                    .findFirst()
+                    .ifPresent(consume);
+            });
+    }
+
+    static final DateTimeFormatter DATETIME_FORMATTER =
             DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
 
     @ObjectSupport public String title() {
         return new TitleBuffer()
-                .append(formatter.format(getTimestamp().toLocalDateTime()))
+                .append(DATETIME_FORMATTER.format(getTimestamp().toLocalDateTime()))
                 .append(" ")
                 .append(getLogicalMemberIdentifier())
                 .toString();
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/CommandLogEntryRepository.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/CommandLogEntryRepository.java
index 2c4b14bf0ed..bf8401c6e8c 100644
--- a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/CommandLogEntryRepository.java
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/CommandLogEntryRepository.java
@@ -19,17 +19,19 @@
 package org.apache.causeway.extensions.commandlog.applib.dom;
 
 import java.time.LocalDate;
+import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 import java.util.UUID;
-
-import org.springframework.lang.Nullable;
+import java.util.stream.Collectors;
 
 import org.apache.causeway.applib.exceptions.RecoverableException;
 import org.apache.causeway.applib.services.bookmark.Bookmark;
 import org.apache.causeway.applib.services.command.Command;
+import org.apache.causeway.commons.internal.base._NullSafe;
 import org.apache.causeway.schema.cmd.v2.CommandDto;
 import org.apache.causeway.schema.cmd.v2.CommandsDto;
+import org.springframework.lang.Nullable;
 
 import lombok.Getter;
 
@@ -158,13 +160,29 @@ List<CommandLogEntry> findByTargetAndFromAndTo(
      */
     Optional<CommandLogEntry> findMostRecentCompleted();
 
-    List<CommandLogEntry> findNotYetReplayed();
-
+    /**
+     * Command Replay feature: Can replay or retry.
+     */
+    List<CommandLogEntry> findReplayPendingOrFailed();
+    /**
+     * Command Replay feature: Cannot replay or retry.
+     */
+    List<CommandLogEntry> findReplaySucceededOrExcluded();
 
     CommandLogEntry saveForReplay(final CommandDto dto);
 
+    default List<CommandLogEntry> saveForReplay(@Nullable final List<CommandDto> commandDtoList) {
+        return _NullSafe.stream(commandDtoList)
+            .map(this::saveForReplay)
+            .collect(Collectors.toList());
+    }
 
-    List<CommandLogEntry> saveForReplay(final CommandsDto commandsDto);
+    default List<CommandLogEntry> saveForReplay(@Nullable final CommandsDto commandsDto) {
+        var commandDtoList = Optional.ofNullable(commandsDto)
+            .map(CommandsDto::getCommandDto)
+            .orElseGet(Collections::emptyList);
+        return saveForReplay(commandDtoList);
+    }
 
 
     void persist(final CommandLogEntry commandLogEntry);
@@ -190,5 +208,4 @@ List<CommandLogEntry> findCommandsOnPrimaryElseFail(
      */
     void removeAll();
 
-
 }
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/CommandLogEntryRepositoryAbstract.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/CommandLogEntryRepositoryAbstract.java
index 8f62da00d6f..fdbb8b23379 100644
--- a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/CommandLogEntryRepositoryAbstract.java
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/CommandLogEntryRepositoryAbstract.java
@@ -22,7 +22,6 @@
 import java.time.Instant;
 import java.time.LocalDate;
 import java.time.ZoneId;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
@@ -31,24 +30,16 @@
 import javax.inject.Inject;
 import javax.inject.Provider;
 
-import org.springframework.lang.Nullable;
-
-import org.apache.causeway.applib.jaxb.JavaSqlXMLGregorianCalendarMarshalling;
 import org.apache.causeway.applib.query.Query;
 import org.apache.causeway.applib.query.QueryRange;
 import org.apache.causeway.applib.services.bookmark.Bookmark;
 import org.apache.causeway.applib.services.command.Command;
 import org.apache.causeway.applib.services.factory.FactoryService;
 import org.apache.causeway.applib.services.repository.RepositoryService;
-import org.apache.causeway.applib.util.schema.CommandDtoUtils;
 import org.apache.causeway.commons.internal.base._Casts;
 import org.apache.causeway.core.config.environment.CausewaySystemEnvironment;
 import org.apache.causeway.schema.cmd.v2.CommandDto;
-import org.apache.causeway.schema.cmd.v2.CommandsDto;
-import org.apache.causeway.schema.cmd.v2.MapDto;
-import org.apache.causeway.schema.common.v2.InteractionType;
-
-import lombok.val;
+import org.springframework.lang.Nullable;
 
 /**
  * Provides supporting functionality for querying {@link CommandLogEntry command log entry} entities.
@@ -63,7 +54,6 @@ public abstract class CommandLogEntryRepositoryAbstract<C extends CommandLogEntr
 
     private final Class<C> commandLogEntryClass;
 
-
     protected CommandLogEntryRepositoryAbstract(final Class<C> commandLogEntryClass) {
         this.commandLogEntryClass = commandLogEntryClass;
     }
@@ -72,10 +62,12 @@ public Class<C> getEntityClass() {
         return commandLogEntryClass;
     }
 
+    @Override
     public C createEntryAndPersist(
             final Command command, final UUID parentInteractionIdIfAny, final ExecuteIn executeIn) {
         C c = factoryService.detachedEntity(commandLogEntryClass);
         c.sync(command);
+        c.setReplayState(ReplayState.UNDEFINED);
         c.setParentInteractionId(parentInteractionIdIfAny);
         c.setExecuteIn(executeIn);
         persist(c);
@@ -148,14 +140,14 @@ public List<CommandLogEntry> findCompleted() {
         );
     }
 
-
+    @Override
     public List<CommandLogEntry> findByTargetAndFromAndTo(
             final Bookmark target,
             final @Nullable LocalDate from,
             final @Nullable LocalDate to) {
 
-        val fromTs = toTimestampStartOfDayWithOffset(from, 0);
-        val toTs = toTimestampStartOfDayWithOffset(to, 1);
+        var fromTs = toTimestampStartOfDayWithOffset(from, 0);
+        var toTs = toTimestampStartOfDayWithOffset(to, 1);
 
         final Query<C> query;
         if(from != null) {
@@ -182,7 +174,6 @@ public List<CommandLogEntry> findByTargetAndFromAndTo(
         return _Casts.uncheckedCast(repositoryService().allMatches(query));
     }
 
-
     @Override
     public List<CommandLogEntry> findMostRecent() {
         return findMostRecent(100);
@@ -196,7 +187,6 @@ public List<CommandLogEntry> findMostRecent(final int limit) {
         );
     }
 
-
     @Override
     public List<CommandLogEntry> findRecentByUsername(final String username) {
         return _Casts.uncheckedCast(
@@ -207,8 +197,7 @@ public List<CommandLogEntry> findRecentByUsername(final String username) {
         );
     }
 
-
-
+    @Override
     public List<CommandLogEntry> findRecentByTarget(final Bookmark target) {
         return _Casts.uncheckedCast(
                 repositoryService().allMatches(
@@ -219,6 +208,7 @@ public List<CommandLogEntry> findRecentByTarget(final Bookmark target) {
         );
     }
 
+    @Override
     public List<CommandLogEntry> findRecentByTargetOrResult(final Bookmark targetOrResult) {
         return _Casts.uncheckedCast(
                 repositoryService().allMatches(
@@ -229,7 +219,6 @@ public List<CommandLogEntry> findRecentByTargetOrResult(final Bookmark targetOrR
         );
     }
 
-
     /**
      * Intended to support the replay of commands on a secondary instance of
      * the application.
@@ -298,6 +287,7 @@ public List<CommandLogEntry> findBackgroundAndNotYetStarted() {
                     Query.named(commandLogEntryClass, CommandLogEntry.Nq.FIND_BACKGROUND_AND_NOT_YET_STARTED)));
     }
 
+    @Override
     public List<CommandLogEntry> findRecentBackgroundByTarget(final Bookmark target) {
         return _Casts.uncheckedCast(
                 repositoryService().allMatches(
@@ -308,7 +298,6 @@ public List<CommandLogEntry> findRecentBackgroundByTarget(final Bookmark target)
         );
     }
 
-
     /**
      * The most recent replayed command previously replicated from primary to
      * secondary.
@@ -344,58 +333,50 @@ public Optional<CommandLogEntry> findMostRecentCompleted() {
                     Query.named(commandLogEntryClass, CommandLogEntry.Nq.FIND_MOST_RECENT_COMPLETED))
         );
     }
-
     @Override
-    public List<CommandLogEntry> findNotYetReplayed() {
+    public List<CommandLogEntry> findReplayPendingOrFailed() {
         return _Casts.uncheckedCast(
                 repositoryService().allMatches(
                     Query.named(commandLogEntryClass, CommandLogEntry.Nq.FIND_BY_REPLAY_STATE)
-                        .withParameter("replayState", ReplayState.PENDING)
-                        .withLimit(10))
+                        .withParameter("replayState1", ReplayState.PENDING)
+                        .withParameter("replayState2", ReplayState.FAILED))
+        );
+    }
+    /**
+     * Command Replay feature: Cannot replay or retry.
+     */
+    @Override
+    public List<CommandLogEntry> findReplaySucceededOrExcluded() {
+        return _Casts.uncheckedCast(
+                repositoryService().allMatches(
+                    Query.named(commandLogEntryClass, CommandLogEntry.Nq.FIND_BY_REPLAY_STATE)
+                        .withParameter("replayState1", ReplayState.OK)
+                        .withParameter("replayState2", ReplayState.EXCLUDED))
         );
     }
 
+    @Override
+    public C saveForReplay(final CommandDto commandToReplay) {
 
-    public C saveForReplay(final CommandDto dto) {
-
-        if(dto.getMember().getInteractionType() == InteractionType.ACTION_INVOCATION) {
-            final MapDto userData = dto.getUserData();
-            if (userData == null ) {
-                throw new IllegalStateException(String.format(
-                        "Can only persist action DTOs with additional userData; got: \n%s",
-                        CommandDtoUtils.dtoMapper().toString(dto)));
-            }
-        }
-
-        final C commandJdo = factoryService.detachedEntity(commandLogEntryClass);
-
-        commandJdo.setInteractionId(UUID.fromString(dto.getInteractionId()));
-        commandJdo.setTimestamp(JavaSqlXMLGregorianCalendarMarshalling.toTimestamp(dto.getTimestamp()));
-        commandJdo.setUsername(dto.getUsername());
-
-        commandJdo.setReplayState(ReplayState.PENDING);
-
-        val firstTargetOidDto = dto.getTargets().getOid().get(0);
-        commandJdo.setTarget(Bookmark.forOidDto(firstTargetOidDto));
-        commandJdo.setCommandDto(dto);
-        commandJdo.setLogicalMemberIdentifier(dto.getMember().getLogicalMemberIdentifier());
-
-        persist(commandJdo);
+//TODO why?
+//        if(commandToReplay.getMember().getInteractionType() == InteractionType.ACTION_INVOCATION) {
+//            final MapDto userData = commandToReplay.getUserData();
+//            if (userData == null )
+//                throw new IllegalStateException(String.format(
+//                        "Can only persist action DTOs with additional userData; got: \n%s",
+//                        CommandDtoUtils.dtoMapper().toString(commandToReplay)));
+//        }
 
-        return commandJdo;
-    }
+        final C entity = factoryService.detachedEntity(commandLogEntryClass);
+        entity.init(commandToReplay, ReplayState.PENDING, 0);
+        entity.setParentInteractionId(null); // n/a for replay
+        entity.setExecuteIn(null); // to be specified later depending on user action
 
+        persist(entity);
 
-    public List<CommandLogEntry> saveForReplay(final CommandsDto commandsDto) {
-        val commandDtos = commandsDto.getCommandDto();
-        val commands = new ArrayList<CommandLogEntry>();
-        for (val dto : commandDtos) {
-            commands.add(saveForReplay(dto));
-        }
-        return commands;
+        return entity;
     }
 
-
     @Override
     public void persist(final CommandLogEntry commandLogEntry) {
         repositoryService().persistAndFlush(commandLogEntry);
@@ -408,7 +389,6 @@ public void truncateLog() {
 
     // --
 
-
     @Override
     public List<CommandLogEntry> findCommandsOnPrimaryElseFail(
             final @Nullable UUID interactionId,
@@ -421,10 +401,8 @@ public List<CommandLogEntry> findCommandsOnPrimaryElseFail(
         return commands;
     }
 
-
-
     private C findByInteractionIdElseNull(final UUID interactionId) {
-        val q = Query.named(commandLogEntryClass, CommandLogEntry.Nq.FIND_BY_INTERACTION_ID)
+        var q = Query.named(commandLogEntryClass, CommandLogEntry.Nq.FIND_BY_INTERACTION_ID)
                 .withParameter("interactionId", interactionId);
         return repositoryService().uniqueMatch(q).orElse(null);
     }
@@ -435,9 +413,9 @@ private List<CommandLogEntry> findSince(
 
         // DN generates incorrect SQL for SQL Server if count set to 1; so we set to 2 and then trim
         // XXX that's a historic workaround, should rather be fixed upstream
-        val needsTrimFix = batchSize != null && batchSize == 1;
+        var needsTrimFix = batchSize != null && batchSize == 1;
 
-        val q = Query.named(commandLogEntryClass, CommandLogEntry.Nq.FIND_SINCE)
+        var q = Query.named(commandLogEntryClass, CommandLogEntry.Nq.FIND_SINCE)
                 .withParameter("timestamp", timestamp)
                 .withRange(QueryRange.limit(
                         needsTrimFix ? 2L : batchSize
@@ -449,10 +427,6 @@ private List<CommandLogEntry> findSince(
                 : commandJdos;
     }
 
-
-
-
-
     private RepositoryService repositoryService() {
         return repositoryServiceProvider.get();
     }
@@ -479,7 +453,6 @@ public List<CommandLogEntry> findAll() {
         return _Casts.uncheckedCast(repositoryService().allInstances(commandLogEntryClass));
     }
 
-
     /**
      * intended for testing purposes only
      */
@@ -491,5 +464,4 @@ public void removeAll() {
         repositoryService().removeAll(commandLogEntryClass);
     }
 
-
 }
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/ReplayState.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/ReplayState.java
index 30a137e1aa3..e644cd240d6 100644
--- a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/ReplayState.java
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/ReplayState.java
@@ -18,20 +18,22 @@
  */
 package org.apache.causeway.extensions.commandlog.applib.dom;
 
+import org.springframework.lang.Nullable;
+
 /**
- * Curently unused.
- *
- * <p>
- *     This enum to support the (incubating) <i>Command Replay</i> extension.
- * </p>
+ * Introduced in support of the Command Replay Feature.
  *
  * @since 2.x {@index}
  */
 public enum ReplayState {
     /**
-     * As used on primary system.
+     * As used on primary system, indicating an initial state.
      */
     UNDEFINED,
+    /**
+     * Marks a {@link CommandLogEntry} as exported, such that consecutive export actions will skip those.
+     */
+    EXPORTED,
     /**
      * For use on secondary system, indicates that the command has not yet been replayed.
      */
@@ -47,8 +49,39 @@ public enum ReplayState {
     /**
      * For use on secondary system, indicates that the command should not be replayed.
      */
-    EXCLUDED,
-    ;
+    EXCLUDED;
+
+    public boolean isExported() { return this == EXPORTED; }
+    public boolean isFailed() { return this == FAILED; }
+
+    public boolean canExport() {
+        return this == ReplayState.UNDEFINED;
+    }
+
+    public boolean canReplayOrRetryOrMarkForExclusion() {
+        return this == ReplayState.PENDING
+                || this == ReplayState.FAILED;
+    }
+
+    // -- NULL SAFE
+
+    public static boolean canExport(final @Nullable ReplayState replayState) {
+        return replayState!=null
+            ? replayState.canExport()
+            : true;
+    }
+
+    public static boolean canReplayOrRetryOrMarkForExclusion(final @Nullable ReplayState replayState) {
+        return replayState!=null
+            ? replayState.canReplayOrRetryOrMarkForExclusion()
+            : false;
+    }
+
+    public static boolean isExported(final ReplayState replayState) {
+        return replayState!=null
+                ? replayState.isExported()
+                : false;
+    }
 
-    public boolean isFailed() { return this == FAILED;}
 }
+
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandExportManager.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandExportManager.java
new file mode 100644
index 00000000000..f8d878143c3
--- /dev/null
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandExportManager.java
@@ -0,0 +1,185 @@
+/*
+ *  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 org.apache.causeway.extensions.commandlog.applib.dom.replay;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.experimental.Accessors;
+
+import org.apache.causeway.applib.ViewModel;
+import org.apache.causeway.applib.annotation.Action;
+import org.apache.causeway.applib.annotation.ActionLayout;
+import org.apache.causeway.applib.annotation.Collection;
+import org.apache.causeway.applib.annotation.CollectionLayout;
+import org.apache.causeway.applib.annotation.DomainObject;
+import org.apache.causeway.applib.annotation.DomainObjectLayout;
+import org.apache.causeway.applib.annotation.Introspection;
+import org.apache.causeway.applib.annotation.ObjectSupport;
+import org.apache.causeway.applib.annotation.SemanticsOf;
+import org.apache.causeway.applib.util.schema.CommandDtoUtils;
+import org.apache.causeway.applib.value.Blob;
+import org.apache.causeway.applib.value.Clob;
+import org.apache.causeway.applib.value.NamedWithMimeType.CommonMimeType;
+import org.apache.causeway.extensions.commandlog.applib.CausewayModuleExtCommandLogApplib;
+import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntry;
+import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntryRepository;
+import org.apache.causeway.extensions.commandlog.applib.dom.ReplayState;
+
+@DomainObject(introspection = Introspection.ANNOTATION_REQUIRED)
+@DomainObjectLayout(cssClassFa = "solid share-from-square")
+@Named(CommandExportManager.LOGICAL_TYPE_NAME)
+@AllArgsConstructor
+public final class CommandExportManager implements ViewModel {
+	
+	public static final String LOGICAL_TYPE_NAME = CausewayModuleExtCommandLogApplib.NAMESPACE + ".CommandExportManager";
+	
+	@Getter @Accessors(fluent = true)
+	private final ReplayContext replayContext;
+
+    @Inject
+    public CommandExportManager(
+            final String memento,
+            final ReplayContext replayContext) {
+        this(replayContext);
+    }
+
+    @ObjectSupport public String title() {
+        return "Command Export Manager";
+    }
+
+    @Action(semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE)
+    @ActionLayout(
+            sequence = "0.1",
+            describedAs = "Deletes all commands, regardless of state (cannot be undone)")
+    public CommandExportManager deleteAll() {
+        commandLogEntryRepository().removeAll();
+        return this;
+    }
+
+    // -- NOT YET EXPORTED
+
+    @Collection
+    @CollectionLayout(
+            describedAs = "Commands that can be exported")
+    public List<ReplayableCommand> getNotYetExported() {
+        return commandLogEntryRepository().findAll().stream()
+            .filter(entry->ReplayState.canExport(entry.getReplayState()))
+            .map(entry->new ReplayableCommand(
+                    replayContext.bookmarkService().bookmarkFor(entry).get().getIdentifier(),
+                    replayContext))
+            .collect(Collectors.toList());
+    }
+
+    @Action(choicesFrom = "notYetExported", semantics = SemanticsOf.NON_IDEMPOTENT)
+    @ActionLayout(associateWith = "notYetExported",
+        sequence = "1.1",
+        cssClassFa = "solid share-from-square",
+        cssClass = "btn-primary",
+        describedAs = "Exports selected Commands as zipped DTOs for import later. "
+                + "(You need to refresh the page to see changed states.)")
+    public Blob exportSelected(
+            final List<ReplayableCommand> selected) {
+
+        var selectedCommandLogEntries = selected.stream()
+            .map(ReplayableCommand::commandLogEntry)
+            .filter(Optional::isPresent)
+            .map(Optional::get)
+            .sorted()
+            .collect(Collectors.toList());
+
+        var yaml = CommandDtoUtils.toYaml(
+            selectedCommandLogEntries.stream()
+                .filter(entry->ReplayState.isExported(entry.getReplayState()))
+                .map(CommandLogEntry::getCommandDto)
+                .collect(Collectors.toList()));
+
+        var blob = Clob.of("commands.yaml", CommonMimeType.YAML, yaml)
+                .toBlobUtf8()
+                .zip();
+
+        // do this last once we have successfully created the Clob
+        selectedCommandLogEntries.forEach(c->c.setReplayState(ReplayState.EXPORTED));
+
+        return blob;
+    }
+
+    @Action(choicesFrom = "notYetExported")
+    @ActionLayout(associateWith = "notYetExported", sequence = "1.2",
+            describedAs = "Deletes selected Commands (cannot be undone)")
+    public CommandExportManager deleteSelected(final List<ReplayableCommand> selected) {
+        selected.stream()
+            .forEach(ReplayableCommand::delete); // filtered on its own responsibility
+        return this;
+    }
+
+    // -- EXPORTED
+
+    @Collection
+    @CollectionLayout(
+            describedAs = "Commands that were exported")
+    public List<ReplayableCommand> getExported() {
+        return commandLogEntryRepository().findAll().stream()
+            .filter(entry->ReplayState.isExported(entry.getReplayState()))
+            .map(entry->new ReplayableCommand(
+                    replayContext.bookmarkService().bookmarkFor(entry).get().getIdentifier(),
+                    replayContext))
+            .collect(Collectors.toList());
+    }
+
+    @Action(choicesFrom = "exported")
+    @ActionLayout(associateWith = "exported", sequence = "2.1",
+            describedAs = "Makes selected Commands exportable (again)")
+    public CommandExportManager makeSelectedExportable(final List<ReplayableCommand> selected) {
+        selected.stream()
+            .forEach(ReplayableCommand::makeExportable); // filtered on its own responsibility
+        return this;
+    }
+
+    @Action(choicesFrom = "exported")
+    @ActionLayout(associateWith = "exported", sequence = "2.2",
+            named = "Delete Selected",
+            describedAs = "Deletes selected Commands (cannot be undone)")
+    public CommandExportManager deleteSelected2(final List<ReplayableCommand> selected) {
+        selected.stream()
+            .forEach(ReplayableCommand::delete); // filtered on its own responsibility
+        return this;
+    }
+
+    // -- VM STATE
+
+    @Override
+    public String viewModelMemento() {
+        // TODO could use to store filter state
+        return null;
+    }
+
+    // -- HELPER
+
+    private CommandLogEntryRepository commandLogEntryRepository() {
+        return replayContext.commandLogEntryRepository();
+    }
+
+}
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandExportManager.layout.fallback.xml b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandExportManager.layout.fallback.xml
new file mode 100644
index 00000000000..df20c9b73aa
--- /dev/null
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandExportManager.layout.fallback.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?><bs:grid xmlns:bs="https://causeway.apache.org/applib/layout/grid/bootstrap3" xmlns:lnk="https://causeway.apache.org/applib/layout/links" xmlns:cpt="https://causeway.apache.org/applib/layout/component" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://causeway.apache.org/applib/layout/component https://causeway.apache.org/applib/layout/component/component.xsd https://causeway.apache.org/applib/layout/links https://caus [...]
+    <bs:row>
+        <bs:col span="8" unreferencedActions="true">
+            <cpt:domainObject/>
+        </bs:col>
+        <bs:col span="4">
+            <bs:tabGroup>
+                <bs:tab name="Identity">
+                    <bs:row>
+                        <bs:col span="12">
+                            <cpt:fieldSet name="Identity" id="identity"/>
+                        </bs:col>
+                    </bs:row>
+                </bs:tab>
+                <bs:tab name="Other">
+                    <bs:row>
+                        <bs:col span="12">
+                            <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/>
+                        </bs:col>
+                    </bs:row>
+                </bs:tab>
+                <bs:tab name="Metadata">
+                    <bs:row>
+                        <bs:col span="12">
+                            <cpt:fieldSet name="Metadata" id="metadata"/>
+                        </bs:col>
+                    </bs:row>
+                </bs:tab>
+            </bs:tabGroup>
+        </bs:col>
+    </bs:row>
+    <bs:row>
+        <bs:col span="12">
+            <bs:row>
+                <bs:col span="12" size="MD">
+                    <cpt:collection defaultView="table" paged="15" id="notYetExported"/>
+                </bs:col>
+            </bs:row>
+            <bs:row>
+                <bs:col span="12" size="MD">
+                    <cpt:collection defaultView="table" paged="15" id="exported"/>
+                </bs:col>
+            </bs:row>
+        </bs:col>
+    </bs:row>
+    <bs:row>
+        <bs:col span="12">
+            <bs:tabGroup unreferencedCollections="true">
+            </bs:tabGroup>
+        </bs:col>
+    </bs:row>
+</bs:grid>
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandReplayManager.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandReplayManager.java
new file mode 100644
index 00000000000..ba592c5c7f8
--- /dev/null
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandReplayManager.java
@@ -0,0 +1,187 @@
+/*
+ *  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 org.apache.causeway.extensions.commandlog.applib.dom.replay;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.causeway.applib.ViewModel;
+import org.apache.causeway.applib.annotation.Action;
+import org.apache.causeway.applib.annotation.ActionLayout;
+import org.apache.causeway.applib.annotation.Collection;
+import org.apache.causeway.applib.annotation.CollectionLayout;
+import org.apache.causeway.applib.annotation.DomainObject;
+import org.apache.causeway.applib.annotation.DomainObjectLayout;
+import org.apache.causeway.applib.annotation.Introspection;
+import org.apache.causeway.applib.annotation.ObjectSupport;
+import org.apache.causeway.applib.annotation.Parameter;
+import org.apache.causeway.applib.annotation.SemanticsOf;
+import org.apache.causeway.applib.util.schema.CommandDtoUtils;
+import org.apache.causeway.applib.value.Blob;
+import org.apache.causeway.applib.value.NamedWithMimeType.CommonMimeType;
+import org.apache.causeway.extensions.commandlog.applib.CausewayModuleExtCommandLogApplib;
+import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntryRepository;
+import org.apache.causeway.schema.cmd.v2.CommandDto;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.experimental.Accessors;
+
+@DomainObject(introspection = Introspection.ANNOTATION_REQUIRED)
+@DomainObjectLayout(cssClassFa = "solid circle-play")
+@Named(CommandReplayManager.LOGICAL_TYPE_NAME)
+@AllArgsConstructor
+public final class CommandReplayManager implements ViewModel {
+	
+    public static final String LOGICAL_TYPE_NAME = CausewayModuleExtCommandLogApplib.NAMESPACE + ".CommandReplayManager";
+    
+    @Getter @Accessors(fluent = true)
+	private final ReplayContext replayContext;
+
+    @Inject
+    public CommandReplayManager(
+            final String memento,
+            final ReplayContext replayContext) {
+        this(replayContext);
+    }
+
+    @ObjectSupport public String title() {
+        return "Command Replay Manager";
+    }
+
+    @Action
+    @ActionLayout(
+            sequence = "0.1",
+            cssClass = "btn-primary",
+            describedAs = "Imports commands from a zipped yaml, then persists them with replayState=PENDING.")
+    public CommandReplayManager importCommands(
+            @Parameter(fileAccept = ".zip")
+            final Blob zippedCommandsYaml) {
+
+        var yamlDs = zippedCommandsYaml.unZip(CommonMimeType.YAML).asDataSource();
+
+        final List<CommandDto> commandDtos = CommandDtoUtils.fromYaml(yamlDs);
+        commandDtos.forEach(commandLogEntryRepository()::saveForReplay);
+
+        return this;
+    }
+
+    @Action(semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE)
+    @ActionLayout(
+            sequence = "0.2",
+            describedAs = "Deletes all commands, regardless of state (cannot be undone)")
+    public CommandReplayManager deleteAll() {
+        commandLogEntryRepository().removeAll();
+        return this;
+    }
+
+    // -- PENDING OR FAILED
+
+    @Collection
+    @CollectionLayout(
+            describedAs = "Imported Commands that can be either replayed (replayState=PENDING) or retried (when replayState=FAILED)")
+    public List<ReplayableCommand> getPendingOrFailed() {
+        return commandLogEntryRepository().findReplayPendingOrFailed().stream()
+            .map(entry->new ReplayableCommand(
+                    replayContext.bookmarkService().bookmarkFor(entry).get().getIdentifier(),
+                    replayContext))
+            .collect(Collectors.toList());
+    }
+
+    @Action(choicesFrom = "pendingOrFailed")
+    @ActionLayout(associateWith = "pendingOrFailed",
+        sequence = "1.1",
+        cssClassFa = "solid circle-play",
+        cssClass = "btn-primary",
+        describedAs = "Executes the list of commands in sequence, after having sorted them by their timestamp. "
+                + "If any of the given commands fails, "
+                + "the surrounding transaction is rolled back and any successful commands are undone). "
+                + "The command, that caused the failure, gets marked as FAILED.")
+    public CommandReplayManager replayOrRetrySelected(final List<ReplayableCommand> selected) {
+        var replayables = selected.stream()
+            .sorted()
+            .collect(Collectors.toList());
+        for(var replayableCommand : replayables) {
+            var tryReplayOrRetry = replayableCommand.tryReplayOrRetry(); // filtered on its own responsibility
+            if(tryReplayOrRetry.isFailure())
+                return this; // stop further execution
+        }
+        return this;
+    }
+
+    @Action(choicesFrom = "pendingOrFailed")
+    @ActionLayout(associateWith = "pendingOrFailed", sequence = "1.2",
+            describedAs = "Marks selected Commands to be EXCLUDED from replay")
+    public CommandReplayManager excludeSelectedFromReplay(final List<ReplayableCommand> selected) {
+        selected.stream()
+            .forEach(ReplayableCommand::excludeFromReplay); // filtered on its own responsibility
+        return this;
+    }
+
+    @Action(choicesFrom = "pendingOrFailed")
+    @ActionLayout(associateWith = "pendingOrFailed", sequence = "1.3",
+            describedAs = "Deletes selected Commands (cannot be undone)")
+    public CommandReplayManager deleteSelected(final List<ReplayableCommand> selected) {
+        selected.stream()
+            .forEach(ReplayableCommand::delete); // filtered on its own responsibility
+        return this;
+    }
+
+    // -- OK OR EXCLUDE
+
+    @Collection
+    @CollectionLayout(
+            describedAs = "Imported Commands that were either replayed with success (replayState=OK) "
+                    + "or marked to be excluded from replay (replayState=EXCLUDE)")
+    public List<ReplayableCommand> getSucceededOrExcluded() {
+        return commandLogEntryRepository().findReplaySucceededOrExcluded().stream()
+            .map(entry->new ReplayableCommand(
+                    replayContext.bookmarkService().bookmarkFor(entry).get().getIdentifier(),
+                    replayContext))
+            .collect(Collectors.toList());
+    }
+
+    @Action(choicesFrom = "succeededOrExcluded")
+    @ActionLayout(associateWith = "succeededOrExcluded",
+            named = "Delete Selected",
+            describedAs = "Deletes selected Commands (cannot be undone)")
+    public CommandReplayManager deleteSelected2(final List<ReplayableCommand> selected) {
+        selected.stream()
+            .forEach(ReplayableCommand::delete); // filtered on its own responsibility
+        return this;
+    }
+
+    // -- VM STATE
+
+    @Override
+    public String viewModelMemento() {
+        // TODO could use to store filter state
+        return null;
+    }
+
+    // -- HELPER
+
+    private CommandLogEntryRepository commandLogEntryRepository() {
+        return replayContext.commandLogEntryRepository();
+    }
+
+}
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandReplayManager.layout.fallback.xml b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandReplayManager.layout.fallback.xml
new file mode 100644
index 00000000000..30489ca2158
--- /dev/null
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/CommandReplayManager.layout.fallback.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?><bs:grid xmlns:bs="https://causeway.apache.org/applib/layout/grid/bootstrap3" xmlns:lnk="https://causeway.apache.org/applib/layout/links" xmlns:cpt="https://causeway.apache.org/applib/layout/component" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://causeway.apache.org/applib/layout/component https://causeway.apache.org/applib/layout/component/component.xsd https://causeway.apache.org/applib/layout/links https://caus [...]
+    <bs:row>
+        <bs:col span="8" unreferencedActions="true">
+            <cpt:domainObject/>
+        </bs:col>
+        <bs:col span="4">
+            <bs:tabGroup>
+                <bs:tab name="Identity">
+                    <bs:row>
+                        <bs:col span="12">
+                            <cpt:fieldSet name="Identity" id="identity"/>
+                        </bs:col>
+                    </bs:row>
+                </bs:tab>
+                <bs:tab name="Other">
+                    <bs:row>
+                        <bs:col span="12">
+                            <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/>
+                        </bs:col>
+                    </bs:row>
+                </bs:tab>
+                <bs:tab name="Metadata">
+                    <bs:row>
+                        <bs:col span="12">
+                            <cpt:fieldSet name="Metadata" id="metadata"/>
+                        </bs:col>
+                    </bs:row>
+                </bs:tab>
+            </bs:tabGroup>
+        </bs:col>
+    </bs:row>
+    <bs:row>
+        <bs:col span="12">
+            <bs:row>
+                <bs:col span="12" size="MD">
+                    <cpt:collection defaultView="table" paged="15" id="pendingOrFailed"/>
+                </bs:col>
+            </bs:row>
+            <bs:row>
+                <bs:col span="12" size="MD">
+                    <cpt:collection defaultView="table" paged="15" id="succeededOrExcluded"/>
+                </bs:col>
+            </bs:row>
+        </bs:col>
+    </bs:row>
+    <bs:row>
+        <bs:col span="12">
+            <bs:tabGroup unreferencedCollections="true">
+            </bs:tabGroup>
+        </bs:col>
+    </bs:row>
+</bs:grid>
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/ReplayContext.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/ReplayContext.java
new file mode 100644
index 00000000000..fee5baf5ef5
--- /dev/null
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/ReplayContext.java
@@ -0,0 +1,40 @@
+/*
+ *  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 org.apache.causeway.extensions.commandlog.applib.dom.replay;
+
+import org.apache.causeway.applib.services.bookmark.BookmarkService;
+import org.apache.causeway.applib.services.command.CommandExecutorService;
+import org.apache.causeway.applib.services.iactnlayer.InteractionService;
+import org.apache.causeway.applib.services.repository.RepositoryService;
+import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntryRepository;
+
+import lombok.Value;
+import lombok.experimental.Accessors;
+
+/**
+ * Bundles dependencies for the replay logic.
+ */
+@Value @Accessors(fluent = true)
+public final class ReplayContext {
+        BookmarkService bookmarkService;
+        RepositoryService repositoryService;
+        InteractionService interactionService;
+        CommandLogEntryRepository commandLogEntryRepository;
+        CommandExecutorService commandExecutorService;
+}
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/ReplayableCommand.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/ReplayableCommand.java
new file mode 100644
index 00000000000..7530a94eb05
--- /dev/null
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/ReplayableCommand.java
@@ -0,0 +1,406 @@
+/*
+ *  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 org.apache.causeway.extensions.commandlog.applib.dom.replay;
+
+import java.time.ZonedDateTime;
+import java.util.Comparator;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.Executors;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.causeway.applib.ViewModel;
+import org.apache.causeway.applib.annotation.Action;
+import org.apache.causeway.applib.annotation.ActionLayout;
+import org.apache.causeway.applib.annotation.DomainObject;
+import org.apache.causeway.applib.annotation.DomainObjectLayout;
+import org.apache.causeway.applib.annotation.Introspection;
+import org.apache.causeway.applib.annotation.LabelPosition;
+import org.apache.causeway.applib.annotation.MemberSupport;
+import org.apache.causeway.applib.annotation.ObjectSupport;
+import org.apache.causeway.applib.annotation.Property;
+import org.apache.causeway.applib.annotation.PropertyLayout;
+import org.apache.causeway.applib.annotation.Where;
+import org.apache.causeway.applib.jaxb.JavaTimeXMLGregorianCalendarMarshalling;
+import org.apache.causeway.applib.services.bookmark.Bookmark;
+import org.apache.causeway.applib.services.command.CommandExecutorService.InteractionContextPolicy;
+import org.apache.causeway.commons.functional.Try;
+import org.apache.causeway.commons.internal.base._Refs.ObjectReference;
+import org.apache.causeway.commons.internal.base._Strings;
+import org.apache.causeway.commons.internal.exceptions._Exceptions;
+import org.apache.causeway.commons.io.JsonUtils;
+import org.apache.causeway.commons.io.TextUtils;
+import org.apache.causeway.commons.io.YamlUtils;
+import org.apache.causeway.extensions.commandlog.applib.CausewayModuleExtCommandLogApplib;
+import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntry;
+import org.apache.causeway.extensions.commandlog.applib.dom.ExecuteIn;
+import org.apache.causeway.extensions.commandlog.applib.dom.ReplayState;
+import org.apache.causeway.schema.cmd.v2.CommandDto;
+import org.apache.causeway.schema.cmd.v2.MemberDto;
+import org.apache.causeway.schema.common.v2.OidDto;
+import org.apache.causeway.valuetypes.asciidoc.applib.value.AsciiDoc;
+import org.apache.causeway.valuetypes.asciidoc.builder.AsciiDocBuilder;
+import org.apache.causeway.valuetypes.asciidoc.builder.AsciiDocFactory;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Value;
+import lombok.experimental.Accessors;
+
+/**
+ * Viewmodel that wraps a {@link CommandLogEntry}.
+ */
+@DomainObject(introspection = Introspection.ENCAPSULATION_ENABLED)
+@DomainObjectLayout(cssClassFa = "terminal")
+@Named(ReplayableCommand.LOGICAL_TYPE_NAME)
+@AllArgsConstructor
+public final class ReplayableCommand implements ViewModel, Comparable<ReplayableCommand> {
+	
+	@Getter @Accessors(fluent = true)
+	private final String commandLogEntryId;
+	
+	@Getter @Accessors(fluent = true)
+	private final ReplayContext replayContext;
+	
+	@Getter @Accessors(fluent = true)
+	private final ObjectReference<CommandRecord> recordRef;
+
+    public static final String LOGICAL_TYPE_NAME = CausewayModuleExtCommandLogApplib.NAMESPACE + ".ReplayableCommand";
+
+    // decoupled from the underlying entity
+    @Value @Accessors(fluent = true)
+    final static class CommandRecord {
+    	
+	    final CommandDto commandDto;
+	    final ReplayState replayState;
+        
+        boolean canReplayOrRetryOrMarkForExclusion() {
+            return replayState.canReplayOrRetryOrMarkForExclusion();
+        }
+        public String faQuickIcon() {
+            switch(replayState) {
+                case UNDEFINED: return "solid terminal .col-indigo";
+                case EXPORTED:  return "solid terminal .col-indigo, solid circle-arrow-right .ov-size-80 .ov-right-45 .ov-bottom-45 .col-dodgerblue";
+                case PENDING:   return "solid terminal .col-indigo, solid circle-pause       .ov-size-80 .ov-right-45 .ov-bottom-45 .col-gold";
+                case OK:        return "solid terminal .col-indigo, solid circle-check       .ov-size-80 .ov-right-45 .ov-bottom-45 .col-green";
+                case FAILED:    return "solid terminal .col-indigo, solid circle-exclamation .ov-size-80 .ov-right-45 .ov-bottom-45 .col-red";
+                case EXCLUDED:  return "solid terminal .col-indigo, solid circle-xmark       .ov-size-80 .ov-right-45 .ov-bottom-45 .col-grey";
+            };
+			return null;
+        }
+    }
+
+    @Inject
+    public ReplayableCommand(
+            final String memento,
+            final ReplayContext replayContext) {
+        this(memento, replayContext, new ObjectReference<>(null));
+    }
+
+    @ObjectSupport public String title() {
+        return "Replayable Command";
+    }
+
+//requires v4    
+//    @ObjectSupport public ObjectSupport.IconResource icon(final ObjectSupport.IconSize iconSize) {
+//        return commandRecord()
+//                .map(CommandRecord::faQuickIcon)
+//                .map(FontAwesomeLayers::fromQuickNotation)
+//                .map(ObjectSupport.FontAwesomeIconResource::new)
+//                .orElse(null);
+//    }
+
+    @Property
+    @PropertyLayout(
+            sequence = "1.1",
+            fieldSetId = "details",
+            describedAs = "UUID of the original (replayabel) Command")
+    public UUID getInteractionId() {
+        return commandRecord()
+            .map(CommandRecord::commandDto)
+            .map(CommandDto::getInteractionId)
+            .map(UUID::fromString)
+            .orElse(null);
+    }
+
+    @Property
+    @PropertyLayout(
+            sequence = "1.2",
+            fieldSetId = "details",
+            describedAs = "Timestamp of the original (replayabel) Command")
+    public ZonedDateTime getTimestamp() {
+        return commandRecord()
+            .map(CommandRecord::commandDto)
+            .map(CommandDto::getTimestamp)
+            .map(JavaTimeXMLGregorianCalendarMarshalling::toZonedDateTime)
+            .orElse(null);
+    }
+
+    @Property
+    @PropertyLayout(
+            sequence = "2.1",
+            fieldSetId = "details",
+            describedAs = "Target Type of the original (replayabel) Command")
+    public String getTargetType() {
+        return commandRecord()
+            .map(CommandRecord::commandDto)
+            .map(commandDto->commandDto.getTargets().getOid().get(0))
+            .map(OidDto::getType)
+            .orElse(null);
+    }
+
+    @Property
+    @PropertyLayout(
+            sequence = "2.2",
+            fieldSetId = "details",
+            describedAs = "Target ID of the original (replayabel) Command")
+    public String getTargetId() {
+        return commandRecord()
+            .map(CommandRecord::commandDto)
+            .map(commandDto->commandDto.getTargets().getOid().get(0))
+            .map(OidDto::getId)
+            .map(id->_Strings.ellipsifyAtEnd(id, 10, "..."))
+            .orElse(null);
+    }
+
+    @Property
+    @PropertyLayout(
+            sequence = "3.1",
+            fieldSetId = "details",
+            describedAs = "Replayabel Action or Property, that was executed as captured by the original Command")
+    public String getMember() {
+        return commandRecord()
+            .map(CommandRecord::commandDto)
+            .map(CommandDto::getMember)
+            .map(MemberDto::getLogicalMemberIdentifier)
+            .map(TextUtils::cutter)
+            .map(cutter->cutter.keepAfter("#").getValue())
+            .orElse(null);
+    }
+
+    @Property
+    @PropertyLayout(
+            sequence = "4",
+            fieldSetId = "details",
+            describedAs = "Replay State of the original (replayabel) Command. "
+                    + "When imported initially is PENDING. "
+                    + "Then after replay its either OK or FAILED. "
+                    + "Can be manually set to EXCLUDED, which marks it to be ignored for replay.")
+    public ReplayState getReplayState() {
+        return commandRecord()
+            .map(CommandRecord::replayState)
+            .orElse(null);
+    }
+
+    @Property
+    @PropertyLayout(
+            sequence = "9",
+            fieldSetId = "dto",
+            hidden = Where.ALL_TABLES,
+            labelPosition = LabelPosition.NONE,
+            describedAs = "DTO of the original (replayabel) Command")
+    public AsciiDoc getDto() {
+        return commandRecord()
+            .map(CommandRecord::commandDto)
+            .map(commandDto->YamlUtils.toStringUtf8(commandDto,
+                JsonUtils::onlyIncludeNonNull))
+            .map(yaml->new AsciiDocBuilder()
+                    .append(doc->AsciiDocFactory.sourceBlock(doc, "yaml", yaml))
+                    .buildAsValue())
+            .orElseGet(()->new AsciiDoc("empty"));
+    }
+
+    // -- ACTIONS
+
+    @Action
+    @ActionLayout(
+            sequence = "0.2",
+            describedAs = "Opens the associated Command Log Entry")
+    public CommandLogEntry openCommandLogEntry() {
+        return commandLogEntry()
+                .orElse(null);
+    }
+
+    @Action
+    @ActionLayout(
+            sequence = "0.1",
+            cssClassFa = "solid circle-play",
+            cssClass = "btn-primary")
+            //hidden = Where.NOWHERE) // show in tables //TODO NPE bug
+    public ReplayableCommand replayOrRetry() {
+        tryReplayOrRetry();
+        return this;
+    }
+    @MemberSupport private String disableReplayOrRetry() {
+        return commandRecord()
+            .map(CommandRecord::canReplayOrRetryOrMarkForExclusion)
+            .orElse(false)
+                ? null
+                : "Cannot replay, if neither PENDING nor FAILED";
+    }
+
+    @Action
+    @ActionLayout(
+            //hidden = Where.NOWHERE, // show in tables //TODO NPE bug
+            sequence = "2.1",
+            associateWith = "replayState",
+            describedAs = "Makes Command exportable (again)")
+    public ReplayableCommand makeExportable() {
+        if(disableMakeExportable()!=null)
+            return this; // safe guard when called programmatically
+        commandLogEntry()
+            .filter(commandLogEntry->ReplayState.isExported(commandLogEntry.getReplayState()))
+            .ifPresent(commandLogEntry->{
+                commandLogEntry.setReplayState(ReplayState.UNDEFINED);
+                invalidateCachedRecord();
+            });
+        return this;
+    }
+    @MemberSupport private String disableMakeExportable() {
+        return commandRecord()
+            .map(rec->ReplayState.isExported(rec.replayState()))
+            .orElse(false)
+                ? null
+                : "Cannot make exportable, if not EXPORTED";
+    }
+
+    @Action
+    @ActionLayout(
+            //hidden = Where.NOWHERE, // show in tables //TODO NPE bug
+            sequence = "2.2",
+            associateWith = "replayState",
+            describedAs = "Marks Command to be EXCLUDED from replay.")
+    public ReplayableCommand excludeFromReplay() {
+        if(disableExcludeFromReplay()!=null)
+            return this; // safe guard when called programmatically
+        commandLogEntry()
+            .filter(ReplayableCommand::canReplayOrRetryOrMarkForExclusion)
+            .ifPresent(commandLogEntry->{
+                commandLogEntry.setReplayState(ReplayState.EXCLUDED);
+                invalidateCachedRecord();
+            });
+        return this;
+    }
+    @MemberSupport private String disableExcludeFromReplay() {
+        return commandRecord()
+            .map(CommandRecord::canReplayOrRetryOrMarkForExclusion)
+            .orElse(false)
+                ? null
+                : "Cannot mark for exclusion, if neither PENDING nor FAILED";
+    }
+
+    @Action
+    @ActionLayout(
+            sequence = "0.3",
+            //hidden = Where.NOWHERE, // show in tables //TODO NPE bug
+            describedAs = "Deletes the associated Command Log Entry (cannot be undone)")
+    public void delete() {
+        commandLogEntry()
+            .ifPresent(commandLogEntry->{
+                replayContext.repositoryService().remove(commandLogEntry);
+                invalidateCachedRecord();
+            });
+    }
+
+    // -- EXECUTION ORDER GOVERNED BY TIMESTAMP
+
+    private static final Comparator<ReplayableCommand> TIMESTAMP_COMPARATOR =
+            Comparator.nullsLast(Comparator.comparing(ReplayableCommand::getTimestamp));
+
+    @Override
+    public int compareTo(final ReplayableCommand other) {
+        return TIMESTAMP_COMPARATOR.compare(this, other);
+    }
+
+    // -- VM STATE
+
+    @Override
+    public String viewModelMemento() {
+        return commandLogEntryId;
+    }
+
+    // -- UTIL
+
+    Try<ReplayableCommand> tryReplayOrRetry() {
+        if(disableReplayOrRetry()!=null)
+            return Try.success(null); // guard against disallowed invocation
+        return commandLogEntry()
+            .filter(ReplayableCommand::canReplayOrRetryOrMarkForExclusion)
+            .map(commandLogEntry->{
+                commandLogEntry.setExecuteIn(ExecuteIn.FOREGROUND);
+                var tryResultBookmark = replayContext.commandExecutorService().executeCommand(
+                        InteractionContextPolicy.SWITCH_USER_AND_TIME,
+                        commandLogEntry.getCommandDto());
+
+                // handle the replay outcome
+                tryResultBookmark.accept(
+                        ex->onReplayError(commandLogEntry.getInteractionId(), ex),
+                        bookmarkOpt->commandLogEntry.setReplayState(ReplayState.OK));
+
+                invalidateCachedRecord();
+
+                return tryResultBookmark
+                        .mapSuccessAsNullable(__->this);
+            })
+            .orElseGet(()->Try.success(null));
+    }
+
+    // -- HELPER
+
+    private void invalidateCachedRecord() {
+        recordRef.update(__->null); // invalidate cache
+    }
+
+    private Optional<CommandRecord> commandRecord() {
+        return Optional.ofNullable(recordRef.computeIfAbsent(()->
+            commandLogEntry()
+                .filter(commandLogEntry->commandLogEntry.getCommandDto()!=null)
+                .filter(commandLogEntry->commandLogEntry.getReplayState()!=null)
+                .map(commandLogEntry->new CommandRecord(
+                        commandLogEntry.getCommandDto(),
+                        commandLogEntry.getReplayState()))
+                .orElse(null)));
+    }
+
+    Optional<CommandLogEntry> commandLogEntry() {
+        return replayContext.bookmarkService().lookup(commandLogEntryBookmark(), CommandLogEntry.class);
+    }
+
+    private Bookmark commandLogEntryBookmark() {
+        return replayContext.bookmarkService()
+            .bookmarkFor(CommandLogEntry.class, commandLogEntryId)
+            .orElseThrow(()->_Exceptions.unrecoverable(
+                    "framework error: cannot create bookmark for CommandLogEntry using id '%s'",
+                    commandLogEntryId));
+    }
+
+    private static boolean canReplayOrRetryOrMarkForExclusion(final CommandLogEntry commandLogEntry) {
+        return ReplayState.canReplayOrRetryOrMarkForExclusion(commandLogEntry.getReplayState());
+    }
+
+    private void onReplayError(final UUID interactionId, final Throwable ex) {
+        Executors.newSingleThreadExecutor()
+            .submit(()->replayContext.interactionService().runAnonymous(()->
+                replayContext.commandLogEntryRepository().findByInteractionId(interactionId)
+                    .ifPresent(entry->entry.saveAnalysis(ex.toString()))));
+    }
+
+}
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/ReplayableCommand.layout.fallback.xml b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/ReplayableCommand.layout.fallback.xml
new file mode 100644
index 00000000000..0b6c5fee4d5
--- /dev/null
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/dom/replay/ReplayableCommand.layout.fallback.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?><bs:grid xmlns:bs="https://causeway.apache.org/applib/layout/grid/bootstrap3" xmlns:lnk="https://causeway.apache.org/applib/layout/links" xmlns:cpt="https://causeway.apache.org/applib/layout/component" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://causeway.apache.org/applib/layout/component https://causeway.apache.org/applib/layout/component/component.xsd https://causeway.apache.org/applib/layout/links https://caus [...]
+    <bs:row>
+        <bs:col span="8" unreferencedActions="true">
+            <cpt:domainObject/>
+        </bs:col>
+        <bs:col span="4">
+            <bs:tabGroup>
+                <bs:tab name="Identity">
+                    <bs:row>
+                        <bs:col span="12">
+                            <cpt:fieldSet name="Identity" id="identity"/>
+                        </bs:col>
+                    </bs:row>
+                </bs:tab>
+                <bs:tab name="Other">
+                    <bs:row>
+                        <bs:col span="12">
+                            <cpt:fieldSet name="Other" id="other" unreferencedProperties="true"/>
+                        </bs:col>
+                    </bs:row>
+                </bs:tab>
+                <bs:tab name="Metadata">
+                    <bs:row>
+                        <bs:col span="12">
+                            <cpt:fieldSet name="Metadata" id="metadata"/>
+                        </bs:col>
+                    </bs:row>
+                </bs:tab>
+            </bs:tabGroup>
+        </bs:col>
+    </bs:row>
+    <bs:row>
+        <bs:col span="6">
+            <cpt:fieldSet name="Details" id="details"/>
+        </bs:col>
+        <bs:col span="6">
+            <cpt:fieldSet name="Command Dto" id="dto"/>
+        </bs:col>
+    </bs:row>
+    <bs:row>
+        <bs:col span="12">
+            <bs:tabGroup unreferencedCollections="true"/>
+        </bs:col>
+    </bs:row>
+</bs:grid>
diff --git a/extensions/core/commandlog/applib/src/test/java/org/apache/causeway/extensions/commandlog/applib/integtest/CommandLog_IntegTestAbstract.java b/extensions/core/commandlog/applib/src/test/java/org/apache/causeway/extensions/commandlog/applib/integtest/CommandLog_IntegTestAbstract.java
index 0b69e6cc622..f1644491016 100644
--- a/extensions/core/commandlog/applib/src/test/java/org/apache/causeway/extensions/commandlog/applib/integtest/CommandLog_IntegTestAbstract.java
+++ b/extensions/core/commandlog/applib/src/test/java/org/apache/causeway/extensions/commandlog/applib/integtest/CommandLog_IntegTestAbstract.java
@@ -369,7 +369,7 @@ void test_all_the_repository_methods() {
         val to = from.plusDays(1);
 
         // when
-        List<? extends CommandLogEntry> notYetReplayed = commandLogEntryRepository.findNotYetReplayed();
+        List<? extends CommandLogEntry> notYetReplayed = commandLogEntryRepository.findReplayPendingOrFailed();
 
         // then
         Assertions.assertThat(notYetReplayed).isEmpty();
@@ -382,7 +382,7 @@ void test_all_the_repository_methods() {
             commandTarget1User1.setReplayState(ReplayState.PENDING);
 
             // when
-            List<? extends CommandLogEntry> notYetReplayed2 = commandLogEntryRepository.findNotYetReplayed();
+            List<? extends CommandLogEntry> notYetReplayed2 = commandLogEntryRepository.findReplayPendingOrFailed();
 
             // then
             Assertions.assertThat(notYetReplayed2).hasSize(1);
diff --git a/extensions/core/commandlog/persistence-jdo/src/main/java/org/apache/causeway/extensions/commandlog/jdo/dom/CommandLogEntry.java b/extensions/core/commandlog/persistence-jdo/src/main/java/org/apache/causeway/extensions/commandlog/jdo/dom/CommandLogEntry.java
index 04a0b51f2e9..f13dda3e615 100644
--- a/extensions/core/commandlog/persistence-jdo/src/main/java/org/apache/causeway/extensions/commandlog/jdo/dom/CommandLogEntry.java
+++ b/extensions/core/commandlog/persistence-jdo/src/main/java/org/apache/causeway/extensions/commandlog/jdo/dom/CommandLogEntry.java
@@ -237,7 +237,7 @@ public CommandLogEntry(
             final CommandDto commandDto,
             final org.apache.causeway.extensions.commandlog.applib.dom.ReplayState replayState,
             final int targetIndex) {
-        super(commandDto, replayState, targetIndex);
+        init(commandDto, replayState, targetIndex);
     }
 
     @PrimaryKey
diff --git a/extensions/core/commandlog/persistence-jpa/src/main/java/org/apache/causeway/extensions/commandlog/jpa/dom/CommandLogEntry.java b/extensions/core/commandlog/persistence-jpa/src/main/java/org/apache/causeway/extensions/commandlog/jpa/dom/CommandLogEntry.java
index de36b0f1ca6..2e58da4f90d 100644
--- a/extensions/core/commandlog/persistence-jpa/src/main/java/org/apache/causeway/extensions/commandlog/jpa/dom/CommandLogEntry.java
+++ b/extensions/core/commandlog/persistence-jpa/src/main/java/org/apache/causeway/extensions/commandlog/jpa/dom/CommandLogEntry.java
@@ -235,7 +235,7 @@ public CommandLogEntry(
             final CommandDto commandDto,
             final org.apache.causeway.extensions.commandlog.applib.dom.ReplayState replayState,
             final int targetIndex) {
-        super(commandDto, replayState, targetIndex);
+        init(commandDto, replayState, targetIndex);
     }
 
 
diff --git a/incubator/extensions/core/commandreplay/secondary/src/main/java/org/apache/causeway/extensions/commandreplay/secondary/jobcallables/ReplicateAndRunCommands.java b/incubator/extensions/core/commandreplay/secondary/src/main/java/org/apache/causeway/extensions/commandreplay/secondary/jobcallables/ReplicateAndRunCommands.java
index a01bf730d18..63df7dfcba1 100644
--- a/incubator/extensions/core/commandreplay/secondary/src/main/java/org/apache/causeway/extensions/commandreplay/secondary/jobcallables/ReplicateAndRunCommands.java
+++ b/incubator/extensions/core/commandreplay/secondary/src/main/java/org/apache/causeway/extensions/commandreplay/secondary/jobcallables/ReplicateAndRunCommands.java
@@ -85,7 +85,7 @@ private void doCall() throws  StatusException  {
 
             // is there a pending command already?
             // (we fetch several at a time, so we may not have processed them all yet)
-            commandsToReplay = commandLogEntryRepository.findNotYetReplayed();
+            commandsToReplay = commandLogEntryRepository.findReplayPendingOrFailed();
 
             if(commandsToReplay.isEmpty()) {
 
diff --git a/incubator/extensions/core/commandreplay/secondary/src/main/java/org/apache/causeway/extensions/commandreplay/secondary/mixins/CommandLogEntry_replayQueue.java b/incubator/extensions/core/commandreplay/secondary/src/main/java/org/apache/causeway/extensions/commandreplay/secondary/mixins/CommandLogEntry_replayQueue.java
index a9078f9f7cb..683b4edb441 100644
--- a/incubator/extensions/core/commandreplay/secondary/src/main/java/org/apache/causeway/extensions/commandreplay/secondary/mixins/CommandLogEntry_replayQueue.java
+++ b/incubator/extensions/core/commandreplay/secondary/src/main/java/org/apache/causeway/extensions/commandreplay/secondary/mixins/CommandLogEntry_replayQueue.java
@@ -45,7 +45,7 @@ public static class CollectionDomainEvent
     final CommandLogEntry commandLogEntry;
 
     public List<? extends CommandLogEntry> coll() {
-        return commandLogEntryRepository.findNotYetReplayed();
+        return commandLogEntryRepository.findReplayPendingOrFailed();
     }
     public boolean hideColl() {
         return !secondaryConfig.isConfigured();