Skip to content

fix(scoring): retract cascading list arrivals before their structure shadows change - #271

Closed
blackopsrepl wants to merge 1 commit into
mainfrom
fix/cascade-arrival-rows
Closed

blackopsrepl wants to merge 1 commit into
mainfrom
fix/cascade-arrival-rows

Conversation

@blackopsrepl

Copy link
Copy Markdown
Collaborator

Bug

With a cascading list shadow, refresh_cascading_owner called update_list_structure_shadows before retracting the rows of elements that arrived from no list. By the time an arrival's row was retracted, its inverse, previous and next fields already held the new values. A constraint reading any of those fields retracted a different score from the one it inserted, so the incremental score drifted from a fresh one.

The refresh without a cascading shadow (refresh_owner) already retracts arrivals before rewriting shadows. This change makes the cascading refresh do the same.

Found in the SolverForge Workbench task scheduling model. Under environment_mode = "full_assert" its first construction step drifted: incremental 1000hard/-498medium, fresh 0hard/-497medium. A rule there charges an untimed task on a resource differently from a task in no list.

Change

  • crates/solverforge-scoring/src/director/score_director/list_shadows.rs: retract arrivals from no list, then refresh the list structure and insert the owner row.
  • crates/solverforge-scoring/src/director/tests/cascading_shadows.rs: the cost now charges an unset start differently in no list (1000) and on a machine (5000). Without the fix, a_task_pushed_later_on_the_saw_retimes_its_milling_on_the_mill and random_moves_and_undos_on_three_machines_keep_the_score_fresh fail by exactly 4000 per arrival. With the fix, both pass.

Performance

Only the PlanningSolution::HAS_CASCADING_SHADOWS branch changes: the same calls run, in a different order. Solutions without a cascading shadow never reach this code.

Checks

  • make lint: fmt, clippy, doc names, file length, facade reachability, public API, deps.
  • cargo test --workspace --no-fail-fast.

…shadows change

With a cascading shadow, an owner's refresh rewrote the inverse, previous and next fields of every element it held before retracting the rows of elements that arrived from no list. A constraint reading any of those fields retracted a different score from the one it inserted, and the incremental score drifted from a fresh one. Arrivals are now retracted first, as the non-cascading refresh does.

The director test's cost now tells an unset start in no list from one on a machine, which fails without the fix.
@blackopsrepl

Copy link
Copy Markdown
Collaborator Author

Zero-regression gate — 51efc69a vs 147011d9 (main = v0.30.0): passed (EXIT 0)

14 cases, 5 layouts, 51 trials. semantic_match on every case: True.

  • wall: -3.56% … +2.29%
  • instructions: -0.01% … +0.04%
  • allocations: +0.00% … +0.00%
  • allocated bytes: +0.00% … +0.00%
  • simulated D1 misses: -0.46% … +4.54%
  • simulated LL misses: -0.09% … +0.02%

Evidence: zr-pr271-51efc69a-vs-147011d9/report.json.

@blackopsrepl

Copy link
Copy Markdown
Collaborator Author

Landed on main as 25f3442 (rebase of 51efc69, identical tree; gate passed above). GitHub's merge call returned 502 and left this PR open, so it is closed by hand.

@blackopsrepl
blackopsrepl deleted the fix/cascade-arrival-rows branch November 16, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant