Skip to content

fix(cli): one trusted PATH rule for the engine and CLI; say why a project copy was skipped - #7801

Merged
jrusso1020 merged 5 commits into
mainfrom
rames/cli-one-trusted-path-rule
Nov 15, 2026
Merged

jrusso1020 merged 5 commits into
mainfrom
rames/cli-one-trusted-path-rule

Conversation

@jrusso1020

Copy link
Copy Markdown
Collaborator

Engine helper lookups and the CLI's PATH rewrite now use one trusted-folder rule, including the Windows cases. When sam, aws, gcloud, docker, git or npx isn't found but the project holds a copy the rule skipped, the error now names that copy and says why it wasn't used.

Claude Opus 5.5

One rule

The Windows PATH rules the CLI added (reading "C:\Program Files\..." entries without their quotes, and always keeping the %SystemRoot% folders: Windows, System32, Wbem, WindowsPowerShell\v1.0) now live in trustedPathDirs in packages/parsers/src/trustedExecutable.ts. It takes optional platform and env arguments that default to the running process. The CLI's withOnlyTrustedPathFolders calls it directly, so findTrustedExecutable (used by the engine for nvidia-smi, vm_stat, ps and tasklist) can't disagree with the CLI.

User effect: on Windows the engine now finds helpers in quoted PATH entries, and finds tasklist when started from inside System32. Linux and macOS are unchanged.

Why a project copy was skipped

New projectCopyHint(name) in packages/cli/src/utils/projectCopyHint.ts looks through the PATH the CLI started with for folders the trusted rule dropped. If one holds name, it returns a sentence naming the copy by its path relative to the working directory (never an absolute path), for example:

`sam` CLI not found on PATH. Install AWS SAM CLI from https://docs.aws.amazon.com/... and retry. A copy at ./.venv/bin/sam was not used: HyperFrames only runs programs from folders outside the current project. Install sam outside the project and retry.

With no such copy the message is unchanged. Used in:

  • lambda (sam, aws)
  • cloudrun (gcloud, docker): a missing program is now reported as not found instead of "exited with null"
  • render --docker (the "Docker not available" hint)
  • skills (git, npx)

executableIn and pathEntries are exported from the parsers so the hint reuses the same program check and PATH parsing.

Verification

  • New tests: parsers trustedPathDirs on Windows (quoted entry, System32 kept, SystemRoot honoured) and the Windows findTrustedExecutable case with a quoted entry; CLI projectCopyHint tests (copy named relative to the project, relative PATH entry, no copy, never a copy outside the working directory) and a lambda test for the sam message. With the parsers change reverted the 4 Windows tests fail; with the sam hint reverted its test fails.
  • The two CLI System32 tests moved to the parsers; the CLI quoted-entry test stays and goes through the shared rule.
  • parsers: 1506 passed. CLI utils, lambda, doctor, skills, cloudrun: all non-browser tests pass.
  • Ran the CLI from a project with sam in .venv/bin and gcloud in node_modules/.bin: both messages name the copy; from a project without them the messages are unchanged.

Authored by Rames (api-platform).

🤖 Generated with Claude Code

…ject copy was skipped

The Windows PATH rules (quoted entries, the %SystemRoot% folders) now live in
the parsers' trustedPathDirs, so engine helper lookups and the CLI's PATH
rewrite apply the same rule.

When sam, aws, gcloud, docker, git or npx is not found but a copy sits in a
project folder the rule skipped, the message names that copy by its path
relative to the project and says why it was not used. cloudrun now reports a
missing gcloud or docker as not found instead of "exited with null".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 267 (base branch 267), smooth 106 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (8)

The shared trusted-folder rule now splits PATH on ';' whenever the platform
is win32, as Windows does. Two tests that pretend to be Windows on Linux
built PATH with ':', so the rule saw one folder instead of two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jrusso1020 jrusso1020 left a comment

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.

Reviewed at 79d5314

Merits verdict: APPROVE — no blocker found. Posted as COMMENT because this PR and the reviewer use the same GitHub account.

The shared parser retains Windows PATH splitting on semicolons, removes paired entry quotes, and preserves the existing SystemRoot-folder exceptions when those folders appear on PATH. POSIX tilde expansion and directory trust checks are unchanged. Both the CLI rewrite and engine helper lookup now use that implementation. The browser/whisper fixture changes correct the separator for the simulated platform while retaining rejection of the project copy and selection of the outside copy.

The new hint checks skipped PATH folders without running their programs. It emits a path relative to cwd only after excluding parent/sibling and absolute results. The SAM/AWS, Cloud Run, Docker and skills call sites append it to failure diagnostics; it does not change successful execution or authorize a skipped program.

Validation: frozen install and full bun run build passed. bun run --cwd packages/parsers test src/trustedExecutable.test.ts src/ffBinaries.test.ts --maxWorkers=1 passed 31 tests. The eight focused CLI suites for PATH filtering, hints, Docker errors, SAM, Cloud Run, skills, whisper and browser resolution passed 159 tests. Replacing trustedPathDirs with its base implementation caused exactly four Windows regression failures; removing the SAM hint caused its new assertion to fail. Both mutations were restored. Windows behavior was simulated on Linux; no native Windows or live cloud deployment test was run.

Nit: projectCopyHint.ts:26 interpolates a project-controlled filename into terminal text. Quote/escape control characters in the displayed relative path (for example, display JSON.stringify(copy)) so unusual folder names cannot alter the diagnostic's presentation. This does not affect the executable trust decision.

