Skip to content
This repository was archived by the owner on Jul 21, 2026. It is now read-only.

libmagic: ship the complete identification database - #29

Merged
brandonpayton merged 3 commits into
mainfrom
migrate/libmagic-dependency-root
Jul 12, 2026
Merged

libmagic: ship the complete identification database#29
brandonpayton merged 3 commits into
mainfrom
migrate/libmagic-dependency-root

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jul 11, 2026

Copy link
Copy Markdown
Member

Purpose

Make libmagic a first-class Kandelo Homebrew dependency with the complete upstream type database and native in-process support for zlib, bzip2, and xz payloads.

The database is compiled by a version-matched native FILE_COMPILE helper. Its on-disk format is fixed-width and endian-tagged, so the formula removes the earlier host-pointer-size truncation assumption instead of preserving a partial 14k-line database.

Formula

  • builds and installs static libmagic for wasm32;
  • generates the complete 5.45 magic.mgc from all 342 upstream source files;
  • installs the source magic files as provenance;
  • enables built-in zlib, bzip2, and xz decoding through declared tap dependencies;
  • publishes static pkg-config linkage with dependency keg paths and libm;
  • embeds the stable Homebrew opt path for default magic_load discovery;
  • leaves the file CLI to a separate consumer PR.

Existing ABI-18 evidence

The artifact-producing formula body is unchanged from the previously validated ABI-18 build:

  • isolated Homebrew source install and literal brew test --keep-tmp --verbose libmagic passed;
  • Node classified WebAssembly, PDF, zlib, bzip2, and xz inputs;
  • Chromium BrowserKernel classified the same inputs with PATH=/no-such-path;
  • database assertions passed for 342 source files, 45,082 logical source lines, 22,642 fixed-width records, and 8,513,392 bytes;
  • WebAssembly recognition came from aggregated source line 42,046, beyond the former partial-database cutoff;
  • the fork-instrumented test consumer manually disassembled to user ABI 18;
  • strict Homebrew audit and style passed.

An independent source-only review subsequently replayed the ABI 18 runtime classification paths and rebuilt a libmagic side module against the current PIC bzip2/xz/zlib formula sources; both the classification and dlopen/dlsym consumer checks passed.

Source merge and bottle publication

Compression source PR #25 is merged at tap main a3ede334ad27aac7c4d5826bac761b9faf768f20. The declared bzip2, xz, and zlib source formulae now resolve from main, so this libmagic source formula no longer has a peer-branch dependency. This PR contains no bottle block, archive, receipt, sidecar, or package-registry artifact and may merge independently after fresh formula review.

Bottle construction and installability claims remain separate. Before publishing a libmagic bottle:

  • sdk: reserve an 8 MiB main-thread shadow stack for linked programs kandelo#842, #873, #874, #881, #882, #885, and #890 must land;
  • trusted ABI-18 bzip2, xz, and zlib bottles must be published first;
  • the trusted publisher must build from the final libmagic tap head, record Homebrew receipts/provenance, and produce the bottle hash from those exact bytes;
  • stock-guest Node and Chromium acceptance must pour libmagic and its dependencies from Homebrew bottles, with no source-build fallback.

Tap #22 is relevant only if a branch-based pre-merge dry run is needed. Automattic/kandelo#867 is merged and is not a gate.

Restack and current-main merge evidence

The two libmagic-owned commits were replayed onto tap main a3ede334ad27aac7c4d5826bac761b9faf768f20, and a third commit changes only the support import to the canonical installed Tap.fetch path. README conflict resolution was additive. Before merge, an independent review refreshed exact tap main aa99c67c632c4f5f0f6ac56850c2b325151e0b78; git merge-tree --write-tree succeeded cleanly, adding only Formula/libmagic.rb and one README line, with the reviewed formula blob unchanged.

Current head: 3784d6bd89e391f8e9660d90180f197e7c51ce2f.

Validation through Kandelo's scripts/dev-shell.sh passed:

  • Homebrew Ruby syntax for the formula and shared support;
  • shared support suite: 21 runs, 186 assertions;
  • brew style Formula/libmagic.rb;
  • literal Homebrew formula loading from a tap path, resolving pkgconf, automattic/kandelo-homebrew/bzip2, xz, and zlib;
  • branch ancestry, three-commit ownership, range-diff inspection, a clean merge tree against current main, git diff --check, and a clean worktree;
  • a main-relative diff containing only Formula/libmagic.rb and one additive README line;
  • no changes to Formula/bzip2.rb or Formula/xz.rb, and no bottle metadata.

