Fix pod builder (#496)
Several fixes and code simplifications:
- MainPodBuilder
- Fix: It was not tracking Contains statements inherited via input pods (via public statements) when automatically generating Contains statements for Entry arguments.
- Enhancement: Deduplicate statements
- MultiPodBuilder
- Simplify: Remove the "statement groups" logic and instead deduplicate statements in the MainPodBuilder (which is much simpler to do)
- Remove the "anchored key" explicit dependency tracking and instead rely on regular dependency tracking by using all the implicit operations and statements generated by MainPodBuilder as input to the solver.
- Fix: Count and constrain custom predicates used in a pod instead of batches used
This commit is contained in:
parent
1e592e11cf
commit
a4069bcc55
7 changed files with 162 additions and 454 deletions
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::cost::AnchoredKeyId;
|
||||
use crate::{
|
||||
frontend::{Operation, OperationArg},
|
||||
middleware::{Hash, Statement},
|
||||
|
|
@ -100,11 +99,6 @@ impl DependencyGraph {
|
|||
pod_hash,
|
||||
statement: dep_stmt.clone(),
|
||||
}));
|
||||
} else if AnchoredKeyId::from_contains_statement(dep_stmt).is_some() {
|
||||
// Anchored-key Contains args may be implicit requirements that are
|
||||
// auto-materialized by MainPodBuilder. They are handled by anchored-key
|
||||
// resource accounting, not by statement dependency edges.
|
||||
continue;
|
||||
} else {
|
||||
// Statement arguments should either be internal (created earlier)
|
||||
// or from external PODs (except anchored-key implicit Contains).
|
||||
|
|
@ -128,9 +122,8 @@ impl DependencyGraph {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
dict,
|
||||
frontend::Operation as FrontendOp,
|
||||
middleware::{AnchoredKey, NativeOperation, OperationAux, OperationType, Value, ValueRef},
|
||||
middleware::{NativeOperation, OperationAux, OperationType, Value, ValueRef},
|
||||
};
|
||||
|
||||
fn equal_stmt(n: i64) -> Statement {
|
||||
|
|
@ -195,32 +188,4 @@ mod tests {
|
|||
assert_eq!(graph.statement_deps[1], vec![StatementSource::Internal(0)]);
|
||||
assert_eq!(graph.statement_deps[2], vec![StatementSource::Internal(0)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_anchored_key_contains_arg_is_treated_as_implicit_requirement() {
|
||||
// A literal Contains statement can be used as an anchored-key argument even when
|
||||
// no explicit producer statement exists in internal/external statements, because
|
||||
// MainPodBuilder auto-inserts Contains statements for anchored keys.
|
||||
let dict = dict!({
|
||||
"k" => 7_i64
|
||||
});
|
||||
|
||||
let anchored_contains = Statement::Contains(
|
||||
ValueRef::Literal(Value::from(dict.clone())),
|
||||
ValueRef::Literal(Value::from("k")),
|
||||
ValueRef::Literal(Value::from(7_i64)),
|
||||
);
|
||||
let ak = AnchoredKey::from((&dict, "k"));
|
||||
let produced_statement = Statement::Equal(ValueRef::Key(ak.clone()), ValueRef::Key(ak));
|
||||
|
||||
// Use a typical frontend operation that consumes entry-like args.
|
||||
// We're only testing the dependency graph, not the actual proof, so the operation
|
||||
// just needs to have the right arguments to test what we're looking for.
|
||||
let statements = vec![produced_statement];
|
||||
let operations = vec![FrontendOp::eq(anchored_contains.clone(), anchored_contains)];
|
||||
|
||||
let graph = DependencyGraph::build(&statements, &operations, &HashMap::new());
|
||||
|
||||
assert!(graph.statement_deps[0].is_empty());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue