feat: Integrate knowledge decay checks into lint-genomes script

This commit is contained in:
Matteo Cherubini 2026-05-09 11:34:21 +02:00
parent c807b0f732
commit 92e68fff00

View file

@ -2,6 +2,8 @@
# =============================================================================
# scripts/lint-genomes.sh
# Executes quality control across all registered genomes.
# Iterates from the GENOMES registry in config.env — not from filesystem patterns —
# so all genomes are covered regardless of their naming convention.
# =============================================================================
set -euo pipefail
@ -12,27 +14,46 @@ source "lib/lint.sh"
step "Starting Knowledge Genome Linting"
TOTAL_ERRORS=0
TOTAL_STALE=0
# Iterate through genome submodules inside the Master repo
for genome_dir in "${WORK_DIR}/${MASTER_REPO}"/genome-*/; do
[[ -d "$genome_dir" ]] || continue
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
GENOME_NAME=$(basename "$genome_dir")
info "Auditing genome: ${GENOME_NAME}..."
# Find all .md files, excluding AGENTS.md and external references
# Lint all .md files except AGENTS.md and core-karpathy reference
while IFS= read -r md_file; do
# Run validations
lint_markdown_file "$md_file" "$GENOME_NAME" || TOTAL_ERRORS=$((TOTAL_ERRORS + $?))
check_privacy_consistency "$md_file" || TOTAL_ERRORS=$((TOTAL_ERRORS + $?))
lint_markdown_file "$md_file" "$GENOME_NAME"
file_errors=$?
TOTAL_ERRORS=$((TOTAL_ERRORS + file_errors))
check_privacy_consistency "$md_file"
TOTAL_ERRORS=$((TOTAL_ERRORS + $?))
check_knowledge_decay "$md_file"
stale=$?
TOTAL_STALE=$((TOTAL_STALE + stale))
check_broken_links "$md_file"
done < <(find "$genome_dir" -name "*.md" ! -name "AGENTS.md" ! -path "*/core-karpathy/*")
done < <(find "$genome_dir" -name "*.md" \
! -name "AGENTS.md" \
! -path "*/core-karpathy/*")
done
if [[ $TOTAL_ERRORS -eq 0 ]]; then
success "Linting passed: All files are consistent and secure."
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: Found ${TOTAL_ERRORS} critical issues."
error "Linting failed: ${TOTAL_ERRORS} critical issue(s), ${TOTAL_STALE} stale file(s)."
exit 1
fi