# EM Full-Direction-Segment Staged Execution Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to execute only the current phase in a fresh window. Do not use subagents. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Execute the approved full-direction-segment planning and observation repair across nine bounded windows with fresh verification, independent handoffs, and copy-ready next-phase prompts.

**Architecture:** The functional design and 11-task master implementation plan remain authoritative. This plan groups those tasks into nine phase gates; each window reads only its assigned tasks plus the previous handoff, commits implementation in the master-plan boundaries, then commits a factual handoff separately. The final response generates the next prompt only after the handoff commit exists, so every copied prompt carries real hashes.

**Tech Stack:** Git on Windows/PowerShell, C#/.NET 8, existing EM/OSQP verification hosts, vanilla HTML/CSS/JavaScript/SVG/Canvas, Node.js 24 with test-only jsdom 29.1.1, Markdown handoffs.

## Global Constraints

- Repository root is `D:\Users\Desktop\项目\prakrobot\ParkingRobot` and expected branch is `trajplanner`.
- Functional design: `docs/superpowers/specs/2026-08-06-em-full-direction-segment-visualization-repair-design.md`.
- Master plan: `docs/superpowers/plans/2026-08-06-em-full-direction-segment-visualization-repair.md`.
- Staged-execution design: `docs/superpowers/specs/2026-08-06-em-full-direction-segment-staged-execution-design.md`.
- Every implementation window reads `executing-plans`, `test-driven-development`, and `verification-before-completion`; read `systematic-debugging` only after a real failure or unexpected result.
- Do not re-run brainstorming, redesign approved behavior, expand features, or spawn subagents.
- MovementTest remains `OBSERVE_ONLY`; never add chassis, steering, braking, motor, or gear writes.
- Keep all unrelated dirty and staged work intact. Before editing a dirty target file, record its diff and preserve unrelated hunks.
- Use `apply_patch` for edits and explicit `git add -- <paths>` commands. Never use `git add .` or `git add -A`.
- A phase may not implement work assigned to a subsequent phase. Minimal signature propagation is allowed only when the master plan lists that file in the current task.
- Each phase implementation commit follows the master plan. The handoff is a separate commit named `docs: record EM full-direction phase XX handoff`.
- A completed phase final response includes the real implementation and handoff hashes plus one copy-ready prompt for the next phase.
- A blocked phase creates a `阻塞` handoff and outputs a recovery prompt for the same phase, never a later-phase prompt.
- Phase 9 automated acceptance and supervised vehicle acceptance are separate checkpoints. Unsafe or unavailable vehicle work remains incomplete.

## Common Phase Start

Every phase prompt supplies the exact expected previous implementation/handoff hashes. At startup run:

```powershell
git branch --show-current
git rev-parse HEAD
git log -5 --oneline
git status --short
git diff --cached --name-only
```

Then run `git merge-base --is-ancestor` for every hash named by the prompt. Read the four authority documents listed above, the current master-plan Task, and the previous handoff in full. If related code changed after the previous handoff, rerun the affected previous-phase GREEN commands before editing.

## Common Phase Finish

Before any success claim or commit:

1. Run the phase RED and confirm the first failure is the intended missing behavior.
2. Run all phase GREEN/regression commands and read complete output.
3. Run `git diff --check` over the phase range and inspect `git diff --stat` plus `git diff --cached --name-only`.
4. Audit actuator calls whenever MovementTest or observer code is touched.
5. Commit only exact current-phase files.
6. Create the phase handoff with `apply_patch`, recording entry HEAD, implementation hashes, files, interfaces, RED/GREEN evidence, dirty-worktree preservation, warnings, omissions, and next-phase facts.
7. Commit only the handoff file.
8. Use the resulting handoff hash in the final answer’s next-phase prompt.

---

### Task 1: Phase 01 — Planning scope, configuration, and full-segment selection

**Master-plan scope:** Task 1 and Task 2 only.

**Files:**

