Skip to content

refactor(hm-vm): ImageRegistry capacity is a bare u64 where 0 silently makes the cache evict every entry#117

Merged
markovejnovic merged 3 commits into
mainfrom
cq/hm-vm-imageregistry-capacity-is-a-bare-u64-whe-9
Jun 10, 2026
Merged

refactor(hm-vm): ImageRegistry capacity is a bare u64 where 0 silently makes the cache evict every entry#117
markovejnovic merged 3 commits into
mainfrom
cq/hm-vm-imageregistry-capacity-is-a-bare-u64-whe-9

Conversation

@markovejnovic

Copy link
Copy Markdown
Contributor

The smell

render_prefs() returned (bool, bool) — two values of the same primitive type with no type-level distinction. Call sites destructured positionally:

  • crates/hm-plugin-cloud/src/verbs/build.rs:59let (color, logs) = …
  • crates/hm-plugin-cloud/src/verbs/job.rs:72let (color, _logs) = …

Swapping the two values in the function body, or a future call site binding them in the wrong order, compiles silently and inverts color/log behavior.

The change

render_prefs() now returns a named struct so each field is named at construction and at every call site:

#[derive(Debug, Clone, Copy)]
pub struct RenderPrefs {
    pub color: bool,
    pub logs: bool,
}

Call sites bind prefs and read prefs.color / prefs.logs instead of relying on tuple position. Behavior is unchanged — the same two values flow to hm_render::renderer_for in the same order.

(#[derive(Debug, ...)] is required because the crate denies missing-debug-implementations.)

Type-safety pattern

This applies the ripgrep/fd "replace bool/bool pairs with named fields or enums" guidance: same-typed positional booleans are a classic source of silent swap bugs. A named struct names each flag at construction and at every use site, so a wrong-order binding no longer type-checks into an inverted-behavior bug. This is a focused, behavior-preserving change touching only this function and its two callers.

Validation

Only cargo check -p hm-plugin-cloud was run locally (passes). Full CI runs on this PR.

@markovejnovic markovejnovic marked this pull request as ready for review June 10, 2026 20:28
@markovejnovic markovejnovic merged commit 6347385 into main Jun 10, 2026
17 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