"""Transfer a latched pipeline failure to its native episode lifecycle owner.""" from local_state import write_json def consume_pipeline_failure(pipeline, directory, stop_command): accessor = getattr(pipeline, "terminal_failure", None) failure = accessor() if accessor is not None else None if failure is None: return None # This stops actuator intent only. It neither rewrites measured velocity # nor claims that the physical body has already stopped. stop_command(0.0, 0.0) write_json(directory / "pipeline-failure.json", failure) return { "outcome": "failed", "mission_outcome": "error", "message": "Симуляция завершена после ошибки обработки наблюдений. Журнал сохранён.", "pipeline_failure": failure, }