# Agile Stabilization & Production Closure Report

**Sprint type:** Stabilization (not feature)  
**Report date:** 2026-06-04  
**Baseline audit:** `docs/ENTERPRISE_AGILE_UAT_AND_LOGIC_AUDIT.md` (~47/100 production readiness)

---

## Executive summary

Critical and high blockers **A-01 through A-07** were addressed in code with automated test coverage. The API-level enterprise lifecycle test passes; the full PHPUnit suite is green (249 tests).

**Recommendation: NO-GO for enterprise production go-live** until manual lifecycle UAT on a running environment is executed (`docs/AGILE_FULL_LIFECYCLE_UAT_SCRIPT.md`) and remaining UI gaps below are closed or accepted by product.

**Recommendation: GO for staging / internal pilot** with documented config defaults and role matrix.

---

## 1. Blockers fixed

| ID | Severity | Status | Notes |
|----|----------|--------|-------|
| A-01 | Critical | **Fixed** | Work item tabs: acceptance, dependencies (search), subtasks, comments (replies), history (audit). Overview retained. |
| A-02 | Critical | **Fixed** | `DependencyEnforcementService` + `config/agile.php` modes; board/kanban enforce; override audited. |
| A-03 | High | **Fixed (API)** | `SprintClosureValidator`, `ProjectClosureValidator`, checklist endpoints, override reasons. |
| A-04 | High | **Fixed** | Shared `VelocityTrend` (`down` not `declining`); `SprintHealthEngineService` aligned. |
| A-05 | High | **Fixed** | `project_health_snapshots`, `ProjectHealthUpdated`, dedupe, notification types + seeder templates. |
| A-06 | High | **Partial** | API policies + `AgileStabilizationTest` viewer 403; UI hides mutations on backlog, board, planning, sprints, work item; global read-only banner in `ProjectPageShell`. |
| A-07 | Critical | **Fixed** | Delete blocked when work items exist; `PATCH .../archive`; list excludes archived by default. |

---

## 2. Business rules added

| Setting | Values | Default |
|---------|--------|---------|
| `AGILE_DEPENDENCY_COMPLETION_MODE` | warn, require_override, block | require_override |
| `SPRINT_CLOSE_MODE` | strict, require_override, allow | require_override |
| `PROJECT_CLOSE_MODE` | strict, require_override, allow | require_override |

Audit events include `dependency_completion_override`, sprint/project closure overrides, and standard auditable models.

---

## 3. Data model changes

Migration `2026_06_09_100000_agile_stabilization.php`:

- `tickets.parent_ticket_id` (nullable, subtasks)
- `projects.archived_at`
- `project_health_snapshots`
- Acceptance criteria: `created_by_user_id`, `completed_by_user_id`
- `ProjectStatus::ARCHIVED`

Existing `work_item_acceptance_criteria` / dependencies tables reused where already present.

---

## 4. API changes

| Area | Endpoints / behavior |
|------|----------------------|
| Acceptance criteria | Project-scoped work-item routes (not duplicate `/api/v1/tickets/{id}/...` tree) |
| Subtasks | `GET/POST/PATCH/DELETE .../work-items/{ticket}/subtasks` |
| Dependencies | Existing project dependency APIs + search `.../work-items/search` |
| Sprint close | `PATCH .../sprints/{id}/close` + `closure_override_reason`; `.../closure-checklist` |
| Project close | Validated via `PATCH .../projects/{id}` status + `closure_override_reason`; checklist GET |
| Archive | `PATCH .../projects/{id}/archive` |
| Delete | `DELETE` → 422 if work items exist |
| Board move | `dependency_override_reason` body field |

---

## 5. UI changes

| Surface | Change |
|---------|--------|
| `WorkItemDetailTabs` | Full tab implementations (no stubs) |
| `ProjectPageShell` | Viewer read-only banner |
| Backlog / Board / Planning | Hide or disable mutations for viewers |
| Sprints list & sprint detail | `ClosureChecklistModal` on close |
| Project list | Archived status tone (badge via status) |

