feat: add audit log demo data + spec kit compliance audit
Some checks are pending
Deploy to Production / deploy (push) Waiting to run
Test / backend-test (push) Waiting to run
Test / frontend-test (push) Waiting to run

- Added 15 audit log entries demonstrating various actions
- Created SPEC-KIT-AUDIT.md documenting feature completeness
- Actions: LOGIN, CREATE, UPDATE, DELETE, ACCESS, EXPORT, APPROVE
This commit is contained in:
fullsizemalt 2025-12-12 22:21:11 -08:00
parent c7f8bc8cec
commit 8b2c55c637
2 changed files with 204 additions and 0 deletions

View file

@ -566,6 +566,42 @@ async function main() {
}
console.log(' ✓ 14 days of time punch history');
// ==================== AUDIT LOGS ====================
console.log('\n📋 Creating Audit Log Entries...');
const auditEntries = [
{ userId: users.admin?.id, userName: 'Admin User', action: 'LOGIN', entity: 'User', entityName: 'Admin login from office', ipAddress: '192.168.1.50' },
{ userId: users.sarah?.id, userName: 'Sarah Chen', action: 'CREATE', entity: 'Batch', entityId: Object.values(batches)[0]?.id, entityName: 'Created batch: Gorilla Glue #4 - B001' },
{ userId: users.mike?.id, userName: 'Mike Thompson', action: 'UPDATE', entity: 'Task', entityName: 'Updated task status to completed', changes: { status: { from: 'PENDING', to: 'COMPLETED' } } },
{ userId: users.sarah?.id, userName: 'Sarah Chen', action: 'CREATE', entity: 'Document', entityName: 'Added SOP: Daily Walkthrough Protocol' },
{ userId: users.admin?.id, userName: 'Admin User', action: 'UPDATE', entity: 'Room', entityName: 'Updated Flower Room A climate settings', changes: { targetTemp: { from: 72, to: 75 } } },
{ userId: users.alex?.id, userName: 'Alex Rivera', action: 'ACCESS', entity: 'Report', entityName: 'Accessed Weekly Production Report' },
{ userId: users.sarah?.id, userName: 'Sarah Chen', action: 'APPROVE', entity: 'TimeLog', entityName: 'Approved overtime for Mike Thompson' },
{ userId: users.mike?.id, userName: 'Mike Thompson', action: 'UPDATE', entity: 'Batch', entityId: Object.values(batches)[1]?.id, entityName: 'Moved batch B002 to Vegetative stage', changes: { stage: { from: 'CLONE_IN', to: 'VEGETATIVE' } } },
{ userId: users.jordan?.id, userName: 'Jordan Lee', action: 'CREATE', entity: 'TouchPoint', entityName: 'Logged watering for batch B003' },
{ userId: users.admin?.id, userName: 'Admin User', action: 'EXPORT', entity: 'Report', entityName: 'Exported compliance report to PDF' },
{ userId: users.sarah?.id, userName: 'Sarah Chen', action: 'CREATE', entity: 'Visitor', entityName: 'Registered visitor: State Inspector' },
{ userId: users.mike?.id, userName: 'Mike Thompson', action: 'UPDATE', entity: 'Plant', entityName: 'Updated plant health status', changes: { healthStatus: { from: 'GOOD', to: 'NEEDS_ATTENTION' } } },
{ userId: users.sam?.id, userName: 'Sam Martinez', action: 'CREATE', entity: 'SupplyItem', entityName: 'Added new supply: Pyganic 5.0' },
{ userId: users.sarah?.id, userName: 'Sarah Chen', action: 'DELETE', entity: 'Announcement', entityName: 'Removed expired announcement' },
{ userId: users.admin?.id, userName: 'Admin User', action: 'UPDATE', entity: 'Role', entityName: 'Updated permissions for Grower role' },
];
for (let i = 0; i < auditEntries.length; i++) {
const entry = auditEntries[i];
const timestamp = daysAgo(i % 14);
timestamp.setHours(8 + Math.floor(Math.random() * 10), Math.floor(Math.random() * 60));
await prisma.auditLog.create({
data: {
...entry,
changes: entry.changes ? JSON.stringify(entry.changes) : null,
metadata: null,
timestamp
}
});
}
console.log(`${auditEntries.length} audit log entries`);
console.log('\n✨ Demo seeding complete!');
console.log('\nDemo Logins:');
console.log(' Owner: admin@runfoo.run / password123');

168
docs/SPEC-KIT-AUDIT.md Normal file
View file

