diff --git a/AGENTS.md b/AGENTS.md index c10a000c..c0ac7e78 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -175,7 +175,11 @@ All hot-path code must stay monomorphized. - Do not introduce `Box` in hot paths. - Do not introduce `Arc` or `Rc`. - Do not introduce `dyn Trait` unless it is an existing intentional boundary. -- Avoid `.clone()` in move evaluation and scoring paths. +- Avoid `.clone()` in move evaluation and scoring paths. Scoring streams do + not require `Clone` on entity types, so generic scoring code cannot clone an + entity; do not add a `Clone` bound to make one compile. Constraint analysis + describes an entity by its type name and `Debug` rendering (`EntityRef`) and + keeps no copy of it. - Preserve concrete types through the full solver pipeline. Intentional type-erasure boundaries that should not be "fixed": @@ -183,8 +187,6 @@ Intentional type-erasure boundaries that should not be "fixed": - `EntityExtractor` in `solverforge-core`: runtime-erased `SolutionDescriptor` access only. Canonical generated `RuntimeModel` and scoring-stream paths retain concrete collection types. -- Analysis `EntityRef` payloads in `solverforge-scoring`: explanation and - reporting boundary only. - `DynamicScalarAccess`, `DynamicListAccess`, `DynamicListMetadata`, and `DynamicScalarAssignmentMetadata`: host-language dynamic-model slot boundaries only. diff --git a/crates/solverforge-macros/tests/ui/fail/stream_source_not_from_model.stderr b/crates/solverforge-macros/tests/ui/fail/stream_source_not_from_model.stderr index bc3664ca..967280a7 100644 --- a/crates/solverforge-macros/tests/ui/fail/stream_source_not_from_model.stderr +++ b/crates/solverforge-macros/tests/ui/fail/stream_source_not_from_model.stderr @@ -14,7 +14,7 @@ help: the trait `CollectionExtract` is implemented for `UniConstraintStream CollectionExtract for UniConstraintStream | | where | | S: Send + Sync + 'static, - | | A: Clone + Send + Sync + 'static, + | | A: Send + Sync + 'static, | | E: CollectionExtract, | | F: UniFilter, | | Sc: Score + 'static, @@ -44,7 +44,7 @@ help: the trait `CollectionExtract` is implemented for `UniConstraintStream CollectionExtract for UniConstraintStream | | where | | S: Send + Sync + 'static, - | | A: Clone + Send + Sync + 'static, + | | A: Send + Sync + 'static, | | E: CollectionExtract, | | F: UniFilter, | | Sc: Score + 'static, diff --git a/crates/solverforge-macros/tests/ui/pass/solverforge_constraints_projected_complemented.rs b/crates/solverforge-macros/tests/ui/pass/solverforge_constraints_projected_complemented.rs index 78eb189a..2a62ab30 100644 --- a/crates/solverforge-macros/tests/ui/pass/solverforge_constraints_projected_complemented.rs +++ b/crates/solverforge-macros/tests/ui/pass/solverforge_constraints_projected_complemented.rs @@ -5,7 +5,7 @@ struct Entry { delta: i64, } -#[derive(Clone, Debug)] +#[derive(Debug)] struct Employee { id: usize, } diff --git a/crates/solverforge-scoring/WIREFRAME.md b/crates/solverforge-scoring/WIREFRAME.md index cfc5b00d..a16cbbfa 100644 --- a/crates/solverforge-scoring/WIREFRAME.md +++ b/crates/solverforge-scoring/WIREFRAME.md @@ -718,8 +718,9 @@ terminals of one shared node. Weight adapters (`GroupAdapter`/`GroupWeight`, row. Sharing is compiler-owned; there are no runtime node caches. A shared terminal requires its operator's rows to implement `ExplainRow`, so -every grouped and complemented builder's `named` requires `Clone + Debug` -entities (projected `Out` rows excepted: they justify nothing themselves). +every grouped and complemented builder's `named` requires `Debug` entities +(projected `Out` rows excepted: they justify nothing themselves). No stream +requires `Clone` on an entity type. Detailed analysis (`get_matches`, `ConstraintSet::evaluate_detailed[_weighted]`) reports, for every terminal on the node, one match per row whose coded weight is not zero, scored at the terminal's multiplier and justified by the row's @@ -748,8 +749,8 @@ Constraints own their `ConstraintRef` once. Metadata and analysis types borrow t **`ConstraintMetadata<'a>`** — `{ constraint_ref: &'a ConstraintRef, is_hard: bool }`; `name()` returns the short constraint name, and `full_name()` returns the package-qualified identity used for exact matching. -**`EntityRef`** — Public fields `{ type_name: String, display: String }` plus a private cloned entity snapshot for typed downcast access. -- Methods: `new()`, `with_display()`, `as_entity::()`, `short_type_name()` +**`EntityRef`** — `{ type_name: String, display: String }`: the entity's type name and `Debug` rendering, taken when a match is explained. It keeps no copy of the entity. +- Methods: `new(&T)`, `short_type_name()` - Implements `Hash + Eq` (by display string) **`ConstraintJustification`** — `{ entities: Vec, description: String }`. diff --git a/crates/solverforge-scoring/public-api.txt b/crates/solverforge-scoring/public-api.txt index b9bce8a8..cfd7374e 100644 --- a/crates/solverforge-scoring/public-api.txt +++ b/crates/solverforge-scoring/public-api.txt @@ -7,10 +7,8 @@ struct api::analysis::ConstraintJustification: pub struct ConstraintJustificatio api::analysis::ConstraintJustification: pub fn with_description(entities: Vec, description: String) -> Self struct api::analysis::DetailedConstraintMatch: pub struct DetailedConstraintMatch<'a, Sc: Score> { pub constraint_ref: &'a ConstraintRef, pub score: Sc, pub justification: ConstraintJustification, } api::analysis::DetailedConstraintMatch: pub fn new( constraint_ref: &'a ConstraintRef, score: Sc, justification: ConstraintJustification, ) -> Self -struct api::analysis::EntityRef: pub struct EntityRef { pub type_name: String, pub display: String, /* private fields */ } - api::analysis::EntityRef: pub fn new(entity: &T) -> Self - api::analysis::EntityRef: pub fn with_display( entity: &T, display: String, ) -> Self - api::analysis::EntityRef: pub fn as_entity(&self) -> Option<&T> +struct api::analysis::EntityRef: pub struct EntityRef { pub type_name: String, pub display: String, } + api::analysis::EntityRef: pub fn new(entity: &T) -> Self api::analysis::EntityRef: pub fn short_type_name(&self) -> &str struct api::constraint_set::ConstraintMetadata: pub struct ConstraintMetadata<'a> { pub constraint_ref: &'a ConstraintRef, pub is_hard: bool, } api::constraint_set::ConstraintMetadata: pub fn new(constraint_ref: &'a ConstraintRef, is_hard: bool) -> Self @@ -119,7 +117,7 @@ struct stream::ComplementedConstraintStream: pub struct ComplementedConstraintSt stream::ComplementedConstraintStream: pub fn reward( self, weight: W, ) -> ComplementedConstraintBuilder Sc + Send + Sync, Sc> where W: for<'w> ConstraintWeight<(&'w K, &'w R), Sc> + Send + Sync, struct stream::ConstraintFactory: pub struct ConstraintFactory { /* private fields */ } stream::ConstraintFactory: pub fn new() -> Self - stream::ConstraintFactory: pub fn for_each( self, extractor: E, ) -> UniConstraintStream where A: Clone + Send + Sync + 'static, E: CollectionExtract, + stream::ConstraintFactory: pub fn for_each( self, extractor: E, ) -> UniConstraintStream where A: Send + Sync + 'static, E: CollectionExtract, struct stream::ExistsConstraintBuilder: pub struct ExistsConstraintBuilder where Sc: Score,{ /* private fields */ } stream::ExistsConstraintBuilder: pub fn named( self, name: &str, ) -> OperatorTerminal, W, Sc> struct stream::ExistsConstraintStream: pub struct ExistsConstraintStream where Sc: Score,{ /* private fields */ } @@ -139,9 +137,9 @@ struct stream::GroupedConstraintBuilder: pub struct GroupedConstraintBuilder where Sc: Score,{ /* private fields */ } stream::GroupedConstraintStream: pub fn penalize( self, weight: W, ) -> GroupedConstraintBuilder Sc + Send + Sync, Sc> where W: for<'w> ConstraintWeight<(&'w K, &'w R), Sc> + Send + Sync, stream::GroupedConstraintStream: pub fn reward( self, weight: W, ) -> GroupedConstraintBuilder Sc + Send + Sync, Sc> where W: for<'w> ConstraintWeight<(&'w K, &'w R), Sc> + Send + Sync, - stream::GroupedConstraintStream: pub fn complement( self, extractor_b: EB, key_b: KB, default_fn: D, ) -> ComplementedConstraintStream Option + Send + Sync, KB, C, V, R, Acc, D, Sc> where B: Clone + Send + Sync + 'static, EB: CollectionExtract, KB: Fn(&B) -> K + Send + Sync, D: Fn(&B) -> R + Send + Sync + 'static, - stream::GroupedConstraintStream: pub fn join( self, target: (EB, KB), ) -> GroupedJoinedStream where B: Clone + Send + Sync + 'static, EB: CollectionExtract + 'static, KB: Fn(&B) -> K + Send + Sync + 'static, - stream::GroupedConstraintStream: pub fn complement_with_key( self, extractor_b: EB, key_a: KA2, key_b: KB, default_fn: D, ) -> ComplementedConstraintStream where B: Clone + Send + Sync + 'static, EB: CollectionExtract, KA2: Fn(&A) -> Option + Send + Sync, KB: Fn(&B) -> K + Send + Sync, D: Fn(&B) -> R + Send + Sync + 'static, + stream::GroupedConstraintStream: pub fn complement( self, extractor_b: EB, key_b: KB, default_fn: D, ) -> ComplementedConstraintStream Option + Send + Sync, KB, C, V, R, Acc, D, Sc> where B: Send + Sync + 'static, EB: CollectionExtract, KB: Fn(&B) -> K + Send + Sync, D: Fn(&B) -> R + Send + Sync + 'static, + stream::GroupedConstraintStream: pub fn join( self, target: (EB, KB), ) -> GroupedJoinedStream where B: Send + Sync + 'static, EB: CollectionExtract + 'static, KB: Fn(&B) -> K + Send + Sync + 'static, + stream::GroupedConstraintStream: pub fn complement_with_key( self, extractor_b: EB, key_a: KA2, key_b: KB, default_fn: D, ) -> ComplementedConstraintStream where B: Send + Sync + 'static, EB: CollectionExtract, KA2: Fn(&A) -> Option + Send + Sync, KB: Fn(&B) -> K + Send + Sync, D: Fn(&B) -> R + Send + Sync + 'static, struct stream::HardWeight: pub struct HardWeight { /* private fields */ } struct stream::JoinedGroupedBuilder: pub struct JoinedGroupedBuilder, W, Sc> { /* private fields */ } stream::JoinedGroupedBuilder: pub fn named( self, name: &str, ) -> SharedOperatorTerminal, GroupAdapter, OperatorScorer< as AdaptWeight, W, Sc>>::RowWeight, Sc>, Sc> @@ -183,7 +181,7 @@ struct stream::UniConstraintStream: pub struct UniConstraintStream( self, projection: P, ) -> Stream, TrueFilter, Sc> where P: Projection + 'static, stream::UniConstraintStream: pub fn unassigned( self, ) -> UniConstraintStream bool>>, Sc> stream::UniConstraintStream: pub fn new(extractor: E) -> Self - stream::UniConstraintStream: pub fn flattened( self, flatten: Flat, ) -> FlattenedCollectionTarget, Sc> where E: CollectionExtract, B: Clone + Send + Sync + 'static, Flat: for<'a> Fn(&'a A) -> &'a Vec + Send + Sync, + stream::UniConstraintStream: pub fn flattened( self, flatten: Flat, ) -> FlattenedCollectionTarget, Sc> where E: CollectionExtract, B: Send + Sync + 'static, Flat: for<'a> Fn(&'a A) -> &'a Vec + Send + Sync, stream::UniConstraintStream: pub fn filter

