Skip to content

Commit 8378a43

Browse files
hyperpolymathclaude
andcommitted
Add fix scripts for workflow hygiene and license hygiene
- fix-workflow-hygiene.sh: removes irrelevant CI workflows detected by Hypatia's scan_workflow_hygiene (ts-blocker, npm-blocker, etc.) - fix-license-hygiene.sh: applies REUSE-compliant dual-license setup (MPL-2.0 LICENSE + LICENSES/ dir + NOTICE) - Updated fix-script-registry.json with new category and recipe mappings Both scripts are idempotent and follow the standard finding JSON input format for the dispatch-runner pipeline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c6f5d4d commit 8378a43

3 files changed

Lines changed: 194 additions & 2 deletions

File tree

scripts/fix-license-hygiene.sh

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: PMPL-1.0-or-later
3+
# fix-license-hygiene.sh — Ensure REUSE-compliant dual-license setup
4+
#
5+
# Applies: LICENSE (MPL-2.0), LICENSES/ dir, NOTICE file
6+
# Idempotent: only modifies what's missing or incorrect.
7+
#
8+
# Requires canonical templates at:
9+
# /var/mnt/eclipse/repos/palimpsest-license/legal/MPL-2.0.txt
10+
# /var/mnt/eclipse/repos/palimpsest-license/legal/PALIMPSEST-MPL-1.0.txt
11+
set -euo pipefail
12+
13+
FINDING_FILE="${1:?Usage: fix-license-hygiene.sh <finding.json>}"
14+
15+
if [[ ! -f "$FINDING_FILE" ]]; then
16+
echo "ERROR: Finding file not found: $FINDING_FILE" >&2
17+
exit 1
18+
fi
19+
20+
PATTERN=$(jq -r '.pattern' "$FINDING_FILE")
21+
FILE=$(jq -r '.file' "$FINDING_FILE")
22+
23+
# Determine repo root
24+
if [[ -d "$FILE" ]]; then
25+
REPO_DIR="$FILE"
26+
elif [[ -f "$FILE" ]]; then
27+
REPO_DIR=$(git -C "$(dirname "$FILE")" rev-parse --show-toplevel 2>/dev/null || echo "")
28+
else
29+
REPO_DIR=$(echo "$FILE" | sed 's|/LICENSE$||; s|/LICENSES.*||; s|/NOTICE$||')
30+
fi
31+
32+
if [[ -z "$REPO_DIR" || ! -d "$REPO_DIR/.git" ]]; then
33+
echo "ERROR: Cannot determine git repo root" >&2
34+
exit 1
35+
fi
36+
37+
cd "$REPO_DIR"
38+
39+
# Template sources
40+
PALIMPSEST_REPO="/var/mnt/eclipse/repos/palimpsest-license"
41+
MPL2_SRC="$PALIMPSEST_REPO/legal/MPL-2.0.txt"
42+
PMPL_SRC="$PALIMPSEST_REPO/legal/PALIMPSEST-MPL-1.0.txt"
43+
44+
# Fallback to boj-server if palimpsest-license not available
45+
if [[ ! -f "$MPL2_SRC" ]]; then
46+
MPL2_SRC="/var/mnt/eclipse/repos/boj-server/LICENSE"
47+
fi
48+
49+
changes=false
50+
51+
case "$PATTERN" in
52+
license_not_mpl2|missing_license_file)
53+
if [[ -f "$MPL2_SRC" ]]; then
54+
cp "$MPL2_SRC" LICENSE
55+
git add LICENSE
56+
changes=true
57+
fi
58+
;;
59+
missing_licenses_dir|missing_pmpl_text)
60+
mkdir -p LICENSES
61+
[[ -f "$MPL2_SRC" && ! -f LICENSES/MPL-2.0.txt ]] && cp "$MPL2_SRC" LICENSES/MPL-2.0.txt
62+
[[ -f "$PMPL_SRC" && ! -f LICENSES/PMPL-1.0-or-later.txt ]] && cp "$PMPL_SRC" LICENSES/PMPL-1.0-or-later.txt
63+
git add LICENSES/
64+
changes=true
65+
;;
66+
missing_notice)
67+
if [[ ! -f NOTICE ]]; then
68+
cat > NOTICE << 'NOTICEEOF'
69+
Licensing Notice
70+
================
71+
72+
This project is authored by Jonathan D.A. Jewell (hyperpolymath) and
73+
is licensed under the Palimpsest License (PMPL-1.0-or-later).
74+
75+
The PMPL-1.0-or-later is a philosophical extension of the Mozilla Public
76+
License 2.0, adding provisions for cryptographic provenance, emotional
77+
lineage preservation, and quantum-safe signatures. The full PMPL text is
78+
available in LICENSES/PMPL-1.0-or-later.txt.
79+
80+
For compatibility with automated license detection tools and platforms
81+
that require OSI-approved licenses, the root LICENSE file contains the
82+
standard Mozilla Public License 2.0 text. This ensures that package
83+
registries, CI systems, and other tooling correctly identify the license.
84+
85+
The legally binding terms are:
86+
- Source files: governed by PMPL-1.0-or-later (per SPDX headers)
87+
- Combined works: compatible with MPL-2.0 (per PMPL Section 6)
88+
89+
For more information about the Palimpsest License:
90+
https://github.com/hyperpolymath/palimpsest-license
91+
NOTICEEOF
92+
git add NOTICE
93+
changes=true
94+
fi
95+
;;
96+
*)
97+
echo "SKIP: Pattern '$PATTERN' not handled by fix-license-hygiene.sh" >&2
98+
exit 0
99+
;;
100+
esac
101+
102+
if [[ "$changes" == true ]] && ! git diff --cached --quiet; then
103+
git commit -m "$(cat <<EOF
104+
Fix license hygiene: $PATTERN
105+
106+
Applied REUSE-compliant dual-license setup (MPL-2.0 for machine
107+
detection + PMPL-1.0-or-later as governing license).
108+
109+
Co-Authored-By: Hypatia Scanner <hypatia@reposystem.dev>
110+
EOF
111+
)"
112+
echo "OK: Fixed $PATTERN in $(basename "$REPO_DIR")"
113+
else
114+
echo "OK: No changes needed (idempotent)"
115+
fi

