Catalog/P family/P19
Proposed specificationSource-located exemplarH2

Budgeted loop with caps

Bound execution resources.

JOIN POINTresource_accounting_cycleRECORD STATUSCandidate · v0.1.0
UML class view for Budgeted loop with caps, showing participant roles, received calls, and analytical dependencies
FIG. P19 / UML CLASS VIEW
Object interaction diagram for Budgeted loop with caps, showing role collaboration and a numbered message sequence
FIG. P19 / OBJECT INTERACTIONS
Context
The harness can consume bounded turns, steps, tokens, time, or cost.
Trigger
Accounting approaches or exceeds a configured cap.
Structure
Resource ledger, cap policy, terminal reason, and optional escalation.
Effect
Execution stops or changes policy before an unaccounted resource overrun.
Requires
Relevant resource use is observable and shared with delegated work.
Ensures
Exhaustion produces a distinct terminal outcome and records the responsible cap.
Invariant
Budget exhaustion is never reported as task success.
Violation
Missing accounting or handler failure falls back to a safe terminal policy.

Negative control

A constant limit in an unrelated library does not meet the pointcut.

Permitted variation

Step, turn, token, cost, wall-clock, delegation, and per-task budgets.

Test obligation

Test exact cap, overshoot, parallel accounting, child work, and custom handler.

Evolution question

Did simple counters evolve into typed exhaustion and recovery contracts?

PROMPT SKETCH
Account for every bounded resource at the point of use, including delegated work. When a cap is exhausted, return a distinct terminal outcome that names the responsible budget.
CODE DESIGN / PYTHON
def before_step(budget, step):
    cost = budget.estimate(step)
    if not budget.can_spend(cost):
        raise BudgetExhausted(
            resource=budget.exhausted_resource,
            limit=budget.limit,
            spent=budget.spent,
            turn=step.turn,
        )
    budget.spend(cost)

Illustrative design sketch. A generic timeout is not a budget record; the failed cap must be attributable. This example is a teaching aid, not implementation evidence or a conformance claim.

Join point
resource_accounting_cycle
Source locator
Barbaste et al., §6.2, p. 15 (Hermes, “Budgeted Loop with Stop-Guards”); adapted label
Lexical cue
(?i)\b(?:max_(?:turns|steps|iterations)|step[_-]?limit|budget[_-]?(?:policy|limit)|token[_-]?budget)\bFrozen expression, v0.1.0. A match is a retrieval cue, not a confirmed implementation.
Aliases
None
Canonical exemplar
anomalyco/opencodepackages/core/src/session/runner/max-steps.ts:1Support: packages/core/test/session-runner.test.ts:1
Negative control
A constant limit in an unrelated library does not meet the pointcut.

Scope-anchored review. pohe-agent analyze <repo> --pattern P19 anchors the cue to its enclosing declaration and checks a separate operational signature for all four pointcut dimensions. Missing roles and negative-control risks remain visible; a structural match is not E2/E3. Calibration report ↗

Source-located exemplar

A concrete source anchor is available for this proposed record. It is one exemplar, not evidence that all repositories—or every contract field—conform.

Review boundary: this candidate and its specification come from an AI-assisted study. Independent human validation remains open.

ANY-EVIDENCE FAMILY COVERAGE27/36

75.0% of repository families in the frozen panel have at least one current cue, historical cue, or canonical source layer. This is not confirmed prevalence.

Current lexical-cue repositories: 23 / 41
Canonical source anchoranomalyco/opencode 885df74024b6packages/core/src/session/runner/max-steps.ts:1

Maximum-step terminal policy.

Exploratory retrieval cue Regex / v0.1.0
(?i)\b(?:max_(?:turns|steps|iterations)|step[_-]?limit|budget[_-]?(?:policy|limit)|token[_-]?budget)\b

This expression is a discovery instrument only. A match is a retrieval cue—not a confirmed implementation, pointcut match, or contract proof.