From ee62078f5be3d9b8181b330724c02f7228757468 Mon Sep 17 00:00:00 2001 From: Copilot Date: Wed, 3 Jun 2026 06:06:15 -0500 Subject: [PATCH] fix(scrape): skip SIGTERM/SIGINT export aborts like OOM Stopping validation with kill/Ctrl+C returned exit 143/130 and failed the whole target instead of SKIPPED + preserve partial. Added smoke for exit 143; gitignore .dce-scrape.lock. --- .gitignore | 1 + ...-06-04-047-fix-skip-sigterm-export-plan.md | 37 +++++++++++++++++++ docs/recurring-scrape-merge-readiness.md | 2 + scripts/run-discord-scrape.sh | 4 +- scripts/tests/run-discord-scrape-smoke.sh | 24 ++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 docs/plans/2026-06-04-047-fix-skip-sigterm-export-plan.md diff --git a/.gitignore b/.gitignore index 5b2185c6..838b7f7f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ TestResults/ # Local automation secrets and logs scrape.env .discord-token +.dce-scrape.lock agentdecompile_projects/ logs/ .compound-engineering/*.local.yaml diff --git a/docs/plans/2026-06-04-047-fix-skip-sigterm-export-plan.md b/docs/plans/2026-06-04-047-fix-skip-sigterm-export-plan.md new file mode 100644 index 00000000..cdf886d1 --- /dev/null +++ b/docs/plans/2026-06-04-047-fix-skip-sigterm-export-plan.md @@ -0,0 +1,37 @@ +--- +title: "fix: Treat SIGTERM/SIGINT export aborts as skippable" +type: fix +status: complete +date: 2026-06-04 +origin: /lfg — yes_general died with fatal ERROR instead of SKIPPED when validation was stopped +--- + +# fix: Treat SIGTERM/SIGINT export aborts as skippable + +## Problem + +Killing overlapping validation (`kill` / Ctrl+C) sends SIGTERM/SIGINT to the export CLI. Bash exit codes **143** (128+15) and **130** (128+2) were not in the abort-skip list, so `scrape_target` called `die` and failed the whole target — losing partial temp progress instead of SKIPPED + preserve. + +Observed: `ERROR: Channel 221726893064454144 failed` at 7% progress in `logs/kotor-validation-20260604.log`. + +## Requirements + +| ID | Requirement | +|----|-------------| +| R1 | `export_channel_incremental` returns skip (2) on exit 130 and 143, same as 134/137/139 | +| R2 | Partial temp preserved on those skips when `temp_export` non-empty | +| R3 | Offline smoke covers exit 143 skip path | +| R4 | `.gitignore` includes `.dce-scrape.lock` | +| R5 | `run-all-smokes.sh` passes; docs updated | + +## Verification + +```bash +./scripts/tests/run-discord-scrape-smoke.sh +DCE_MIN_FREE_MB=0 ./scripts/run-all-smokes.sh +``` + +## Out of scope + +- Completing yes_general catch-up inside LFG +- Container memory tuning diff --git a/docs/recurring-scrape-merge-readiness.md b/docs/recurring-scrape-merge-readiness.md index 0751c810..506953b7 100644 --- a/docs/recurring-scrape-merge-readiness.md +++ b/docs/recurring-scrape-merge-readiness.md @@ -115,6 +115,8 @@ DCE_MIN_FREE_MB=0 ./scripts/run-operator-validation.sh --sync-gui --per-target - \* Audit failed before plan 045 because truncated partial exports under `.dce-temp/` were scanned as archives. After fix, audit passes while partial temps exist. +**Plan 047 (2026-06-04):** Treat SIGTERM (143) and SIGINT (130) export exits as skippable aborts — stopping validation no longer fails the whole target with `ERROR: Channel failed`. `.dce-scrape.lock` gitignored. + **Plan 046 (2026-06-04):** `run-discord-scrape-host.sh scrape` holds non-blocking `flock` on `.dce-scrape.lock` so overlapping manual/cron validation cannot spawn twin yes_general exports. Stop duplicate runs before restarting KotOR validation. **Plan 045 (2026-06-04):** `audit-archive-json.sh` and `verify-documents-archives.sh` skip `*/.dce-temp/*` (in-progress partial exports). Salvage run 2026-06-03: 7 merged, 17 unchanged, 3 skipped (+5404 messages); yes_general OOM-skipped with partial temps preserved for next salvage. diff --git a/scripts/run-discord-scrape.sh b/scripts/run-discord-scrape.sh index c31bcf65..4e00cd0e 100755 --- a/scripts/run-discord-scrape.sh +++ b/scripts/run-discord-scrape.sh @@ -731,8 +731,8 @@ export_channel_incremental() { return 0 fi - # SIGABRT (134), SIGKILL/OOM (137), SIGSEGV (139) — bash reports these when the CLI crashes. - if (( export_status == 134 || export_status == 137 || export_status == 139 )); then + # SIGINT (130), SIGTERM (143), SIGABRT (134), SIGKILL/OOM (137), SIGSEGV (139) + if (( export_status == 130 || export_status == 143 || export_status == 134 || export_status == 137 || export_status == 139 )); then log "Skipping channel $channel_id (export process aborted, exit $export_status)." [[ -s "$export_log" ]] && cat "$export_log" >&2 rm -f "$export_log" diff --git a/scripts/tests/run-discord-scrape-smoke.sh b/scripts/tests/run-discord-scrape-smoke.sh index 640cfc00..e772d0b5 100755 --- a/scripts/tests/run-discord-scrape-smoke.sh +++ b/scripts/tests/run-discord-scrape-smoke.sh @@ -135,6 +135,14 @@ cat >"$CONFIG_PATH" <&2 + exit 143 + fi + case "$mode" in initial) cp "$fixture_dir/append-existing.json" "$output" ;; append) cp "$fixture_dir/append-incremental.json" "$output" ;; @@ -392,6 +406,16 @@ partial_temp_dirs=( "$ARCHIVE_ROOT/skip-abort/.dce-temp"/export.134.* ) [[ -d "${partial_temp_dirs[0]}" ]] || { echo "expected partial temp dir preserved for channel 134" >&2; exit 1; } [[ -s "${partial_temp_dirs[0]}/export.json" ]] || { echo "expected partial export.json preserved for channel 134" >&2; exit 1; } +mkdir -p "$ARCHIVE_ROOT/skip-sigterm" +cp "$FIXTURE_DIR/append-existing.json" "$ARCHIVE_ROOT/skip-sigterm/$DEFAULT_FILE_NAME" +SKIP_SIGTERM_LOG="$TMP_DIR/skip-sigterm.log" +run_wrapper skip-sigterm append 2>"$SKIP_SIGTERM_LOG" +SKIP_SIGTERM_DEST="$ARCHIVE_ROOT/skip-sigterm/$DEFAULT_FILE_NAME" +[[ "$(jq -r '.messages | length' "$SKIP_SIGTERM_DEST")" == "3" ]] || { echo "expected skip-sigterm to append accessible channel" >&2; exit 1; } +grep -q 'SKIPPED.*143' "$SKIP_SIGTERM_LOG" || { echo "expected SKIPPED line for sigterm channel 143" >&2; exit 1; } +grep -q 'exit 143' "$SKIP_SIGTERM_LOG" || { echo "expected sigterm exit logged for channel 143" >&2; exit 1; } +grep -q 'Preserving partial export temp' "$SKIP_SIGTERM_LOG" || { echo "expected partial temp preserved on sigterm channel 143" >&2; exit 1; } + # Salvage stale temp export smoke mkdir -p "$ARCHIVE_ROOT/salvage-stale" cp "$FIXTURE_DIR/append-existing.json" "$ARCHIVE_ROOT/salvage-stale/$DEFAULT_FILE_NAME"