Skip to content

refactor(BA-6927): rename usage_bucket_entries.amount to resource_seconds#12967

Closed
jopemachine wants to merge 7 commits into
fix/BA-6927-usage-bucket-cross-productfrom
feat/BA-6891-kernel-history-dto-service
Closed

refactor(BA-6927): rename usage_bucket_entries.amount to resource_seconds#12967
jopemachine wants to merge 7 commits into
fix/BA-6927-usage-bucket-cross-productfrom
feat/BA-6891-kernel-history-dto-service

Conversation

@jopemachine

@jopemachine jopemachine commented Jul 20, 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.

Summary

  • Rename usage_bucket_entries.amount to resource_seconds. The column holds resource-seconds, not a resource amount, and under the old name amount * duration_seconds reads 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.
  • Mechanical rename across the ORM model, the two repository read paths (resource_usage_history and fair_share) and the tests, plus an alembic column rename. No behaviour change.
  • Split out of fix(BA-6927): stop cross-multiplying usage bucket amounts and durations #12965 so the correctness fix can be reviewed without the rename churn, and so the rename can be dropped independently if it is not wanted. The table is internal — only the three repository modules read it, and the GraphQL/REST surface exposes the bucket tables' resource_usage JSONB rather than these entries.

Test plan

  • pants test tests/unit/manager/repositories/resource_usage_history/ tests/unit/manager/repositories/retention/
  • pants fmt/fix/lint pass on the changeset; pants check (mypy) clean
  • Confirmed no consumer outside repositories/{resource_usage_history,fair_share,retention} references the column

Resolves BA-6927

🤖 Generated with Claude Code

HyeockJinKim and others added 3 commits July 20, 2026 10:51
…tory CLI (#12963)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…#12887)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ers (#12867)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the size:XL 500~ LoC label Jul 20, 2026
@github-actions github-actions Bot added comp:manager Related to Manager component comp:common Related to Common component labels Jul 20, 2026
jopemachine added a commit that referenced this pull request Jul 20, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jopemachine and others added 4 commits July 20, 2026 13:21
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
jopemachine force-pushed the feat/BA-6891-kernel-history-dto-service branch from 01a65ec to e23c1a9 Compare July 20, 2026 04:22
@jopemachine

Copy link
Copy Markdown
Member Author

Closing: this PR was opened with the wrong head branch. It targeted feat/BA-6891-kernel-history-dto-service (unrelated work, tracked in #12869) instead of the rename branch, so its diff is meaningless. Reopening from the correct branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants