RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /OpenCLaw: Building a Personal AI Agent
  6. /Ch. 19
OpenCLaw: Building a Personal AI Agent

19. Privacy by Design

Chapter 19 of 24 · 20 min
KEY INSIGHT

Privacy by design requires technical enforcement, not just policy documentation. Automated retention enforcement, purpose tagging, and user-facing controls provide enforceable privacy guarantees rather than theoretical commitments.

Personal AI agents process sensitive user data. OpenCLaw implements privacy by design principles: data minimization, purpose limitation, and user control.

Data Minimization

OpenCLaw collects only data necessary for its functions. Conversation history retention follows configurable policies with automatic expiration.

# privacy.py
from dataclasses import dataclass
from datetime import datetime, timedelta
from typing import Optional

@dataclass
class RetentionPolicy:
    conversation_days: int = 90
    feedback_days: int = 180
    logs_days: int = 30
    anonymize_after: int = 365

class DataMinimizer:
    def __init__(self, policy: RetentionPolicy, storage):
        self.policy = policy
        self.storage = storage
    
    def apply_retention(self) -> int:
        deleted_count = 0
        
        cutoff = datetime.utcnow() - timedelta(days=self.policy.conversation_days)
        deleted = self.storage.delete_old_conversations(cutoff)
        deleted_count += deleted
        
        cutoff = datetime.utcnow() - timedelta(days=self.policy.feedback_days)
        deleted = self.storage.delete_old_feedback(cutoff)
        deleted_count += deleted
        
        return deleted_count
    
    def anonymize(self, user_id: str) -> None:
        self.storage.remove_identifying_info(user_id)
        self.storage.update_user_id(user_id, f"anon_{hash(user_id)}")

Purpose Limitation

Data collected for one purpose should not be used for another without consent. OpenCLaw tags data with purpose metadata and enforces usage restrictions.

class PurposeTracker:
    PURPOSES = ['core_functionality', 'improvement', 'analytics', 'sharing']
    
    def __init__(self, storage):
        self.storage = storage
    
    def tag_data(self, data_id: str, purpose: str):
        self.storage.set_purpose(data_id, purpose)
    
    def can_use_for(self, data_id: str, requested_purpose: str) -> bool:
        original_purpose = self.storage.get_purpose(data_id)
        
        if original_purpose == 'core_functionality':
            return True
        if original_purpose == requested_purpose:
            return True
        
        return False

User Control Interface

Users must have visibility into and control over their data. OpenCLaw provides a privacy dashboard showing data collection, retention, and export options.

class PrivacyDashboard:
    def __init__(self, storage, minimizer: DataMinimizer):
        self.storage = storage
        self.minimizer = minimizer
    
    def get_data_summary(self, user_id: str) -> dict:
        return {
            'conversation_count': self.storage.count_conversations(user_id),
            'oldest_conversation': self.storage.get_oldest_conversation(user_id),
            'feedback_entries': self.storage.count_feedback(user_id),
            'estimated_storage_mb': self.storage.estimate_size(user_id) / (1024*1024)
        }
    
    def export_data(self, user_id: str, format: str) -> str:
        if format == 'json':
            return self.storage.export_json(user_id)
        elif format == 'csv':
            return self.storage.export_csv(user_id)
    
    def delete_all_user_data(self, user_id: str) -> bool:
        self.storage.purge_user(user_id)
        return True
EXERCISE

Design a data portability system that exports all user data in standard formats. Include conversation history, learned preferences, and configuration settings. Implement the export functionality.

← Chapter 18
Security Model
Chapter 20 →
Performance Optimization