Skip to content

fix: map local runtime paths without rewriting host paths - #941

Merged
rng1995 merged 4 commits into
NVIDIA:mainfrom
Afloat16:fix/local-shell-path-mapping-20261130b
Nov 30, 2026
Merged

rng1995 merged 4 commits into
NVIDIA:mainfrom
Afloat16:fix/local-shell-path-mapping-20261130b

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Current integration update

Source: 02eb256105db493a76193874a184697d8cf58ba7; main: 38cb609a36cb02360c2e737eb6ce2d982be860a5. Merged main and preserved upstream changes; only the CHANGELOG conflict needed manual resolution.

Validation on this source: The local environment/mode modules reported 385 passed, 3 skipped, 6 deselected, and 2 failures. Both failing absolute /workspace download cases reproduce on unmodified main with the same FileNotFoundError before their expected containment error. Repository Ruff checks and whitespace checks passed. The earlier results below apply to their recorded revisions; current-head CI must be evaluated separately.

Original contribution and validation before this integration update

Summary

Local evaluation breaks when the host run directory shares a virtual path component such as /workspace: a translated host path can be mapped a second time, changing artifact, working-directory or interpreter locations.

Map only original command text, prefer the longest matching root, retain shell quoting and preserve known host run/runtime/interpreter paths. Resolve an already-local working directory before considering virtual aliases, with containment checks intact. URLs, relative path suffixes, adjacent text and longer root names retain their meaning.

The review follow-up preserves paths attached to short options such as -I, -C and -o, including quoted and combined-letter options. A filesystem-independent regression explicitly uses /workspace/ci/run and covers host-path priority, virtual-path translation and escape rejection.

Current head: 00f4ebe53930b4b739fda336fd65f1062827a6e5, including main d218ef806ab505e1a4754499af6a56e732812627. Both CHANGELOG entries are retained.

Size

Relative to current main: src +37 net lines; tests +75 net lines, three new test functions and no new module. Size guard G1–G5 passed.

Verification on this head

  • 32 focused tests passed. The attached-short-option cases produced 24 failures / 8 passes on the preceding implementation. Removing only the host-path-priority block makes the new literal /workspace regression fail.

  • The two related modules initially recorded 379 passed / 7 failed / 3 skipped, with six default deselections. Five failures came from the environment's missing SOCKS dependency during LiteLLM catalog import; all five passed using LiteLLM's official bundled-catalog setting. The remaining two absolute-outside-source cases reproduce on unchanged 78f224d under this host's /workspace prefix.

  • A full make test attempt with fail-fast recorded 464 passed / 1 failed / 4 skipped / 20 deselected. The failure is an existing GitLab-script test that assumes /tmp exists; the same case fails on unchanged 78f224d. This is not a full-suite pass.

  • make lint, wheel/sdist build, changed-file formatting, whitespace checks and the size guard passed.

  • Upstream CI on this revision and its six companion workflows await maintainer approval.

  • I am familiar with the Contributing Guidelines

  • Added focused tests and updated CHANGELOG.md

  • Ran make lint and make build

  • Completed a passing full make test

  • Did not add credentials, private datasets, or proprietary benchmark content

Earlier validation and reproducible artifacts at preceding revisions

Verification after upstream refresh

Merged upstream main 4b1143d4704bcb7983207c32c3ebfa667d0b3d96 into this branch, preserving the original contribution as the first parent. Current source: 78f224de85ff0ea9d503f860e3e3c5d2460e7440. The only conflict was in CHANGELOG.md; both entries are retained. Every contribution production and test blob is unchanged from the original source.

  • 37 focused tests passed against the merged source, comprising the original 35 path/artifact cases plus the two real local interpreter/subprocess/redaction cases (333 unrelated cases deselected).
  • These checks exercise actual local Bash/Python commands, Harbor artifact collection and directory transfers, overlapping and quoted mappings, host working directories, include/exclude filters, and existing containment/link protection. The unchanged-upstream failure comparisons remain in the original evidence below.
  • make lint, make build (wheel and sdist), git diff --check, and the report-only size guard G1–G5 passed against the refreshed upstream.
  • The full repository suite was not rerun for this CHANGELOG-only conflict resolution. Its previously documented baseline/environment limitations remain; a passing full suite is not claimed.

