Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/actions/affirmation-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Affirmation Document Gate'
description: 'Validates an applicable AFFIRMATION snapshot without treating it as a universal or self-proving document.'
inputs:
required:
description: 'Set true only when the repository declares the governance-tier capability.'
required: false
default: 'false'
runs:
using: 'composite'
steps:
- name: Run Affirmation Check
shell: bash
env:
AFFIRMATION_REQUIRED: ${{ inputs.required }}
run: "${{ github.action_path }}/check.sh"
70 changes: 70 additions & 0 deletions .github/actions/affirmation-check/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0

set -euo pipefail

root=${GITHUB_WORKSPACE:-.}
required=${AFFIRMATION_REQUIRED:-false}
aff_file=

for candidate in AFFIRMATION.adoc AFFIRMATION.md AFFIRMATION; do
if [[ -f "$root/$candidate" ]]; then
aff_file=$candidate
break
fi
done

if [[ -z "$aff_file" ]]; then
if [[ "$required" == "true" ]]; then
echo "::error::AFFIRMATION.adoc is required by the declared governance-tier capability."
exit 1
fi
echo "::notice::AFFIRMATION is not applicable: governance-tier was not required."
exit 0
fi

path=$root/$aff_file
echo "Found AFFIRMATION document: $aff_file"

substantive_lines=$(awk '!/^[[:space:]]*(#|\/\/|;|$)/ { count++ } END { print count + 0 }' "$path")
if (( substantive_lines < 5 )); then
echo "::error::$aff_file has only $substantive_lines substantive lines; it is a stub, not an affirmation."
exit 1
fi

if grep -qiE '\{\{|TODO: update|<PROJECT|YOUR_PROJECT|lorem ipsum|example\.com' "$path"; then
echo "::error::$aff_file contains template placeholders."
exit 1
fi

# The signature is the signature on the commit containing this content. Text
# such as "Signed:" inside the document proves nothing. Shallow checkouts may
# not contain the file-changing commit, so report that limitation honestly.
signature=N
last_update_ts=
if git -C "$root" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
signature=$(git -C "$root" log -1 --format='%G?' -- "$aff_file" 2>/dev/null || true)
last_update_ts=$(git -C "$root" log -1 --format='%at' -- "$aff_file" 2>/dev/null || true)
fi

case "$signature" in
G) echo "Affirmation commit signature verified with a trusted key." ;;
U) echo "::notice::Affirmation commit has a valid signature from an untrusted or locally unknown key." ;;
B|R|E) echo "::error::Affirmation commit signature is bad, revoked, or failed verification."; exit 1 ;;
*) echo "::notice::Affirmation commit signature could not be verified from the available Git history." ;;
esac

# A dated affirmation is a frozen receipt, not a claim that remains current
# forever. Report age without invalidating historical evidence or forcing an
# empty monthly rewrite.
if [[ -n "$last_update_ts" ]]; then
current_ts=$(date +%s)
age_days=$(( (current_ts - last_update_ts) / 86400 ))
if (( age_days > 28 )); then
echo "::warning::$aff_file is a $age_days-day-old snapshot; verify its anchor before relying on it as current."
else
echo "$aff_file snapshot age: $age_days days."
fi
fi

echo "AFFIRMATION document validation passed."
33 changes: 33 additions & 0 deletions .github/actions/affirmation-check/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0

set -euo pipefail

here=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
fixture=$(mktemp -d)
trap 'rm -rf -- "$fixture"' EXIT

GITHUB_WORKSPACE=$fixture AFFIRMATION_REQUIRED=false "$here/check.sh"

if GITHUB_WORKSPACE=$fixture AFFIRMATION_REQUIRED=true "$here/check.sh"; then
echo "required-but-absent affirmation unexpectedly passed" >&2
exit 1
fi

printf '= AFFIRMATION\n' > "$fixture/AFFIRMATION.adoc"
if GITHUB_WORKSPACE=$fixture AFFIRMATION_REQUIRED=true "$here/check.sh"; then
echo "stub affirmation unexpectedly passed" >&2
exit 1
fi

printf '%s\n' \
'= AFFIRMATION — controlled fixture' \
'This snapshot makes a falsifiable claim.' \
'The claim is anchored to a named revision.' \
'Tests were run and their scope is stated.' \
'Unproved properties are not called proved.' \
'Later revisions must be assessed separately.' \
> "$fixture/AFFIRMATION.adoc"
GITHUB_WORKSPACE=$fixture AFFIRMATION_REQUIRED=true "$here/check.sh"

echo 'affirmation-check controls passed'
35 changes: 35 additions & 0 deletions .github/actions/badges-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'Accreditations & Badges Gate'
description: 'Validates presence, standing, and non-drift of accreditations and badges (GLAMA, Greenweb, OpenSSF, RSR, etc.).'
runs:
using: 'composite'
steps:
- name: Run Badges and Accreditations Check
shell: bash
run: |
echo "Validating Accreditations and Badges..."
README="README.adoc"
[ -f "README.md" ] && README="README.md"

