feat: schema projections, command transactions, quantum-secure encryption

This commit is contained in:
Will Anderson
2026-04-27 18:26:46 -05:00
parent 69410a6908
commit 192528543f
27 changed files with 5460 additions and 4 deletions
+38
View File
@@ -36,7 +36,9 @@ use axum::{
Router,
};
use engram_core::EngramDb;
use engram_projection::registry::ProjectionRegistry;
use engram_sync::{SyncConfig, SyncEngine};
use engram_tx::TransactionEngine;
use mime_guess::from_path;
use rust_embed::RustEmbed;
use tokio::time::interval;
@@ -109,6 +111,18 @@ async fn main() -> anyhow::Result<()> {
let db = EngramDb::open(&PathBuf::from(&db_path))?;
let db = Arc::new(Mutex::new(db));
// Transaction engine (separate sled db alongside the main db)
let tx_log_path = format!("{}-tx-log", db_path);
let tx_log_db = sled::open(&tx_log_path)?;
let tx_engine = Arc::new(Mutex::new(TransactionEngine::new(
db.clone(),
tx_log_db,
Some(uuid::Uuid::new_v4()),
)));
// Projection registry
let projection_registry = Arc::new(Mutex::new(ProjectionRegistry::new()));
info!("Database opened at {}", db_path);
// Sync engine — wrapped in tokio::sync::Mutex so it can be held across .await
@@ -164,6 +178,8 @@ async fn main() -> anyhow::Result<()> {
db: db.clone(),
sync_engine: sync_engine.clone(),
api_key: api_key.clone(),
projection_registry,
tx_engine,
});
// Protected sync/swarm routes (auth middleware applied)
@@ -192,6 +208,26 @@ async fn main() -> anyhow::Result<()> {
.route("/decay", post(routes::core::decay))
.route("/consolidate", post(routes::core::consolidate));
// Projection routes (no auth)
let projection_routes = Router::new()
.route("/projections", post(routes::projection::register_projection))
.route("/projections", get(routes::projection::list_projections))
.route(
"/projections/{name}/schema",
get(routes::projection::get_projection_schema),
)
.route(
"/projections/{name}/query",
post(routes::projection::query_projection),
);
// Transaction routes (no auth — add auth layer if needed)
let tx_routes = Router::new()
.route("/tx/apply", post(routes::tx::tx_apply))
.route("/tx/rollback/{command_id}", post(routes::tx::tx_rollback))
.route("/tx/history", get(routes::tx::tx_history))
.route("/tx/chain/{command_id}", get(routes::tx::tx_causal_chain));
let studio_routes = Router::new()
.route("/", get(serve_studio_index))
.route("/studio", get(serve_studio_index))
@@ -201,6 +237,8 @@ async fn main() -> anyhow::Result<()> {
.merge(studio_routes)
.merge(core_routes)
.merge(sync_routes)
.merge(projection_routes)
.merge(tx_routes)
.layer(CorsLayer::permissive())
.with_state(state);