Repository navigation
feat(scoring): report planning ids in constraint matches - #267
Merged
Merged
Conversation
Every entity in a constraint match now carries its planning id when its type has one, so callers can look the blamed record up by id instead of parsing its Debug rendering. EntityRef gains `planning_id: Option<String>`: the `#[planning_id]` field rendered with Display when the id type implements it, otherwise with Debug, and None for an id type with neither. Entities streamed from planning-model entity and fact collections report it; list elements and hand-built sources report None, and stream elements need no new bound. Generated entity and fact accessors return SourceExtract<_, ModelPlanningIds> through the hidden `model_source`, which reads the AnalysisPlanningId the macros implement for every annotated type. CollectionExtract gains a provided `planning_id` method. Explanation moves from the row view to the operator (ExplainOperator with a RowOrigin), because the operator owns the source that renders the id. Projected rows are now justified by the entities they were projected from. Ids are read only in get_matches and detailed analysis, never while scoring; the group view drops two fields only explanation used. Closes #265 BREAKING CHANGE: EntityRef has a new public field `planning_id`, so struct literals must set it (or use EntityRef::new(..).with_planning_id).
Collaborator
Author
Zero-regression gate —
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #265.
What
EntityRef::planning_id: Option<String>: the record's#[planning_id]rendered withDisplaywhen the id type implements it (7,anna), otherwise withDebug(a tuple-struct id renders as ShiftId(7)), andNonefor an id type with neither. Set for entities from planning-model entity and fact collections;Nonefor list elements and hand-built sources. No new bound on stream elements.AnalysisPlanningIdfor every#[planning_entity]/#[problem_fact]type. Generated entity/fact accessors returnSourceExtract<_, ModelPlanningIds>(zero-sized type parameter) via hiddenmodel_source;CollectionExtractgains a providedplanning_idmethod (defaultNone).ExplainRow) to the operator (ExplainOperator+RowOrigin), because the operator owns the source that renders the id. Each operator maps a retained handle or an evaluation to its input rows, the same way its provenance already does.Cold path only
Ids are read only in
get_matches/ detailed analysis. No scoring code reads them, and nothing is allocated in scoring. The one scoring-side layout change:GroupViewdrops two pointer fields (input,solution) that only explanation used. The zero-regression gate result will be posted below.Tests
tests/planning_id_constraint_analysis.rs, macro-derived entity and facts across filter, join, group_by, complement and projection, plus a fact without a planning id; before and after initialization; match scores sum to each constraint score.constraint/tests/planning_id_analysis.rscovers filter, plain source (None), self-join, cross join, existence, flatten, group+complement, on the evaluation path, the retained path and after a move.grouped_analysis.rsadds shared-terminal ids. Projected analysis now asserts owners. Rendering unit tests cover Display / Debug / neither.Found along the way
#266: uni
group_by(..).complement(..)drops the stream's filter. It is a separate bug and gets its own fix.Verification
cargo test --workspace --all-features --no-fail-fast: 69 suites, 0 failurescargo clippy --workspace --all-targets --all-features -- -D warnings: cleanmake pre-release,make examples: see the chain log