The old validated formula blob was 5710428d9c4e3e5065e5f493af99027c6fbd69c3; the new import-adjusted blob is 0ef72dfadb31c034174e66da97e70f819779e214. Every line after the support import is byte-identical, with SHA-256 255ee00f07aecc3bea393ff8cc1b523f87f9155b3dd4f94f538e09300c31d94e.

This PR changes only tap formula source and documentation. It does not change Kandelo's kernel, host runtime, SDK, or ABI.

@brandonpayton

Copy link
Copy Markdown
Member Author

Independent devil review found that the original BSD-2-Clause declaration understated the licensing of the installed 5.45 database. Commit 6f3c169 corrects it to the complete Homebrew expression: BSD-2-Clause-Darwin + BSD-2-Clause + public domain.

Revalidated after the correction:

  • clean-prefix brew audit --strict automattic/kandelo-homebrew/libmagic
  • clean-prefix brew style automattic/kandelo-homebrew/libmagic
  • git diff --check

The reviewer found no runtime, database-completeness, static-linking, fork-instrumentation, or ABI issue. The stacked file CLI adds the suggested separate gzip-header runtime coverage.

@brandonpayton
brandonpayton force-pushed the migrate/compression-library-surfaces branch from e143ffd to 6dd503b Compare July 11, 2026 20:16
@brandonpayton
brandonpayton force-pushed the migrate/libmagic-dependency-root branch from 6f3c169 to 991712b Compare July 11, 2026 22:20
@brandonpayton
brandonpayton force-pushed the migrate/compression-library-surfaces branch from 6dd503b to ca052d7 Compare July 12, 2026 01:41
@brandonpayton
brandonpayton deleted the branch main July 12, 2026 01:55
Build the full version-matched magic.mgc with a native FILE_COMPILE helper, link the target library to declared compression dependencies, and validate the fixed-record database under Kandelo.
@brandonpayton brandonpayton reopened this Jul 12, 2026
@brandonpayton
brandonpayton changed the base branch from migrate/compression-library-surfaces to main July 12, 2026 02:01
@brandonpayton
brandonpayton force-pushed the migrate/libmagic-dependency-root branch from 991712b to 3784d6b Compare July 12, 2026 02:01
@brandonpayton

Copy link
Copy Markdown
Member Author

Independent devil's-advocate source-only review at 3784d6bd89e391f8e9660d90180f197e7c51ce2f: ACCEPT.

The review refreshed exact tap main aa99c67c632c4f5f0f6ac56850c2b325151e0b78; the clean merge tree adds only Formula/libmagic.rb and one README line, with the reviewed formula blob unchanged. It rechecked the official file 5.45 source and composite license, complete 342-fragment database, native generator format, stable opt lookup path, direct compression dependencies, static pkg-config interface, and installed Tap.fetch loader.

Fresh dev-shell syntax, style, literal formula-load, support, dependency, diff, and no-artifact checks passed. A fresh ABI 18 replay classified Wasm/PDF and zlib/bzip2/xz payloads without external commands. A libmagic side module built against the current PIC bzip2/xz/zlib sources also passed dlopen/dlsym. The diff contains no bottle, sidecar, archive, receipt, provenance, JSON, Wasm, or duplicated dependency formula. No source-formula blocker remains.

@brandonpayton
brandonpayton merged commit c1d5183 into main Jul 12, 2026
@brandonpayton
brandonpayton deleted the migrate/libmagic-dependency-root branch July 12, 2026 02:21
@brandonpayton
brandonpayton restored the migrate/libmagic-dependency-root branch July 12, 2026 02:25
@brandonpayton
brandonpayton deleted the migrate/libmagic-dependency-root branch July 12, 2026 02:25
@brandonpayton
brandonpayton restored the migrate/libmagic-dependency-root branch July 12, 2026 02:26
@brandonpayton
brandonpayton deleted the migrate/libmagic-dependency-root branch July 12, 2026 02:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant