fix(evidence): close S3 and smoke safety gaps

This commit is contained in:
2026-07-12 06:09:15 +02:00
parent efcb0deb31
commit e6d44ba082
5 changed files with 148 additions and 36 deletions
+30 -5
View File
@@ -4,10 +4,15 @@ cd "$(dirname "$0")/.."
tmp=$(mktemp -d "${TMPDIR:-/tmp}/thoth-preprocess.XXXXXX")
project="thoth-preprocess-$$"
compose=""
cleanup() {
docker compose -f compose.yaml -f deploy/compose.local-vector.yaml \
-f deploy/compose.preprocess.yaml -f "$tmp/smoke.yaml" --project-name "$project" \
--profile local-vector --profile preprocess down --volumes >/dev/null 2>&1 || true
trap - EXIT HUP INT TERM
if [ -n "$compose" ]; then
$compose down --volumes >/dev/null
fi
test -z "$(docker ps -aq --filter "label=com.docker.compose.project=$project")"
test -z "$(docker volume ls -q --filter "label=com.docker.compose.project=$project")"
test -z "$(docker network ls -q --filter "label=com.docker.compose.project=$project")"
rm -rf "$tmp"
}
trap cleanup EXIT HUP INT TERM
@@ -56,18 +61,36 @@ $compose build preprocess-evidence
$compose up -d vector-db mock-embeddings
$compose run --rm vector-reconcile >/dev/null
$compose run --rm --no-deps vector-migrate >/dev/null
if [ "${1:-}" = "--cleanup-failure" ]; then
cleanup
test ! -e "$tmp"
echo "injected preprocessing failure cleanup passed."
exit 0
fi
generation_count() {
$compose run --rm --no-deps --entrypoint sh preprocess-evidence -c \
'find /data/workspaces/preprocess-evidence/corpus/generations -mindepth 1 -maxdepth 1 -type d 2>/dev/null | wc -l'
}
before=$(generation_count)
first=$($compose run --rm preprocess-evidence)
after_first=$(generation_count)
second=$($compose run --rm preprocess-evidence)
after_second=$(generation_count)
printf '%s' 'generation two' >>"$tmp/source/evidence/a.md"
third=$($compose run --rm preprocess-evidence)
after_third=$(generation_count)
dwh=$($compose run --rm preprocess-dwh)
python3 - "$first" "$second" "$third" <<'PY'
python3 - "$first" "$second" "$third" "$before" "$after_first" "$after_second" "$after_third" <<'PY'
import json, sys
a, b, c = map(json.loads, sys.argv[1:])
a, b, c = map(json.loads, sys.argv[1:4])
before, first_count, second_count, third_count = map(int, sys.argv[4:])
assert len(a["changed"]) == 1 and not a["unchanged"]
assert len(b["unchanged"]) == 1 and not b["changed"]
assert len(c["changed"]) == 1 and c["generation"] != a["generation"]
assert all(row["published"] for row in (a, b, c))
assert first_count == before + 1
assert second_count == first_count
assert third_count == second_count + 1
PY
python3 - "$dwh" <<'PY'
import json, sys
@@ -80,3 +103,5 @@ import json, sys
assert json.loads(sys.argv[1])["generation"] == sys.argv[2].strip()
PY
echo "real Compose preprocessing unchanged rerun, mutation, DWH job, and ACTIVE publish passed."
cleanup
test ! -e "$tmp"