Files
poimen-memory/crates/mem-core/Cargo.toml
T
Story Crater Bot 0d836c4ec1
Build and Push / Test (push) Failing after 1m55s
Build and Push / Build and push image (push) Skipped
feat: M3.8 pluggable optimizer service (DRY + SOLID, 13 tests)
Refactored M3.8 to be extensible and customizable:

SOLID Architecture:
- Single Responsibility: OptimizerPlugin (optimize), FormatHandler (format)
- Open/Closed: Registry trait for extensibility without modification
- Liskov Substitution: Generic SimpleRegistry<T> works for any plugin type
- Interface Segregation: Traits focused, minimal methods
- Dependency Inversion: OptimizerService depends on abstractions

DRY Improvements:
- Generic Registry<T> trait eliminates duplicate register/get/list code
- PluginLocator strategy pattern replaces duplicated lookup logic
- OptimizerServiceBuilder factory pattern for ergonomic creation

Features:
✓ OptimizerPlugin trait (async optimization with metrics)
✓ FormatHandler trait (json, jsonl, raw, csv, yaml)
✓ Registry<T> generic trait (reusable for any plugin type)
✓ PluginLocator strategy (find optimizer by type, format by name)
✓ OptimizerService (orchestrator + dependency injection)
✓ OptimizerServiceBuilder (fluent builder)
✓ BuiltinOptimizer (wraps ContextOptimizer)
✓ 5 format handlers (JSON, JSONL, Raw, CSV, YAML)

Tests (13 passing):
- Registry registration and lookup
- Type-based optimizer finding
- Format handler discovery
- Service creation via builder
- Service optimization workflow
- Error handling on missing formats

Build:  mem-core clean (130 tests total)

Usage:
  let service = OptimizerServiceBuilder::new()
      .with_optimizer(Arc::new(MyOptimizer))
      .with_format(Arc::new(JsonFormatter))
      .build()?;

  let output = service.optimize(content, "text/plain", Some("json")).await?;

Ready for:
- Custom optimizer implementations
- Custom format handlers
- Query optimization (next commit)
- Ingest pipeline integration (next commit)
2026-08-28 12:13:14 -07:00

26 lines
640 B
TOML

[package]
name = "mem-core"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
tokio = { workspace = true }
futures = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_yaml = { workspace = true }
anyhow = { workspace = true }
thiserror = { workspace = true }
sha2 = { workspace = true }
tracing = { workspace = true }
hex = "0.4"
time = { version = "0.3", features = ["serde", "formatting", "parsing", "macros"] }
magika = "1.1.0"
ort = { version = "2.0.0-rc.12", default-features = true }
regex = "1.10"
once_cell = "1.19"
indexmap = "2.0"
lazy_static = "1.4"
async-trait = "0.1.92"