Skip to content

hub: serve REPO@REVISION and the snapshot fallback; Windows build notes - #6405

Open
joshuaswarren wants to merge 5 commits into
ashhart:mainfrom
joshuaswarren:w7S-win-cache-resolve
Open

joshuaswarren wants to merge 5 commits into
ashhart:mainfrom
joshuaswarren:w7S-win-cache-resolve

Conversation

@joshuaswarren

@joshuaswarren joshuaswarren commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6390

What

  • serve/plan/drafter/chat/benchmark accept REPO@REVISION and the server's model resolution gains the CLI's cache-layout walk. server/hub.zig previously read only refs/main and refused owner/name@revision; a cache filled by hf download --revision listed under models/info but would not serve. The walk lives in zig/src/core/hub_cache.zig (cachedSnapshotRev: refs/<rev> then snapshots/<rev>; with no refs/main, the newest snapshot holding a config.json), wired as a shared module like checkpoint_config.
  • servedName names the repo, not the snapshot sha, for REPO@REVISION.
  • Hardened resolution (post-review): revisionOk now refuses a bare . alongside ..; cachedSnapshotRev requires a readable config.json on the explicit revision path too — a refs/<rev> or snapshots/<rev> dir that resolves but holds no config no longer serves as a model.
  • cli/hub.zig deduplicated onto hub_cache: the ~140 lines of copy-pasted helpers (revisionOk, isDir, readSmall, ensureDirPath, trimTrailingSeps, envValue, cachedSnapshotRev, cachedSnapshot, resolve:) are now pub const re-exports of the shared module, so CLI and server share one implementation.
  • Windows install: tf-muse and tf-qwen3-asr are POSIX-only (fabric/tp, std.c.clock_gettime); their install steps skip the artifacts on Windows so zig build native install exits 0 and reaches start --check. The named build steps remain for explicit builds.
  • docs/WINDOWS.md: tensorfold benchmark is unsupported on Windows; WDDM free-memory queries do not count other processes' allocations; a pre-eol=lf clone keeps CRLF and panics at configure time — and every ... boundaries changed panic text now names a stale CRLF checkout as a suspect.
  • info/models are unchanged: both resolve through zig/src/cli/hub.zig, which open lead-train PRs cli: tensorfold mcp, a Model Context Protocol server on stdio for this machine's models and local servers #3549 and server: tensorfold serve --router answers for several models at one address, each a serve child loaded on demand #3540 rewrite; REPO@REVISION support there lands cleanly on top of either.

Tests

  • resolve: tests in server/hub.zig cover: ref revision, bare snapshot sha, invalid revision refusal (., .., empty), servedName, the no-refs/main snapshot fallback, and refusing a ref that names a snapshot dir with no config.json.
  • pull.zig revision test refuses . and ...
  • zig build test-pull-security and test-pull-host green; server/hub.zig tests green including the new cases; zig fmt clean.

@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

Thanks @joshuaswarren. The walk is right: an explicit revision reads only its own ref or snapshot and never falls back, the fallback needs refs/main or a snapshot with a readable config.json, and the joined path always stays inside the cache. The Windows notes match the code, and the host suites pass on today's main (server 582 plus 5 skipped, pull security 85, goldens 69/69, serving pins).

Two small things are left, and we'll do them ourselves on this branch:

  1. A bare . revision passes the shape check and resolves to the snapshots folder itself, so serve Org/Name@. fails later with a confusing load error. We'll refuse it, and have the explicit path require a config.json the way the fallback does, which also covers a sha naming an empty snapshot. We'll add a test where the .. form would reach a real snapshot, so that refusal is pinned too.
  2. cli/hub.zig still has its own copy of cachedSnapshotRev; we'll point it at the shared module so the two can't drift.

Nothing more is needed from you.

  • Synthena

@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

@joshuaswarren, thank you for the shared cache walk and the revision serving. The resolution reads correctly: an explicit revision reads only its own ref or snapshot and never falls back, the fallback needs refs/main or a snapshot with a readable config.json, and the joined path always stays inside the cache. The host suites pass on today's main.

Two small things are left, and we will make them ourselves on this branch. First, a bare "." revision passes the shape check and resolves to the snapshots folder itself, so serve Org/Name@. fails later with a confusing load error; we will refuse it, and have the explicit path require a config.json the way the fallback does, which also covers a sha naming an empty snapshot. We will add a test where the ".." form would reach a real snapshot, so that refusal is pinned too. Second, cli/hub.zig still carries its own copy of the cache walk; we will point it at the shared module so the two cannot drift.

No change is needed from you.

  • Synthena

The native server's model argument (server/hub.zig resolve) read only
refs/main and refused owner/name@revision, while pull, rm and the tfq3
converter already split REPO@REVISION and info/models/plan already reach
the newest-snapshot fallback through cachedSnapshot. A cache filled by
'hf download --revision' listed but did not serve.

The cache-layout walk now lives in core/hub_cache.zig and both sides
share it: resolve accepts REPO@REVISION (refs/<rev>, then snapshots/<rev>)
and, with no refs/main, the newest snapshot holding a config.json;
info and plan accept the revision too; servedName keeps the repo name
over the snapshot sha.

On Windows zig build native install failed on the POSIX-only tf-muse and
tf-qwen3-asr tools; their install steps now skip the artifacts there.

docs/WINDOWS.md notes: benchmark unsupported, WDDM free-memory queries
not counting other processes' allocations, and the CRLF panic a
pre-eol=lf clone hits at configure time; the boundary-check panics name
line endings as the suspect.

Fixes ashhart#6390
…cit path

serve Org/Name@. resolved to the snapshots dir itself and a sha naming an
empty snapshot served, while the fallback walk requires a config.json.
revisionOk now refuses the bare ".", and the explicit-revision path applies
the same config.json bar as the fallback. cli/hub.zig re-exports the shared
core/hub_cache walk instead of keeping its own copy, so the two cannot
drift. resolve tests cover @., @.., and a sha/ref naming an empty snapshot.
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Both changes are in 6db99c01a15cb2754fdc8f0b2d3f8882f984dd64, rebased onto main (038b7a6):

  • revisionOk refuses the bare ., and cachedSnapshotRev's explicit path now applies the same config.json bar as the fallback walk (hasConfig in core/hub_cache.zig). serve Org/Name@. can no longer resolve to the snapshots dir itself, and a sha or ref naming an empty snapshot refuses.
  • cli/hub.zig re-exports the shared core/hub_cache walk — the local copy is deleted, so the two can't drift.
  • resolve: tests in server/hub.zig cover @., @.., and a sha/ref naming an empty snapshot (red on the pre-change code, green here); pull's revision test pins the . refusal.

Ran zig build test-pull-security test-pull-host plus the server/hub.zig test module, zig 0.17.0 — all green.

@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

READY to land on this head. Thanks @joshuaswarren: 6db99c0 refuses the bare '.' revision, applies the same config.json bar to an explicit revision as to the fallback walk, and cli/hub.zig now re-exports the shared core/hub_cache walk, with resolve tests for @., @.. and an empty snapshot. Checks pass on this head, and model path resolution does not change any served tokens.

  • Synthena

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

2 participants