Skip to content

Refactor before container CPU: one Sort, shared fixtures, view formatting - #10

Merged
bencode merged 1 commit into
mainfrom
refactor
Oct 5, 2026
Merged

bencode merged 1 commit into
mainfrom
refactor

Conversation

@bencode

@bencode bencode commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

A behaviour-preserving clean-up before container CPU (iteration 2). A structural review of main found no correctness issues. It did find duplication and hard-coded branches that iteration 2 would multiply.

What changes

Item Change
One Sort next, label, column (which header gets ▼) and order. The memory sort was spread over six == Sort::Memory checks; with this, adding CPU means one variant plus its match arms.
Shared fixtures skym_core::fixtures::{app, workload, host_overview, incident} are built from minimal JSON, with serde defaults for the rest. Tests set only what they assert on (AppSummary { status: Warn, ..fixtures::app("x/shop") }). The full literals and copies are gone: 8 AppSummary, 5 IncidentView, 2 HostOverview, 3 JSON workload builders. The server's integration tests share down() and app_config() in tests/common. HostEntry derives Default (a config type).
ui/format.rs Times, sizes, rates, CPU and a URL's answer, which was written twice, now live here. preview.rs goes from 452 to 379 lines, ui/mod.rs from 332 to 303.
Server views::summary() replaces four copies of links + workload_summary. App links come from links(&Subject::App). AppView reuses the app's workloads instead of recomputing them.
View lookups App::apps_iter, app_summary and host_summary replace the repeated chains. The filter's text for an app moves into filter.rs.

28 files: +287 −521.

No behaviour change: how it was checked

  • Before touching anything, every screen the view's render tests draw and every API body the server's tests fetch were captured on main, 29 files in all. They were captured again after the refactor, with timestamps normalized: byte-identical.
  • One documented difference that the captures don't exercise: an application's workloads in AppView are now problems first and then by key, like everywhere else. Before, they were ordered by key. The view already re-sorts them.
  • 258 tests pass; clippy and fmt are clean.
  • cargo-mutants on the diff: 53 mutants, none missed.
  • An independent review traced each item, including the server's ordering, fixture defaults versus the old literals, and string identity of the moved helpers. It found no behaviour change besides the documented one.

Not done, deliberately

  • workload.rs using label(): it would dim those labels, a visible change.
  • Removing customers: that comes next, in its own PR (a protocol and config removal).
  • The agent's cgroup module: it goes into iteration 2's design.

No deploy is needed; the next deploy carries this.

…ting

No behaviour change: every view render-test screen and every API body the
server tests fetch are byte-identical before and after (timestamps
normalized), except the order of an application's workloads in AppView,
now problems first like everywhere else (the view sorts them anyway).

- Sort knows its next order, label, sorted column and comparison; the
  memory sort is no longer wired into six places.
- skym_core::fixtures gains app, workload, host_overview and incident: tests
  set only what they assert on, so a new field needs no test edits. Server
  integration tests share down() and app_config() in tests/common.
- The view's formatting (times, sizes, rates, CPU, a URL's answer) lives in
  ui/format.rs.
- The server builds a workload summary in one place and reuses an app's
  workloads for AppView; app links come from links().
- App::apps_iter, app_summary and host_summary replace repeated lookups;
  the filter's text for an application lives in filter.rs.
@bencode
bencode merged commit d89f89a into main Oct 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant