Skip to content

feat(solver): report the resolved solver policy in final telemetry - #260

Merged
blackopsrepl merged 1 commit into
mainfrom
feat/resolved-policy-telemetry
Nov 13, 2026
Merged

blackopsrepl merged 1 commit into
mainfrom
feat/resolved-policy-telemetry

Conversation

@blackopsrepl

Copy link
Copy Markdown
Collaborator

First of the four PRs for #253 (diagnostics before any policy change). Solver behaviour is unchanged.

What changes

  • SolverTelemetry::resolved_phase_plan (new public field). The compiled runtime already resolved the exact phase plan at solve end but only published it into an enabled candidate trace. Every compiled solve now reports it in final telemetry; it is None before the solve ends.
  • Construction reason. Each default construction step names the model declaration that chose it: savings_hooks_declared, precedence_construction_order_and_ownership_declared, precedence_and_construction_order_declared, no_specialized_list_policy_declared, required_assignments_remain, only_optional_assignments_remain, scalar_slot_outside_assignment_groups, route_hooks_declared_and_route_non_empty.
  • Default local search adds weighting (equal) and excluded_families: each family a slot did not receive and the capabilities it was missing, e.g. nearby_list_change@...:missing=cross_position_distance.
  • Every local-search node adds forager_accepted_count_limit, the effective horizon. An omitted forager on a list model reports 256; an explicit accepted_count with no limit reports 1.
  • Docs. docs/configuration.md adds the default construction table, the acceptor/forager table per model shape, and the omitted-vs-explicit component contract. docs/running-solves.md describes the field. Solver wireframe and public-api.txt are updated.

Verification

  • resolved_policy_telemetry.rs (facade integration, 3 tests):
    • A default CVRP solve without candidate tracing reports a complete plan with Clarke-Wright, reason savings_hooks_declared, Late Acceptance, accepted count 256, equal weighting and stratified-random order.
    • An explicit local-search phase with an omitted forager reports default:AcceptedCount { limit: 256 } and limit 256.
    • An explicit accepted_count forager without limit reports limit 1.
  • Compiler tests:
    • Typed and dynamic CVRP, JSSP and plain list slots report the construction reason that selected them.
    • The full-capability CVRP slot excludes only the precedence bundle (missing=precedence); the reduced dynamic slot lists each missing capability.
    • The terminal trace carries the reasons.
  • make pre-release and make examples pass.
  • Zero-regression gate vs main (6ffcacab): result posted below.

Refs #253

The compiled runtime already resolved an exact phase plan at the end of
every solve, but published it only into an enabled candidate trace. It now
also lands in SolverTelemetry::resolved_phase_plan for every compiled
solve, so the policy a solve actually ran is visible without tracing.

The plan gains what #253 asks diagnostics to explain:
- default construction steps carry the model declaration that selected
  them (reason = savings_hooks_declared, required_assignments_remain, ...);
- the default local-search node carries its family weighting and the
  families each slot did not receive with the capabilities they lacked
  (excluded_families = family@slot:missing=...);
- every local-search node carries its effective accepted-count horizon,
  which separates an omitted forager (the default policy's 256 on list
  models) from an explicit accepted_count without a limit (1); tabu without
  a forager and variable neighborhood descent report none.

An explicit phase's horizon is resolved from the lowered phase when the
plan is published, not while compiling the runner: an extra attribute
built at compile time grew one cold allocation by 48 bytes, which moved
the heap layout of the hot neighborhood loops (gate: scalar_change
simulated D1 misses +10.8%, list_swap LL +5.9%, with equal instructions
and allocation counts). Compiling a runner allocates exactly as before.

docs/configuration.md documents the default construction choice, the
acceptor and forager per model shape, and the omitted-versus-explicit
component contract; tests pin each of them. Solver behaviour is
unchanged.

Refs #253
@blackopsrepl
blackopsrepl force-pushed the feat/resolved-policy-telemetry branch from 998966e to 82e0e04 Compare November 13, 2026 17:39
@blackopsrepl

Copy link
Copy Markdown
Collaborator Author

Zero-regression gate — first run failed; cause found and fixed

The run for 998966e5 against main 6ffcacab failed. The moves were identical in every case (semantic_match), and instructions and allocations were unchanged.

case metric delta
scalar_change simulated D1 misses +10.81%
scalar_change simulated LL misses +7.54%
list_swap simulated LL misses +5.90%

Cause: heap layout, not new work in the hot loop.

  • Struct sizes and the graded allocation counts and bytes were unchanged.
  • A malloc trace (valgrind --trace-malloc) of the compile step showed the difference: the new forager_accepted_count_limit attribute was built while compiling the runner. That grew one cold Vec from 192 to 240 bytes and added two short strings. This moved where the hot neighborhood loop's objects sit in the heap relative to each other.
  • Taking that one attribute out of the compile step brings Cachegrind back to main's numbers on both failing cases.
  • A uniform heap pad changes nothing, so the effect depends on where objects sit relative to each other, not on one buffer's offset.

Fix (amended into this PR's single commit): an explicit phase's horizon is now worked out from the lowered phase when the plan is published (runner/phase_plan.rs). Compiling a runner allocates exactly as on main.

  • The resolved plan has the same content as before.
  • Variable neighborhood descent now reports none instead of inheriting the default 256.
  • Two new final-telemetry tests cover implicit tabu and VND. The VND test fails on the previous commit.

Cachegrind smoke, main vs the fixed commit, at the gate's iteration counts:

case D1mr DLmw
scalar_change 101,402 → 101,389 9,494 → 9,504
list_swap 236,886 → 236,800 118,849 → 118,849

The qualifying run on the amended commit follows below.

Zero-regression gate — 82e0e043 vs main 6ffcacab: passed (EXIT 0)

14 cases, 5 layouts, 51 trials. Every case semantic_match, allocations identical.

  • wall −0.95% … +1.03%
  • instructions −0.00% … +0.01%
  • simulated D1 misses −0.52% … +0.35% (scalar_change +0.06%)
  • simulated LL misses −0.01% … +0.71% (list_swap +0.01%)

Evidence: zr-pr5b-82e0e043-vs-6ffcacab/report.json.

@blackopsrepl
blackopsrepl merged commit dc34520 into main Nov 13, 2026
7 checks passed
@blackopsrepl
blackopsrepl deleted the feat/resolved-policy-telemetry branch November 13, 2026 19:54
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