Skip to content

feat: preview a Hugging Face model in the browser, headers only (prototype) - #289

Closed
Defilan wants to merge 1 commit into
mainfrom
proto/browser-preview
Closed

Defilan wants to merge 1 commit into
mainfrom
proto/browser-preview

Conversation

@Defilan

@Defilan Defilan commented Oct 15, 2026

Copy link
Copy Markdown
Member

Prototype, not for merge as is. This lets you put socair.ai/ in front of a Hugging Face model URL and see what Socair's checks find. The visitor's browser runs the open engine, compiled to WebAssembly, on the model's headers and small files, fetched straight from Hugging Face with range requests.

  • Nothing is uploaded or stored, and socair.ai stays a static site.
  • There's no promotion verdict and no signature: the decision stays with each organization.

What it does

  • engine.PreviewDir scans a model directory in place and hashes nothing.
    • Each file's SHA-256 comes from its source: the hub's value for LFS files, computed from the bytes for small files.
    • modeldir.List walks a directory without opening any file.
    • ScanMode still refuses a header-only directory scan (the existing test is unchanged).
  • cmd/socair-preview is the engine built for js/wasm. It exposes socairPreview(dir, hashes) and, for a GGUF on its own, socairPreviewFile(path).
  • tools/socair-preview:
    • hffs.js is a filesystem in the shape Go's browser runtime calls. Reads become cached range requests, and headers are prefetched in parallel.
    • The page is set up as noindex. Every engine note is set as text, never as markup.
    • try.mjs runs the same path in Node; serve.mjs serves the page locally.
  • Honesty rules.
    • Reads are all or nothing: if any read fails, no row is shown.
    • For safetensors models it previews the selection docs/airlock.md recommends, plus *.py, printed as the airlock pull's --include.

Measured

Repo In the repo Read Time
SmolLM2-135M-Instruct 2.0 GB 3.7 MB 1.8 s (browser)
Phi-3-mini-4k-instruct 7.6 GB 3.1 MB 1.3 s, Remote code LEAD
Qwen3-0.6B-GGUF 0.64 GB 6.4 MB 4.3 s, GGUF chat template, tokenizer and quant PASS
nvidia/GLM-5.3-Flash-NVFP4 204.5 GB 57.5 MB 16 s, 33 shard layouts verified

Fidelity. SmolLM2's selection was pulled through socair airlock pull at the same commit and scanned in full. The subject digest, the 13 file hashes, and every row's status and notes are identical to the preview.

Size. socair.wasm is 17 MB, 3.0 MB brotli.

Tests

  • TestPreviewReadsInPlaceWithStatedHashes. Two falsifications: a missing SOCAIR_SCAN_TMP would fail a snapshot, and a planted hash is reported as given.
  • TestPreviewNeedsEveryFilesHash.
  • TestPreviewFindsWhatAScanFinds: every row equals a full scan's, including a Remote code LEAD.
  • TestListStatesHashesWithoutReadingAFile: a file nobody can read still lists.
  • gofmt, go vet, staticcheck (native and js/wasm), and the full go test ./... pass.

Found along the way

The legacy torch storage walk (internal/checks/pickle/containers.go:182) reports any ReadAt error as "a record cut off at the end of the file", a FAIL. An I/O error is not positive evidence; only end-of-file is. That's a separate issue, and the preview's all-or-nothing rule already keeps it off the page.

Before this ships

  • A Netlify rewrite of /huggingface.co/* on socair.ai, plus the site's design.
  • Gated repos: the preview takes no token yet, so it stops with a message.
  • Decide whether cmd/socair-preview and tools/socair-preview belong in this repo or the site's.

Assisted-by: Claude Code (Opus 5.5)

engine.PreviewDir scans a model directory in place and hashes nothing:
each file's SHA-256 is the one its source states, and every file needs
one. modeldir.List walks a directory in the scan's rules without
opening a file. ScanMode still refuses a header-only directory scan.

cmd/socair-preview builds the engine for js/wasm. tools/socair-preview
mounts a Hugging Face repo as a filesystem whose reads are HTTP range
requests, runs the preview on it, and shows the rows with no promotion
verdict. If any read fails, it shows none.

On SmolLM2-135M-Instruct the preview read 3.7 MB of a 2 GB repo, and its
subject digest, file hashes, row statuses and notes equal a full scan of
the same selection pulled through the airlock.

Signed-off-by: Christopher Maher <chris@mahercode.io>
@Defilan Defilan closed this Oct 15, 2026
@Defilan
Defilan deleted the proto/browser-preview branch October 15, 2026 23:34
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