filters are now entities and auto-generated for all table backed types

This commit is contained in:
2026-04-17 01:46:02 -04:00
parent 8175b10a97
commit 87a845e85a
9 changed files with 399 additions and 19 deletions

View File

@ -1,3 +1,4 @@
pub mod compile;
pub mod edge;
pub mod r#enum;
pub mod executors;
@ -8,7 +9,6 @@ pub mod punc;
pub mod relation;
pub mod schema;
pub mod r#type;
pub mod compile;
// External mock exports inside the executor sub-folder
@ -210,6 +210,7 @@ impl Database {
}
pub fn compile(&mut self, errors: &mut Vec<crate::drop::Error>) {
// Collect existing schemas patched in the databse
let mut harvested = Vec::new();
for (id, schema_arc) in &self.schemas {
crate::database::schema::Schema::collect_schemas(
@ -234,6 +235,37 @@ impl Database {
.as_ref()
.compile(self, root_id, id.clone(), errors);
}
// Phase 2: Synthesize Composed Filter References
let mut filter_schemas = Vec::new();
for type_def in self.types.values() {
for (id, schema_arc) in &type_def.schemas {
// Only run synthesis on actual structured, table-backed boundaries. Exclude subschemas!
let base_name = id.split('.').last().unwrap_or(id);
let is_table_backed = base_name == type_def.name;
if is_table_backed && !id.contains('/') {
if let Some(filter_schema) = schema_arc.compile_filter(self, id, errors) {
filter_schemas.push((format!("{}.filter", id), Arc::new(filter_schema)));
}
}
}
}
let mut filter_ids = Vec::new();
for (id, filter_arc) in filter_schemas {
filter_ids.push(id.clone());
self.schemas.insert(id, filter_arc);
}
// Now actively compile the newly injected filters to lock all nested compose references natively
for id in filter_ids {
if let Some(filter_arc) = self.schemas.get(&id).cloned() {
let root_id = id.split('/').next().unwrap_or(&id);
filter_arc
.as_ref()
.compile(self, root_id, id.clone(), errors);
}
}
}
fn collect_schemas(&mut self, errors: &mut Vec<crate::drop::Error>) {