fix: resolve kb_collections and kb_group_associations imports for directory feature
All checks were successful
BotServer CI/CD / build (push) Successful in 7m50s

- Extract kb_collections and kb_group_associations into dedicated schema/kb.rs module
- Gate kb module behind rbac feature (directory depends on rbac)
- Remove duplicate definitions from research.rs
- Fix import paths in directory/groups/kbs.rs
- Remove dead rbac_kb imports from settings/rbac.rs
- Gate llm::local module behind llm feature to fix missing set_embedding_server_ready

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-12 12:48:42 -03:00
parent 504e6e12ad
commit 2f3dd957e3
8 changed files with 49 additions and 38 deletions

View file

@ -43,7 +43,7 @@ pub use super::schema::{
};
#[cfg(feature = "rbac")]
pub use super::schema::kb_group_associations;
pub use super::schema::kb::{kb_collections, kb_group_associations};
pub use botlib::message_types::MessageType;
pub use botlib::models::{ApiResponse, Attachment, BotResponse, Session, Suggestion, UserMessage};

View file

@ -0,0 +1,36 @@
use crate::core::shared::schema::core::bots;
use crate::core::shared::schema::core::rbac_groups;
use crate::core::shared::schema::core::users;
diesel::table! {
kb_collections (id) {
id -> Uuid,
bot_id -> Uuid,
name -> Text,
folder_path -> Text,
qdrant_collection -> Text,
document_count -> Int4,
created_at -> Timestamptz,
updated_at -> Timestamptz,
}
}
diesel::table! {
kb_group_associations (id) {
id -> Uuid,
kb_id -> Uuid,
group_id -> Uuid,
granted_by -> Nullable<Uuid>,
granted_at -> Timestamptz,
}
}
diesel::joinable!(kb_collections -> bots (bot_id));
diesel::joinable!(kb_group_associations -> kb_collections (kb_id));
diesel::joinable!(kb_group_associations -> rbac_groups (group_id));
diesel::joinable!(kb_group_associations -> users (granted_by));
diesel::allow_tables_to_appear_in_same_query!(
kb_collections,
kb_group_associations,
);

View file

@ -73,6 +73,11 @@ pub mod research;
#[cfg(feature = "research")]
pub use self::research::*;
#[cfg(feature = "rbac")]
pub mod kb;
#[cfg(feature = "rbac")]
pub use self::kb::*;
#[cfg(feature = "learn")]
pub mod learn;
#[cfg(feature = "learn")]

View file

@ -1,5 +1,6 @@
use crate::core::shared::schema::core::{bots, organizations};
use crate::core::shared::schema::core::{rbac_groups, users};
use crate::core::shared::schema::kb::{kb_collections, kb_group_associations};
diesel::table! {
kb_documents (id) {
@ -20,19 +21,6 @@ diesel::table! {
}
}
diesel::table! {
kb_collections (id) {
id -> Uuid,
bot_id -> Uuid,
name -> Text,
folder_path -> Text,
qdrant_collection -> Text,
document_count -> Int4,
created_at -> Timestamptz,
updated_at -> Timestamptz,
}
}
diesel::table! {
user_kb_associations (id) {
id -> Text,
@ -151,20 +139,6 @@ diesel::table! {
}
}
diesel::table! {
kb_group_associations (id) {
id -> Uuid,
kb_id -> Uuid,
group_id -> Uuid,
granted_by -> Nullable<Uuid>,
granted_at -> Timestamptz,
}
}
diesel::joinable!(kb_collections -> bots (bot_id));
diesel::joinable!(kb_group_associations -> kb_collections (kb_id));
diesel::joinable!(kb_group_associations -> rbac_groups (group_id));
diesel::joinable!(kb_group_associations -> users (granted_by));
diesel::joinable!(research_projects -> organizations (org_id));
diesel::joinable!(research_projects -> bots (bot_id));
diesel::joinable!(research_sources -> research_projects (project_id));

View file

@ -30,7 +30,7 @@ pub async fn get_group_kbs(
let mut db_conn = conn.get().map_err(|e| format!("DB error: {e}"))?;
// 1. Get all KBs from kb_collections
use crate::core::shared::models::schema::kb_collections;
use crate::core::shared::models::kb_collections;
let all_kbs = kb_collections::table
.select((
kb_collections::id,
@ -41,7 +41,7 @@ pub async fn get_group_kbs(
.map_err(|e| format!("KB query error: {e}"))?;
// 2. Get associated KB IDs for this group
use crate::core::shared::models::schema::kb_group_associations;
use crate::core::shared::models::kb_group_associations;
let associated_ids: Vec<Uuid> = kb_group_associations::table
.filter(kb_group_associations::group_id.eq(group_id))
.select(kb_group_associations::kb_id)
@ -216,7 +216,7 @@ pub async fn toggle_group_kb(
let conn = state.conn.clone();
let result = tokio::task::spawn_blocking(move || -> Result<bool, String> {
let mut db_conn = conn.get().map_err(|e| format!("DB error: {e}"))?;
use crate::core::shared::models::schema::kb_group_associations;
use crate::core::shared::models::kb_group_associations;
let existing = kb_group_associations::table
.filter(kb_group_associations::kb_id.eq(kb_id))

View file

@ -11,6 +11,7 @@ pub mod episodic_memory;
pub mod glm;
pub mod hallucination_detector;
pub mod llm_models;
#[cfg(feature = "llm")]
pub mod local;
pub mod observability;
pub mod rate_limiter;

View file

@ -18,11 +18,6 @@ use serde::{Deserialize, Serialize};
use std::sync::Arc;
use uuid::Uuid;
#[cfg(feature = "rbac")]
use crate::settings::rbac_kb::{
assign_kb_to_group, get_accessible_kbs_for_user, get_kb_groups, remove_kb_from_group,
};
pub fn configure_rbac_routes() -> Router<Arc<AppState>> {
Router::new()

View file

@ -134,7 +134,7 @@ pub async fn assign_kb_to_group(
let now = Utc::now();
let result = tokio::task::spawn_blocking(move || -> Result<(), String> {
let mut db_conn = conn.get().map_err(|e| format!("DB error: {e}"))?;
use crate::core::shared::models::schema::kb_group_associations;
use crate::core::shared::models::kb_group_associations;
let existing: Option<Uuid> = kb_group_associations::table
.filter(kb_group_associations::kb_id.eq(kb_id))
.filter(kb_group_associations::group_id.eq(group_id))
@ -183,7 +183,7 @@ pub async fn remove_kb_from_group(
let conn = state.conn.clone();
let result = tokio::task::spawn_blocking(move || -> Result<(), String> {
let mut db_conn = conn.get().map_err(|e| format!("DB error: {e}"))?;
use crate::core::shared::models::schema::kb_group_associations;
use crate::core::shared::models::kb_group_associations;
diesel::delete(
kb_group_associations::table
.filter(kb_group_associations::kb_id.eq(kb_id))