refactor(BA-6927): rename usage_bucket_entries.amount to resource_seconds#12967
Closed
jopemachine wants to merge 7 commits into
Closed
refactor(BA-6927): rename usage_bucket_entries.amount to resource_seconds#12967jopemachine wants to merge 7 commits into
jopemachine wants to merge 7 commits into
Conversation
jopemachine
added a commit
that referenced
this pull request
Jul 20, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7 tasks
Add KernelSchedulingHistorySearchScope and the scoped repository read path. Unlike the session/deployment/route scopes, which each carry one required entity id, a kernel query is scoped by session_id (all of a session's kernels), kernel_id, or both. to_condition() filters on each axis given and intersects when both are; existence_checks covers the corresponding session and kernel rows. At least one axis is required: an empty scope would silently degenerate into an unscoped, system-wide search, so it raises EmptyKernelSchedulingHistoryScope. The shared DTO validates this too (BA-6891); the scope defends it again because it is what the repository actually trusts. search_kernel_scoped_history mirrors the existing unscoped method, differing only in passing the scope to execute_batch_querier. The service actions that build this scope land in BA-6891. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The two axes were plain UUIDs, so nothing stopped a caller from passing a kernel id as the session axis. Both identifiers already have NewType wrappers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add the v2 DTOs and the service layer for kernel scheduling history. The DTOs are the schema shared by REST v2 and GraphQL, so BA-6883 builds its GraphQL types on these rather than defining its own. KernelHistoryScopeDTO carries both scope axes as optional and rejects an empty scope in a model_validator, so the rule lives with the schema both surfaces share instead of being restated per surface. KernelHistoryNode has no sub_steps: kernel_scheduling_history defines no such column, unlike the session/deployment/route tables. BEP-1061 and BA-6852 both describe kernel as carrying sub_steps, which does not match the schema; that belongs to the writer side and is left alone here. Only the two inputs that get wired are added. There is no offset-only SearchKernelHistoryInput mirroring SearchSessionHistoryInput, as that one has no callers. The adapter that converts these DTOs and drives the processors lands in BA-6892. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The admin search is system-wide and unscoped, so its authorization is the SUPERADMIN role gate rather than RBAC scope resolution. That is what BaseGlobalAction and GlobalActionProcessor model, and the processor applies the gate on the action path as defense in depth behind the route's superadmin_required middleware. The scoped counterpart is unchanged: it resolves against an RBAC scope and stays on the plain action path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jopemachine
force-pushed
the
feat/BA-6891-kernel-history-dto-service
branch
from
July 20, 2026 04:22
01a65ec to
e23c1a9
Compare
Member
Author
|
Closing: this PR was opened with the wrong head branch. It targeted |
3 tasks
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.
📚 Stacked PRs
BA-6927fix: stop cross-multiplying usage bucket amounts and durationsBA-6927refactor: rename usage_bucket_entries.amount to resource_seconds ← you are hereMerge in order, bottom-up. Each PR is based on the one above it, so its diff shows only its own layer.
Summary
usage_bucket_entries.amounttoresource_seconds. The column holds resource-seconds, not a resource amount, and under the old nameamount * duration_secondsreads like the quantity a caller wants — when both columns are already sums and their product is a cross product, which is exactly the shape of the bug fixed in fix(BA-6927): stop cross-multiplying usage bucket amounts and durations #12965.resource_usage_historyandfair_share) and the tests, plus an alembic column rename. No behaviour change.resource_usageJSONB rather than these entries.Test plan
pants test tests/unit/manager/repositories/resource_usage_history/ tests/unit/manager/repositories/retention/pants fmt/fix/lintpass on the changeset;pants check(mypy) cleanrepositories/{resource_usage_history,fair_share,retention}references the columnResolves BA-6927
🤖 Generated with Claude Code