scripts/fix-script-registry.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"PathTraversal": "fix-tmp-paths.sh",
3636
"TodoMarkers": "fix-todo-markers.sh",
3737
"BelieveMe": "fix-believe-me.sh",
38-
"WorkflowHygiene": "fix-workflow-hygiene.sh"
38+
"WorkflowHygiene": "fix-workflow-hygiene.sh",
39+
"LicenseHygiene": "fix-license-hygiene.sh"
3940
},
4041
"by_recipe": {
4142
"recipe-heredoc-to-install": "fix-heredoc-install.sh",
@@ -75,7 +76,9 @@
7576
"synthetic-eliminate-AtomExhaustion": "fix-atom-exhaustion.sh",
7677
"synthetic-eliminate-UnsafeTypeCoercion": "fix-unsafe-type-coercion.sh",
7778
"recipe-workflow-hygiene": "fix-workflow-hygiene.sh",
78-
"recipe-remove-irrelevant-workflow": "fix-workflow-hygiene.sh"
79+
"recipe-remove-irrelevant-workflow": "fix-workflow-hygiene.sh",
80+
"recipe-license-hygiene": "fix-license-hygiene.sh",
81+
"recipe-reuse-dual-license": "fix-license-hygiene.sh"
7982
}
8083
}
8184
}

scripts/fix-workflow-hygiene.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: PMPL-1.0-or-later
3+
# fix-workflow-hygiene.sh — Remove irrelevant CI workflows detected by Hypatia
4+
#
5+
# Accepts a finding JSON file. Reads the pattern ID and file path, then
6+
# removes the irrelevant workflow file. Idempotent: no-op if file already gone.
7+
#
8+
# Patterns handled:
9+
# irrelevant_ts_blocker, irrelevant_npm_blocker, irrelevant_jekyll,
10+
# irrelevant_guix_nix, irrelevant_wellknown, irrelevant_rsr_antipattern,
11+
# redundant_scorecard_enforcer, redundant_instant_sync,
12+
# redundant_security_policy_wf, unnecessary_workflow_linter
13+
set -euo pipefail
14+
15+
FINDING_FILE="${1:?Usage: fix-workflow-hygiene.sh <finding.json>}"
16+
17+
if [[ ! -f "$FINDING_FILE" ]]; then
18+
echo "ERROR: Finding file not found: $FINDING_FILE" >&2
19+
exit 1
20+
fi
21+
22+
PATTERN=$(jq -r '.pattern' "$FINDING_FILE")
23+
FILE=$(jq -r '.file' "$FINDING_FILE")
24+
25+
# Validate this is a workflow hygiene finding we can handle
26+
case "$PATTERN" in
27+
irrelevant_ts_blocker|irrelevant_npm_blocker|irrelevant_jekyll|\
28+
irrelevant_guix_nix|irrelevant_wellknown|irrelevant_rsr_antipattern|\
29+
redundant_scorecard_enforcer|redundant_instant_sync|\
30+
redundant_security_policy_wf|unnecessary_workflow_linter)
31+
;;
32+
*)
33+
echo "SKIP: Pattern '$PATTERN' not handled by fix-workflow-hygiene.sh" >&2
34+
exit 0
35+
;;
36+
esac
37+
38+
# Idempotent: if file already removed, nothing to do
39+
if [[ ! -f "$FILE" ]]; then
40+
echo "OK: $FILE already removed (idempotent)"
41+
exit 0
42+
fi
43+
44+
WF_NAME=$(basename "$FILE")
45+
REPO_DIR=$(git -C "$(dirname "$FILE")" rev-parse --show-toplevel 2>/dev/null || echo "")
46+
47+
if [[ -z "$REPO_DIR" ]]; then
48+
echo "ERROR: Cannot determine git repo root for $FILE" >&2
49+
exit 1
50+
fi
51+
52+
# Remove the workflow
53+
rm "$FILE"
54+
55+
# Stage and commit
56+
cd "$REPO_DIR"
57+
git add "$FILE"
58+
59+
# Only commit if there are staged changes
60+
if ! git diff --cached --quiet; then
61+
git commit -m "$(cat <<EOF
62+
Remove irrelevant workflow: $WF_NAME
63+
64+
Hypatia detected $WF_NAME as irrelevant to this repository's
65+
technology stack (pattern: $PATTERN). Removing to reduce CI noise
66+
and GitHub Actions minutes waste.
67+
68+
Co-Authored-By: Hypatia Scanner <hypatia@reposystem.dev>
69+
EOF
70+
)"
71+
echo "OK: Removed $WF_NAME from $(basename "$REPO_DIR")"
72+
else
73+
echo "OK: No staged changes (already clean)"
74+
fi

0 commit comments

Comments
 (0)