Documentation

AMATELUS.ResourceBudget

Local resource profiles are mandatory at untrusted input boundaries. These counters are maintained by the receiver, never supplied as trusted claims by the sender. Termination proofs do not establish a practical resource bound.

structure ResourceBudget :
  • wireBytes : ℕ
  • expandedBytes : ℕ
  • nodes : ℕ
  • depth : ℕ
  • arrayItems : ℕ
  • signatures : ℕ
  • schemaBranches : ℕ
  • regexSteps : ℕ
Instances For
    def consumeWork (remaining cost : ℕ) :

    Consume actual work before executing it; exhaustion is rejection.

    Equations
    Instances For
      def admitBytes (budget : ResourceBudget) (wire expanded : ℕ) :

      Streaming parser must enforce both limits while receiving/decompressing, not after allocating the entire object. Unknown sizes require bounded streaming.

      Equations
      Instances For
        def boundedRegex (run : ℕ → String → String → Option Bool) (budget : ResourceBudget) (pattern text : String) :

        A bounded regex backend returns none on exhaustion or unsupported syntax. The backend must enforce the supplied step budget (or an equivalent hard deadline).

        Equations
        Instances For
          theorem exhausted_work_rejected (remaining cost : ℕ) (h : remaining < cost) :
          consumeWork remaining cost = none