Who a consolidation cycle's costs are charged to.
Split from :mod:symfonic.capabilities.memory.napping at the 300-line budget.
It is a small module and a whole idea: a nap can spend a model call, and a cost
with no owner is a cost nobody sees on any invoice.
attributed
attributed(run_id: str, root_run_id: str) -> Iterator[None]
Bind the turn's identity for this cycle, when there is one.
Source code in src/symfonic/capabilities/memory/attribution.py
| @contextmanager
def attributed(run_id: str, root_run_id: str) -> Iterator[None]:
"""Bind the turn's identity for this cycle, when there is one."""
if not run_id and not root_run_id:
yield
return
identity = RunIdentity(
run_id=run_id or root_run_id,
root_run_id=root_run_id or run_id,
# The cycle is not a delegated child of the turn -- it is
# maintenance the turn triggered -- but the turn is what it is
# charged to, and naming it here is what lets a reader of the cost
# find the turn rather than a bare consolidation with no lineage.
parent_run_id=run_id or None,
)
with bind_run_identity(identity):
yield
|