if [ ! -f "$README" ]; then
echo "::warning::No README found to check badges."
exit 0
fi

# Check for core badges
for badge in "GLAMA" "Greenweb" "OpenSSF" "License"; do
if ! grep -qi "$badge" "$README"; then
echo "::warning::Missing $badge badge in $README. Check standing and display."
fi
done

# Check Idris Inside / RSR compliance
if [ -d "src" ] || ls *.ipkg 1>/dev/null 2>] || ls *.ipkg 1>/dev/null 2>&11; then
Comment thread
hyperpolymath marked this conversation as resolved.
Resolved
if ! grep -qi "Idris Inside" "$README"; then
echo "::warning::Idris source detected but 'Idris Inside' badge is missing."
fi
if ! grep -qi "RSR" "$README"; then
echo "::warning::Missing RSR-compliant badge in Idris repository."
fi
fi

echo "Badges and Accreditations validation complete."
15 changes: 15 additions & 0 deletions .github/actions/boj-cartridge-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'BoJ Cartridge Gate'
description: 'Checks for a BoJ cartridge when BoJ integration is applicable.'
inputs:
required:
description: 'Set true when this repository declares BoJ integration.'
required: false
default: 'false'
runs:
using: 'composite'
steps:
- name: Run BoJ Cartridge Check
shell: bash
env:
BOJ_CARTRIDGE_REQUIRED: ${{ inputs.required }}
run: "${{ github.action_path }}/check.sh"
29 changes: 29 additions & 0 deletions .github/actions/boj-cartridge-check/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0

set -euo pipefail

root=${GITHUB_WORKSPACE:-.}
required=${BOJ_CARTRIDGE_REQUIRED:-false}
found=

for candidate in cartridge.json cartridge.yml cartridge.yaml; do
if [[ -f "$root/$candidate" ]]; then
found=$candidate
break
fi
done
if [[ -z "$found" && -d "$root/.cartridges" ]]; then
found=.cartridges/
fi

if [[ -z "$found" ]]; then
if [[ "$required" == "true" ]]; then
echo '::error::A BoJ cartridge is required but no canonical cartridge path exists.'
exit 1
fi
echo '::notice::BoJ cartridge is not applicable to this repository.'
exit 0
fi

echo "BoJ cartridge present at $found."
20 changes: 20 additions & 0 deletions .github/actions/boj-cartridge-check/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0

set -euo pipefail

here=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
fixture=$(mktemp -d)
trap 'rm -rf -- "$fixture"' EXIT

GITHUB_WORKSPACE=$fixture BOJ_CARTRIDGE_REQUIRED=false "$here/check.sh"

if GITHUB_WORKSPACE=$fixture BOJ_CARTRIDGE_REQUIRED=true "$here/check.sh"; then
echo 'required-but-absent BoJ cartridge unexpectedly passed' >&2
exit 1
fi

printf '%s\n' '{"name":"controlled-fixture"}' > "$fixture/cartridge.json"
GITHUB_WORKSPACE=$fixture BOJ_CARTRIDGE_REQUIRED=true "$here/check.sh"

echo 'boj-cartridge-check controls passed'
8 changes: 8 additions & 0 deletions .github/actions/code-hygiene-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: 'Code Hygiene Check'
description: 'Fails on untracked debt markers in source, and on undeclared proof circumventions in proof code.'
runs:
using: 'composite'
steps:
- name: Run Hygiene Check
shell: bash
run: bash "$GITHUB_ACTION_PATH/check.sh"
81 changes: 81 additions & 0 deletions .github/actions/code-hygiene-check/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
# Distinguish untracked implementation debt from prose, templates, generated
# metadata, and issue-linked work. Proof circumventions remain a separate,
# stricter check over proof languages only.
set -uo pipefail
fail=0

readonly allow_file='.cicd-hygiene-allow'
allow_args=()
if [[ -f "$allow_file" ]]; then
echo "Using allowlist $allow_file:"
while IFS= read -r pat || [[ -n "$pat" ]]; do
case "$pat" in
''|'#'*) continue ;;
*)
echo " exclude: $pat"
allow_args+=(":(exclude)$pat")
;;
esac
done < "$allow_file"
fi

# The horizon is deliberately explicit. These are implementation-language
# files, wherever they occur in the tree. Documentation, workflows,
# machine-readable templates, packaging recipes, and container templates are
# not silently relabelled as application source.
exclude_paths=(
':(exclude).github/**' ':(exclude).githooks/**'
':(exclude).machine_readable/**' ':(exclude)docs/**'
':(exclude)packaging/**' ':(exclude)container/**'
":(exclude)$allow_file"
)

