Skip to content

ROX-36764: Add rules for default work arguments - #61

Merged
erthalion merged 1 commit into
mainfrom
feature/default-values-rules
Sep 4, 2026
Merged

ROX-36764: Add rules for default work arguments#61
erthalion merged 1 commit into
mainfrom
feature/default-values-rules

Conversation

@erthalion

Copy link
Copy Markdown
Collaborator

Extend rules to apply new type of rule -- to add default values to work arguments, if they were omitted. Currently only number of workers and duration is set, so that

main() {}

is transformed into

main(workers=1, duration=0) {}

where duration=0 means run until stopped.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: 196928e5-f5b8-4f07-b9f2-6e1a71727055

📥 Commits

Reviewing files that changed from the base of the PR and between 8cf70c6 and 508455f.

📒 Files selected for processing (1)
  • src/script/rules.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Work instructions now use default values of 1 worker and 0 duration when these settings are omitted.
    • Custom worker counts and durations are preserved.
    • Defaults are applied consistently before scripts run, including scripts that combine machine and work instructions.
    • Script execution now handles mixed instruction types more reliably.
  • Tests
    • Added coverage for default settings and custom work instruction values.

Walkthrough

apply_rules now adds default workers and duration arguments to work nodes before run_script partitions and executes them. Custom values remain unchanged. Tests cover both cases.

Changes

Work Argument Defaults

Layer / File(s) Summary
Node rule pipeline
src/script/rules.rs
apply_rules now accepts and returns owned nodes. Work nodes receive workers=1 and duration=0 when absent. Machine nodes remain unchanged.
Script execution integration
src/main.rs
run_script applies rules before partitioning nodes and requires the resulting arguments. Tests cover default and custom work arguments.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 50845

Work nodes now receive default workers and duration values when omitted while preserving explicit values. No merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding rules for default work arguments.
Description check ✅ Passed The description directly explains the default values for workers and duration and provides a relevant transformation example.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/default-values-rules

Warning

Some tools did not complete. Review the errors below.

🔧 Clippy (1.97.1)

Clippy execution failed


Comment @coderabbitai help to get the list of available commands.

@Molter73 Molter73 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, just a few comments on ownership in the rules.rs file.

Comment thread src/script/rules.rs Outdated
Comment thread src/script/rules.rs Outdated
Comment on lines +9 to +12
if !new_args.contains_key("workers") {
debug!("Applying default number of workers");
new_args.insert("workers".to_string(), "1".to_string());
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] If we remove the debug statement, these assignments could be condensed to:

let _ = new_args.entry("workers").or_insert("1".to_string);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to_string part has to stay in both cases anyway. Having this in mind, how is it condensed?

new_args.insert("workers".to_string(), "1".to_string());

// vs

let _ = new_args.entry("workers".to_string()).or_insert("1".to_string());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don need to the the initial check, you can go from

    if !new_args.contains_key("workers") {
        new_args.insert("workers".to_string(), "1".to_string());
    }

To just:

    let _ = new_args.entry("workers").or_insert("1".to_string());

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see what you mean. But I find the debug message valuable here, how about or_insert_with?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or_insert_with leaves you with the same number of lines I think, so I'm fine leaving it as is or changing it, whichever you find more readable.

Comment thread src/script/rules.rs
Comment thread src/script/rules.rs
@erthalion
erthalion force-pushed the feature/default-values-rules branch 3 times, most recently from 8cf70c6 to 79d8dd2 Compare September 4, 2026 10:25
Extend rules to apply new type of rule -- to add default values to work
arguments, if they were omitted. Currently only number of workers and
duration is set, so that

    main() {}

is transformed into

    main(workers=1, duration=0) {}

where duration=0 means run until stopped.
@erthalion
erthalion force-pushed the feature/default-values-rules branch from 79d8dd2 to 508455f Compare September 4, 2026 11:36

@Molter73 Molter73 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@erthalion
erthalion merged commit 176cd70 into main Sep 4, 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.

2 participants