Skip to content

Add GitHub update checker subsystem with hot-reload and YAML/JSON configuration - #37

Merged
makr-code merged 12 commits into
mainfrom
copilot/add-themisdb-update-checker
Nov 22, 2025
Merged

makr-code merged 12 commits into
mainfrom
copilot/add-themisdb-update-checker

Conversation

Copilot AI commented Nov 22, 2025 •

Copy link
Copy Markdown
Contributor

Implements a DLL subsystem that periodically polls GitHub Releases API for ThemisDB updates, exposes status via HTTP endpoints for admin tools, and provides complete hot-reload capability with automatic backups and rollback support. Includes comprehensive YAML/JSON configuration for update behavior, auto-update policies, and scheduling.

Core Components

Update Checker

UpdateChecker (utils/update_checker.h/cpp)

  • Background thread polls GitHub Releases API at configurable intervals (default 1h)
  • Semantic versioning parser with full semver support (major.minor.patch[-prerelease][+build])
  • Critical update detection via keyword analysis (security, CVE, vulnerability, etc.)
  • Thread-safe with mutex-protected state and atomic running flag
  • Graceful degradation when CURL unavailable

UpdateApiHandler (server/update_api_handler.h/cpp)

  • GET /api/updates - Current status
  • POST /api/updates/check - Manual trigger
  • GET /api/updates/config - Read configuration
  • PUT /api/updates/config - Update configuration (requires admin auth)

Integration (server/http_server.h/cpp)

  • Feature flag: config.feature_update_checker
  • Version string from CMake: THEMIS_VERSION_STRING="${PROJECT_VERSION}"
  • Environment overrides: THEMIS_GITHUB_API_TOKEN, THEMIS_UPDATE_CHECK_INTERVAL

Configuration System (New)

UpdatesConfig (updates/updates_config.h/cpp)

  • Complete YAML/JSON configuration support via config/updates.yaml
  • Update checker settings (check interval, GitHub repository, API token)
  • Auto-update policies (enable/disable, critical only, require approval)
  • Scheduled updates (specific time and days of week)
  • Hot-reload settings (directories, signature verification, rollback points)
  • Notification settings (webhook, email, event filtering)

Configuration Example:

updates:
  checker:
    enabled: true
    check_interval_seconds: 3600
  
  auto_update:
    enabled: false
    critical_only: true
    require_approval: true
    scheduled: false
    schedule_time: "02:00"
    schedule_days: [Sunday]
  
  hot_reload:
    enabled: true
    verify_signatures: true
    create_backup: true
    keep_rollback_points: 3

Hot-Reload System

ReleaseManifest (updates/release_manifest.h/cpp)

  • Complete manifest data structure with file list, hashes, and signatures
  • JSON serialization/deserialization
  • Manifest hash calculation for integrity verification

ManifestDatabase (updates/manifest_database.h/cpp)

  • RocksDB-backed storage with 4 column families
  • Manifest versioning and file registry
  • Signature verification caching
  • Download cache management

HotReloadEngine (updates/hot_reload_engine.h/cpp)

  • Download releases from GitHub with CURL
  • Verify file hashes (SHA-256) and signatures (CMS/PKCS#7)
  • Atomic file replacement
  • Automatic backup before updates
  • Rollback capability on failure
  • Progress reporting and callbacks
  • Rollback point management

HotReloadApiHandler (server/hot_reload_api_handler.h/cpp)

  • GET /api/updates/manifests/:version - Get manifest details
  • POST /api/updates/download/:version - Download release files
  • POST /api/updates/apply/:version - Apply hot-reload (requires admin auth)
  • POST /api/updates/rollback/:id - Rollback to previous version (requires admin auth)
  • GET /api/updates/rollback - List available rollback points

Usage Examples

Update Checker

// Server config
HttpServer::Config config;
config.feature_update_checker = true;

// API query
curl http://localhost:8765/api/updates
{
  "status": "critical_update",
  "current_version": "1.0.0",
  "latest_release": {
    "version": "1.2.0",
    "tag_name": "v1.2.0",
    "name": "Security Update"
  }
}

Hot-Reload Workflow

# 1. Check for updates
curl http://localhost:8765/api/updates

# 2. Download release
curl -X POST http://localhost:8765/api/updates/download/1.2.0

# 3. Verify (dry-run)
curl -X POST http://localhost:8765/api/updates/apply/1.2.0 \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -d '{"verify_only": true}'

# 4. Apply update
curl -X POST http://localhost:8765/api/updates/apply/1.2.0 \
  -H "Authorization: Bearer $ADMIN_TOKEN"

# 5. Rollback if needed
curl -X POST http://localhost:8765/api/updates/rollback/rollback_xyz \
  -H "Authorization: Bearer $ADMIN_TOKEN"

Security - Manifest-based Binary Authenticity

Purpose: Signed manifests ensure binaries come from ThemisDB team and haven't been tampered with.

How it works:

  1. Build process generates SHA-256 hashes for all release files
  2. Manifest containing hashes is signed with private key (CMS/PKCS#7)
  3. Users download manifest and verify signature with public certificate
  4. Each file is verified against manifest hash before installation

Protection against:

  • ✅ Compromised GitHub accounts
  • ✅ Man-in-the-Middle attacks
  • ✅ Tampered downloads
  • ✅ CDN compromise

No encryption needed: As an open-source project, manifests are public and transparent. Security comes from cryptographic signatures proving authenticity, not from hiding information.

Reuses existing security primitives:

  • PluginSecurityVerifier - SHA-256 hashing + CMS signature verification
  • CMSSigningService - PKCS#7 signatures with OpenSSL
  • PluginManifest - JSON metadata with signature support

All files verified with:

  • SHA-256 hash comparison
  • CMS/PKCS#7 signature verification
  • File size validation
  • Manifest hash integrity check

Protected endpoints require admin authentication.

Testing

Unit tests cover version parsing/comparison, critical detection, config serialization. Test file added to CMakeLists.txt.

Documentation

  • docs/UPDATE_CHECKER.md - API reference, configuration
  • docs/KONZEPT_UPDATE_CHECKER.md - Architecture (German)
  • docs/SECURITY_SUMMARY_UPDATE_CHECKER.md - Security analysis
  • docs/KONZEPT_RELEASE_MANIFEST_SERVICE.md - Hot-reload design (German)
  • docs/HOT_RELOAD_API.md - Hot-reload API reference with examples
  • docs/MANIFEST_SECURITY_PRINCIPLE.md - Core security principle: binary authenticity
  • docs/OPEN_SOURCE_SECURITY_BEST_PRACTICE.md - Best practices for open source
  • docs/MANIFEST_ENCRYPTION_ANALYSIS.md - Why no encryption is needed
  • config/updates.yaml - Example YAML configuration
  • examples/hot_reload_example.cpp - Usage examples
Original prompt

Erstelle eine zusätzliche DLL Subsystem welches regelmäßig prüft ob auf github updates der ThemisDB vorliegen. Diese meldungen sollen über den HTTP-Server verfügbar sein, z.B. für ein Admin-tool. GGf sollen automatisiert updates und hot-reaload für kritische patches möglich sein. Erarbeite ein Konzept und beachte OOP und best-practice.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Nov 22, 2025
Copilot AI changed the title [WIP] Add subsystem to check for ThemisDB updates Add GitHub update checker subsystem with manifest service concept for hot-reload Nov 22, 2025
Copilot AI requested a review from makr-code November 22, 2025 11:09
@makr-code

Copy link
Copy Markdown
Owner

@copilot Okay setzten wir das Konzept um.

Copilot AI and others added 2 commits November 22, 2025 11:19
- Add ReleaseManifest and ReleaseFile data structures with JSON serialization
- Implement ManifestDatabase with RocksDB backend for manifest storage
- Implement HotReloadEngine with download, verify, apply, and rollback functionality
- Add HotReloadApiHandler with REST endpoints for hot-reload operations
- Support atomic file replacement and automatic backup/rollback
- Integrate with existing PluginSecurityVerifier for signature verification

Co-authored-by: makr-code <[email protected]>

Copilot AI commented Nov 22, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Okay setzten wir das Konzept um.

Das Konzept ist umgesetzt! ✅

Implementiert in Commit 8daa084 und 987dce3:

Kernkomponenten:

  • ReleaseManifest - Manifest-Datenstruktur mit JSON-Serialisierung
  • ManifestDatabase - RocksDB-Backend mit 4 Column Families
  • HotReloadEngine - Download, Verify, Apply, Rollback-Funktionalität
  • HotReloadApiHandler - 5 neue REST-Endpoints

Neue API-Endpoints:

  • GET /api/updates/manifests/:version - Manifest abrufen
  • POST /api/updates/download/:version - Release herunterladen
  • POST /api/updates/apply/:version - Hot-Reload anwenden (Admin)
  • POST /api/updates/rollback/:id - Rollback durchführen
  • GET /api/updates/rollback - Rollback-Punkte auflisten

Features:
✅ Nutzt existierende PluginSecurityVerifier
✅ SHA-256 + CMS-Signaturen
✅ Atomare Updates mit automatischem Backup
✅ Rollback bei Fehler
✅ CURL-basierte Downloads
✅ Progress Callbacks

Vollständige Dokumentation in docs/HOT_RELOAD_API.md und Beispielcode in examples/hot_reload_example.cpp.

Copilot AI changed the title Add GitHub update checker subsystem with manifest service concept for hot-reload Add GitHub update checker subsystem with hot-reload implementation Nov 22, 2025
@makr-code

Copy link
Copy Markdown
Owner

@copilot Die Konfiguration soll über ein yaml / json erfolgen. Darin soll festgelegt werden ob kritische update / upgrades sofort durchgeführt werden, wann und wie oft nach updates geschaut werden soll usw.

… source

- Add UpdatesConfig with YAML/JSON support for all update settings
- Create config/updates.yaml example configuration
- Critical updates can be auto-applied or require approval
- Scheduled updates support (time and days)
- Document best practices: signature-based security, no encryption
- Remove manifest encryption (unnecessary for open source)
- Focus on transparency and industry standards

Co-authored-by: makr-code <[email protected]>

Copilot AI commented Nov 22, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Die Konfiguration soll über ein yaml / json erfolgen. Darin soll festgelegt werden ob kritische update / upgrades sofort durchgeführt werden, wann und wie oft nach updates geschaut werden s...

YAML/JSON Konfiguration implementiert in Commit 325ad89:

Neue Konfigurationsdatei: config/updates.yaml

Einstellbare Parameter:

  • ✅ Update-Prüfung: Intervall (check_interval_seconds)
  • ✅ Auto-Update: An/Aus, nur kritische Updates
  • ✅ Approval: Manuell oder automatisch nach Timeout
  • ✅ Zeitplanung: Spezifische Uhrzeit und Wochentage
  • ✅ Benachrichtigungen: Webhook/Email bei Events

Beispiel:

updates:
  auto_update:
    enabled: false
    critical_only: true
    require_approval: true
    scheduled: true
    schedule_time: "02:00"
    schedule_days: [Sunday]

Vollständige Dokumentation in config/updates.yaml.

Document the core purpose of the manifest system: ensuring binary authenticity
- Explain how signed manifests prove binaries come from ThemisDB team
- Detail protection against compromised GitHub, MITM, tampered downloads
- Show verification workflow with signature and hash checks
- Provide attack scenarios and how manifest protects
- Industry standard approach (Kubernetes, Docker, APT)

Co-authored-by: makr-code <[email protected]>
Copilot AI changed the title Add GitHub update checker subsystem with hot-reload implementation Add GitHub update checker subsystem with hot-reload and YAML/JSON configuration Nov 22, 2025
@makr-code
makr-code marked this pull request as ready for review November 22, 2025 11:50
@makr-code
makr-code merged commit eadd8c9 into main Nov 22, 2025
@makr-code
makr-code deleted the copilot/add-themisdb-update-checker branch November 30, 2025 11:49
makr-code added a commit that referenced this pull request Dec 6, 2025
…cker

Add GitHub update checker subsystem with hot-reload and YAML/JSON configuration
Copilot AI added a commit that referenced this pull request Jan 17, 2026
Issue #37: Gradient Checkpointing (P2) - 50-80% memory reduction
Issue #38: Fused LoRA Kernels (P1) - 2-3x speedup via kernel fusion
Issue #39: Dynamic Batching (P2) - 30-50% throughput improvement
Issue #40: FlashAttention-style LoRA (P1) - 2-4x speedup + 4-8x longer sequences

All templates include:
- Research paper citations (FlashAttention, S-LoRA, Punica, etc.)
- Detailed CUDA/HIP kernel implementations
- Memory bandwidth analysis
- Performance benchmarks and targets
- Integration strategies

Co-authored-by: makr-code <[email protected]>
makr-code added a commit that referenced this pull request Jan 17, 2026
…based optimizations (#596)

* Initial plan

* Add GPU-accelerated training infrastructure

- Created gpu_data_loader.h/cpp for GPU-optimized data loading
- Created gpu_training_loop.h/cpp for GPU training loop
- Integrated GPU training into trainWithQuantization()
- Replaced CPU synthetic tensors with GPU tensors
- Added VRAMAllocator integration for memory management
- Added mixed precision trainer support
- Added multi-GPU layer support hooks

Co-authored-by: makr-code <[email protected]>

* Add GPU training loop tests and CMake integration

- Updated CMakeLists.txt to build gpu_data_loader and gpu_training_loop
- Created comprehensive test suite for GPU training loop
- Tests cover GPU data loading, LoRA layer creation, training loop
- Tests include CPU fallback validation
- Tests validate memory tracking and batch processing

Co-authored-by: makr-code <[email protected]>

* Address code review feedback and add documentation

- Removed duplicate source file entries in CMakeLists.txt
- Added detailed TODO comments for placeholder implementations
- Documented limitations of hash-based embeddings
- Documented CPU-based loss/gradient computation bottlenecks
- Documented mixed precision gradient unscaling limitation
- Added implementation documentation (GPU_TRAINING_IMPLEMENTATION.md)
- All placeholders clearly marked for future GPU kernel implementation

Co-authored-by: makr-code <[email protected]>

* Add comprehensive code review for LoRA training network

- Complete architecture and design review
- Implementation quality assessment
- Performance analysis with bottleneck identification
- Thread safety and memory safety evaluation
- Testing coverage analysis
- Detailed recommendations for production readiness
- Overall rating: GOOD (8/10) - APPROVED for merge

Co-authored-by: makr-code <[email protected]>

* Add GitHub issue templates for GPU training improvements

- Issue #34: GPU Real Embeddings - Replace hash-based with base model lookup
- Issue #35: GPU Loss/Gradient Kernels - Eliminate CPU↔GPU transfers
- Issue #36: GPU Mixed Precision Unscaling - Add GPU tensor support for FP16

All templates follow existing format with detailed implementation plans,
code examples, acceptance criteria, and effort estimations.

Co-authored-by: makr-code <[email protected]>

* Add advanced optimization issue templates based on research

Issue #37: Gradient Checkpointing (P2) - 50-80% memory reduction
Issue #38: Fused LoRA Kernels (P1) - 2-3x speedup via kernel fusion
Issue #39: Dynamic Batching (P2) - 30-50% throughput improvement
Issue #40: FlashAttention-style LoRA (P1) - 2-4x speedup + 4-8x longer sequences

All templates include:
- Research paper citations (FlashAttention, S-LoRA, Punica, etc.)
- Detailed CUDA/HIP kernel implementations
- Memory bandwidth analysis
- Performance benchmarks and targets
- Integration strategies

Co-authored-by: makr-code <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: makr-code <[email protected]>
@makr-code makr-code added this to the v1.0.2 milestone Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants