From 1c6d7a4ecd325dacf05048e0c01f48c5112c4e41 Mon Sep 17 00:00:00 2001 From: Matteo Cherubini Date: Wed, 1 Jul 2026 19:37:10 +0200 Subject: [PATCH] feat(n8n): add 'pi prune' command to n8n-pi-wrap --- deploy/vm101/n8n-pi-wrap | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/deploy/vm101/n8n-pi-wrap b/deploy/vm101/n8n-pi-wrap index 43c7099..468139b 100755 --- a/deploy/vm101/n8n-pi-wrap +++ b/deploy/vm101/n8n-pi-wrap @@ -79,6 +79,29 @@ case "$cmd" in # MECHANICAL step: validate manifest -> index/log/scoped-lint/commit/PR -> 1 JSON line exec "${HOME}/.pi/agent/skills/ingest/scripts/run-ingest.sh" "${genome}" ;; + "pi prune "*) + # Pota le source orfane. Stesso lock dell'ingest (serializza le scritture per genoma), + # clean_start, poi run-prune.sh (che ri-deriva gli orfani e apre una PR gated). + genome="${cmd#pi prune }" + case "$genome" in ""|*[!a-z0-9-]*) echo '{"status":"error","reason":"invalid genome name"}'; exit 1;; esac + logger -t n8n-pi-wrap "ok: pi prune ${genome}" + + exec 9>"/run/lock/kg-ingest-${genome}.lock" 2>/dev/null || exec 9>"/tmp/kg-ingest-${genome}.lock" + if ! flock -n 9; then + echo '{"status":"busy","reason":"another ingest/prune is running for this genome","genome":"'"$genome"'"}' + exit 0 + fi + + set -a; . "${HOME}/.config/knowledge-genome.env"; set +a + cd "${GENOMES_ROOT}/${genome}" || { echo '{"status":"error","reason":"unknown genome"}'; exit 1; } + + : "${KG_LIB_DIR:=${HOME}/knowledge-genome-orchestrator/lib}" + source "${KG_LIB_DIR}/clean-start.sh" 2>/dev/null \ + || { echo '{"status":"error","reason":"clean-start.sh not found"}'; exit 1; } + clean_start || { echo '{"status":"error","reason":"clean-start failed"}'; exit 1; } + + exec "${HOME}/.pi/agent/skills/ingest/scripts/run-prune.sh" "${genome}" + ;; "pi ingest-rework "*) # args: (3 token). # Feedback in base64 nell'argv: il nodo SSH di n8n non passa stdin, e cosi' i metacaratteri