pub fn observe_lifecycle(
telemetry: Res<'_, Telemetry>,
agents: Query<'_, '_, (Entity, &RunMetadata, &AgentState, Option<&StageCursor>, Option<&TokenTotals>, Option<&StageLedger>, Option<&StageJustEntered>, Option<&mut TelemetryState>, Option<&mut StageActivity>, Option<&StageIoBuffer>)>,
commands: Commands<'_, '_>,
)Expand description
Emit lifecycle, activity, and log events for every agent run.
Stage boundaries come from the StageJustEntered marker (with the
agent’s first sighting standing in for the marker-less initial stage);
a re-entry into the same stage index keeps the stage open rather than
closing and reopening it, matching how the stage ledger accrues.