mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
style(memory): cargo fmt on source_tree module (#709)
CI rustfmt caught a few multi-line function signatures and import groups that rustfmt wants collapsed / reordered. No behaviour change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
8e55ddd71e
commit
b7395a85c6
@@ -25,7 +25,7 @@ use crate::openhuman::config::Config;
|
|||||||
use crate::openhuman::memory::tree::source_tree::registry::new_summary_id;
|
use crate::openhuman::memory::tree::source_tree::registry::new_summary_id;
|
||||||
use crate::openhuman::memory::tree::source_tree::store;
|
use crate::openhuman::memory::tree::source_tree::store;
|
||||||
use crate::openhuman::memory::tree::source_tree::summariser::{
|
use crate::openhuman::memory::tree::source_tree::summariser::{
|
||||||
SummaryContext, SummaryInput, Summariser,
|
Summariser, SummaryContext, SummaryInput,
|
||||||
};
|
};
|
||||||
use crate::openhuman::memory::tree::source_tree::types::{
|
use crate::openhuman::memory::tree::source_tree::types::{
|
||||||
Buffer, SummaryNode, Tree, TreeKind, TOKEN_BUDGET,
|
Buffer, SummaryNode, Tree, TreeKind, TOKEN_BUDGET,
|
||||||
@@ -333,11 +333,7 @@ fn refresh_last_sealed_tx(
|
|||||||
/// Fetch contributions for `item_ids`. At level 0 we pull from
|
/// Fetch contributions for `item_ids`. At level 0 we pull from
|
||||||
/// `mem_tree_chunks` + `mem_tree_score`; at ≥1 we pull from
|
/// `mem_tree_chunks` + `mem_tree_score`; at ≥1 we pull from
|
||||||
/// `mem_tree_summaries`.
|
/// `mem_tree_summaries`.
|
||||||
fn hydrate_inputs(
|
fn hydrate_inputs(config: &Config, level: u32, item_ids: &[String]) -> Result<Vec<SummaryInput>> {
|
||||||
config: &Config,
|
|
||||||
level: u32,
|
|
||||||
item_ids: &[String],
|
|
||||||
) -> Result<Vec<SummaryInput>> {
|
|
||||||
if level == 0 {
|
if level == 0 {
|
||||||
hydrate_leaf_inputs(config, item_ids)
|
hydrate_leaf_inputs(config, item_ids)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -87,9 +87,7 @@ mod tests {
|
|||||||
use crate::openhuman::memory::tree::source_tree::registry::get_or_create_source_tree;
|
use crate::openhuman::memory::tree::source_tree::registry::get_or_create_source_tree;
|
||||||
use crate::openhuman::memory::tree::source_tree::summariser::inert::InertSummariser;
|
use crate::openhuman::memory::tree::source_tree::summariser::inert::InertSummariser;
|
||||||
use crate::openhuman::memory::tree::store::upsert_chunks;
|
use crate::openhuman::memory::tree::store::upsert_chunks;
|
||||||
use crate::openhuman::memory::tree::types::{
|
use crate::openhuman::memory::tree::types::{chunk_id, Chunk, Metadata, SourceKind, SourceRef};
|
||||||
chunk_id, Chunk, Metadata, SourceKind, SourceRef,
|
|
||||||
};
|
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
|
|
||||||
fn test_config() -> (TempDir, Config) {
|
fn test_config() -> (TempDir, Config) {
|
||||||
|
|||||||
@@ -60,11 +60,7 @@ pub(crate) fn insert_tree_conn(conn: &Connection, tree: &Tree) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Fetch a tree by `(kind, scope)`. Returns `None` if no such tree exists.
|
/// Fetch a tree by `(kind, scope)`. Returns `None` if no such tree exists.
|
||||||
pub fn get_tree_by_scope(
|
pub fn get_tree_by_scope(config: &Config, kind: TreeKind, scope: &str) -> Result<Option<Tree>> {
|
||||||
config: &Config,
|
|
||||||
kind: TreeKind,
|
|
||||||
scope: &str,
|
|
||||||
) -> Result<Option<Tree>> {
|
|
||||||
with_connection(config, |conn| get_tree_by_scope_conn(conn, kind, scope))
|
with_connection(config, |conn| get_tree_by_scope_conn(conn, kind, scope))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,12 +110,7 @@ pub(crate) fn update_tree_after_seal_tx(
|
|||||||
max_level = ?2,
|
max_level = ?2,
|
||||||
last_sealed_at_ms = ?3
|
last_sealed_at_ms = ?3
|
||||||
WHERE id = ?4",
|
WHERE id = ?4",
|
||||||
params![
|
params![root_id, max_level, sealed_at.timestamp_millis(), tree_id,],
|
||||||
root_id,
|
|
||||||
max_level,
|
|
||||||
sealed_at.timestamp_millis(),
|
|
||||||
tree_id,
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
.with_context(|| format!("Failed to update tree {tree_id} after seal"))?;
|
.with_context(|| format!("Failed to update tree {tree_id} after seal"))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -306,11 +297,7 @@ pub fn get_buffer(config: &Config, tree_id: &str, level: u32) -> Result<Buffer>
|
|||||||
with_connection(config, |conn| get_buffer_conn(conn, tree_id, level))
|
with_connection(config, |conn| get_buffer_conn(conn, tree_id, level))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_buffer_conn(
|
pub(crate) fn get_buffer_conn(conn: &Connection, tree_id: &str, level: u32) -> Result<Buffer> {
|
||||||
conn: &Connection,
|
|
||||||
tree_id: &str,
|
|
||||||
level: u32,
|
|
||||||
) -> Result<Buffer> {
|
|
||||||
let mut stmt = conn.prepare(
|
let mut stmt = conn.prepare(
|
||||||
"SELECT tree_id, level, item_ids_json, token_sum, oldest_at_ms
|
"SELECT tree_id, level, item_ids_json, token_sum, oldest_at_ms
|
||||||
FROM mem_tree_buffers WHERE tree_id = ?1 AND level = ?2",
|
FROM mem_tree_buffers WHERE tree_id = ?1 AND level = ?2",
|
||||||
@@ -361,10 +348,7 @@ pub(crate) fn clear_buffer_tx(tx: &Transaction<'_>, tree_id: &str, level: u32) -
|
|||||||
|
|
||||||
/// List all non-empty buffers ordered by `oldest_at_ms ASC`. Used by the
|
/// List all non-empty buffers ordered by `oldest_at_ms ASC`. Used by the
|
||||||
/// time-based flush pass.
|
/// time-based flush pass.
|
||||||
pub fn list_stale_buffers(
|
pub fn list_stale_buffers(config: &Config, older_than: DateTime<Utc>) -> Result<Vec<Buffer>> {
|
||||||
config: &Config,
|
|
||||||
older_than: DateTime<Utc>,
|
|
||||||
) -> Result<Vec<Buffer>> {
|
|
||||||
with_connection(config, |conn| {
|
with_connection(config, |conn| {
|
||||||
let mut stmt = conn.prepare(
|
let mut stmt = conn.prepare(
|
||||||
"SELECT tree_id, level, item_ids_json, token_sum, oldest_at_ms
|
"SELECT tree_id, level, item_ids_json, token_sum, oldest_at_ms
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use anyhow::Result;
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
||||||
use crate::openhuman::memory::tree::source_tree::summariser::{
|
use crate::openhuman::memory::tree::source_tree::summariser::{
|
||||||
SummaryContext, SummaryInput, SummaryOutput, Summariser,
|
Summariser, SummaryContext, SummaryInput, SummaryOutput,
|
||||||
};
|
};
|
||||||
use crate::openhuman::memory::tree::types::approx_token_count;
|
use crate::openhuman::memory::tree::types::approx_token_count;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user