Skip to content

refactor(ledger): wrap sqlite_store types in domain abstractions #378

@fagemx

Description

@fagemx

Problem

`edda-ledger/src/lib.rs` re-exports 12 types directly from `sqlite_store`:

```rust
pub use sqlite_store::{
BundleRow, ChainEntry, DecideSnapshotRow, DecisionRow,
DepRow, DetectedPattern, DeviceTokenRow, ImportParams,
PatternDetectionResult, PatternType, SuggestionRow, TaskBriefRow,
};
```

These are SQL row structs, not domain concepts. Downstream crates like `edda-ask` import `DecisionRow` directly:

```rust
// edda-ask/src/lib.rs:2
use edda_ledger::sqlite_store::DecisionRow;
```

This couples the query engine to the SQLite storage implementation. If the storage backend changes, the blast radius is large.

Proposed Fix

  1. Create domain-level types (or use existing `DecisionView`) as the public API
  2. Mark `sqlite_store` types as `pub(crate)` where possible
  3. Update `edda-ask` and `edda-serve` to use domain types instead of row types
  4. Keep `sqlite_store` module public only for types that are genuinely domain concepts (`PatternType`)

Impact

  • `edda-ask` — uses `DecisionRow` (1 import)
  • `edda-serve` — uses several re-exported types
  • Other crates — use `Ledger` methods that return these types

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorCode refactoring

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions