# FleetLume Autopilot

## What it automates

Autopilot scans operational records and can create notifications and team tasks for:

- Late or stalled loads
- Delivered loads missing POD/BOL
- Reefer temperatures outside the configured range
- Fuel allocations that are exceeded or expired
- HOS logs with violations, draft status, or recertification needs
- Border crossings with document, queue, inspection, or hold delays
- Overdue customer invoices
- Carrier authority and insurance review

Gemini is used to prioritize deterministic findings and draft concise action text. If Gemini is unavailable, the deterministic checks and safe actions continue to work.

## Action safety levels

- **Automatic safe actions:** notifications and team tasks
- **Approval required:** customer/broker message drafts and any future data-changing action
- **Never automatic:** payments, journal entries, settlement approval, load assignment, HOS certification, border clearance, legal/compliance decisions, or safety decisions

## Change notifications and audit trail

Every executed AI action:

1. Writes a record to `ai_change_log`.
2. Appears in **AI Autopilot → AI change feed**.
3. Creates a notification for owners and administrators.
4. Writes a standard activity-log entry.

## Cron configuration

Run hourly:

```bash
php /full/path/to/fleetlume/automation_runner.php
```

Example cPanel cron command:

```bash
/usr/local/bin/php /home/ACCOUNT/public_html/automation_runner.php >/dev/null 2>&1
```

Use the PHP binary path provided by the hosting company. The script accepts CLI execution only.

## Recommended rollout

1. Start all rules in **Recommend only** mode.
2. Review results for several days.
3. Enable **Automatically run safe actions** for notifications and tasks.
4. Keep sensitive actions approval-only.
5. Review failed runs and change records daily during the rollout period.
