Skip to content

fix(tier3): preserve MCP validation and local artifact paths - #472

Merged
chrisknvidia merged 2 commits into
mainfrom
naren/harbor-025-review-fixes
Nov 13, 2026
Merged

chrisknvidia merged 2 commits into
mainfrom
naren/harbor-025-review-fixes

Conversation

@rng1995

@rng1995 rng1995 commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow up on the merged Harbor 0.25 upgrade in #464. Apply the existing MCP declaration policy consistently to native tasks, preserve supported source header placeholders, and collect local artifacts written through the documented log parent.

Before / After

Trigger Before After
Native task declares MCP servers Native declarations did not take the shared MCP approval path Validate agent, task-verifier and step-verifier MCP declarations before Harbor parsing or staging; retain approved dedicated credentials and safe stdio references
Approved HTTP MCP header uses $VAR Source validation passed, but Harbor 0.25 rejected the generated task Use ${VAR} in generated Harbor TOML; retain original source files and agent MCP JSON
Local command builds the artifact path from /logs or HARBOR_LOGS_DIR Files went to a different tree from the convention directory and were absent from collected artifacts Use one private log parent and artifact child, while retaining role logs and separate collected snapshots

Malformed native MCP shapes fail without echoing their values. Escaped, malformed and default-bearing credential placeholders remain rejected.

Verification

Actual verification Result
New MCP staging regressions, real Harbor TaskConfig 21 passed
MCP policy and native role-boundary subset, including the new cases 90 passed, 549 deselected
Local artifact/log lifecycle, real ArtifactHandler, local exec, and Claude prompt boundaries 25 passed, 5 integration cases deselected
Instruction transport and host-environment compatibility 25 passed, 278 deselected
Independent before/after probes Native declarations rejected before staging; normalized headers parse; local parent-written answer is collected; optional user-agent directory stays absent
Project checks make lint, sdist/wheel build, changed Python formatting, diff and OSS boundary checks passed; Fern 0 errors, 1 existing warning

The native-policy and bare-header cases failed against the original a72a6119 adapter before the fix. The local parent/artifact and transfer cases also failed before implementation. The focused suites exercise actual Harbor models/staging and artifact collection with controlled local commands and fake credential names; no external MCP requests, vendor-agent inference or paid model calls were made in this follow-up. Actual Codex/Claude Code NVIDIA-backed smoke evidence from the upgrade remains recorded in #464.

A broader local four-file attempt was interrupted after five passing tests under host filesystem load and is not reported as a passing suite. Complete final-revision CI will be recorded below.

CI: Merged head 388bd4ab completed with 23 successful and 4 skipped checks. Post-merge download-boundary hardening is proposed in #479; verifier-role grants and safe validation hints are proposed in #491. Those follow-ups remain separate and are not claimed as merged into main.

Local transfer boundaries

Retained role directories keep their host locations. Use HARBOR_ARTIFACTS_DIR or HARBOR_LOGS_DIR/artifacts for artifacts, rather than deriving a parent from a role directory or writing ../artifacts from it. Whole /logs transfers fail before changing the destination; direct role and artifact-directory transfers remain supported. Secure-copy restrictions on symbolic links are unchanged.

Review

Three independent post-merge review passes identified the three changes above. A separate independent review of the follow-up implementation found no additional actionable regressions. Inline findings on #464 will link to this PR and their verification.

Release impact

  • Focused regression tests and current documentation updated.
  • CHANGELOG.md updated.
  • Commit carries DCO sign-off.
  • No credentials, generated reports or transcripts committed.

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

LGTM. Native task MCP declarations, including verifier and step-verifier environments, now go through the shared declaration policy before Harbor parses them, and malformed shapes fail without echoing values. _harbor_mcp_headers rewrites only unescaped bare $VAR to ${VAR}, and leaves $$VAR and already-braced values alone (I probed both). The /logs parent now resolves to a private runtime-logs tree whose role entries are fixed symlinks to the retained host dirs, and transfers of that parent are rejected. eval.py and the custom grader runner read the role-specific env vars, so their outputs don't move. With the locked Harbor 0.25.0, 748 local-environment, local-mode and isolation tests pass, and ruff is clean.

@chrisknvidia
chrisknvidia merged commit cf325c8 into main Nov 13, 2026
27 checks passed
@chrisknvidia
chrisknvidia deleted the naren/harbor-025-review-fixes branch November 13, 2026 06:07

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

Reading this after it merged, so treat what follows as follow-ups.

I read the MCP and path changes line by line. The MCP side and the /logs rework look right; there is one small hardening fix I'd make before merging (below), and the rest are non-blocking notes.

MCP: the new native check runs right after the task.toml parse in _native_task_workdir, before any other validator and before the output directory is touched, and the staged copy is validated again. It covers environment, verifier.environment and steps[].verifier.environment, which are the only places Harbor 0.25's TaskConfig accepts mcp_servers (I checked the 0.25 config model). Malformed shapes and pydantic errors are turned into messages that do not echo values. validate_mcp_server_declarations itself is unchanged, and the $VAR to ${VAR} rewrite runs only on headers that already passed it. Escaped ($$), unterminated and default-bearing placeholders are still rejected, and the rewrite leaves them alone. Nothing is loosened.

Paths: /logs now maps to a private runtime-logs directory under the run root, with the artifacts staging dir inside it and role aliases pointing at the real host role dirs. _resolve_path normalizes the logical spelling first, which also fixes the old '/logs//agent' case that resolved to an absolute '/agent'. '..' is still not collapsed, so safety rests on the resolve-based allowed-roots check; upload_file, upload_dir, download_file and download_dir all call it, and the reachable set stays the two existing roots (run root and trial dir). The exception is the two new download overrides, see below. Whole-/logs transfers (and any ancestor of runtime-logs) are rejected before the destination is touched, and the lstat checks on restart fail closed if a directory or alias was swapped. stop(delete=True) removes the aliases, not their targets, so retained role logs survive. Native Windows local mode fails closed before the environment starts, so the symlink code is not reachable there.

The one thing I'd fix before merging: download_dir_with_exclusions and download_dir_filtered resolve the source but never call _path_is_within_allowed_local_roots, so a '..' source through a mapped prefix (for example /workspace/../../../etc) still gets past them. It is not a regression, and it looks hard to exploit because Harbor's base code writes its archive under host /tmp, but a one-line check plus a test makes the four transfer methods consistent. Other suggestions are inline and in the list above: one sandboxed (or macOS) run of the new local-environment tests, passing verifier_env for the verifier scopes, a hint in the native MCP error message, and a refresh of the stale CI line in the PR body.

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

Post-merge feedback is addressed by separate proposed repairs: #479 for download allowed roots and #491 for verifier MCP role grants plus safe hints. The existing #479 passed all40local-environment tests onmacOS; #491 has9initial focused passes and10independent staging passes, with broader local/CI runs still under observation. Refreshed the stale CI line using historical merged-head evidence23successful/4skipped checks. No source write or reopening was made to the merged #472 branch, and the proposed fixes are not claimed as current-main changes.

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