Binding leases
An exarch agent’s top-level names expire after BINDING_IDLE_CALLS (256)
source runs without use; nothing else about binding changes. A model treats
top-level let as scratch and never erases it. The ledger
(core/src/shell/runtime/state/bindings.rs, BindingLedger) removes such a
name at a ready boundary; afterwards the name reads exactly as one never bound.
ral’s semantics are untouched, and a host that never arms the ledger (the REPL)
never expires anything.
What is leased
Only names the model binds in ρ at session scope after arming.
Shell::arm_binding_leaseseals every name then visible (Env::all_bindings: ρ and Σ’s prelude) as baseline, permanently exempt. exarch arms it inboot::engine_rootthroughshell_eval::arm_session_ledgers, after the agent library and host seeds are in place, so a rebooted engine reseals.- A child built by
Shell::constructarms from the parent’s marshalledTerms.leaseand seals every inherited name as baseline. Its lease governs only names the child writes. - A name only Σ answers (a native, an unshadowed prelude function) is never a ρ entry, so it is never a candidate.
Shell::note_defineis the one stamp, called fromrun_phrases’sDefinearm underMode::Session, for every name a top-levellet, pattern or recursive group installs, and never underMode::Local. Bindings inside blocks, lambdas andusebodies are not session names.BindingLedger::pruneends with an adoption sweep: an unstamped, non-baseline ρ name gains a lease late rather than living forever.
The clock and use
The clock counts source runs; use is read off program text.
- Each
Program::Sourcedispatch ticks once before compiling, so a run that fails to parse or check ages leases without renewing them.Program::Checkneither ticks nor renews. No wall clock exists. - After a successful compile,
Toplevel::referenced_namesrenews every name the program mentions. It is theMentionswalk that builds each node’sOcc: a nested node contributes its stored occ, so the harvest is linear and a stored body’s names count once, on the run that compiled it. - Evaluation renews nothing. The elaborator saw every name a run can resolve, so the harvest is complete; it over-approximates, which only lengthens a lease.
- A rebind restamps through
note_define. Enumeration (/resources,Shell::leased_binding_count) renews nothing.
Pruning
Shell::emit_ready_boundary_notices prunes once per settled source run,
while the run’s frame is still installed. A hook run and a panicked run are
no ready boundary.
- Prune runs only when the mooring has a surface sink; otherwise the ledger is left untouched for a later run.
- Each name idle past the bound is examined in sorted order:
- absent from ρ (a rolled-back install): its entry is dropped silently;
- its value reaches a live (
runningorstopping) handle bypins_live_work: kept and re-examined next boundary; - otherwise unset, value and scheme together, and reported as one
Notice::PruneofPruned { name, idle_calls, kind }.
pins_live_workrecurses lists, maps, tag spines and a partial builtin’s supplied arguments, never a block’s capture. AHandle::Withheld(every handle in a marshalled image) pins nothing (runtime-values-are-value-closures).- exarch records the notice as
Forensic::Prune(shell_eval/surface.rs); the model is told nothing. Naming the name again is an ordinary staticundefined variableerror. Shell::run_undercheckpoints(env, context)at run entry, after any earlier prune, so a panic rollback cannot restore a pruned name.
Large bindings are a separate axis. note_define queues a
LargeBindingNotice whenever ValClos::shallow_size meets
large_binding_bytes (1 MiB in exarch), whatever the name’s age or baseline
status. The ready boundary writes it to stderr, sink or no sink, so it reaches
the model in its tool result.
Captured values
Pruning a name never touches a closure that captured it.
let big = <5 MB of text>
let f = { … $big … } # f is called every run
ValClos::thunkandValClos::closerestrict a capture to the body’s occ at formation;closealso pulls a missing direct name from Σ with its scheme (a-closure-keeps-only-what-it-mentions).- Every run that calls
fmentionsf, neverbig;big’s mention was harvested once, whenfwas compiled.bigexpires andfkeeps working: its capture holdsbig’s value, and the session ρ is persistent, so the unset cannot reach it. - The bytes stay resident until
fitself is pruned or rebound. The large-binding notice exists to steer the model toward binding a path instead.
Decay
A settled worker’s registry entry expires after SETTLED_WORKER_RETENTION
(256) calls unclaimed, on the same clock. A name holding a finished handle is
ordinary scratch; one holding a live handle is pinned. Each removal leaves a
record in record.jsonl.
See shell-state, agent, probe-convention and output-capture-and-detachment.