# Phase 7 — Maintenance management

Phase 7 adds airline-scoped maintenance programs, recurring task requirements, planning schedules, work orders, task completions, defect management, controlled approvals, attachments, and operational return-to-service records. The module is an operational management aid and does not claim regulatory certification.

## Programs, tasks, and triggers

Tasks can apply to an aircraft type, a specific aircraft, or the airline fleet. Supported triggers are calendar date, flight hours, flight cycles, engine hours, engine cycles, landing count, custom measurements, and whichever occurs first. Requirements retain last-completion readings, next-due readings, warning thresholds, mandatory status, and calculated Planned, Due Soon, Due, or Overdue state.

The planning screen provides due lists plus task, aircraft, maintenance-provider, and calendar-oriented schedule data. Completed work recalculates applicable next-due values without overwriting completion history.

## Work orders and defects

Work orders retain planned and actual times, assigned engineer, provider, findings, corrective action, labour, Phase 8 parts consumption, estimated and actual cost, approval state, task completions, private attachments, and return-to-service state. Approved closed work orders and approval decisions are immutable.

Defects retain flight context, category, severity, aircraft-on-ground state, assignment, rectification actions, deferral and expiry information, and closure approval. Critical and aircraft-on-ground defects immediately ground the aircraft and create aircraft status history.

## Scheduling enforcement and alerts

The backend prevents aircraft assignment and dispatch release when a critical/AOG defect is open, mandatory maintenance is overdue, a required return-to-service approval is absent, airworthiness or insurance records are expired, or the aircraft is under maintenance, grounded, or out of service. Enforcement applies to individual flight creation/edit, recurring generation, duplication, imports, bulk assignment, conflict detection, and dispatch release.

Alerts cover approaching, due, and overdue maintenance, deferred defects nearing expiry, aircraft-on-ground events, and pending return to service. Fleet dashboard upcoming-maintenance and open-defect indicators include Phase 7 records. No GPS, ADS-B, or geographical tracking is used.

## Security

Routes and services enforce separate view, manage, schedule, complete, defect, approve, release, and attachment permissions. Mutations require CSRF protection, all queries are prepared and airline-scoped, output is escaped, uploads remain outside the public directory, timestamps are UTC, money uses `DECIMAL`, and all material events are audited.
