Skip to content

Replace a damaged prepared tool runtime - #132

Merged
lexoliu merged 2 commits into
devfrom
fix/131-damaged-tool-runtime
Oct 15, 2026
Merged

lexoliu merged 2 commits into
devfrom
fix/131-damaged-tool-runtime

Conversation

@lexoliu

@lexoliu lexoliu commented Oct 15, 2026

Copy link
Copy Markdown
Owner

prepare_local treated <root>/<cache key> as prepared as soon as the directory existed, so a runtime with missing executables failed with a pathless Io(NotFound) on every later run (seen in May's CI after a cache tool restored the directories without their files), and an altered one failed with Integrity forever.

  • An invalid runtime — an executable missing, not a regular file, with the wrong digest or with writable/non-executable permissions — is replaced by a freshly staged one, then verified once; a second failure is an error, never a retry loop.
  • A missing executable is reported as InvalidCache(path).
  • Creating or replacing a runtime runs under an exclusive fd-lock lock on <root>/.<cache key>.lock, re-checked after acquisition, so two preparers cannot move aside a runtime the other just installed. A valid runtime is reused without the lock and without writes. (std::fs::File::lock needs Rust 1.89; the workspace MSRV is 1.88.)
  • Behaviour change: a tampered runtime is now replaced with a warning instead of failing closed; tampered_cache_fails_closed became the replacement test.

Tests: missing executable reports its path; empty bin/ skeleton, altered bytes and writable executable are each replaced; a valid runtime is reused with inode and mtime unchanged; eight concurrent preparations of one broken root all succeed with nothing left behind. aither-sandbox: 169 passed (with HEEL_BIN), fmt and clippy -D warnings clean.

Closes #131

prepare_local treated <root>/<cache key> as prepared as soon as the
directory existed. A runtime whose executables were missing failed with a
pathless Io(NotFound) on every later run, and an altered one failed with
Integrity forever.

An invalid runtime (an executable missing, not a regular file, with the
wrong digest or permissions) is now replaced by a freshly staged one and
verified once; a missing executable is reported as InvalidCache(path).
Creating or replacing a runtime runs under an exclusive lock on
<root>/.<cache key>.lock with a re-check after acquiring it, so concurrent
preparers never move aside a runtime another one just installed. A valid
runtime is reused without taking the lock or writing anything.

Closes #131
@codecov-commenter

codecov-commenter commented Oct 15, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 95.53073% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
sandbox/src/tool_runtime.rs 95.53% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

Preparation marks executables read-only on every platform, but only unix
verified it, so a writable executable passed verification on Windows.
@lexoliu
lexoliu merged commit 5b77130 into dev Oct 15, 2026
27 checks passed
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.

A damaged prepared tool runtime fails with a pathless NotFound and never recovers

2 participants