This commit adds the read path (Cortex) to complement the write path (Spine): ## Crates - stemedb-api: HTTP API with axum + utoipa OpenAPI - /v1/assert, /v1/query, /v1/epoch, /v1/skeptic, /v1/trace, /v1/audit - Metered endpoints with quota enforcement - Ed25519 signature verification - stemedb-lens: Truth resolution lenses - RecencyLens, ConsensusLens, ConfidenceLens - VoteAwareConsensusLens (Ballot Box pattern) - TrustAwareAuthorityLens (The Hive pattern) - SkepticLens (conflict analysis) - EpochAwareLens (paradigm-safe queries) - stemedb-query: Query engine with materialized views ## Storage Extensions - VoteStore: Vote aggregation with cached counts - TrustRankStore: Agent reputation with decay - AuditStore: Query audit trail - IndexStore: SP/P/S index structures - SupersessionStore: Epoch supersession chains ## SDKs - sdk/go/steme: Go HTTP client with Ed25519 signing - sdk/go/adk: ADK-Go tools for AI agents ## Documentation - Updated CLAUDE.md, architecture.md, roadmap.md - New ai-lookup entries for all services - Use case docs for consumer health intelligence - Arena roadmap for simulation advancement Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
73 lines
2.7 KiB
Markdown
73 lines
2.7 KiB
Markdown
# storage-serde-dedup
|
|
|
|
## COMPLETE (2026-02-01)
|
|
|
|
**Before:** 12 instances of duplicated serialization helpers
|
|
**After:** 0 instances - all use centralized `crate::serde_helpers`
|
|
|
|
**Enforcement:** Added to `.claude/skills/stemedb-core/SKILL.md`:
|
|
- Do: "In stemedb-storage: Use crate::serde_helpers::{serialize, deserialize}"
|
|
- Do Not: "Call stemedb_core::serde::serialize or deserialize directly"
|
|
|
|
**Documentation:** Updated `ai-lookup/services/storage.md`:
|
|
- Added storage-layer serialization section
|
|
- Added serde_helpers.rs to file pointers
|
|
|
|
---
|
|
|
|
## FIX Progress (2026-02-01)
|
|
|
|
- [x] CREATE serde_helpers.rs with generic serialize/deserialize functions
|
|
- [x] FIX vote_store.rs - replaced serialize_vote/deserialize_vote
|
|
- [x] FIX index_store.rs - replaced serialize_hash_list/deserialize_hash_list
|
|
- [x] FIX trust_rank_store.rs - replaced serialize_trust_rank/deserialize_trust_rank
|
|
- [x] FIX audit_store.rs - replaced serialize_audit/deserialize_audit
|
|
- [x] FIX trust_pack_store.rs - replaced serialize_pack/deserialize_pack
|
|
- [x] FIX quota_store.rs - replaced serialize_record/deserialize_record
|
|
- [x] Removed unused StorageError imports from 3 files
|
|
- [x] All 64 stemedb-storage tests pass
|
|
- [x] All workspace tests pass (225+ tests)
|
|
- [x] Clippy passes with zero warnings
|
|
|
|
## AUDIT (2026-02-01)
|
|
|
|
Pattern: Every storage module duplicates serialize_X/deserialize_X helper functions that wrap stemedb_core::serde with StorageError mapping.
|
|
|
|
```rust
|
|
// DUPLICATED 12 times (6 serialize + 6 deserialize)
|
|
fn serialize_X(data: &X) -> Result<Vec<u8>> {
|
|
stemedb_core::serde::serialize(data)
|
|
.map_err(|e| StorageError::Serialization(e.to_string()))
|
|
}
|
|
|
|
fn deserialize_X(data: &[u8]) -> Result<X> {
|
|
stemedb_core::serde::deserialize(data)
|
|
.map_err(|e| StorageError::Serialization(e.to_string()))
|
|
}
|
|
```
|
|
|
|
Found: **12 instances** in **6 files**
|
|
|
|
| File | Line | Function |
|
|
|------|------|----------|
|
|
| vote_store.rs | 150 | serialize_vote |
|
|
| vote_store.rs | 155 | deserialize_vote |
|
|
| index_store.rs | 128 | serialize_hash_list |
|
|
| index_store.rs | 134 | deserialize_hash_list |
|
|
| trust_rank_store.rs | 248 | serialize_trust_rank |
|
|
| trust_rank_store.rs | 254 | deserialize_trust_rank |
|
|
| audit_store.rs | 153 | serialize_audit |
|
|
| audit_store.rs | 159 | deserialize_audit |
|
|
| trust_pack_store.rs | 138 | serialize_pack |
|
|
| trust_pack_store.rs | 143 | deserialize_pack |
|
|
| quota_store.rs | 291 | serialize_record |
|
|
| quota_store.rs | 297 | deserialize_record |
|
|
|
|
## Plan
|
|
|
|
1. CREATE: Add `stemedb-storage/src/serde_helpers.rs` with generic serialize/deserialize
|
|
2. FIX: Replace all 12 type-specific functions with calls to the generic helpers
|
|
3. VERIFY: grep returns 0 for old pattern
|
|
4. ENFORCE: Add rule to skill or guideline
|
|
5. DOCUMENT: Update ai-lookup/services/storage.md
|