Add scoped replica scheduling history REST v2 + SDK + CLI (Route to Replica naming)
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 368
Description
## Goal
Expose `search_route_scoped_history` via REST v2 + SDK + CLI under the new `replica` naming. The repository/service/processor layers and the GraphQL `route_scoped_scheduling_histories` query already exist; only the v2 stack from REST onward is missing.
Newly created REST v2 / SDK / CLI surfaces use `replica` as the user-facing term (internal types and the existing GraphQL query keep `route` for backward compatibility).
## Scope
### REST v2
- Add `search_replica_scoped_history` handler in `src/ai/backend/manager/api/rest/v2/scheduling_history/handler.py` (URL path uses `replica`, e.g., `/v2/scheduling-history/replica/{replica_id}`; internally calls the existing route-scoped processor)
- Register route in `src/ai/backend/manager/api/rest/v2/scheduling_history/registry.py`
### DTO
- Add request/response DTOs under `src/ai/backend/common/dto/manager/v2/scheduling_history/` named `ReplicaScoped\*` (alias or thin wrapper over existing Route types; field naming follows `replica_id` on the v2 surface)
### Adapter
- Add `search_replica_scoped_history` method in `src/ai/backend/manager/api/adapters/scheduling_history.py` that maps v2 `replica_id` to the existing route-scoped processor input
### SDK v2
- Add typed method `replica_scoped_history(...)` in `src/ai/backend/client/v2/domains_v2/scheduling_history.py`
### CLI v2
- Add subcommand `./bai history replica-scoped ` under `src/ai/backend/client/cli/v2/scheduling_history/`
### Naming convention documentation
- Add a short comment in the adapter explaining the Route→Replica mapping rationale (internal: route; public v2 surface: replica)
## Out of Scope
- Renaming the existing GraphQL `route_scoped_scheduling_histories` query (kept for backward compatibility)
- Renaming the repository/service/processor methods (internal API stability)
## Success Criteria
### REST v2
- [ ] GET `/v2/scheduling-history/replica/{replica_id}` with caller access → 200 with paginated history rows
- [ ] Caller without access → 403
- [ ] Non-existent replica_id → 404 (or empty list per existing convention)
- [ ] Filter / order / cursor params behave the same as the GraphQL `route_scoped_scheduling_histories` equivalent
### Naming
- [ ] All new REST v2 / SDK / CLI surfaces use `replica` consistently (path params, DTO field names, CLI flag names)
- [ ] Internal layer (repository/service/processor) still uses `route` — confirmed unchanged
### SDK
- [ ] `replica_scoped_history` returns typed response; pagination iterator works end-to-end
### CLI
- [ ] `./bai history replica-scoped ` prints rows; non-admin user can only see their own replica
- [ ] Both admin and non-admin scenarios verified against live server
### General
- [ ] pants test passes for affected packages
JIRA Issue: BA-6142
Contributor guide
Assessment
This issue has not been assessed yet.