Skip to content

Replace the AGPL compress script with a GPLv3 one - #31

Open
zfouts wants to merge 1 commit into
n30nex:codex/split-assets-20261129from
zfouts:chore/precompress-gpl
Open

zfouts wants to merge 1 commit into
n30nex:codex/split-assets-20261129from
zfouts:chore/precompress-gpl

Conversation

@zfouts

@zfouts zfouts commented Dec 1, 2026

Copy link
Copy Markdown

For Kpa-clawbot#2512. This replaces scripts/static/beacon/compress-assets.mjs and its AGPL-3.0 LICENSE with scripts/static/precompress.js, written for CoreScope under the repo's GPLv3. The repo then carries no AGPL file, and nothing else in Kpa-clawbot#2512 changes.

What changes

  • scripts/static/precompress.js (new): walks the packaged tree and writes .br and .gz copies beside each text file. It uses the same nine extensions, Brotli at max quality in text mode, gzip at level 9, and only keeps a copy that is smaller.
  • scripts/static/build.sh: the PRECOMPRESS step calls the new script. Dockerfile.web and docker/web/Caddyfile are untouched.
  • scripts/static/beacon/ is removed.
  • tests/unit/test-static-build.js: the precompression test also checks that a second packaging gives identical copies and that gzip carries no mtime. A new test fails if any file under scripts/static is AGPL-licensed.

The new script was written after reading the original, so this is a rewrite rather than a clean-room one. The work is a handful of Node zlib calls, and the code is structured differently (synchronous, its own directory walk, CommonJS).

Testing

  • On a full packaging of public/, the old and new scripts produce byte-identical trees (diff -r, 132 .br + 132 .gz).
  • node tests/unit/test-static-build.js: 34 passed. node tests/unit/test-web-container.js: 10 passed.
  • With the old LICENSE put back, the new AGPL test fails, as intended.
  • I built Dockerfile.web and ran the image. For /app.js, Caddy answers Content-Encoding: br, gzip or identity depending on Accept-Encoding, with Vary: Accept-Encoding and the right Content-Type. Both compressed bodies decode to the exact identity body.

Merging this into codex/split-assets-20261129 updates Kpa-clawbot#2512.

🤖 Generated with Claude Code

scripts/static/beacon/compress-assets.mjs and its AGPL-3.0 LICENSE are
replaced by scripts/static/precompress.js, written for this repo under
its GPLv3 licence. Behaviour is unchanged: the same nine text
extensions, Brotli at max quality in text mode and gzip at level 9,
and a copy only when it is smaller. On a full packaging of public/ the
two scripts produce byte-identical trees (132 .br + 132 .gz).

build.sh calls the new script; Dockerfile.web and the Caddyfile are
untouched. test-static-build.js now also checks that a second
packaging gives identical copies, that gzip carries no mtime, and that
nothing under scripts/static is AGPL-licensed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qodo-code-review

qodo-code-review Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Replace AGPL asset compress script with GPLv3 precompress.js

✨ Enhancement ⚙️ Configuration changes 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Replaces the AGPL-3.0 compress-assets.mjs and its LICENSE with a new GPLv3
 scripts/static/precompress.js.
• build.sh now calls the new script. Brotli and gzip output is meant to match the old script byte
 for byte.
• Adds tests for reproducible output (no gzip mtime) and a guard that fails if any AGPL text appears
 under scripts/static.
Merge Risk 🟢 Low

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The changed behavior packages and supplies compressed representations of the same static web assets consumed by the web server.
  • The build invocation, generated sidecars, and Caddy consumer form one bounded static-delivery capability; API and WebSocket proxying are outside this path.
Sources

scripts/static/build.sh[154-156]

if [ "${PRECOMPRESS:-false}" = true ]; then
  node scripts/static/precompress.js "$OUT"
fi
Behavioral complexity 🟢 Low 🧩 Straightforward

  • Before, the build called a separate asynchronous compressor; after, it calls a synchronous recursive implementation that selects recognized extensions, compresses each file, and writes only smaller sidecars.
  • The changed correctness conditions are preserving original bytes, matching each sidecar to its source, recursively covering packaged files, and skipping non-beneficial outputs.
  • These are direct rules using the existing zlib compression primitives, without new concurrency, persistence, compatibility protocol, or cross-capability invariant.
Potential damage 🟡 Medium 🩹 Recoverable

  • If precompression regresses while packaging succeeds, compressed sidecars may be absent or unusable, but Caddy still has original-file and on-demand compression paths.
  • A build-time exception would require rebuilding or reverting the image, not data repair.
  • Rebuild or revert restores the packaging behavior; no persistent application state or external customer effect requires repair.
Assessed commit c6ecce3
Diagram

graph TD
  A["build.sh"] --> B["precompress.js"] --> C["packaged tree .br/.gz"] --> D["Caddy precompressed"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Clean-room rewrite with documented provenance
  • ➕ Gives a defensible GPLv3 position if the original's license is the concern
  • ➕ Keeps the same output without copying structure
  • ➖ Requires someone who has not read the AGPL file to write the code
  • ➖ More effort for a few zlib calls
2. Use an existing package or Caddy's own on-the-fly encoding
  • ➕ No custom packaging script to maintain or license
  • ➕ Caddy's encode directive already handles gzip and br
  • ➖ Loses precomputed max-quality brotli, which is the reason the script exists
  • ➖ Changes the image and runtime configuration
3. Keep the AGPL script and relicense the repo or the build tooling
  • ➕ No rewrite, so no provenance question
  • ➕ Output stays identical
  • ➖ Puts AGPL code in a GPLv3 repo, which the PR is trying to avoid
  • ➖ Relicensing needs the upstream authors' consent

Recommendation: The PR's approach (replace the file and check the result against the old tool's output) is sound and well verified. The open issue is provenance. The new file follows the original closely: the same nine-extension list, the same Brotli and gzip parameters, the same size-check rule, and similar comments. A derivative of AGPL code is not automatically GPLv3 just because it is rewritten. Get a licensing review, or do a clean-room rewrite, before merging. Also, the claim that behaviour is unchanged is slightly off: the new script lowercases extensions, so FOO.JS is now compressed, while the old regex was case-sensitive.

Files changed (3) +85 / -1

Enhancement (1) +63 / -0
precompress.jsNew synchronous CommonJS precompression script +63/-0

New synchronous CommonJS precompression script

• Walks the packaged tree for nine text extensions and writes .br (max quality, text mode) and .gz (level 9) beside each file. A copy is written only when it is smaller than the original. Output is reproducible because gzip has no mtime or file name. Files are handled one at a time.

scripts/static/precompress.js

Tests (1) +21 / -0
test-static-build.jsAdds reproducibility and AGPL-guard tests +21/-0

Adds reproducibility and AGPL-guard tests

• Extends the precompression test to check that a second packaging gives identical .br and .gz bytes and that gzip mtime is zero. Adds a test that fails if any file under scripts/static contains AFFERO or AGPL- text.

tests/unit/test-static-build.js

Other (1) +1 / -1
build.shPRECOMPRESS step calls the new script +1/-1

PRECOMPRESS step calls the new script

• Swaps the node invocation from the removed beacon/compress-assets.mjs to scripts/static/precompress.js. Nothing else in the build changes.

scripts/static/build.sh

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can pick a display mode instead of tweaking every Display option by hand

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

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