refactor(BA-7226): replace session/kernel/agent ORM relationship usages with explicit queries - #13786
Open
fregataa wants to merge 5 commits into
Open
refactor(BA-7226): replace session/kernel/agent ORM relationship usages with explicit queries#13786fregataa wants to merge 5 commits into
fregataa wants to merge 5 commits into
Conversation
… queries Add fetch_actual_occupied_slots() to the agent repository query module and pass the resolved slots into AgentRow.to_data(), so agent occupancy no longer depends on the agent_resource_rows relationship or its slot_type_row chain. The scheduler db_source loads per-slot capacity/reserved/used through its own batched query. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…explicit queries - ComputeContainer.imageObject resolves through a new id-keyed ImageNode dataloader instead of the KernelRow.image_row join; group_row/user_row were eager-loaded but never read, so those loader options are gone. - KernelRow.get_kernel() filters live agents with an explicit join on agents. - get_direct_access_info() reads the agent public host through the session repository rather than walking main_kernel.agent_row. - Drop the now-dead agent_row eager loads in the registry, the stream/session db_sources and the session kernel loading strategies. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… queries - ComputeSessionNode.owner resolves through a uuid-keyed UserNode dataloader. - gql_legacy session queries join users/groups explicitly so the full_name/user_email/group_name filters keep working. - The resource-usage report runs one explicit join and returns ResourceUsageRecord instead of walking kernel -> session -> user/group. - convert_session_to_image reads the project container registry through the session repository; get_session_with_group is gone. - join_by_related_field had no callers left and is removed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ype_row Both relationships are now unreferenced: slot_type_row lost its last reader when agent occupancy moved to an explicit join, and nothing reads KernelRow.session. SessionRow.kernels drops its back_populates and becomes one-directional; no code writes through the relationship, so delete behaviour still comes from the database foreign keys. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ComputeContainer.imageObjectandComputeSessionNode.ownernow resolve through id/uuid-keyed dataloaders instead of eager-loaded joins; the GraphQL schema itself is unchanged.gql_legacyjoins users/groups explicitly so thefull_name/user_email/group_namefilters keep working, and the resource-usage report runs one explicit join returningResourceUsageRecord.SessionRow.kernelsand the row helpers built on it (main_kernel,resource_opts,get_kernel_by_id,delegate_ownership) are intentionally left for a follow-up PR — converging them onto the sokovan-style dataclass accessors touches ~100 consumer sites and is a separate change.Test plan
pants test --changed-since=origin/mainpassesagentsGQL) reports the sameoccupied_slotsas before, with slots still ordered byresource_slot_types.rankcomputeContainerList/computeContainerstill returnimageObject, andcomputeSessionNode.ownerstill resolvesfull_name,user_email,group_namestill workusage_per_period/usage_per_monthproject usage reports return the same figuresget_direct_access_infoon a SYSTEM session returns the agent public host, and raisesKernelNotReadywhen no agent is assignedconvert_session_to_imagestill resolves the project container registryResolves BA-7226
🤖 Generated with Claude Code