Skip to content

Budget exhaustion is not enforced after cost metrics #25

Description

@nficano

Cost metrics decrement the budget ledger, but no code checks whether the counter reached zero afterward. BudgetLedger.AssertNotExhausted exists and the XML comment on Job.EmitMetricAsync says a BudgetExhaustedException may be raised, yet EmitMetricAsync only calls ApplyMetric and then emits the metric event. A job can keep running after spending through its declared cost.budget, while the docs and conformance page state that BUDGET_EXHAUSTED is enforced.

The relevant locations are src/Arcp.Runtime/Job.cs:151, src/Arcp.Runtime/Job.cs:155, src/Arcp.Runtime/Budget/BudgetLedger.cs:51, docs/guides/jobs.md:129, and docs/conformance.md:33.

Fix prompt: Enforce budget exhaustion immediately after applying a matching cost.* metric. Update Job.EmitMetricAsync to call BudgetLedger.AssertNotExhausted after ApplyMetric returns true, convert exhaustion into the protocol behavior described by the docs, and ensure the job terminates with ErrorCode.BudgetExhausted and Retryable = false rather than continuing. Add unit and integration tests for a lease with cost.budget of USD:1.00, a metric of cost.inference with value greater than or equal to the budget, and the expected BUDGET_EXHAUSTED terminal result.

Activity

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 workingseverity:highHigh severity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions