Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

feat: wire governance webhook through CLI and server

FABIOTESS17a75552fc49
diff --git a/src/main.rs b/src/main.rs
index c5b29b8c..66138981 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -37,6 +37,9 @@ enum Commands {
Serve {
#[arg(long, default_value = "~/.open-ontologies/config.toml")]
config: String,
+ /// Optional governance webhook URL (fires on every lineage event)
+ #[arg(long, env = "GOVERNANCE_WEBHOOK")]
+ governance_webhook: Option<String>,
},
/// Start the MCP server (Streamable HTTP transport)
ServeHttp {
@@ -51,6 +54,9 @@ enum Commands {
/// Optional bearer token for authentication
#[arg(long, env = "OPEN_ONTOLOGIES_TOKEN")]
token: Option<String>,
+ /// Optional governance webhook URL (fires on every lineage event)
+ #[arg(long, env = "GOVERNANCE_WEBHOOK")]
+ governance_webhook: Option<String>,
},
// ─── Core ontology ────────────────────────────────────────────
@@ -379,7 +385,7 @@ async fn main() -> anyhow::Result<()> {
println!("\nOpen Ontologies initialized successfully!");
}
- Commands::Serve { config: config_path } => {
+ Commands::Serve { config: config_path, governance_webhook } => {
let config_path = expand_tilde(&config_path);
let cfg = match Config::load(std::path::Path::new(&config_path)) {
Ok(c) => c,
@@ -398,11 +404,11 @@ async fn main() -> anyhow::Result<()> {
std::fs::create_dir_all(&data_dir)?;
let db = StateDb::open(&db_path)?;
- let server = OpenOntologiesServer::new(db);
+ let server = OpenOntologiesServer::new_with_options(db, Arc::new(GraphStore::new()), governance_webhook);
let service = server.serve(rmcp::transport::stdio()).await?;
service.waiting().await?;
}
- Commands::ServeHttp { config: config_path, host, port, token } => {
+ Commands::ServeHttp { config: config_path, host, port, token, governance_webhook } => {
use rmcp::transport::streamable_http_server::{
StreamableHttpServerConfig, StreamableHttpService,
session::local::LocalSessionManager,
@@ -440,12 +446,13 @@ async fn main() -> anyhow::Result<()> {
};
let shared_graph_for_service = shared_graph.clone();
+ let gw_for_service = governance_webhook.clone();
let service: StreamableHttpService<_, LocalSessionManager> =
StreamableHttpService::new(
move || {
let db = StateDb::open(&db_path_owned)
.map_err(std::io::Error::other)?;
- Ok(OpenOntologiesServer::new_with_graph(db, shared_graph_for_service.clone()))
+ Ok(OpenOntologiesServer::new_with_options(db, shared_graph_for_service.clone(), gw_for_service.clone()))
},
Default::default(),
http_config,
diff --git a/src/server.rs b/src/server.rs
index dc737d80..b31319e0 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -26,6 +26,7 @@ pub struct OpenOntologiesServer {
db: StateDb,
graph: Arc<GraphStore>,
session_id: String,
+ governance_webhook: Option<String>,
#[cfg(feature = "embeddings")]
vecstore: Arc<std::sync::Mutex<crate::vecstore::VecStore>>,
#[cfg(feature = "embeddings")]
@@ -35,13 +36,18 @@ pub struct OpenOntologiesServer {
impl OpenOntologiesServer {
/// Create a new server with all tools wired to domain services.
pub fn new(db: StateDb) -> Self {
- Self::new_with_graph(db, Arc::new(GraphStore::new()))
+ Self::new_with_options(db, Arc::new(GraphStore::new()), None)
}
/// Create a new server sharing an existing graph store (for HTTP mode where
/// all sessions must see the same in-memory triples).
pub fn new_with_graph(db: StateDb, graph: Arc<GraphStore>) -> Self {
- let lineage = crate::lineage::LineageLog::new(db.clone());
+ Self::new_with_options(db, graph, None)
+ }
+
+ /// Create a new server with all options including optional governance webhook.
+ pub fn new_with_options(db: StateDb, graph: Arc<GraphStore>, governance_webhook: Option<String>) -> Self {
+ let lineage = crate::lineage::LineageLog::with_governance_webhook(db.clone(), governance_webhook.clone());
let session_id = lineage.new_session();
#[cfg(feature = "embeddings")]
@@ -72,6 +78,7 @@ impl OpenOntologiesServer {
db,
graph,
session_id,
+ governance_webhook,
#[cfg(feature = "embeddings")]
vecstore,
#[cfg(feature = "embeddings")]
@@ -85,7 +92,7 @@ impl OpenOntologiesServer {
}
fn lineage(&self) -> crate::lineage::LineageLog {
- crate::lineage::LineageLog::new(self.db.clone())
+ crate::lineage::LineageLog::with_governance_webhook(self.db.clone(), self.governance_webhook.clone())
}
fn monitor(&self) -> crate::monitor::Monitor {