Skip to content

refactor(ledger): split sqlite_store.rs into sub-modules #376

@fagemx

Description

@fagemx

Problem

edda-ledger/src/sqlite_store.rs is 7,003 lines with 11 distinct concerns in a single impl SqliteStore block. It is the second largest file and a frequent churn hotspot.

Mixed concerns: connection/schema management, 13 migration functions, device tokens, suggestions, event persistence, references, decision queries, village/pattern detection, bundles, dependencies, causal chain/outcomes, task briefs.

Evidence of Feasibility

device_token.rs was already extracted from this file — the pattern works. The split should continue.

Proposed Structure

src/
├── sqlite_store.rs     (~500 lines: SqliteStore struct, open/create, pragmas)
├── schema/
│   ├── mod.rs          (schema constants)
│   └── migrations.rs   (~600 lines: v1_to_v2 through v11_to_v12)
├── persistence/
│   ├── events.rs       (~460 lines: append, iter, queries)
│   └── snapshots.rs    (~125 lines)
├── entities/
│   ├── suggestions.rs  (~100 lines)
│   ├── bundles.rs      (~115 lines)
│   └── briefs.rs       (~125 lines)
├── decisions/
│   ├── queries.rs      (~220 lines)
│   ├── dependencies.rs (~125 lines)
│   └── outcomes.rs     (~320 lines)
└── analytics/
    └── village.rs      (~315 lines: stats, pattern detection)

Notes

  • Pure refactor — no behavior change
  • Tests (~3,400 lines) should be split to match
  • device_token.rs extraction is the template to follow

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