# Indirect Goods Upgrade — Phase 14 Completion

## Daily health audit

The read-only command below audits the indirect-goods workflow without changing balances:

```bash
php artisan indirect-goods:monitor
php artisan indirect-goods:monitor --json
php artisan indirect-goods:monitor --fail-on-warning
```

It checks:

- Negative warehouse, project and FOC quantities.
- Request released quantity against fulfillment totals.
- Fulfillment and allocation over-accounting.
- Overall project reconciliation variance.
- FOC inventory against the latest adjustment balance.
- Division summaries against warehouse/project source ledgers.
- Active fulfillments and completed returns without stock movements.
- Duplicate fulfillment idempotency keys, delivery numbers and return numbers.
- Missing fulfillment division, project or source context.

Every exception includes severity, stable code, entity type/ID, operational owner, open status and details.

## Scheduling and alerts

Laravel schedules the JSON audit every day at **02:15 server time**, with overlap prevention and a single-server mutex:

```text
15 2 * * * php artisan indirect-goods:monitor --json
```

The application scheduler must already be invoked by the host's normal once-per-minute cron or process supervisor. Repository code cannot verify or create that host-level scheduler safely.

- Critical exceptions return a failing exit code and write a critical structured log entry.
- Warnings create a structured warning entry.
- Clean audits create a compact informational entry.
- `--fail-on-warning` is available for stricter CI/alert integrations.

The infrastructure log collector should alert the warehouse operations channel on `Indirect-goods daily health audit failed`. Failed transactional operations continue to be captured by the existing controller/service exception logging; rolled-back transactions leave no partial ledger rows.

## Reconciliation dashboard

Managers with `warehouse.indirect-reconciliation.run` can access:

```text
/warehouse/indirect-goods/reconciliation
```

The dashboard provides:

- Health, critical, warning and reconciliation-variance cards.
- Severity and exception-code filters.
- Read-only exception table with owner/status.
- CSV exception export using the same filters.
- A protected per-request JSON audit timeline covering creation, approval, fulfillments and stock movements.
- Navigation through Warehouse → Inventory → Indirect Reconciliation.

## Operational repair boundary

- `indirect-goods:backfill-fulfillments --dry-run` and `indirect-goods:backfill-consumption-links --dry-run` remain the supported diagnostic repair previews.
- No monitoring command writes stock or silently repairs an exception.
- Any committed repair requires a reviewed reconciliation result and the Phase 11 reconciliation permission/process.
- Stock corrections use approved compensating operations; completed documents and audit ledgers are never deleted.

## Verification result

- Live health audit: **healthy**.
- Critical exceptions: **0**.
- Warnings: **0**.
- Daily schedule registered for 02:15.
- Blade compilation passed.
- Full suite: **32 tests, 84 assertions, 0 failures**.
- Reconciliation variance remains **0.0000**.

## Upgrade completion

Phases 0–14 of the indirect-goods issue parity and FOC-only return upgrade are implemented. External operations must still maintain the production scheduler, alert routing, backups, supervised cutover evidence and daily exception ownership described in the Phase 13 and Phase 14 runbooks.

