63 lines
2.6 KiB
Bash
Executable File
63 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Post-comment-close re-farm for docket CMS-2026-2377 (CY2027 PFS NPRM,
|
|
# CMS-1848-P). Scheduled via host crontab for 2026-09-15 (comment period
|
|
# closes 2026-09-14 per 91 FR 43842 DATES block). Tracker: issue #615.
|
|
#
|
|
# Every step is resumable/incremental — safe to re-run on partial failure.
|
|
set -uo pipefail
|
|
cd "$(dirname "$0")/../.."
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
set -a; source .env; set +a
|
|
|
|
mkdir -p .state/comments
|
|
LOG=.state/comments/refarm-CMS-2026-2377.log
|
|
exec >>"$LOG" 2>&1
|
|
echo "=== re-farm run $(date -Is) ==="
|
|
|
|
FAILURES=0
|
|
|
|
step() { # step <label> <cmd...>: run, count failures, keep going
|
|
local label=$1; shift
|
|
echo "--- $label: $(date -Is)"
|
|
"$@" || { echo "WARN: $label rc=$?"; FAILURES=$((FAILURES+1)); }
|
|
}
|
|
|
|
# Every step is incremental: sealed dockets are skipped outright, open
|
|
# dockets pull from the stored watermark, extract/index compare cheap
|
|
# fingerprints before doing any work. Mirror first (bulk, no cap), then
|
|
# the API for anything the mirror lags on.
|
|
step "mirror backfill" uv run stack bib backfill-comments --docket CMS-2026-2377 --mirror
|
|
step "api fetch" uv run stack bib fetch-pfs-comments --docket CMS-2026-2377
|
|
step "api backfill" uv run stack bib backfill-comments --docket CMS-2026-2377
|
|
step "extract" uv run stack comments extract --docket CMS-2026-2377
|
|
step "index" uv run stack llm index --collection comments --docket CMS-2026-2377
|
|
|
|
COUNTS=$(uv run python - <<'EOF'
|
|
from conf import connect
|
|
s = connect.bib()
|
|
con = s._con()
|
|
total, enriched = con.execute(
|
|
"SELECT count(*), sum(CASE WHEN coalesce(abstract,'')<>'' THEN 1 ELSE 0 END) "
|
|
"FROM items WHERE url LIKE 'https://www.regulations.gov/comment/CMS-2026-2377-%'"
|
|
).fetchone()
|
|
print(f"comments={total} enriched={enriched}")
|
|
s.close()
|
|
EOF
|
|
) || { echo "WARN: counts rc=$?"; FAILURES=$((FAILURES+1)); }
|
|
echo "$COUNTS"
|
|
|
|
if [ "$FAILURES" -eq 0 ]; then
|
|
RESULT_MSG="Automated post-close re-farm ran $(date -I): $COUNTS."
|
|
else
|
|
RESULT_MSG="Automated post-close re-farm ran $(date -I) — completed with $FAILURES failed steps — check log. $COUNTS."
|
|
fi
|
|
|
|
curl -sf -X POST \
|
|
"https://git.fhirworx.io/api/v1/repos/homelab/stack/issues/615/comments" \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-H "User-Agent: curl/8.5.0" \
|
|
-d "{\"body\": \"$RESULT_MSG Log: .state/comments/refarm-CMS-2026-2377.log. Review counts, spot-check indexing, then close this issue and milestone P37.\n\nIf complete: close #615, close milestone P37, and REMOVE the crontab line (re-fires annually).\"}" \
|
|
|| echo "WARN: gitea comment failed"
|
|
echo "=== done $(date -Is) ==="
|