Skip to content

fix(runtime): advance idle discovery freshness heartbeat#62

Open
pureliture wants to merge 1 commit into
mainfrom
codex/idle-freshness-pr
Open

fix(runtime): advance idle discovery freshness heartbeat#62
pureliture wants to merge 1 commit into
mainfrom
codex/idle-freshness-pr

Conversation

@pureliture

Copy link
Copy Markdown
Contributor

What

  • Advance REPO_HEALTH.lastSuccessfulIncrementalAt when incremental discovery successfully confirms that a repository has no new incremental work.
  • Keep DISCOVERY_MODE_INITIALIZE, missing cursor, non-fast-forward, and pending-work paths from marking a repository fresh.
  • Add regression coverage for idle skip, unchanged refs, no refs, and all-ledger-skipped paths.

Why

lastSuccessfulIncrementalAt is an incremental discovery heartbeat, not proof that every commit scan completed. When discover-updates --ls-remote-skip or 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_JOB and SCAN_LEDGER. Baseline freshness remains separate through lastSuccessfulFullScanAt.

Review

  • Reviewed locally by codebase_architecture_manager; initial initialize/no-refs blocker was fixed.
  • Reviewed locally by 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.py
  • uv run pytest tests/test_incremental_discovery.py tests/test_m4_poll_baseline.py tests/test_cli_timer_entrypoints.py tests/test_repo_health_freshness.py
  • uv run pytest

Closes #61

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>
@pureliture pureliture added the type:bug Bug work item label Jun 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +487 to +493
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),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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
  1. 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.

Comment on lines +509 to +514
if request.mode == DISCOVERY_MODE_ENQUEUE:
request.store.advance_repo_health(
repo_id,
job_type=JOB_TYPE_INCREMENTAL,
completed_at=_now(request),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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
  1. 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.

Comment on lines +575 to +584
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),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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
  1. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug work item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: idle repository freshness false breach 보정

1 participant