]> git.hungrycats.org Git - bees/commitdiff
plan: reject impossible coverings before the search
authorZygo Blaxell <bees@furryterror.org>
Thu, 24 Sep 2026 03:17:06 +0000 (23:17 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sun, 11 Oct 2026 00:48:00 +0000 (20:48 -0400)
Every data region needs at least one dedupe or copy edge, since a copy
run never crosses the hole between regions, and every hole is already
one op.  When that floor exceeds rewrite.total-max no covering exists,
but the search only found out after walking the whole extent, which is
O(V^2) in its boundary count.

With total-max = 10, a reference run on a disk-image corpus counted
582,604 searches ending with no covering under the limit (270 at
total-max = 100).  Check the floor up front and count the rejection the
same way.

Assisted-by: Claude-Code:claude-opus-5-5
src/bees-plan.cc

index 539bc73e22678e53fe7a4fd6acc8061b050be3c2..5da9eec5875ca95e8a8755061472d234ae5b382b 100644 (file)
@@ -398,6 +398,15 @@ scan_next_plan_shortest_path(const PlanSearchInputs &in,
                return nullopt;
        }
 
+       // Op floor: every data region needs at least one dedupe or copy edge (a
+       // copy run never crosses the hole between regions), and every hole is
+       // already one op.  If that floor exceeds total-max no covering exists,
+       // so say so now instead of discovering it after an O(V^2) walk.
+       if (in.m_data_regions.size() + in.m_hole_ops > policy.m_total_max) {
+               BEESCOUNT(plan_cover_none_limit);
+               return nullopt;
+       }
+
        // V-budget: the exact DP below is O(V^2) in the boundary count and holds
        // the dst Exclusion for its whole duration, so a high-V extent can wedge a
        // worker (and everything queued behind that extent).  Above the budget,