57 lines
2 KiB
Bash
Executable file
57 lines
2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# =============================================================================
|
|
# scripts/lint-genomes.sh
|
|
# Executes quality control across all registered genomes.
|
|
# Iterates from the GENOMES registry in registry.sh — not from filesystem patterns —
|
|
# so all genomes are covered regardless of their naming convention.
|
|
# =============================================================================
|
|
|
|
set -euo pipefail
|
|
source "lib/output.sh"
|
|
source "globals.env"
|
|
source "registry.sh"
|
|
source "lib/lint.sh"
|
|
|
|
step "Starting Knowledge Genome Linting"
|
|
|
|
TOTAL_ERRORS=0
|
|
TOTAL_STALE=0
|
|
|
|
for entry in "${GENOMES[@]}"; do
|
|
IFS='|' read -r GENOME_NAME _ <<< "$entry"
|
|
genome_dir="${WORK_DIR}/${MASTER_REPO}/${GENOME_NAME}"
|
|
|
|
if [[ ! -d "$genome_dir" ]]; then
|
|
warn "Genome directory not found locally, skipping: ${genome_dir}"
|
|
continue
|
|
fi
|
|
|
|
info "Auditing genome: ${GENOME_NAME}..."
|
|
|
|
# Lint all .md files except AGENTS.md and core-karpathy reference
|
|
while IFS= read -r md_file; do
|
|
|
|
lint_markdown_file "$md_file" "$GENOME_NAME" && fe=0 || fe=$?
|
|
check_privacy_consistency "$md_file" && pce=0 || pce=$?
|
|
check_page_size "$md_file" && pse=0 || pse=$?
|
|
TOTAL_ERRORS=$((TOTAL_ERRORS + fe + pce + pse))
|
|
|
|
check_knowledge_decay "$md_file" && stale=0 || stale=$?
|
|
TOTAL_STALE=$((TOTAL_STALE + stale))
|
|
|
|
check_broken_links "$md_file" || true # warnings only, never contributes to errors
|
|
|
|
done < <(find "$genome_dir" -name "*.md" \
|
|
! -name "AGENTS.md" \
|
|
! -path "*/core-karpathy/*")
|
|
done
|
|
|
|
echo ""
|
|
if [[ $TOTAL_ERRORS -eq 0 && $TOTAL_STALE -eq 0 ]]; then
|
|
success "Linting passed: all files are consistent, secure, and current."
|
|
elif [[ $TOTAL_ERRORS -eq 0 && $TOTAL_STALE -gt 0 ]]; then
|
|
warn "Linting passed with ${TOTAL_STALE} stale file(s). Review and re-validate flagged pages."
|
|
else
|
|
error "Linting failed: ${TOTAL_ERRORS} critical issue(s), ${TOTAL_STALE} stale file(s)."
|
|
exit 1
|
|
fi
|