From f8e3e8ca297a2f9b65dd4a25f4ad180aac0fbce9 Mon Sep 17 00:00:00 2001 From: Master Date: Sat, 18 Jul 2026 19:27:14 +0200 Subject: [PATCH] feat: lint_weekly.sh - execution hebdomadaire du Lint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Etage 1 de l'automatisation du Lint (backlog 8ETP6OyqToMR). - wrapper d'exploitation, lint_audit.py reste un moteur pur en lecture seule - tache DSM dimanche 21h00, utilisateur Master (pas root : moindre privilege, le Lint lit Trilium via ETAPI localhost) - sortie d'UNE ligne pour le mail DSM (total, bacs, dimensions, chemin rapport) - mail a chaque run (pas seulement si anomalie) : le silence serait ambigu entre 'rien a signaler' et 'la tache est morte' — anti confident-but-stale - rotation 12 rapports (~3 mois), erreur explicite si venv absent, si le Lint plante, ou si la synthese est illisible --- lint_weekly.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lint_weekly.sh diff --git a/lint_weekly.sh b/lint_weekly.sh new file mode 100644 index 0000000..3376568 --- /dev/null +++ b/lint_weekly.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# lint_weekly.sh - Execution hebdomadaire du Lint (etage 1 : lecture seule). +# Lance par le planificateur DSM le dimanche soir, utilisateur Master. +# lint_audit.py n ecrit RIEN dans Trilium : il produit un rapport dans lint_reports/. +# Ce wrapper : execute, fait tourner les rapports, sort UNE ligne pour le mail DSM. + +BASE=/volume1/homes/Master/App/Context_continuity +PY=$BASE/venv/bin/python3 +REPORTS=$BASE/lint_reports +GARDER=12 # ~3 mois d historique hebdomadaire + +cd $BASE || { echo "ERREUR repertoire introuvable : $BASE"; exit 1; } +[ -x "$PY" ] || { echo "ERREUR venv introuvable : $PY"; exit 1; } + +SORTIE=$($PY lint_audit.py 2>&1) +CODE=$? +if [ $CODE -ne 0 ]; then + echo "ERREUR lint_audit.py a echoue (code $CODE)" + echo "$SORTIE" | tail -5 + exit 1 +fi + +# Extraire la synthese du rapport +TOTAL=$(echo "$SORTIE" | grep '^## Synthese' | sed 's/.*: \([0-9]*\) anomalie.*/\1/') +DIMS=$(echo "$SORTIE" | grep 'Par dimension' | sed 's/.*Par dimension : //') +BACS=$(echo "$SORTIE" | grep "Par bac d'action" | sed "s/.*Par bac d'action : //") +FICHIER=$(echo "$SORTIE" | grep '^Rapport ecrit' | sed 's/^Rapport ecrit : //') + +# Rotation des rapports +if [ -d "$REPORTS" ]; then + cd $REPORTS && ls -1t lint_*.txt 2>/dev/null | tail -n +$((GARDER+1)) | while read f; do rm -f "$f"; done +fi + +# Une ligne pour le mail DSM (le detail est dans le fichier) +if [ -z "$TOTAL" ]; then + echo "ERREUR synthese illisible dans la sortie du Lint" + exit 1 +fi +echo "LINT $TOTAL anomalie(s) | $BACS | $DIMS | rapport: $FICHIER"