Skip to main content

knowdit_kg_model/db/
pending_semantic.rs

1//! Semantics that the historical KG has admitted but not yet cross-linked
2//! against the corpus of already-linked findings.
3//!
4//! Lifecycle (used by the "learn-new-project" CLI):
5//! 1. When a new project is admitted (after categorize → extract → in-project
6//!    linking → merge), every newly-introduced canonical semantic id is
7//!    inserted here.
8//! 2. The retro-link phase iterates each row in `finding_link_status` (i.e.
9//!    findings that have already gone through global linking on a previous
10//!    pass) and asks the LLM whether each pending-semantic relates to it,
11//!    appending links to `semantic_finding_link` as needed.
12//! 3. After retro-link finishes, this table is truncated and pending findings
13//!    flow through normal global linking — which now will see the new
14//!    semantics naturally because they are canonical at that point.
15use sea_orm::entity::prelude::*;
16
17#[sea_orm::model]
18#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, DeriveEntityModel)]
19#[sea_orm(table_name = "pending_semantic")]
20pub struct Model {
21    /// References `semantic_node.id`. Always a canonical id in practice
22    /// (newly-introduced semantics never start out merged-away).
23    #[sea_orm(primary_key, auto_increment = false)]
24    pub semantic_node_id: i32,
25
26    #[sea_orm(belongs_to, from = "semantic_node_id", to = "id")]
27    pub semantic_node: Option<super::semantic_node::Entity>,
28}
29
30impl ActiveModelBehavior for ActiveModel {}