Redefine: the reply reports the features it rebuilt (#5694) (#8244)

* claim: #5694

* Redefine: the reply reports the features it rebuilt (#5694)

timeline.redefine builds the edited feature and the features after it in its trial session;
the session's own evaluation then only takes those results from what the trial kept, so the
reply reported that second evaluation and read as "nothing was rebuilt" although the geometry
changed. Report the trial's rebuild, plus anything the session still had to compute itself, as
timeline.edit reports the same change; `restored` keeps counting only genuine reuse of earlier
results.

Tests: redefining_reports_the_features_it_rebuilt fails before the change with
{"feature": 2, "recomputed": 0, "restored": 2} and passes after it;
redefining_computes_the_later_features_once still guards the single computation (the reply
doubles if the kept results are lost).
This commit is contained in:
Colin Faulkingham
2026-10-28 14:02:44 +00:00
committed by GitHub
parent 5f90d06452
commit 84016f036e
2 changed files with 29 additions and 3 deletions
+8 -1
View File
@@ -1670,6 +1670,11 @@ fn redefine(s: &mut Session, p: &Value) -> Result<Value> {
if let Some(e) = trial.model.result(id).and_then(|r| r.error.clone()) {
return Err(EngineError::Other(e));
}
// What this edit rebuilt: the trial computed the edited feature and the features after it. The
// session's evaluation below only takes those results from what the trial kept, so its own
// counters read as "nothing was rebuilt" (#5694).
let rebuilt = trial.model.last_recomputed;
let reused = trial.model.last_restored;
let original_ids: std::collections::BTreeSet<u64> = s.doc.features.iter().map(|feature| feature.id).collect();
let added_ids: std::collections::BTreeSet<u64> =
trial.doc.features.iter().filter(|feature| !original_ids.contains(&feature.id)).map(|feature| feature.id).collect();
@@ -1711,7 +1716,9 @@ fn redefine(s: &mut Session, p: &Value) -> Result<Value> {
if let Some(e) = s.model.result(id).and_then(|r| r.error.clone()) {
return Err(EngineError::Other(e));
}
Ok(json!({"feature": id, "recomputed": s.model.last_recomputed, "restored": s.model.last_restored}))
// Report the trial's rebuild, plus anything the session still had to compute itself (a kept
// result its budget dropped); `s.model`'s own counters would only report the reuse (#5694).
Ok(json!({"feature": id, "recomputed": rebuilt + s.model.last_recomputed, "restored": reused}))
}
fn dependents(s: &mut Session, p: &Value) -> Result<Value> {