Technical doc 32.16.1.13. Engine in
@kuanyin/dharma-analytics/privacy-protection.ts; user-facing controls inuser-autonomy.ts.
Privacy is engineered in, not bolted on. The core principle: analyse the minimum, retain less, and keep the user in control.
Data minimisation at the source#
- Typing dynamics —
analyzeTypingOnDevicereduces raw keystrokes to aggregate features on-device; raw timings are discarded and never leave the client. - Content analysis —
analyzeEphemeralContentworks over a SHA-256 fingerprint with no retention of the original text. - Aggregates —
aggregatePatternsWithKAnonymityenforces a k-anonymity floor;laplaceNoisyCountadds calibrated differential-privacy noise before any pattern count is exposed. enforceDataMinimizationstrips fields not justified by the stated purpose.
Consent#
manageConsent({ subjectId, purpose, action, now, ttlMs? }) is a state machine
with expiry; getConsentStatus resolves the effective state
(granted | withdrawn | expired | never_set). Predictive features and learning
are opt-in and honour withdrawal immediately (user-autonomy.ts).
Data subject rights (GDPR)#
- Art. 20 export —
exportUserData(subjectId, categories, now)returns a bundle with a record count and integrity checksum. - Art. 17 erasure —
processRightToDeletion(records)deletes everything except legal-hold records, reporting what was retained and why (fullyErased: falsewhen a hold applies). - Retention —
applyRetentionPolicyflags records past their window for deletion.
Pseudonymisation & audit#
pseudonymizeIdentifiers/hmacPseudonymreplace identifiers with HMAC-SHA-256 pseudonyms;anonymizeDatasetgeneralises quasi-identifiers.- Every data access is appended to a tamper-evident hash chain
(
auditDataAccess);verifyAuditChain()detects any break.
Encryption & breach response#
assessEncryptionAtRest / assessEncryptionInTransit validate NIST-aligned
policy; the module includes a GDPR 72-hour breach-response planner.
User controls#
user-autonomy.ts exposes opt-out for predictive features, friction-skip
preservation (with a no-shadow-penalty guarantee), appeal rights, human-review
requests, notification/data-sharing/learning/recommendation/visibility controls,
account portability, and complete account deletion. These map to the user-facing
"Privacy controls guide" (../user/07-privacy-controls.md).