Skip to content

fix(server): re-sign bundled llama-server on darwin to survive macOS amfid#34

Closed
dvcdsys wants to merge 1 commit intomainfrom
fix/macos-llama-codesign
Closed

fix(server): re-sign bundled llama-server on darwin to survive macOS amfid#34
dvcdsys wants to merge 1 commit intomainfrom
fix/macos-llama-codesign

Conversation

@dvcdsys
Copy link
Copy Markdown
Owner

@dvcdsys dvcdsys commented May 7, 2026

Summary

  • macOS Sequoia (26+) tightened amfid: ad-hoc-signed binaries whose linked dylibs carry stale signatures or a com.apple.provenance xattr from the previous bundle get SIGKILL'd within milliseconds of execve.
  • Symptom in the supervisor: {"level":"WARN","msg":"llama-server exited unexpectedly","err":"signal: killed"} with empty stderr (kill happens before the child can write a single byte), restart loop exhausts budget after 4 attempts, boot path fails with embeddings: llama-server not ready: context deadline exceeded.
  • Root cause: existing bundle: target copies cp -R $(LLAMA_DIR)/. $(BUNDLE_DIR)/llama/cp creates new files which macOS treats as untrusted regardless of what state the source had. Whatever blessing the previous bundle accumulated doesn't carry over.
  • Fix: strip xattrs and re-sign the bundle on every make bundle, gated behind ifeq ($(OS),darwin) so other platforms are unaffected.

Diagnosis trail (for the record)

Confirmed via:

  1. Direct llama-server invocation outside the supervisor → same signal: killed, exit 137, empty stderr
  2. xattr -l showed com.apple.provenance on every dylib (auto-applied by macOS on file creation)
  3. codesign --force --deep --sign - once → first run works, subsequent runs killed (signature on dylibs not propagated by single-binary codesign)
  4. xattr -cr <bundle>/llama/ && codesign --force --deep --sign - <bundle>/llama/llama-server → both consecutive runs alive (SN status, full metal init logs)

Test plan

  • make bundle produces a working llama-server
  • Two consecutive direct invocations both survive past ggml_metal_library_init
  • make run boots cleanly without supervisor restart loop
  • Re-run make bundle + make run → still works (the recurrence-on-rebundle case)
  • Linux dev box (or CI Linux runner) → ifeq ($(OS),darwin) block skipped, no behavioural change

Notes

This change does not affect Linux Docker images — those use distroless runtime, the binary inside the image is built/copied by the Dockerfile with its own signing/permissions, and amfid is macOS-only. Only matters for make run / make bundle on macOS dev boxes.

🤖 Generated with Claude Code

…amfid

macOS Sequoia (26+) tightened the amfid (AppleMobileFileIntegrity)
policy: ad-hoc-signed binaries whose linked dylibs carry stale
signatures or a com.apple.provenance xattr from the previous bundle
get SIGKILL'd within milliseconds of execve. Symptom in the
supervisor: `signal: killed` with empty stderr (kill happens before
the child can write a single byte), followed by exhausted restart
budget and the boot path failing with "embeddings: llama-server not
ready: context deadline exceeded".

Root cause is that `cp -R $(LLAMA_DIR)/. $(BUNDLE_DIR)/llama/` in
the existing `bundle:` target creates new files macOS treats as
untrusted; whatever blessing the previous bundle had does not carry
over. So the fix has to run on every bundle, not just first install.

Wraps the strip + deep re-sign in `ifeq ($(OS),darwin)` so other
platforms are unaffected. Tested with two consecutive `make bundle`
+ direct llama-server invocation cycles — both stay alive past the
first metal_library_init log line where the previous behaviour died.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@dvcdsys
Copy link
Copy Markdown
Owner Author

dvcdsys commented May 7, 2026

Folded into #33 — shipping the Makefile fix together with the version-check feature so dev-box survives end-to-end on macOS Sequoia.

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