From 2eb37d1c87efbd1f8fbf3c2535f5643b82d3c2f0 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Tue, 10 Nov 2026 07:56:43 -0400 Subject: [PATCH 1/2] npu-pack: sweep every fconst scratch directory, and stop the test suite leaking into them (Fixes #1907) Since #1801 the canonical copy is written to ~/.cache, and the sweep ran only in the directory being written, so copies older binaries had left in /tmp (tmpfs, i.e. RAM: 17.0 GiB measured) were never reclaimed. The sweep now covers every candidate directory, creating none. With ONEBIT_FCONST_SCRATCH set, only that directory is swept, so a run with an override never removes another lane's files. The test suite was the source of 179 of the 188 /tmp files: test_fconst_scratch_order() left HOME=/home/x with TMPDIR and the override unset, so later crafted imports fell through to /tmp, and the earlier ones wrote into the real ~/.cache. It now restores the four variables, and main() gives the run its own scratch dir, removed at exit. docs/npu.md: where the copy goes, and what the sweep removes. Co-Authored-By: Claude Opus 5.5 --- docs/npu.md | 17 ++++++++++ npu/pack_import.cpp | 25 +++++++++++++- npu/pack_import.h | 8 +++++ tests/npu_pack_import_test.cpp | 61 +++++++++++++++++++++++++++++++++- 4 files changed, 109 insertions(+), 2 deletions(-) diff --git a/docs/npu.md b/docs/npu.md index 98d287a95..8acebe3c0 100644 --- a/docs/npu.md +++ b/docs/npu.md @@ -936,6 +936,23 @@ Two facts about what the container holds, both reported, not hidden: scale 0, zero 0). That is 12.5 % more bytes than the pack; the true K is in the container's manifest and in `config.json`, and nothing reads a padding column as a weight. +### Where a 1.9 pack's rewritten `.fconst` goes + +A Ryzen AI 1.9 pack's Token `.fconst` is rewritten into its 1.8 form before it is read. The copy is as large as the source +(3.6 GB for an h4096 pack), so where it lands matters: on strixhalo `/tmp` is tmpfs, which means RAM. The importer tries these +directories in order: + +1. `$ONEBIT_FCONST_SCRATCH`, if set; +2. `$XDG_CACHE_HOME/1bit/fconst19`, or `~/.cache/1bit/fconst19` (on disk); +3. `$TMPDIR`, then `/tmp`, then the current directory. + +The copy is a cache: it is reused while the source's size and mtime and the rules version match. On each write the importer +sweeps the scratch directories. It removes other identities of the same pack and geometry, the pre-version name, and any +`1bit-fconst19*` copy nobody has written for 6 hours. Without an override, **every** candidate directory is swept, not only the +one being written, so copies older binaries left in `/tmp` get reclaimed (engine#1907). With `ONEBIT_FCONST_SCRATCH` set, only +that directory is swept, and a run with an override never removes another lane's files. The test suite sets one per run and +removes it at exit. + ### Linking the kernel set the container will be served with A model directory carries its own NPU kernels in `npu/` (see "A model directory"), and for an imported diff --git a/npu/pack_import.cpp b/npu/pack_import.cpp index 248c2f6ce..65ab29d62 100644 --- a/npu/pack_import.cpp +++ b/npu/pack_import.cpp @@ -752,7 +752,17 @@ std::string materialise_token_fconst(const std::string& pack_dir, const Dims& di // GiB of tmpfs, had been resident all day). const std::string legacy_name = std::string(kScratchStem) + "-" + tag + "-" + std::to_string(dims.hidden) + "-" + std::to_string(dims.heads) + "-" + std::to_string(dims.layers) + ".fconst"; - evict_stale_canonical_copies(d.string(), name, ident_prefix, legacy_name, kScratchMaxAgeSeconds); + // Sweep EVERY candidate directory, not only the one written (engine#1907). Since #1801 moved the cache to disk, a + // write lands in ~/.cache, so the sweep never visited /tmp again, and the copies older binaries had left there + // (17.0 GiB of tmpfs, i.e. RAM, measured 2026-11-10) stayed until reboot. The other directories are only swept, + // never created, and the rule is the same one as here: the exact name is kept wherever it is. + // An explicit ONEBIT_FCONST_SCRATCH is a lane saying "my scratch is here": then only that directory is swept, so a + // run with an override (the test suite sets one) never removes another lane's files from the shared /tmp or cache. + std::vector dir_names; + const char* override_dir = std::getenv("ONEBIT_FCONST_SCRATCH"); + if (override_dir && *override_dir) dir_names.push_back(d.string()); + else for (const auto& x : dirs) dir_names.push_back(x.string()); + sweep_fconst_scratch_dirs(dir_names, d.string(), name, ident_prefix, legacy_name, kScratchMaxAgeSeconds); // Say where it went whenever that is not the ordinary place: the copy is a few hundred MB and it is scratch. std::error_code ec2; const fs::path tmpdir = [&] { try { return fs::temp_directory_path(); } catch (...) { return fs::path(); } }(); @@ -4908,4 +4918,17 @@ void evict_stale_canonical_copies(const std::string& dir, const std::string& kee } } +void sweep_fconst_scratch_dirs(const std::vector& dirs, const std::string& written_dir, + const std::string& keep_name, const std::string& prefix, const std::string& legacy_name, + int64_t max_age_seconds) { + // engine#1907: every candidate is swept, not only the one being written. A directory that does not exist is skipped, + // never created: only the written one is made ready, by its caller. + for (const auto& dir : dirs) { + std::error_code ec; + if (dir == written_dir || fs::is_directory(dir, ec)) + evict_stale_canonical_copies(dir, keep_name, prefix, legacy_name, max_age_seconds); + } +} + + } // namespace onebit::npu::pack_import diff --git a/npu/pack_import.h b/npu/pack_import.h index 01541c3d7..5265ec3b8 100644 --- a/npu/pack_import.h +++ b/npu/pack_import.h @@ -207,6 +207,14 @@ void evict_stale_canonical_copies(const std::string& dir, const std::string& kee const std::string& legacy_name = std::string(), int64_t max_age_seconds = 0); +// engine#1907: apply evict_stale_canonical_copies() to EVERY scratch candidate, not only the one being written. Since #1801 the +// write lands in the on-disk cache, so a sweep of that directory alone never reached /tmp again, and the copies older binaries +// had left in tmpfs (17.0 GiB of RAM, measured 2026-11-10) stayed until reboot. `written_dir` is swept even if it is not yet a +// directory as seen here; every other entry is swept only when it already exists, and is never created. +void sweep_fconst_scratch_dirs(const std::vector& dirs, const std::string& written_dir, + const std::string& keep_name, const std::string& prefix, const std::string& legacy_name, + int64_t max_age_seconds); + // The text artifacts a runnable container needs beside model.q4nx, and which of them the pack // actually carries. A pack fetched weight by weight can be weights-only (engine#1024; AMD's repos // do publish the text, and how much of it varies per pack), and an importer that says nothing about diff --git a/tests/npu_pack_import_test.cpp b/tests/npu_pack_import_test.cpp index c63b3fb93..d000f0ac0 100644 --- a/tests/npu_pack_import_test.cpp +++ b/tests/npu_pack_import_test.cpp @@ -731,6 +731,44 @@ void test_evict_stale_canonical_copies() { " geometry/age rules + 3 degenerate)\n"); } +// engine#1907: the sweep ran only in the directory being written. Since #1801 that is the on-disk cache, so /tmp was never swept +// again, and 17.0 GiB of copies left there by older binaries stayed in tmpfs (RAM). Every candidate is swept now; one that does +// not exist is not created. +void test_sweep_fconst_scratch_dirs() { + const fs::path root = fs::temp_directory_path() / ("1bit-sweep-" + std::to_string(::getpid())); + std::error_code ec; + fs::remove_all(root, ec); + const fs::path written = root / "cache", other = root / "tmp", absent = root / "never-made"; + fs::create_directories(written); + fs::create_directories(other); + auto touch = [&](const fs::path& d, const std::string& base) { + std::ofstream o(d / base, std::ios::binary | std::ios::trunc); + o << 'x'; + }; + const std::string prefix = "1bit-fconst19v1-12345-896-14-24-"; + const std::string keep = prefix + "291653952-76263210.fconst"; + const std::string stale = prefix + "291653952-99999.fconst"; + const std::string legacy = "1bit-fconst19-12345-896-14-24.fconst"; + const std::string old_other = "1bit-fconst19v1-77777-1536-12-28-995712640-73345656.fconst"; + const std::string fresh_other = "1bit-fconst19v1-88888-1536-12-28-995712640-73345656.fconst"; + for (const auto& f : {keep, stale, legacy, old_other, fresh_other}) touch(other, f); + touch(written, keep); + const auto seven_hours_ago = fs::file_time_type::clock::now() - std::chrono::hours(7); + fs::last_write_time(other / old_other, seven_hours_ago, ec); + pi::sweep_fconst_scratch_dirs({written.string(), other.string(), absent.string()}, written.string(), keep, prefix, legacy, + 6 * 3600); + const auto in_other = [&](const std::string& b) { return fs::exists(other / b); }; + check(!in_other(old_other), "sweep: an abandoned copy in a directory that was NOT written goes (the /tmp left behind by #1801)"); + check(!in_other(stale) && !in_other(legacy), + "sweep: a stale identity and the legacy name of this pack go from the other directory too"); + check(in_other(keep), "sweep: the exact name is kept in every directory (another environment may reuse it there)"); + check(in_other(fresh_other), "sweep: a fresh copy of another pack stays -- another run may be writing it"); + check(fs::exists(written / keep), "sweep: the copy being written is kept"); + check(!fs::exists(absent), "sweep: a candidate that does not exist is not created"); + fs::remove_all(root, ec); + std::printf(" scratch sweep: every candidate directory, 6 arms\n"); +} + void test_modelbin_genre_refusal(const std::string& root) { const fs::path dir = fs::path(root) / "crafted-modelbin"; fs::remove_all(dir); @@ -2891,6 +2929,19 @@ void test_fconst_block_headers() { // cache whose size is the pack's own .fconst, and on this box /tmp is tmpfs, so where it lands is a RAM decision. The bug was a // cache directory that was never created -- every pack then fell through to /tmp and nothing noticed. void test_fconst_scratch_order() { + // engine#1907: this arm rewrites four variables, and it used to leave HOME=/home/x with TMPDIR and the override unset, so + // every crafted import after it fell through to the literal /tmp (179 of the 188 files found there were this suite's). + // Save and restore them, so the rest of the run keeps the per-run scratch directory main() set. + struct Saved { const char* name; bool had; std::string value; }; + std::vector saved; + for (const char* n : {"ONEBIT_FCONST_SCRATCH", "XDG_CACHE_HOME", "HOME", "TMPDIR"}) { + const char* v = std::getenv(n); + saved.push_back({n, v != nullptr, v ? v : ""}); + } + struct Restore { + std::vector& s; + ~Restore() { for (const auto& x : s) { if (x.had) setenv(x.name, x.value.c_str(), 1); else unsetenv(x.name); } } + } restore{saved}; const auto first_with = [](const char* scratch, const char* xdg, const char* home) { if (scratch) setenv("ONEBIT_FCONST_SCRATCH", scratch, 1); else unsetenv("ONEBIT_FCONST_SCRATCH"); if (xdg) setenv("XDG_CACHE_HOME", xdg, 1); else unsetenv("XDG_CACHE_HOME"); @@ -2945,7 +2996,6 @@ void test_fconst_scratch_order() { check(std::count(no_tmpdir.begin(), no_tmpdir.end(), std::string("/tmp")) == 1, "fconst scratch: with TMPDIR unset, /tmp appears exactly once (no duplicate from the resolver)"); std::system(("rm -rf " + tdir).c_str()); - setenv("HOME", "/home/x", 1); // leave the environment as the arms above expect it } std::printf("fconst scratch: order is override -> disk cache -> temp/cwd, pinned\n"); } @@ -3662,6 +3712,14 @@ void test_qk_norm_refusal() { } int main(int argc, char** argv) { + // engine#1907: every crafted 1.9 import writes a canonical copy into the scratch cache. Without this the suite left 0-byte + // copies in the user's real ~/.cache/1bit/fconst19 and in /tmp on every run. Give the run its own directory, removed at exit. + const fs::path run_scratch = fs::temp_directory_path() / ("1bit-pack-test-scratch-" + std::to_string(::getpid())); + if (!std::getenv("ONEBIT_FCONST_SCRATCH")) setenv("ONEBIT_FCONST_SCRATCH", run_scratch.c_str(), 1); + struct ScratchCleanup { + fs::path p; + ~ScratchCleanup() { std::error_code ec; fs::remove_all(p, ec); } + } scratch_cleanup{run_scratch}; test_qk_norm_refusal(); test_tail_head_placement(); const std::string golden_dir = argc > 1 ? argv[1] : ""; @@ -3683,6 +3741,7 @@ int main(int argc, char** argv) { test_external_container_names(); test_external_packed_genre(golden_dir.empty() ? "." : golden_dir); test_canonical_copy_reusable(); test_evict_stale_canonical_copies(); + test_sweep_fconst_scratch_dirs(); test_crafted_refusals(golden_dir.empty() ? "." : golden_dir); test_modelbin_genre_refusal(golden_dir.empty() ? "." : golden_dir); test_1671_plan_head_arm(golden_dir.empty() ? "." : golden_dir); From 15697299f59ac4374139f622d9ebdd6f69cf7530 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Tue, 10 Nov 2026 11:19:09 -0400 Subject: [PATCH 2/2] npu-pack: never sweep the current directory, and test the sweep through the importer (#1915 review, engine#1907) - sweep_fconst_scratch_dirs skips the current directory (compared on canonical paths) unless it is the directory being written, and sweeps a directory listed twice once - test_sweep_is_wired runs import_pack() with an abandoned foreign copy in the scratch directory and asserts it is gone; with an override set, the cache directory's copy must still be there - boundary arms: a file that is not fconst19 scratch is kept however old; the cwd under three spellings; the cwd when it is the written directory - the 6 h constant says what it protects Co-Authored-By: Claude Fable 5.2 --- docs/npu.md | 5 +- npu/pack_import.cpp | 22 ++++++- tests/npu_pack_import_test.cpp | 116 ++++++++++++++++++++++++++++++++- 3 files changed, 139 insertions(+), 4 deletions(-) diff --git a/docs/npu.md b/docs/npu.md index 8acebe3c0..8f053375f 100644 --- a/docs/npu.md +++ b/docs/npu.md @@ -950,7 +950,10 @@ The copy is a cache: it is reused while the source's size and mtime and the rule sweeps the scratch directories. It removes other identities of the same pack and geometry, the pre-version name, and any `1bit-fconst19*` copy nobody has written for 6 hours. Without an override, **every** candidate directory is swept, not only the one being written, so copies older binaries left in `/tmp` get reclaimed (engine#1907). With `ONEBIT_FCONST_SCRATCH` set, only -that directory is swept, and a run with an override never removes another lane's files. The test suite sets one per run and +that directory is swept, and a run with an override never removes another lane's files. The current directory is the +one candidate that is never swept unless the copy is being written there: it is only the last write fallback, and a +working directory's files are not the importer's to clean. The 6 hours are what keep a concurrent run's copy alive in a +shared directory, so the number stays above the longest import; it is not the knob for disk or tmpfs pressure. The test suite sets one per run and removes it at exit. ### Linking the kernel set the container will be served with diff --git a/npu/pack_import.cpp b/npu/pack_import.cpp index 65ab29d62..916009d53 100644 --- a/npu/pack_import.cpp +++ b/npu/pack_import.cpp @@ -717,6 +717,9 @@ std::string materialise_token_fconst(const std::string& pack_dir, const Dims& di constexpr const char* kScratchStem = "1bit-fconst19"; // A scratch copy older than this is a pack no run is importing: no import holds one for hours, so an mtime this far back // means the pack was abandoned, not that somebody is using it. Kept well above the longest import measured (~minutes). + // This number is what protects a CONCURRENT run's copy in a shared directory (the sweep reaches every candidate + // directory now, engine#1907), so it has to stay above the longest import: do not lower it to relieve disk or tmpfs + // pressure -- remove the files, or point ONEBIT_FCONST_SCRATCH at disk, instead. constexpr int64_t kScratchMaxAgeSeconds = 6 * 3600; // Everything but the source identity: the group this run evicts its stale siblings from (engine#1770). const std::string ident_prefix = "1bit-fconst19v" + std::to_string(kCanonicalFormVersion) + "-" + tag + "-" + @@ -4923,9 +4926,24 @@ void sweep_fconst_scratch_dirs(const std::vector& dirs, const std:: int64_t max_age_seconds) { // engine#1907: every candidate is swept, not only the one being written. A directory that does not exist is skipped, // never created: only the written one is made ready, by its caller. + // + // The CURRENT DIRECTORY is the one candidate that is not this importer's to clean (#1915 review): it is in the list + // only as the last write fallback, and a lane that runs `npu-pack` from inside its own scratch would otherwise have + // that scratch's old `1bit-fconst19*` files removed. So it is swept only when it is the directory being written -- + // which is what happened before #1907 and is the evict-on-write rule of engine#1770, unchanged. The comparison is + // on canonical paths: `.`, a relative spelling and the absolute path are the same directory. A directory listed + // twice is swept once. + std::error_code cwd_ec; + const fs::path cwd = fs::weakly_canonical(fs::current_path(cwd_ec), cwd_ec); + std::set seen; for (const auto& dir : dirs) { - std::error_code ec; - if (dir == written_dir || fs::is_directory(dir, ec)) + if (dir.empty()) continue; + std::error_code ec, cec; + const bool written = dir == written_dir; + const fs::path canon = fs::weakly_canonical(dir, cec); + if (!written && (cwd_ec || cec || canon == cwd)) continue; + if (!cec && !seen.insert(canon.string()).second) continue; + if (written || fs::is_directory(dir, ec)) evict_stale_canonical_copies(dir, keep_name, prefix, legacy_name, max_age_seconds); } } diff --git a/tests/npu_pack_import_test.cpp b/tests/npu_pack_import_test.cpp index d000f0ac0..3efb089a0 100644 --- a/tests/npu_pack_import_test.cpp +++ b/tests/npu_pack_import_test.cpp @@ -765,8 +765,121 @@ void test_sweep_fconst_scratch_dirs() { check(in_other(fresh_other), "sweep: a fresh copy of another pack stays -- another run may be writing it"); check(fs::exists(written / keep), "sweep: the copy being written is kept"); check(!fs::exists(absent), "sweep: a candidate that does not exist is not created"); + // #1915 review, boundary arms. (a) A file that is not fconst19 scratch is kept however old it is. (b) The current + // directory is never swept unless it is the directory being written -- under every spelling of it. + { + const fs::path lane = root / "lane-cwd"; + fs::create_directories(lane); + const std::string notes = "notes-about-1bit-fconst19.txt"; + for (const auto& d : {other, lane}) { + touch(d, notes); + touch(d, old_other); + fs::last_write_time(d / notes, seven_hours_ago, ec); + fs::last_write_time(d / old_other, seven_hours_ago, ec); + } + const fs::path was = fs::current_path(); + fs::current_path(lane); + pi::sweep_fconst_scratch_dirs({written.string(), other.string(), ".", lane.string(), (lane / ".." / "lane-cwd").string()}, + written.string(), keep, prefix, legacy, 6 * 3600); + const bool cwd_kept = fs::exists(lane / old_other); + // and when the cwd IS the directory being written, the evict-on-write rule still applies to it + pi::sweep_fconst_scratch_dirs({lane.string(), other.string()}, lane.string(), keep, prefix, legacy, 6 * 3600); + const bool cwd_written_swept = !fs::exists(lane / old_other); + fs::current_path(was); + check(!in_other(old_other), "sweep: (control) the same old file in a directory that is not the cwd goes"); + check(in_other(notes) && fs::exists(lane / notes), "sweep: a file that is not fconst19 scratch is kept however old"); + check(cwd_kept, "sweep: the current directory is never swept, as '.', as its absolute path or through '..'"); + check(cwd_written_swept, "sweep: unless it is the directory being written (evict-on-write, engine#1770)"); + } fs::remove_all(root, ec); - std::printf(" scratch sweep: every candidate directory, 6 arms\n"); + std::printf(" scratch sweep: every candidate directory, 10 arms\n"); +} + +// #1915 review: the arms above call the sweep; nothing ran the importer and looked. "Delete the call site and the suite +// stays green" was true. This runs the production path once -- import_pack() on a crafted pack with a Token .fconst -- +// with a scratch directory that already holds an abandoned copy of ANOTHER pack, and asserts that copy is gone. With an +// override set only that directory is swept, so the second directory's copy must still be there. +void test_sweep_is_wired(const std::string& root) { + const fs::path dir = fs::path(root) / "sweep-wired"; + const fs::path scratch = fs::temp_directory_path() / ("1bit-sweep-wired-" + std::to_string(::getpid())); + const fs::path cache_home = fs::temp_directory_path() / ("1bit-sweep-wired-xdg-" + std::to_string(::getpid())); + std::error_code ec; + fs::remove_all(dir, ec); + fs::remove_all(scratch, ec); + fs::remove_all(cache_home, ec); + fs::create_directories(dir / "cache"); + fs::create_directories(scratch); + fs::create_directories(cache_home / "1bit" / "fconst19"); + const int H = 128, L = 8, V = 64; + { + const int64_t stride = 1 << 20, second = 262144; + std::string fc(size_t(int64_t(L) * stride + 64 + size_t(H) * 2), '\0'); + for (int l = 0; l <= L; ++l) { + fc[size_t(int64_t(l) * stride)] = char(0x86); + fc[size_t(int64_t(l) * stride) + 1] = char(0x35); + if (l < L) { + fc[size_t(int64_t(l) * stride + second)] = char(0x86); + fc[size_t(int64_t(l) * stride + second) + 1] = char(0x35); + } + } + put_file((dir / "dd_metastate_Llm_Token_Token_crafted.fconst").string(), fc); + } + put_file((dir / "config.json").string(), + R"({"model_type":"qwen2","hidden_size":128,"intermediate_size":256,"num_hidden_layers":8,)" + R"("num_attention_heads":2,"num_key_value_heads":1,"head_dim":64,"vocab_size":64,)" + R"("rope_theta":10000.0,"tie_word_embeddings":true,"rms_norm_eps":1e-06})"); + put_file((dir / "model.onnx.data").string(), std::string(size_t(V) * size_t(H) * 2, '\x11')); + put_file((dir / "model.onnx").string(), + pb::model({pb::tensor("model.embed_tokens.weight", {V, H}, "model.onnx.data", 0, uint64_t(V) * uint64_t(H) * 2, 10)}, + {})); + const std::string foreign_old = "1bit-fconst19v1-77777-1536-12-28-995712640-73345656.fconst"; + const std::string foreign_fresh = "1bit-fconst19v1-88888-1536-12-28-995712640-73345656.fconst"; + const std::string unrelated = "keep-me.txt"; + const auto seven_hours_ago = fs::file_time_type::clock::now() - std::chrono::hours(7); + for (const fs::path& d : {scratch, cache_home / "1bit" / "fconst19"}) + for (const auto& f : {foreign_old, foreign_fresh, unrelated}) { + put_file((d / f).string(), "x"); + if (f != foreign_fresh) fs::last_write_time(d / f, seven_hours_ago, ec); + } + struct Env { + std::string name, value; + bool had; + }; + std::vector saved; + for (const char* n : {"ONEBIT_FCONST_SCRATCH", "XDG_CACHE_HOME"}) { + const char* v = std::getenv(n); + saved.push_back({n, v ? v : "", v != nullptr}); + } + setenv("ONEBIT_FCONST_SCRATCH", scratch.c_str(), 1); + setenv("XDG_CACHE_HOME", cache_home.c_str(), 1); + const std::string out = (fs::temp_directory_path() / ("oga_pack_import_sweepwired." + std::to_string(::getpid()))).string(); + fs::remove_all(out, ec); + pi::Options allow; + allow.allow_incomplete = true; + try { + (void)pi::import_pack(dir.string(), out, allow); + } catch (const std::exception&) { + // the import's own outcome is not what is under test: the scratch copy is made, and swept around, before any + // refusal about this fixture's empty payload + } + for (const auto& e : saved) { + if (e.had) setenv(e.name.c_str(), e.value.c_str(), 1); + else unsetenv(e.name.c_str()); + } + bool wrote_here = false; + for (const auto& e : fs::directory_iterator(scratch, ec)) + if (e.path().filename().string().rfind("1bit-fconst19v", 0) == 0 && e.path().filename().string() != foreign_fresh) + wrote_here = true; + check(wrote_here, "sweep wiring: (premise) the import put its scratch copy in the override directory"); + check(!fs::exists(scratch / foreign_old), "sweep wiring: an abandoned copy of another pack is GONE after a real import"); + check(fs::exists(scratch / foreign_fresh), "sweep wiring: a fresh copy of another pack is still there"); + check(fs::exists(scratch / unrelated), "sweep wiring: a file that is not fconst19 scratch is still there"); + check(fs::exists(cache_home / "1bit" / "fconst19" / foreign_old), + "sweep wiring: with an override set, the cache directory is NOT swept (another lane's files stay)"); + fs::remove_all(out, ec); + fs::remove_all(dir, ec); + fs::remove_all(scratch, ec); + fs::remove_all(cache_home, ec); } void test_modelbin_genre_refusal(const std::string& root) { @@ -3742,6 +3855,7 @@ int main(int argc, char** argv) { test_external_packed_genre(golden_dir.empty() ? "." : golden_dir); test_canonical_copy_reusable(); test_evict_stale_canonical_copies(); test_sweep_fconst_scratch_dirs(); + test_sweep_is_wired(golden_dir.empty() ? "." : golden_dir); test_crafted_refusals(golden_dir.empty() ? "." : golden_dir); test_modelbin_genre_refusal(golden_dir.empty() ? "." : golden_dir); test_1671_plan_head_arm(golden_dir.empty() ? "." : golden_dir);