Repository navigation
feat(engine): pinned, sha256-verified Zen bootstrap and offline inference - #174
Conversation
hanzo_engine::zen: embedded catalog of zen6-nano pins (commit, sha256, licence files), hardware selection, disk preflight, verified resumable pull into the shared Hugging Face cache, offline bundle export/import, activate and rollback. hanzo-engine zen <list|select|pull|verify|use| rollback|export|import> and -m zen:<id|auto>, which loads only the verified local snapshot. Memory requirements in catalog.json are provisional until measured. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01P5YBduxQAc4tdxANUmrkHx
…ed variants The sync hub client resumes from blobs/<etag>.part, not .incomplete, so missing_bytes ignored a partial download. The pull tests move to their own binary, which clears proxy variables the hub client would otherwise send localhost through. zen6-nano-2b is dropped: it answers known-answer prompts wrongly in both quant formats. Memory figures still provisional. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01P5YBduxQAc4tdxANUmrkHx
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01P5YBduxQAc4tdxANUmrkHx
… local Review fixes. hf-hub built blob and pointer paths from server headers, so pull now uses its own downloader: blobs/<pinned sha256>.part only, at most the pinned size, Range resume. Resolving zen: forces hub access offline for the process; quantize, train and distill refuse zen:. Verify refuses unpinned files in the snapshot; --cpu budgets RAM only; the state file is synced and its errors name the fix; import checks disk; replacing an entry only deletes the pin's own blob. Measured memory figures in the catalog. Tests for these changes are running; not yet confirmed green. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01P5YBduxQAc4tdxANUmrkHx
…CI gate The GGUF loader reads optional configs beside the weights, and the shared snapshot may hold other hub clients' files, so zen: now loads from <cache>/hanzo-zen/<pin>/, hard links to exactly the verified files, instead of refusing neighbours. Hub errors name a zen: model as the reason access is local-only. Import's disk check no longer credits download parts. hanzo.yml runs the zen tests as a gate. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01P5YBduxQAc4tdxANUmrkHx
rename(2) does nothing when both names already link the same file, so the second load of an unchanged pin left LICENSE.link.<pid> and friends in its load directory. The temp link is now removed after the rename. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01P5YBduxQAc4tdxANUmrkHx
Measured at 2,048 prompt tokens the 9B peaks at 3,295 MiB, not the 2,813 its short prompts reached, so its requirement is 4.25 GiB, not 3.5. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01P5YBduxQAc4tdxANUmrkHx
- prepare_load and cache delete never list, write or remove through a symlink; the .part and .import temps are created create_new and appended O_NOFOLLOW. - A 206 is appended only when Content-Range starts at the requested byte; a resumed file that fails its digest is fetched once more from 0. - Loads of one pin lock hanzo-zen/<pin>.lock; zen commands lock state.json.lock. - Import sizes its disk preflight from files that fail verification. - Unified-memory devices count no more than free RAM; zen subcommands take --cpu. - tune refuses zen: (nothing to tune in a pre-quantized GGUF). - Bundle manifests carry no digests; docs and notes match the code. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01T1hoMwU8cnJHjJncdB1mgM
- A symlink at hanzo-zen/ is removed before a load or cache delete touches anything under it; cache delete skips pins that were never loaded. - zen list/select/verify/export take no state lock, and a waiting writer says so; the lock file is state.json.lock as documented. - Test 206 answers at another offset and without Content-Range. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01T1hoMwU8cnJHjJncdB1mgM
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01T1hoMwU8cnJHjJncdB1mgM
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01T1hoMwU8cnJHjJncdB1mgM
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01T1hoMwU8cnJHjJncdB1mgM
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Red review 1 of 2: full change at 4532ccdRanked findings from an adversarial read of
Generated by Claude Code |
Red review 2 of 2: fix delta 4532ccd..e626e3fCode read only; I did not run cargo. Findings, ranked
Clean: Outcomes on the branch
Generated by Claude Code |
Part of #163.
hanzo-engine zenpicks a Zen model that fits the machine, installs it, verifies every byte and runs it with no network. The pins are compiled into the binary: each one fixes a repo, a 40-hex commit, and the size and sha256 of every file (the weights,LICENSEandNOTICE). Files live in the shared Hugging Face hub cache, in the hub's own layout.-m zen:autoor-m zen:<pin>loads only local files that have just been verified.What it does
zen selecttakes the highest-ranked pin that fits the free memory. On a unified-memory device (Metal, integrated CUDA) the device counts no more than free RAM.--cpucounts RAM only.blobs/<pinned sha256>.partand never reads past the pinned size.Range, and appends a 206 only when itsContent-Rangestarts at the byte it asked for.zen use,zen rollback. State is~/.cache/hanzo/zen/state.json, replaced by rename. Commands that change it holdstate.json.lock.hanzo-zen/<pin>/as hard links to exactly the pinned files.zen:load can fall back to a download or a hosted model.hanzo-zen/, athanzo-zen/<pin>or inside it is removed, never followed.tune,quantize,train,distilland the non-text model kinds refusezen:.zen6-nano-4b-pq2(needs 3.00 GiB) andzen6-nano-9b-pq2(needs 4.25 GiB), both Apache-2.0. Each figure is the highest measured CPU peak x 1.25, rounded up to 256 MiB. For the 9B that peak is 3,295 MiB, from a 2,048-token prompt.hanzo.ymlgains azen-bootstrapgate. Docs:guides/models/run-zen-offline.md,reference/cli.md; notes inLLM.md.Proof
All from the release binary of
b678be2(hanzo-enginesha2560b7fda4d...fc12), on a 4-core Xeon 2.10 GHz with 16 GB RAM, no GPU, starting from an empty cache. The two commits after it only move a test import and add two#[allow]lint attributes, so they change no code path.catalog.jsonin sha256 and sizezen pull zen6-nano-4b-pq2failed verification ... has sha256 4607229f... (1146465344 bytes), the pin is f7cbf3f9... (1146465344 bytes). 0 files left behindunshare -rnError: zen6-nano-4b-pq2 is not installed: ... Run hanzo-engine zen pull ... or zen import, exit 1, no downloadserve -m zen:zen6-nano-4b-pq2 --cpu --host 127.0.0.1 --no-advertiseinsideunshare -rn(loopback only), temperature 0strace -f -e connect: 0 connect() callszen pull zen6-nano-9b-pq2zen use/zen rollbacktwicecache delete -m zenlm/zen6-nano-4bhanzo-zen/zen6-nano-4b-pq2/removedA sanity check confirms the strace capture does log connects. A no-network curl under the same capture logs 3.
Every review fix has a test that fails without it. The new tests were run against
4532ccd(before the fixes): 6 lib tests and 3zen_pulltests failed. On this branch:--lib zen::: 47 passed.zen_pull: 14 passed.zen_offline: 1 passed.zen: 8 passed.The
hanzo.ymlgates, run locally (GitHub Actions is off on this repo, and the forge gates only main andv*):v1-only: pass.fmt: pass.kv-isolation: pass (9 + 9 + 12 tests).zen-bootstrap: pass (47 + 14 + 8 tests).check --workspace: pass.--no-deps): no lint in any file this PR touches.hanzo-clipasses.hanzo-enginestill fails clippy on 7 errors that predate this branch (inmodels/zen6.rs,attention/backends/lsa.rs,paged_attention/mod.rsand others); this PR adds none.Review
An independent Opus red review of the full change found 16 items. The blockers and should-fixes are fixed here, each with a failing-first test:
.part,.import);--cpuignored by thezencommands;tuneadvertised but broken;cache deleteleaving hard links that kept the blob on disk;state.jsonread-modify-write races;A second review of the fix delta found three should-fixes, now fixed with tests:
hanzo-zen/itself;zencommands blocking behind a pull;The review notes are posted below.
Nits left as they are:
cache deletematches the repo name case-sensitively.ModelTypehas noDebug, so its tests use.err().Not done here (remaining scope of #163)
serve.servestill binds0.0.0.0and advertises over mDNS by default. The guide says to pass--host 127.0.0.1 --no-advertise.doctorreports, and GPU memory peaks. Thememory_bytesfigures are CPU peaks.Generated by Claude Code