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>
2.1 KiB
2.1 KiB
serialization-duplication
AUDIT (2026-01-31)
Pattern: Duplicated rkyv serialization/deserialization boilerplate across crates
// ANTI-PATTERN: This 4-line pattern appears 7 times
let mut serializer = AllocSerializer::<4096>::default();
serializer.serialize_value(&value).map_err(...)?;
let bytes = serializer.into_serializer().into_inner();
Found: 7 production instances in 4 files
| File | Line | Function | Type |
|---|---|---|---|
| stemedb-ingest/src/worker.rs | 61 | serialize_assertion | Serialize |
| stemedb-ingest/src/worker.rs | 75 | serialize_vote | Serialize |
| stemedb-ingest/src/worker.rs | 88 | serialize_epoch | Serialize |
| stemedb-storage/src/vote_store.rs | 155 | serialize_vote | Serialize |
| stemedb-storage/src/vote_store.rs | 162 | deserialize_vote | Deserialize |
| stemedb-query/src/engine.rs | 140 | deserialize_assertion | Deserialize |
| stemedb-lens/src/vote_aware_consensus.rs | 100 | compute_assertion_hash | Serialize |
Excluded (test code):
- stemedb-core/src/lib.rs (all in #[cfg(test)])
- stemedb-query/src/engine.rs:184 (test helper)
- stemedb-sim/src/main.rs (demo binary)
Plan
- CREATE: Add
stemedb-core/src/serde.rswith generic serialize/deserialize helpers - FIX: Replace all 7 instances with calls to the new helpers
- VERIFY: grep returns 0 for raw AllocSerializer usage outside tests
- ENFORCE: Add CLAUDE.md rule prohibiting direct AllocSerializer usage
- DOCUMENT: Update ai-lookup with the canonical pattern
FIX Progress
- CREATE utility module -
stemedb-core/src/serde.rswithserialize<T>()anddeserialize<T>() - stemedb-ingest/src/worker.rs <- CURRENT
- stemedb-storage/src/vote_store.rs
- stemedb-query/src/engine.rs
- stemedb-lens/src/vote_aware_consensus.rs
CREATE (2026-01-31)
Created crates/stemedb-core/src/serde.rs:
serialize<T>(value: &T) -> Result<Vec<u8>, SerdeError>- Generic serializationdeserialize<T>(data: &[u8]) -> Result<T, SerdeError>- Generic deserializationSerdeErrorenum for error handling- 5 unit tests + 2 doc tests passing