Confidentiality Declaration Repository
Component Detail
Description
Data access layer for confidentiality declaration records, including acknowledgement state and storage references. Maintains a declarations table with status, read timestamps, and Supabase Storage object references.
declaration-repository
Summaries
This component is the system of record for every confidentiality declaration issued to drivers, capturing the full lifecycle from creation through acknowledgement. Accurate declaration tracking directly supports compliance verification—organizations can demonstrate precisely when each driver received and acknowledged their declaration, providing defensible evidence in audits or disputes. The storage of read timestamps creates a granular activity trail that strengthens due diligence posture. By maintaining status transitions and Supabase Storage references in a single repository, the platform eliminates fragmented record-keeping that increases compliance risk.
Medium-complexity data component managing a declaration lifecycle with four status states (draft, sent, read, acknowledged) and seven query interfaces. The status transition logic must be enforced at the repository level to prevent invalid state changes, adding validation complexity. A key delivery dependency is the Supabase Storage integration for object references—the storage bucket naming and access policy must be agreed upon before this repository can be fully implemented. Testing must cover status transition enforcement, acknowledgement timestamp immutability (cannot be overwritten), and the findPendingAcknowledgement query performance at scale.
Schema must be coordinated with the declaration encryption service for encrypted blob references. Estimate 3–5 days.
Backend data access layer for confidentiality_declaration and declaration_acknowledgement data models, with interfaces for insert, status update, acknowledgement recording, and four read patterns. The updateDeclarationStatus method should validate allowed state transitions (e.g., draft→sent, sent→read, read→acknowledged) and reject invalid transitions with a typed error to prevent data corruption. recordAcknowledgement should be idempotent—re-acknowledging the same declaration should not overwrite the original timestamp. Storage references (Supabase Storage object paths) should be stored as a structured field supporting versioned or rotated encrypted blobs.
The findPendingAcknowledgement query is high-frequency; index the declarations table on (org_id, status) for performance. Ensure RLS policies scope all queries to the authenticated org context.
Responsibilities
- Insert and update declaration records with storage references
- Track status transitions (draft, sent, read, acknowledged)
- Store acknowledgement timestamp and driver ID
- Query declarations by driver, assignment, or status
Interfaces
insertDeclaration(declaration)
updateDeclarationStatus(id, status, timestamp)
recordAcknowledgement(id, driverId, timestamp)
findByAssignment(assignmentId)
findByDriver(driverId)
findPendingAcknowledgement(orgId)
findById(id)
Relationships
Dependents (2)
Components that depend on this component
Related Data Entities (2)
Data entities managed by this component