Repository navigation
llama.cpp: ship third-party notices for the embedded web UI (#994) - #1561
bryan-minimal wants to merge 2 commits 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>
|
Warning Review limit reached
This review includes 4 billable files and costs up to $1.00.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 33 minutes for your next included review. View limit details
|
llama-brand is CC-BY-NC-4.0 plus a BRAND-USAGE.md grant that permits redistribution in software packages, commercially too. Declare it in license_spdx so an SBOM or license scan sees those terms, instead of an expression that silently omits them. The notices file (and its generator) name the LicenseRef next to both texts. Bryan chose this on 2026-11-18. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
norrietaylor
left a comment
There was a problem hiding this comment.
Scope matches the title. The four files all trace to the notices for the embedded web UI. gen-ui-notices.py is not a build input, so an edit to it does not rehash the package.
Clobber not checked with git log, because the harness denied shell access. The diff removes only the old license comment and the old license_spdx value, and both replacements are intended.
Correctness The build.sh guard reads the header fields correctly and fails closed on an empty field. The ui-notices test matches the shipped file: the pdfjs-dist section has License: and NOTICE: in the 4 lines after its name. The header counts add up to 365 (362 npm plus 3 vendored). LicenseRef-llama-brand matches the LicenseRef- pattern in .github/scripts/license_lint.py, and seven other packages use that form. The import order on line 1 follows the repo rule. One real defect: the license-file pattern in the generator also matches a JavaScript source file, and that file is in the shipped notices. The other findings are small.
Not checked No build and no test run. gitleaks and git log did not run (shell denied). I did not download the tarballs, so the 362-package closure and the per-package license texts are not verified against the lock. I did not confirm that ggml-org/llama-brand is public.
| """ | ||
| STANDARD_TEXTS = {"MIT": MIT_TEXT} | ||
|
|
||
| LICENSE_FILE = re.compile(r"^(LICEN[CS]E|COPYING|NOTICE)([.\-_].*)?$", re.I) |
There was a problem hiding this comment.
low · LICENSE_FILE matches any top-level name that starts with license, copying or notice plus ., - or _. It matched cytoscape's license-update.mjs, a script that writes the LICENSE file. The shipped ui-THIRD-PARTY-NOTICES prints that JavaScript at lines 3276-3309 as a license text. This is the only such label among the sections of the file. The same match also counts as a license file in the no license file test at line 378, so a package with only such a source file skips the standard-text fallback. Exclude code extensions (.js, .mjs, .cjs, .ts, .json) or allow only known suffixes, then regenerate the file.
| ["/bin/bash", "-c", "grep -qx 'svelte@[0-9.]*' /usr/share/licenses/llama.cpp/ui-THIRD-PARTY-NOTICES && grep -qx 'dompurify@[0-9.]*' /usr/share/licenses/llama.cpp/ui-THIRD-PARTY-NOTICES"], | ||
| ["/bin/bash", "-c", "grep -A4 -x 'pdfjs-dist@[0-9.]*' /usr/share/licenses/llama.cpp/ui-THIRD-PARTY-NOTICES | grep -qx 'License: Apache-2.0'"], | ||
| ["/bin/bash", "-c", "grep -A4 -x 'pdfjs-dist@[0-9.]*' /usr/share/licenses/llama.cpp/ui-THIRD-PARTY-NOTICES | grep -qx 'NOTICE: none in the package'"], | ||
| ["/bin/bash", "-c", "grep -q 'Apache License' /usr/share/licenses/llama.cpp/ui-THIRD-PARTY-NOTICES && grep -q 'Mozilla Public License' /usr/share/licenses/llama.cpp/ui-THIRD-PARTY-NOTICES"], |
There was a problem hiding this comment.
low · The comment at lines 112-114 says the test proves that dompurify ships both texts. This command greps the whole file. Apache License is also in the six Apache-2.0 packages and in dexie, so the Apache half passes when dompurify's section has no Apache text. Scope the grep to the dompurify section, as lines 122-123 do for pdfjs-dist. For example, use sed -n '/^dompurify@/,/^=====/p' and grep both strings in that output.
|
|
||
| Both tarballs are checked against the sha256 pins in build.ncl. Needs network | ||
| access to registry.npmjs.org and an authenticated `gh` (for llama-brand, which | ||
| the lock resolves from GitHub rather than npm). Nothing downloaded is executed |
There was a problem hiding this comment.
nit · The usage text says the script needs an authenticated gh for llama-brand. The script never calls gh. git_files fetches the pinned commit with plain git fetch over https. The person who runs the next bump reads this and sets up a tool the script does not use. Say git and network access to github.com.
| (b) You may distribute such Executable Form under the terms of this | ||
| License, or sublicense it under different terms, provided that the | ||
| license for the Executable Form does not attempt to limit or alter | ||
| the recipients' rights in the Source Code Form under this Licens |
There was a problem hiding this comment.
nit · build.ncl declares the marks as LicenseRef-llama-brand, and the PR body says the notices file names that id next to both texts. The llama-brand section and the count table in the header both say CC-BY-NC-4.0. Only the header paragraph names the LicenseRef. A reader who goes to the section sees the non-commercial license alone. The generator can print License: LicenseRef-llama-brand (CC-BY-NC-4.0 plus BRAND-USAGE.md) for this package.
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. It is declared inlicense_spdxasLicenseRef-llama-brand(CC-BY-NC-4.0 plus that grant; no SPDX id covers the pair), so an SBOM or license scan sees the marks' terms; the notices file names the LicenseRef next to both texts. Decided by Bryan, 2026-11-18.f055406…, which pins them by hash.Follow-up
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