Skip to content

Require explicit recursive workspace lookup (#646) - #672

Draft
leynos wants to merge 1 commit into
mainfrom
issue-646-require-explicit-opt-in-for-recursive-workspace-executable-resolution
Draft

Require explicit recursive workspace lookup (#646)#672
leynos wants to merge 1 commit into
mainfrom
issue-646-require-explicit-opt-in-for-recursive-workspace-executable-resolution

Conversation

@leynos

@leynos leynos commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Summary

This branch makes recursive workspace executable discovery an explicit
cwd_mode='workspace-recursive' opt-in. Default which and
command_available now search only PATH, preventing an empty or unset PATH
from resolving a checkout-controlled helper.

Closes #646.

Review walkthrough

Validation

  • make check-fmt: passed
  • make lint: passed
  • make doc-coverage: passed (99.14%)
  • make test: passed (2,800 nextest tests; 32 doctests passed, 6 ignored)

References

Summary by Sourcery

Require explicit opt-in for recursive workspace executable discovery while making PATH-only lookup the secure default.

New Features:

  • Add an explicit cwd_mode="workspace-recursive" option for intentional recursive workspace executable discovery.

Bug Fixes:

  • Prevent empty or unset PATH values from implicitly resolving checkout-controlled executables.
  • Update lookup diagnostics and localization to explain the explicit recursive-search opt-in.

Enhancements:

  • Define distinct flat PATH, current-directory, and recursive workspace search semantics across which and command_available.
  • Include the new search mode in resolver caching, documentation, migration guidance, and architectural security decisions.

Documentation:

  • Document the new executable discovery contract, security boundary, migration path, and ADR.

Tests:

  • Add unit, feature, integration, and snapshot coverage for search modes, empty or unset PATH behavior, cache separation, and invalid options.

Chores:

  • Update changelog entries and localized which messages for the new resolver behavior.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Warning

Your free Security trial is over. An organization admin can upgrade to Advanced for continuous pull request security review or dismiss this notice.


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

@sourcery-ai

sourcery-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR changes executable lookup to a PATH-only default and introduces an explicit cwd_mode='workspace-recursive' opt-in for bounded recursive workspace discovery, with corresponding resolver logic, cache and diagnostic updates, comprehensive regression coverage, and migration/security documentation.

Sequence diagram for explicit recursive workspace executable lookup

sequenceDiagram
    participant Caller
    participant WhichResolver
    participant Lookup
    participant Workspace

    Caller->>WhichResolver: resolve(command, options)
    WhichResolver->>Lookup: PATH lookup
    alt PATH match found
        Lookup-->>WhichResolver: matches
    else PATH miss
        alt cwd_mode == WorkspaceRecursive
            Lookup->>Workspace: search_workspace(env.cwd, command, options.all, workspace_skips)
            Workspace-->>Lookup: discovered paths
            Lookup-->>WhichResolver: matches or not_found
        else other cwd_mode
            Lookup-->>WhichResolver: not_found
        end
    end
    WhichResolver-->>Caller: result
Loading

Flow diagram for PATH-only default and recursive opt-in

flowchart TD
    A["which or command_available"] --> B{"cwd_mode"}
    B -->|auto| C["Search PATH only"]
    B -->|always| D["Search workspace root, then PATH"]
    B -->|never| E["Search non-empty PATH entries"]
    B -->|workspace-recursive| F["Search PATH first"]
    F --> G{"PATH miss?"}
    G -->|yes| H["search_workspace"]
    G -->|no| I["Return PATH match"]
    C --> J["Missing command remains absent"]
    D --> J
    E --> J
    H --> K["Return bounded workspace match or not_found"]
Loading

File-Level Changes

Change Details Files
Make recursive workspace executable discovery an explicit resolver mode while preserving flat search modes.
  • Add workspace-recursive parsing and option semantics.
  • Restrict auto and command_available defaults to explicit PATH directories, including no lookup for empty or unset PATH.
  • Run the existing bounded workspace walker only after a miss in the explicit recursive mode.
  • Ensure current-directory handling, miss diagnostics, cache keys, and workspace kill-switch behavior distinguish the new mode.
src/stdlib/which/options.rs
src/stdlib/which/env.rs
src/stdlib/which/lookup/mod.rs
src/stdlib/which/cache.rs
src/stdlib/which/mod.rs
src/localization/keys.rs
Add regression coverage for the trust-boundary and resolver contract.
  • Test that nested checkout executables resolve only with workspace-recursive.
  • Update cache, unit, feature, integration, predicate, and workspace-switch tests for the changed defaults and opt-in behavior.
  • Cover invalid mode handling and updated not-found diagnostics.
src/stdlib/which/lookup/tests.rs
tests/features/stdlib.feature
tests/std_filter_tests/which_filter_tests.rs
tests/stdlib_which_tests.rs
tests/stdlib_workspace_switch_tests.rs
tests/snapshots/which_diagnostic_snapshot_tests__which_args_invalid_cwd_mode.snap
tests/snapshots/which_diagnostic_snapshot_tests__which_not_found.snap
Document and announce the breaking search-domain change and migration path.
  • Record the security decision and alternatives in a new ADR.
  • Update design and user documentation with mode semantics, trust-boundary guidance, and kill-switch behavior.
  • Add migration guidance, changelog entries, and documentation index coverage.
docs/adr-018-require-explicit-recursive-workspace-which-search.md
docs/netsuke-design.md
docs/users-guide.md
docs/v0-1-0-migration-guide.md
docs/contents.md
CHANGELOG.md
Update localized resolver diagnostics for the new mode and workspace-search hint.
  • Add a localized workspace-recursive hint and accept the new mode in invalid-argument messages.
  • Update all shipped locale message catalogs to reflect the new search semantics.
locales/ar/messages.ftl
locales/cs/messages.ftl
locales/cy/messages.ftl
locales/da/messages.ftl
locales/de/messages.ftl
locales/el/messages.ftl
locales/en-GB/messages.ftl
locales/en-US/messages.ftl
locales/es-419/messages.ftl
locales/es-ES/messages.ftl
locales/fa/messages.ftl
locales/fi/messages.ftl
locales/fr/messages.ftl
locales/gd/messages.ftl
locales/he/messages.ftl
locales/hi/messages.ftl
locales/hu/messages.ftl
locales/id/messages.ftl
locales/it/messages.ftl
locales/ja/messages.ftl
locales/ko/messages.ftl
locales/nb/messages.ftl
locales/nl/messages.ftl
locales/pl/messages.ftl
locales/pt-BR/messages.ftl
locales/pt-PT/messages.ftl
locales/ro/messages.ftl
locales/ru/messages.ftl
locales/sv/messages.ftl
locales/th/messages.ftl
locales/tr/messages.ftl
locales/uk/messages.ftl
locales/vi/messages.ftl
locales/zh-Hans/messages.ftl
locales/zh-Hant/messages.ftl

Assessment against linked issues

Issue Objective Addressed Explanation
#646 Change default which and cwd_mode='auto' resolution to search only explicit PATH directories, so empty or unset PATH cannot recursively resolve executables from the workspace.
#646 Require a clearly named explicit opt-in for recursive workspace executable discovery, while defining cwd_mode='always' as a flat current-directory/workspace-root search rather than implicitly recursive.
#646 Preserve recursive lookup behavior and distinguish search modes in caching, tests, and user/design documentation, while retaining existing PATH, direct-path, platform, skip-list, symlink, executability, canonicalization, all, and cache behavior.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

codescene-access[bot]

This comment was marked as outdated.

Keep the default `which` and `command_available` search domain limited to
PATH, and require `cwd_mode="workspace-recursive"` before scanning
checkout-controlled executables.

Preserve the existing recursive walk behind that explicit mode, with its
cache, skip-list, canonicalization, executable, and platform behaviour.
Document the trust boundary and update the complete test and diagnostic
coverage.
@leynos
leynos force-pushed the issue-646-require-explicit-opt-in-for-recursive-workspace-executable-resolution branch from 9852e7b to c72a789 Compare September 4, 2026 11:20
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@codescene-access codescene-access 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.

No quality gates enabled for this code.

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.

Require explicit opt-in for recursive workspace executable resolution

1 participant