- Create: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Contracts/EmPlanningScope.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Contracts/EmPlanningRequest.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Contracts/EmPlanningStatus.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Contracts/EmTrajectoryMetadata.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Configuration/SchedulingConfiguration.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Configuration/LongitudinalConfiguration.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Configuration/ValidationConfiguration.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Configuration/EmPlannerConfiguration.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Validation/EmPlanningRequestValidator.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Segmentation/PlanningHorizonSelector.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Facade/EmPlanningService.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Trajectory/EmTrajectoryAssembler.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/FoundationChecks.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/LongitudinalModelChecks.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/EmPlanningServiceChecks.cs`
- Handoff: `docs/superpowers/handoffs/em-full-direction-visualization/phase-01.md`

**Interfaces:**

- Produces `EmPlanningScope.RollingHorizon` and `FullDirectionSegment`.
- Produces request/metadata scope, desired speeds, adaptive-resource configuration, terminal tolerances, and explicit `NoProgress`, `TerminalPoseMismatch`, and `FullSegmentResourceLimitExceeded` statuses.
- Produces scope-aware `PlanningHorizonSelector.Select` that keeps rolling behavior intact and selects the true direction boundary for full mode.

- [ ] **Step 1: Execute master Task 1 RED/GREEN/commit**

Follow every checkbox in master Task 1. Required focused commands:

```powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- foundation
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- em-planning-service
```

Expected GREEN: `PASS foundation` and `PASS em-planning-service`.

Commit exactly as:

```powershell
git commit -m "feat: define full-direction EM planning scope"
```

- [ ] **Step 2: Execute master Task 2 RED/GREEN/commit**

Follow every checkbox in master Task 2. Required commands:

```powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- longitudinal-model
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- em-planning-service
```

Expected GREEN: `PASS longitudinal-model` and `PASS em-planning-service`; full mode reaches the true Goal/GearSwitch boundary and rolling remains truncated by its configured window.

Commit exactly as:

```powershell
git commit -m "feat: select complete EM direction segments"
```

- [ ] **Step 3: Run phase regression and handoff**

```powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- em-core-all
git diff --check
```

Expected: every `em-core-all` component PASS and no new whitespace errors.

Create `phase-01.md`, then commit only it:

```powershell
git add -- docs/superpowers/handoffs/em-full-direction-visualization/phase-01.md
git commit -m "docs: record EM full-direction phase 01 handoff"
```

**Exit gate:** Task 1–2 commits and handoff are reachable; no adaptive knot schedule or MovementTest/Web/Painter work exists.

---

### Task 2: Phase 02 — Adaptive full-segment ST schedule

**Master-plan scope:** Task 3 only.

**Files:**

- Create: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/LongitudinalKnotSchedule.cs`
- Create: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/FullDirectionSegmentScheduleBuilder.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/PathSpeedLimitBuilder.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/LongitudinalPlanningInput.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/LongitudinalConstraintBuilder.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/LongitudinalSolutionValidator.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/SequentialLongitudinalOptimizer.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/LongitudinalPreviousTrajectorySeedBuilder.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Facade/EmPlanningService.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/LongitudinalModelChecks.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/LongitudinalIntegrationChecks.cs`
- Handoff: `docs/superpowers/handoffs/em-full-direction-visualization/phase-02.md`

**Interfaces:**

- Consumes Phase 01 scope/configuration.
- Produces immutable `LongitudinalKnotSchedule` and `FullDirectionSegmentScheduleBuilder.TryBuild`.
- Makes `LongitudinalPlanningInput.KnotSchedule` the sole optimization-knot source while publication remains separately sampled.

- [ ] **Step 1: Execute master Task 3 RED/GREEN**

Run the exact model RED before implementation, then all Task 3 changes. Required GREEN:

```powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- longitudinal-model
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- longitudinal-integration
```

Expected: both PASS, including short/long derived duration, curvature/stop breakpoints, knot cap failure, and publication-density independence.

- [ ] **Step 2: Commit and run regression**

```powershell
git commit -m "feat: derive adaptive full-segment ST schedule"
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- em-core-all
git diff --check
```

Expected: commit contains only Task 3 paths; `em-core-all` PASS.

- [ ] **Step 3: Write and commit Phase 02 handoff**

```powershell
git add -- docs/superpowers/handoffs/em-full-direction-visualization/phase-02.md
git commit -m "docs: record EM full-direction phase 02 handoff"
```

**Exit gate:** derived `T_end` and adaptive knots are validated; no static-start objective, terminal pose, MovementTest, or visualization work is included.

---

### Task 3: Phase 03 — Static start, no-progress rejection, and terminal publication gates

**Master-plan scope:** Task 4 and Task 5 only.

**Files:**

- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/SequentialLongitudinalOptimizer.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/LongitudinalObjectiveBuilder.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/LongitudinalSolutionValidator.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Longitudinal/LongitudinalPlanningResult.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Validation/EmTrajectoryValidator.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Facade/EmPlanningService.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Trajectory/TrajectorySampleSchedule.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/Trajectory/EmTrajectoryAssembler.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/LongitudinalModelChecks.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/LongitudinalIntegrationChecks.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/TrajectoryChecks.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/EmPlanningServiceChecks.cs`
- Handoff: `docs/superpowers/handoffs/em-full-direction-visualization/phase-03.md`

