fix(agent-office): node_monitor _beat_age가 epoch ts 허용 → naver-fetch 영구 down 오탐 해소

매물알림 스펙 §4.4는 fetcher heartbeat ts를 epoch 정수로 정의했는데
_beat_age가 ISO 문자열만 파싱해 int.replace AttributeError → age=None
→ naver-fetch가 heartbeat 정상 발신 중에도 /nodes에서 영구 alive=false.
isinstance(int|float) 분기로 epoch·ISO 둘 다 지원 (신규 테스트 2건).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jBG2fz48w1bMfaQo8YC6M
This commit is contained in:
2026-07-11 15:43:55 +09:00
parent b86fb874f0
commit a020c52a30
2 changed files with 28 additions and 2 deletions

View File

@@ -28,9 +28,13 @@ def _get_redis():
return _redis
def _beat_age(ts_str, now):
def _beat_age(ts, now):
"""ts는 ISO-8601 문자열 또는 epoch 숫자(매물알림 스펙 §4.4) 둘 다 허용."""
try:
beat = dt.datetime.fromisoformat(ts_str.replace("Z", "+00:00"))
if isinstance(ts, (int, float)):
beat = dt.datetime.fromtimestamp(ts, tz=dt.timezone.utc)
else:
beat = dt.datetime.fromisoformat(ts.replace("Z", "+00:00"))
return max(0, int((now - beat).total_seconds()))
except Exception:
return None