[PR #1801] [CLOSED] fix(setup): discard damaged llama.cpp source archives #3681

Closed
opened 2026-11-07 15:30:02 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1801
Author: @hulkbig
Created: 10/10/2026
Status: ❌ Closed

Base: main ← Head: fix/llama-source-corrupt-archive-1797


📝 Commits (1)

  • cdb17c7 fix(setup): discard damaged llama.cpp source archives

📊 Changes

2 files changed (+184 additions, -4 deletions)

View changed files

📝 setup.py (+12 -4)
➕ tools/test_setup_llama_archive.py (+172 -0)

📄 Description

Title

Issue: Fixes #1797

Summary

A damaged cached llama.cpp source ZIP can keep its .done mark after get_llama_cpp() raises BadZipFile. Every later setup run then reuses the same bad archive. Remove that archive and its mark so the next run can download it again.

Kept as a draft: CUDA/HIP/SYCL builds have not been run, so the backend-build requirement in AGENTS.md has not been met. The applicability of that requirement to this installer-only change still needs clarification before requesting review.

What changed

  • Catch zipfile.BadZipFile only around opening and extracting the llama.cpp source archive, and reuse drop_archive() for that exact ZIP and its .done mark.
  • Re-raise the original exception. If cleanup raises OSError, warn about manual cleanup without replacing the original archive error.
  • Add isolated local-file regressions for invalid/truncated archives, extraction-time CRC failure and recovery, cleanup edge cases, successful reuse, and non-corruption errors that must retain their cache.

The download strategy, retries, source pin, archive member filtering, successful extraction path, and engine/backend code are unchanged. This does not add checksums or change archive-security policy.

Related: #1126 changes the same function to use safe_extract(), but its current implementation does not remove this damaged source cache. These changes address different behavior; any future integration must preserve that safe-extraction work. #424 covers the analogous engine-archive path.

Extra Notes

Local validation on Linux x86_64 (kernel 6.18.44), Python 3.12.14, at cdb17c717260bdb9122099bac055df82ef197f0e:

  • Real production get_llama_cpp() / download(file://...) reproduction: two calls on unchanged base fb58e0d keep reusing the bad ZIP and mark. With the fix, the first call removes them and the second installs a valid local archive. Network calls are prohibited in these regressions.
  • python tools/test_setup_llama_archive.py -v: 10 tests passed. The same final suite fails on the unchanged base.
  • Independent review: 9 additional boundary checks passed.
  • python tools/test_setup_golden.py -v: 4 passed, including saved-configuration byte consistency.
  • 33 selected adjacent archive checks passed through an offline runner with socket calls blocked: tools.test_setup_pins.Engine; tools.test_setup_engine_hash classes ArchiveVerification, DigestLookup, WhereTheHashComesFrom, Wiring; and WhatARefusalDoesToTheCaller.test_the_cuda_and_amd_paths_both_verify.
  • python tools/test_setup_choices.py -v: 39 passed, 1 environment error (RotationalDisk.test_sysfs: missing /sys/block), identical on base and patch.
  • python -m py_compile setup.py tools/test_setup_llama_archive.py, git diff --check, and exact-base patch replay checks passed.

Validation limits: no CUDA/HIP/SYCL build, Windows run, GPU/model execution, or real remote llama.cpp download. Three existing adjacent checks with unmocked HEAD requests were excluded from the final offline selection. An earlier broad engine-hash run made release-asset HEAD requests, received HTTP 404, and was interrupted; the full suite is not reported as passing. No online CI success is assumed.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1801 **Author:** [@hulkbig](https://github.com/hulkbig) **Created:** 10/10/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/llama-source-corrupt-archive-1797` --- ### 📝 Commits (1) - [`cdb17c7`](https://github.com/Niko1221/Strata/commit/cdb17c717260bdb9122099bac055df82ef197f0e) fix(setup): discard damaged llama.cpp source archives ### 📊 Changes **2 files changed** (+184 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `setup.py` (+12 -4) ➕ `tools/test_setup_llama_archive.py` (+172 -0) </details> ### 📄 Description ## Title Issue: Fixes #1797 ## Summary A damaged cached llama.cpp source ZIP can keep its `.done` mark after `get_llama_cpp()` raises `BadZipFile`. Every later setup run then reuses the same bad archive. Remove that archive and its mark so the next run can download it again. Kept as a draft: CUDA/HIP/SYCL builds have not been run, so the backend-build requirement in AGENTS.md has not been met. The applicability of that requirement to this installer-only change still needs clarification before requesting review. ## What changed - Catch `zipfile.BadZipFile` only around opening and extracting the llama.cpp source archive, and reuse `drop_archive()` for that exact ZIP and its `.done` mark. - Re-raise the original exception. If cleanup raises `OSError`, warn about manual cleanup without replacing the original archive error. - Add isolated local-file regressions for invalid/truncated archives, extraction-time CRC failure and recovery, cleanup edge cases, successful reuse, and non-corruption errors that must retain their cache. The download strategy, retries, source pin, archive member filtering, successful extraction path, and engine/backend code are unchanged. This does not add checksums or change archive-security policy. Related: #1126 changes the same function to use `safe_extract()`, but its current implementation does not remove this damaged source cache. These changes address different behavior; any future integration must preserve that safe-extraction work. #424 covers the analogous engine-archive path. ## Extra Notes Local validation on Linux x86_64 (kernel 6.18.44), Python 3.12.14, at `cdb17c717260bdb9122099bac055df82ef197f0e`: - Real production `get_llama_cpp()` / `download(file://...)` reproduction: two calls on unchanged base `fb58e0d` keep reusing the bad ZIP and mark. With the fix, the first call removes them and the second installs a valid local archive. Network calls are prohibited in these regressions. - `python tools/test_setup_llama_archive.py -v`: 10 tests passed. The same final suite fails on the unchanged base. - Independent review: 9 additional boundary checks passed. - `python tools/test_setup_golden.py -v`: 4 passed, including saved-configuration byte consistency. - 33 selected adjacent archive checks passed through an offline runner with socket calls blocked: `tools.test_setup_pins.Engine`; `tools.test_setup_engine_hash` classes `ArchiveVerification`, `DigestLookup`, `WhereTheHashComesFrom`, `Wiring`; and `WhatARefusalDoesToTheCaller.test_the_cuda_and_amd_paths_both_verify`. - `python tools/test_setup_choices.py -v`: 39 passed, 1 environment error (`RotationalDisk.test_sysfs`: missing `/sys/block`), identical on base and patch. - `python -m py_compile setup.py tools/test_setup_llama_archive.py`, `git diff --check`, and exact-base patch replay checks passed. Validation limits: no CUDA/HIP/SYCL build, Windows run, GPU/model execution, or real remote llama.cpp download. Three existing adjacent checks with unmocked HEAD requests were excluded from the final offline selection. An earlier broad engine-hash run made release-asset HEAD requests, received HTTP 404, and was interrupted; the full suite is not reported as passing. No online CI success is assumed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:30:02 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3681
No description provided.