format: a bailing container must promise a walkable layer count

bailingmoe3_layouts rebuilds the release GGUF's layouts by walking every
layer the container claims -- and it runs on the open path, before any
plugin gets a vote. Its gate checked the counts were positive and nothing
more: a GGUF naming 2^62 blocks sends the name-probe loops over centuries
of iterations. The process never listens, never refuses; StallWatch notes
the silence after two minutes and stops there. A negative
first_k_dense_replace opens a second loop of the same order, starting
below zero. This is a hostile container's permanent hang, the same
supply-chain class as the round-two finding on the shard index: the
refusal must land before the walk.

The gate now caps n_layers at 4096 (the family's real models are an order
of magnitude below; 4096 layers is not a slow load either) and requires
the dense prefix to lie inside the stack. checkpoint_test pins all three
shapes -- 2^62 layers refused, negative prefix refused, a small honest
stack opens as before -- and the test GGUF writer gains the INT64 KV type
they are spelled in, which the u32 field could not carry.

Found by the 2.1.0 review pass (axis: hostile model files).
This commit is contained in:
fl0l0u committed 2026-11-15 21:15:23 +00:00
1 parent 6e8a2f0a94
commit 4943bba2fb
3 files changed
+49 -2

No files matched your search

+2 -1
View File
@@ -11,7 +11,7 @@ namespace ggufw {
struct GKv {
std::string key;
uint32_t type; /* 4 u32, 6 f32, 8 string, 9 array of strings */
uint32_t type; /* 4 u32, 6 f32, 8 string, 9 array of strings, 10 i64 */
double num = 0;
std::vector<std::string> strs;
};
@@ -42,6 +42,7 @@ inline bool write_gguf(const std::string& path, const std::vector<GKv>& kvs,
put_str(&b, kv.key);
put_bytes(&b, &kv.type, 4);
if (kv.type == 4) { const uint32_t v = (uint32_t)kv.num; put_bytes(&b, &v, 4); }
else if (kv.type == 10) { const int64_t v = (int64_t)kv.num; put_bytes(&b, &v, 8); }
else if (kv.type == 6) { const float v = (float)kv.num; put_bytes(&b, &v, 4); }
else if (kv.type == 8) put_str(&b, kv.strs.at(0));
else {