Skip to content

refactor(harness): one is_executable instead of four - #253

Open
ArihantDeva wants to merge 1 commit into
RunanywhereAI:mainfrom
ArihantDeva:refactor/hoist-is-executable
Open

ArihantDeva wants to merge 1 commit into
RunanywhereAI:mainfrom
ArihantDeva:refactor/hoist-is-executable

Conversation

@ArihantDeva

@ArihantDeva ArihantDeva commented Nov 29, 2026 •

Copy link
Copy Markdown

deepsec, vvah, shannon and openwork each grew their own "is this path a regular file with an execute bit" check:

fn is_executable(path: &Path) -> bool {
    let Ok(metadata) = std::fs::metadata(path) else { return false; };
    if !metadata.is_file() { return false; }
    #[cfg(unix)]  { metadata.permissions().mode() & 0o111 != 0 }
    #[cfg(not(unix))] { true }
}

Three copies are byte-identical. The fourth, in openwork.rs, was written differently and disagreed off unix — it answered path.is_file() where the others answered true. Nothing reads differently on the platforms this ships to, which is why the drift stayed invisible: a fifth copy would have been written by copying whichever one was nearest.

There is now one in crate::util, with the is_file() requirement kept (a directory carrying 0o755 is not a program) and the off-unix answer left as true, matching three of the four.

The test pins the distinction that is easy to lose rather than restating the body:

  • a directory with the execute bit is not executable
  • a missing path is false, not an error
  • a plain file with no x bit is not executable

Dropping the is_file() guard fails it, so it covers the case the copies quietly disagreed about.

Verification

  • cargo test --lib: 631 passed (630 + the new test)
  • cargo fmt --check clean, cargo clippy --all-targets -- -D warnings clean
  • Net −68/+67 across five files; the four call sites are unchanged

Note on building this branch: plain main does not link on macOS here — -nostdinc++ and its SDK operand reach cc as an input file. That is #245; I applied it locally to run the gate and left it out of this PR.


Summary by cubic

Consolidates the four duplicated is_executable helpers in the harness modules (deepsec, vvah, shannon, openwork) into a single crate::util::is_executable. The copies behaved identically on Unix but disagreed off-Unix: three answered true and openwork answered path.is_file(), a drift that nothing exercised. The shared helper keeps the is_file() guard and the true off-Unix answer, and the four call sites are unchanged.

Verification

  • New test covers a directory with the execute bit (not executable), a missing path (false, not an error), and a plain file without any x bit.
  • cargo test --lib passes 631 tests, with cargo fmt and cargo clippy --all-targets -- -D warnings clean.

Written for commit 2a13e5a. Summary will update on new commits.

View guided diff

Summary by CodeRabbit

  • Refactor
    • Application launch eligibility is checked consistently across the supported harnesses and platforms. Missing paths and paths that do not point to regular files are not treated as launchable. On Unix, a file must also have an execute permission; on other platforms, a regular file is considered launchable.
    • No user-facing features or workflows changed.

deepsec, vvah, shannon and openwork each grew the same "is this path a regular
file with an execute bit" check. They agreed on behaviour but not on spelling,
and disagreed outright off unix: three answered `true`, openwork answered
`path.is_file()`. Nothing read differently on the platforms this ships to, which
is exactly why the drift was invisible -- a fourth copy would have been written
by copying whichever one was nearest.

Declared once in `crate::util`, with the `is_file()` requirement kept (a
directory carrying 0o755 is not a program) and the off-unix answer left as
`true`, which is what three of the four already did.

The new test pins the part that is easy to lose: a directory with the execute
bit is not executable, a missing path is `false` rather than an error, and a
plain file without any x bit is not executable. Removing the `is_file()` guard
fails it, so it is covering the distinction rather than restating the body.

Net -68/+67 across five files; the four call sites are unchanged.
@ArihantDeva
ArihantDeva requested a review from a team as a code owner November 29, 2026 02:00
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Four harness modules now use a shared executable-check utility. The utility checks regular files and applies platform-specific rules. Tests cover executable permissions, directories, and missing paths.

Changes: Shared executable-check utility

