mirror of
https://github.com/gorules/zen.git
synced 2026-10-07 00:02:19 +00:00
fix: record affected documents at change time
Edits queue their path; before the next snapshot the engine walks dependents with a frozen copy of every recorded view (each dependent on the graph stack) and stamps affected documents with a sequence. Consumers read them via changes_since(cursor), so queries in between cannot absorb a change. Graph dictionary views now cover the combined import list, matching first-wins resolution.
This commit is contained in:
@@ -12,6 +12,12 @@ use zen_engine::workspace;
|
||||
|
||||
type ResolverRef = FunctionRef<FnArgs<(String, Value)>, Option<String>>;
|
||||
|
||||
#[napi(object)]
|
||||
pub struct PolicyChanges {
|
||||
pub cursor: i64,
|
||||
pub paths: Vec<String>,
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct PolicyExpressionCursor {
|
||||
pub policy_path: String,
|
||||
@@ -627,13 +633,12 @@ impl Workspace {
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn affected_by(&self, paths: Vec<String>) -> Vec<String> {
|
||||
let paths: Vec<&str> = paths.iter().map(String::as_str).collect();
|
||||
self.inner
|
||||
.affected_by(&paths)
|
||||
.into_iter()
|
||||
.map(|p| p.to_string())
|
||||
.collect()
|
||||
pub fn changes_since(&self, cursor: i64) -> PolicyChanges {
|
||||
let (next, paths) = self.inner.changes_since(cursor.max(0) as u64);
|
||||
PolicyChanges {
|
||||
cursor: next as i64,
|
||||
paths: paths.into_iter().map(|p| p.to_string()).collect(),
|
||||
}
|
||||
}
|
||||
|
||||
#[napi]
|
||||
|
||||
Reference in New Issue
Block a user