← Back to Pull requests

feat(files): register agents from any Git repository over SSH #2617

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 05, 2026 22:04 UTC
Author

<!-- SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -->
<!-- SPDX-License-Identifier: Apache-2.0 -->

<!-- markdownlint-disable MD041 -->

Summary


<!-- In 1-3 plain sentences, explain what changes and why. Describe before-and-after behavior when it applies. -->

Agents could only be registered from GitHub, through the GitHub REST API. This adds a git fileset storage type that reads any Git repository over SSH with a private key stored in a workspace secret. The lookups Studio needs to register one (an SSH host key scan and a search for files in a commit) are in #2645, stacked on this one, and the Studio registration flow is in #2634, stacked on that.

Changes


<!-- List the concrete changes included in this pull request. -->

Files service

  • New GitStorageConfig (type: git): url (git@host:org/repo.git or ssh://host:port/...), revision, path, ssh_key_secret, required known_hosts. URLs, revisions and paths that git or ssh could read as options, or that escape the repository, are rejected. Percent-encoding is refused in URLs, because git decodes ssh:// URLs before connecting and %2F would move the host it reaches past the allowlist. The URL is split the way git reads it (an ssh:// URL at its first /, the SCP form when a : comes before any /), then hosts are limited to DNS labels and users to login characters, because the allowlist's urlparse stops a host at ? or # while ssh does not. Control characters are refused in the URL, revisions and path. The URL keeps the form it was given, so an ssh:// absolute path stays absolute, with the host lowercased, any trailing dot and an ssh:// URL's :22 dropped, so ssh and known_hosts name the host the same way. read_chunk_size is limited to 1 byte–16 MiB. SCP paths may be absolute, ports must be ASCII 1–65535, and commit SHAs are lowercased; SHA-256 ids are refused, and a branch on a SHA-256 repository is refused at create. revision and original_revision must be plain branch, tag or commit names, since a refresh resolves the latter with ls-remote.

  • New GitStorageImpl: resolves a branch, tag or other name under refs/ with git ls-remote in git's order (so a tag wins over a same-named branch, and heads/x or pull/5/head work), which also proves the key can read the repository, and pins the fileset to that commit; the existing tracked-revision refresh moves it to a branch's new head. original_revision is always recorded from the requested revision, as for GitHub filesets, so a client-supplied value cannot repoint a pinned fileset on refresh. A pinned commit SHA is fetched at create with the fileset's key, even if another fileset already cached it, so a commit the remote lacks or will not serve to that key fails up front. On first use a commit's listing of paths, blob ids and sizes is written to the files service's default storage and kept in memory, up to 250,000 listed files; a stored listing is rebuilt if it is missing or its contents are wrong (another commit, a malformed entry, a bad blob id or size), while errors from the store itself fail the request; a commit over 100,000 files is refused, and a listing that cannot be stored is still served. File contents stream from git cat-file and are cached in the background by the files service's download cache, as other external backends' are: get_cache_path_key keys each file by URL and blob, so an update caches only the files that changed, and cache=True warms git filesets too. Looking a file up, which a download does before its 10 s first-byte deadline starts, makes sure the commit is in the local fetch repository, so a restart, second replica or pruned repository fetches outside that deadline. HEAD and other metadata lookups of an uncached file therefore fetch the commit too: the backend cannot tell them from a GET, and a GET usually follows. The download itself runs one git process without taking the repository lock, and fetching or listing a commit finishes even when its request is cancelled, so a retry finds it done. Storage errors from the cache key lookup map to the same 502s as the rest of the download path.

  • As with GitHub and Hugging Face filesets, the key's access is checked with the remote when a fileset is created or refreshed, including a second fileset for a URL another one already cached; reads of a cached commit do not contact the remote.

  • A per-URL bare repository under the platform data dir holds fetched commits. Fetches run under that URL's lock; reads do not. git runs with auto-gc and background maintenance off, so it leaves no detached gc holding locks. Reads, including finding a commit already fetched, mark a repository as used, at most once a minute; after every fetch, repositories unused for a week are pruned. git runs in its own process group, stopped with SIGTERM then SIGKILL on timeout or cancellation; ssh sends keepalives; file paths are literal (GIT_LITERAL_PATHSPECS); at most 16 git commands other than file streams run at once.

  • SSH runs with only the fileset's key and host keys: -F /dev/null, IdentitiesOnly, IdentityAgent=none, StrictHostKeyChecking=yes against the fileset's known_hosts, BatchMode, GIT_ALLOW_PROTOCOL=ssh, no system or global git config. The key is written to a 0600 temp file per call; keys pasted into a single-line secret field are re-wrapped.

  • Git and ssh failures map to the storage errors the files API already reports: access (any ssh Permission denied (...), host key mismatch), config (missing repository, ref or path, including GitLab's "not found or no permission") and unavailable (network failures, hung-up remotes, ServerAlive timeouts). Faults on the server itself, such as a missing git or ssh binary, ssh refusing a uid without a passwd entry, or a full disk, raise GitServerFault, a new StorageServerFault, and surface as 500s, on downloads too.

  • allowed_external_hosts gates SSH hosts too; ssh://host:22 matches ssh://host.

  • openssh-client added to nhx-python-base; git was already present, but --no-install-recommends left out ssh.
  • Studio compatibility

  • The Git storage backend label and the datasets table's storage union and path display, which Studio needs to type-check once the regenerated SDK includes GitStorageConfig. The registration flow itself is in #2634.
  • Type of Change

  • Code change (feature, bug fix, or refactor)

  • Code change with documentation updates

  • Documentation only

  • Contributor tooling or automation

  • CI, build, or test infrastructure
  • Quality Gates


    <!-- Check one tests line and one documentation line. Include the requested justification when a gate is not applicable. -->

  • Tests added or updated for changed behavior

  • Existing tests cover changed behavior — justification:

  • Tests not applicable — justification:

  • Documentation updated for user-visible behavior

  • Documentation not applicable — justification:
  • Documentation for the new storage type, the SSH registration flow and the allowed_external_hosts requirement is not written yet.

    Verification


    <!-- Check an item only when supported by evidence. List exact targeted validation commands and results below. -->

  • Pull request title follows the repository's Conventional Commit format

  • Every commit includes an appropriate Signed-off-by: trailer

  • uv run pre-commit run -a passes, or any blocked checks are identified below

  • Targeted tests pass, or tests are marked not applicable above

  • No secrets, API keys, or credentials are included
  • Targeted validation:

    <!-- List each command and result. Explain skipped, blocked, or non-successful checks without marking them as passed. -->

  • pytest services/core/files/tests with .env set aside — 829 passed, 51 skipped (git backend 156). The backend tests drive real git against a local repository over the file protocol, enabled only in tests.

  • ty check, ruff check, ruff format on the changed Python — clean.

  • script/generate-openapi-spec.sh — spec unchanged after the last change; web SDK regenerated with pnpm gen.

  • With only the Studio compatibility files from this PR: npm run typecheck in web/packages/studio — 0 errors; Studio agent, secrets, API and datasets suites — 750 passed.

  • Pre-commit hooks ran on each commit's files and passed. uv run pre-commit run -a across the whole repository was not run.

  • pytest packages/nemo_helix_plugin/tests -k "storage or files or git" — 98 passed. generate-config-docs leaves docs/set-up/config-reference.mdx unchanged by this PR.

  • Manual, before reads moved to durable storage: registered agents from gitlab-master.nvidia.com:12051 over SSH against a local platform. The current design has not been exercised against a real SSH host yet.
  • Not run or known gaps:

  • Left for follow-ups to keep this change smaller: repairing a damaged fetch repository or a stale lock file on its own (until then, the affected URL returns 502s until its repository folder is deleted), a size cap on the fetch repositories, a limit on concurrent file streams, and fetching a pinned commit through its branch for servers that refuse fetching by commit id (GitHub and GitLab allow it).
  • opa test fails to compile common.rego locally with OPA 1.21.1 on unmodified main as well; CI runs its own pinned OPA.

  • With NHX_FILES_ALLOWED_EXTERNAL_HOSTS set in a developer .env, five test_files_config.py tests fail when the full files suite runs, because the integration tests load .env. Unrelated to this change.

  • Passphrase-protected SSH keys are not supported.

  • Listings and cached files in default storage are not evicted, the same policy as other backends' caches. A cached commit can be read through another user's fileset for the same URL if they know its SHA.

  • As with GitHub and Hugging Face filesets, a key revoked after a fileset was created keeps reading what is already cached. A file never read before cannot be served if both the remote and the local fetch repository are gone.

  • A commit's first materialization fetches the whole commit snapshot (later updates fetch deltas): listing files needs blob sizes, and the git protocol cannot fetch one directory without server-side sparse filters. A very large repository could reach the 120 s fetch timeout on first read. Reading a file whose blob is not cached yet fetches its commit again if the local fetch repository has been pruned.
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added read-only Git storage over SSH for filesets, with configurable repository, revision, and path. Files can be listed and downloaded, including byte-range downloads.
    Studio now identifies Git-backed filesets as “Git (SSH)” and displays their repository location.
    Bug Fixes
    * Improved file-download error handling so server-side faults are reported accurately.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: matthewgrossman Review duration: 2796m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #2617"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%