Skip to content

refactor(hm-dsl-engine): Replace stringly-typed run() mode ("list"/"render") with an internal enum#113

Merged
markovejnovic merged 2 commits into
mainfrom
cq/hm-dsl-engine-replace-stringly-typed-run-mode-list-ren-14
Jun 10, 2026
Merged

refactor(hm-dsl-engine): Replace stringly-typed run() mode ("list"/"render") with an internal enum#113
markovejnovic merged 2 commits into
mainfrom
cq/hm-dsl-engine-replace-stringly-typed-run-mode-list-ren-14

Conversation

@markovejnovic

Copy link
Copy Markdown
Contributor

The smell

SubprocessTsEngine::run took the operation as a raw mode: &str, and the two
call sites passed the string literals "list" and "render". The same magic
strings were also branched on inside the embedded JS runner. The variant set was
implicit, and a typo like "lst" would compile fine and only fail at runtime in
the spawned JS process.

The change

Introduced a small private enum RunMode { List, Render } with an
as_arg(self) -> &'static str conversion. run now takes RunMode instead of
&str; list_pipelines passes RunMode::List and render_pipeline_json
passes RunMode::Render. The wire string now appears in exactly one place — the
enum's as_arg match.

This is fully crate-internal (a private method on a private enum), so the blast
radius is zero and the change is behavior-preserving: the exact same "list" /
"render" argument is still passed to the JS runner.

Type-safety pattern

Follows the fd "ValueEnum / strategy-enum over stringly-typed flag" pattern: a
closed set of operations modeled as an enum makes the dispatch exhaustive and
typo-proof at compile time, while keeping a single source of truth for the wire
string.

Validation

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

@markovejnovic markovejnovic marked this pull request as ready for review June 10, 2026 19:51
@markovejnovic markovejnovic merged commit 4afad53 into main Jun 10, 2026
17 checks passed
@markovejnovic markovejnovic deleted the cq/hm-dsl-engine-replace-stringly-typed-run-mode-list-ren-14 branch June 10, 2026 19:51
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