# PBPS MIS Improvement Roadmap (Critical -> Low)

This roadmap turns the full-system analysis into phased implementation work for a production-grade Performance Based Payment Scheme (PBPS) MIS.

## How to use this document

- Start with Phase 1 and do not skip controls marked Critical.
- Each item includes a target outcome and implementation notes.
- Keep this file updated as each item is delivered.

---

## Phase 1 - Critical Controls (Payment-Grade Integrity)

### 1. Verification decision integrity and audit trail
- **Goal:** Every verification decision is traceable, justified, and immutable enough for external review.
- **Missing today:** Subject decisions can be saved without structured rationale; audit coverage is partial.
- **Simple meaning:** Verifiers cannot just click yes/no without explanation for negative decisions, and every decision leaves a trace.
- **What changed vs old behavior:** Before, decision justification was inconsistent and audit trail coverage was incomplete. Now negative decisions require structured reason + note, and decision/finalization events are logged.
- **Implement:**
  - Require verifier reason note when decision is negative.
  - Add decision reason taxonomy (`document_mismatch`, `beneficiary_unreachable`, `not_eligible`, `other`).
  - Write `submission_events` entries for:
    - subject verification update,
    - run finalization.
  - Include actor, decision payload hash/meta, run and subject references.
- **Status:** In progress (started in this implementation round).

### 2. Reproducible and defensible sampling
- **Goal:** Sampling runs are repeatable and externally auditable.
- **Missing today:** Non-deterministic random draw and no manifest/seed persistence.
- **Simple meaning:** If an auditor asks "why these trainees were sampled?", the system can reproduce exactly the same sample from stored seed + rules.
- **What changed vs old behavior:** Before, runs could differ unpredictably. Now sampling is deterministic and manifest-backed with representativeness factors.
- **Implement:**
  - Deterministic sampling with stored seed.
  - Save sampling manifest snapshot (population size, selected IDs hash, config).
  - Add representativeness report (sex, age band, training/cohort/location distributions).
  - Block finalization if representativeness diagnostics fail configurable thresholds.

### 3. Verification evidence chain
- **Goal:** Verified outcomes are supported by documents/evidence per sampled subject.
- **Missing today:** No per-subject evidence registry.
- **Simple meaning:** Each sampled trainee must have proof files attached before final verification decisions.
- **What changed vs old behavior:** Before, verification could proceed without evidence artifact tracking. Now evidence upload/download is per subject and enforced.
- **Implement:**
  - Add verification evidence table and upload API.
  - Evidence type checklist per indicator/report type.
  - Require minimum evidence set before subject can be marked verified.

### 4. Indicator governance lock and versioning
- **Goal:** Indicator definitions used for payment cannot be silently changed.
- **Missing today:** No immutable version history + maker-checker workflow.
- **Simple meaning:** Indicator definitions are treated like controlled documents, not editable without trace.
- **What changed vs old behavior:** Before, changes could be hard to audit historically. Now version snapshots record create/update/lock/delete context.
- **Implement:**
  - `project_indicator_versions` snapshot table.
  - "Propose change -> approve -> publish" flow.
  - Freeze indicator versions by payment period.

### 5. Payment lifecycle domain
- **Goal:** Complete claim-to-disbursement control plane.
- **Missing today:** KPI and verification exist, but payment entities are absent.
- **Simple meaning:** End-to-end payment objects and states are still outside this pilot MIS scope.
- **What changed vs old behavior:** No pilot change here; this remains deferred.
- **Implement:**
  - `payment_period`, `payment_claim`, `payment_verdict`, `payment_instruction`,
    `payment_adjustment`, `dispute_case`.
  - State machines with strict transitions and audit events.

---

## Phase 2 - High Priority Robustness

### 1. Outcome resubmission dual control and SLA
- **Simple meaning:** The same person who requests re-upload cannot approve it, and reviewer comments are mandatory.
- **What changed vs old behavior:** Before, resubmission control was weaker. Now approval/rejection follows dual control with rationale.
- Enforce requester != approver.
- Mandatory reviewer rationale.
- Aging/escalation for pending requests.

### 2. Universal event ledger coverage
- **Simple meaning:** Important actions across modules are written into a common event ledger.
- **What changed vs old behavior:** Before, some modules had no consistent mutation logs. Now more critical workflows are audit-logged.
- Extend event logging across all critical mutations:
  - indicator create/update/retire,
  - activity review decisions,
  - resubmission decisions,
  - diagnostics repair actions.

### 3. Centralized scope policy engine
- **Simple meaning:** Access scope logic (admin vs TP provider scope) is centralized, not repeated differently in each route.
- **What changed vs old behavior:** Before, each route had custom checks and could drift. Now routes use shared policy service consistently.
- Replace route-level repeated TP checks with a single scope policy service.
- Apply uniformly to outcomes, verification, attendance, activities.

