Add scoped session scheduling history REST v2 + SDK + CLI
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 368
Description
## Goal
Expose `search_session_scoped_history` via REST v2 + SDK + CLI. The repository/service/processor layers and the GraphQL `session_scoped_scheduling_histories` query already exist; only the v2 stack from REST onward is missing.
## Scope
### REST v2
- Add `search_session_scoped_history` handler in `src/ai/backend/manager/api/rest/v2/scheduling_history/handler.py` (model after `admin_search_session_scheduling_history` at L~60 area; take a session_id path param + filter/order/pagination)
- Register route in `src/ai/backend/manager/api/rest/v2/scheduling_history/registry.py`
### DTO
- Request/response under `src/ai/backend/common/dto/manager/v2/scheduling_history/` (extend existing modules; reuse filter/order types where possible)
### Adapter
- Add `search_session_scoped_history` method in `src/ai/backend/manager/api/adapters/scheduling_history.py` calling the existing processor
### SDK v2
- Add typed method in `src/ai/backend/client/v2/domains_v2/scheduling_history.py`
### CLI v2
- Add subcommand under `src/ai/backend/client/cli/v2/scheduling_history/` (e.g., `bai history session-scoped [--limit N] [--cursor ...]`)
## Success Criteria
### REST v2
- [ ] GET request with valid session_id and the caller has access → 200 with paginated history rows
- [ ] Request for a session the caller cannot access → 403
- [ ] Request for non-existent session_id → 404 (or empty list per existing endpoint convention)
- [ ] Filter / order / cursor params behave the same as the GraphQL equivalent
### SDK
- [ ] SDK method returns typed response; pagination iterator works end-to-end
### CLI
- [ ] `./bai history session-scoped ` prints rows; non-admin user can only see their own session
- [ ] Both admin and non-admin scenarios verified against live server (per CLAUDE.md API verification rule)
### General
- [ ] pants test passes for affected packages
JIRA Issue: BA-6140
Contributor guide
Research direction
Start with the existing admin handler in src/ai/backend/manager/api/rest/v2/scheduling_history/handler.py and the GraphQL session_scoped_scheduling_histories query, then trace the registry, DTO, adapter, SDK, and CLI paths named in the issue. Done means the REST endpoint, typed SDK pagination, and session-scoped CLI command satisfy the listed access, filtering, ordering, and pagination behavior; run affected pants tests and follow CLAUDE.md for live API verification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100