Files
llm-intelligence/scripts/review/backlog_current_freshness_guard.sh
2026-05-29 18:48:48 +08:00

26 lines
869 B
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
BACKLOG_PATH="${1:?backlog path required}"
NOW_RAW="${LLM_NOW:-$(date '+%Y-%m-%d %H:%M')}"
python3 - <<'PY' "$BACKLOG_PATH" "$NOW_RAW"
from pathlib import Path
from datetime import datetime
import re
import sys
text = Path(sys.argv[1]).read_text(encoding='utf-8')
now = datetime.strptime(sys.argv[2], '%Y-%m-%d %H:%M')
match = re.search(r'## 当前未修复问题速查表(截至 ([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2})', text)
if not match:
print('missing current table timestamp', file=sys.stderr)
raise SystemExit(1)
seen = datetime.strptime(match.group(1), '%Y-%m-%d %H:%M')
age_minutes = int((now - seen).total_seconds() // 60)
if age_minutes > 180:
print('stale current truth snapshot', file=sys.stderr)
raise SystemExit(1)
print(f'BACKLOG_FRESHNESS age_minutes={age_minutes} status=fresh')
PY