Audience
- System Administrators: Use the API endpoints described below to manage compliance tasks.
- Developers: Integrate these features into your applications using the QWED Python SDK.
1. SOC 2 preparation
QWED provides built-in tools to assist with SOC 2 Type II audits, specifically focusing on Security, Availability, and Processing Integrity.SOC 2 report generator
Generate a JSON report containing security metrics, control statuses, and evidence summaries. API Endpoint:Audit trail verification
Verify the cryptographic integrity of your audit logs. This ensures that no logs have been tampered with since creation. Per-entry verification covers three checks:hash_valid: the entry’s SHA-256 hash matches a recomputation of its canonical payload. For backwards compatibility, entries hashed beforeraw_llm_outputwas covered are also accepted against the legacy canonical form.signature_valid: the entry’s HMAC-SHA256 signature is constant-time-equal to the expected signature.chain_valid: the entry’sprevious_hashcorrectly references the prior entry’s hash within the same organization. Genesis entries (the first entry for an organization) must have anullprevious_hash; non-genesis entries must reference a non-empty prior hash.
Audit chains are isolated per organization. Hash linkage is verified only against prior entries belonging to the same
organization_id, so cross-tenant activity cannot affect another organization’s chain validity.result payload cannot be decoded as JSON, verify_log_entry fails closed with a SecurityError rather than reporting the entry as valid.
Verify a Single Log Entry:
AuditLogger() requires QWED_AUDIT_SECRET_KEY to be set in the environment, or the constructor must receive an explicit secret_key argument. Initialization fails closed otherwise.Evidence collection
Export all verification logs and security events as a CSV file to provide to your auditor. API Endpoint:2. GDPR compliance
Data export (Article 15 - right of access)
QWED supports the Right of Access by allowing you to export all data associated with an organization or user. API Endpoint: Use the CSV export endpoint to retrieve all verification data.Data deletion (Article 17 - right to erasure)
Note: Currently, user deletion must be performed by an administrator directly in the database. A self-service deletion API is planned. To comply with a deletion request:- Delete the User: Remove the user record from the database.
- Prune Logs: For full GDPR Article 17 compliance, ensure all verification logs associated with the user are also deleted or anonymized.
Consent management
QWED does not have a built-in “Consent Management Platform” (CMP), but you can use the immutable audit log to track consent events. Implementing Consent Tracking: Log a specific “verification” event when a user grants consent. This creates a tamper-proof record.3. Audit trail setup
Enable cryptographic logging
Cryptographic logging is enabled by default, but you must configure the signing key before the audit logger will start. The audit logger fails closed when the signing key is missing or when chain continuity cannot be established.-
Set the signing key:
Set
QWED_AUDIT_SECRET_KEYto a secure, random string (at least 32 characters). The audit logger raises aSecurityErrorand refuses to initialize if this variable is not set. - Secure storage: Store the key in a secrets manager (for example, AWS Secrets Manager or HashiCorp Vault) and inject it into the application environment.
- Rotation: Rotating the signing key invalidates the HMAC signatures on existing entries. Verify and archive the existing trail before rotating, then start a new trail with the new key.
Chain continuity across restarts
On startup,AuditLogger loads the most recent persisted entry hash and uses it as the new chain head. New entries are bound to the persisted hash rather than a fresh in-memory root, so restarts do not produce a discontinuous trail.
If the in-memory chain head and the persisted chain head disagree at write time, log_verification raises a SecurityError instead of writing a misleading entry. Treat this as a tampering or replication-lag signal and investigate before restarting writes.
Per-organization chain isolation
Each organization has its own append-only hash chain. When verifying or appending entries, the logger:- Locks the chain head per organization to prevent concurrent appends from forking the chain.
- Re-verifies the persisted chain head before appending a new entry and refuses to append if the head fails integrity checks.
- Accepts both the current canonical payload (which covers
raw_llm_output) and the legacy payload during verification, so historical entries written before that field was hashed remain verifiable. - Fails closed if a stored
resultpayload is malformed JSON or if a chain entry is missing itsentry_hash.
Verify log integrity
Regularly run the verification process (see “Audit trail verification” above) to detect database tampering. Verification now flags:- A genesis entry that references a non-null
previous_hash. - A previous entry that is missing its hash.
- A
previous_hashthat does not match the prior entry’s hash. - An entry whose recomputed hash or HMAC signature does not match the stored value.
Long-term storage
QWED uses the configured database (SQLite/PostgreSQL) for log storage. For high-volume compliance requirements:- Configure database backups to a WORM (Write Once, Read Many) compatible storage (e.g., AWS S3 Object Lock) for archival.
4. Compliance checklist
Use this checklist to prepare for an enterprise audit.- Audit Logs Verified: Run
verify_audit_trailon all historical logs. - API Keys Rotated: Rotate any API keys older than 90 days.
- SOC 2 Report Generated: Generate and review the latest SOC 2 report via API.
- Secret Key Secured: Confirm
QWED_AUDIT_SECRET_KEYis set to a production-grade value and stored in a secrets manager. - GDPR Export Tested: Verify that data export works for a sample organization.
- Security Events Reviewed: Check the “Security Events” section of the SOC 2 report for any anomalies.
- Rate Limiting Active: Confirm rate limits are enforced to prevent abuse (DoS protection).