Skip to content

feat(BA-6883): expose kernel scheduling history over GraphQL v2#12989

Merged
HyeockJinKim merged 1 commit into
mainfrom
feat/BA-6883-kernel-history-gql
Jul 21, 2026
Merged

feat(BA-6883): expose kernel scheduling history over GraphQL v2#12989
HyeockJinKim merged 1 commit into
mainfrom
feat/BA-6883-kernel-history-gql

Conversation

@jopemachine

@jopemachine jopemachine commented Jul 21, 2026

Copy link
Copy Markdown
Member

📚 Stacked PRs

Merge in order, bottom-up. Each PR is based on the one above it, so its diff shows only its own layer.

Resolves #12852 (BA-6883)

Summary

  • Root queries adminKernelSchedulingHistories (super-admin, check_admin_only()) and scopedKernelSchedulingHistories(scope: KernelScope!) (RBAC-resolved), following the adminFoos / scopedFoos convention in api/gql/AGENTS.md rather than the {scope}Foos shape the session / deployment / route slices still use.
  • KernelV2.schedulingHistories for walking from a kernel to its history, mirroring AgentV2.sessions. It takes the same filter / order / cursor / offset arguments as the scoped root and injects kernel_id=self.id.
  • New types, all with the GQL Python suffix and a suffix-free schema name=: KernelSchedulingHistoryGQL, KernelScopeGQL, KernelSchedulingHistoryFilterGQL, KernelSchedulingHistoryOrderByGQL, KernelSchedulingHistoryOrderFieldGQL, KernelSchedulingHistoryConnectionGQL.
  • Kernel history is now orderable by phase, from_status, to_status, result, and attempts as well as the two timestamps. That needed the DTO enum, KERNEL_ORDER_FIELD_MAP, and the GQL enum widened together — the map is keyed by the enum, so they have to stay in step.
  • resolve_nodes is backed by a new kernel_history_loader over batch_load_kernel_histories_by_ids; KernelSchedulingHistoryID is the key type end to end. Everything else reuses the adapter from feat(BA-6892): add kernel scheduling-history adapter and REST v2 endpoints #12870 — no new service or repository code.
  • added_version uses NEXT_RELEASE_VERSION per api/gql/AGENTS.md.

The history node exposes kernelId / sessionId as scalars and carries no back-reference fields; traversal to the entity goes through KernelV2.schedulingHistories.

SessionV2.kernelHistories from the issue description is intentionally not implemented — a session-wide query needs the action, repository search scope, and RBAC element widened beyond a single kernel, which is service/repository work rather than a GraphQL change.

Test plan

  • Schema builds; both roots and the KernelV2 field resolve
  • Generated SDL carries the full filter / order / cursor / offset argument set, and no *GQL name leaks into the schema
  • Every KernelHistoryOrderField member resolves through resolve_kernel_order
  • v2-schema.graphql / supergraph.graphql / openapi.json regenerated
  • ruff check / ruff format clean
  • Live query against a running manager — blocked: kernel_scheduling_history has no writer (KernelSchedulingHistoryCreatorSpec is called from nowhere), so the table stays empty until BA-6852 lands

🤖 Generated with Claude Code

