The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(cost): simplify storage schema definition
Steven Enamakelb8abe750555a
diff --git a/crates/openhuman-core/src/platform/cost/storage_schema.rs b/crates/openhuman-core/src/platform/cost/storage_schema.rsindex 136d1de0ea..fb1995aeeb 100644--- a/crates/openhuman-core/src/platform/cost/storage_schema.rs+++ b/crates/openhuman-core/src/platform/cost/storage_schema.rs@@ -6,22 +6,14 @@//! | `cost_records` (`usage.timestamp` RFC 3339 beside `ts_ms`) | `cost.records` | `usage.timestamp` dropped; `ts_ms` is the instant |use serde_json::Value;-use tinystoragedrivers::schema::{Schema, ScopeClass, SourceRecord, Step, TargetRecord};-use tinystoragedrivers::{CollectionSpec, IndexSpec, Result};+use tinystoragedrivers::{CollectionSpec, IndexSpec};use super::types::CostRecord;-use crate::storage::schema_support::{key_of, owner, rfc3339_ms};pub(super) const RECORDS: &str = "cost.records";-pub(super) const LEGACY_RECORDS: &str = "cost_records";-const SCHEMA: u32 = 2;--/// What the cost ledger keeps and the step from the v1 collection.-#[must_use]-pub fn storage_schema() -> Schema {- Schema::new(owner("cost"))- .collection_with(SCHEMA, spec(), ScopeClass::Tenant)- .step(Step::new("records_v2", RECORDS, 1, SCHEMA, records_v2).source(LEGACY_RECORDS))+/// Collections owned by the cost ledger.+pub(crate) fn collection_specs() -> Vec<CollectionSpec> {+ vec![spec()]}pub(super) fn spec() -> CollectionSpec {@@ -57,29 +49,6 @@ pub(super) fn from_body(mut doc: Value) -> anyhow::Result<CostRecord> {Ok(serde_json::from_value(doc)?)}-fn records_v2(batch: Vec<SourceRecord>) -> Result<Vec<TargetRecord>> {- batch- .into_iter()- .map(|record| {- let mut body = record.body;- let stamped = body- .pointer("/usage/timestamp")- .and_then(Value::as_str)- .and_then(rfc3339_ms);- let ts_ms = body- .get("ts_ms")- .and_then(Value::as_i64)- .or(stamped)- .unwrap_or(record.meta.created_ms);- if let Some(usage) = body.get_mut("usage").and_then(Value::as_object_mut) {- usage.remove("timestamp");- }- body["ts_ms"] = ts_ms.into();- Ok(TargetRecord::new(RECORDS, key_of(&record.id)?, body).created_ms(ts_ms))- })- .collect()-}-#[cfg(test)]#[path = "storage_schema_tests.rs"]mod tests;