Repository navigation
llama.cpp: ship third-party notices for the embedded web UI (#994) - #1561
Draft
bryan-minimal wants to merge 1 commit into
Draft
bryan-minimal wants to merge 1 commit into
bryan-minimal wants to merge 1 commit into
Conversation
The llama-ui dist bundle that llama-server embeds is minified and carries none of the license texts or NOTICE files of the code compiled into it. ui-THIRD-PARTY-NOTICES holds them: one section per bundled npm package (name@version, SPDX id, verbatim LICENSE/COPYING/NOTICE text from the npm tarball, checked against the lock's sha512 integrity), the three libraries vendored in tools/ui/src/lib/vendors, and llama-brand's logo licence and redistribution grant. gen-ui-notices.py generates it from the b12359 source's tools/ui/package-lock.json; the build does not run it. build.sh installs it to usr/share/licenses/llama.cpp (new `licenses` output) and fails closed unless its header's UI version, dist sha256 and lock sha256 match what is being built, so a bump without regenerating cannot ship stale notices. A Standalone test checks the installed file names this version and carries the svelte, dompurify and pdfjs-dist sections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #994 with option 1: a pinned, generated notices file for the llama-ui dist bundle that llama-server embeds.
What changes
packages/llama.cpp/ui-THIRD-PARTY-NOTICES(649,529 bytes, 13,072 lines). A header records the llama-ui version (b12359), the dist sha256, thetools/ui/package-lock.jsonsha256 (240e37ff…1553), the source sha256, the license counts and the packages that have no license file. After the header comes one section per package, sorted by name:name@version, its SPDX id, its source with the integrity check used, the verbatim LICENSE/LICENCE/COPYING text, and any NOTICE (orNOTICE: none in the package).packages/llama.cpp/gen-ui-notices.py. Generates the file, with usage at the top. Run it aspython3 -Ion each bump; the build doesn't run it. It checks both tarballs against the build.ncl pins and the dist'sbuild.jsonversion. Each npm tarball is checked against the lock's sha512integrity. It reads only top-level license files and package.json, and executes or installs nothing. Output is byte-identical across runs.Localinput, with a newlicensesoutput (usr/share/licenses/llama.cpp/*,OutputData). A Standaloneui-noticestest checks four things: the file names thisversion, it has the svelte and dompurify sections, pdfjs-dist isApache-2.0with its missing NOTICE recorded, and both the Apache and MPL texts are present. The attrs license comment is updated.llama-ui versionequals$MINIMAL_ARG_VERSION, and unless the header's dist and lock sha256s match${version}-dist.tar.gzandtools/ui/package-lock.json. A bump that doesn't regenerate the file therefore fails the build. I checked the guard locally against the real lock and dist. A wrong version, a tampered lock and a missing header field each fail it, and the real inputs pass.Which packages are bundled (and why not "non-dev")
llama-ui lists every dependency under
devDependencies, as SvelteKit apps do: all 1,239 lock entries aredev: true. So the lock's non-dev closure is empty and can't be the answer. The generator instead derives the roots fromtools/ui/src. A root is a bare specifier imported for its value;import type,*.d.ts, tests and stories don't count, and CSS@import/@plugin/@usedo. The workbox modules that the dist'ssw.jsreports (workbox:<module>:) are added as roots too. From the roots it followsdependencies,optionalDependenciesand installedpeerDependencies, resolved the way node resolves the lock. It does not enter:@types/*(declarations only);vite,typescript,@sveltejs/vite-plugin-svelte,sass,@typescript-eslint/types);@napi-rs/canvasand its per-platform binaries).The closure errs toward including too much. For example, it keeps the MCP SDK's server-side dependencies (express, qs, …) and kit's server helpers (sirv, cookie, …). Tree-shaking may drop those from the bundle, but an extra notice does no harm and a missing one does.
Reconciling with the issue's 402. I reproduced roughly that number (407–411 unique name@version) by walking the same closure without the exclusions above. The difference from 362 is the 42
@types/*packages,@napi-rs/canvasplus 11 platform binaries, and@typescript-eslint/types. None of them puts code into a browser bundle. Six packages pulled in by the Tailwind CSS plugins (@tailwindcss/forms,@tailwindcss/typographyand their dependencies) are added the other way, because they emit CSS into the bundle. The issue's per-license table matches this result for Apache-2.0 (7), ISC (44), BSD-2-Clause (2), 0BSD, Unlicense and DOMPurify.Counts
362 npm packages (unique name@version), plus 3 libraries vendored in
tools/ui/src/lib/vendors(nerdamer-prime, decimal.js, big-integer). The vendored libraries are bundled through the nerdamer vite plugin and aren't in the lock.Packages with no license file in their npm tarball (8). For these the file gives the standard text of the SPDX id from package.json, with the package.json author as the copyright holder:
@polka/url@1.0.0-next.29,fastdom@1.0.12,is-reference@3.0.3,locate-character@3.0.0,rehype-katex@7.0.1,remark-math@6.0.0,sirv@3.0.2,strictdom@1.0.1(all MIT).No
licensein package.json (khroma, runed ×3, svelte-toolbelt ×3). All of them ship a license file. Their SPDX id (MIT) is taken from their repository's LICENSE, which I checked.Every package's license was determined. Of the Apache-2.0 packages, only dexie ships a NOTICE file, and it's included verbatim. The other six, pdfjs-dist among them, ship none, and the file records that for each.
For review
Logo.svelte, the favicons, and the PWA/splash icons in the dist. ItsBRAND-USAGE.mdgrants everyone permission to redistribute the marks, commercially too, "as part of software distributions, packages, and operating systems". It also says attribution is satisfied by naming the repo in a credits file. Both texts are in the notices. I left CC-BY-NC-4.0 out oflicense_spdxbecause the grant has no SPDX expression. Say if you'd rather declare it, e.g. as aLicenseRef-.f055406…, which pins them by hash.Follow-up 8000
Doing this automatically at bump time is a pkgmgr follow-up (pm#1181): a generic "npm-lock notices" step in the updater, so a llama.cpp bump regenerates this file instead of failing the guard. Until then, a bump PR needs one
gen-ui-notices.pyrun; the usage is at the top of the script.Not built locally; build-bot will build it.
🤖 Generated with Claude Code