Skip to content

Address pesap review feedback on #271#272

Merged
daniel-thom merged 4 commits intomainfrom
pesap-followups-271
Apr 21, 2026
Merged

Address pesap review feedback on #271#272
daniel-thom merged 4 commits intomainfrom
pesap-followups-271

Conversation

@daniel-thom
Copy link
Copy Markdown
Collaborator

Summary

Follow-ups on @pesap's review of #271 (which was merged before the comments could be addressed):

  • torc exec -- <cmd> vs spec-file hintdetect_spec_file_in_trailing runs before the -- delimiter branch, so torc exec -- cat workflow.yaml was getting steered toward torc run. Gated the check on !args.shell_command_delimited and added a regression test (exec_delimited_spec_like_arg_is_allowed).
  • --sample-interval-seconds overflow — the CLI parsed it as u32 with range 1.. and then cast to i32 when building ResourceMonitorConfig, which wraps negative for values above i32::MAX. Switched the arg to i32 (clap range 1..) and dropped the as i32 cast. ResourceMonitorConfig::sample_interval_seconds is already i32, so this just removes the lossy conversion.
  • torc -s tui doc — top-level -s is ignored for the tui subcommand (it's excluded from requires_server, so main.rs prints "has no effect … ignoring"). Changed the example to torc tui --standalone, which is the actual flag on tui_runner::Args.

Also moved the Run Inline Commands (torc exec) entry out of the first slot in SUMMARY.md, how-to/index.md, and introduction Key Features. torc exec is an alternative entry point rather than the main torc workflow, so it shouldn't lead these lists.

Test plan

  • cargo fmt --check
  • cargo clippy --all --all-targets --all-features -- -D warnings
  • dprint check
  • cargo nextest run --lib (265 passed)
  • cargo nextest run --test test_exec_cmd for exec_delimited_spec_like_arg_is_allowed, exec_spec_file_trailing_arg_suggests_torc_run, exec_non_delimited_trailing_arg_is_rejected (3 passed)

- exec_cmd: skip `detect_spec_file_in_trailing` when `--` was used so
  `torc exec -- cat workflow.yaml` is run as a shell command instead of
  being flagged as a `torc run` mistake. Added a regression test.
- cli: switch `--sample-interval-seconds` from `u32` (range `1..`) to
  `i32` (range `1..`) so the value can't wrap negative when assigned to
  `ResourceMonitorConfig::sample_interval_seconds`. Dropped the
  `as i32` cast in exec_cmd accordingly.
- docs: fix `torc -s tui` example (the top-level `-s` is ignored for
  `tui`; the working invocation is `torc tui --standalone`). Move the
  `torc exec` how-to out of the first slot in SUMMARY / how-to index /
  introduction Key Features since it's an alternative entry point, not
  the main workflow.
Adds a new HPC how-to covering the sbatch patterns enabled by the
ephemeral torc-server in #271:

- `torc -s run workflow.yaml` for single-node spec-driven jobs
- `torc -s exec -C commands.txt` for single-node ad-hoc command queues
- How to inspect the persisted database from the login node afterwards

Also documents the multi-node alternative (persistent torc-server bound
to a routable hostname + `srun`) and explains the standalone vs
multi-node tradeoff up front so users pick the right pattern.

Wired into SUMMARY.md and the HPC section index.
`torc exec` is an alternative entry point, not a core workflow, so it
shouldn't sit near the top of the cheat sheet. Moved it from just below
Quick Start to just above Remote Workers — alongside the other
specialized command groups.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR applies follow-up fixes to the torc exec CLI behavior and related documentation after review feedback on #271, improving correctness around ---delimited shell commands, resource monitor sampling interval handling, and standalone/TUI docs.

Changes:

  • Prevent spec-file hinting for torc exec -- <cmd ...> by gating spec detection on whether -- was used, and add a regression test.
  • Fix --sample-interval-seconds overflow by switching the CLI arg type to i32 and removing the lossy cast when building ResourceMonitorConfig.
  • Update/reorder docs and navigation, including a new HPC guide for running self-contained Slurm jobs.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_exec_cmd.rs Adds regression test ensuring torc exec -- ... workflow.yaml is treated as a shell command, not a spec hint.
src/exec_cmd.rs Skips spec-file hinting when -- is used; updates sampling interval type and removes as i32 cast.
src/cli.rs Changes --sample-interval-seconds parsing from u32 to i32 with >= 1 range enforcement.
docs/src/specialized/hpc/self-contained-slurm-job.md Adds a new guide for running workflows inside a single Slurm allocation via standalone mode.
docs/src/specialized/hpc/index.md Links the new self-contained Slurm job guide from the HPC index.
docs/src/introduction.md Reorders Key Features list to avoid leading with torc exec.
docs/src/core/reference/cli-cheatsheet.md Moves the Inline Commands section lower in the cheatsheet for better flow.
docs/src/core/how-to/run-inline-commands.md Updates TUI invocation example away from -s tui.
docs/src/core/how-to/index.md Reorders how-to index entries so inline commands aren’t first.
docs/src/SUMMARY.md Reorders summary entries and adds the new HPC page.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/exec_cmd.rs
Comment on lines 402 to 406
.as_ref()
.map(|j| j.granularity.clone())
.unwrap_or(MonitorGranularity::Summary),
sample_interval_seconds: sample_interval_seconds.map(|v| v as i32).unwrap_or(10),
sample_interval_seconds: sample_interval_seconds.unwrap_or(10),
generate_plots,
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

sample_interval_seconds is now Option<i32> and is written into ResourceMonitorConfig without validation. Because the resource monitor later converts this to a Duration via an as u64 cast, negative values (or 0) coming from non-CLI call sites could produce an extremely large interval / unexpected behavior. Consider validating sample_interval_seconds (>= 1) inside exec_cmd::run/build_spec before populating the spec, and returning a user-facing error if it’s invalid.

Copilot uses AI. Check for mistakes.
Comment thread docs/src/core/how-to/run-inline-commands.md
Reject `sample_interval_seconds < 1` at the single construction
chokepoint. Defends against hand-written workflow specs where the value
is 0 (busy-loop) or negative (wraps to a ~584-billion-year Duration via
the `as u64` cast in the monitoring loop).

The CLI already rejects invalid values at parse time, so this only
affects deserialized-spec paths. Caller in job_runner logs and falls
back to no-monitoring on failure, which is the same behavior as other
resource_monitor setup errors.

Added two unit tests: accept 1, reject 0/-1/i32::MIN.
@daniel-thom daniel-thom merged commit 128695d into main Apr 21, 2026
9 checks passed
@daniel-thom daniel-thom deleted the pesap-followups-271 branch April 21, 2026 12: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.

2 participants