**Interfaces:**

- Consumes adaptive reference speed and scope.
- Produces nonzero motion from `v0=0`, `NoProgress`, terminal 3 cm/5° normalized-yaw validation, and publication sample cap.

- [ ] **Step 1: Execute master Task 4 with real RED evidence**

```powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- longitudinal-integration
```

Expected RED: the clear 5 m static-start fixture remains all-zero or lacks measurable progress.

After minimal implementation run:

```powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- longitudinal-model
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- longitudinal-integration
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- em-planning-service
```

Expected: all PASS; the explicit all-zero candidate returns `NoProgress` and publishes no trajectory.

Commit: `fix: accelerate EM trajectories from rest`.

- [ ] **Step 2: Execute master Task 5 RED/GREEN**

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

Expected RED: terminal world pose is not yet validated.

After implementation run `trajectory` and `em-planning-service`; expect yaw wrap, 3 cm/5° boundary, sample cap, terminal anchor, and `N-1` jerk checks PASS.

Commit: `feat: validate EM terminal world pose`.

- [ ] **Step 3: Run phase regression and handoff**

```powershell
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- em-core-all
git diff --check
```

Create/commit `phase-03.md` with message `docs: record EM full-direction phase 03 handoff`.

**Exit gate:** a full clear segment accelerates from rest and stops at a pose-valid terminal; invalid zero progress/pose/sample count cannot publish.

---

### Task 4: Phase 04 — One-shot MovementTest direction segments

**Master-plan scope:** Task 6 only.

**Files:**

- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationContracts.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationPipeline.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/MovementTest.TrajectoryObservationTest.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationStaticSnapshotBuilder.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/TrajectoryObservationSettingsChecks.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/TrajectoryObservationChecks.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/TrajectoryObservationSegmentChecks.cs`
- Handoff: `docs/superpowers/handoffs/em-full-direction-visualization/phase-04.md`

**Interfaces:**

- Produces `TrajectoryObservationSettings.PlanningScope`, full-mode defaults, and one plan attempt per active segment.
- Preserves stop hold plus three signed-speed samples before N+1 activation.

- [ ] **Step 1: Run Task 6 RED and implement one-shot state**

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

Expected RED: current coordinator cadence starts more than one planning cycle in full scope.

Implement only Task 6 and rerun the same command. Expected GREEN: one plan for N, observation continues, and one new plan starts only after confirmed N→N+1.

- [ ] **Step 2: Audit read-only safety and commit**

```powershell
rg -n "SendXYThSpeed|SendMotion|DriveStop|PredefinedDriveStop|AccumulateSpeed|SetGear|SetBrake" ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest
git diff --check
```

Expected: no actuator call in observer runtime sources.

Commit: `feat: observe one full EM direction segment`.

- [ ] **Step 3: Write and commit Phase 04 handoff**

Commit `phase-04.md` with `docs: record EM full-direction phase 04 handoff`.

**Exit gate:** MovementTest is full-scope by explicit setting, plans once per direction segment, retains explicit waiting state, and remains read-only.

---

### Task 5: Phase 05 — Observation snapshot and chart semantics

**Master-plan scope:** Task 7 only.

**Files:**

- Modify: `ClumsyPilot/TrajectoryPlanningVisualization/Contracts/VisualizationCharts.cs`
- Modify: `ClumsyPilot/TrajectoryPlanningVisualization/Contracts/VisualizationGeometry.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationStaticSnapshotBuilder.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationDynamicSnapshotBuilder.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationKinematicChartBuilder.cs`
- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/MovementTest.TrajectoryObservationTest.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/TrajectoryObservationVisualizationChecks.cs`
- Test: `ClumsyPilot/tests/TrajectoryPlanningVisualizationVerificationHost/ContractChecks.cs`
- Test: `ClumsyPilot/tests/TrajectoryPlanningVisualizationVerificationHost/SampleSnapshotFactory.cs`
- Handoff: `docs/superpowers/handoffs/em-full-direction-visualization/phase-05.md`

