# A-Monster Guard — Release Deploy Checklist

**Target:** `lolo.qoinix.net` (cPanel: `/home/qoinsbrm/lolo.qoinix.net`)  
**Panel version:** current working tree  
**Plugin version:** `1.3.0` (malware engine `2.4`)  
**Tests:** 188/188 passing (`php artisan test`)

---

## 1. Pre-deploy (local)

```bash
composer install --no-dev --optimize-autoloader
npm ci
npm run build
php artisan test
```

Confirm `public/build/manifest.json` exists after build.

---

## 2. Server commands (SSH / cPanel Terminal)

Run from project root on the server:

```bash
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan queue:restart
```

**Queue worker** (required for Telegram agent alerts):

```bash
php artisan queue:work --sleep=3 --tries=3 --max-time=3600
```

Use Supervisor or cPanel cron to keep the worker running.

**Scheduler** (cron, every minute):

```
* * * * * cd /home/qoinsbrm/lolo.qoinix.net && php artisan schedule:run >> /dev/null 2>&1
```

---

## 3. Panel upload bundle

Upload these paths (overwrite existing). Do **not** upload `.env`, `storage/logs/*`, or local `node_modules/`.

### PHP — core fixes

| Path | Why |
|------|-----|
| `app/Features/Monitoring/Services/WebsiteHealthService.php` | Health consistency + security score for health |
| `app/Features/Monitoring/Support/MalwareReportClassifier.php` | Confirmed malware count (string-safe) |
| `app/Features/Monitoring/Support/MalwareThreatDetailsNormalizer.php` | v2.1 threat shape |
| `app/Features/Monitoring/Models/MalwareReport.php` | Integer casts |
| `app/Features/Monitoring/Services/IncidentForensicsEnricher.php` | Forensic context |
| `app/Features/Monitoring/Services/IncidentForensicsPresenter.php` | Forensic API |
| `app/Features/Monitoring/Services/AttackDescriptionService.php` | Incident descriptions |
| `app/Features/Monitoring/Repositories/Eloquent/AuditLogRepository.php` | Forensics on ingest |
| `app/Features/Monitoring/Repositories/Eloquent/MalwareReportRepository.php` | Report storage |
| `app/Features/Monitoring/Controllers/DashboardAdminController.php` | Dashboard health batch |
| `app/Features/Monitoring/Controllers/MonitoringAdminController.php` | Malware UI API |
| `app/Features/Agent/Controllers/AgentAdminController.php` | `evaluateAgent()` health |
| `app/Features/Agent/Services/TelemetryProcessingService.php` | Telemetry pipeline |
| `app/Features/Auth/Controllers/AdminSecurityLogController.php` | Admin login logs API |
| `app/Features/Auth/Controllers/TrustedDeviceController.php` | Session timestamp cast |
| `app/Features/Auth/Services/AdminLoginNotifier.php` | Admin login Telegram |
| `app/Features/Notifications/Jobs/SendTelegramNotification.php` | Confirmed malware alerts |
| `app/Features/Notifications/Jobs/SendAdminTelegramNotification.php` | Admin notifications |
| `app/Features/Notifications/Services/` | Telegram dispatch helpers |
| `app/Support/ClientIpResolver.php` | Real client IP |
| `app/Http/Middleware/ResolveClientIp.php` | IP middleware |
| `bootstrap/app.php` | Register IP middleware |
| `routes/admin.php` | Admin security logs route |

### Frontend (after `npm run build`)

| Path | Why |
|------|-----|
| `public/build/` | **Entire folder** — dashboard, agents, malware, security settings |

Source changed (rebuild required):

- `resources/js/features/dashboard/components/DashboardView.tsx`
- `resources/js/features/agents/components/AgentsView.tsx`
- `resources/js/features/monitoring/components/MalwareReportsView.tsx`
- `resources/js/features/monitoring/components/EventDetailsDrawer.tsx`
- `resources/js/features/auth/components/SecuritySettingsView.tsx`
- `resources/js/utils/malwareReport.ts`
- `resources/js/utils/forensics.ts`

---

## 4. WordPress plugin (all 6 sites)

Upload **`A-Monster Guard Plugin/`** as plugin folder `a-monster-guard-agent` (or zip install).

| Path | Why |
|------|-----|
| `a-monster-guard-agent.php` | v1.2.6 |
| `src/Security/Malware/` | Scoring engine 2.1 |
| `src/Security/MalwareScannerModule.php` | Refactored scanner |
| `src/Security/ForensicAuditLogger.php` | Audit forensics |
| `src/Security/ForensicContextBuilder.php` | Context builder |
| `src/Security/AttackSurfaceProtectionModule.php` | Forensic logging |
| `src/Core/Plugin.php` | Wiring |

After activate/update on each site:

1. Confirm plugin version **1.2.6** in WP admin.
2. Trigger **Run malware scan** from panel (or wait for scheduled scan).
3. Verify heartbeat still succeeds (check `last_heartbeat_at` in panel).

---

## 5. Post-deploy verification

| Check | Expected |
|-------|----------|
| `/api/v1/agents` (logged in) | Returns all 6 websites, no 500 |
| Dashboard | Websites visible, counts match DB |
| Website detail health | Same status as dashboard row |
| Security Settings → Admin logs | Rows visible (not empty) |
| New admin login | Real IP (not `127.0.0.1`) in log |
| Malware report | Status labels: Clean / Suspicious / Malware |
| `storage/logs/laravel.log` | No `MalwareReportClassifier` type errors |

---

## 6. Optional env (.env on server)

Ensure proxy headers are trusted if behind Cloudflare/nginx:

```
APP_URL=https://lolo.qoinix.net
TRUSTED_PROXIES=*
```

Do not commit `.env`.

---

## 7. Rollback

Keep a backup of:

- `app/Features/Monitoring/Services/WebsiteHealthService.php`
- `public/build/`
- Previous plugin zip

If dashboard goes empty again, check `storage/logs/laravel.log` first — usually a PHP type error on `/agents` or `/dashboard/refresh`.

---

## Suggested git commit message

```
Fix health scoring, malware v2.1 panel sync, and deploy readiness

Use agent-reported security score for health when higher than policy
computed score; harden MalwareReportClassifier casts; add forensics,
admin security logs, client IP resolution, and plugin malware engine 2.1.
All 172 tests passing.
```