@ -0,0 +1,168 @@
# CA Grow Ops Manager - Spec Kit Compliance Audit
**Audit Date:** December 12, 2025
**Auditor:** AI Assistant
**App Version:** Latest (main branch)
---
## Executive Summary
This audit reviews the CA Grow Ops Manager against the defined specification documents to assess feature completeness, demo functionality, and documentation coverage.
---
## Spec Coverage Matrix
### Core Specifications (`/specs/`)
| Spec File | Status | Frontend | Backend | Demo Data | Notes |
|-----------|--------|----------|---------|-----------|-------|
| `daily-walkthrough.md` | ✅ Complete | ✅ | ✅ | ✅ 30 days | Now shows "completed" status |
| `batches-and-rooms.md` | ✅ Complete | ✅ | ✅ | ✅ 7 batches, 8 rooms | |
| `plant-touch-points-ipm.md` | ✅ Complete | ✅ | ✅ | ✅ IPM schedules | |
| `facility-3d-viewer.md` | 🔲 Spec Only | 🔲 | ✅ Data seeded | ✅ 21 sections, 648 positions | React Three Fiber installed |
| `visitor-management.md` | ✅ Complete | ✅ | ✅ | 🔲 Minimal | Kiosk + management pages |
| `compliance-and-docs.md` | ⚠️ Partial | ⚠️ | ⚠️ | ⚠️ | SOP/Audit need demo data |
| `tasks-and-scheduling.md` | ✅ Complete | ✅ | ✅ | ✅ 7 tasks | |
| `labor-and-hours.md` | ✅ Complete | ✅ | ✅ | ✅ 14 days | Timeclock page |
| `inventory-and-materials.md` | ✅ Complete | ✅ | ✅ | ✅ 12 items | Supplies page |
| `photo-management.md` | ⚠️ Partial | ✅ Upload UI | ✅ | 🔲 | Photo compression, no demo photos |
| `metrc-integration.md` | ⚠️ Spec Only | 🔲 | 🔲 | 🔲 | Placeholder for future |
| `paperless-integration.md` | 🔲 Spec Only | 🔲 | 🔲 | 🔲 | Future integration |
| `hardware-integration.md` | 🔲 Spec Only | 🔲 | 🔲 | 🔲 | Sensors, etc. |
| `communications-and-notifications.md` | ⚠️ Partial | ✅ Announcements | 🔲 | ✅ 3 announcements | No push/email |
| `integrations-and-hardware.md` | 🔲 Spec Only | 🔲 | 🔲 | 🔲 | |
| `advanced-features.md` | ⚠️ Partial | ✅ Dashboards | ✅ | 🔲 | Env/Finance/Insights mock |
| `audit-and-documents.md` | ⚠️ Partial | ✅ Pages | ⚠️ | ⚠️ | Need more demo data |
| `messaging.md` | 🔲 Not Started | 🔲 | 🔲 | 🔲 | |
| `accessibility-i18n.md` | ⚠️ Partial | ✅ i18n setup | N/A | N/A | Skip link, basic a11y |
| `grow-room-heatmap.md` | ✅ Complete | ✅ | Mock | 🔲 | Visual component done |
---
## Documentation Status (`/docs/`)
| Document | Purpose | Status |
|----------|---------|--------|
| `architecture.md` | System architecture | ✅ Up to date |
| `ROADMAP.md` | Feature roadmap | ⚠️ Needs update |
| `openapi.yaml` | API documentation | ⚠️ Partial |
| `DESIGN-SYSTEM-LINEAR.md` | UI/UX guidelines | ✅ Complete |
| `compliance-notes-ca.md` | CA regulations | ✅ Reference |
| Phase plans (`PHASE-*.md`) | Sprint planning | ✅ Historical |
| Session summaries | Work tracking | ✅ Maintained |
---
## Critical Items Needing Attention
### 1. SOP Library (`/compliance/documents`)
**Issue:** Page exists but demo data may not fully demonstrate functionality
**Action Required:**
- [ ] Verify SOPs display correctly
- [ ] Add more diverse document types
- [ ] Test document viewing
### 2. Audit Log (`/compliance/audit`)
**Issue:** Page exists but may need more demo entries
**Action Required:**
- [ ] Verify audit entries display
- [ ] Add sample entries for various action types
- [ ] Test filtering/search
### 3. 3D Facility Viewer
**Issue:** Spec created, data seeded, but no 3D visualization component yet
**Action Required:**
- [x] Spec document created
- [x] Install React Three Fiber
- [x] Seed facility positions (648 positions)
- [ ] Build Facility3DViewer component
- [ ] Integrate with layout API
### 4. Layout Designer
**Issue:** Complex drag-drop tool has API issues, consider simplifying
**Action Required:**
- [x] Fixed double /api prefix
- [ ] Consider replacing with simpler dimension-input form
- [ ] Focus on 3D viewer vs. designer
---
## Demo Data Summary
```
✅ Seeded Demo Data:
├── 5 Users (admin, manager, growers, workers)
├── 8 Rooms (Veg, Flower, Dry, Cure, Mother)
├── 7 Batches (various stages: clone, veg, flower, dry, cure)
├── ~292 Touch Points (50/batch average)
├── 30 Days Walkthrough History
├── 9 SOP Documents
├── 12 Supply Items
├── 7 Tasks
├── IPM Schedules (per active batch)
├── Weight Logs (for dried batches)
├── 3 Announcements
├── 14 Days Time Punch History
└── Facility Structure:
├── 1 Property (777 Wolfpack Cultivation)
├── 2 Buildings
├── 3 Floors
├── 8 Facility Rooms
├── 21 Sections (tables/racks)
└── 648 Plant Positions
```
---
## Recommendations
### Immediate (This Session)
1. ✅ ~~Walkthrough "completed today" indicator~~
2. ⚠️ Verify SOP Library displaying seeded data
3. ⚠️ Verify Audit Log displaying entries
4. 🔲 Start basic 3D Viewer component
### Short-term
1. Add more Audit Log demo entries
2. Complete 3D Facility Viewer
3. Update ROADMAP.md
4. Expand OpenAPI documentation
### Medium-term
1. METRC integration (Phase 2)
2. Paperless-ngx integration
3. Push notifications
4. Hardware sensor integration
---
## Compliance Score
| Category | Score | Max |
|----------|-------|-----|
| Core Operations | 18 | 20 |
| Compliance Features | 6 | 10 |
| Visualization | 4 | 10 |
| Integrations | 2 | 10 |
| Documentation | 8 | 10 |
| Demo Data | 9 | 10 |
| **Total** | **47** | **70** |
**Overall Compliance: 67%** - Good foundation, key features complete, visualization/integrations pending.
---
*Last Updated: December 12, 2025*