**Interfaces:**

- Produces `VisualizationChartAnnotation` and distinct coarse/Local G2/active/previous/current kinds.
- Produces real `s_end`, gear/final marker, vehicle/plan-start, correct LS/ST/kinematic axes, and real curvature limit.

- [ ] **Step 1: Run both Task 7 RED hosts**

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

Expected RED: duplicate current horizon, missing annotations, or incorrect curvature-limit semantics.

- [ ] **Step 2: Implement Task 7 and run GREEN**

Run both commands again. Expected: both PASS; full mode contains exactly one current trajectory; jerk current series has `N-1` points; LS uses `ReferenceS`, ST uses `PathS`; curvature limit comes from vehicle geometry.

Commit: `fix: publish distinct EM observation semantics`.

- [ ] **Step 3: Regression, audit, and handoff**

Run `trajectory-observation`, the visualization host, actuator `rg`, and `git diff --check`. Commit `phase-05.md` as `docs: record EM full-direction phase 05 handoff`.

**Exit gate:** immutable snapshots carry all correct semantics before any Web or Painter rendering changes.

---

### Task 6: Phase 06 — DOM/SVG Web rendering repair

**Master-plan scope:** Task 8 only.

**Files:**

- Create: `ClumsyPilot/tests/TrajectoryPlanningVisualizationWebDom/package.json`
- Create: `ClumsyPilot/tests/TrajectoryPlanningVisualizationWebDom/package-lock.json`
- Create: `ClumsyPilot/tests/TrajectoryPlanningVisualizationWebDom/dashboard.dom.test.mjs`
- Modify: `ClumsyPilot/TrajectoryPlanningVisualization/Web/index.html`
- Modify: `ClumsyPilot/TrajectoryPlanningVisualization/Web/app.css`
- Modify: `ClumsyPilot/TrajectoryPlanningVisualization/Web/app.js`
- Modify: `ClumsyPilot/tests/TrajectoryPlanningVisualizationVerificationHost/WebAssetChecks.cs`
- Handoff: `docs/superpowers/handoffs/em-full-direction-visualization/phase-06.md`

**Interfaces:**

- Adds test-only Node/jsdom DOM verification.
- Repairs hidden tabs, empty overview, y ticks/units, stable domains, semantic layer order, vehicle/boundary markers, and thin paper style.

- [ ] **Step 1: Install locked test dependency and run RED**

Create the exact Task 8 `package.json`, run:

```powershell
npm install --package-lock-only --prefix ClumsyPilot/tests/TrajectoryPlanningVisualizationWebDom
npm test --prefix ClumsyPilot/tests/TrajectoryPlanningVisualizationWebDom
```

Expected RED: hidden-section CSS, y ticks, semantic classes, or empty-state assertions fail.

- [ ] **Step 2: Implement Task 8 and run GREEN**

```powershell
npm test --prefix ClumsyPilot/tests/TrajectoryPlanningVisualizationWebDom
dotnet run --project ClumsyPilot/tests/TrajectoryPlanningVisualizationVerificationHost/TrajectoryPlanningVisualizationVerificationHost.csproj
```

