Resource Bounds Are Part of the FACET Language
An AI contract is incomplete until it says what execution is allowed to consume.
I do not mean a Kubernetes memory limit added after the application is built. I mean limits that change whether a document is valid, whether a transformation may run, and whether a request may reach the model at all. In FACET, resource bounds belong to the language because unbounded construction can change semantics before infrastructure monitoring has anything useful to report.
That distinction matters. A provider token limit is an external ceiling. A FACET budget is part of the compiled contract.
Four different bounds, four different failure classes
“Limit” is too vague for engineering review. I separate at least four boundaries:
| Boundary | What it constrains | Failure it prevents |
|---|---|---|
| Structural limits | document size, nesting depth, list length, lens-chain length | parser and compiler resource abuse |
| Compute gas | deterministic transformation work | hidden or runaway compile-time computation |
| Context budget | the ordered content admitted to the request | accidental truncation and unstable packing |
| Runtime authority | tool effects allowed after inference | unbounded side effects |
These limits are related, but they are not interchangeable. A small context budget does not stop an expensive transform. A gas ceiling does not constrain a destructive tool call. A runtime guard does not repair a compiler that silently removed critical instructions.
FACET makes these boundaries visible at different phases instead of collapsing them into one generic timeout.
Structural ceilings protect the compiler itself
The older FACET implementation already exposes explicit ceilings for document bytes, nesting depth, list length, fenced content, lens-chain length, and regular-expression time. The current standard defines FACET as resource-bounded, while the compiler turns that principle into concrete validation and execution checks.
This is not only denial-of-service hygiene. Structural limits define which documents are valid inputs to the toolchain. If one implementation accepts a document with extreme nesting and another fails unpredictably, they do not share the same practical language.
A conformance review should therefore ask:
- Is the limit explicit?
- At which phase is it checked?
- Does violation produce a stable diagnostic?
- Can a host silently raise it?
- Is the effective value recorded in an inspection artifact?
If the answer to the fourth question is “yes” and the fifth is “no,” replay is already weaker than it looks.
Gas is a semantic budget for transformations
FACET lenses are transformations inside the compilation pipeline. Some are pure and bounded; others depend on cached or host-mediated data. A gas limit gives deterministic work an explicit ceiling.
I prefer this to treating a timeout as the primary contract. Wall-clock time changes with hardware, load, and runtime implementation. Gas can count semantic operations under rules defined by the compiler. It is not a performance benchmark. It is a refusal boundary.
The useful invariant is simple:
same contract + same inputs + same compiler semantics + same gas budget
→ same success or same gas-exhaustion failure
A host may still enforce a wall-clock timeout for operational safety. But that timeout should sit outside the semantic result, not replace it.
Context budget is not a provider afterthought
The Token Box model treats context as an ordered, finite resource. The FACET specification measures it in FACET Units, loads critical sections first, then packs flexible sections using declared priority and retention rules.
This produces two important outcomes.
First, the model receives a deliberate layout rather than whatever survives provider-side truncation. Second, infeasible contracts fail before inference. If critical content exceeds the budget, FACET returns F901; it does not improvise by deleting part of the contract. I described that boundary in Why FACET Fails on Critical Context Overflow.
The effective-minimum rule closes a subtler hole. A section minimum cannot become a hidden reservation larger than the section itself. FACET computes the effective floor from the smaller of the declared minimum and actual section size, so retention policy cannot make the packed result exceed the total budget. That mechanism is covered in Why a Context Minimum Must Never Break the Budget.
These are language rules because they determine the canonical request.
Review the effective bounds, not only the source
A source file may omit @context. The standard permits the host to provide the budget, but requires that value to be stable for a fixed execution configuration and surfaced in canonical metadata.
That creates a practical review pattern:
source contract
+ compiler identity
+ host profile identity
+ effective structural limits
+ gas limit
+ effective context budget
= bounded compilation identity
I would preserve this tuple beside the canonical JSON and inspection artifacts. A diff that changes only the host profile or effective budget can still change layout, hashes, and the provider request. The source did not change; the executable meaning did.
This is also why compiler upgrades need replay and semantic artifact comparison. A new release may correct a boundary rule, as the FACET compiler did for oversized section minima. That is the right fix, but it is still an observable semantic change that deserves a migration diff.
A minimal CI gate for bounded execution
A useful gate does not need a model call. It can compile a representative corpus and assert four classes of behavior:
1. valid boundary cases compile;
2. one-step-over cases fail with the expected diagnostic;
3. inspect output records effective budgets and identities;
4. canonical artifacts remain stable for unchanged inputs.
The negative fixtures matter most. Include a critical section one unit over budget, a transformation that exhausts gas, excessive nesting, and a flexible section whose declared minimum exceeds its actual size. A green happy-path example proves almost nothing about resource semantics.
This gate complements the broader FACET contract gate for CI. Its specific job is to catch accidental expansion of what the compiler is willing to consume or emit.
Where the guarantee stops
FACET resource bounds do not prove that a model response will be cheap, fast, correct, or safe. FACET Units are not provider billing tokens. Compile-time gas is not CPU accounting. A context budget does not cap the number of runtime retries. Runtime authorization still needs its own effect and policy boundaries.
The narrower claim is more useful: the request-construction phase can be bounded, inspected, tested, and refused deterministically.
I see resource limits as part of program meaning. If a contract can consume arbitrary structure, transformation work, context, or authority, it is not fully specified. The compiler should not merely produce a request. It should prove that request construction stayed inside declared boundaries—or stop before the model receives anything.