Skip to content

fix(plan-selection): reject an unpriceable candidate in the reference pricer (#1067) - #1164

Merged
milindsrivastava1997 merged 1 commit into
mainfrom
fix-planner-timing-flakes
Nov 3, 2026
Merged

milindsrivastava1997 merged 1 commit into
mainfrom
fix-planner-timing-flakes

Conversation

@milindsrivastava1997

@milindsrivastava1997 milindsrivastava1997 commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #1067. The test-only reference pricer failed a whole selection on a candidate the search rejects.

Why

planner_layering_example2::production_memo_selects_a_validated_example2_plan failed intermittently in CI with plan selection selects: Cost { candidate: "E17-0", node: 4, error: Overflow } (#1166 now ignores it). The search rejects a candidate whose cost overflows (cost_not_representable); the reference pricer, which prices every memo choice of the selected round for tests and stage_pipeline's reference_pricing, returned the error instead. Which round is selected depends on timing, so the failure appeared only when that round held such a candidate.

What

The reference pricer rejects a candidate whose cost overflows, with the new RejectionCause::CostNotRepresentable, and selects among the rest.

How

select_among_plans skips an overflowing candidate when fitting the calibration and, when offering it, records a CostNotRepresentable rejection instead of returning ErrorSelectingPlan::Cost. The search's own overflow handling and PlanSelector::offer_before are unchanged.

Key code interfaces added / modified

crates/plan-selection/src/report.rs — RejectionCause stays, gains one variant:

pub enum RejectionCause {
    AccuracyTargetMissed,                 // unchanged
    CountMinWeightsNotProvenNonNegative,  // unchanged
    NoAccuracyGuarantee,                  // unchanged
    LatencyBoundExceeded,                 // unchanged
    LatencyOverRepeatInterval,            // unchanged
    OverClusterCapacity,                  // unchanged
    /// Its cost overflows the cost model's arithmetic, so it cannot be
    /// priced. Written by the reference pricer; a failed check.
    CostNotRepresentable,                 // new
    Costlier,                             // unchanged
    Slower,                               // unchanged
    MoreMemory,                           // unchanged
    TiedLostOnEnumerationOrder,           // unchanged
    Infeasible,                           // unchanged
}

Serialized as cost_not_representable; added to the DAG viewer's failed-check causes, its README, the stage_pipeline output docs and asap-aware-mapping-contracts.md.

Major algorithm changes

None.

Before this PR

When the selected round held a candidate whose cost overflows, the reference pricer returned Err(Cost { .. Overflow }), failing tests that read it (and stage_pipeline's reference pricing), although the search had rejected that candidate.

After this PR

That candidate is listed under the reference's rejections with cause cost_not_representable; selection among the rest proceeds.

Evidence

the_reference_pricer_rejects_an_unpriceable_candidate fails on main (the selection errors instead of returning NoValidCandidate) and passes with the fix. The CI failure itself is timing-dependent and not reproduced.

Verification

  • Unit tests: plan-selection tests::the_reference_pricer_rejects_an_unpriceable_candidate — candidates whose cost overflows are each rejected as CostNotRepresentable, not a selection failure.
  • End-to-end tests: devtools viewer_contract (2) and tools/dag-viewer stages.test.mjs (19) pass. Full workspace suite not run locally; relying on CI.
  • Other checks: workspace clippy -D warnings (CI's flags), fmt.

Snapshot changes

None.

Architectural decisions

Limitations and follow-up

Human review — do not complete with an agent

  • The MVP boundary is correct.
  • New conceptual layers or public interfaces are necessary.
  • The before/after description matches the intended product behavior.
  • Human reviewer:
  • Decision and rationale:

🤖 Generated with Claude Code

… pricer

The search rejects a candidate whose cost overflows (cost_not_representable),
but the test-only reference pricer failed the whole selection on it. Which
round the search selects depends on timing, so planner_layering_example2's
production_memo_selects_a_validated_example2_plan failed whenever the
selected round held such a candidate. The reference pricer now rejects it
with the new RejectionCause::CostNotRepresentable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milindsrivastava1997 milindsrivastava1997 changed the title fix(plan-selection): keep earlier rounds on a preparation timeout; reject unpriceable reference candidates (#1067) fix(plan-selection): reject an unpriceable candidate in the reference pricer (#1067) Nov 2, 2026
@milindsrivastava1997
milindsrivastava1997 merged commit c7d5071 into main Nov 3, 2026
3 of 4 checks passed
@milindsrivastava1997
milindsrivastava1997 deleted the fix-planner-timing-flakes branch November 3, 2026 02:01
zzylol added a commit that referenced this pull request Nov 3, 2026
… selector (main build after #1164 and #1187)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
milindsrivastava1997 added a commit that referenced this pull request Nov 3, 2026
…ector.rs

#1164 imports crate::AnalyticalCostError, which #1187 moved into lib.rs's
test module; the two merged in that order, so main does not compile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol added a commit that referenced this pull request Nov 3, 2026
…y and cost exactly (#1185, part 1) (#1188)

* fix(plan-selection): run the group selection MILP to proven optimality and cost exactly (#1185)

The group selection MILP stopped at wall-clock deadlines and costed some
candidates inexactly past hardcoded caps, so the selected plan depended on
machine speed and could differ from the optimum of the model.

Deadlines removed:
- select_plan no longer takes a deadline; the facade stops passing one
  (its own round budgets and the Pass 2 deadline are unchanged).
- The warm start has no time budget: it tries workload order, its reverse
  and MORE_ORDERS pseudo-random orders, every run.
- No per-part time split and no HiGHS time_limit: every part is solved to
  proven optimality. Any HiGHS status other than Optimal or Infeasible is
  a solver error.
- Deleted WARM_START_MOST_TIME, MOMENT_TO_READ_THE_START_S, LP_TIME_LIMIT_S
  (the LP diagnosis's LPs and one-node root solve end on their own),
  SelectionMilpStatus, SelectionMilpError::{DeadlineReached, NoSolution},
  SearchStatus::DeadlineReached, ErrorSelectingPlan::NoPlanByDeadline and
  the solution's relative_gap (always 0 now).

Caps removed (every combination is costed and encoded exactly):
- MAX_CONTEXTS, MAX_PRODUCER_CHOICES and UsageContext::TooManyContexts.
- MAX_WINDOW_KINDS: every union of a scan run's window kinds is costed
  and encoded with exact indicators; the widest-window fallback is gone.
- MAX_COMPOSITIONS: every composition is built and checked, so no set of
  approximate candidates is marked NotChecked for its size.

HiGHS threads are now SelectionMilpOptions::highs_threads, default 1
(was 4), so ties between plans of equal cost break the same way.

Snapshot changes: only the search status. o11y_bench q05, q19, q25 and
the sketch workloads shared-quantiles-1h-mvp and quantile-single-mvp
used to stop at the time limit with the optimal plan; they are now proven
optimal (proven_optimal true, search_status optimal). Plans and costs
are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(plan-selection): guard window-union enumeration against shift overflow; update deadline docs (review)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(plan-selection): name why candidates could not be costed when the selection MILP is infeasible

The dag-viewer test test_a_plan_without_a_rate_fact_names_the_missing_fact
failed on main since the group MILP became the default: candidates whose
usage asap-cost could not price (e.g. a source without an arrival rate)
were left out silently and the error said only 'infeasible'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(plan-selection): import AnalyticalCostError from asap-cost in the selector (main build after #1164 and #1187)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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