diff --git a/README.md b/README.md
index 451eddd..8a9d576 100755
--- a/README.md
+++ b/README.md
@@ -53,6 +53,7 @@ docker run -d --name cpas-tracker -p 3001:3001 -v cpas-data:/data cpas-tracker
- **At-risk badge**: flags employees within 2 points of the next tier escalation
- Search/filter by name, department, or supervisor
- Click any employee name to open their full profile modal
+- **π Audit Log** button β filterable, paginated view of all system write actions
### Violation Form
- Select existing employee or enter new employee by name
@@ -66,11 +67,24 @@ docker run -d --name cpas-tracker -p 3001:3001 -v cpas-data:/data cpas-tracker
- One-click PDF download immediately after submission
### Employee Profile Modal
-- Full violation history with resolution status
+- Full violation history with resolution status and **amendment count badge** per record
+- **β Edit Employee** button β update name, department, or supervisor inline
+- **Merge Duplicate** tab β reassign all violations from a duplicate record and delete it
+- **Amend** button per active violation β edit non-scoring fields (location, notes, witness, etc.) with a full field-level diff history
- Negate / restore individual violations (soft delete with resolution type + notes)
- Hard delete option for data entry errors
- PDF download for any historical violation record
+### Audit Log
+- Append-only log of every write action: employee created/edited/merged, violation logged/amended/negated/restored/deleted
+- Filterable by entity type (employee / violation) and action
+- Paginated with load-more; accessible from the Dashboard toolbar
+
+### Violation Amendment
+- Edit submitted violations' non-scoring fields without delete-and-resubmit
+- Point values, violation type, and incident date are immutable
+- Every change is stored as a field-level diff (old β new value) with timestamp and actor
+
### CPAS Tier System
| Points | Tier | Label |
@@ -100,14 +114,19 @@ Scores are computed over a **rolling 90-day window** (negated violations exclude
| GET | `/api/health` | Health check |
| GET | `/api/employees` | List all employees |
| POST | `/api/employees` | Create or upsert employee |
+| PATCH | `/api/employees/:id` | Edit employee name, department, or supervisor |
+| POST | `/api/employees/:id/merge` | Merge duplicate employee into target; reassigns all violations |
| GET | `/api/employees/:id/score` | Get active CPAS score for employee |
| GET | `/api/dashboard` | All employees with active points + violation counts |
| POST | `/api/violations` | Log a new violation |
-| GET | `/api/violations/employee/:id` | Get violation history for employee (with resolutions) |
+| GET | `/api/violations/employee/:id` | Get violation history for employee (with resolutions + amendment counts) |
| PATCH | `/api/violations/:id/negate` | Negate a violation (soft delete + resolution record) |
| PATCH | `/api/violations/:id/restore` | Restore a negated violation |
+| PATCH | `/api/violations/:id/amend` | Amend non-scoring fields with field-level diff logging |
+| GET | `/api/violations/:id/amendments` | Get amendment history for a violation |
| DELETE | `/api/violations/:id` | Hard delete a violation |
| GET | `/api/violations/:id/pdf` | Download violation PDF |
+| GET | `/api/audit` | Paginated audit log (filterable by entity_type, entity_id) |
---
@@ -115,16 +134,16 @@ Scores are computed over a **rolling 90-day window** (negated violations exclude
```
cpas/
-βββ Dockerfile # Multi-stage: builds React + runs Express w/ Chromium
+βββ Dockerfile # Multi-stage: builds React + runs Express w/ Chromium
βββ .dockerignore
-βββ package.json # Backend (Express) deps
-βββ server.js # API + static file server
+βββ package.json # Backend (Express) deps
+βββ server.js # API + static file server
βββ db/
-β βββ schema.sql # Tables + 90-day active score view
-β βββ database.js # SQLite connection (better-sqlite3)
+β βββ schema.sql # Tables + 90-day active score view
+β βββ database.js # SQLite connection (better-sqlite3) + auto-migrations
βββ pdf/
-β βββ generator.js # Puppeteer PDF generation
-βββ client/ # React frontend (Vite)
+β βββ generator.js # Puppeteer PDF generation
+βββ client/ # React frontend (Vite)
βββ package.json
βββ vite.config.js
βββ index.html
@@ -132,28 +151,33 @@ cpas/
βββ main.jsx
βββ App.jsx
βββ data/
- β βββ violations.js # All CPAS violation definitions + groups
+ β βββ violations.js # All CPAS violation definitions + groups
βββ hooks/
β βββ useEmployeeIntelligence.js # Score + history hook
βββ components/
- βββ CpasBadge.jsx # Tier badge + color logic
- βββ TierWarning.jsx # Pre-submit tier crossing alert
- βββ Dashboard.jsx # Company-wide leaderboard
- βββ ViolationForm.jsx # Violation entry form
- βββ EmployeeModal.jsx # Employee profile + history modal
- βββ NegateModal.jsx # Negate/resolve violation dialog
- βββ ViolationHistory.jsx # Violation list component
+ βββ CpasBadge.jsx # Tier badge + color logic
+ βββ TierWarning.jsx # Pre-submit tier crossing alert
+ βββ Dashboard.jsx # Company-wide leaderboard + audit log trigger
+ βββ ViolationForm.jsx # Violation entry form
+ βββ EmployeeModal.jsx # Employee profile + history modal
+ βββ EditEmployeeModal.jsx # Employee edit + merge duplicate
+ βββ AmendViolationModal.jsx # Non-scoring field amendment + diff history
+ βββ AuditLog.jsx # Filterable audit log panel
+ βββ NegateModal.jsx # Negate/resolve violation dialog
+ βββ ViolationHistory.jsx # Violation list component
```
---
## Database Schema
-Three tables + one view:
+Six tables + one view:
- **`employees`** β id, name, department, supervisor
- **`violations`** β full incident record including `prior_active_points` snapshot at time of logging
- **`violation_resolutions`** β resolution type, details, resolved_by (linked to violations)
+- **`violation_amendments`** β field-level diff log for violation edits; one row per changed field per amendment
+- **`audit_log`** β append-only record of every write action (action, entity_type, entity_id, performed_by, details, timestamp)
- **`active_cpas_scores`** (view) β sum of points for non-negated violations in rolling 90 days, grouped by employee
---
@@ -177,26 +201,33 @@ Three tables + one view:
| 4 | Tier crossing warning | Pre-submit alert when new points push employee to next tier |
| 4 | Employee profile modal | Full history, negate/restore, hard delete, per-record PDF download |
| 4 | Negate & restore | Soft-delete violations with resolution type + notes, fully reversible |
+| 5 | Employee edit / merge | Update employee name/dept/supervisor; merge duplicate records without losing history |
+| 5 | Violation amendment | Edit non-scoring fields with field-level audit trail |
+| 5 | Audit log | Append-only log of all system writes; filterable panel in the dashboard |
---
-### π² Proposed
+### π In Progress
+
+#### Reporting & Visibility
+- **Expiration timeline** β per-employee view showing which active violations roll off the 90-day window and when; lets supervisors anticipate tier drops before they happen
+- **Employee notes / flags** β free-text notes attached to an employee record (e.g. "on PIP", "union member") visible in the profile modal without affecting scoring
+
+---
+
+### π‘ Proposed
#### Reporting & Analytics
- **Violation trends chart** β line/bar chart of violations per day/week/month, filterable by department or supervisor; useful for identifying systemic patterns vs. individual incidents
- **Department heat map** β grid view showing violation density and average CPAS score by department; helps supervisors identify team-level risk
-- **Expiration timeline** β visual showing which active violations will roll off the 90-day window and when, so supervisors can anticipate tier drops
- **CSV / Excel export** β bulk export of violations or dashboard data for external reporting or payroll integration
#### Employee Management
-- **Employee edit / merge** β ability to update employee name, department, or supervisor without losing history; merge duplicate records created by name typos
- **Supervisor view** β scoped dashboard showing only the employees under a given supervisor, useful for multi-supervisor environments
-- **Employee notes / flags** β free-text notes attached to an employee record (e.g. "on PIP", "union member") visible in the profile modal without affecting scoring
#### Violation Workflow
- **Acknowledgment signature field** β a "received by employee" name/date field on the violation form that prints on the PDF, replacing the blank signature line
- **Draft / pending violations** β save a violation as draft before finalizing, useful when incidents need review before being officially logged
-- **Violation amendment** β edit a submitted violation's details (not points) with an audit trail, rather than delete-and-resubmit
- **Bulk violation import** β CSV import for migrating historical records from paper logs or a prior system
#### Notifications & Escalation
@@ -206,7 +237,6 @@ Three tables + one view:
#### Infrastructure & Ops
- **Multi-user auth** β simple login with role-based access (admin, supervisor, read-only); currently the app has no auth and is assumed to run on a trusted internal network
-- **Audit log** β immutable log of all creates, negates, restores, and deletes with timestamp and acting user, stored separately from the violations table
- **Automated DB backup** β cron job or Docker health hook to snapshot `/data/cpas.db` to a mounted backup volume or remote location on a schedule
- **Dark/light theme toggle** β the UI is currently dark-only; a toggle would improve usability in bright environments
diff --git a/client/src/components/EmployeeModal.jsx b/client/src/components/EmployeeModal.jsx
index 4706e87..d1a57f7 100755
--- a/client/src/components/EmployeeModal.jsx
+++ b/client/src/components/EmployeeModal.jsx
@@ -4,6 +4,8 @@ import CpasBadge, { getTier } from './CpasBadge';
import NegateModal from './NegateModal';
import EditEmployeeModal from './EditEmployeeModal';
import AmendViolationModal from './AmendViolationModal';
+import ExpirationTimeline from './ExpirationTimeline';
+import EmployeeNotes from './EmployeeNotes';
const s = {
overlay: {
@@ -201,7 +203,7 @@ export default function EmployeeModal({ employeeId, onClose }) {