Module

marksy/limits

src/marksy/limits.pooka

A document may ask for more time than its reader can spare. Checked parsing uses an isolated, monitored BEAM process with byte, reduction, heap, and elapsed-time budgets. The ordinary parser stays a direct, pure operation.

Pooka
let budget = limits.defaults()
assert limits.run("owl", budget, fn() { 42 }) == Ok(42)

API reference

class

Budget

src/marksy/limits.pooka:17
class Budget(
  max_bytes: Int,
  max_reductions: Int,
  max_heap_words: Int,
  timeout_ms: Int
)

Heap size is in BEAM words, not bytes. Reductions measure runtime work rather than source characters; limits are resource guards, not nesting heuristics.

field

max_bytes

src/marksy/limits.pooka:18
max_bytes: Int
INFERREDInt
field

max_reductions

src/marksy/limits.pooka:19
max_reductions: Int
INFERREDInt
field

max_heap_words

src/marksy/limits.pooka:20
max_heap_words: Int
INFERREDInt
field

timeout_ms

src/marksy/limits.pooka:21
timeout_ms: Int
INFERREDInt
constructor

new

src/marksy/limits.pooka:18
INFERREDfn(Int, Int, Int, Int) -> marksy/limits.Budget
enum

Reason

src/marksy/limits.pooka:24
enum Reason
variant

InvalidBudget

src/marksy/limits.pooka:25
Reason.InvalidBudget
variant

InputTooLarge

src/marksy/limits.pooka:26
Reason.InputTooLarge
variant

WorkExceeded

src/marksy/limits.pooka:27
Reason.WorkExceeded
variant

HeapExceeded

src/marksy/limits.pooka:28
Reason.HeapExceeded
variant

TimedOut

src/marksy/limits.pooka:29
Reason.TimedOut
variant

WorkerFailed

src/marksy/limits.pooka:30
Reason.WorkerFailed
class

LimitError

src/marksy/limits.pooka:33
class LimitError(reason: Reason, message: String)
field

reason

src/marksy/limits.pooka:33
reason: Reason
field

message

src/marksy/limits.pooka:33
message: String
INFERREDString
constructor

new

src/marksy/limits.pooka:33
function

defaults

src/marksy/limits.pooka:44
defaults() -> Budget
INFERREDfn() -> marksy/limits.Budget

One MiB of source, twenty million reductions, four million heap words, and five seconds. Applications may choose a different budget for their workload.

function

run

src/marksy/limits.pooka:50
run(source: String, budget: Budget, work: fn() -> a) -> Result(a, LimitError)
INFERREDfn(String, marksy/limits.Budget, fn() -> a) -> Result(a, marksy/limits.LimitError)

Reject oversized source before spawning. A cancelled worker is killed and joined before this function returns; its private reply cannot leak later.