# V1.1 Handoff: Done vs Pending Date: 2026-03-19 ## Completed in this pass ### Owner KPI (scan-first) - [x] Snapshot freshness now updates when KPI rows are edited (`patchWeeklyKpiRow` touches parent snapshot `updatedAt`). - [x] Owner board metadata now shows `source` together with `lastUpdatedAt` and coverage. - [x] Drill-down `
` sections are no longer forced closed on rerender. ### Human Capital - [x] Removed write side-effect from `GET /api/human-capital/dashboard` (read no longer auto-publishes KPIs). - [x] `people` endpoint now requires owner/HC leader (`canManageHumanCapital`) for employee-level visibility. - [x] `lifecycle-events` GET now requires owner/HC leader. - [x] `updates` GET now hides non-published items from non-managers. - [x] CSV export fixed to real newlines (`\n`) instead of escaped `\\n` text. - [x] People endpoint now calls `ensureEmployeeProfiles()` to reduce first-load/race gaps. - [x] HC compliance input excludes auto-published HC KPI section (`human-capital-auto-v1`) to prevent KPI self-feedback. - [x] Churn trend denominator now uses month-specific estimated headcount rather than current headcount for all months. ### Operations / Maintenance - [x] Removed write side-effect from `GET /api/operations/dashboard` (read no longer auto-publishes KPIs). - [x] Added owner approval action endpoint: `PATCH /api/operations/approvals/[id]`. - [x] Added policy endpoint: `GET/PATCH /api/operations/policy`. - [x] Work-order read/list is department-scoped. - [x] Template read/list is department-scoped. - [x] Reminder read/list is department-scoped. - [x] Asset update/delete now validates department ownership before mutating. - [x] Work-order patch now validates department scope and blocks non-owner state transitions when owner approval is pending. - [x] Production-plan patch now validates department scope and enforces owner-only transitions for `approved/released`. - [x] Production-plan create enforces owner-only for privileged states and sets approval metadata accordingly. - [x] Maintenance policy bootstrap now backfills missing owner approver when possible. - [x] Work-order create now validates asset/template department ownership and resolves owner approver fallback. - [x] Operations dashboard payload now includes `workOrderId` / `productionPlanId` in approval inbox entries. - [x] Operations UI owner inbox now has Approve/Reject actions wired to approval API. - [x] Operations UI now shows down-assets in summary and an upcoming maintenance list. ### Marketing - [x] Meta connection/disconnect now avoids inactive-row unique collisions by clearing stale inactive rows before state flips. - [x] Meta sync now attempts both Facebook and Instagram ingestion (best-effort Instagram discovery/fetch). - [x] Social snapshot writes now dedupe same `department+channel+range+capturedAt` before create. - [x] SocialPanel no longer computes local fallback growth math from snapshots; it displays server insights only. - [x] Initiative drawer now includes attribution fields in UI: channel, page ID, campaign tag, date window. - [x] Initiative drawer includes "Use auto values" action and displays last auto-fill summary. - [x] Marketing scoring and initiative mapping now consume auto-attributed actuals when manual values are still zero. - [x] Sync auto-fill now respects attribution page/date windows; campaign-tagged records are intentionally skipped until campaign-level data is ingested. ### Database / schema - [x] Prisma migration created: `prisma/migrations/20260319180300_0012_v11_scan_first_owner_department_dashboards/migration.sql`. ## Validation status - [x] `npm test` passes (19/19). - [x] `npm run build` passes. - [ ] Recharts static-generation warnings remain (`width(-1)/height(-1)`), non-blocking but should be cleaned later. ## Remaining / Follow-up items ### High-priority follow-up - [ ] Add campaign-level attribution ingestion for Meta sync (currently campaign-tagged initiatives are skipped to avoid bad attribution). - [ ] Add explicit CRUD coverage for operations entities still missing full lifecycle endpoints (e.g., delete/update routes for every list entity as originally envisioned). - [ ] Add automated API tests for new authorization hardening and owner-approval transition guards. ### Medium-priority follow-up - [ ] Add UI controls for operations policy thresholds (`costThreshold`, `downtimeThresholdHours`, approver owner). - [ ] Improve Instagram metrics quality (current implementation is best-effort and may use limited fields depending on account permissions). - [ ] Normalize/chunk dashboard chart containers to remove Recharts build-time width warnings. ### Optional / V1.2 candidates - [ ] Improve attribution model to support campaign/source dimensions end-to-end in stored metrics. - [ ] Add audit trail events for owner approval actions (who/when/why) in UI timeline. - [ ] Add integration tests for Meta sync -> initiative auto-fill -> publish -> owner KPI chain. ## Quick resume commands ```bash cd /home/mdares03/benell npm test npm run build ``` ## Notes for next person - Projects module was intentionally left unchanged per V1.1 scope. - Department dashboards now feed owner KPI via explicit publish endpoints (read endpoints no longer mutate KPI data).