fix(runtime): advance idle discovery freshness heartbeat#62
Conversation
ls-remote에서 변경 없음이 확인되거나 fetch 후 새 작업이 없는 repository도 incremental health를 전진시켜 freshness 평가가 실제 지속 점검 의미와 맞도록 한다. 새 job, missing cursor, non-fast-forward 경로는 기존처럼 worker/후속 검증에 맡긴다. 검증: - uv run ruff check src/security_scanner/runtime/incremental_discovery.py tests/test_incremental_discovery.py tests/test_m4_poll_baseline.py - uv run pytest Co-Authored-By: Codex GPT-5 <noreply@openai.com>
There was a problem hiding this comment.
Code Review
This pull request updates the incremental discovery process to track skipped idle targets and conditionally advance repository health when running in enqueue mode, ensuring repositories are marked as incrementally fresh when no new work is observed. The reviewer suggests wrapping the advance_repo_health calls in try-except blocks to prevent transient database failures from aborting the discovery process, as these are best-effort, non-transactional operations.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if request.mode == DISCOVERY_MODE_ENQUEUE: | ||
| for target in skipped_idle_targets: | ||
| request.store.advance_repo_health( | ||
| repo_id_for_scan_target_url(target.url), | ||
| job_type=JOB_TYPE_INCREMENTAL, | ||
| completed_at=_now(request), | ||
| ) |
There was a problem hiding this comment.
The advance_repo_health call is a best-effort, non-transactional secondary operation. To prevent transient database failures from aborting the entire incremental discovery process, this call should be wrapped in a try-except block.
if request.mode == DISCOVERY_MODE_ENQUEUE:
for target in skipped_idle_targets:
try:
request.store.advance_repo_health(
repo_id_for_scan_target_url(target.url),
job_type=JOB_TYPE_INCREMENTAL,
completed_at=_now(request),
)
except Exception:
import logging
logging.getLogger(__name__).warning(
"Failed to advance repo health for %s",
target.url,
exc_info=True,
)References
- Best-effort or non-transactional secondary operations (such as writing secondary lookup pointers or logs) should be wrapped in try-except blocks to ensure that transient failures in these operations do not abort or roll back the main transaction.
| if request.mode == DISCOVERY_MODE_ENQUEUE: | ||
| request.store.advance_repo_health( | ||
| repo_id, | ||
| job_type=JOB_TYPE_INCREMENTAL, | ||
| completed_at=_now(request), | ||
| ) |
There was a problem hiding this comment.
The advance_repo_health call is a best-effort, non-transactional secondary operation. To prevent transient database failures from aborting the entire incremental discovery process, this call should be wrapped in a try-except block.
if request.mode == DISCOVERY_MODE_ENQUEUE:
try:
request.store.advance_repo_health(
repo_id,
job_type=JOB_TYPE_INCREMENTAL,
completed_at=_now(request),
)
except Exception:
import logging
logging.getLogger(__name__).warning(
"Failed to advance repo health for %s",
repo_id,
exc_info=True,
)References
- Best-effort or non-transactional secondary operations (such as writing secondary lookup pointers or logs) should be wrapped in try-except blocks to ensure that transient failures in these operations do not abort or roll back the main transaction.
| if ( | ||
| request.mode == DISCOVERY_MODE_ENQUEUE | ||
| and not pending_work_observed | ||
| and not unsafe_to_mark_fresh | ||
| ): | ||
| request.store.advance_repo_health( | ||
| repo_id, | ||
| job_type=JOB_TYPE_INCREMENTAL, | ||
| completed_at=_now(request), | ||
| ) |
There was a problem hiding this comment.
The advance_repo_health call is a best-effort, non-transactional secondary operation. To prevent transient database failures from aborting the entire incremental discovery process, this call should be wrapped in a try-except block.
if (
request.mode == DISCOVERY_MODE_ENQUEUE
and not pending_work_observed
and not unsafe_to_mark_fresh
):
try:
request.store.advance_repo_health(
repo_id,
job_type=JOB_TYPE_INCREMENTAL,
completed_at=_now(request),
)
except Exception:
import logging
logging.getLogger(__name__).warning(
"Failed to advance repo health for %s",
repo_id,
exc_info=True,
)References
- Best-effort or non-transactional secondary operations (such as writing secondary lookup pointers or logs) should be wrapped in try-except blocks to ensure that transient failures in these operations do not abort or roll back the main transaction.
What
REPO_HEALTH.lastSuccessfulIncrementalAtwhen incremental discovery successfully confirms that a repository has no new incremental work.DISCOVERY_MODE_INITIALIZE, missing cursor, non-fast-forward, and pending-work paths from marking a repository fresh.Why
lastSuccessfulIncrementalAtis an incremental discovery heartbeat, not proof that every commit scan completed. Whendiscover-updates --ls-remote-skipor the fetch path confirms no new work, freshness should not report a stale repository solely because it was idle.Actual scan completion and dedupe proof remain in
SCAN_JOBandSCAN_LEDGER. Baseline freshness remains separate throughlastSuccessfulFullScanAt.Review
codebase_architecture_manager; initial initialize/no-refs blocker was fixed.system_architecture_manager; no remaining system-level blocker.Verification
uv run ruff check src/security_scanner/runtime/incremental_discovery.py tests/test_incremental_discovery.py tests/test_m4_poll_baseline.pyuv run pytest tests/test_incremental_discovery.py tests/test_m4_poll_baseline.py tests/test_cli_timer_entrypoints.py tests/test_repo_health_freshness.pyuv run pytestCloses #61