Skip to content

fix(budget): enforce active gating to prevent token and runtime overruns. - #109

Closed
MASTER870-CMD wants to merge 2 commits into
sapientinc:mainfrom
MASTER870-CMD:fix/budget-enforcement-gate
Closed

MASTER870-CMD wants to merge 2 commits into
sapientinc:mainfrom
MASTER870-CMD:fix/budget-enforcement-gate

Conversation

@MASTER870-CMD

Copy link
Copy Markdown
Contributor

Resolves #81

Overview
The budget ledger previously operated purely as a post-mortem audit log, allowing unchecked resource exhaustion before flagging an overrun. This PR shifts the ledger to an active pre-admission gate, strictly enforcing budget ceilings during the BudgetedActionGuard initialization to eliminate unbounded cost exposure.

Technical Implementation

Implemented a get_exhausted_units check prior to peer admission to halt execution the moment cumulative tokens or wall-clock limits are breached.

Ensured in-flight tasks gracefully drain their runtime usage via finish() while safely and immediately blocking new model calls.

Hardened the test suite for cross-platform stability by safely handling Unix-only modules (fcntl, os.killpg, pty, socketserver.ThreadingUnixStreamServer), ensuring robust local testing and CI passes on Windows environments.

Validation

Successfully executed the full resource guard and budget test suite locally.

100% pass rate across all 39 budget enforcement contracts and workflow loops.

@MASTER870-CMD

Copy link
Copy Markdown
Contributor Author
Screenshot 2026-09-02 112557 image

Execution verified. Attached are the results confirming the active pre-admission gate implementation.

Cross-platform stability achieved: Patched OS-dependent Unix libraries (fcntl, os.killpg, pty) to ensure the test suite runs cleanly on Windows without impacting upstream Linux CI.

Validation: 100% pass rate across all 39 resource guard and budget enforcement contracts.

Ready for review.

@MASTER870-CMD
MASTER870-CMD force-pushed the fix/budget-enforcement-gate branch from 6c61fa6 to 69420ba Compare September 2, 2026 06:49
@electrixoul

Copy link
Copy Markdown
Collaborator

Thank you, @MASTER870-CMD, for contributing the active budget-admission fix.

We transferred the functional budget-gating change into validation/budget-and-cost-accounting, where it is integrated with provider cost accounting while preserving existing compatibility: approved token and runtime budgets now gate subsequent actions when exhausted, while informational cost metrics remain observable without becoming implicit hard limits. The branch passed the complete offline test suite (3,084 tests, 6 skipped), local CI/guardrails, coverage gates, documentation checks, and compile/diff hygiene before it was pushed. We kept the validation branch scoped to Praxist's currently supported Linux/macOS platforms rather than carrying unrelated, incomplete Windows socket and locking changes from the source branch.

Our maintainer workflow is documented here: https://github.com/sapientinc/PRAXIST/blob/main/docs/guides/contributing.md#what-happens-after-submission

This branch is now ready for a separately scheduled real-task experiment stage. Please allow us time to complete that validation; if it passes, the maintainers will submit the validated change to main with your authorship retained. We are closing this source PR only because its contribution has been transferred to the shared validation branch, not because the contribution was rejected.

@electrixoul electrixoul closed this Sep 3, 2026
@Glen-SP

Glen-SP commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Update: this shipped. Your active budget-admission fix is now on main in
9d6932d, merged via #199, with co-author credit.

Thank you for your contribution, @MASTER870-CMD

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Budget enforcement is advisory — a run overran its token grant 12x with nothing throttling

3 participants