hyf

Context-aware query service for Radroots
git clone https://radroots.dev/git/hyf.git
Log | Files | Refs | README | LICENSE

commit eaa48d4405bb27a3efda400051e8c385ae3d1595
parent 85eca288cda4daad3733327ebc525909757ffcd4
Author: triesap <tyson@radroots.org>
Date:   Mon, 21 Sep 2026 13:55:51 +0000

core: represent explicit partial-fulfillment outcomes

Diffstat:
Msrc/hyf_application/match_plan.mojo | 24++++++++++++++++++++++++
Mtests/test_application.mojo | 16++++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/src/hyf_application/match_plan.mojo b/src/hyf_application/match_plan.mojo @@ -109,3 +109,27 @@ def allocate_multiple_lines( def shared_lot_allows_concurrent_over_allocation() -> Bool: return False + + +@fieldwise_init +struct PartialOutcome(Copyable, Movable): + var fulfilled: Bool + var uncovered_value: Int + var permitted: Bool + + +def partial_outcome( + required_value: Int, allocated_value: Int, partial_allowed: Bool +) raises -> PartialOutcome: + if required_value < 0 or allocated_value < 0: + raise Error("partial outcome requires non-negative quantities") + if allocated_value >= required_value: + return PartialOutcome(fulfilled=True, uncovered_value=0, permitted=True) + var uncovered = required_value - allocated_value + return PartialOutcome( + fulfilled=False, uncovered_value=uncovered, permitted=partial_allowed + ) + + +def partial_discloses_deficit() -> Bool: + return True diff --git a/tests/test_application.mojo b/tests/test_application.mojo @@ -574,3 +574,19 @@ def test_conservation_across_multiple_demand_lines() raises: assert_equal(total, 50) assert_equal(len(plan_conservation_violations(plan, capacities)), 0) assert_true(not shared_lot_allows_concurrent_over_allocation()) + + +from hyf_application.match_plan import partial_outcome, partial_discloses_deficit + + +def test_explicit_partial_fulfillment_outcome() raises: + var full = partial_outcome(50, 50, False) + assert_true(full.fulfilled) + assert_equal(full.uncovered_value, 0) + var partial = partial_outcome(50, 30, True) + assert_true(not partial.fulfilled) + assert_equal(partial.uncovered_value, 20) + assert_true(partial.permitted) + var disallowed = partial_outcome(50, 30, False) + assert_true(not disallowed.permitted) + assert_true(partial_discloses_deficit())