Runtime
Blue documents may use executable JavaScript-based logic. That power needs boundaries. This page explains the role of JS processing, gas limits, and bounded execution.
Without bounded execution, a document runtime can become expensive, unpredictable, unsafe, and hard to reason about. With bounded execution, you can still write useful logic while keeping the system practical.
Gas is a bounded execution budget. It exists so that:
This is especially important when documents contain JavaScript logic, many events are processed, or agent-generated structures become more common.
Many useful contract behaviors cannot be expressed declaratively without inventing a domain-specific scripting language. Blue lets you embed real JavaScript inside a workflow step (Conversation/JavaScript Code) executed in a sandboxed QuickJS WebAssembly runtime. That gives expressive power without giving up determinism.
document(...) helpereventConversation/Trigger Event outputs that other contracts in the same document can react toConversation/Update Document changesetsfetch, no sockets)These are not philosophical restrictions — they are the difference between "the same document and the same events always produce the same state" and "sometimes it does, depending on the network."
LLM calls, RPC calls, network requests, and other non-deterministic side effects happen outside the document processing boundary. The pattern is:
The non-determinism becomes data. The document never sees uncertainty.
Good JS step — derive next status from current state:
const current = document('/status');
const amount = event.message.request.amount;
if (current === 'pending' && amount > 0) {
return { newStatus: 'accepted' };
}
return { newStatus: current };Bad JS step — would smuggle non-determinism into processing:
// ❌ Not allowed: network call.
const exchangeRate = await fetch("https://example.com/usd").then(r => r.json());
return { amount: event.message.request.amount * exchangeRate.value };The fix is to publish the exchange rate to a timeline as data. The document then reads it deterministically.
The processor returns the actual gas it spent. With @blue-labs/document-processor, the value is on the result object as totalGas. The document stepper shows it directly on every epoch — no estimate, no guess.