Skip to content

feat(validation): validate Hub Space sources and gate unverified HF runtime - #1525

Draft
burtenshaw wants to merge 10 commits into
ben/rfc008-episode-oraclefrom
ben/rfc008-hf-sandbox-provider
Draft

burtenshaw wants to merge 10 commits into
ben/rfc008-episode-oraclefrom
ben/rfc008-hf-sandbox-provider

Conversation

@burtenshaw

@burtenshaw burtenshaw commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add --space, --revision and --flavor for Hub Space source validation, following hf download and hf jobs run conventions. Resolve revision names once to a full commit and hash a standalone repository snapshot, preserving tracked files while excluding SDK bookkeeping.

resolved source commit -> downloaded files -> static validation
unverified source-to-image binding -> immutable_image SKIP, no Job

Draft: HF runtime is disabled until a trusted source-commit-to-immutable-image binding and direct digest launch are available and qualified. Matching Hub repository/runtime SHAs does not establish job image provenance. Shared launch specifications remain digest-only.

Evidence

Regressions cover named revisions, repeat-download hashes, tracked SDK-metadata paths, multiline/final-stage Docker commands, unsupported command settings, and a real local 2 MiB output producer whose retained log stays at 64 KiB. Returned, printed, saved and bundled reports retain the same resolved Space identity. Unsupported heredocs and unavailable runtime metadata produce named SKIPs; explicit revision/stage contradictions remain errors. Runtime refusal is tested before job creation.

Test Plan

  • BOM final-top source gate: 1,022 validation/all-CLI tests passed, 8 optional-pip cases skipped, 44 Docker cases deselected.
  • Locked lab: 806 fast and 35 protocol cases passed, zero skips; clean tested head 986af419, artifact checksums verified.
  • Independent final HF identity/gate check: 11 tests passed; zero Jobs created.
  • Touched Python lint and diff checks passed.

Reference Linux/amd64 runtime CI passed at 986af419: 806 fast, 35 protocol and all 44 required Docker cases, with complete artifact verification: https://github.com/openenv/OpenEnv/actions/runs/40746462903.

These local and Linux CI suites do not qualify live HF execution.

RFC Status

RFC 008 / #778 remains In Review. Live HF CPU/GPU execution, transport and cleanup remain unqualified. The earlier uvicorn/proxy 404 issue was not retested. Network/host/resource enforcement remains unsupported by this provider.

Merge Danger

Door: two-way. Blast Radius: Space source validation and draft HF provider.

@burtenshaw
burtenshaw force-pushed the ben/rfc008-hf-sandbox-provider branch from a4784de to 5339417 Compare October 28, 2026 17:22
@burtenshaw
burtenshaw force-pushed the ben/rfc008-episode-oracle branch from 5503a92 to 70b2484 Compare October 28, 2026 17:22
@burtenshaw burtenshaw changed the title feat(validation): validate Hub Spaces on HF Jobs with --space feat(validation): validate Hub Space sources and gate unverified HF runtime Oct 28, 2026
@burtenshaw
burtenshaw force-pushed the ben/rfc008-hf-sandbox-provider branch from 5339417 to 95e5db6 Compare October 28, 2026 17:25
@burtenshaw
burtenshaw force-pushed the ben/rfc008-episode-oracle branch from 70b2484 to 457d3e3 Compare October 28, 2026 17:25
burtenshaw and others added 10 commits October 28, 2026 19:28
`openenv validate --space <id> [--revision] [--flavor]` downloads the Space at
an exact revision, runs static checks on those files, and runs runtime checks
against the Hub-built image in a dedicated huggingface_hub Sandbox on the
requested HF Jobs flavor, including GPU flavors. The run refuses a Space that
moved past the validated revision, never forwards the host token, and confirms
job cancellation through the Jobs API. Checks the Jobs VM cannot evidence
(network policy, host containment, resource bounds) report the missing
provider capability.

Live runs are currently blocked by an HF Jobs Sandbox issue: with a uvicorn
server running inside a dedicated sandbox, its port proxy and exec API start
returning 404 after a few requests.

Part of RFC 008 Level Two (#778).

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

`--space --revision main` passed the branch name to the provider, which compared
it with the Space's commit hash and refused the run as "Space moved". The CLI
now resolves the revision to its commit hash once, before downloading, and uses
that hash for the download, the provider and the report target. The provider
rejects anything but a full commit hash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`snapshot_download(local_dir=...)` keeps timestamped download metadata under
`.cache/huggingface` in the folder, so two downloads of the same Space commit
produced different source digests. The CLI now removes that directory, which
huggingface_hub reserves and never commits, before validating the tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The provider compared the Space's commit once during build, then started the
mutable `hf.co/spaces/<id>` image and reported the validated commit as if the
image were pinned. HF Jobs take a Space image by name only and report no
digest, so the image cannot be pinned. The provider now checks immediately
before and after the job starts that the Space is at the validated commit and
running a Hub build of it (stage RUNNING, built from that commit), stops the
job and reports runtime.startup ERROR otherwise, and records the image as
unverified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Join Dockerfile continuations and use the final stage command, preserving inheritance from earlier stages and refusing unsupported entrypoints.

Keep only the first 64 KiB of server output while draining the rest so logging cannot fill the sandbox disk or break the server pipe.
Matching Space source and runtime revisions do not bind a Job to an immutable image. Report a named immutable_image SKIP before creating any job, keep launch specifications digest-only, and stop reporting the requested source commit as observed job build provenance.

Copy cached source snapshots into an isolated validation tree so SDK metadata stays out of source digests without deleting files tracked by the repository.
Accept a durable report target separately from the validated package path. Construct returned and bundled reports with the same identity while preserving exact source hashing.
Pass the resolved Space source identity into validation before reports are serialized. Cover static and runtime refusal reports, returned objects, printed JSON, source hashes and bundle checksums.
Stop command parsing at a heredoc marker before payload lines can become fictitious stages. Report a named capability SKIP and preserve the supported final-stage parser behavior.
Classify absent runtime stage or source revision as the named unsupported space_runtime_metadata capability. Preserve errors for explicit contradictions and retain the immutable-image refusal without launching jobs.

This branch has not been deployed

No deployments
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.

1 participant