# Resources and lifecycle

A resource is anything with identity, ownership, availability, and cleanup
obligations: memory, files, sockets, credentials, database instances, queues,
volumes, devices, workloads, cloud objects, and logical domain resources.

## Identity precedes use

Every resource kind defines its stable identity, owner, lifecycle states,
containment rules, and observable properties. A path, URL, provider handle, or
cloud object name may locate a resource, but it does not replace the owned
resource identity.

Resources can contain, borrow, lease, share, transfer, or depend on other
resources only through explicit relationships. Cleanup follows those
relationships rather than relying on naming convention or process exit.

## Acquisition is not authority

Discovering or provisioning a resource does not grant a workload permission
to use it. Planning selects the realization and proposed binding. Authority
issues a scoped grant. Deployment activates the binding under that grant. The
runtime receives an attenuated handle or token enforced at the real boundary.

The inspectable chain keeps the logical requirement, physical realization,
instance, binding subject, grant, activation receipt, and current binding
revision distinct.

## Lifetimes are compositional

Resources may be lexical, task-scoped, session-scoped, workload-scoped,
release-scoped, tenant-scoped, or independently durable. A child lifetime
cannot outlive its owner unless an explicit transfer creates a new owner and
cleanup contract.

Cancellation requests cooperative shutdown. It does not prove cleanup.
Shutdown, drain, flush, snapshot, revoke, detach, delete, and verify-absence are
separate transitions where the resource semantics require them.

## Destruction is an effect

Delete, revoke, release, and destroy operations name their blast radius,
preconditions, approval, idempotency, retention, recovery window, and
postcondition evidence. Cascading deletion is explicit in the plan.

When creation or deletion has an unknown outcome, reconciliation observes the
provider before repeating the action. Orphan detection and adoption operate
through authenticated identity and ownership evidence; matching a name or tag
is not sufficient.

## Quotas and cost belong to the resource graph

Capacity, rate, concurrency, storage, energy, accelerator time, monetary cost,
and carbon or locality constraints can all enter resource requirements.
Planning accounts for fixed, marginal, expected, and worst-case consumption.
Deployment enforces quotas and records preemption, scaling, and exhaustion as
typed outcomes.

## Example

Illustrative end-product code scopes acquisition and release:

```rust,ignore
let scratch = ctx.resources().temporary_storage().acquire().await?;
let result = process(&scratch).await;
scratch.release().await?;
result
```

Follow [Manage resources and execution](/one/examples/resources-execution).

Canonical owner:
[Resources](https://github.com/muijf/one/blob/main/systems/resources/AGENTS.md).

Next: [communication](/one/model/communication).
