From eed2251c28141cc848e38ce39da886f8ddc227dd Mon Sep 17 00:00:00 2001 From: Matteo Cherubini Date: Wed, 1 Jul 2026 19:56:41 +0200 Subject: [PATCH] feat(raw-commit): implement raw file quiet window for ingest --- deploy/nexus/genome-raw-commit.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/deploy/nexus/genome-raw-commit.sh b/deploy/nexus/genome-raw-commit.sh index f7dfa24..3e1c084 100644 --- a/deploy/nexus/genome-raw-commit.sh +++ b/deploy/nexus/genome-raw-commit.sh @@ -43,8 +43,30 @@ grep -qxF 'raw/.stfolder' "${vault}/.git/info/exclude" 2>/dev/null || echo 'raw/ git add -A -- raw/ git reset -q -- raw/.stignore raw/.stfolder 2>/dev/null || true + +# --- Quiet window: only commit raw files that have STOPPED changing. ---------------- +# While a note is being written (Obsidian autosave -> Syncthing -> here) its mtime stays +# fresh; we leave it UNSTAGED so a half-written note never triggers an ingest. A file is +# committed only after it has been still for RAW_QUIET_MINUTES. Deletions (nothing on disk) +# are stable by definition and pass straight through. Deterministic — no model in the loop. +quiet_min="${RAW_QUIET_MINUTES:-2}" +held=0 +while IFS= read -r f; do + [[ -z "$f" ]] && continue + # Only an existing file can be "hot"; a staged deletion has nothing on disk to settle. + if [[ -e "$f" && -n "$(find "$f" -mmin -"$quiet_min" 2>/dev/null)" ]]; then + git reset -q -- "$f" 2>/dev/null || true + held=$((held+1)) + fi +done < <(git diff --cached --name-only -- raw/) + if git diff --cached --quiet; then - printf '{"status":"noop","genome":"%s"}\n' "$genome" + if [[ "$held" -gt 0 ]]; then + printf '{"status":"noop","reason":"raw still settling","genome":"%s","held":%d,"quiet_minutes":%d}\n' \ + "$genome" "$held" "$quiet_min" + else + printf '{"status":"noop","genome":"%s"}\n' "$genome" + fi exit 0 fi