perf(prune-reinsert): exact directional insertion scorer (last Wagner-fix sharer) + regime-soundness tests - #263
Merged
Merged
Conversation
… + Δ-probe expand_and_reinsert (T-266, 2026-03-27) used the union-of-finals fitch_indirect_length_bounded approximation that the June directional fix (#26/#27) replaced everywhere else — it was MISSED. Port it to the exact edge_set scorer, mirroring ts_wagner.cpp:487: - per-tip compute_insertion_edge_sets (prelim is current via wagner_incremental_rescore) + fitch_indirect_length_cached per edge. Also a gated, non-perturbing -DTS_SCOREAPPROX_PROBE oracle that tallied Δ = exact_cost(E_bounded) − min_E exact_cost(E) per placement. On Zanol (forced pruneReinsertCycles): bounded chose strictly-worse edges in ~62% of placements, mean ~6 steps, ~48% greedy-regret SHARE. After the port the probe reports Δ=0 at every placement (production == exact argmin). NOTE: this is greedy-regret SHARE, not realizable wall-clock — prune_reinsert auto-enables ONLY at nTip>=120 (`large` preset); NO mission dataset reaches 120t (max=88). So this path runs on zero default mission searches. Land + time-matched A/B (NNI-polish `large` preset, ≥120t) is COMPOSITION-gated (#40). Worktree-only; NOT for cpp-search until composition. Tests: prune-reinsert 44/0, drift 22/0, ratchet 17/0, tbr 28/0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…-search data race Post-review hardening of the exact-directional scorer port. The -DTS_SCOREAPPROX_PROBE diagnostic block's function-local `static` counters (sa_placements/sa_delta_*/sa_*_exact_sum) are mutated with no synchronization, but expand_and_reinsert runs concurrently on parallel-search workers — an unsynchronised data race (adversarial review, CONFIRMED low). thread_local gives each worker its own tally (per-thread partials under multithreading; exact for the single-threaded diagnostic runs this probe is intended for). Production (probe undefined) is byte-identical and unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…w coverage gap) Adversarial review of the exact-directional scorer port found no prior test drove expand_and_reinsert on NA (inapplicable) or IW (implied-weights) data, nor asserted score self-consistency in any regime — yet prune_reinsert_search runs on both (its guard only early-returns for PROFILE/HSJ/XFORM). The port is a ranking-only construction heuristic; the accepted tree is gated by a regime-correct score_tree() (strict-improve + revert), so the REPORTED best_score must equal an independent length recompute of the RETURNED tree in every regime. Adds two tests (Vinther2008, 23t, forced pruneReinsertCycles=3): NA-EW and IW (concavity=3) — each asserts result$best_score == ts_fitch_score(returned tree). Both green. Empirically confirms the port cannot corrupt the accepted tree on NA/IW (mirrors the ts_wagner.cpp all-regime convention, not the ts_tbr.cpp guard). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ms609
force-pushed
the
claude/scoreapprox-land
branch
from
July 3, 2026 13:02
6b378f0 to
98122e5
Compare
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.
Exact-directional insertion scorer in
expand_and_reinsert(last Wagner-fix sharer)Completes the June Wagner insertion-cost fix (
2b299e4b, #26/#27).expand_and_reinsert(taxon prune-reinsert, T-266) was the one sharer missed by that migration: it still
scored candidate insertion edges with the union-of-finals approximation
(
fitch_indirect_length_bounded), which undercounts insertion cost. This routes it throughthe exact directional edge-set scorer (
compute_insertion_edge_sets+fitch_indirect_length_cached), mirroringts_wagner.cpp.A gated
-DTS_SCOREAPPROX_PROBEΔ-oracle (off by default, byte-identical when undefined)measured the pre-port cost on Zanol: the bounded path chose a strictly-worse edge on ~62% of
placements (mean ~6 steps); after the port Δ=0 at every placement (production == exact argmin).
Prune-reinsert auto-enables at nTip ≥ 120 (
largepreset,pruneReinsertCycles=5), so thispath runs on the large-dataset tail of the corpus (up to ~4000 tips) — where wall-clock is
largest and least characterised.
Commits
42a1f021) — the bounded→exact swap + Δ-probe (original, June worktree).0307f4e8) —thread_localthe probe's static accumulators (parallel-search data race, review-confirmed low, diagnostic-only).6b378f0d) — NA + IW score-soundness regression tests (close the review coverage gap).Validation
cutoff/argmin, probe-gating, coverage): 0 soundness bugs. Regime-safety CONFIRMED safe — the
port correctly follows the
ts_wagner.cppall-regime convention (ranking-only constructionheuristic, corrected by a regime-correct
score_tree()accept gate), not thets_tbr.cppew_directionalguard convention; on NA it swaps one NA-blind heuristic for another and cannotcorrupt the accepted tree. Bounds, prelim-currency, cutoff/argmin equivalence and
twstride allverified safe.
cpp-searchtip; targeted suites green on the freshly built DLL:prune-reinsert (incl. new NA/IW), tbr-search, tbr-symmetry, wagner, wagner-quality, drift, ratchet — 0 failures.
result$best_score == ts_fitch_score(returned tree)under NA-EW and IW(concavity=3) with forced
pruneReinsertCycles— the score-soundness invariant no prior test checked.Scope / safety
sibling Wagner builder; accepted tree always gated by regime-correct
score_tree()→ cannot alterfinal reported score. Default (probe-undefined) production path behaviour on EW ≤120t is unchanged
except that placement edges may now be chosen exactly.
post-merge confirmation (also a BGS-recipe-tuning input); neither is a correctness gate — the code
path is scale-invariant and statically proven.
🤖 Generated with Claude Code