Feature Specification: Audit & Compliance
1. Overview & Vision
Audit & Compliance is the platform's immutable memory. It captures all security-sensitive events and administrative changes across the entire platform, providing a tamper-proof trail for compliance auditing, troubleshooting, and forensics.
2. Personas & Stakeholders
| Persona | Goal |
|---|---|
| Security Officer | Review access patterns and investigate security incidents. |
| Org Admin | Audit changes made by other admins (e.g., member removal). |
| System Admin | Monitor platform-wide configuration changes and health. |
3. User Stories
- As a security officer, I want to see every IP address that attempted to log in as an Admin last night.
- As an admin, I want to know who deleted a mission-critical project folder.
4. Functional Requirements (FR)
- REQ-AUD-001: Centralized logging of all "Write" and "Delete" operations.
- REQ-AUD-002: Capturing of actor metadata (User ID, IP, User-Agent).
- REQ-AUD-003: In-app audit log viewer with advanced filtering.
- REQ-AUD-004: Data export (CSV/JSON) for external compliance reports.
5. Non-Functional Requirements (NFR)
- Immutability: Audit records MUST NOT be deletable or modifiable, even by admins.
- Persistence: 1-year default retention for all audit data.
- Performance: Logging overhead must be < 5ms per operation.
6. Business Logic & Rules
- Event Schema: Every event includes
timestamp,actor,action,resource,status, andpayload_diff. - Severity Levels: INFO (Config change), WARNING (Failed login), CRITICAL (Permission escalation).
- Auto-archiving: Logs older than 365 days are moved to cold storage (S3).
7. User Interface (UI/UX)
- "Audit Trail" table with chronological sorting.
- Detail view for individual events showing "Before" vs "After" snapshots.
- Quick filters for "Critical Only" and specific modules.
8. Information Architecture
- Located under "Organization Settings -> Security" in the Shell.
- Platform-wide logs accessible via the System Admin portal.
9. Data Model & Persistence
- Table:
audit_log(Optimized for append-only performance). - Storage: PostgreSQL for active logs; S3 for archives.
10. API & Service Layer
GET /api/admin/auditPOST /internal/audit-event(S2S only)
11. Integration Patterns
- Logging Middleware: Automatically captures controller actions in the backend.
- Cross-Service Bus: Satellite apps send events to the Shell Audit Service via Connect/gRPC.
12. Security & Permissions
- Only
Security OfficerorOwnerroles can view audit logs. - Audit service itself runs in a strictly isolated security context.
13. Error Handling & Resilience
- Fail-safe: If the audit service is down, mission-critical write operations MUST fail (Zero-trust).
- Buffer: Local in-memory buffer for high-frequency logs.
14. Performance & Scalability
- Optimized indexing on
timestampandorganization_id. - Support for millions of events per organization.
15. Globalization & i18n
- Event descriptions are standardized and localized.
16. Accessibility (a11y)
- High-contrast log viewer for better readability.
17. Observability & Analytics
- Anomaly detection (e.g., "Sudden spike in failed logins").
- Top actors and most modified resources analytics.
18. Testing & Quality
- Integration tests ensuring that
DELETEoperations are always logged. - Penetration testing to verify log immutability.
19. Constraints & Assumptions
- Assumes satellite apps implement the audit middleware or explicitly call the audit API.
20. Future Enhancements
- Real-time SIEM integration (e.g., Splunk, Datadog).
- Webhook alerts for critical security events.