Skip to content

Inventory planner: halving the largest record can reject a reachable target #83

Closed

Description

@iamalwaysuncomfortable

Raised in review of #82 (#82 (comment)).

The split loop in sdk/python/aleo/inventory/planner.py always halves the largest remaining record (usable // outputs_needed). In preserve mode this can reject a target that is reachable with a capacity-aware split:

  • Token amounts [9, 3], records=4, min_record_amount=3: the planner splits 9 into [4, 5], then tries [2, 3] and raises InventoryPlanError; [3, 6] followed by [3, 3] succeeds.
  • Credits: 20,003 microcredits can fund two 10,000 deductions and three outputs of 1, but the first halving leaves neither output able to fund the second split.

The loop is a line-for-line port of Veil's planner (packages/core/src/inventory/planner.ts), and the planner tests are Veil's known answers, so the fix should land in both SDKs together to keep plans identical for the same inventory. Choose split amounts that retain enough value for the remaining outputs and deductions, and add both cases to the planner tests.

Activity

  1. added a commit that references this issue on Oct 23, 2026
    16c057e
  2. iamalwaysuncomfortable commented on Oct 23, 2026

    @iamalwaysuncomfortable
    MemberAuthor

    Fixed on the PR #82 branch: the split now cuts whole lots when halving would strand value below the minimum. Both cases from this issue are planner tests. Veil's planner still halves unconditionally; a matching change there would keep the two SDKs' plans identical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions