From 8b2c55c6375edbd002999437e7d41043d98e9112 Mon Sep 17 00:00:00 2001 From: fullsizemalt <106900403+fullsizemalt@users.noreply.github.com> Date: Fri, 12 Dec 2025 22:21:11 -0800 Subject: [PATCH] feat: add audit log demo data + spec kit compliance audit - Added 15 audit log entries demonstrating various actions - Created SPEC-KIT-AUDIT.md documenting feature completeness - Actions: LOGIN, CREATE, UPDATE, DELETE, ACCESS, EXPORT, APPROVE --- backend/prisma/seed-demo.js | 36 ++++++++ docs/SPEC-KIT-AUDIT.md | 168 ++++++++++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 docs/SPEC-KIT-AUDIT.md diff --git a/backend/prisma/seed-demo.js b/backend/prisma/seed-demo.js index 067d28d..5ecf9c2 100644 --- a/backend/prisma/seed-demo.js +++ b/backend/prisma/seed-demo.js @@ -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'); diff --git a/docs/SPEC-KIT-AUDIT.md b/docs/SPEC-KIT-AUDIT.md new file mode 100644 index 0000000..15b4c44 --- /dev/null +++ b/docs/SPEC-KIT-AUDIT.md @@ -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*