You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by da...@apache.org on 2026/06/08 07:37:24 UTC
(causeway) 19/27: CAUSEWAY-4024: adds move commands action proposal
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch CAUSEWAY-4025
in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 594d265f2c3b00c137f40121ddceea96d58a6f00
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Jun 8 07:48:00 2026 +0100
CAUSEWAY-4024: adds move commands action proposal
---
.../add-move-commands-action/.openspec.yaml | 2 +
.../changes/add-move-commands-action/design.md | 74 ++++++++++++++++++++
.../changes/add-move-commands-action/proposal.md | 28 ++++++++
.../command-export-command-reordering/spec.md | 80 ++++++++++++++++++++++
.../specs/command-export-known-targets/spec.md | 47 +++++++++++++
openspec/changes/add-move-commands-action/tasks.md | 50 ++++++++++++++
6 files changed, 281 insertions(+)
diff --git a/openspec/changes/add-move-commands-action/.openspec.yaml b/openspec/changes/add-move-commands-action/.openspec.yaml
new file mode 100644
index 00000000000..e8d4ccfe905
--- /dev/null
+++ b/openspec/changes/add-move-commands-action/.openspec.yaml
@@ -0,0 +1,2 @@
+schema: spec-driven
+created: 2026-06-08
diff --git a/openspec/changes/add-move-commands-action/design.md b/openspec/changes/add-move-commands-action/design.md
new file mode 100644
index 00000000000..569f2aac734
--- /dev/null
+++ b/openspec/changes/add-move-commands-action/design.md
@@ -0,0 +1,74 @@
+## Context
+
+`CommandExportManager` lists commands after a baseline and exports selected `ReplayableCommand` rows in timestamp order.
+Known-target validation treats menu-service roots and earlier command results as the only ways for selected action targets and reference parameters to be reachable in an exported sequence.
+When a developer records an action first and only later records the finder or navigation action that explains the missing target or parameter, selecting both commands still fails because the explanatory command is later in export order.
+The manager already exposes collection-associated actions such as `exportSelected` and `makeSelectedExportable`, so the reordering feature should fit the same UI model and operate on selected collection rows.
+
+## Goals / Non-Goals
+
+**Goals:**
+
+- Add a prototyping-only `CommandExportManager` action that moves one or more selected commands relative to another command at or after the baseline.
+- Exclude moved commands from the target choices so a command cannot be moved after itself.
+- Preserve the selected commands as a contiguous block and preserve their original internal timing gaps.
+- Retimestamp moved commands so the first moved command occurs 10ms after the chosen target command.
+- Let existing export sorting and known-target validation naturally observe the repaired order.
+
+**Non-Goals:**
+
+- Do not infer missing finder or navigation commands automatically.
+- Do not change YAML export format or replay import semantics.
+- Do not relax known-target or reference-parameter validation rules.
+- Do not reorder commands before the export manager baseline.
+
+## Decisions
+
+### Model command movement as a collection-associated action
+
+Add a `CommandExportManager_moveCommands` mixin or equivalent action contribution associated with the `notYetExported` collection.
+The action should accept `List<ReplayableCommand> selected` and a single `ReplayableCommand target` parameter.
+This follows the existing `exportSelected` and `makeSelectedExportable` conventions and keeps the UI affordance near the exportable command list.
+
+Alternative considered: add a per-command move action on `ReplayableCommand`.
+That would make multi-command movement awkward and would not naturally express exclusion of selected rows from target choices.
+
+### Use baseline-bounded target choices
+
+The target choices should come from `CommandExportManager.getNotYetExported()` or the same repository query used by that collection, filtered to remove selected commands.
+This ensures choices are commands since the baseline and visible in the current export context.
+The action should require a non-empty selection and a non-null target.
+It should reject a target that is not part of the baseline-bounded command set or that is one of the selected commands, even if a caller bypasses UI choices.
+
+Alternative considered: allow any command log entry as the move target.
+That could accidentally move commands outside the export repair context and make pagination or baseline behavior surprising.
+
+### Retimestamp the selected block in one ordered pass
+
+Resolve selected `ReplayableCommand` instances to their `CommandLogEntry` rows and sort them by their original timestamps before mutating any timestamps.
+Let `baseTimestamp` be the chosen target command timestamp plus 10ms.
+Set the first moved entry to `baseTimestamp`.
+For each following moved entry, add the original time gap between that entry and the previous selected entry to the prior new timestamp.
+If an original gap is null or negative because of equal or inconsistent timestamps, use a minimum 10ms increment to preserve deterministic ordering.
+
+Alternative considered: space every moved command by a fixed 10ms.
+That would be simpler, but it would discard recorded spacing that can help humans understand the original interaction flow.
+
+### Persist by updating command log timestamps
+
+Use the existing mutable `CommandLogEntry#setTimestamp` API so existing repository ordering, collection display, export sorting, and validator logic continue to work without separate order metadata.
+After the action executes, return the same `CommandExportManager` and rely on page refresh to show changed ordering, consistent with export actions that mutate replay state.
+
+Alternative considered: add an explicit export-order column or per-export override.
+That would require schema changes and extra export logic for a repair workflow that is intentionally scoped to command-log maintenance.
+
+## Risks / Trade-offs
+
+- [Risk] Retimestamping command log entries changes historical recording metadata.
+ → Mitigate by keeping the action prototyping-only, recording-suppressed, and explicit in its description.
+- [Risk] Moving commands after a target near following commands could create timestamp collisions with commands not selected for movement.
+ → Mitigate by applying deterministic increments and relying on existing timestamp sort; add tests around adjacent commands.
+- [Risk] Pagination could hide a valid target command that is after the baseline but outside the current limit.
+ → Mitigate initially by using the visible baseline-bounded collection choices and document that the baseline/limit can be adjusted before moving.
+- [Risk] Moving commands can make other selected commands invalid if their required known participants move after them.
+ → Mitigate by not bypassing export validation; users can move again until validation succeeds.
diff --git a/openspec/changes/add-move-commands-action/proposal.md b/openspec/changes/add-move-commands-action/proposal.md
new file mode 100644
index 00000000000..495d2347d6e
--- /dev/null
+++ b/openspec/changes/add-move-commands-action/proposal.md
@@ -0,0 +1,28 @@
+## Why
+
+Command export can reject otherwise useful recordings when an action target or reference parameter was obtained by a finder or navigation command that occurred later in the recording than the selected action that needs it.
+Developers need an in-product way to repair the baseline-bounded command order so retrospective finder or navigation commands can establish dotted-path participants before dependent commands are exported.
+
+## What Changes
+
+- Add `moveCommand`/`moveCommands` support on `CommandExportManager` so one or more selected commands can be moved relative to another command after the export baseline.
+- Provide command choices for the move target from commands at or after the baseline, excluding commands selected for movement.
+- Move the selected commands as a contiguous block after the target command while preserving their original relative timing gaps.
+- Retimestamp the first moved command to the target command timestamp plus 10ms, then retimestamp subsequent moved commands using their original inter-command timing offsets.
+- Ensure command export ordering and known-target validation use the adjusted timestamps after a move.
+
+## Capabilities
+
+### New Capabilities
+
+- `command-export-command-reordering`: Covers reordering baseline-bounded command log entries from `CommandExportManager` so exportable sequences can be repaired before YAML export.
+
+### Modified Capabilities
+
+- `command-export-known-targets`: Clarifies that reordered command timestamps can make retrospective finder or navigation results available to later selected command targets and reference parameters.
+
+## Impact
+
+- Affects `CommandExportManager`, its action contributions, layout/action metadata, and any command-log retimestamping services used by the replay/export UI.
+- Affects export validation tests around target and reference parameter reachability because command order can now be intentionally changed before export.
+- May require focused integration or unit tests for multi-command movement, target choices, timestamp preservation, and validation behavior after movement.
diff --git a/openspec/changes/add-move-commands-action/specs/command-export-command-reordering/spec.md b/openspec/changes/add-move-commands-action/specs/command-export-command-reordering/spec.md
new file mode 100644
index 00000000000..ce4508485f0
--- /dev/null
+++ b/openspec/changes/add-move-commands-action/specs/command-export-command-reordering/spec.md
@@ -0,0 +1,80 @@
+## ADDED Requirements
+
+### Requirement: Export manager moves selected commands after a target command
+The export manager SHALL provide an action to move one or more selected exportable commands after a target command.
+The action SHALL operate only on commands at or after the export manager baseline.
+The target command choices SHALL include commands at or after the export manager baseline.
+The target command choices MUST exclude every command selected for movement.
+The action MUST reject execution when no commands are selected.
+The action MUST reject execution when the target command is missing.
+The action MUST reject execution when the target command is one of the selected commands.
+The action MUST reject execution when any selected command or target command is outside the baseline-bounded exportable command set.
+
+#### Scenario: Target choices exclude selected commands
+- **GIVEN** an export manager baseline is set
+- **AND** commands `A`, `B`, and `C` are exportable after the baseline
+- **AND** commands `A` and `B` are selected for movement
+- **WHEN** the system provides target choices for the move action
+- **THEN** command `C` is offered as a target choice
+- **AND** commands `A` and `B` are not offered as target choices
+
+#### Scenario: Cannot move without a selection
+- **GIVEN** an export manager baseline is set
+- **WHEN** the user invokes the move action with no selected commands
+- **THEN** the system rejects the invocation
+- **AND** no command timestamps are changed
+
+#### Scenario: Cannot move after a selected command
+- **GIVEN** an export manager baseline is set
+- **AND** command `A` is selected for movement
+- **WHEN** the user invokes the move action using command `A` as the target command
+- **THEN** the system rejects the invocation
+- **AND** no command timestamps are changed
+
+#### Scenario: Cannot move commands outside the baseline-bounded set
+- **GIVEN** an export manager baseline is set
+- **AND** command `A` is before the baseline
+- **WHEN** a caller bypasses the UI and invokes the move action with command `A` selected
+- **THEN** the system rejects the invocation
+- **AND** no command timestamps are changed
+
+### Requirement: Moved commands preserve selected block timing
+The export manager SHALL move selected commands as one contiguous block after the target command.
+The first moved command SHALL receive a timestamp 10ms after the target command timestamp.
+Each remaining moved command SHALL preserve the original elapsed time from the previous selected command where that elapsed time is positive.
+When an original elapsed time is zero, negative, or unavailable, the system SHALL use a deterministic minimum increment of 10ms from the previous moved command timestamp.
+The action SHALL preserve the relative order of the selected commands from before the move.
+The action MUST NOT change the target command timestamp.
+The action MUST NOT change timestamps of commands that are neither selected nor the target command.
+
+#### Scenario: Single command moves after target with ten millisecond offset
+- **GIVEN** command `A` has timestamp `10:00:00.000`
+- **AND** command `B` has timestamp `10:00:05.000`
+- **AND** command `A` is selected for movement
+- **WHEN** the user moves the selected command after target command `B`
+- **THEN** command `A` has timestamp `10:00:05.010`
+- **AND** command `B` keeps timestamp `10:00:05.000`
+
+#### Scenario: Multiple commands preserve original internal gaps
+- **GIVEN** command `A` has timestamp `10:00:00.000`
+- **AND** command `B` has timestamp `10:00:00.250`
+- **AND** command `C` has timestamp `10:00:05.000`
+- **AND** commands `A` and `B` are selected for movement
+- **WHEN** the user moves the selected commands after target command `C`
+- **THEN** command `A` has timestamp `10:00:05.010`
+- **AND** command `B` has timestamp `10:00:05.260`
+- **AND** command `C` keeps timestamp `10:00:05.000`
+
+#### Scenario: Multiple commands keep selected order when original gap is not positive
+- **GIVEN** commands `A` and `B` are selected for movement
+- **AND** command `A` does not have a timestamp before command `B`
+- **WHEN** the user moves the selected commands after a target command
+- **THEN** command `A` is timestamped before command `B`
+- **AND** command `B` is timestamped at least 10ms after command `A`
+
+#### Scenario: Unselected commands are not retimestamped
+- **GIVEN** commands `A`, `B`, and `C` are after the export manager baseline
+- **AND** command `A` is selected for movement
+- **AND** command `B` is not selected
+- **WHEN** the user moves command `A` after target command `C`
+- **THEN** command `B` keeps its original timestamp
diff --git a/openspec/changes/add-move-commands-action/specs/command-export-known-targets/spec.md b/openspec/changes/add-move-commands-action/specs/command-export-known-targets/spec.md
new file mode 100644
index 00000000000..d91b14e4cf6
--- /dev/null
+++ b/openspec/changes/add-move-commands-action/specs/command-export-known-targets/spec.md
@@ -0,0 +1,47 @@
+## MODIFIED Requirements
+
+### Requirement: Export target knowledge follows baseline-bounded export order
+The export manager SHALL evaluate target knowledge using the same command ordering that command export uses for replayable sequences.
+The export manager SHALL use current command timestamps when evaluating baseline-bounded export order.
+When command timestamps have been changed by an export-manager command move action, the changed timestamps SHALL determine whether a command result is earlier or later for target and reference-parameter validation.
+A command result SHALL make a bookmark known only for selected commands that occur later in that ordering.
+A command result MUST NOT make the same bookmark known for an earlier selected command or for another selected command whose ordering is not after the result-producing command.
+A command before the export manager baseline MUST NOT make a target known for the selected export sequence.
+
+#### Scenario: Later result does not validate earlier selected target
+- **GIVEN** an export manager baseline is set
+- **AND** a selected action command targets bookmark `demoCustomer:1`
+- **AND** a later selected command in export order has result bookmark `demoCustomer:1`
+- **WHEN** the export manager validates the selected command sequence
+- **THEN** the system rejects the earlier selected command because the target was not known at that point in the export sequence
+
+#### Scenario: Earlier result validates later selected target
+- **GIVEN** an export manager baseline is set
+- **AND** a command with result bookmark `demoCustomer:1` appears earlier in export order and at or after the baseline
+- **WHEN** a selected later action command targets bookmark `demoCustomer:1`
+- **THEN** the export manager accepts the later command for export
+
+#### Scenario: Result before baseline does not validate selected target
+- **GIVEN** an export manager baseline is set
+- **AND** a command before the baseline has result bookmark `demoCustomer:1`
+- **WHEN** a selected later action command targets bookmark `demoCustomer:1`
+- **THEN** the export manager rejects the selected command unless another command at or after the baseline establishes `demoCustomer:1`
+
+#### Scenario: Moved finder result validates later selected target
+- **GIVEN** an export manager baseline is set
+- **AND** a selected action command targets bookmark `demoCustomer:1`
+- **AND** a selected finder command has result bookmark `demoCustomer:1`
+- **AND** the finder command originally occurs later than the action command
+- **WHEN** the user moves the finder command before the action command using the export manager move action
+- **AND** the export manager validates the selected command sequence
+- **THEN** the export manager accepts the action command target as known
+
+#### Scenario: Moved navigation result validates later selected reference parameter
+- **GIVEN** command-log recording support is `ENABLED`
+- **AND** an export manager baseline is set
+- **AND** a selected action command has reference parameter `customer` with bookmark `demoCustomer:1`
+- **AND** a selected navigation command has result bookmark `demoCustomer:1`
+- **AND** the navigation command originally occurs later than the action command
+- **WHEN** the user moves the navigation command before the action command using the export manager move action
+- **AND** the export manager validates the selected command sequence
+- **THEN** the export manager accepts the action command reference parameter as known
diff --git a/openspec/changes/add-move-commands-action/tasks.md b/openspec/changes/add-move-commands-action/tasks.md
new file mode 100644
index 00000000000..9ef82c67c64
--- /dev/null
+++ b/openspec/changes/add-move-commands-action/tasks.md
@@ -0,0 +1,50 @@
+## 1. Locate and Prepare Command Movement Points
+
+- [ ] 1.1 Confirm how `CommandExportManager` obtains the baseline-bounded exportable command list for `notYetExported`.
+- [ ] 1.2 Confirm how `ReplayableCommand` resolves its backing `CommandLogEntry` and exposes interaction id and timestamp data.
+- [ ] 1.3 Confirm whether existing repository queries and persistence contexts flush `CommandLogEntry#setTimestamp(...)` changes without additional save calls.
+- [ ] 1.4 Identify where `CausewayModuleExtCommandLogApplib` registers `CommandExportManager` action contributions.
+
+## 2. Implement Move Action
+
+- [ ] 2.1 Add a `CommandExportManager_moveCommands` action associated with the `notYetExported` collection.
+- [ ] 2.2 Accept `List<ReplayableCommand> selected` and a `ReplayableCommand target` parameter.
+- [ ] 2.3 Provide target choices from the baseline-bounded exportable command list, excluding selected commands.
+- [ ] 2.4 Disable or validate the action when the exportable command list is empty.
+- [ ] 2.5 Validate that the selection is non-empty and that the target is present.
+- [ ] 2.6 Validate that selected commands and the target command are all within the baseline-bounded exportable command set.
+- [ ] 2.7 Validate that the target command is not one of the selected commands.
+- [ ] 2.8 Register the new action contribution in the command-log applib module.
+
+## 3. Retimestamp Selected Commands
+
+- [ ] 3.1 Resolve selected commands and the target command to `CommandLogEntry` instances.
+- [ ] 3.2 Sort selected command log entries by their original timestamps before mutating any timestamps.
+- [ ] 3.3 Retimestamp the first selected command to target timestamp plus 10ms.
+- [ ] 3.4 Retimestamp subsequent selected commands by preserving original positive gaps from the selected block.
+- [ ] 3.5 Use a deterministic minimum 10ms gap when original gaps are zero, negative, or unavailable.
+- [ ] 3.6 Ensure unselected commands and the target command keep their original timestamps.
+- [ ] 3.7 Return the `CommandExportManager` after movement so the UI can refresh the same manager context.
+
+## 4. Verify Export Validation After Movement
+
+- [ ] 4.1 Add or update tests showing a moved finder result can validate a later selected action target.
+- [ ] 4.2 Add or update tests showing a moved navigation or finder result can validate a later selected reference parameter.
+- [ ] 4.3 Ensure `CommandExportManager_exportSelected` continues to sort by current command timestamps and needs no separate order override.
+- [ ] 4.4 Ensure existing unknown-target and unknown-reference-parameter rejection tests still pass when commands have not been moved.
+
+## 5. Test Move Action Behavior
+
+- [ ] 5.1 Add action tests showing target choices include baseline-bounded exportable commands and exclude selected commands.
+- [ ] 5.2 Add validation tests for empty selection, missing target, target included in selected commands, and commands outside the baseline-bounded set.
+- [ ] 5.3 Add retimestamping tests for a single moved command using target plus 10ms.
+- [ ] 5.4 Add retimestamping tests for multiple moved commands preserving positive original internal gaps.
+- [ ] 5.5 Add retimestamping tests for zero or negative original gaps using the deterministic minimum 10ms increment.
+- [ ] 5.6 Add retimestamping tests showing unselected commands and the target command are unchanged.
+
+## 6. Build and Review
+
+- [ ] 6.1 Run focused command-log applib tests for export selection, known-target validation, and the new move action.
+- [ ] 6.2 Run the relevant module build or broader test target used by this repository for command-log changes.
+- [ ] 6.3 Review action labels, descriptions, and collection association so the UI clearly explains that timestamps are changed.
+- [ ] 6.4 Run `openspec validate add-move-commands-action --strict` and fix any proposal, spec, or task issues.