|
| 1 | +#!/usr/bin/env bash |
| 2 | +# SPDX-License-Identifier: MPL-2.0 |
| 3 | +# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk> |
| 4 | +# |
| 5 | +# registry-readiness.sh — make a Julia package honest for the General registry. |
| 6 | +# |
| 7 | +# Encodes the owner-approved remediation applied to Axiom.jl (#18) and |
| 8 | +# AcceleratorGate.jl (#8): resolve the PMPL/MPL-2.0 dual-license |
| 9 | +# contradiction to a single OSI licence (MPL-2.0) with REUSE compliance, |
| 10 | +# remove LLM-tell scaffolding, and SANITY-CHECK (not auto-edit) the |
| 11 | +# Project.toml for fabricated dependency UUIDs. |
| 12 | +# |
| 13 | +# Principles (the whole point — do not violate): |
| 14 | +# * No fabrication. Ambiguous things are REPORTED, never invented. |
| 15 | +# * Non-destructive beyond the known-safe set below. |
| 16 | +# * Idempotent. Run it twice → same result. |
| 17 | +# * Run it ON A BRANCH; it does not commit or push. |
| 18 | +# |
| 19 | +# Usage: cd <repo> && git switch -c cleanup/registry-readiness && \ |
| 20 | +# bash /path/to/standards/scripts/registry-readiness.sh |
| 21 | +# |
| 22 | +set -euo pipefail |
| 23 | +RED=$'\033[31m'; GRN=$'\033[32m'; YEL=$'\033[33m'; NC=$'\033[0m' |
| 24 | +say() { printf '%s\n' "$*"; } |
| 25 | +ok() { printf '%s✓%s %s\n' "$GRN" "$NC" "$*"; } |
| 26 | +warn(){ printf '%s!%s %s\n' "$YEL" "$NC" "$*"; } |
| 27 | +flag(){ printf '%s⚠ NEEDS HUMAN%s %s\n' "$RED" "$NC" "$*"; } |
| 28 | + |
| 29 | +[ -d .git ] || { echo "not a git repo"; exit 1; } |
| 30 | +[ -f Project.toml ] || warn "no Project.toml — not a Julia package? continuing anyway" |
| 31 | + |
| 32 | +say "== 1. Licensing → MPL-2.0 (REUSE) ==" |
| 33 | +if grep -rlq "PMPL-1.0-or-later" $(git ls-files) 2>/dev/null; then |
| 34 | + # 1a. SPDX identifiers + the dual-license contradiction comment |
| 35 | + git ls-files -z | xargs -0 grep -lZ "PMPL-1.0-or-later" 2>/dev/null | xargs -0 -r sed -i \ |
| 36 | + -e 's|SPDX-License-Identifier: PMPL-1.0-or-later|SPDX-License-Identifier: MPL-2.0|g' \ |
| 37 | + -e '/(PMPL-1\.0-or-later preferred; MPL-2\.0 required for Julia ecosystem)/d' |
| 38 | + # 1b. canonical LICENSE from the bundled MPL text (do NOT fabricate licence text) |
| 39 | + if [ -f LICENSES/MPL-2.0.txt ]; then |
| 40 | + { echo "SPDX-License-Identifier: MPL-2.0" |
| 41 | + echo "SPDX-FileCopyrightText: 2024-2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>" |
| 42 | + echo; cat LICENSES/MPL-2.0.txt; } > LICENSE |
| 43 | + ok "LICENSE rebuilt from LICENSES/MPL-2.0.txt" |
| 44 | + else |
| 45 | + flag "LICENSES/MPL-2.0.txt absent — cannot rebuild LICENSE without fabricating licence text. Fix by hand." |
| 46 | + fi |
| 47 | + rm -f LICENSES/PMPL-1.0-or-later.txt; git rm -q --cached LICENSES/PMPL-1.0-or-later.txt 2>/dev/null || true |
| 48 | + printf 'version = 1\n\n[[annotations]]\npath = "**"\nprecedence = "aggregate"\nSPDX-FileCopyrightText = "2024-2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>"\nSPDX-License-Identifier = "MPL-2.0"\n' > REUSE.toml |
| 49 | + ok "SPDX headers → MPL-2.0; REUSE.toml written" |
| 50 | + # 1c. broad SAFE prose normalisation — every one of these is a licence |
| 51 | + # reference that must now read MPL-2.0; none changes meaning. |
| 52 | + git ls-files -z | xargs -0 grep -lZ "PMPL\|Palimpsest" 2>/dev/null | xargs -0 -r sed -i \ |
| 53 | + -e 's/PMPL-1\.0-or-later/MPL-2.0/g' \ |
| 54 | + -e 's/Palimpsest License (MPL-2.0)/Mozilla Public License 2.0/g' \ |
| 55 | + -e 's/Palimpsest License/Mozilla Public License 2.0/g' \ |
| 56 | + -e 's/the Palimpsest/the Mozilla Public License 2.0/g' \ |
| 57 | + -e 's/Palimpsest/Mozilla Public License 2.0/g' \ |
| 58 | + -e 's#https://github.com/hyperpolymath/palimpsest-license#https://www.mozilla.org/MPL/2.0/#g' \ |
| 59 | + -e 's/License-PMPL--1\.0-blue/License-MPL--2.0-blue/g' \ |
| 60 | + -e 's/license = with licenses; \[ mit \];.*/license = with licenses; [ mpl20 ]; # MPL-2.0/' \ |
| 61 | + -e 's/"Add PMPL-1\.0 license"/"Add MPL-2.0 license"/g' \ |
| 62 | + -e "s/'SPDX\\\\|License\\\\|MIT\\\\|Apache\\\\|PMPL\\\\|MPL'/'SPDX\\\\|License\\\\|MIT\\\\|Apache\\\\|MPL'/g" \ |
| 63 | + -e "s/'PMPL\\\\|MPL\\\\|MIT\\\\|Apache\\\\|LGPL'/'MPL\\\\|MIT\\\\|Apache\\\\|LGPL'/g" \ |
| 64 | + -e '/preserve Emotional Lineage per PMPL/d' \ |
| 65 | + -e '/automatic legal fallback until PMPL is formally recognised/d' \ |
| 66 | + -e '/^.*\bPMPL\b.*Section [0-9].*$/d' |
| 67 | + # 1c-bis. ROBUST SPDX normalisation. The broad prose pass can leave or |
| 68 | + # create non-canonical identifiers (`MPL-2.0 +` from `... +` tails, |
| 69 | + # pre-existing `MPL-2.0-or-later`, the `PLMP-1.0-or-later` typo). reuse |
| 70 | + # lint rejects these. Force every SPDX-License-Identifier value to the |
| 71 | + # single canonical `MPL-2.0` (this is what makes `reuse lint` pass). |
| 72 | + git ls-files -z | xargs -0 -r sed -i -E \ |
| 73 | + -e 's/(SPDX-License-Identifier:) +MPL-2\.0 \+/\1 MPL-2.0/g' \ |
| 74 | + -e 's/(SPDX-License-Identifier:) +MPL-2\.0-or-later/\1 MPL-2.0/g' \ |
| 75 | + -e 's/(SPDX-License-Identifier:) +P[LM]MP-1\.0-or-later/\1 MPL-2.0/g' |
| 76 | + # 1d. canonical NOTICE (standard MPL-2.0 notice — not fabrication, the |
| 77 | + # generic form; replaces any bespoke PMPL paragraph deterministically) |
| 78 | + if [ -f NOTICE ]; then |
| 79 | + repo=$(basename "$(git rev-parse --show-toplevel)") |
| 80 | + cat > NOTICE <<EOF |
| 81 | +Licensing Notice |
| 82 | +================ |
| 83 | +
|
| 84 | +$repo is authored by Jonathan D.A. Jewell (hyperpolymath) |
| 85 | +<j.d.a.jewell@open.ac.uk> and is licensed under the Mozilla Public |
| 86 | +License 2.0 (MPL-2.0), an OSI-approved licence. |
| 87 | +
|
| 88 | +The full licence text is in LICENSE and LICENSES/MPL-2.0.txt. Per-file |
| 89 | +SPDX-License-Identifier headers and REUSE.toml record MPL-2.0 |
| 90 | +consistently across the repository (REUSE-compliant). |
| 91 | +EOF |
| 92 | + ok "NOTICE rewritten to canonical MPL-2.0 form" |
| 93 | + fi |
| 94 | + resid=$(git ls-files | xargs grep -l "PMPL\|Palimpsest" 2>/dev/null | grep -v '\.git/' || true) |
| 95 | + [ -n "$resid" ] && { warn "residual PMPL/Palimpsest refs still present:"; printf ' %s\n' $resid; } || ok "0 PMPL/Palimpsest refs remain" |
| 96 | + [ -f README.adoc ] || [ -f README.md ] && flag "README: verify it has purpose + a run-verified usage example + prior-art (goerz/DilumAluthge asked) — content-specific, not auto-generated" |
| 97 | +else |
| 98 | + ok "no PMPL references" |
| 99 | +fi |
| 100 | +command -v reuse >/dev/null 2>&1 && { reuse lint >/dev/null 2>&1 && ok "reuse lint passes" || warn "reuse lint not clean — run 'reuse lint' and inspect"; } || warn "reuse CLI not installed (pipx install reuse)" |
| 101 | + |
| 102 | +say "== 2. De-LLM the package face ==" |
| 103 | +for f in 0-AI-MANIFEST.a2ml llm-warmup-dev.md llm-warmup-user.md; do |
| 104 | + [ -e "$f" ] && { git rm -q "$f" 2>/dev/null || rm -f "$f"; ok "removed $f"; } |
| 105 | +done |
| 106 | +[ -e EXPLAINME.adoc ] && flag "EXPLAINME.adoc present — do NOT auto-delete; rewrite to verified truth or remove by decision" |
| 107 | + |
| 108 | +say "== 3. Project.toml manifest sanity (REPORT ONLY — never auto-edit deps) ==" |
| 109 | +if [ -f Project.toml ]; then |
| 110 | + if grep -qE '"([0-9])\1{7}-' Project.toml; then |
| 111 | + flag "fabricated sequential-dummy weakdep UUIDs in Project.toml — remove the phantom deps+extensions by hand (see Axiom.jl#18)" |
| 112 | + else ok "no obvious fabricated UUIDs"; fi |
| 113 | + grep -q '^license *= *"MPL-2.0"' Project.toml && ok 'Project.toml license = "MPL-2.0"' \ |
| 114 | + || flag "Project.toml license is not MPL-2.0 — set it" |
| 115 | +fi |
| 116 | + |
| 117 | +say "== 4. Tests (authoritative — paste real result) ==" |
| 118 | +if [ -f Project.toml ] && command -v julia >/dev/null 2>&1; then |
| 119 | + if timeout 560 julia --project=. -e 'using Pkg; Pkg.test()' 2>&1 | tee /tmp/rr_test.$$ | tail -3; then |
| 120 | + grep -q "Testing .* tests passed" /tmp/rr_test.$$ && ok "Pkg.test() passed" || flag "Pkg.test() did NOT pass — inspect /tmp/rr_test.$$" |
| 121 | + else flag "Pkg.test() errored — inspect /tmp/rr_test.$$"; fi |
| 122 | +else warn "skipped tests (no Project.toml or julia)"; fi |
| 123 | + |
| 124 | +say "${GRN}== registry-readiness pass complete — review, then commit on this branch ==${NC}" |
0 commit comments