# MovementTest Solver Timeout 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:** Make the observation-only MovementTest expose a 0.50-second default OSQP time budget without relaxing solver accuracy.

**Architecture:** `TrajectoryObservationSettings` owns the test-facing time-budget value and validates/copies it. The MovementTest maps its public field into those settings, and `TrajectoryObservationController` maps the snapshot into the per-session EM configuration. The production EM defaults remain unchanged.

**Tech Stack:** C# 10, .NET, existing EMPlannerVerificationHost test host.

## Global Constraints

- Default test solver timeout is exactly `0.50d` seconds.
- `AbsoluteTolerance`, `RelativeTolerance`, and `StrictResidualTolerance` remain `1e-5d`.
- Do not change vehicle constraints, map construction, speed limits, or observe-only command behavior.
- Do not alter `EmPlannerConfiguration.CreateDefault()`; the override belongs only to the observation test.

---

### Task 1: Propagate the test solver budget into an EM request

**Files:**

- Modify: `ClumsyPilot/tests/EMPlannerVerificationHost/TrajectoryObservationChecks.cs:122-170,384-405`
- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationContracts.cs:9-49`
- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/MovementTest.TrajectoryObservationTest.cs:25-70`
- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationPipeline.cs:198-214`

**Interfaces:**

- Consumes: `TrajectoryObservationSettings.CreateValidatedSnapshot()` and `TrajectoryObservationController.StartCycle(...)`.
- Produces: `TrajectoryObservationSettings.SolverTimeoutSeconds`, copied to `EmPlanningRequest.Configuration.Scheduling.SolverTimeoutSeconds`.

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

In `VerifiesControllerBuildsSegmentZeroRequest`, set a non-default observation setting and assert it reaches the request:

```csharp
var settings = new TrajectoryObservationSettings
{
    SolverTimeoutSeconds = 0.42d,
};
// Start one controller cycle.
Verification.NearlyEqual(0.42d, planningService.Requests[0].Configuration.Scheduling.SolverTimeoutSeconds,
    "observer configured solver timeout");
```

Also extend `VerifiesSettingsSnapshotAndVehicle` to assert that a default snapshot retains `0.50d`, and extend `RejectsInvalidSettings` with `settings => settings.SolverTimeoutSeconds = 0d`.

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

Run:

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

Expected: FAIL because `SolverTimeoutSeconds` does not yet exist or its value is not propagated to the request.

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

Add and copy/validate the settings property:

```csharp
public double SolverTimeoutSeconds { get; set; } = 0.50d;
```

Map it from the public MovementTest field, then set the session-local EM configuration:

```csharp
configuration.Scheduling.SolverTimeoutSeconds = settings.SolverTimeoutSeconds;
```

Do not alter the EM default configuration or any tolerance property.

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

Run:

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

Expected: all trajectory-observation checks pass, including timeout propagation and invalid-setting rejection.

- [x] **Step 5: Run the related EM regression suite**

Run:

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

Expected: both commands finish successfully with no errors.

- [x] **Step 6: Commit the 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 solver timeout"
```
