context
The Context fabric: the in-memory `ctx.attrs` and fabric bindings.
Module nu.context.
The Context fabric: the in-memory ctx.attrs and fabric bindings.
A Fabric is an addressable space where Refs live; it resolves Refs and carries out the Interactions over them. The Context fabric has two axes:
- attrs - the channel an interaction uses to hand its internal values
to its body (
ctx.attrs): a loop its item, a catch the error. Only interactions bind it; the tree reads it withAttr(name)and asksAttr(name).exists()(aBooloverAttrExists). It is never a store: state goes through a fabric. - fabric - typed bindings (
ctx.bind/ctx.get) for every other ctx-bound thing: execution resources, storage handles, cluster handles, compute actors. Ref:FabricRef(read-only, self-yields); existence:.exists(), aBooloverFabricExists. Provisioning bracketsProvide/ProvideList/ProvideDictinstall fabrics into the Context for a body's duration. ProtocolsFabric(empty marker; every ctx-bound thing satisfies it) andFabricLifecycle(Fabric)(with optional setup / cleanup) describe the contract.
The read on the attrs axis is the Ref's dual role; only existence needs an
explicit query. Other concrete fabrics (nu.mem in the kernel, the rest in
nustd) follow the same shape in their own dirs: concrete Refs plus the
interactions that touch that fabric. Nothing in nu.core touches a fabric -
core is the pure Python builtins.
attrs.interactions
Module nu.context.attrs.interactions.
Attrs interactions: AttrExists.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| AttrExists | scalar_query | AttrExists(ref) | Whether the name its attrs ref names is bound in ctx.attrs. |
fabric.queries
Module nu.context.fabric.queries.
Fabric existence query.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| FabricExists | scalar_query | FabricExists(ref) | Whether the fabric type of its FabricRef is bound on the Context. |
fabric.lifecycle
Module nu.context.fabric.lifecycle.
Provide brackets: construct + bind fabrics for the body's duration.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| Provide | bracket | Provide(cls, kwargs=None, body=None, tag=None, tags=(), predicate=None, bind_as=None) | Constructs one fabric and binds it on the Context for the body's duration. |
| ProvideDict | bracket | ProvideDict(cls, specs, body=None, extra_tags=(), predicate=None, bind_as=None, parallel=False) | Constructs a fleet of one class and binds each member under its own key. |
| ProvideList | bracket | ProvideList(cls, specs, body=None, base_tag=0, extra_tags=(), predicate=None, bind_as=None) | Constructs a fleet of one class and binds each member under its index. |
| With | bracket | With(body=None) | Enters several lifecycle brackets around one body, tearing down in reverse. |
attrs.refs
Module nu.context.attrs.refs.
Attr: the tree's one read of ctx.attrs.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| Attr | ref | Attr(address) | Reads the value an interaction handed its body under a name. |
fabric.refs
Module nu.context.fabric.refs.
FabricRef: a Ref into a Context binding.
| Name | Sort | Call | Meaning |
|---|---|---|---|
| FabricRef | ref | FabricRef(address=None) | A Ref into a Context binding, keyed by the fabric type it resolves to. |