( self, predicate: P, ) -> UniConstraintStream bool + Send + Sync>>, Sc> where P: Fn(&A) -> bool + Send + Sync + 'static, stream::UniConstraintStream: pub fn join(self, target: J) -> J::Output where J: JoinTarget, stream::UniConstraintStream: pub fn group_by( self, key_fn: KF, collector: C, ) -> GroupedConstraintStream where K: Clone + Eq + Hash + Send + Sync + 'static, KF: Fn(&A) -> K + Send + Sync, C: for<'i> Collector<&'i A, Value = V, Result = R, Accumulator = Acc> + Send + Sync + 'static, V: Send + Sync + 'static, R: Send + Sync + 'static, Acc: Accumulator + Send + Sync + 'static, @@ -195,7 +193,7 @@ struct stream::UniConstraintStream: pub struct UniConstraintStream where O: Operator,{ /* private fields */ } stream::chain::Chain: pub fn new(tree: O, next_binding: u32) -> Self stream::chain::Chain: pub fn filter

(self, predicate: P) -> Chain, Sc> where P: for<'a> FilterPredicate> + 'static, FilterNode: Operator, - stream::chain::Chain: pub fn join( self, target: (EB, P), ) -> Chain, P::Plan>, Sc> where B: Clone + Send + Sync + 'static, EB: CollectionExtract + 'static, P: CompileCondition + 'static, for<'a> P::Plan: IndexedPlan + ExecutablePlan, Leaf<'a, B>>, for<'a> CollectionNode: Operator = Leaf<'a, B>>, JoinNode, P::Plan>: Operator, + stream::chain::Chain: pub fn join( self, target: (EB, P), ) -> Chain, P::Plan>, Sc> where B: Send + Sync + 'static, EB: CollectionExtract + 'static, P: CompileCondition + 'static, for<'a> P::Plan: IndexedPlan + ExecutablePlan, Leaf<'a, B>>, for<'a> CollectionNode: Operator = Leaf<'a, B>>, JoinNode, P::Plan>: Operator, stream::chain::Chain: pub fn penalize(self, weight: W) -> ChainBuilder where W: for<'a> Fn(&S, &O::View<'a>) -> Sc + Send + Sync, stream::chain::Chain: pub fn reward(self, weight: W) -> ChainBuilder where W: for<'a> Fn(&S, &O::View<'a>) -> Sc + Send + Sync, struct stream::chain::ChainBuilder: pub struct ChainBuilder where O: Operator,{ /* private fields */ } @@ -247,8 +245,8 @@ struct stream::cross::Bi: pub struct Bi where Sc: Sco stream::cross::Bi: pub fn new(extractor_a: EA, extractor_b: EB, key_a: KA, key_b: KB) -> Self stream::cross::Bi: pub fn new_with_filter( extractor_a: EA, extractor_b: EB, key_a: KA, key_b: KB, filter: F, ) -> Self stream::cross::Bi: pub fn filter( self, predicate: Q, ) -> Bi bool + Send + Sync>>, Sc> where Q: Fn(&A, &B) -> bool + Send + Sync, - stream::cross::Bi: pub fn join( self, target: (EC, P2), ) -> Tri, Sc> where C: Clone + Send + Sync + 'static, EC: CollectionExtract + 'static, P: CompileCondition + 'static, for<'a> P::Plan: ExecutablePlan, Leaf<'a, B>> + IndexedPlan, P2: CompileCondition + 'static, for<'a> P2::Plan: IndexedPlan + ExecutablePlan, Leaf<'a, B>>, Leaf<'a, C>>, EA: 'static, EB: 'static, - stream::cross::Bi: pub fn flatten_last( self, flatten: Flatten, c_key_fn: CKeyFn, a_lookup_fn: ALookup, ) -> FlattenedBiConstraintStream where C: Clone + Send + Sync + 'static, CK: Eq + Hash + Clone + Send + Sync, Flatten: Fn(&B) -> &[C] + Send + Sync, CKeyFn: Fn(&C) -> CK + Send + Sync, ALookup: Fn(&A) -> CK + Send + Sync, + stream::cross::Bi: pub fn join( self, target: (EC, P2), ) -> Tri, Sc> where C: Send + Sync + 'static, EC: CollectionExtract + 'static, P: CompileCondition + 'static, for<'a> P::Plan: ExecutablePlan, Leaf<'a, B>> + IndexedPlan, P2: CompileCondition + 'static, for<'a> P2::Plan: IndexedPlan + ExecutablePlan, Leaf<'a, B>>, Leaf<'a, C>>, EA: 'static, EB: 'static, + stream::cross::Bi: pub fn flatten_last( self, flatten: Flatten, c_key_fn: CKeyFn, a_lookup_fn: ALookup, ) -> FlattenedBiConstraintStream where C: Send + Sync + 'static, CK: Eq + Hash + Clone + Send + Sync, Flatten: Fn(&B) -> &[C] + Send + Sync, CKeyFn: Fn(&C) -> CK + Send + Sync, ALookup: Fn(&A) -> CK + Send + Sync, stream::cross::Bi: pub fn group_by( self, group_key_fn: GF, collector: C, ) -> Grouped where GK: Eq + Hash + Clone + Send + Sync + 'static, GF: Fn(&A, &B) -> GK + Send + Sync, C: for<'i> Collector<(&'i A, &'i B), Value = V, Result = R, Accumulator = Acc> + Send + Sync + 'static, V: Send + Sync + 'static, R: Send + Sync + 'static, Acc: Accumulator + Send + Sync + 'static, stream::cross::Bi: pub fn project( self, project: Proj, ) -> Stream, TrueFilter, Sc> where Out: Send + Sync + 'static, Proj: Fn(&A, &B) -> Out + Send + Sync + 'static, stream::cross::Bi: pub fn penalize( self, weight: W, ) -> Builder Sc + Send + Sync, Sc> where W: for<'w> ConstraintWeight<(&'w A, &'w B), Sc> + Send + Sync, @@ -263,7 +261,7 @@ struct stream::cross::ComplementedGroupedBuilder: pub struct ComplementedGrouped struct stream::cross::Grouped: pub struct Grouped where Sc: Score,{ /* private fields */ } stream::cross::Grouped: pub fn penalize( self, weight: W, ) -> GroupedBuilder Sc + Send + Sync, Sc> where W: for<'w> ConstraintWeight<(&'w GK, &'w R), Sc> + Send + Sync, stream::cross::Grouped: pub fn reward( self, weight: W, ) -> GroupedBuilder Sc + Send + Sync, Sc> where W: for<'w> ConstraintWeight<(&'w GK, &'w R), Sc> + Send + Sync, - stream::cross::Grouped: pub fn complement( self, extractor_t: ET, key_t: KT, default_fn: D, ) -> ComplementedGrouped where T: Clone + Send + Sync + 'static, ET: CollectionExtract, KT: Fn(&T) -> GK + Send + Sync, D: Fn(&T) -> R + Send + Sync, + stream::cross::Grouped: pub fn complement( self, extractor_t: ET, key_t: KT, default_fn: D, ) -> ComplementedGrouped where T: Send + Sync + 'static, ET: CollectionExtract, KT: Fn(&T) -> GK + Send + Sync, D: Fn(&T) -> R + Send + Sync, struct stream::cross::GroupedBuilder: pub struct GroupedBuilder where Sc: Score,{ /* private fields */ } stream::cross::GroupedBuilder: pub fn named( self, name: &str, ) -> SharedOperatorTerminal, F>, impl Fn(&Pair, Leaf<'_, B>>) -> GK + Send + Sync, TupleCollector, GK, Acc, V, R>, GroupAdapter, OperatorScorer, Sc>, Sc> struct stream::cross::Penta: pub struct Penta where Sc: Score, P1: CompileCondition, P2: CompileCondition, P3: CompileCondition, P4: CompileCondition,{ /* private fields */ } @@ -276,7 +274,7 @@ struct stream::cross::PentaBuilder: pub struct PentaBuilder OperatorTerminal, impl Fn(&S, &, CollectionNode, ::Plan>, CollectionNode, ::Plan>, CollectionNode, ::Plan>, CollectionNode, ::Plan> as Operator>::View<'_>) -> Sc + Send + Sync, Sc> struct stream::cross::Quad: pub struct Quad where Sc: Score, P1: CompileCondition, P2: CompileCondition, P3: CompileCondition,{ /* private fields */ } stream::cross::Quad: pub fn filter

( self, predicate: P, ) -> Quad bool + Send + Sync>>, Sc> where P: Fn(&A, &B, &C, &D) -> bool + Send + Sync, - stream::cross::Quad: pub fn join( self, target: (EE, P4), ) -> Penta, Sc> where E: Clone + Send + Sync + 'static, EE: CollectionExtract + 'static, P4: CompileCondition + 'static, for<'a> P4::Plan: IndexedPlan + ExecutablePlan, Leaf<'a, B>>, Leaf<'a, C>>, Leaf<'a, D>>, Leaf<'a, E>>, for<'a> JoinNode, CollectionNode, ::Plan>, CollectionNode, ::Plan>, CollectionNode, ::Plan>: Operator = Pair, Leaf<'a, B>>, Leaf<'a, C>>, Leaf<'a, D>>>, for<'a> JoinNode, CollectionNode, ::Plan>, CollectionNode, ::Plan>, CollectionNode, ::Plan>, CollectionNode, ::Plan>: Operator, + stream::cross::Quad: pub fn join( self, target: (EE, P4), ) -> Penta, Sc> where E: Send + Sync + 'static, EE: CollectionExtract + 'static, P4: CompileCondition + 'static, for<'a> P4::Plan: IndexedPlan + ExecutablePlan, Leaf<'a, B>>, Leaf<'a, C>>, Leaf<'a, D>>, Leaf<'a, E>>, for<'a> JoinNode, CollectionNode, ::Plan>, CollectionNode, ::Plan>, CollectionNode, ::Plan>: Operator = Pair, Leaf<'a, B>>, Leaf<'a, C>>, Leaf<'a, D>>>, for<'a> JoinNode, CollectionNode, ::Plan>, CollectionNode, ::Plan>, CollectionNode, ::Plan>, CollectionNode, ::Plan>: Operator, stream::cross::Quad: pub fn penalize( self, weight: W, ) -> QuadBuilder Sc + Send + Sync, Sc> where W: for<'w> ConstraintWeight<(&'w A, &'w B, &'w C, &'w D), Sc> + Send + Sync, stream::cross::Quad: pub fn reward( self, weight: W, ) -> QuadBuilder Sc + Send + Sync, Sc> where W: for<'w> ConstraintWeight<(&'w A, &'w B, &'w C, &'w D), Sc> + Send + Sync, stream::cross::Quad: pub fn group_by( self, key: GF, collector: Co, ) -> JoinedGroupedStream, CollectionNode, ::Plan>, CollectionNode, ::Plan>, CollectionNode, ::Plan>, impl Fn(&S, &Pair, Leaf<'_, B>>, Leaf<'_, C>>, Leaf<'_, D>>) -> bool + Send + Sync>, impl Fn(&Pair, Leaf<'_, B>>, Leaf<'_, C>>, Leaf<'_, D>>) -> GK + Send + Sync, TupleCollector, GK, V, R, Acc, Sc> where GK: Eq + Hash + Clone + Send + Sync + 'static, GF: Fn(&A, &B, &C, &D) -> GK + Send + Sync + 'static, Co: for<'i> Collector<(&'i A, &'i B, &'i C, &'i D), Value = V, Result = R, Accumulator = Acc> + 'static, V: Send + Sync + 'static, R: Send + Sync + 'static, Acc: Accumulator + 'static, @@ -284,7 +282,7 @@ struct stream::cross::QuadBuilder: pub struct QuadBuilder OperatorTerminal, impl Fn(&S, &, CollectionNode, ::Plan>, CollectionNode, ::Plan>, CollectionNode, ::Plan> as Operator>::View<'_>) -> Sc + Send + Sync, Sc> struct stream::cross::Tri: pub struct Tri where Sc: Score, P1: CompileCondition, P2: CompileCondition,{ /* private fields */ } stream::cross::Tri: pub fn filter

( self, predicate: P, ) -> Tri bool + Send + Sync>>, Sc> where P: Fn(&A, &B, &C) -> bool + Send + Sync, - stream::cross::Tri: pub fn join( self, target: (ED, P3), ) -> Quad, Sc> where D: Clone + Send + Sync + 'static, ED: CollectionExtract + 'static, P3: CompileCondition + 'static, for<'a> P3::Plan: IndexedPlan + ExecutablePlan, Leaf<'a, B>>, Leaf<'a, C>>, Leaf<'a, D>>, for<'a> JoinNode, CollectionNode, ::Plan>, CollectionNode, ::Plan>: Operator = Pair, Leaf<'a, B>>, Leaf<'a, C>>>, for<'a> JoinNode, CollectionNode, ::Plan>, CollectionNode, ::Plan>, CollectionNode, ::Plan>: Operator, + stream::cross::Tri: pub fn join( self, target: (ED, P3), ) -> Quad, Sc> where D: Send + Sync + 'static, ED: CollectionExtract + 'static, P3: CompileCondition + 'static, for<'a> P3::Plan: IndexedPlan + ExecutablePlan, Leaf<'a, B>>, Leaf<'a, C>>, Leaf<'a, D>>, for<'a> JoinNode, CollectionNode, ::Plan>, CollectionNode, ::Plan>: Operator = Pair, Leaf<'a, B>>, Leaf<'a, C>>>, for<'a> JoinNode, CollectionNode, ::Plan>, CollectionNode, ::Plan>, CollectionNode, ::Plan>: Operator, stream::cross::Tri: pub fn penalize( self, weight: W, ) -> Builder Sc + Send + Sync, Sc> where W: for<'w> ConstraintWeight<(&'w A, &'w B, &'w C), Sc> + Send + Sync, stream::cross::Tri: pub fn reward( self, weight: W, ) -> Builder Sc + Send + Sync, Sc> where W: for<'w> ConstraintWeight<(&'w A, &'w B, &'w C), Sc> + Send + Sync, stream::cross::Tri: pub fn group_by( self, key: GF, collector: Co, ) -> JoinedGroupedStream, CollectionNode, ::Plan>, CollectionNode, ::Plan>, impl Fn(&S, &Pair, Leaf<'_, B>>, Leaf<'_, C>>) -> bool + Send + Sync>, impl Fn(&Pair, Leaf<'_, B>>, Leaf<'_, C>>) -> GK + Send + Sync, TupleCollector, GK, V, R, Acc, Sc> where GK: Eq + Hash + Clone + Send + Sync + 'static, GF: Fn(&A, &B, &C) -> GK + Send + Sync + 'static, Co: for<'i> Collector<(&'i A, &'i B, &'i C), Value = V, Result = R, Accumulator = Acc> + 'static, V: Send + Sync + 'static, R: Send + Sync + 'static, Acc: Accumulator + 'static, diff --git a/crates/solverforge-scoring/src/api/analysis.rs b/crates/solverforge-scoring/src/api/analysis.rs index 6d9bb08e..eaf9ac9e 100644 --- a/crates/solverforge-scoring/src/api/analysis.rs +++ b/crates/solverforge-scoring/src/api/analysis.rs @@ -1,54 +1,34 @@ //! Score analysis types for detailed constraint tracking. //! -//! This module provides types for analyzing constraint matches in detail, -//! including which entities are involved in each match, score explanations, -//! and entity-level indictments. +//! This module provides types for analyzing constraint matches in detail: +//! each match's score and the entities that caused it. -use std::any::Any; use std::fmt::Debug; -use std::hash::{Hash, Hasher}; -use std::sync::Arc; use solverforge_core::score::Score; use solverforge_core::ConstraintRef; -/// Reference to an entity involved in a constraint match. -/// Uses type erasure to allow storing references to different entity types -/// in a single collection. -#[derive(Clone)] +/// An entity involved in a constraint match, as constraint analysis reports +/// it: the entity's type name and its `Debug` rendering, taken when the match +/// is explained. It holds no copy of the entity, so explaining a match +/// requires only `Debug` on the entity type. +#[derive(Clone, PartialEq, Eq, Hash)] pub struct EntityRef { /// Type name of the entity (e.g., "Shift", "Employee"). pub type_name: String, /// String representation for display. pub display: String, - // Type-erased entity for programmatic access. - entity: Arc, } impl EntityRef { - /// Creates a new entity reference from a concrete entity. - pub fn new(entity: &T) -> Self { + /// Describes `entity` by its type name and `Debug` rendering. + pub fn new(entity: &T) -> Self { Self { type_name: std::any::type_name::().to_string(), - display: format!("{:?}", entity), - entity: Arc::new(entity.clone()), + display: format!("{entity:?}"), } } - /// Creates an entity reference with a custom display string. - pub fn with_display(entity: &T, display: String) -> Self { - Self { - type_name: std::any::type_name::().to_string(), - display, - entity: Arc::new(entity.clone()), - } - } - - /// Attempts to downcast to the concrete entity type. - pub fn as_entity(&self) -> Option<&T> { - self.entity.downcast_ref::() - } - /// Returns the short type name (without module path). pub fn short_type_name(&self) -> &str { self.type_name @@ -67,21 +47,6 @@ impl Debug for EntityRef { } } -impl PartialEq for EntityRef { - fn eq(&self, other: &Self) -> bool { - self.type_name == other.type_name && self.display == other.display - } -} - -impl Eq for EntityRef {} - -impl Hash for EntityRef { - fn hash(&self, state: &mut H) { - self.type_name.hash(state); - self.display.hash(state); - } -} - /// Justification for why a constraint matched. #[derive(Debug, Clone)] pub struct ConstraintJustification { diff --git a/crates/solverforge-scoring/src/api/tests/analysis.rs b/crates/solverforge-scoring/src/api/tests/analysis.rs index dee01b61..e7e1f9d4 100644 --- a/crates/solverforge-scoring/src/api/tests/analysis.rs +++ b/crates/solverforge-scoring/src/api/tests/analysis.rs @@ -21,17 +21,20 @@ fn test_entity_ref_creation() { assert!(entity_ref.display.contains("1")); } +/// Explaining a match needs only `Debug`: the entity type is neither `Clone` +/// nor `'static`, and the reference keeps no copy of it. #[test] -fn test_entity_ref_downcast() { - let entity = TestEntity { - id: 42, - name: "Answer".to_string(), - }; - let entity_ref = EntityRef::new(&entity); +fn test_entity_ref_describes_a_borrowed_debug_only_entity() { + #[derive(Debug)] + struct Borrowed<'a> { + #[allow(dead_code)] + name: &'a str, + } + let name = String::from("Answer"); + let entity_ref = EntityRef::new(&Borrowed { name: &name }); - let recovered: Option<&TestEntity> = entity_ref.as_entity(); - assert!(recovered.is_some()); - assert_eq!(recovered.unwrap().id, 42); + assert_eq!(entity_ref.short_type_name(), "Borrowed<'_>"); + assert_eq!(entity_ref.display, r#"Borrowed { name: "Answer" }"#); } #[test] diff --git a/crates/solverforge-scoring/src/constraint/balance.rs b/crates/solverforge-scoring/src/constraint/balance.rs index aab14271..35efe62a 100644 --- a/crates/solverforge-scoring/src/constraint/balance.rs +++ b/crates/solverforge-scoring/src/constraint/balance.rs @@ -134,7 +134,7 @@ where impl BalanceConstraint where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, K: Clone + Eq + Hash + Send + Sync + 'static, E: crate::stream::collection_extract::CollectionExtract, F: UniFilter, @@ -241,7 +241,7 @@ impl IncrementalConstraint for BalanceConstraint where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, K: Clone + Eq + Hash + Send + Sync + 'static, E: crate::stream::collection_extract::CollectionExtract, F: UniFilter, diff --git a/crates/solverforge-scoring/src/constraint/incremental.rs b/crates/solverforge-scoring/src/constraint/incremental.rs index 0d1dc9a1..d294c48a 100644 --- a/crates/solverforge-scoring/src/constraint/incremental.rs +++ b/crates/solverforge-scoring/src/constraint/incremental.rs @@ -32,7 +32,7 @@ where impl IncrementalUniConstraint where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, E: crate::stream::collection_extract::CollectionExtract, F: Fn(&S, &A) -> bool + Send + Sync, W: Fn(&A) -> Sc + Send + Sync, @@ -96,7 +96,7 @@ where impl IncrementalConstraint for IncrementalUniConstraint where S: Send + Sync + 'static, - A: Clone + Debug + Send + Sync + 'static, + A: Debug + Send + Sync + 'static, E: crate::stream::collection_extract::CollectionExtract, F: Fn(&S, &A) -> bool + Send + Sync, W: Fn(&A) -> Sc + Send + Sync, diff --git a/crates/solverforge-scoring/src/constraint/relational/grouped_weights.rs b/crates/solverforge-scoring/src/constraint/relational/grouped_weights.rs index 99a1d21e..3577c4be 100644 --- a/crates/solverforge-scoring/src/constraint/relational/grouped_weights.rs +++ b/crates/solverforge-scoring/src/constraint/relational/grouped_weights.rs @@ -117,7 +117,7 @@ where Acc: Accumulator + 'static, V: Send + Sync + 'static, R: Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + B: Send + Sync + 'static, EB: crate::stream::collection_extract::CollectionExtract + 'static, P: crate::stream::joiner::plan::IndexedPlan + 'static, for<'a> P: @@ -156,7 +156,7 @@ where Acc: Accumulator + 'static, V: Send + Sync + 'static, R: Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + B: Send + Sync + 'static, EB: crate::stream::collection_extract::CollectionExtract + 'static, P: crate::stream::joiner::plan::IndexedPlan + 'static, for<'a> P: diff --git a/crates/solverforge-scoring/src/constraint/tests/cross_bi_incr.rs b/crates/solverforge-scoring/src/constraint/tests/cross_bi_incr.rs index 035f6360..bec70698 100644 --- a/crates/solverforge-scoring/src/constraint/tests/cross_bi_incr.rs +++ b/crates/solverforge-scoring/src/constraint/tests/cross_bi_incr.rs @@ -3,6 +3,7 @@ use std::sync::{ Arc, }; +use crate::api::analysis::EntityRef; use crate::api::constraint_set::IncrementalConstraint; use crate::stream::collection_extract::{source, ChangeSource, CollectionExtract}; use crate::stream::collector::sum; @@ -298,22 +299,18 @@ fn test_cross_bi_get_matches_works_without_initialize() { assert_eq!(matches[0].score, SoftScore::of(-1)); assert_eq!(matches[0].justification.entities.len(), 2); assert_eq!( - matches[0].justification.entities[0] - .as_entity::() - .unwrap(), - &Shift { + matches[0].justification.entities[0], + EntityRef::new(&Shift { employee_id: Some(0), day: 5, - } + }) ); assert_eq!( - matches[0].justification.entities[1] - .as_entity::() - .unwrap(), - &Employee { + matches[0].justification.entities[1], + EntityRef::new(&Employee { id: 0, unavailable_days: vec![5], - } + }) ); } diff --git a/crates/solverforge-scoring/src/constraint/tests/grouped_analysis.rs b/crates/solverforge-scoring/src/constraint/tests/grouped_analysis.rs index 54edb256..fd5d1137 100644 --- a/crates/solverforge-scoring/src/constraint/tests/grouped_analysis.rs +++ b/crates/solverforge-scoring/src/constraint/tests/grouped_analysis.rs @@ -7,6 +7,8 @@ the match scores must sum to the constraint's score: before initialization, after it, and across mutations. Shared grouped nodes report matches for every terminal they carry, scaled by each terminal's weight multiplier. +The entities implement only `Debug`: explaining a match copies nothing. + Roster: nurse 0 works shifts 0 and 1, nurse 1 works shift 2, shift 3 is unassigned, nurse 2 works nothing. */ @@ -22,12 +24,12 @@ use crate::stream::ConstraintFactory; const UNASSIGNED: usize = usize::MAX; -#[derive(Clone, Debug)] +#[derive(Debug)] struct Nurse { id: usize, } -#[derive(Clone, Debug)] +#[derive(Debug)] struct Shift { // Read only through `Debug`: it tells the shifts apart in justifications. #[allow(dead_code)] @@ -35,7 +37,6 @@ struct Shift { nurse: Option, } -#[derive(Clone)] struct Roster { shifts: Vec, nurses: Vec, diff --git a/crates/solverforge-scoring/src/stream/arity_stream_macros/nary_stream/shared.rs b/crates/solverforge-scoring/src/stream/arity_stream_macros/nary_stream/shared.rs index 48f707b7..936f8be7 100644 --- a/crates/solverforge-scoring/src/stream/arity_stream_macros/nary_stream/shared.rs +++ b/crates/solverforge-scoring/src/stream/arity_stream_macros/nary_stream/shared.rs @@ -75,7 +75,7 @@ macro_rules! impl_nary_arity_stream_common { impl $stream where S: Send + Sync + 'static, - A: Clone + std::hash::Hash + PartialEq + Send + Sync + 'static, + A: std::hash::Hash + PartialEq + Send + Sync + 'static, K: Eq + std::hash::Hash + Clone + Send + Sync, E: super::collection_extract::CollectionExtract, KE: super::key_extract::KeyExtract, @@ -95,7 +95,7 @@ macro_rules! impl_nary_arity_stream_common { impl $stream where S: Send + Sync + 'static, - A: Clone + std::hash::Hash + PartialEq + Send + Sync + 'static, + A: std::hash::Hash + PartialEq + Send + Sync + 'static, K: Eq + std::hash::Hash + Clone + Send + Sync, E: super::collection_extract::CollectionExtract, KE: super::key_extract::KeyExtract, @@ -358,7 +358,7 @@ macro_rules! impl_nary_arity_stream_common { impl $builder where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, K: Eq + std::hash::Hash + Clone + Send + Sync, E: super::collection_extract::CollectionExtract, KE: super::key_extract::KeyExtract, diff --git a/crates/solverforge-scoring/src/stream/balance_stream.rs b/crates/solverforge-scoring/src/stream/balance_stream.rs index 55300262..30b6da84 100644 --- a/crates/solverforge-scoring/src/stream/balance_stream.rs +++ b/crates/solverforge-scoring/src/stream/balance_stream.rs @@ -94,7 +94,7 @@ where impl BalanceConstraintStream where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, K: Clone + Eq + Hash + Send + Sync + 'static, E: CollectionExtract, F: UniFilter, @@ -167,7 +167,7 @@ where impl BalanceConstraintBuilder where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, K: Clone + Eq + Hash + Send + Sync + 'static, E: CollectionExtract, F: UniFilter, diff --git a/crates/solverforge-scoring/src/stream/bi_stream.rs b/crates/solverforge-scoring/src/stream/bi_stream.rs index 639b5f15..e3713383 100644 --- a/crates/solverforge-scoring/src/stream/bi_stream.rs +++ b/crates/solverforge-scoring/src/stream/bi_stream.rs @@ -60,7 +60,7 @@ super::arity_stream_macros::impl_arity_stream!(bi, BiConstraintStream, BiConstra impl BiConstraintStream where S: Send + Sync + 'static, - A: Clone + Hash + PartialEq + Send + Sync + 'static, + A: Hash + PartialEq + Send + Sync + 'static, K: Eq + Hash + Clone + Send + Sync, E: super::collection_extract::CollectionExtract, KE: super::key_extract::KeyExtract, diff --git a/crates/solverforge-scoring/src/stream/chain_stream.rs b/crates/solverforge-scoring/src/stream/chain_stream.rs index 8b53a67b..72ec35d8 100644 --- a/crates/solverforge-scoring/src/stream/chain_stream.rs +++ b/crates/solverforge-scoring/src/stream/chain_stream.rs @@ -89,7 +89,7 @@ where target: (EB, P), ) -> Chain, P::Plan>, Sc> where - B: Clone + Send + Sync + 'static, + B: Send + Sync + 'static, EB: CollectionExtract + 'static, P: CompileCondition + 'static, P::Plan: IndexedPlan, diff --git a/crates/solverforge-scoring/src/stream/complemented_stream.rs b/crates/solverforge-scoring/src/stream/complemented_stream.rs index df15bb53..e52aab0d 100644 --- a/crates/solverforge-scoring/src/stream/complemented_stream.rs +++ b/crates/solverforge-scoring/src/stream/complemented_stream.rs @@ -135,8 +135,8 @@ impl ComplementedConstraintStream where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, K: Clone + Eq + Hash + Send + Sync + 'static, EA: CollectionExtract, EB: CollectionExtract, @@ -303,8 +303,8 @@ impl ComplementedConstraintBuilder where S: Send + Sync + 'static, - A: Clone + std::fmt::Debug + Send + Sync + 'static, - B: Clone + std::fmt::Debug + Send + Sync + 'static, + A: std::fmt::Debug + Send + Sync + 'static, + B: std::fmt::Debug + Send + Sync + 'static, K: Clone + Eq + Hash + Send + Sync + 'static, EA: CollectionExtract + 'static, EB: CollectionExtract + 'static, diff --git a/crates/solverforge-scoring/src/stream/cross_bi_stream/base.rs b/crates/solverforge-scoring/src/stream/cross_bi_stream/base.rs index c9149164..b720eca2 100644 --- a/crates/solverforge-scoring/src/stream/cross_bi_stream/base.rs +++ b/crates/solverforge-scoring/src/stream/cross_bi_stream/base.rs @@ -41,8 +41,8 @@ where impl Bi, EA, EB, TrueFilter, Sc> where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, K: Eq + std::hash::Hash + Clone + Send + Sync, EA: CollectionExtract, EB: CollectionExtract, @@ -66,8 +66,8 @@ where impl Bi, EA, EB, F, Sc> where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, K: Eq + std::hash::Hash + Clone + Send + Sync, EA: CollectionExtract, EB: CollectionExtract, @@ -97,8 +97,8 @@ where impl Bi where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, EA: CollectionExtract, EB: CollectionExtract, F: BiFilter, @@ -191,7 +191,7 @@ where Sc, > where - C: Clone + Send + Sync + 'static, + C: Send + Sync + 'static, EC: CollectionExtract + 'static, P: CompileCondition + 'static, for<'a> P::Plan: ExecutablePlan< @@ -226,8 +226,8 @@ where impl Bi, EA, EB, F, Sc> where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, K: Eq + std::hash::Hash + Clone + Send + Sync + 'static, EA: CollectionExtract, EB: CollectionExtract, @@ -260,7 +260,7 @@ where Sc, > where - C: Clone + Send + Sync + 'static, + C: Send + Sync + 'static, CK: Eq + std::hash::Hash + Clone + Send + Sync, Flatten: Fn(&B) -> &[C] + Send + Sync, CKeyFn: Fn(&C) -> CK + Send + Sync, diff --git a/crates/solverforge-scoring/src/stream/cross_bi_stream/complemented_grouped.rs b/crates/solverforge-scoring/src/stream/cross_bi_stream/complemented_grouped.rs index 18db7929..c68bca06 100644 --- a/crates/solverforge-scoring/src/stream/cross_bi_stream/complemented_grouped.rs +++ b/crates/solverforge-scoring/src/stream/cross_bi_stream/complemented_grouped.rs @@ -79,9 +79,9 @@ impl ComplementedGrouped where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - T: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + T: Send + Sync + 'static, JK: Eq + Hash + Clone + Send + Sync + 'static, GK: Eq + Hash + Clone + Send + Sync + 'static, EA: CollectionExtract, @@ -316,9 +316,9 @@ impl > where S: Send + Sync + 'static, - A: Clone + std::fmt::Debug + Send + Sync + 'static, - B: Clone + std::fmt::Debug + Send + Sync + 'static, - T: Clone + std::fmt::Debug + Send + Sync + 'static, + A: std::fmt::Debug + Send + Sync + 'static, + B: std::fmt::Debug + Send + Sync + 'static, + T: std::fmt::Debug + Send + Sync + 'static, JK: Eq + Hash + Clone + Send + Sync + 'static, GK: Eq + Hash + Clone + Send + Sync + 'static, EA: CollectionExtract + Send + Sync + 'static, diff --git a/crates/solverforge-scoring/src/stream/cross_bi_stream/grouped.rs b/crates/solverforge-scoring/src/stream/cross_bi_stream/grouped.rs index 600aadb3..b268e8f9 100644 --- a/crates/solverforge-scoring/src/stream/cross_bi_stream/grouped.rs +++ b/crates/solverforge-scoring/src/stream/cross_bi_stream/grouped.rs @@ -50,8 +50,8 @@ impl Grouped where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, JK: Eq + Hash + Clone + Send + Sync + 'static, GK: Eq + Hash + Clone + Send + Sync + 'static, EA: CollectionExtract, @@ -179,7 +179,7 @@ where default_fn: D, ) -> ComplementedGrouped where - T: Clone + Send + Sync + 'static, + T: Send + Sync + 'static, ET: CollectionExtract, KT: Fn(&T) -> GK + Send + Sync, D: Fn(&T) -> R + Send + Sync, @@ -233,8 +233,8 @@ impl GroupedBuilder where S: Send + Sync + 'static, - A: Clone + std::fmt::Debug + Send + Sync + 'static, - B: Clone + std::fmt::Debug + Send + Sync + 'static, + A: std::fmt::Debug + Send + Sync + 'static, + B: std::fmt::Debug + Send + Sync + 'static, JK: Eq + Hash + Clone + Send + Sync + 'static, GK: Eq + Hash + Clone + Send + Sync + 'static, EA: CollectionExtract + Send + Sync + 'static, diff --git a/crates/solverforge-scoring/src/stream/cross_bi_stream/scored.rs b/crates/solverforge-scoring/src/stream/cross_bi_stream/scored.rs index 452c22b0..18658535 100644 --- a/crates/solverforge-scoring/src/stream/cross_bi_stream/scored.rs +++ b/crates/solverforge-scoring/src/stream/cross_bi_stream/scored.rs @@ -237,8 +237,8 @@ where impl Operator for BiScored where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, P: IndexedPlan + 'static, EA: CollectionExtract, EB: CollectionExtract, @@ -383,8 +383,8 @@ where impl BiScored where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, P: IndexedPlan, F: BiFilter, JoinNode, CollectionNode, P>: Operator, diff --git a/crates/solverforge-scoring/src/stream/cross_bi_stream/weighting.rs b/crates/solverforge-scoring/src/stream/cross_bi_stream/weighting.rs index c3534d16..50e1e920 100644 --- a/crates/solverforge-scoring/src/stream/cross_bi_stream/weighting.rs +++ b/crates/solverforge-scoring/src/stream/cross_bi_stream/weighting.rs @@ -16,8 +16,8 @@ use crate::constraint::relational::OperatorTerminal; impl Bi where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, P: CompileCondition + 'static, for<'a> P::Plan: ExecutablePlan, Leaf<'a, B>>, P::Plan: IndexedPlan, @@ -107,8 +107,8 @@ where impl Builder where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, P: CompileCondition + 'static, for<'a> P::Plan: ExecutablePlan, Leaf<'a, B>>, P::Plan: IndexedPlan, diff --git a/crates/solverforge-scoring/src/stream/cross_penta_stream.rs b/crates/solverforge-scoring/src/stream/cross_penta_stream.rs index 1d1b01cd..6db73efe 100644 --- a/crates/solverforge-scoring/src/stream/cross_penta_stream.rs +++ b/crates/solverforge-scoring/src/stream/cross_penta_stream.rs @@ -109,11 +109,11 @@ impl Penta where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, - D: Clone + Send + Sync + 'static, - E: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, + D: Send + Sync + 'static, + E: Send + Sync + 'static, EA: 'static, EB: 'static, EC: 'static, @@ -276,11 +276,11 @@ impl Penta where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, - D: Clone + Send + Sync + 'static, - E: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, + D: Send + Sync + 'static, + E: Send + Sync + 'static, EA: 'static, EB: 'static, EC: 'static, @@ -377,11 +377,11 @@ impl PentaBuilder where S: Send + Sync + 'static, - A: Clone + std::fmt::Debug + Send + Sync + 'static, - B: Clone + std::fmt::Debug + Send + Sync + 'static, - C: Clone + std::fmt::Debug + Send + Sync + 'static, - D: Clone + std::fmt::Debug + Send + Sync + 'static, - E: Clone + std::fmt::Debug + Send + Sync + 'static, + A: std::fmt::Debug + Send + Sync + 'static, + B: std::fmt::Debug + Send + Sync + 'static, + C: std::fmt::Debug + Send + Sync + 'static, + D: std::fmt::Debug + Send + Sync + 'static, + E: std::fmt::Debug + Send + Sync + 'static, P1: CompileCondition, P2: CompileCondition, P3: CompileCondition, diff --git a/crates/solverforge-scoring/src/stream/cross_penta_stream/scored.rs b/crates/solverforge-scoring/src/stream/cross_penta_stream/scored.rs index b325f4d5..49d0656c 100644 --- a/crates/solverforge-scoring/src/stream/cross_penta_stream/scored.rs +++ b/crates/solverforge-scoring/src/stream/cross_penta_stream/scored.rs @@ -59,11 +59,11 @@ impl Operator for PentaScored where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, - D: Clone + Send + Sync + 'static, - E: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, + D: Send + Sync + 'static, + E: Send + Sync + 'static, P1: CompileCondition + 'static, P2: CompileCondition + 'static, P3: CompileCondition + 'static, diff --git a/crates/solverforge-scoring/src/stream/cross_quad_stream.rs b/crates/solverforge-scoring/src/stream/cross_quad_stream.rs index 1bdc2473..4992e026 100644 --- a/crates/solverforge-scoring/src/stream/cross_quad_stream.rs +++ b/crates/solverforge-scoring/src/stream/cross_quad_stream.rs @@ -94,10 +94,10 @@ impl Quad where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, - D: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, + D: Send + Sync + 'static, EA: 'static, EB: 'static, EC: 'static, @@ -179,7 +179,7 @@ where Sc, > where - E: Clone + Send + Sync + 'static, + E: Send + Sync + 'static, EE: super::collection_extract::CollectionExtract + 'static, P4: CompileCondition + 'static, P4::Plan: IndexedPlan, @@ -326,10 +326,10 @@ impl QuadBuilder where S: Send + Sync + 'static, - A: Clone + std::fmt::Debug + Send + Sync + 'static, - B: Clone + std::fmt::Debug + Send + Sync + 'static, - C: Clone + std::fmt::Debug + Send + Sync + 'static, - D: Clone + std::fmt::Debug + Send + Sync + 'static, + A: std::fmt::Debug + Send + Sync + 'static, + B: std::fmt::Debug + Send + Sync + 'static, + C: std::fmt::Debug + Send + Sync + 'static, + D: std::fmt::Debug + Send + Sync + 'static, P1: CompileCondition, P2: CompileCondition, P3: CompileCondition, diff --git a/crates/solverforge-scoring/src/stream/cross_quad_stream/scored.rs b/crates/solverforge-scoring/src/stream/cross_quad_stream/scored.rs index 725c9dc7..2fbc4893 100644 --- a/crates/solverforge-scoring/src/stream/cross_quad_stream/scored.rs +++ b/crates/solverforge-scoring/src/stream/cross_quad_stream/scored.rs @@ -32,10 +32,10 @@ impl Operator for QuadScored where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, - D: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, + D: Send + Sync + 'static, P1: CompileCondition + 'static, P2: CompileCondition + 'static, P3: CompileCondition + 'static, diff --git a/crates/solverforge-scoring/src/stream/cross_tri_stream/base.rs b/crates/solverforge-scoring/src/stream/cross_tri_stream/base.rs index f4df5b1c..10b4df87 100644 --- a/crates/solverforge-scoring/src/stream/cross_tri_stream/base.rs +++ b/crates/solverforge-scoring/src/stream/cross_tri_stream/base.rs @@ -49,9 +49,9 @@ pub(super) fn build_tree( ) -> BuiltTri where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, EA: CollectionExtract + 'static, EB: CollectionExtract + 'static, EC: CollectionExtract + 'static, @@ -93,9 +93,9 @@ pub(crate) fn assemble_tri( ) -> Tri where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, EA: CollectionExtract + 'static, EB: CollectionExtract + 'static, EC: CollectionExtract + 'static, @@ -142,9 +142,9 @@ where impl Tri where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, EA: 'static, EB: 'static, EC: 'static, @@ -250,7 +250,7 @@ where Sc, > where - D: Clone + Send + Sync + 'static, + D: Send + Sync + 'static, ED: CollectionExtract + 'static, P3: CompileCondition + 'static, P3::Plan: IndexedPlan, @@ -335,9 +335,9 @@ where impl Builder where S: Send + Sync + 'static, - A: Clone + std::fmt::Debug + Send + Sync + 'static, - B: Clone + std::fmt::Debug + Send + Sync + 'static, - C: Clone + std::fmt::Debug + Send + Sync + 'static, + A: std::fmt::Debug + Send + Sync + 'static, + B: std::fmt::Debug + Send + Sync + 'static, + C: std::fmt::Debug + Send + Sync + 'static, P1: CompileCondition, P2: CompileCondition, for<'a> JoinNode, CollectionNode, ::Plan>: diff --git a/crates/solverforge-scoring/src/stream/cross_tri_stream/base/scored.rs b/crates/solverforge-scoring/src/stream/cross_tri_stream/base/scored.rs index ff0e1837..bede9d20 100644 --- a/crates/solverforge-scoring/src/stream/cross_tri_stream/base/scored.rs +++ b/crates/solverforge-scoring/src/stream/cross_tri_stream/base/scored.rs @@ -32,9 +32,9 @@ pub struct TriScored< impl Operator for TriScored where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, P1: CompileCondition + 'static, P2: CompileCondition + 'static, for<'a> JoinNode, CollectionNode, ::Plan>: diff --git a/crates/solverforge-scoring/src/stream/existence_stream.rs b/crates/solverforge-scoring/src/stream/existence_stream.rs index 10315585..03ad0b55 100644 --- a/crates/solverforge-scoring/src/stream/existence_stream.rs +++ b/crates/solverforge-scoring/src/stream/existence_stream.rs @@ -67,7 +67,7 @@ where impl ExistsConstraintStream where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, K: Eq + std::hash::Hash + Clone + Send + Sync + 'static, L: super::relational::operator::Operator, for<'a> LK: super::relational::view_plan::ViewKey, Key = K>, diff --git a/crates/solverforge-scoring/src/stream/existence_target.rs b/crates/solverforge-scoring/src/stream/existence_target.rs index c75c74ae..a4cfc5ae 100644 --- a/crates/solverforge-scoring/src/stream/existence_target.rs +++ b/crates/solverforge-scoring/src/stream/existence_target.rs @@ -58,8 +58,8 @@ impl ExistenceTarget + Send + Sync + 'static, FA: UniFilter + Send + Sync + 'static, EB: CollectionExtract + Send + Sync + 'static, @@ -107,9 +107,9 @@ impl ExistenceTarget + Send + Sync + 'static, FA: UniFilter + Send + Sync + 'static, EP: CollectionExtract + Send + Sync + 'static, diff --git a/crates/solverforge-scoring/src/stream/factory.rs b/crates/solverforge-scoring/src/stream/factory.rs index 041e3e53..e03e5e4b 100644 --- a/crates/solverforge-scoring/src/stream/factory.rs +++ b/crates/solverforge-scoring/src/stream/factory.rs @@ -73,7 +73,7 @@ where /// The extractor type is preserved as a concrete generic for full zero-erasure. pub fn for_each(self, extractor: E) -> UniConstraintStream where - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, E: CollectionExtract, { UniConstraintStream::new(extractor) diff --git a/crates/solverforge-scoring/src/stream/flattened_bi_stream/base.rs b/crates/solverforge-scoring/src/stream/flattened_bi_stream/base.rs index 0add2f11..f57543b9 100644 --- a/crates/solverforge-scoring/src/stream/flattened_bi_stream/base.rs +++ b/crates/solverforge-scoring/src/stream/flattened_bi_stream/base.rs @@ -74,9 +74,9 @@ impl > where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, K: Eq + Hash + Clone + Send + Sync, CK: Eq + Hash + Clone + Send + Sync, EA: CollectionExtract, @@ -117,9 +117,9 @@ impl FlattenedBiConstraintStream where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, K: Eq + Hash + Clone + Send + Sync, CK: Eq + Hash + Clone + Send + Sync, EA: CollectionExtract, diff --git a/crates/solverforge-scoring/src/stream/flattened_bi_stream/builder.rs b/crates/solverforge-scoring/src/stream/flattened_bi_stream/builder.rs index 3e84d471..ea106fdf 100644 --- a/crates/solverforge-scoring/src/stream/flattened_bi_stream/builder.rs +++ b/crates/solverforge-scoring/src/stream/flattened_bi_stream/builder.rs @@ -80,8 +80,8 @@ impl > where S: Send + Sync + 'static, - A: Clone + Send + Sync + std::fmt::Debug + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + std::fmt::Debug + 'static, + B: Send + Sync + 'static, C: 'static, K: Eq + Hash + Clone + Send + Sync + 'static, CK: Eq + Hash + Clone + Send + Sync + 'static, diff --git a/crates/solverforge-scoring/src/stream/group_by_penta.rs b/crates/solverforge-scoring/src/stream/group_by_penta.rs index 2be80e78..62ca3ef2 100644 --- a/crates/solverforge-scoring/src/stream/group_by_penta.rs +++ b/crates/solverforge-scoring/src/stream/group_by_penta.rs @@ -13,11 +13,11 @@ impl super::cross::Penta where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, - D: Clone + Send + Sync + 'static, - E: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, + D: Send + Sync + 'static, + E: Send + Sync + 'static, EA: 'static, EB: 'static, EC: 'static, diff --git a/crates/solverforge-scoring/src/stream/group_by_quad.rs b/crates/solverforge-scoring/src/stream/group_by_quad.rs index b51b58c6..cab47a94 100644 --- a/crates/solverforge-scoring/src/stream/group_by_quad.rs +++ b/crates/solverforge-scoring/src/stream/group_by_quad.rs @@ -12,10 +12,10 @@ impl super::cross::Quad where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, - D: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, + D: Send + Sync + 'static, EA: 'static, EB: 'static, EC: 'static, diff --git a/crates/solverforge-scoring/src/stream/group_by_tri.rs b/crates/solverforge-scoring/src/stream/group_by_tri.rs index 7fab594d..2a471ad6 100644 --- a/crates/solverforge-scoring/src/stream/group_by_tri.rs +++ b/crates/solverforge-scoring/src/stream/group_by_tri.rs @@ -11,9 +11,9 @@ type Row<'a, A, B, C> = Pair, Leaf<'a, B>>, Leaf<'a, C>>; impl super::cross::Tri where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, - C: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, + C: Send + Sync + 'static, EA: 'static, EB: 'static, EC: 'static, diff --git a/crates/solverforge-scoring/src/stream/grouped_stream/base.rs b/crates/solverforge-scoring/src/stream/grouped_stream/base.rs index b01f6487..ffb714a3 100644 --- a/crates/solverforge-scoring/src/stream/grouped_stream/base.rs +++ b/crates/solverforge-scoring/src/stream/grouped_stream/base.rs @@ -38,7 +38,7 @@ impl GroupedConstraintStream where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, K: Clone + Eq + Hash + Send + Sync + 'static, E: CollectionExtract, Fi: UniFilter, @@ -170,7 +170,7 @@ where Sc, > where - B: Clone + Send + Sync + 'static, + B: Send + Sync + 'static, EB: CollectionExtract, KB: Fn(&B) -> K + Send + Sync, D: Fn(&B) -> R + Send + Sync + 'static, @@ -197,7 +197,7 @@ where target: (EB, KB), ) -> super::joined::GroupedJoinedStream where - B: Clone + Send + Sync + 'static, + B: Send + Sync + 'static, EB: CollectionExtract + 'static, KB: Fn(&B) -> K + Send + Sync + 'static, { @@ -221,7 +221,7 @@ where default_fn: D, ) -> ComplementedConstraintStream where - B: Clone + Send + Sync + 'static, + B: Send + Sync + 'static, EB: CollectionExtract, KA2: Fn(&A) -> Option + Send + Sync, KB: Fn(&B) -> K + Send + Sync, diff --git a/crates/solverforge-scoring/src/stream/grouped_stream/joined.rs b/crates/solverforge-scoring/src/stream/grouped_stream/joined.rs index 71568ff3..e04b37bb 100644 --- a/crates/solverforge-scoring/src/stream/grouped_stream/joined.rs +++ b/crates/solverforge-scoring/src/stream/grouped_stream/joined.rs @@ -84,8 +84,8 @@ impl GroupedJoinedStream where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, K: Clone + Eq + Hash + Send + Sync + 'static, E: CollectionExtract + 'static, EB: CollectionExtract + 'static, @@ -217,8 +217,8 @@ impl GroupedJoinedBuilder where S: Send + Sync + 'static, - A: Clone + std::fmt::Debug + Send + Sync + 'static, - B: Clone + std::fmt::Debug + Send + Sync + 'static, + A: std::fmt::Debug + Send + Sync + 'static, + B: std::fmt::Debug + Send + Sync + 'static, K: Clone + Eq + Hash + Send + Sync + 'static, E: CollectionExtract + 'static, EB: CollectionExtract + 'static, diff --git a/crates/solverforge-scoring/src/stream/grouped_stream/weighting.rs b/crates/solverforge-scoring/src/stream/grouped_stream/weighting.rs index 3d90b543..808bd1bd 100644 --- a/crates/solverforge-scoring/src/stream/grouped_stream/weighting.rs +++ b/crates/solverforge-scoring/src/stream/grouped_stream/weighting.rs @@ -42,7 +42,7 @@ impl GroupedConstraintBuilder where S: Send + Sync + 'static, - A: Clone + std::fmt::Debug + Send + Sync + 'static, + A: std::fmt::Debug + Send + Sync + 'static, K: Clone + Eq + Hash + Send + Sync + 'static, E: CollectionExtract + 'static, Fi: UniFilter + 'static, diff --git a/crates/solverforge-scoring/src/stream/join_target.rs b/crates/solverforge-scoring/src/stream/join_target.rs index d618e7c3..f7db4b30 100644 --- a/crates/solverforge-scoring/src/stream/join_target.rs +++ b/crates/solverforge-scoring/src/stream/join_target.rs @@ -43,7 +43,7 @@ pub trait JoinTarget { impl JoinTarget for EqualJoiner where S: Send + Sync + 'static, - A: Clone + Hash + PartialEq + Send + Sync + 'static, + A: Hash + PartialEq + Send + Sync + 'static, E: CollectionExtract, F: UniFilter, K: Eq + Hash + Clone + Send + Sync, @@ -65,8 +65,8 @@ impl JoinTarget for (EB, EqualJoiner) where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, E: CollectionExtract, F: UniFilter, EB: CollectionExtract, @@ -104,8 +104,8 @@ macro_rules! impl_comparison_join_target { for (EB, $joiner) where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, E: CollectionExtract, F: UniFilter, EB: CollectionExtract, @@ -152,8 +152,8 @@ impl JoinTarget for (EB, OverlappingJoiner) where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, E: CollectionExtract, F: UniFilter, EB: CollectionExtract, @@ -185,8 +185,8 @@ where impl JoinTarget for (EB, AndJoiner) where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, E: CollectionExtract, F: UniFilter, EB: CollectionExtract, @@ -225,8 +225,8 @@ impl JoinTarget for (UniConstraintStream, P) where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, E: CollectionExtract, F: UniFilter, EB: CollectionExtract, diff --git a/crates/solverforge-scoring/src/stream/projected_stream/bi.rs b/crates/solverforge-scoring/src/stream/projected_stream/bi.rs index 37b58829..1d12a0d9 100644 --- a/crates/solverforge-scoring/src/stream/projected_stream/bi.rs +++ b/crates/solverforge-scoring/src/stream/projected_stream/bi.rs @@ -212,7 +212,7 @@ where impl UniConstraintStream where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, E: CollectionExtract, F: UniFilter, Sc: Score + 'static, diff --git a/crates/solverforge-scoring/src/stream/projected_stream/complemented_grouped.rs b/crates/solverforge-scoring/src/stream/projected_stream/complemented_grouped.rs index da39ada0..3c01ae10 100644 --- a/crates/solverforge-scoring/src/stream/projected_stream/complemented_grouped.rs +++ b/crates/solverforge-scoring/src/stream/projected_stream/complemented_grouped.rs @@ -195,7 +195,7 @@ impl where S: Send + Sync + 'static, Out: Send + Sync + 'static, - B: Clone + std::fmt::Debug + Send + Sync + 'static, + B: std::fmt::Debug + Send + Sync + 'static, K: Clone + Eq + Hash + Send + Sync + 'static, Src: Source + 'static, EB: CollectionExtract + 'static, diff --git a/crates/solverforge-scoring/src/stream/projected_stream/source/joined.rs b/crates/solverforge-scoring/src/stream/projected_stream/source/joined.rs index f949f4ce..81e150b9 100644 --- a/crates/solverforge-scoring/src/stream/projected_stream/source/joined.rs +++ b/crates/solverforge-scoring/src/stream/projected_stream/source/joined.rs @@ -133,8 +133,8 @@ impl Source for JoinedSource where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, - B: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, + B: Send + Sync + 'static, K: Eq + Hash + Clone + Send + Sync + 'static, EA: CollectionExtract, EB: CollectionExtract, diff --git a/crates/solverforge-scoring/src/stream/projected_stream/source/single.rs b/crates/solverforge-scoring/src/stream/projected_stream/source/single.rs index ee4b0b34..acbe03b3 100644 --- a/crates/solverforge-scoring/src/stream/projected_stream/source/single.rs +++ b/crates/solverforge-scoring/src/stream/projected_stream/source/single.rs @@ -26,7 +26,7 @@ impl SingleSource { impl Source for SingleSource where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, E: CollectionExtract, F: UniFilter, P: Projection, diff --git a/crates/solverforge-scoring/src/stream/quad_stream.rs b/crates/solverforge-scoring/src/stream/quad_stream.rs index dc224169..cbeb27a5 100644 --- a/crates/solverforge-scoring/src/stream/quad_stream.rs +++ b/crates/solverforge-scoring/src/stream/quad_stream.rs @@ -69,7 +69,7 @@ super::arity_stream_macros::impl_arity_stream!(quad, QuadConstraintStream, QuadC impl QuadConstraintStream where S: Send + Sync + 'static, - A: Clone + Hash + PartialEq + Send + Sync + 'static, + A: Hash + PartialEq + Send + Sync + 'static, K: Eq + Hash + Clone + Send + Sync, E: CollectionExtract, KE: super::key_extract::KeyExtract, diff --git a/crates/solverforge-scoring/src/stream/relational/operator/analysis.rs b/crates/solverforge-scoring/src/stream/relational/operator/analysis.rs index 98bf33c4..87b1161e 100644 --- a/crates/solverforge-scoring/src/stream/relational/operator/analysis.rs +++ b/crates/solverforge-scoring/src/stream/relational/operator/analysis.rs @@ -17,7 +17,7 @@ pub trait ExplainRow { /// `entities`, in row order. fn explain(&self, entities: &mut Vec); } -impl ExplainRow for Leaf<'_, T> { +impl ExplainRow for Leaf<'_, T> { fn explain(&self, entities: &mut Vec) { entities.push(EntityRef::new(self.entity)); } diff --git a/crates/solverforge-scoring/src/stream/tri_stream.rs b/crates/solverforge-scoring/src/stream/tri_stream.rs index c42893a4..814f4dfd 100644 --- a/crates/solverforge-scoring/src/stream/tri_stream.rs +++ b/crates/solverforge-scoring/src/stream/tri_stream.rs @@ -67,7 +67,7 @@ super::arity_stream_macros::impl_arity_stream!(tri, TriConstraintStream, TriCons impl TriConstraintStream where S: Send + Sync + 'static, - A: Clone + Hash + PartialEq + Send + Sync + 'static, + A: Hash + PartialEq + Send + Sync + 'static, K: Eq + Hash + Clone + Send + Sync, E: CollectionExtract, KE: super::key_extract::KeyExtract, diff --git a/crates/solverforge-scoring/src/stream/uni_stream/base.rs b/crates/solverforge-scoring/src/stream/uni_stream/base.rs index 71342b06..1f82a4d6 100644 --- a/crates/solverforge-scoring/src/stream/uni_stream/base.rs +++ b/crates/solverforge-scoring/src/stream/uni_stream/base.rs @@ -39,7 +39,7 @@ where impl UniConstraintStream where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, E: CollectionExtract, Sc: Score + 'static, { @@ -56,7 +56,7 @@ where impl UniConstraintStream where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, E: CollectionExtract, F: UniFilter, Sc: Score + 'static, @@ -70,7 +70,7 @@ where ) -> FlattenedCollectionTarget, Sc> where E: CollectionExtract, - B: Clone + Send + Sync + 'static, + B: Send + Sync + 'static, Flat: for<'a> Fn(&'a A) -> &'a Vec + Send + Sync, { FlattenedCollectionTarget { @@ -150,7 +150,7 @@ where impl UniConstraintStream where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, E: CollectionExtract, F: UniFilter, Sc: Score + 'static, @@ -204,7 +204,7 @@ impl std::fmt::Debug for UniConstraintStream CollectionExtract for UniConstraintStream where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, E: CollectionExtract, F: UniFilter, Sc: Score + 'static, diff --git a/crates/solverforge-scoring/src/stream/uni_stream/weighting.rs b/crates/solverforge-scoring/src/stream/uni_stream/weighting.rs index 0959278b..f589a749 100644 --- a/crates/solverforge-scoring/src/stream/uni_stream/weighting.rs +++ b/crates/solverforge-scoring/src/stream/uni_stream/weighting.rs @@ -13,7 +13,7 @@ use super::base::UniConstraintStream; impl UniConstraintStream where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, E: CollectionExtract, F: UniFilter, Sc: Score + 'static, @@ -94,7 +94,7 @@ where impl UniConstraintBuilder where S: Send + Sync + 'static, - A: Clone + Send + Sync + 'static, + A: Send + Sync + 'static, E: CollectionExtract, F: UniFilter, W: Fn(&A) -> Sc + Send + Sync, diff --git a/docs/constraints.md b/docs/constraints.md index 1cc4cbc2..924dd687 100644 --- a/docs/constraints.md +++ b/docs/constraints.md @@ -224,9 +224,10 @@ satisfied one. For analysis of a running job, see with the entities behind them. A grouped or complemented constraint reports one match per group whose weight is not zero, justified by the entities in the group (a complemented key without a group is justified by its target entity), -and the match scores add up to the constraint's score. Grouped and complemented -constraints therefore need entities that implement `Clone` and `Debug`, like -every other constraint. +and the match scores add up to the constraint's score. Each entity appears as +its type name and `Debug` rendering, so constraints need entities that +implement `Debug`; no constraint requires `Clone`, and analysis keeps no copy +of your entities. ## Runtime constraint weights diff --git a/docs/extend-scoring.md b/docs/extend-scoring.md index e2ee45af..50aa092b 100644 --- a/docs/extend-scoring.md +++ b/docs/extend-scoring.md @@ -96,8 +96,9 @@ unlocalized source and no rebuild fallback. side-table. Return the inverse retained score on retraction; do not recompute it from changed entities. Accumulate callbacks as `retract_delta + insert_delta`. Full evaluation and match counting are meaningful before initialization. -Explanation payload conversion is confined to the existing cold `EntityRef` -boundary. +Explanation is confined to the cold `EntityRef` conversion: a type name and +a `Debug` rendering per entity, no copy and no type erasure. Do not add a +`Clone` bound on entity types; no stream needs one. Runtime constraint weights never touch that signing step. A score director's weight mode is a type (`ScoreDirector`, `M` = `UnweightedMode`