On this page

Scope Work and Resources๏ƒ

Architecture and design home

Reader Question๏ƒ

How should a web request, job, session, or nested operation receive an honest lifetime?

Short Answer๏ƒ

Choose the narrowest owner that matches the work. Frame-wide services use unique; request/session state commonly uses unique_per_conduit; child work can share lineage state; request-local ephemeral objects can live in an active SpellSpace; stateless work can use many.

Melder ownership and lifetime map

Editable diagram source

A Typical Request Shape๏ƒ

root = book.conjure()
request_scope = root.create_lesser_conduit()

try:
    handler = request_scope.meld("RequestHandler")
    handler.handle()
finally:
    request_scope.cleanup()

The root retains broad services. The lesser conduit owns request-specific creations and inherits only the lifetimes designed to cross the lineage boundary.

Why This Design Is Strong๏ƒ

The object graph and lifetime graph agree. Reuse decisions are made by the owning store, and teardown can run deterministically when the scope ends rather than waiting for GC.

Tradeoffs๏ƒ

The application must end scopes deliberately and choose lifetime semantics during registration. This adds lifecycle design work and prevents accidental process-global state.

Where to Go Next๏ƒ

Evidence:


Canonical source ยท Full contents