Need: yes · Size: ok · Reuse: shared trustedPathDirs, pathEntries and executableIn · Simpler: one PATH policy for CLI and engine · Structure: fine (checked the former CLI Windows policy, parser lookup and all hint consumers; no further split)
Risk: medium — shared executable discovery changes on Windows; native Windows validation remains limited.

Verdict: APPROVE on the merits (COMMENT only on this account's own PR).
Reasoning: The Windows rules are consolidated without widening POSIX trust, the new hint avoids absolute project paths, and the relevant regressions fail when the fixes are removed.

— Rames

@miguel-heygen miguel-heygen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at 79d5314. The idea is right and every bare-name CLI call is covered once cli.ts:35 rewrites PATH, but the branch predates hf#7845 and rewrites the same file (mergeStateStatus DIRTY).

Blocking:

  1. As written it would undo hf#7845: main's trustedExecutable.ts:48-62 drops every ancestor node_modules (:39-45) and the whole project root (:31-37) and matches not-yet-existing folders by real location; this version (:27-34, :78-90) only drops folders inside the working directory. Rebase, fold the Windows system-folder rule and the quote handling into main's single rule, keep #7845's tests.
  2. projectCopyHint.ts:5-7,17 names only copies inside the working directory, so the common ../node_modules/.bin case (npm/pnpm scripts) gets no hint. Name any copy main's rule skipped, as a relative ../ path.

Not blocking:
3. trustedPathDirs (:78-90): platform changes how PATH is split but the trust check uses the real OS's rules; pass it through or drop the setting.
4. Windows system folders trusted by name (:63-75,87): fine.

jrusso1020 and others added 2 commits November 15, 2026 21:08
Resolve trustedExecutable.ts onto main's single trust rule: trustedPathDirs
filters PATH with main's trustRule() (project root and ancestor
node_modules included) and adds this branch's Windows system folders and
quoted-entry handling on top of it, rather than replacing it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ATH to the shared rule

The not-found hint now names any copy the trusted PATH rule skipped,
relative to the working folder, including ../node_modules/.bin when an
npm or pnpm script runs from a subfolder. A Windows test pins that quoted
PATH entries still go through the shared rule, so the project root's and
ancestors' node_modules/.bin stay skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jrusso1020

Copy link
Copy Markdown
Collaborator Author

Thanks. Main is merged in and both blockers are addressed at fc8dc189.

  1. Folded into main's rule, not replacing it. trustedExecutable.ts now differs from main only by additions. trustedPathDirs filters PATH with main's trustRule() (project root, every ancestor node_modules, not-yet-existing folders matched by real location), then adds the Windows system folders and the quoted-entry handling on top. Main's tests are all kept and pass. A new Windows test pins that quoted entries for the project root's and an ancestor's node_modules/.bin are still skipped. With the pre-merge file, that test fails along with six of main's tests.
  2. ../node_modules/.bin copies. skippedProjectCopy now names any copy the rule skipped, relative to the working folder: ./… inside it, ../… above it (e.g. ../node_modules/.bin/npx from a subfolder). The hint now says "absolute PATH folders outside the current project". Two new tests cover a subfolder of a project and a relative entry outside the working folder, and both fail with the old hint.
  3. platform in trustedPathDirs (not blocking): I left it. It only controls how PATH is split and unquoted, which is what withOnlyTrustedPathFolders needs when it rewrites a Windows-shaped environment. The trust check deliberately keeps the real OS's path rules, because it inspects real folders on this machine. Happy to drop the parameter if you'd rather.

Checks:

  • packages/parsers trustedExecutable + ffBinaries: 38 passed.
  • packages/cli projectCopyHint + windowsExeSearch + trustedLookup: 21 passed.
  • tsc --noEmit is clean in both packages, and oxlint/oxfmt are clean.
  • Run with a TMPDIR that has no project marker above it, and with packages/parsers rebuilt, since the CLI resolves its dist under node.

@miguel-heygen miguel-heygen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved at fc8dc18. Both blockers fixed: main's single rule in trustedExecutable.ts is unchanged (project root :42-48, ancestor node_modules :50-56, real location of not-yet-existing folders :21-33) with quote handling and the Windows system folders folded in at :89-130, the separate windowsExeSearch copy is gone, and every #7845 test is still there plus a Windows one. projectCopyHint.ts now names any skipped copy, ../node_modules/.bin included. One thing before merge: the Comments check is red on projectCopyHint.ts's comment share (5 of 35 lines vs the package's 9.3%); cut about two comment lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@miguel-heygen miguel-heygen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-approved at 1d76e30: the only change since fc8dc18 shortens comments in projectCopyHint.ts (+1/-6, no code lines).

@jrusso1020
jrusso1020 added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit e2430ed Nov 15, 2026
84 checks passed
@jrusso1020
jrusso1020 deleted the rames/cli-one-trusted-path-rule branch November 15, 2026 21:56
timothybrush pushed a commit to timothybrush/hyperframes that referenced this pull request Nov 15, 2026
* chore: release v0.9.55

* chore: release v0.9.55 notes include heygen-com#7830

* chore: release v0.9.55 notes include heygen-com#7859 and heygen-com#7867

* chore: release v0.9.55 notes name the docs change and cloud render

* chore: release v0.9.55 notes include heygen-com#7866 and heygen-com#7801

* chore: release v0.9.55 notes match the style bar
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