hyf

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

commit b70d7d4e2c9e5312840fd8598deb4502250a550d
parent 67a479d55d4bc9212287a430505cab81e794306a
Author: triesap <tyson@radroots.org>
Date:   Mon, 21 Sep 2026 15:01:02 +0000

core: measure candidate and plan resource envelopes

Diffstat:
Asrc/hyf_application/resource_envelope.mojo | 36++++++++++++++++++++++++++++++++++++
Mtests/test_soak.mojo | 14++++++++++++++
2 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/src/hyf_application/resource_envelope.mojo b/src/hyf_application/resource_envelope.mojo @@ -0,0 +1,36 @@ + + +@fieldwise_init +struct ResourceEnvelope(Copyable, Movable): + var max_candidates: Int + var max_plans: Int + var max_state_bytes: Int + var max_questions: Int + var max_provider_calls: Int + + +def default_resource_envelope() -> ResourceEnvelope: + return ResourceEnvelope( + max_candidates=64, + max_plans=8, + max_state_bytes=4096, + max_questions=32, + max_provider_calls=4, + ) + + +def within_envelope( + envelope: ResourceEnvelope, + candidates: Int, + plans: Int, + state_bytes: Int, + questions: Int, + provider_calls: Int, +) -> Bool: + return ( + candidates <= envelope.max_candidates + and plans <= envelope.max_plans + and state_bytes <= envelope.max_state_bytes + and questions <= envelope.max_questions + and provider_calls <= envelope.max_provider_calls + ) diff --git a/tests/test_soak.mojo b/tests/test_soak.mojo @@ -36,3 +36,17 @@ def test_bounded_process_soak_200_frames() raises: def main() raises: TestSuite.discover_tests[__functions_in_module()]().run() + + +from hyf_application.resource_envelope import ( + default_resource_envelope, + within_envelope, +) + + +def test_candidate_and_plan_resource_envelope() raises: + var envelope = default_resource_envelope() + assert_true(within_envelope(envelope, 10, 2, 100, 5, 1)) + assert_true(not within_envelope(envelope, 1000, 2, 100, 5, 1)) + assert_true(not within_envelope(envelope, 10, 100, 100, 5, 1)) + assert_true(not within_envelope(envelope, 10, 2, 100000, 5, 1))