# MovementTest ST Time Controls Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox syntax for tracking.

**Goal:** Expose configurable ST horizon and trajectory timestamp spacing for observation-only MovementTest sessions.

**Architecture:** TrajectoryObservationSettings owns TimeHorizonSeconds and OutputTimeStepSeconds, preserves them in a validated snapshot, and enforces a time step no larger than the horizon. Public MovementTest fields feed those settings, then TrajectoryObservationController copies both values into its session-local EM schedule.

**Tech Stack:** C# 10, .NET, EMPlannerVerificationHost.

## Global Constraints

- TimeHorizonSeconds defaults to 6d.
- OutputTimeStepSeconds defaults to 0.10d.
- OutputTimeStepSeconds must be positive and no greater than TimeHorizonSeconds.
- ObserverPeriodSeconds stays 0.05d.
- SolverTimeoutSeconds stays 0.50d, MaximumOsqpIterations stays 12000, and all solver tolerances stay 1e-5d.
- Do not change production EM defaults, vehicle/map constraints, or observe-only command behavior.

---

### Task 1: Propagate ST time controls into an EM request

**Files:**

- Modify: ClumsyPilot/tests/EMPlannerVerificationHost/TrajectoryObservationChecks.cs
- Modify: ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationContracts.cs
- Modify: ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/MovementTest.TrajectoryObservationTest.cs
- Modify: ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationPipeline.cs

**Interfaces:**

- Consumes: TrajectoryObservationSettings.CreateValidatedSnapshot() and TrajectoryObservationController.StartCycle(...).
- Produces: TimeHorizonSeconds and OutputTimeStepSeconds in EmPlanningRequest.Configuration.Scheduling.

- [x] **Step 1: Write the failing test**

Add assertions for the visible defaults and request propagation:

~~~csharp
Verification.True(source.Contains("public double TimeHorizonSeconds = 6d;"),
    "observer MovementTest exposes the ST time-horizon default");
Verification.True(source.Contains("public double OutputTimeStepSeconds = 0.10d;"),
    "observer MovementTest exposes the ST timestamp-spacing default");

var settings = new TrajectoryObservationSettings
{
    TimeHorizonSeconds = 4d,
    OutputTimeStepSeconds = 0.20d,
};
// Start one controller cycle.
Verification.NearlyEqual(4d, request.Configuration.Scheduling.TimeHorizonSeconds,
    "observer configured ST time horizon");
Verification.NearlyEqual(0.20d, request.Configuration.Scheduling.OutputTimeStepSeconds,
    "observer configured ST timestamp spacing");
~~~

Assert zero horizon, zero step, and a step larger than the horizon are rejected.

- [x] **Step 2: Run focused verification to verify it fails**

Run:

~~~powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- trajectory-observation
~~~

Expected: FAIL because the ST time-control properties are absent.

- [x] **Step 3: Write the minimal implementation**

Add public settings and comments:

~~~csharp
/// <summary>单次 ST 轨迹覆盖的未来时长，单位 s；不等于观察循环周期。</summary>
public double TimeHorizonSeconds { get; set; } = 6d;

/// <summary>发布 Trajectory 相邻 TimeFromStart 时间戳的间隔，单位 s；不等于观察循环周期。</summary>
public double OutputTimeStepSeconds { get; set; } = 0.10d;
~~~

Validate both values and require OutputTimeStepSeconds to be no larger than TimeHorizonSeconds. Copy them through the MovementTest and use:

~~~csharp
configuration.Scheduling.TimeHorizonSeconds = settings.TimeHorizonSeconds;
configuration.Scheduling.OutputTimeStepSeconds = settings.OutputTimeStepSeconds;
~~~

- [x] **Step 4: Run focused verification to verify it passes**

Run:

~~~powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- trajectory-observation
~~~

Expected: PASS trajectory-observation.

- [x] **Step 5: Run full regression and build**

Run:

~~~powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- em-all
dotnet build ClumsyPilot/ClumsyPilot.csproj --no-restore
~~~

Expected: all suites pass and the build reports zero errors.

- [x] **Step 6: Commit implementation**

~~~powershell
git add ClumsyPilot/tests/EMPlannerVerificationHost/TrajectoryObservationChecks.cs ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationContracts.cs ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/MovementTest.TrajectoryObservationTest.cs ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationPipeline.cs
git commit -m "feat: configure MovementTest ST time controls"
~~~
