# Phase 006 Execution ## Scope - Added maintenance schedule management pages. - Added manual schedule baselines for mileage and time calculations. - Added overdue, upcoming, no-history, and current maintenance status calculations. - Added vehicle show alerts for overdue, upcoming, and no-history schedules. - Added logger-backed notification behavior for status changes. - Added specs for schedule CRUD and maintenance status behavior. ## Changes - Added schedule fields for `baseline_odometer`, `baseline_date`, `active`, `last_status`, and `last_status_changed_at`. - Added validation for manual baselines and schedule active state. - Added nested maintenance schedule routes under vehicles. - Added `MaintenanceSchedulesController` with list, show, new, create, edit, update, and deactivate actions. - Added separate maintenance schedule views and a shared form partial. - Added `MaintenanceScheduleStatus` for calculating due odometer/date and status. - Added `MaintenanceNotification` as the isolated notification stub that logs status changes through `Rails.logger`. - Updated `vehicles#show` to show overdue alerts, upcoming warnings, no-history notices, next due odometer, next due date, and status. - Updated maintenance entry validation and forms to use only active schedules for new entries. - Added request specs for schedule CRUD, soft deactivation, vehicle alerts, and status-change logging. - Added model specs for mileage-based, time-based, upcoming, no-history, and current status cases. ## Decisions - Maintenance schedule baselines are manually entered per schedule. - Without matching maintenance history, status uses the schedule baseline. - With matching maintenance history, status uses the latest matching maintenance entry instead of the schedule baseline. - A schedule is overdue exactly when either mileage or time interval is reached. - Upcoming warnings use a 5% lead window for both mileage and time intervals. - Schedules are soft-deactivated instead of deleted. - Vehicle show is allowed to update stored status tracking and log status changes. - Status changes are stored for all statuses, but notifications are logged only for `upcoming` and `overdue` statuses. ## Verification - Passed: `bundle exec rspec spec/models/maintenance_schedule_spec.rb spec/models/maintenance_schedule_status_spec.rb` - Passed: `bundle exec rspec spec/requests/vehicles_spec.rb` - Passed: `bundle exec rspec` - Passed: `bin/rubocop app/models/maintenance_schedule.rb app/models/maintenance_entry.rb app/models/maintenance_schedule_status.rb app/models/maintenance_notification.rb app/controllers/vehicles_controller.rb app/controllers/fuel_entries_controller.rb app/controllers/maintenance_entries_controller.rb app/controllers/maintenance_schedules_controller.rb spec/models/maintenance_schedule_spec.rb spec/models/maintenance_schedule_status_spec.rb spec/requests/vehicles_spec.rb` - Passed: `bin/ci`