Expected: all DOM tests pass and .NET host prints `PASS trajectory-planning-visualization`.

Commit: `fix: repair EM observation web charts`.

- [ ] **Step 3: Verify production assets and handoff**

Confirm no npm package is copied into plugin output, run `git diff --check`, and commit `phase-06.md` as `docs: record EM full-direction phase 06 handoff`.

**Exit gate:** existing four-tab page renders correct data/axes/layers with no layout redesign; zoom is not yet implemented.

---

### Task 7: Phase 07 — Per-chart viewport zoom

**Master-plan scope:** Task 9 only.

**Files:**

- Modify: `ClumsyPilot/TrajectoryPlanningVisualization/Web/index.html`
- Modify: `ClumsyPilot/TrajectoryPlanningVisualization/Web/app.css`
- Modify: `ClumsyPilot/TrajectoryPlanningVisualization/Web/app.js`
- Modify: `ClumsyPilot/tests/TrajectoryPlanningVisualizationWebDom/dashboard.dom.test.mjs`
- Handoff: `docs/superpowers/handoffs/em-full-direction-visualization/phase-07.md`

**Interfaces:**

- Produces per-chart viewport-only box zoom, wheel zoom, reset, and fullscreen.
- Never mutates snapshot arrays or sends planner configuration.

- [ ] **Step 1: Run frozen-data interaction RED**

```powershell
npm test --prefix ClumsyPilot/tests/TrajectoryPlanningVisualizationWebDom
```

Expected RED: zoom controls and viewport state are absent.

- [ ] **Step 2: Implement Task 9 and run GREEN**

```powershell
npm test --prefix ClumsyPilot/tests/TrajectoryPlanningVisualizationWebDom
dotnet run --project ClumsyPilot/tests/TrajectoryPlanningVisualizationVerificationHost/TrajectoryPlanningVisualizationVerificationHost.csproj
```

Expected: wheel/box/reset/fullscreen tests pass; serialized input snapshot remains byte-identical.

Commit: `feat: add observation chart viewport zoom`.

- [ ] **Step 3: Handoff**

Run `git diff --check`; commit `phase-07.md` as `docs: record EM full-direction phase 07 handoff`.

**Exit gate:** every chart has independent local navigation and no Native Painter changes.

---

### Task 8: Phase 08 — Native Painter correctness

**Master-plan scope:** Task 10 only.

**Files:**

- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/TrajectoryObservationPresentation.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/TrajectoryObservationChecks.cs`
- Test: `ClumsyPilot/tests/EMPlannerVerificationHost/TrajectoryObservationVisualizationChecks.cs`
- Handoff: `docs/superpowers/handoffs/em-full-direction-visualization/phase-08.md`

**Interfaces:**

- Consumes Phase 05 semantics.
- Produces equal-scale world geometry, correct LS/ST axes, thin vehicle outline/heading ray, and correct `s_end`/gear/final markers.

- [ ] **Step 1: Run Painter geometry RED**

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

Expected RED: the current pose uses a large `endArrow: true` marker or old axis semantics.

- [ ] **Step 2: Implement Task 10 and run GREEN**

Run the same command. Expected: `PASS trajectory-observation`; tests prove the large triangle is absent and x/y use one scale.

Commit: `fix: correct EM observation painter geometry`.

- [ ] **Step 3: Safety audit and handoff**

```powershell
rg -n "SendXYThSpeed|SendMotion|DriveStop|PredefinedDriveStop|AccumulateSpeed|SetGear|SetBrake" ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest
git diff --check
```

Commit `phase-08.md` as `docs: record EM full-direction phase 08 handoff`.

**Exit gate:** Native Painter is semantically correct but not redesigned; Web remains primary.

---

### Task 9: Phase 09 — Documentation, automated acceptance, and vehicle continuation

**Master-plan scope:** Task 11 only.

**Files:**

- Modify: `ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest/README.md`
- Modify: `ClumsyPilot/ParkrobTrajplanner/EMPlanner/README.md`
- Modify: `ClumsyPilot/TrajectoryPlanningVisualization/README.md`
- Create: `docs/superpowers/handoffs/em-full-direction-visualization/phase-09.md`
- Create only after supervised execution: `docs/superpowers/handoffs/em-full-direction-visualization/phase-09-vehicle.md`

**Interfaces:**

- Produces operator documentation and fresh automated evidence.
- Produces either final supervised vehicle acceptance or an exact continuation/recovery prompt without false completion.

- [ ] **Step 1: Update docs and commit**

Follow master Task 11 Step 1 exactly. Commit only the three READMEs as:

```powershell
git commit -m "docs: explain full-direction EM observation"
```

- [ ] **Step 2: Run the complete automated suite**

```powershell
npm test --prefix ClumsyPilot/tests/TrajectoryPlanningVisualizationWebDom
dotnet run --project ClumsyPilot/tests/TrajectoryPlanningVisualizationVerificationHost/TrajectoryPlanningVisualizationVerificationHost.csproj
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- trajectory-observation
dotnet run --project ClumsyPilot/tests/EMPlannerVerificationHost/EMPlannerVerificationHost.csproj -- em-all
dotnet build ClumsyPilot/ClumsyPilot.csproj -p:ExcludeLegacyAutoAvoidance=true
rg -n "SendXYThSpeed|SendMotion|DriveStop|PredefinedDriveStop|AccumulateSpeed|SetGear|SetBrake" ClumsyPilot/ParkrobTrajplanner/tarjplanner_movementtest
git diff --check
```

Expected: Node tests pass; visualization/observation/em-all PASS; build exits 0; no observer actuator calls; no new whitespace errors.

- [ ] **Step 3: Run deterministic local smoke**

```powershell
dotnet run --project ClumsyPilot/tests/TrajectoryPlanningVisualizationVerificationHost/TrajectoryPlanningVisualizationVerificationHost.csproj -- --smoke-seconds 60
```

Verify the tokenized page and port cleanup exactly as master Task 11. Record screenshots/log paths.

- [ ] **Step 4: Commit automated handoff**

Write `phase-09.md`. If supervision/safety is unavailable, set status `自动验收完成但实车待验` and include every pending vehicle item. Commit only it:

```powershell
git add -- docs/superpowers/handoffs/em-full-direction-visualization/phase-09.md
git commit -m "docs: record EM full-direction phase 09 handoff"
```

Output a full Phase 09 vehicle-continuation prompt using the real handoff hash.

- [ ] **Step 5: Execute vehicle continuation only when supervised and safe**

A new window verifies Phase 09 evidence reachability and reruns affected automation if related code changed. It then performs the eight-item vehicle checklist from master Task 11 without writing hardware commands.

- [ ] **Step 6: Record final vehicle status**

If all items pass, create `phase-09-vehicle.md` with status `完成` and commit:

```powershell
git add -- docs/superpowers/handoffs/em-full-direction-visualization/phase-09-vehicle.md
git commit -m "docs: record EM visualization vehicle acceptance"
```

If a real regression appears, write status `阻塞`, record the first valid failure/reproduction/safety impact, commit only the same file with message `docs: record blocked EM visualization vehicle acceptance`, and output a Phase 09 vehicle recovery prompt.

**Exit gate:** only fresh supervised vehicle evidence permits the statement that the overall work is complete. Final completion has no next-phase prompt.

---

## Phase Prompt Construction Rule

After each handoff commit, construct the next prompt from factual repository state. The prompt must include:

- absolute repository path and expected branch;
- exact current HEAD, previous implementation hashes, and handoff hash;
- exact required documents and current sections/tasks;
- startup ancestry/status/dirty-worktree checks;
- exact allowed files and forbidden later-phase work;
- exact RED/GREEN/regression/audit commands;
- implementation and handoff commit messages;
- completion output and blocked recovery behavior.

Never write an unresolved hash variable or depend on chat history. The prompt may instruct the next agent to read a file, but it must say why and identify the exact phase/task.
