Skip to content

Lazy apply_tbr_move rescore in tbr_search #38

Description

@ms609

Priority: P3 · Former status: PARKED (d7, other ) · Blocks:

Lazy apply_tbr_move rescore in tbr_search. After the score_fresh flag was wired (companion to T-187/PSF work), the trailing full_rescore at function exit is now skipped when states are coherent. The remaining redundancy is the full_rescore(tree, ds) call at ts_tbr.cpp:1134, run after every successful apply_tbr_move to obtain the authoritative score for the acceptance check. Each call is O(n_node × total_words). Since the move is local (clip + reroot + regraft), the indirect-evaluation pre-check at ts_tbr.cpp:767-772 already shows that fitch_incremental_downpass/uppass from the join point gives the correct score in O(affected_subtree_depth × total_words) instead. Plan: make apply_tbr_move push touched nodes onto the prealloc_undo stack, return the join node, and replace line 1134's full_rescore with fitch_incremental_downpass from that node. Estimated savings: O(n_char) per accepted move × ~10–100 accepted moves per replicate. Risk: medium — apply_tbr_move is the hot correctness-critical path; need careful unit tests covering NA/non-NA, IW/EW, constrained/unconstrained, equal-accept paths. Validate by comparing scores against current unconditional rescore on a battery of datasets before committing.


Migrated 2026-08-04 from the retired to-do.md; former task id T-300. Full original row: git show findings-md-final:to-do.md. Task state now lives in this tracker — see dev/red-team/migration-map.tsv for red-team ids.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in-progressBeing fixed; claiming comment names the branchtaskPlanned work migrated from the retired to-do.md

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions