"""Step repository (tenant-scoped)."""

from __future__ import annotations

import uuid

from sqlalchemy import select
from sqlalchemy.orm import Session

from legate.db.models.step import Step


def list_for_run(db: Session, *, workspace_id: uuid.UUID, run_id: uuid.UUID) -> list[Step]:
    return list(
        db.scalars(
            select(Step)
            .where(Step.run_id == run_id, Step.workspace_id == workspace_id)
            .order_by(Step.idx.asc())
        ).all()
    )