Layer / File(s) Summary
Shared executable-check utility and tests
src/util/mod.rs
Adds public is_executable, which rejects unreadable paths and non-regular files. On Unix, regular files require an execute bit; on non-Unix platforms, regular files pass. Tests cover these rules and missing paths.
Harness adoption of the shared utility
src/harness/deepsec.rs, src/harness/openwork.rs, src/harness/shannon.rs, src/harness/vvah.rs
Imports the shared is_executable utility and removes the local implementations from each harness module.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: sanchitmonga22, siddhesh2377

Merge Risk: Minimal · up to 2a13e

This is a behavior-preserving refactor that consolidates duplicated executable checks into one shared utility. No user-facing or production risk was identified, and it is ready to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "refactor(harness): one is_executable instead of four" matches the main change. The PR moves four duplicated executable-path checks from deepsec, vvah, shannon, and openwork into one shared …
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.
Full details: Title check

Explanation

The title "refactor(harness): one is_executable instead of four" matches the main change. The PR moves four duplicated executable-path checks from deepsec, vvah, shannon, and openwork into one shared is_executable function in crate::util. The title is short, specific, and names the function, so a reviewer scanning history can see the primary change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d16e7563-5839-4238-94db-1a3cbfd524d3
Commits

Reviewing files that changed from the base of the PR and between e2b4776 and 2a13e5a.

Files selected for processing: 5

  • src/harness/deepsec.rs
  • src/harness/openwork.rs
  • src/harness/shannon.rs
  • src/harness/vvah.rs
  • src/util/mod.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/util/mod.rs">

<violation number="1" location="src/util/mod.rs:260">
P3: This explanatory comment is missing the two function names, so it no longer says which old implementation used which check. Restore `path.is_file()` and `metadata.is_file()` in the comment.</violation>

<violation number="2" location="src/util/mod.rs:268">
P3: The non-Unix test branch never verifies that directories are rejected, so a Windows regression in the regular-file guard would pass. Add the same directory assertion to that branch.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread src/util/mod.rs
assert!(!is_executable(&plain), "regular file without any x bit");
// A directory carrying the execute bit is not a program. This is
// the case the copies agreed on only by accident -- one of them
// answered off unix and merely on it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This explanatory comment is missing the two function names, so it no longer says which old implementation used which check. Restore path.is_file() and metadata.is_file() in the comment.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/util/mod.rs, line 260:

<comment>This explanatory comment is missing the two function names, so it no longer says which old implementation used which check. Restore `path.is_file()` and `metadata.is_file()` in the comment.</comment>

<file context>
@@ -211,4 +239,38 @@ mod tests {
+            assert!(!is_executable(&plain), "regular file without any x bit");
+            // A directory carrying the execute bit is not a program. This is
+            // the case the copies agreed on only by accident -- one of them
+            // answered  off unix and merely  on it.
+            std::fs::set_permissions(dir.path(), std::fs::Permissions::from_mode(0o755))
+                .expect("chmod dir");
</file context>
Suggested change
// answered off unix and merely on it.
// answered `path.is_file()` off Unix and merely `metadata.is_file()` on it.

Comment thread src/util/mod.rs
#[cfg(not(unix))]
{
assert!(is_executable(&executable));
assert!(is_executable(&plain), "no execute bit to read off unix");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The non-Unix test branch never verifies that directories are rejected, so a Windows regression in the regular-file guard would pass. Add the same directory assertion to that branch.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/util/mod.rs, line 268:

<comment>The non-Unix test branch never verifies that directories are rejected, so a Windows regression in the regular-file guard would pass. Add the same directory assertion to that branch.</comment>

<file context>
@@ -211,4 +239,38 @@ mod tests {
+        #[cfg(not(unix))]
+        {
+            assert!(is_executable(&executable));
+            assert!(is_executable(&plain), "no execute bit to read off unix");
+        }
+
</file context>
Suggested change
assert!(is_executable(&plain), "no execute bit to read off unix");
assert!(is_executable(&plain), "no execute bit to read off unix");
assert!(!is_executable(dir.path()), "a directory is not executable");

This branch has not been deployed

No deployments
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