### 4. Comprehensive `useCohorts` consistency guards
- **Simple meaning:** Training/cohort/location/duration combinations are validated everywhere on create/update/import.
- **What changed vs old behavior:** Before, some inconsistent combinations could slip through. Now writes are blocked when scope mapping is invalid.
- Add write-time transactional checks across all relevant endpoints.
- Reject inconsistent training/cohort/location/duration combinations everywhere.

### 5. Verification rerun policy
- **Simple meaning:** You can rerun verification by period in controlled rounds, without duplicate open runs.
- **What changed vs old behavior:** Before, rerun handling was ambiguous. Now runs carry period/round metadata and duplicate-open prevention.
- Allow period-based reruns while preventing accidental duplicates.
- Introduce run series metadata (`period_key`, `round_no`).

---

## Phase 3 - Medium Priority Operations and Scale

### 1. Configurable late submission policy
- **Simple meaning:** Activity windows now support optional grace days, and late is tracked but not penalized in pilot mode.
- **What changed vs old behavior:** Before, window closed strictly at end date. Now admins can allow extra days and still monitor lateness.
- Grace periods, penalties, and override reasons for late activity submissions.

### 2. Data quality operations
- **Simple meaning:** Admin can run quick health checks to find missing mapping fields and other common integrity issues.
- **What changed vs old behavior:** Before, data issues were mostly discovered manually. Now there is a dedicated report and safe repair support.
- Scheduled anomaly checks:
  - duplicate trainees,
  - suspicious spikes,
  - denominator drift,
  - impossible transitions.
- Exception queue with owner and resolution state.

### 3. Observability and risk monitoring
- **Simple meaning:** Admin can monitor operational risks (stale verification, delayed reviews, failed imports, unresolved requests).
- **What changed vs old behavior:** Before, no compact risk view existed. Now a focused monitor endpoint/UI gives early warning signals.
- Dashboards and alerts for:
  - failed imports,
  - stale verification runs,
  - unresolved resubmissions,
  - permission/scope denials.

### 4. Permission granularity improvements
- **Simple meaning:** New operational tools are explicitly protected by admin settings permission.
- **What changed vs old behavior:** Before, new ops surfaces did not exist. Now they are wired behind `admin:settings`.
- Split `view:*` and `submit/manage:*` for sensitive modules (especially outcomes and verification).

---

## Phase 4 - Lower Priority UX and Productivity

### 1. Advanced search and cross-module navigation
- **Simple meaning:** Search is faster to use with keyboard navigation (up/down/enter) and permission-aware results.
- **What changed vs old behavior:** Before, search required mouse-first interaction. Now keyboard-first navigation is supported.
- Unified command/search palette with permission-aware entity routing and recents.

### 2. Bulk review tools for verification
- **Simple meaning:** Verifiers can jump quickly through pending sample subjects during review.
- **What changed vs old behavior:** Before, reviewers scrolled manually row by row. Now there are quick next/previous pending actions.
- Keyboard-driven review queue, reason templates, and evidence checklist quick actions.

### 3. Executive and donor reporting packs
- **Simple meaning:** Admin can generate a concise project snapshot for governance/donor reporting conversations.
- **What changed vs old behavior:** Before, summary extraction was manual. Now there is an API + UI-generated executive snapshot.
- Exportable monthly PBPS governance pack (claims, verification, disputes, payments, exceptions).

---

## Suggested Execution Order

1. Phase 1.1 (decision integrity + event logs) - start now.
2. Phase 1.2 (deterministic sampling + manifest).
3. Phase 1.3 (verification evidence table/API/UI).
4. Phase 2.1 and 2.2 (dual control + universal event ledger).
5. Phase 1.4 and 1.5 (indicator governance and payment lifecycle).

---

## Current Implementation Progress

- [x] Roadmap document created.
- [x] Phase 1.1 Verification decision integrity complete.
- [x] Phase 1.2 Sampling reproducibility complete.
- [x] Phase 1.3 Verification evidence chain complete.
- [x] Phase 1.4 Indicator governance versioning complete.
- [ ] Phase 1.5 Payment lifecycle domain complete (deferred for pilot: payments handled outside MIS).
- [x] Phase 2.1 Outcome resubmission dual-control + mandatory rationale complete.
- [x] Phase 2.2 Universal event ledger coverage complete.
- [x] Phase 2.3 Centralized scope policy engine complete.
- [x] Phase 2.4 Comprehensive useCohorts consistency guards complete.
- [x] Phase 2.5 Verification rerun policy complete.
- [x] Phase 3.1 Configurable late submission policy complete (pilot mode: no penalties, grace days supported).
- [x] Phase 3.2 Data quality operations complete (admin report + anomaly samples).
- [x] Phase 3.3 Observability and risk monitoring complete (risk monitor API + settings UI).
- [x] Phase 3.4 Permission granularity improvements complete for new ops surfaces (`admin:settings`).
- [x] Phase 4.1 Advanced search/navigation improvements complete (keyboard navigation in search).
- [x] Phase 4.2 Bulk verification review productivity complete (next/prev pending subject jump actions).
- [x] Phase 4.3 Executive and donor reporting pack complete (executive pack API + settings UI snapshot).