Exact refreshed tree, raw logs, commands, commit/parent metadata, and limitations.

Original-source verification (before refresh)

The following results were recorded before this upstream refresh and are retained as historical evidence for the original contribution.

  • 35 focused tests passed on the final source. The identical selection against unchanged main produces 17 failures and 18 passes.
  • Two additional real local subprocess/redaction tests pass on the final source and both fail on unchanged main because the evaluator's absolute Python path is rewritten incorrectly. These are separate from the 35-test selection.
  • The checks execute Bash and Python locally and use Harbor's real artifact handler and directory-transfer code, including tar, include/exclude filters, exact output contents, retained source files, and rejection of linked destinations. They cover quoted paths, overlapping/reordered mappings, host working directories, and literal URLs/adjacent text.
  • The complete local-environment test module after the host-cwd fix recorded 59 passed, 2 failed, 2 skipped (four integration cases deselected). The two failures are the existing absolute-outside-source negative cases under this host's /workspace prefix; both fail identically on unchanged main before destination or staging mutation.
  • A wider five-file run at the earlier implementation stage recorded 488 passed, 413 failed, 6 skipped (seven integration cases deselected). Exact classification: 396 provenance-location errors, 11 assertion failures, four transfer errors, and two missing-path errors. The subsequent working-directory/interpreter fixes are verified by the final checks above. A representative provenance failure and the Pi test's assumption that no host path contains /workspace both reproduce on unchanged main; the 396 provenance cases were not all rerun on the baseline.
  • The provenance failures arise because the permitted temporary locations are inside enclosing Git repositories and the test key is a sibling of the generated skill. The existing product check rejects that location. No provenance or sandbox check was disabled.
  • make lint, make build, changed-file formatting, git diff --check, and the size guard passed. A passing full-repository suite is not claimed.

The 35-test selection is:

python -m pytest -q tests/test_harbor_local_environment.py tests/test_harbor_local_mode.py \
  -k 'shell_path or collects_local_convention or artifact_parent_paths or logical_artifact_paths or contained_exclusion_download or contained_filtered_download or transfer_source or traversal or symlink or link_or_reparse or local_stream_redacts'
  • I am familiar with the Contributing Guidelines
  • Added or updated focused tests
  • Updated the user-visible release note
  • Ran make lint
  • Completed a passing full make test
  • Ran make build
  • Did not add credentials, private datasets, or proprietary benchmark content

Release Impact

  • Updated CHANGELOG.md

Reproducible evidence

Independent verification scripts, retained results, and explicit test-environment limitations. Generated logs are isolated from this source branch.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Keep both CHANGELOG entries; preserve the original contribution's source and tests.

Signed-off-by: Afloat <ShuffleMonkey@163.com>

@chrisknvidia chrisknvidia 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.

I reproduced the double rewrite on main with a run directory whose path contains /workspace/, /logs/ and /tests/ components: a plain cd /workspace && ls /logs/artifacts came out as a long nonsense path, quoted and KEY=/--flag= forms were mangled the same way, and _resolve_path mapped an already-local working directory back into the virtual workspace when the run lives under a literal /workspace. At head every one of those cases maps once, rewriting the rewritten command again is a no-op, host paths under the run directory, the runtime root and the interpreter's bin dir pass through untouched, $HOME/workspace/x, ./workspace, URLs and /workspace-other are left alone, and commands with no mappable paths are byte-identical to main. Single, double and backslash quoting and the KEY=/path and --flag=/path spellings behave as before, and the containment checks still reject escapes from the run directory.

Both test files pass at head. With the head test files on main's source the two new tests fail, and so do seven existing artifact, log and verifier tests, purely because the fixture's trial path now contains those components, which is a good way to make the existing suite cover this. Clean main has no failures in either file, so nothing regressed.

One behaviour change beyond the title, inline: a path glued to a short option (-I/workspace/include, -C/workspace, -o/logs/agent/x) is no longer rewritten. Not blocking, but it should be a deliberate choice and in the release note.

The branch conflicts with main in CHANGELOG.md only (Unreleased > Fixed); the source merges cleanly with main, #937 and #938, so a rebase should be quick.

