Skip to content

strata_pack.py build: refuse an output directory that already holds a pack, naming the file - #634

Closed
Avicennasis wants to merge 1 commit into
Niko1221:mainfrom
Avicennasis:fix/pack-occupied-output
Closed

Avicennasis wants to merge 1 commit into
Niko1221:mainfrom
Avicennasis:fix/pack-occupied-output

Conversation

@Avicennasis

Copy link
Copy Markdown
Contributor

One fail-closed change on the packer, with a test that runs without a model or a GPU.

strata_pack.py build: an occupied --out is refused before anything is written

build() did out_dir.mkdir(parents=True, exist_ok=True) (tools/strata_pack.py:207) and then wrote experts.bin (:229, through pack_layer.build, which opens it "wb"), dense.bin, embd.bin and manifest.json over whatever the directory held, with nothing said. A --out pointed at a finished pack - this tool's, or iq_pack.py's, whose dense.bin and experts.bin share names with this tool's - was overwritten in place, and a build that stopped partway left the old manifest.json describing the new, half-written files.

Now a manifest.json, index.txt or native_experts.txt in --out stops build before it opens the GGUF or writes a byte, naming the directory and the file, and returns 1 like the other refusals in build:

$ python tools/strata_pack.py build --gguf /nonexistent/m-00001-of-00002.gguf --out /tmp/sr6-cli.9RfT/pack --skip-hash
/tmp/sr6-cli.9RfT/pack already holds a pack (manifest.json is there) - refusing to build; delete the directory or pass another --out
exit 1

Those three are the files the engine reads a pack's identity from (src/core/expert_source.cpp:2289, the fingerprint), so "holds a pack" means the same thing to the tool and to the engine. experts.bin on its own does not count: build writes manifest.json last, so experts.bin without it is a build that did not finish, and it is rebuilt as before. An empty or absent directory proceeds as today. There is no resume to keep - pack_layer.build has no sidecar and rewrites experts.bin from the start - so none was invented. (The same rule in Swiftlet #41 and Colibri 41b4544: the manifest-equivalent is refused, and only an explicit install sidecar resumes.)

Where this meets setup: setup.py:3503 re-runs build when index.txt or experts.bin is missing from the pack directory. An interrupted conversion (no manifest.json yet) is rebuilt as before. A directory with a finished pack and no index.txt (pack_index.py interrupted after build finished), or with experts.bin deleted by hand, now stops setup at this message instead of rewriting the directory; deleting it and running setup again is the way through, and is what the rewrite did to it anyway. setup.py is not touched.

Test: tools/test_shards.py (python -m unittest tools.test_shards), with the GGUF reader replaced by a sentinel so "went on into the build" is observable without the model's shards: each of the three markers is refused with the path and the file named and the directory's contents untouched; an empty and an absent directory go on into the build; experts.bin without manifest.json goes on too.

What I ran, and where

Linux x86_64 (Ubuntu 24.04, AMD Ryzen 7 5800X - no AVX-512, no NVIDIA GPU), Python 3.12.3. Nothing under src/ is touched, so nothing was built.

Branch is on 99f3dbd (0.1.38); happy to rebase if it has moved by the time you look.

… pack, naming the file

build did mkdir(exist_ok=True) and then wrote experts.bin, dense.bin,
embd.bin and manifest.json over whatever pack the directory held, with
nothing said. Now a manifest.json, index.txt or native_experts.txt in
--out (the files the engine reads a pack's identity from) stops build
before it opens the GGUF or writes a byte, naming the directory and the
file; it returns 1 like the other refusals. An empty or absent directory
proceeds as before, and so does experts.bin without manifest.json: build
writes the manifest last, so that is a build that did not finish, not a
pack.

tools/test_shards.py: each marker is refused with the path and the file
named and nothing in the directory touched; an empty and an absent
directory go on into the build; an unfinished build is rebuilt.
Niko1221 added a commit that referenced this pull request Oct 6, 2026
)

Co-authored-by: Léon Avic Simmons <Avicennasis@gmail.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Niko1221

Niko1221 commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Fixed in 0.1.40: strata_pack build refuses an output directory that already holds a pack, naming the file. build --force rebuilds into it, and setup passes --force when it rebuilds a pack that lost its index.txt or experts.bin.

@Niko1221 Niko1221 closed this Oct 6, 2026
Niko1221 added a commit that referenced this pull request Oct 6, 2026
)

Co-authored-by: Léon Avic Simmons <Avicennasis@gmail.com>
anon761 pushed a commit to anon761/Strata-upstream that referenced this pull request Oct 6, 2026
…iko1221#634)

Co-authored-by: Léon Avic Simmons <Avicennasis@gmail.com>
sskver pushed a commit to sskver/Strata that referenced this pull request Oct 7, 2026
…iko1221#634)

Co-authored-by: Léon Avic Simmons <Avicennasis@gmail.com>
MistVVK added a commit to MistVVK/XeStrata that referenced this pull request Oct 8, 2026
…iko1221#634)

取り込んだ strata_pack.py は、pack のあるフォルダーへの build を --force なしでは断る。
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.

2 participants