@github-actions github-actions Bot added size:XL 500~ LoC area:docs Documentations comp:manager Related to Manager component labels Jul 21, 2026
@jopemachine
jopemachine force-pushed the feat/BA-6883-kernel-history-gql branch from ca8c6a7 to f4c96ed Compare July 21, 2026 06:00
@jopemachine
jopemachine force-pushed the feat/BA-6892-kernel-history-adapter-rest branch from e22ab80 to e432eec Compare July 21, 2026 06:06
@jopemachine
jopemachine force-pushed the feat/BA-6883-kernel-history-gql branch from f4c96ed to 769ee93 Compare July 21, 2026 06:07
@jopemachine
jopemachine force-pushed the feat/BA-6892-kernel-history-adapter-rest branch from e432eec to 517ad26 Compare July 21, 2026 06:28
@jopemachine
jopemachine force-pushed the feat/BA-6883-kernel-history-gql branch from 769ee93 to 037de46 Compare July 21, 2026 06:28
@jopemachine
jopemachine force-pushed the feat/BA-6892-kernel-history-adapter-rest branch from 517ad26 to a7abc8e Compare July 21, 2026 06:40
@jopemachine
jopemachine force-pushed the feat/BA-6883-kernel-history-gql branch from 037de46 to 7982881 Compare July 21, 2026 06:40
Base automatically changed from feat/BA-6892-kernel-history-adapter-rest to main July 21, 2026 06:54
@jopemachine
jopemachine force-pushed the feat/BA-6883-kernel-history-gql branch from 7982881 to 8629480 Compare July 21, 2026 06:57
Comment thread src/ai/backend/manager/api/adapters/scheduling_history/adapter.py Outdated
Comment thread src/ai/backend/manager/api/gql/data_loader/data_loaders.py Outdated
@jopemachine
jopemachine force-pushed the feat/BA-6883-kernel-history-gql branch from 8629480 to bb424dc Compare July 21, 2026 07:01
@jopemachine
jopemachine requested a review from Copilot July 21, 2026 07:01
@jopemachine
jopemachine force-pushed the feat/BA-6883-kernel-history-gql branch from bb424dc to 93ae650 Compare July 21, 2026 07:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds GraphQL v2 access to kernel scheduling history through admin and RBAC-scoped queries.

Changes:

  • Adds kernel history GraphQL types, filters, ordering, connections, and resolvers.
  • Adds Relay node batch loading through the scheduling-history adapter.
  • Regenerates GraphQL schemas and adds a changelog fragment.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
schema.py Registers kernel history query roots.
scheduling_history/types.py Defines kernel history GraphQL types and inputs.
scheduling_history/resolver.py Implements admin and scoped queries.
scheduling_history/__init__.py Exports new GraphQL symbols.
data_loader/data_loaders.py Adds the kernel history DataLoader.
adapters/scheduling_history/adapter.py Adds batch loading by history ID.
v2-schema.graphql Records generated v2 SDL changes.
supergraph.graphql Records generated federated schema changes.
changes/12989.feature.md Documents the feature for release notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ai/backend/manager/api/gql/scheduling_history/types.py Outdated
Comment thread src/ai/backend/manager/api/gql/scheduling_history/types.py Outdated
Comment thread src/ai/backend/manager/api/gql/scheduling_history/types.py Outdated
Comment thread src/ai/backend/manager/api/gql/scheduling_history/types.py Outdated
Comment thread src/ai/backend/manager/api/gql/scheduling_history/types.py Outdated
Comment thread src/ai/backend/manager/api/gql/scheduling_history/resolver.py Outdated
Comment thread src/ai/backend/manager/api/gql/scheduling_history/resolver.py Outdated
Comment thread changes/12989.feature.md Outdated
@jopemachine
jopemachine force-pushed the feat/BA-6883-kernel-history-gql branch 3 times, most recently from 2d50b46 to 7f66aec Compare July 21, 2026 07:21
@github-actions github-actions Bot added the comp:common Related to Common component label Jul 21, 2026
@jopemachine
jopemachine force-pushed the feat/BA-6883-kernel-history-gql branch from 7f66aec to 4b1cbea Compare July 21, 2026 07:25
Add the kernel slice of the Strawberry scheduling-history schema, mirroring the
session, deployment, and route slices:

- `adminKernelSchedulingHistories` — super-admin, system-wide
- `kernelScopedSchedulingHistories` — scoped to one kernel via `KernelScope`

The node exposes `kernel` and `session` back-references through the existing
data loaders, and `resolve_nodes` is backed by a new `kernel_history_loader`
over `batch_load_kernel_histories_by_ids`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jopemachine
jopemachine force-pushed the feat/BA-6883-kernel-history-gql branch from 4b1cbea to 5f814cd Compare July 21, 2026 07:27
@jopemachine
jopemachine marked this pull request as ready for review July 21, 2026 07:32
@HyeockJinKim
HyeockJinKim merged commit 6fbbdc3 into main Jul 21, 2026
38 checks passed
@HyeockJinKim
HyeockJinKim deleted the feat/BA-6883-kernel-history-gql branch July 21, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Documentations comp:common Related to Common component comp:manager Related to Manager component size:XL 500~ LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kernel scheduling history: GraphQL (scoped/admin roots + Session/Kernel node fields)

3 participants