One more inline: the host-first _resolve_path hunk has no test that fails without it (with only that hunk reverted both files stay green); a filesystem-free unit test with roots under a literal /workspace/ci/run passes here and fails on main, so it is cheap to pin. Fuzzing about 3,500 commands over seven run-directory shapes gave 1,600 cases main got wrong and head gets right, no new double rewrites, and the glued short-option form as the only regression.

Recognize alphabetic short options at shell-token boundaries while
preserving host paths, URLs, and relative path suffixes. Extend quoting
and mapping-order coverage and pin host-first resolution under a
literal /workspace run root without creating that directory.

Merge current main and retain both release notes.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
@Afloat16

Copy link
Copy Markdown
Contributor Author

Addressed both points in 00f4ebe53930:

  • Restored rewriting for paths attached to -I, -C, -o and combined-letter short options, at shell token boundaries. The regression matrix covers unquoted, single-quoted and double-quoted operands plus reversed mapping order. URL paths, relative suffixes, host paths and long-option-like text stay unchanged.
  • Added the filesystem-independent /workspace/ci/run test for _resolve_path: a real host path wins before virtual mapping, a virtual path still maps, and an escaping path is rejected. Removing just the host-first block makes this test fail.

The 32 focused tests, lint, formatting, wheel/sdist build and size guard pass. The two existing path-boundary failures and the full-suite /tmp failure reproduce on the previous head; the PR body records those environment limits separately. The CHANGELOG conflict is resolved against current main.

Could you approve the seven new workflows and re-review the two fixes?

@rng1995 rng1995 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.

[SkillEvaluator Review]

Thanks @Afloat16 for this contribution.

Value and readiness: Corrects repeated rewriting of local runtime paths and preserves host paths, quoted paths, attached short options, and containment. New regressions reproduce failures against current-main source. No confirmed findings remain; ready for final review by the maintainers and PIC once current-head CI is green.
Prior findings: 2 of 2 prior concerns verified fixed: attached short-option paths and the literal /workspace host-root regression. Their threads were already resolved.
Material findings: none; all earlier findings verified fixed.
PIC tradeoffs: none.
Verification and gaps: Read the full delta and path/containment call paths, checked simultaneous longest-root substitution, idempotence, shell boundaries and quoting, host-first resolution, traversal rejection, compatibility, CHANGELOG and DCO. Complete local environment/mode suites: 388 passed, 1 skipped, 6 deselected. New regression selection against main: 17 failed, 15 passed as expected. Repository-wide Ruff and whitespace checks passed. Static execution-safety triage passed and fork workflows were authorized. CI is pending. No live agent/provider/container run or full repository test run was performed.

Reviewed head: 00f4ebe53930b4b739fda336fd65f1062827a6e5

@rng1995

rng1995 commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

@Afloat16 - Please give me permissions to merge all your PRs.

Retain the pull request contribution and current upstream changes.
Resolve the CHANGELOG conflict by preserving both sets of entries.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
@Afloat16

Copy link
Copy Markdown
Contributor Author

Yes @rng1995, please go ahead and merge my PRs once their current required checks pass.

All 14 branches (#905, #906, #907, #908, #909, #910, #911, #913, #914, #916, #921, #922, #940 and #941) now include main 38cb609a, and their merge conflicts are resolved. All existing review threads are resolved as well. The current heads and local validation results, including the environment limitations reproduced on the comparison revisions, are recorded at the top of each PR description.

The #922 source conflict retains both the new planted-canary normalization and the versioned metadata identity. Its permission regression passes with and without planted canaries.

The new-head workflows are awaiting approval; the required checks have not run on these heads yet. Please approve the current runs, including this PR's CI, and merge when the required checks pass. I can push any further requested branch edits directly.

@rng1995
rng1995 enabled auto-merge (squash) November 30, 2026 17:58
@rng1995
rng1995 merged commit 2af3f81 into NVIDIA:main Nov 30, 2026
27 checks passed

@chrisknvidia chrisknvidia 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-checked 00f4ebe on top of the main merge: attached short-option paths are rewritten again (with negative cases for URL, prefix and ./ spellings), and the host-root branch of _resolve_path now has a test that pins it. tests/test_harbor_local_environment.py passes at this head with Harbor 0.27 (89). Nothing open from my side.

@chrisknvidia chrisknvidia mentioned this pull request Nov 30, 2026
8 tasks done
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.

3 participants