Federated Learning Homomorphic
Skill Profile
(Select at least one profile to enable specific modules)
Overview
This skill covers the implementation of privacy-preserving machine learning techniques that enable training models on distributed, sensitive data without exposing raw data. It includes Federated Learning for distributed training, Homomorphic Encryption for computation on encrypted data, and Secure Multi-Party Computation (SMPC) for collaborative computation.
Why This Matters
- Data Privacy: Enables ML on sensitive data without privacy violations
- Regulatory Compliance: Meets GDPR, HIPAA, and other data protection regulations
- Collaborative Learning: Multiple organizations can collaborate without sharing data
Core Concepts & Rules
1. Core Principles
- Follow established patterns and conventions
- Maintain consistency across codebase
- Document decisions and trade-offs
2. Implementation Guidelines
- Start with the simplest viable solution
- Iterate based on feedback and requirements
- Test thoroughly before deployment
Inputs / Outputs / Contracts
- Inputs:
- Local datasets on client devices (never transmitted to server)
- Model architecture and hyperparameters
- Privacy budget parameters (epsilon, delta)
- Client selection criteria and participation requirements
- Entry Conditions:
- TensorFlow Federated or PySyft installed
- HE library (SEAL/TenSEAL) configured
- Client devices with local data available
- Secure communication channels established (TLS 1.3)
- Outputs:
- Trained global model
- Client participation metrics and contribution tracking
- Privacy loss accounting reports
- Model performance evaluation on test data
- Artifacts Required (Deliverables):
- Federated training configuration
- Client-side training scripts
- Server aggregation logic
- Privacy audit reports
- Acceptance Evidence:
- Model achieves target accuracy without exposing raw data
- Privacy budget not exceeded
- Client contributions properly tracked
- Communication overhead within acceptable limits
- Success Criteria:
- Model accuracy within 5% of centralized training baseline
- Privacy budget epsilon < 1.0 for DP-SGD
- Communication overhead < 10x centralized training
- Training completes within 2x centralized training time
Skill Composition
Quick Start / Implementation Example
- Review requirements and constraints
- Set up development environment
- Implement core functionality following patterns
- Write tests for critical paths
- Run tests and fix issues
- Document any deviations or decisions
# Example implementation following best practices
def example_function():
# Your implementation here
pass
Assumptions / Constraints / Non-goals
- Assumptions:
- Development environment is properly configured
- Required dependencies are available
- Team has basic understanding of domain
- Constraints:
- Must follow existing codebase conventions
- Time and resource limitations
- Compatibility requirements
- Non-goals:
- This skill does not cover edge cases outside scope
- Not a replacement for formal training
Compatibility & Prerequisites
- Supported Versions:
- Python 3.8+
- Node.js 16+
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Required AI Tools:
- Code editor (VS Code recommended)
- Testing framework appropriate for language
- Version control (Git)
- Dependencies:
- Language-specific package manager
- Build tools
- Testing libraries
- Environment Setup:
.env.example keys: API_KEY, DATABASE_URL (no values)
Test Scenario Matrix (QA Strategy)
| Type |
Focus Area |
Required Scenarios / Mocks |
| Unit |
Core Logic |
Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |
| Integration |
DB / API |
All external API calls or database connections must be mocked during unit tests |
| E2E |
User Journey |
Critical user flows to test |
| Performance |
Latency / Load |
Benchmark requirements |
| Security |
Vuln / Auth |
SAST/DAST or dependency audit |
| Frontend |
UX / A11y |
Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |
Technical Guardrails & Security Threat Model
1. Security & Privacy (Threat Model)
- Top Threats: Injection attacks, authentication bypass, data exposure
2. Performance & Resources
3. Architecture & Scalability
4. Observability & Reliability
Agent Directives & Error Recovery
(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)
- Thinking Process: Analyze root cause before fixing. Do not brute-force.
- Fallback Strategy: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
- Self-Review: Check against Guardrails & Anti-patterns before finalizing.
- Output Constraints: Output ONLY the modified code block. Do not explain unless asked.
Definition of Done (DoD) Checklist
Anti-patterns / Pitfalls
- ⛔ Don't: Log PII, catch-all exception, N+1 queries
- ⚠️ Watch out for: Common symptoms and quick fixes
- 💡 Instead: Use proper error handling, pagination, and logging
Reference Links & Examples
- Internal documentation and examples
- Official documentation and best practices
- Community resources and discussions
Versioning & Changelog
- Version: 1.0.0
- Changelog:
- 2026-02-22: Initial version with complete template structure
Source: AmnadTaowsoam/CerebraSkills — distributed by TomeVault.
1---2name: federated-learning-homomorphic3description: This skill covers the implementation of privacy-preserving machine learning Use when this capability is needed.4---56# Federated Learning Homomorphic78## Skill Profile9*(Select at least one profile to enable specific modules)*10- [ ] **DevOps**11- [x] **Backend**12- [ ] **Frontend**13- [ ] **AI-RAG**14- [ ] **Security Critical**1516## Overview17This skill covers the implementation of privacy-preserving machine learning techniques that enable training models on distributed, sensitive data without exposing raw data. It includes Federated Learning for distributed training, Homomorphic Encryption for computation on encrypted data, and Secure Multi-Party Computation (SMPC) for collaborative computation.1819## Why This Matters20- **Data Privacy**: Enables ML on sensitive data without privacy violations21- **Regulatory Compliance**: Meets GDPR, HIPAA, and other data protection regulations22- **Collaborative Learning**: Multiple organizations can collaborate without sharing data2324---2526## Core Concepts & Rules2728### 1. Core Principles29- Follow established patterns and conventions30- Maintain consistency across codebase31- Document decisions and trade-offs3233### 2. Implementation Guidelines34- Start with the simplest viable solution35- Iterate based on feedback and requirements36- Test thoroughly before deployment373839## Inputs / Outputs / Contracts40* **Inputs**:41 - Local datasets on client devices (never transmitted to server)42 - Model architecture and hyperparameters43 - Privacy budget parameters (epsilon, delta)44 - Client selection criteria and participation requirements45* **Entry Conditions**:46 - TensorFlow Federated or PySyft installed47 - HE library (SEAL/TenSEAL) configured48 - Client devices with local data available49 - Secure communication channels established (TLS 1.3)50* **Outputs**:51 - Trained global model52 - Client participation metrics and contribution tracking53 - Privacy loss accounting reports54 - Model performance evaluation on test data55* **Artifacts Required (Deliverables)**:56 - Federated training configuration57 - Client-side training scripts58 - Server aggregation logic59 - Privacy audit reports60* **Acceptance Evidence**:61 - Model achieves target accuracy without exposing raw data62 - Privacy budget not exceeded63 - Client contributions properly tracked64 - Communication overhead within acceptable limits65* **Success Criteria**:66 - Model accuracy within 5% of centralized training baseline67 - Privacy budget epsilon < 1.0 for DP-SGD68 - Communication overhead < 10x centralized training69 - Training completes within 2x centralized training time7071## Skill Composition72* **Depends on**: [model-serving-inference](../../78-inference-model-serving/high-performance-inference/SKILL.md), [mlflow-patterns](../../77-mlops-data-engineering/mlflow-patterns/SKILL.md)73* **Compatible with**: [drift-detection-retraining](../../77-mlops-data-engineering/drift-detection-retraining/SKILL.md), [pii-policy-enforcement](../../70-data-platform-governance/pii-policy-enforcement/SKILL.md)74* **Conflicts with**: None75* **Related Skills**: [llm-security-redteaming](../../61-ai-production/llm-security-redteaming/SKILL.md)7677---7879## Quick Start / Implementation Example80811. Review requirements and constraints822. Set up development environment833. Implement core functionality following patterns844. Write tests for critical paths855. Run tests and fix issues866. Document any deviations or decisions8788```python89# Example implementation following best practices90def example_function():91 # Your implementation here92 pass93```949596## Assumptions / Constraints / Non-goals9798* **Assumptions**:99 - Development environment is properly configured100 - Required dependencies are available101 - Team has basic understanding of domain102* **Constraints**:103 - Must follow existing codebase conventions104 - Time and resource limitations105 - Compatibility requirements106* **Non-goals**:107 - This skill does not cover edge cases outside scope108 - Not a replacement for formal training109110111## Compatibility & Prerequisites112113* **Supported Versions**:114 - Python 3.8+115 - Node.js 16+116 - Modern browsers (Chrome, Firefox, Safari, Edge)117* **Required AI Tools**:118 - Code editor (VS Code recommended)119 - Testing framework appropriate for language120 - Version control (Git)121* **Dependencies**:122 - Language-specific package manager123 - Build tools124 - Testing libraries125* **Environment Setup**:126 - `.env.example` keys: `API_KEY`, `DATABASE_URL` (no values)127128129## Test Scenario Matrix (QA Strategy)130131| Type | Focus Area | Required Scenarios / Mocks |132| :--- | :--- | :--- |133| **Unit** | Core Logic | Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |134| **Integration** | DB / API | All external API calls or database connections must be mocked during unit tests |135| **E2E** | User Journey | Critical user flows to test |136| **Performance** | Latency / Load | Benchmark requirements |137| **Security** | Vuln / Auth | SAST/DAST or dependency audit |138| **Frontend** | UX / A11y | Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |139140141## Technical Guardrails & Security Threat Model142143### 1. Security & Privacy (Threat Model)144* **Top Threats**: Injection attacks, authentication bypass, data exposure145- [ ] **Data Handling**: Sanitize all user inputs to prevent Injection attacks. Never log raw PII146- [ ] **Secrets Management**: No hardcoded API keys. Use Env Vars/Secrets Manager147- [ ] **Authorization**: Validate user permissions before state changes148149### 2. Performance & Resources150- [ ] **Execution Efficiency**: Consider time complexity for algorithms151- [ ] **Memory Management**: Use streams/pagination for large data152- [ ] **Resource Cleanup**: Close DB connections/file handlers in finally blocks153154### 3. Architecture & Scalability155- [ ] **Design Pattern**: Follow SOLID principles, use Dependency Injection156- [ ] **Modularity**: Decouple logic from UI/Frameworks157158### 4. Observability & Reliability159- [ ] **Logging Standards**: Structured JSON, include trace IDs `request_id`160- [ ] **Metrics**: Track `error_rate`, `latency`, `queue_depth`161- [ ] **Error Handling**: Standardized error codes, no bare except162- [ ] **Observability Artifacts**:163 - **Log Fields**: timestamp, level, message, request_id164 - **Metrics**: request_count, error_count, response_time165 - **Dashboards/Alerts**: High Error Rate > 5%166167168## Agent Directives & Error Recovery169*(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)*170171- **Thinking Process**: Analyze root cause before fixing. Do not brute-force.172- **Fallback Strategy**: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.173- **Self-Review**: Check against Guardrails & Anti-patterns before finalizing.174- **Output Constraints**: Output ONLY the modified code block. Do not explain unless asked.175176177## Definition of Done (DoD) Checklist178179- [ ] Tests passed + coverage met180- [ ] Lint/Typecheck passed181- [ ] Logging/Metrics/Trace implemented182- [ ] Security checks passed183- [ ] Documentation/Changelog updated184- [ ] Accessibility/Performance requirements met (if frontend)185186187## Anti-patterns / Pitfalls188189* ⛔ **Don't**: Log PII, catch-all exception, N+1 queries190* ⚠️ **Watch out for**: Common symptoms and quick fixes191* 💡 **Instead**: Use proper error handling, pagination, and logging192193194## Reference Links & Examples195196* Internal documentation and examples197* Official documentation and best practices198* Community resources and discussions199200201## Versioning & Changelog202203* **Version**: 1.0.0204* **Changelog**:205 - 2026-02-22: Initial version with complete template structure206207---208> Source: [AmnadTaowsoam/CerebraSkills](https://github.com/AmnadTaowsoam/CerebraSkills) — distributed by [TomeVault](https://tomevault.io).209<!-- tomevault:4.0:skill_md:2026-05-22 -->