Eviction and release
Release and eviction both tear down a node’s resources. They differ in what survives.
| Release | Eviction | |
|---|---|---|
| Method | releaseResources(reason?) | evict(mode?, reason?) |
| Returns | Promise<void> | Promise<EvictResult> |
| Graph identity | Kept | Removed |
| Graph edges | Kept | Removed |
| Ready data | Cleared | Cleared |
| Next read | Idle, can reacquire | Unwired, must rewire |
| Use when | Identity still valid; you’ll read it again | Identity is gone; drop it and its dependents |
Release
Release cleans a node’s resources and returns it to Idle, keeping its place in the graph.
await runtime.client.node(ProfileNode, { userId: "u_42" }).releaseResources();
In order, release:
- Stops the active live resource, if one exists.
- Runs the driver release hook, if configured.
- Runs the node’s disposers.
- Closes and drops the current ready node instance.
- Transitions the cell to
Idle(or a release-failure projection).
Graph identity, the graph record, and edges stay. A released node can be acquired again with ensureReady() without rewiring. Missing release hooks are no-ops; release on a node with no cell is a no-op.
Eviction
Eviction removes a node and its dependents from the graph.
const result = await runtime.client.node(SessionNode, Frond.Args.none).evict();
result.nodeIds; // ids that were removed
result.failures; // cleanup failures, if any
In order, eviction:
- Computes the dependency closure for the requested mode.
- Interrupts active actor work for each node in the closure.
- Runs cleanup, best-effort.
- Removes the actor entries, graph node records, and edges touching evicted nodes.
- Emits one eviction event with the evicted ids and cleanup failures.
evict() returns an EvictResult of { nodeIds, failures } — the ids removed and any failures collected during cleanup.
Modes
await handle.evict("selfAndDependents"); // default
await handle.evict("dependents");
| Mode | Effect |
|---|---|
selfAndDependents | Evict the node and its reverse dependency closure. Default. |
dependents | Evict the reverse closure, leave the node itself. |
The reverse dependency closure is every node that depends on the target, directly or transitively. Eviction orders deeper dependents before the nodes they depend on. See Dependencies.
Tip: On logout, evict the session node. Every user-scoped node that declared a session dependency is automatically removed with it — one call clears the entire user subgraph.
Interruption
Eviction interrupts active work on each evicted node. Interrupted work receives the eviction cancellation reason unless the request supplies a more specific one. Late completion of an interrupted acquire, action, refresh, or args reconciliation does not commit after the graph record is removed.
Cleanup failures
Cleanup is best-effort. A failure stopping a live resource or running a disposer does not abort the rest of the cleanup, and does not by itself keep the node’s identity.
- Release collects failures from live-resource stop, driver release, release-hook disposers, and normal disposers.
releaseResources()still resolvesvoid; the runtime emits the retained cleanup failure through events and diagnostics. The projected released cell retains the first failure in execution order as its primary failure. - Eviction returns all cleanup failures in
EvictResult.failures.
After the call
| Reads project | ensureReady() | |
|---|---|---|
| After release | Idle (or release failure) | Reacquires |
| After eviction | Unwired / missing | Wires and acquires a new node |
Idempotency
Releasing a node with no cell is a no-op. Evicting a missing root is ignored — there is no record to remove. Repeated eviction of an already-removed node does not rerun cleanup.
Next: Result validity — how a result moves from current to stale to expired.