- Protect _aggregated_usage_metrics with a lock so concurrent
LLMCallCompletedEvent handlers can't race the read-modify-write
inside add_usage_metrics, and so usage_metrics snapshots are
consistent.
- Wire the usage aggregation listener into resume_async so LLM
calls during outcome collapsing and downstream crews continue
to roll up into flow.usage_metrics after a paused-then-resumed
kickoff. Restores current_flow_id to the original kickoff's
match id when none is set, and detaches in finally.
- Guard against reentrant kickoff on the same Flow instance:
only the outer kickoff captures _flow_match_id, resets the
accumulator, and owns the listener lifecycle. Inner reentrant
calls pass through and no longer wipe outer state or detach
the shared handler.
- Rename test_snapshot_is_immutable to
test_usage_metrics_returns_independent_copy to reflect that
the property returns a copy of a (still-mutable) UsageMetrics.
- Extend test_handler_is_unregistered_after_kickoff to also
cover the failure path, confirming the handler is removed
when kickoff raises.