source_paths=(
'*.adb' '*.ads' '*.affine' '*.agda' '*.bash' '*.c' '*.cc' '*.clj' '*.cljs'
'*.cjs' '*.cpp' '*.cr' '*.cts' '*.cxx' '*.eph' '*.erl' '*.ex' '*.exs'
'*.fish' '*.fs'
'*.fsx' '*.gleam' '*.go' '*.h' '*.hh' '*.hpp' '*.hs' '*.idr' '*.java'
'*.js' '*.jsx' '*.kt' '*.kts' '*.lean' '*.lhs' '*.lua' '*.m' '*.mjs'
'*.ml' '*.mli' '*.mm' '*.mts' '*.nu'
'*.php' '*.pl' '*.pm' '*.py' '*.r' '*.rb' '*.res' '*.resi' '*.roc' '*.rs'
'*.scala' '*.sh' '*.sol' '*.sql' '*.swift' '*.thy' '*.ts' '*.tsx' '*.v'
'*.vala' '*.vapi' '*.zig'
"${exclude_paths[@]}"
)

echo 'Scanning implementation source for untracked debt markers...'
debt="$({ git grep --untracked -n -E -w 'TODO|FIXME|XXX|HACK|STUB' -- \
"${source_paths[@]}" "${allow_args[@]+"${allow_args[@]}"}" || true; } \
| perl -ne 'print if /:[0-9]+:.*\b(?:TODO|FIXME|XXX|HACK|STUB)\b(?!\(#[0-9]+\))/')"
if [[ -n "$debt" ]]; then
echo '::error::Untracked debt markers found in implementation source:' >&2
printf '%s\n' "$debt"
echo '::error::Resolve the debt or link it as MARKER(#issue).' >&2
fail=1
else
echo ' none.'
fi

echo 'Scanning proof code for undeclared circumventions...'
circ="$({ git grep --untracked -n -E -w 'sorry|believe_me|admit|postulate|assert_total' -- \
'*.idr' '*.lean' '*.v' '*.agda' '*.thy' \
"${exclude_paths[@]}" \
"${allow_args[@]+"${allow_args[@]}"}" || true; } \
| grep -vE ':[0-9]+:[[:space:]]*(\|\|\||--|//|\(\*)' || true)"
if [[ -n "$circ" ]]; then
echo '::error::Undeclared proof circumventions found:' >&2
printf '%s\n' "$circ"
echo "::error::If sanctioned, isolate the axioms, list the module in $allow_file," >&2
echo '::error::and enforce the exact count with a trusted-base check.' >&2
fail=1
else
echo ' none.'
fi

if [[ "$fail" -eq 1 ]]; then
echo '::error::Code hygiene gate failed.' >&2
exit 1
fi
echo 'Hygiene check passed.'
50 changes: 50 additions & 0 deletions .github/actions/code-hygiene-check/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
set -euo pipefail

checker="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/check.sh"
readonly checker
fixture="$(mktemp -d)"
trap 'rm -rf "$fixture"' EXIT
git -C "$fixture" init -q
git -C "$fixture" config user.email test@example.invalid
git -C "$fixture" config user.name 'Hygiene test'
mkdir -p "$fixture/src" "$fixture/docs" "$fixture/.github/workflows" \
"$fixture/.machine_readable/templates"

printf '%s\n' '// clean source' > "$fixture/src/main.rs"
printf '%s\n' 'TODO in documentation is explanatory.' > "$fixture/docs/design.md"
printf '%s\n' 'example = believe_me value' > "$fixture/docs/example.idr"
printf '%s\n' '// marker in the filename is not debt' > "$fixture/src/TODO.rs"
printf '%s\n' '# TODO: workflow follow-up' > "$fixture/.github/workflows/ci.yml"
printf '%s\n' 'TODO: fill this template' > "$fixture/.machine_readable/templates/example.ncl"
git -C "$fixture" add .
git -C "$fixture" commit -qm fixture

(cd "$fixture" && bash "$checker")

printf '%s\n' '// TODO: TypeScript implementation debt' > "$fixture/src/app.ts"
if (cd "$fixture" && bash "$checker"); then
echo 'FAIL: untracked TypeScript debt was accepted' >&2
exit 1
fi
printf '%s\n' '// clean TypeScript source' > "$fixture/src/app.ts"

printf '%s\n' '// TODO: untracked implementation debt' > "$fixture/src/main.rs"
if (cd "$fixture" && bash "$checker"); then
echo 'FAIL: untracked source debt was accepted' >&2
exit 1
fi

printf '%s\n' '// TODO(#123): tracked implementation debt' > "$fixture/src/main.rs"
(cd "$fixture" && bash "$checker")

printf '%s\n' 'proof = believe_me value' > "$fixture/src/Safety.idr"
if (cd "$fixture" && bash "$checker"); then
echo 'FAIL: proof circumvention was accepted' >&2
exit 1
fi

printf '%s' 'src/Safety.idr' > "$fixture/.cicd-hygiene-allow"
(cd "$fixture" && bash "$checker")
echo 'All code-hygiene positive and negative controls passed.'
Loading
Loading