SochDB Kernel
The minimal ACID core of SochDB with a plugin architecture.
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Extension Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ LSCS Plugin │ │Vector Plugin│ │ Observability Plugin│ │
│ └──────┬──────┘ └──────┬──────┘ └──────────┬──────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Plugin Manager (Registry) │ │
│ └─────────────────────────┬───────────────────────────┘ │
└────────────────────────────┼────────────────────────────────┘
│
┌────────────────────────────┼────────────────────────────────┐
│ ▼ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Kernel API (Traits) │ │
│ │ KernelStorage, KernelTransaction, KernelCatalog │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
│ │ WAL │ │ MVCC │ │ Pager │ │ Catalog │ │
│ │ Recovery │ │ Txn │ │ Buffer │ │ Schema │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────────┘ │
│ │
│ KERNEL (~5K LOC) │
│ Auditable • Stable API • ACID │
└─────────────────────────────────────────────────────────────┘
Design Principles
- Minimal Core: Only ACID-critical code in kernel (<5K LOC)
- Plugin Everything: Storage backends, indices, observability are plugins
- No Dependency Bloat: Core has minimal deps, plugins bring their own
- Stable API: Kernel API is versioned, plugins can evolve independently
- Auditable: Small enough for formal verification
Plugin Categories
| Category | Trait | Purpose |
|---|---|---|
| Storage | StorageExtension |
Alternative storage backends (LSCS, RocksDB, etc.) |
| Index | IndexExtension |
Custom index types (vector, learned, full-text) |
| Observability | ObservabilityExtension |
Metrics, tracing, logging backends |
| Compression | CompressionExtension |
Compression algorithms |
Why Plugin Architecture for Observability?
Problems with Baked-In Monitoring:
- Dependency Bloat: Forces every user to pull in Prometheus, Grafana, etc. even if they use DataDog, CloudWatch, or nothing
- Version Conflicts: User's app might need different Prometheus client version
- Deployment Flexibility: Embedded use cases (mobile, WASM) don't need monitoring
- Vendor Lock-in: Forces specific monitoring stack on users
- Binary Size: Adds MBs to binary for features most users don't need
Plugin Architecture Benefits:
Core SochDB: 5 MB binary ← Everyone downloads this
+ prometheus-plugin: +500 KB ← Only if you want Prometheus
+ datadog-plugin: +300 KB ← Or DataDog
+ opentelemetry-plugin: +400 KB ← Or OpenTelemetry
+ logging-plugin-json: +50 KB ← Structured logging
+ logging-plugin-logfmt: +50 KB ← Or logfmt style
Usage
Basic Kernel Usage
use ;
// Create kernel components
let wal = open?;
let txn_mgr = new;
let plugins = new;
// Begin a transaction
let txn_id = txn_mgr.begin;
// Log operations
wal.log_begin?;
wal.log_update?;
// Commit
txn_mgr.commit?;
wal.log_commit?;
Adding Observability Plugin
use ;
use Arc;
// Define a custom observability plugin
// Register the plugin
let plugins = new;
plugins.register_observability?;
// Kernel will now emit metrics to all registered observability plugins
plugins.counter_inc;
Null Observability (Default)
When no observability plugin is registered, the kernel uses NullObservability which has zero overhead:
let plugins = new;
assert!; // No observability configured
// These calls are no-ops with zero overhead
plugins.counter_inc;
plugins.gauge_set;
Kernel API Stability
The kernel API follows semantic versioning:
- 1.x.x: No breaking changes to trait signatures
- 2.0.0: May introduce breaking changes with migration guide
Core traits that are stable:
KernelStorageKernelTransactionKernelCatalogKernelRecoveryExtensionand sub-traits
Code Budget
To ensure auditability, the kernel maintains a strict code budget:
| Component | Target LOC |
|---|---|
| WAL | ~1,000 |
| Transaction | ~800 |
| Page Manager | ~1,000 |
| Catalog | ~500 |
| Plugin System | ~700 |
| Error Handling | ~500 |
| Total | ~5,000 |
License
Apache-2.0 OR MIT