# Nexus Deployment Engine 1.0 — Evidence Summary

**Date:** 2026-06-05  
**Scope:** Local `.nxp` install / update / remove via Ninja Store (POC)

## Build & test

| Check | Result |
|-------|--------|
| `dotnet build NexusShell -c Release` | **PASS** |
| `dotnet test NexusShell.Tests -c Release --filter NexusDeploymentEngineTests` | **PASS** (3 tests) |

## Changed / added files

### New — Deployment services (`Services/Deployment/`)

| File | Role |
|------|------|
| `NexusDeploymentService.cs` | Orchestrator: install, update, remove |
| `NexusPackageInstaller.cs` | Copy local `.nxp`, extract ZIP to `installed/{id}/` |
| `NexusPackageRegistry.cs` | Installed metadata + in-progress phase tracking |
| `NexusPackageUpdater.cs` | Full-package update with rollback snapshot |
| `NexusRollbackService.cs` | Snapshot/restore under `packages/rollback/{id}/` |
| `NexusInstallQueue.cs` | Serial job queue |

### New — Models

| File | Role |
|------|------|
| `Models/NexusDeploymentModels.cs` | `NexusDeploymentPhase`, progress/result types, update stubs (delta, mandatory, dependencies) |

### Modified

| File | Change |
|------|--------|
| `NexusPackageRepository.cs` | `RollbackDirectory`, `ResolvePackageFilePath()`, rollback layout |
| `NexusPackageService.cs` | Deployment phase in status labels; registry injection |
| `NexusStoreService.cs` | Install/Update/Remove APIs; progress events; enabled action flags |
| `NexusStoreViewModel.cs` | Async deployment commands, progress bar, loop-safe reload |
| `NexusStoreView.xaml` | Enabled Install/Update, Remove button, progress bar |
| `NexusStoreModels.cs` | In-progress install states, `CanRemove`, `DeploymentPhase` |
| `NexusPackageUpdateModels.cs` | Documented stubs for delta/mandatory/rollback/dependencies |
| `App.xaml.cs` | Wire deployment service graph |

### Tests

| File | Coverage |
|------|----------|
| `NexusShell.Tests/NexusDeploymentEngineTests.cs` | Install, update, remove against temp repo |

## Install flow (POC)

```mermaid
sequenceDiagram
    participant Store as NexusStoreViewModel
    participant Svc as NexusStoreService
    participant Dep as NexusDeploymentService
    participant Q as NexusInstallQueue
    participant Inst as NexusPackageInstaller
    participant Reg as NexusPackageRegistry

    Store->>Svc: InstallAsync(packageId)
    Svc->>Dep: InstallAsync
    Dep->>Q: Enqueue job
    Q->>Dep: ExecuteInstallAsync
    Dep->>Reg: SetActivePhase(Downloading)
    Dep->>Inst: CopyFromRepository (.nxp)
    Dep->>Reg: SetActivePhase(Installing)
    Dep->>Inst: ExtractAsync → installed/{id}/
    Dep->>Reg: SaveInstalled + metadata JSON
    Dep->>Store: OperationCompleted → CatalogChanged
```

**Paths (under `%LocalAppData%/NinjaNexus/packages/`):**

- `repository/` — seeded `.nxp` from `Assets/Packages/` (bundled manifests zipped at first run)
- `installed/{packageId}/` — extracted payload + `manifest.json`
- `installed/{packageId}.json` — install record (version, state, timestamp)
- `rollback/{packageId}/{version}/` — previous install snapshot before update
- `temp/` — transient copy during operation

**No external download** — POC copies from local `repository/` only.

## States

### Stable (`NexusPackageState`)

`Available`, `Installed`, `UpdateAvailable`, `Broken`, `Disabled`

### In-progress (`NexusDeploymentPhase`)

`Downloading`, `Installing`, `Updating`, `Removing`, `Failed`

Store UI maps both via `NexusStoreInstallState` and Danish status labels (`StatusLabelFor`).

## Store integration

- **Install** — available packages; extracts bundled `.nxp`
- **Update** — `UpdateAvailable` packages; full replace + rollback snapshot
- **Remove** — deletes `installed/{id}/` + metadata; clears rollback
- **Open** — unchanged (`nexus:` apps)
- **Progress** — `StatusMessage` + `ProgressBar` during operations

### CatalogChanged loop fix

- `CatalogChanged` → `ReloadUiOnly()` (no `Reload()`)
- Manual refresh uses guarded `ReloadFromRepository()` with `_suppressCatalogNotify` in store reload
- Deployment progress uses separate `DeploymentProgress` event (no catalog rebuild per tick)

## What's POC vs future

| Feature | Status |
|---------|--------|
| Local `.nxp` install/update/remove | **Implemented** |
| Full-package update | **Implemented** |
| Rollback on failed update | **Implemented** (restore snapshot) |
| Serial install queue | **Implemented** |
| Remote download | **Not in scope** |
| Delta updates | **Stub** (`INexusPackageDeltaUpdater`) |
| Mandatory update enforcement | **Stub** (`INexusMandatoryUpdatePolicy`) |
| Dependency cascade updates | **Stub** (`INexusDependencyUpdateCoordinator`) |
| Windows registry / MSI / setup.exe | **Excluded** |

## Manual verification

1. Open Ninja Store → **Tilgængelige Apps** → select **Nexus Media** → **Installer**
2. Confirm status **Installeret** and folder under `%LocalAppData%\NinjaNexus\packages\installed\nexus-media\`
3. **Nexus Files** (seeded v1.0.0, catalog v1.2.0) → **Opdater** → version becomes 1.2.0
4. **Afinstaller** removes folder and metadata
