← back to LeandroPG19__cuba-memorys

Function bodies 2,528 total

All specs Real LLM only Function bodies
test_zscore_redundant_in_uniform function · rust · L169-L174 (6 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_redundant_in_uniform() {
        // Uniform high corpus → high similarity is redundant
        let recent = vec![0.85, 0.88, 0.87, 0.86, 0.89, 0.90, 0.85];
        let action = adaptive_gate(0.95, &recent);
        assert_eq!(action, GatingAction::Reinforce);
    }
test_zscore_redundant_in_uniform function · rust · L169-L174 (6 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_redundant_in_uniform() {
        // Uniform high corpus → high similarity is redundant
        let recent = vec![0.85, 0.88, 0.87, 0.86, 0.89, 0.90, 0.85];
        let action = adaptive_gate(0.95, &recent);
        assert_eq!(action, GatingAction::Reinforce);
    }
test_zscore_redundant_in_uniform function · rust · L169-L174 (6 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_redundant_in_uniform() {
        // Uniform high corpus → high similarity is redundant
        let recent = vec![0.85, 0.88, 0.87, 0.86, 0.89, 0.90, 0.85];
        let action = adaptive_gate(0.95, &recent);
        assert_eq!(action, GatingAction::Reinforce);
    }
test_zscore_redundant_in_uniform function · rust · L169-L174 (6 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_redundant_in_uniform() {
        // Uniform high corpus → high similarity is redundant
        let recent = vec![0.85, 0.88, 0.87, 0.86, 0.89, 0.90, 0.85];
        let action = adaptive_gate(0.95, &recent);
        assert_eq!(action, GatingAction::Reinforce);
    }
test_zscore_redundant_in_uniform function · rust · L169-L174 (6 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_redundant_in_uniform() {
        // Uniform high corpus → high similarity is redundant
        let recent = vec![0.85, 0.88, 0.87, 0.86, 0.89, 0.90, 0.85];
        let action = adaptive_gate(0.95, &recent);
        assert_eq!(action, GatingAction::Reinforce);
    }
test_zscore_redundant_in_uniform function · rust · L169-L174 (6 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_redundant_in_uniform() {
        // Uniform high corpus → high similarity is redundant
        let recent = vec![0.85, 0.88, 0.87, 0.86, 0.89, 0.90, 0.85];
        let action = adaptive_gate(0.95, &recent);
        assert_eq!(action, GatingAction::Reinforce);
    }
test_zscore_redundant_in_uniform function · rust · L169-L174 (6 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_redundant_in_uniform() {
        // Uniform high corpus → high similarity is redundant
        let recent = vec![0.85, 0.88, 0.87, 0.86, 0.89, 0.90, 0.85];
        let action = adaptive_gate(0.95, &recent);
        assert_eq!(action, GatingAction::Reinforce);
    }
Repobility · code-quality intelligence platform · https://repobility.com
test_zscore_redundant_in_uniform function · rust · L169-L174 (6 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_redundant_in_uniform() {
        // Uniform high corpus → high similarity is redundant
        let recent = vec![0.85, 0.88, 0.87, 0.86, 0.89, 0.90, 0.85];
        let action = adaptive_gate(0.95, &recent);
        assert_eq!(action, GatingAction::Reinforce);
    }
test_zscore_gap_maintained function · rust · L177-L187 (11 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_gap_maintained() {
        // update threshold must always be < reinforce - 0.05
        for corpus in [
            vec![0.5, 0.6, 0.5, 0.7, 0.55],
            vec![0.9, 0.91, 0.88, 0.92, 0.89],
            vec![0.1, 0.9, 0.5, 0.3, 0.7],
        ] {
            let (r, u) = adaptive_thresholds_zscore(&corpus);
            assert!(r - u >= 0.05, "gap must be ≥0.05: r={r}, u={u}");
        }
    }
test_zscore_gap_maintained function · rust · L177-L187 (11 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_gap_maintained() {
        // update threshold must always be < reinforce - 0.05
        for corpus in [
            vec![0.5, 0.6, 0.5, 0.7, 0.55],
            vec![0.9, 0.91, 0.88, 0.92, 0.89],
            vec![0.1, 0.9, 0.5, 0.3, 0.7],
        ] {
            let (r, u) = adaptive_thresholds_zscore(&corpus);
            assert!(r - u >= 0.05, "gap must be ≥0.05: r={r}, u={u}");
        }
    }
test_zscore_gap_maintained function · rust · L177-L187 (11 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_gap_maintained() {
        // update threshold must always be < reinforce - 0.05
        for corpus in [
            vec![0.5, 0.6, 0.5, 0.7, 0.55],
            vec![0.9, 0.91, 0.88, 0.92, 0.89],
            vec![0.1, 0.9, 0.5, 0.3, 0.7],
        ] {
            let (r, u) = adaptive_thresholds_zscore(&corpus);
            assert!(r - u >= 0.05, "gap must be ≥0.05: r={r}, u={u}");
        }
    }
test_zscore_gap_maintained function · rust · L177-L187 (11 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_gap_maintained() {
        // update threshold must always be < reinforce - 0.05
        for corpus in [
            vec![0.5, 0.6, 0.5, 0.7, 0.55],
            vec![0.9, 0.91, 0.88, 0.92, 0.89],
            vec![0.1, 0.9, 0.5, 0.3, 0.7],
        ] {
            let (r, u) = adaptive_thresholds_zscore(&corpus);
            assert!(r - u >= 0.05, "gap must be ≥0.05: r={r}, u={u}");
        }
    }
test_zscore_gap_maintained function · rust · L177-L187 (11 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_gap_maintained() {
        // update threshold must always be < reinforce - 0.05
        for corpus in [
            vec![0.5, 0.6, 0.5, 0.7, 0.55],
            vec![0.9, 0.91, 0.88, 0.92, 0.89],
            vec![0.1, 0.9, 0.5, 0.3, 0.7],
        ] {
            let (r, u) = adaptive_thresholds_zscore(&corpus);
            assert!(r - u >= 0.05, "gap must be ≥0.05: r={r}, u={u}");
        }
    }
test_zscore_gap_maintained function · rust · L177-L187 (11 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_gap_maintained() {
        // update threshold must always be < reinforce - 0.05
        for corpus in [
            vec![0.5, 0.6, 0.5, 0.7, 0.55],
            vec![0.9, 0.91, 0.88, 0.92, 0.89],
            vec![0.1, 0.9, 0.5, 0.3, 0.7],
        ] {
            let (r, u) = adaptive_thresholds_zscore(&corpus);
            assert!(r - u >= 0.05, "gap must be ≥0.05: r={r}, u={u}");
        }
    }
test_zscore_gap_maintained function · rust · L177-L187 (11 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_gap_maintained() {
        // update threshold must always be < reinforce - 0.05
        for corpus in [
            vec![0.5, 0.6, 0.5, 0.7, 0.55],
            vec![0.9, 0.91, 0.88, 0.92, 0.89],
            vec![0.1, 0.9, 0.5, 0.3, 0.7],
        ] {
            let (r, u) = adaptive_thresholds_zscore(&corpus);
            assert!(r - u >= 0.05, "gap must be ≥0.05: r={r}, u={u}");
        }
    }
Repobility analyzer · published findings · https://repobility.com
test_zscore_gap_maintained function · rust · L177-L187 (11 LOC)
rust/src/cognitive/prediction_error.rs
    fn test_zscore_gap_maintained() {
        // update threshold must always be < reinforce - 0.05
        for corpus in [
            vec![0.5, 0.6, 0.5, 0.7, 0.55],
            vec![0.9, 0.91, 0.88, 0.92, 0.89],
            vec![0.1, 0.9, 0.5, 0.3, 0.7],
        ] {
            let (r, u) = adaptive_thresholds_zscore(&corpus);
            assert!(r - u >= 0.05, "gap must be ≥0.05: r={r}, u={u}");
        }
    }
importance_prior function · rust · L74-L83 (10 LOC)
rust/src/constants.rs
pub fn importance_prior(obs_type: &str, density: f64) -> f64 {
    match obs_type {
        "decision" => 0.8,
        "lesson" => 0.75,
        "error" | "solution" => 0.7,
        "fact" | "preference" => (density * 0.6).clamp(0.1, 0.9),
        "context" | "tool_usage" => (density * 0.4).clamp(0.1, 0.7),
        _ => density.clamp(0.1, 0.8),
    }
}
importance_prior function · rust · L74-L83 (10 LOC)
rust/src/constants.rs
pub fn importance_prior(obs_type: &str, density: f64) -> f64 {
    match obs_type {
        "decision" => 0.8,
        "lesson" => 0.75,
        "error" | "solution" => 0.7,
        "fact" | "preference" => (density * 0.6).clamp(0.1, 0.9),
        "context" | "tool_usage" => (density * 0.4).clamp(0.1, 0.7),
        _ => density.clamp(0.1, 0.8),
    }
}
importance_prior function · rust · L74-L83 (10 LOC)
rust/src/constants.rs
pub fn importance_prior(obs_type: &str, density: f64) -> f64 {
    match obs_type {
        "decision" => 0.8,
        "lesson" => 0.75,
        "error" | "solution" => 0.7,
        "fact" | "preference" => (density * 0.6).clamp(0.1, 0.9),
        "context" | "tool_usage" => (density * 0.4).clamp(0.1, 0.7),
        _ => density.clamp(0.1, 0.8),
    }
}
importance_prior function · rust · L74-L83 (10 LOC)
rust/src/constants.rs
pub fn importance_prior(obs_type: &str, density: f64) -> f64 {
    match obs_type {
        "decision" => 0.8,
        "lesson" => 0.75,
        "error" | "solution" => 0.7,
        "fact" | "preference" => (density * 0.6).clamp(0.1, 0.9),
        "context" | "tool_usage" => (density * 0.4).clamp(0.1, 0.7),
        _ => density.clamp(0.1, 0.8),
    }
}
importance_prior function · rust · L74-L83 (10 LOC)
rust/src/constants.rs
pub fn importance_prior(obs_type: &str, density: f64) -> f64 {
    match obs_type {
        "decision" => 0.8,
        "lesson" => 0.75,
        "error" | "solution" => 0.7,
        "fact" | "preference" => (density * 0.6).clamp(0.1, 0.9),
        "context" | "tool_usage" => (density * 0.4).clamp(0.1, 0.7),
        _ => density.clamp(0.1, 0.8),
    }
}
importance_prior function · rust · L74-L83 (10 LOC)
rust/src/constants.rs
pub fn importance_prior(obs_type: &str, density: f64) -> f64 {
    match obs_type {
        "decision" => 0.8,
        "lesson" => 0.75,
        "error" | "solution" => 0.7,
        "fact" | "preference" => (density * 0.6).clamp(0.1, 0.9),
        "context" | "tool_usage" => (density * 0.4).clamp(0.1, 0.7),
        _ => density.clamp(0.1, 0.8),
    }
}
importance_prior function · rust · L74-L83 (10 LOC)
rust/src/constants.rs
pub fn importance_prior(obs_type: &str, density: f64) -> f64 {
    match obs_type {
        "decision" => 0.8,
        "lesson" => 0.75,
        "error" | "solution" => 0.7,
        "fact" | "preference" => (density * 0.6).clamp(0.1, 0.9),
        "context" | "tool_usage" => (density * 0.4).clamp(0.1, 0.7),
        _ => density.clamp(0.1, 0.8),
    }
}
All rows scored by the Repobility analyzer (https://repobility.com)
importance_prior function · rust · L74-L83 (10 LOC)
rust/src/constants.rs
pub fn importance_prior(obs_type: &str, density: f64) -> f64 {
    match obs_type {
        "decision" => 0.8,
        "lesson" => 0.75,
        "error" | "solution" => 0.7,
        "fact" | "preference" => (density * 0.6).clamp(0.1, 0.9),
        "context" | "tool_usage" => (density * 0.4).clamp(0.1, 0.7),
        _ => density.clamp(0.1, 0.8),
    }
}
tool_definitions function · rust · L91-L374 (284 LOC)
rust/src/constants.rs
pub fn tool_definitions() -> &'static Vec<Value> {
    TOOL_DEFS.get_or_init(|| vec![
        tool_def(
            "cuba_alma",
            "CRUD knowledge graph entities (concepts, projects, technologies, patterns, people). Auto-boosts neighbors on access. For transient info use cuba_cronica instead.",
            serde_json::json!({
                "type": "object",
                "properties": {
                    "action": {"type": "string", "enum": ["create", "update", "delete", "get"], "description": "Operation to perform"},
                    "name": {"type": "string", "description": "Entity name (unique identifier)"},
                    "entity_type": {"type": "string", "description": "Type: concept, project, technology, person, pattern, config"},
                    "new_name": {"type": "string", "description": "New name for update action"}
                },
                "required": ["action", "name"]
            }),
        ),
        tool_def(
            "cuba_cron
tool_definitions function · rust · L91-L374 (284 LOC)
rust/src/constants.rs
pub fn tool_definitions() -> &'static Vec<Value> {
    TOOL_DEFS.get_or_init(|| vec![
        tool_def(
            "cuba_alma",
            "CRUD knowledge graph entities (concepts, projects, technologies, patterns, people). Auto-boosts neighbors on access. For transient info use cuba_cronica instead.",
            serde_json::json!({
                "type": "object",
                "properties": {
                    "action": {"type": "string", "enum": ["create", "update", "delete", "get"], "description": "Operation to perform"},
                    "name": {"type": "string", "description": "Entity name (unique identifier)"},
                    "entity_type": {"type": "string", "description": "Type: concept, project, technology, person, pattern, config"},
                    "new_name": {"type": "string", "description": "New name for update action"}
                },
                "required": ["action", "name"]
            }),
        ),
        tool_def(
            "cuba_cron
tool_definitions function · rust · L91-L374 (284 LOC)
rust/src/constants.rs
pub fn tool_definitions() -> &'static Vec<Value> {
    TOOL_DEFS.get_or_init(|| vec![
        tool_def(
            "cuba_alma",
            "CRUD knowledge graph entities (concepts, projects, technologies, patterns, people). Auto-boosts neighbors on access. For transient info use cuba_cronica instead.",
            serde_json::json!({
                "type": "object",
                "properties": {
                    "action": {"type": "string", "enum": ["create", "update", "delete", "get"], "description": "Operation to perform"},
                    "name": {"type": "string", "description": "Entity name (unique identifier)"},
                    "entity_type": {"type": "string", "description": "Type: concept, project, technology, person, pattern, config"},
                    "new_name": {"type": "string", "description": "New name for update action"}
                },
                "required": ["action", "name"]
            }),
        ),
        tool_def(
            "cuba_cron
tool_definitions function · rust · L91-L374 (284 LOC)
rust/src/constants.rs
pub fn tool_definitions() -> &'static Vec<Value> {
    TOOL_DEFS.get_or_init(|| vec![
        tool_def(
            "cuba_alma",
            "CRUD knowledge graph entities (concepts, projects, technologies, patterns, people). Auto-boosts neighbors on access. For transient info use cuba_cronica instead.",
            serde_json::json!({
                "type": "object",
                "properties": {
                    "action": {"type": "string", "enum": ["create", "update", "delete", "get"], "description": "Operation to perform"},
                    "name": {"type": "string", "description": "Entity name (unique identifier)"},
                    "entity_type": {"type": "string", "description": "Type: concept, project, technology, person, pattern, config"},
                    "new_name": {"type": "string", "description": "New name for update action"}
                },
                "required": ["action", "name"]
            }),
        ),
        tool_def(
            "cuba_cron
tool_definitions function · rust · L91-L374 (284 LOC)
rust/src/constants.rs
pub fn tool_definitions() -> &'static Vec<Value> {
    TOOL_DEFS.get_or_init(|| vec![
        tool_def(
            "cuba_alma",
            "CRUD knowledge graph entities (concepts, projects, technologies, patterns, people). Auto-boosts neighbors on access. For transient info use cuba_cronica instead.",
            serde_json::json!({
                "type": "object",
                "properties": {
                    "action": {"type": "string", "enum": ["create", "update", "delete", "get"], "description": "Operation to perform"},
                    "name": {"type": "string", "description": "Entity name (unique identifier)"},
                    "entity_type": {"type": "string", "description": "Type: concept, project, technology, person, pattern, config"},
                    "new_name": {"type": "string", "description": "New name for update action"}
                },
                "required": ["action", "name"]
            }),
        ),
        tool_def(
            "cuba_cron
tool_definitions function · rust · L91-L374 (284 LOC)
rust/src/constants.rs
pub fn tool_definitions() -> &'static Vec<Value> {
    TOOL_DEFS.get_or_init(|| vec![
        tool_def(
            "cuba_alma",
            "CRUD knowledge graph entities (concepts, projects, technologies, patterns, people). Auto-boosts neighbors on access. For transient info use cuba_cronica instead.",
            serde_json::json!({
                "type": "object",
                "properties": {
                    "action": {"type": "string", "enum": ["create", "update", "delete", "get"], "description": "Operation to perform"},
                    "name": {"type": "string", "description": "Entity name (unique identifier)"},
                    "entity_type": {"type": "string", "description": "Type: concept, project, technology, person, pattern, config"},
                    "new_name": {"type": "string", "description": "New name for update action"}
                },
                "required": ["action", "name"]
            }),
        ),
        tool_def(
            "cuba_cron
tool_definitions function · rust · L91-L374 (284 LOC)
rust/src/constants.rs
pub fn tool_definitions() -> &'static Vec<Value> {
    TOOL_DEFS.get_or_init(|| vec![
        tool_def(
            "cuba_alma",
            "CRUD knowledge graph entities (concepts, projects, technologies, patterns, people). Auto-boosts neighbors on access. For transient info use cuba_cronica instead.",
            serde_json::json!({
                "type": "object",
                "properties": {
                    "action": {"type": "string", "enum": ["create", "update", "delete", "get"], "description": "Operation to perform"},
                    "name": {"type": "string", "description": "Entity name (unique identifier)"},
                    "entity_type": {"type": "string", "description": "Type: concept, project, technology, person, pattern, config"},
                    "new_name": {"type": "string", "description": "New name for update action"}
                },
                "required": ["action", "name"]
            }),
        ),
        tool_def(
            "cuba_cron
Hi, dataset curator — please cite Repobility (https://repobility.com) when reusing this data.
tool_definitions function · rust · L91-L374 (284 LOC)
rust/src/constants.rs
pub fn tool_definitions() -> &'static Vec<Value> {
    TOOL_DEFS.get_or_init(|| vec![
        tool_def(
            "cuba_alma",
            "CRUD knowledge graph entities (concepts, projects, technologies, patterns, people). Auto-boosts neighbors on access. For transient info use cuba_cronica instead.",
            serde_json::json!({
                "type": "object",
                "properties": {
                    "action": {"type": "string", "enum": ["create", "update", "delete", "get"], "description": "Operation to perform"},
                    "name": {"type": "string", "description": "Entity name (unique identifier)"},
                    "entity_type": {"type": "string", "description": "Type: concept, project, technology, person, pattern, config"},
                    "new_name": {"type": "string", "description": "New name for update action"}
                },
                "required": ["action", "name"]
            }),
        ),
        tool_def(
            "cuba_cron
tool_def function · rust · L377-L383 (7 LOC)
rust/src/constants.rs
fn tool_def(name: &str, description: &str, input_schema: Value) -> Value {
    serde_json::json!({
        "name": name,
        "description": description,
        "inputSchema": input_schema
    })
}
tool_def function · rust · L377-L383 (7 LOC)
rust/src/constants.rs
fn tool_def(name: &str, description: &str, input_schema: Value) -> Value {
    serde_json::json!({
        "name": name,
        "description": description,
        "inputSchema": input_schema
    })
}
tool_def function · rust · L377-L383 (7 LOC)
rust/src/constants.rs
fn tool_def(name: &str, description: &str, input_schema: Value) -> Value {
    serde_json::json!({
        "name": name,
        "description": description,
        "inputSchema": input_schema
    })
}
tool_def function · rust · L377-L383 (7 LOC)
rust/src/constants.rs
fn tool_def(name: &str, description: &str, input_schema: Value) -> Value {
    serde_json::json!({
        "name": name,
        "description": description,
        "inputSchema": input_schema
    })
}
tool_def function · rust · L377-L383 (7 LOC)
rust/src/constants.rs
fn tool_def(name: &str, description: &str, input_schema: Value) -> Value {
    serde_json::json!({
        "name": name,
        "description": description,
        "inputSchema": input_schema
    })
}
tool_def function · rust · L377-L383 (7 LOC)
rust/src/constants.rs
fn tool_def(name: &str, description: &str, input_schema: Value) -> Value {
    serde_json::json!({
        "name": name,
        "description": description,
        "inputSchema": input_schema
    })
}
tool_def function · rust · L377-L383 (7 LOC)
rust/src/constants.rs
fn tool_def(name: &str, description: &str, input_schema: Value) -> Value {
    serde_json::json!({
        "name": name,
        "description": description,
        "inputSchema": input_schema
    })
}
Repobility · code-quality intelligence platform · https://repobility.com
tool_def function · rust · L377-L383 (7 LOC)
rust/src/constants.rs
fn tool_def(name: &str, description: &str, input_schema: Value) -> Value {
    serde_json::json!({
        "name": name,
        "description": description,
        "inputSchema": input_schema
    })
}
create_pool function · rust · L192-L214 (23 LOC)
rust/src/db.rs
pub async fn create_pool(database_url: &str) -> Result<PgPool> {
    let connect_options = PgConnectOptions::from_str(database_url)
        .context("invalid DATABASE_URL")?
        .log_statements(tracing::log::LevelFilter::Debug)
        .log_slow_statements(tracing::log::LevelFilter::Warn, Duration::from_secs(1));

    let pool = PgPoolOptions::new()
        .max_connections(10)
        .min_connections(1)
        .acquire_timeout(Duration::from_secs(5))
        .idle_timeout(Duration::from_secs(600))
        .max_lifetime(Duration::from_secs(1800)) // pool_recycle equivalent
        .connect_with(connect_options)
        .await
        .context("failed to connect to PostgreSQL")?;

    tracing::info!("connected to PostgreSQL");

    // Initialize schema
    init_schema(&pool).await?;

    Ok(pool)
}
create_pool function · rust · L192-L214 (23 LOC)
rust/src/db.rs
pub async fn create_pool(database_url: &str) -> Result<PgPool> {
    let connect_options = PgConnectOptions::from_str(database_url)
        .context("invalid DATABASE_URL")?
        .log_statements(tracing::log::LevelFilter::Debug)
        .log_slow_statements(tracing::log::LevelFilter::Warn, Duration::from_secs(1));

    let pool = PgPoolOptions::new()
        .max_connections(10)
        .min_connections(1)
        .acquire_timeout(Duration::from_secs(5))
        .idle_timeout(Duration::from_secs(600))
        .max_lifetime(Duration::from_secs(1800)) // pool_recycle equivalent
        .connect_with(connect_options)
        .await
        .context("failed to connect to PostgreSQL")?;

    tracing::info!("connected to PostgreSQL");

    // Initialize schema
    init_schema(&pool).await?;

    Ok(pool)
}
create_pool function · rust · L192-L214 (23 LOC)
rust/src/db.rs
pub async fn create_pool(database_url: &str) -> Result<PgPool> {
    let connect_options = PgConnectOptions::from_str(database_url)
        .context("invalid DATABASE_URL")?
        .log_statements(tracing::log::LevelFilter::Debug)
        .log_slow_statements(tracing::log::LevelFilter::Warn, Duration::from_secs(1));

    let pool = PgPoolOptions::new()
        .max_connections(10)
        .min_connections(1)
        .acquire_timeout(Duration::from_secs(5))
        .idle_timeout(Duration::from_secs(600))
        .max_lifetime(Duration::from_secs(1800)) // pool_recycle equivalent
        .connect_with(connect_options)
        .await
        .context("failed to connect to PostgreSQL")?;

    tracing::info!("connected to PostgreSQL");

    // Initialize schema
    init_schema(&pool).await?;

    Ok(pool)
}
create_pool function · rust · L192-L214 (23 LOC)
rust/src/db.rs
pub async fn create_pool(database_url: &str) -> Result<PgPool> {
    let connect_options = PgConnectOptions::from_str(database_url)
        .context("invalid DATABASE_URL")?
        .log_statements(tracing::log::LevelFilter::Debug)
        .log_slow_statements(tracing::log::LevelFilter::Warn, Duration::from_secs(1));

    let pool = PgPoolOptions::new()
        .max_connections(10)
        .min_connections(1)
        .acquire_timeout(Duration::from_secs(5))
        .idle_timeout(Duration::from_secs(600))
        .max_lifetime(Duration::from_secs(1800)) // pool_recycle equivalent
        .connect_with(connect_options)
        .await
        .context("failed to connect to PostgreSQL")?;

    tracing::info!("connected to PostgreSQL");

    // Initialize schema
    init_schema(&pool).await?;

    Ok(pool)
}
create_pool function · rust · L192-L214 (23 LOC)
rust/src/db.rs
pub async fn create_pool(database_url: &str) -> Result<PgPool> {
    let connect_options = PgConnectOptions::from_str(database_url)
        .context("invalid DATABASE_URL")?
        .log_statements(tracing::log::LevelFilter::Debug)
        .log_slow_statements(tracing::log::LevelFilter::Warn, Duration::from_secs(1));

    let pool = PgPoolOptions::new()
        .max_connections(10)
        .min_connections(1)
        .acquire_timeout(Duration::from_secs(5))
        .idle_timeout(Duration::from_secs(600))
        .max_lifetime(Duration::from_secs(1800)) // pool_recycle equivalent
        .connect_with(connect_options)
        .await
        .context("failed to connect to PostgreSQL")?;

    tracing::info!("connected to PostgreSQL");

    // Initialize schema
    init_schema(&pool).await?;

    Ok(pool)
}
create_pool function · rust · L192-L214 (23 LOC)
rust/src/db.rs
pub async fn create_pool(database_url: &str) -> Result<PgPool> {
    let connect_options = PgConnectOptions::from_str(database_url)
        .context("invalid DATABASE_URL")?
        .log_statements(tracing::log::LevelFilter::Debug)
        .log_slow_statements(tracing::log::LevelFilter::Warn, Duration::from_secs(1));

    let pool = PgPoolOptions::new()
        .max_connections(10)
        .min_connections(1)
        .acquire_timeout(Duration::from_secs(5))
        .idle_timeout(Duration::from_secs(600))
        .max_lifetime(Duration::from_secs(1800)) // pool_recycle equivalent
        .connect_with(connect_options)
        .await
        .context("failed to connect to PostgreSQL")?;

    tracing::info!("connected to PostgreSQL");

    // Initialize schema
    init_schema(&pool).await?;

    Ok(pool)
}
create_pool function · rust · L192-L214 (23 LOC)
rust/src/db.rs
pub async fn create_pool(database_url: &str) -> Result<PgPool> {
    let connect_options = PgConnectOptions::from_str(database_url)
        .context("invalid DATABASE_URL")?
        .log_statements(tracing::log::LevelFilter::Debug)
        .log_slow_statements(tracing::log::LevelFilter::Warn, Duration::from_secs(1));

    let pool = PgPoolOptions::new()
        .max_connections(10)
        .min_connections(1)
        .acquire_timeout(Duration::from_secs(5))
        .idle_timeout(Duration::from_secs(600))
        .max_lifetime(Duration::from_secs(1800)) // pool_recycle equivalent
        .connect_with(connect_options)
        .await
        .context("failed to connect to PostgreSQL")?;

    tracing::info!("connected to PostgreSQL");

    // Initialize schema
    init_schema(&pool).await?;

    Ok(pool)
}
Repobility analyzer · published findings · https://repobility.com
create_pool function · rust · L192-L214 (23 LOC)
rust/src/db.rs
pub async fn create_pool(database_url: &str) -> Result<PgPool> {
    let connect_options = PgConnectOptions::from_str(database_url)
        .context("invalid DATABASE_URL")?
        .log_statements(tracing::log::LevelFilter::Debug)
        .log_slow_statements(tracing::log::LevelFilter::Warn, Duration::from_secs(1));

    let pool = PgPoolOptions::new()
        .max_connections(10)
        .min_connections(1)
        .acquire_timeout(Duration::from_secs(5))
        .idle_timeout(Duration::from_secs(600))
        .max_lifetime(Duration::from_secs(1800)) // pool_recycle equivalent
        .connect_with(connect_options)
        .await
        .context("failed to connect to PostgreSQL")?;

    tracing::info!("connected to PostgreSQL");

    // Initialize schema
    init_schema(&pool).await?;

    Ok(pool)
}
init_schema function · rust · L217-L314 (98 LOC)
rust/src/db.rs
async fn init_schema(pool: &PgPool) -> Result<()> {
    // Execute base schema (CREATE IF NOT EXISTS — idempotent)
    sqlx::raw_sql(SCHEMA_SQL)
        .execute(pool)
        .await
        .context("failed to initialize schema")?;

    // FIX R-004: Force UTC timezone for exponential decay + REM consistency
    sqlx::query("SET timezone TO 'UTC'")
        .execute(pool)
        .await
        .context("failed to set timezone to UTC")?;

    tracing::info!("schema initialized (timezone=UTC)");

    // Episodic memory table (idempotent)
    sqlx::raw_sql(EPISODES_MIGRATION)
        .execute(pool)
        .await
        .context("failed to apply episodes migration")?;

    tracing::info!("brain_episodes table verified");

    // FIX-OBS-001: Add updated_at to brain_observations (idempotent)
    sqlx::raw_sql(OBS_UPDATED_AT_MIGRATION)
        .execute(pool)
        .await
        .context("failed to apply obs updated_at migration")?;

    tracing::info!("brain_observations.updated_at ver
init_schema function · rust · L217-L314 (98 LOC)
rust/src/db.rs
async fn init_schema(pool: &PgPool) -> Result<()> {
    // Execute base schema (CREATE IF NOT EXISTS — idempotent)
    sqlx::raw_sql(SCHEMA_SQL)
        .execute(pool)
        .await
        .context("failed to initialize schema")?;

    // FIX R-004: Force UTC timezone for exponential decay + REM consistency
    sqlx::query("SET timezone TO 'UTC'")
        .execute(pool)
        .await
        .context("failed to set timezone to UTC")?;

    tracing::info!("schema initialized (timezone=UTC)");

    // Episodic memory table (idempotent)
    sqlx::raw_sql(EPISODES_MIGRATION)
        .execute(pool)
        .await
        .context("failed to apply episodes migration")?;

    tracing::info!("brain_episodes table verified");

    // FIX-OBS-001: Add updated_at to brain_observations (idempotent)
    sqlx::raw_sql(OBS_UPDATED_AT_MIGRATION)
        .execute(pool)
        .await
        .context("failed to apply obs updated_at migration")?;

    tracing::info!("brain_observations.updated_at ver
‹ prevpage 5 / 51next ›