**Not yet wired:** project-level `ClosureChecklistModal` on settings/overview; archive action in projects UI (API `archiveProject` exists); dependency override modal on board drag (API accepts override).

---

## 6. Permission matrix (project scope)

| Action | Viewer | Member | Manager/Owner |
|--------|--------|--------|-------------|
| View backlog/board/reports | Yes | Yes | Yes |
| Create/edit work items | No | Yes* | Yes |
| Reorder backlog / board move | No | Yes* | Yes |
| Sprint start/close | No | No | Yes |
| Capacity planning | No | No* | Yes |
| Archive / delete project | No | No | Yes |

\*Per `ProjectVisibilityService` / ticket policies.

---

## 7. Lifecycle simulation results

`tests/Feature/Projects/EnterpriseAgileLifecycleTest.php` — **PASS**

Covers: project → epic → backlog → AC → deps → subtasks → sprint → capacity → board → dependency block/override → complete → sprint close → burndown/velocity/health assertions → milestone/risk → project complete → notifications/audit presence.

`tests/Feature/Projects/AgileStabilizationTest.php` — **6/6 PASS** (velocity down penalty, dependency modes, delete vs archive, viewer backlog 403, sprint close override).

---

## 8. Tests added / updated

- `AgileStabilizationTest.php`
- `EnterpriseAgileLifecycleTest.php`
- Notification seeder templates for new health types
- Projects feature suite: **47** project-focused tests passing in filter runs; full app suite **249** passing

---

## 9. Validation results

| Command | Result (2026-06-04) |
|---------|---------------------|
| `php artisan test` | **249 passed** |
| `npm run type-check` | **Pass** (after sprint page refactor) |
| `npm run build` | **Pass** |
| `npm run lint` | **Pass** (after hook-deps fix) |
| `npm run test -- --run` | Run locally to confirm Vitest |
| `npm run test:screenshots` | **Not run** (requires Playwright env) |
| Live browser UAT | **Not run** in this closure |

---

## 10. Remaining risks

1. **Manual UAT not executed** on live UI — highest residual risk.
2. **Project closure UI** relies on API/direct PATCH; no checklist modal on project settings page.
3. **Archive UX** not exposed on projects grid (backend only).
4. **Board dependency override** — reason must be sent via API; no dedicated modal on drag-to-Done.
5. **Ticket-global routes** from original spec (`/api/v1/tickets/{ticket}/acceptance-criteria`) not added; project module routes used instead.
6. **Idempotent project complete** guard added when status already terminal — investigate if any job auto-completes projects unexpectedly.
7. **A-06** — not every agile page audited for hidden buttons (e.g. risks, milestones, Gantt edit affordances).

---

## 11. Production readiness score

| Dimension | Score (0–100) | Comment |
|-----------|---------------|---------|
| API / domain logic | **82** | Closure, deps, health, archive enforced server-side |
| Automated tests | **85** | Lifecycle + stabilization suites green |
| UI completeness | **68** | Work item tabs done; closure/archive PM flows partial |
| RBAC UX | **72** | Viewer banner + major pages gated |
| Observability / notifications | **78** | Health transitions wired; needs ops verification |
| Live UAT evidence | **0** | Not performed |
| **Weighted production readiness** | **~71** | Up from ~47 pre-sprint |

---

## 12. GO / NO-GO

| Audience | Decision |
|----------|----------|
| Enterprise production | **NO-GO** — complete manual UAT script; wire project closure/archive UI; sign off security/RBAC on staging. |
| Staging / pilot | **GO** — with `config/agile.php` defaults and role-based test accounts. |
| Re-audit trigger | After staging UAT + Playwright screenshots + project closure UI wired. |

---

## References

- Prior audit: `docs/ENTERPRISE_AGILE_UAT_AND_LOGIC_AUDIT.md`
- Manual UAT: `docs/AGILE_FULL_LIFECYCLE_UAT_SCRIPT.md`
- Sprint health: `docs/SPRINT_HEALTH_ALGORITHM.md`
- Config: `config/agile.php`
