Skip to content

claude: fall back to a temp dir when the libhegel cache is unwritable - #13

Merged
Liam-DeVoe merged 1 commit into
mainfrom
libhegel-cache-best-effort
Jul 31, 2026
Merged

claude: fall back to a temp dir when the libhegel cache is unwritable#13
Liam-DeVoe merged 1 commit into
mainfrom
libhegel-cache-best-effort

Conversation

@Liam-DeVoe

@Liam-DeVoe Liam-DeVoe commented Jul 31, 2026

Copy link
Copy Markdown
Member

See hegeldev/hegel-go#116

Claude-written description

Ports hegeldev/hegel-go#116 (fixing hegeldev/hegel-go#115) to hegel-java.

LibraryLoader previously refused to load if it could not write the bundled libhegel to the per-user cache directory (~/.cache/hegel-java/libhegel/<sha256>/), so sandboxes that deny writes outside the workspace — e.g. Codex's macOS seatbelt policy — could not run hegel tests at all, even though the cache is purely a performance optimization.

The cache is now best-effort: unpackBundled tries the content-hash-keyed per-user cache first (unchanged semantics: reuse if present, atomic temp-file-plus-rename install); on any cache failure it silently extracts the native to a fresh directory under the system temp dir (Files.createTempDirectory) and loads from there, leaving reclamation to the OS's temp cleaning. Loading fails only when both paths fail, with an error reporting both causes — the temp failure as the exception's cause and the cache failure in the message plus as a suppressed exception, so both stack traces survive. The temp fallback needs no locking or permission hardening since the directory is fresh, unique, and private per process.

The temp-dir supplier is injected via a new constructor overload so both new paths are unit-tested: cache unwritable → temp fallback succeeds (through the real default supplier), and cache + temp both failing → error mentions both causes.

@Liam-DeVoe
Liam-DeVoe enabled auto-merge July 31, 2026 04:49
@Liam-DeVoe
Liam-DeVoe merged commit 79550a8 into main Jul 31, 2026
7 checks passed
@Liam-DeVoe
Liam-DeVoe deleted the libhegel-cache-best-effort branch July 31, 2026 04:50
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.

1 participant