Skip to content

[codex] fix guide refresh stale artifact validation#33

Merged
zachyzissou merged 4 commits intomainfrom
codex/fix-guide-refresh-stale-artifacts
Feb 24, 2026
Merged

[codex] fix guide refresh stale artifact validation#33
zachyzissou merged 4 commits intomainfrom
codex/fix-guide-refresh-stale-artifacts

Conversation

@zachyzissou
Copy link
Owner

Summary

This change fixes a stale-guide failure mode where scheduled refresh runs can be marked successful even when the CLI did not actually produce fresh artifacts for that run. In that state, existing index.m3u and index.xml files from prior days remain on disk and the service continues serving outdated guide data.

Issue and user impact

When the upstream CLI exits successfully but does not refresh files, Downlink previously accepted any already-existing artifacts as success. That allowed last_update to advance and scheduling to continue as if data were current, while clients still received stale guide content.

Root cause

_verify_generated_files() only checked for existence of output files. If old files were present before the run, validation passed regardless of whether current-attempt generation actually updated those files.

Fix

Generation now validates freshness per attempt:

  • Capture an attempt_started_at timestamp before each CLI invocation.
  • Require both artifacts to be present, non-empty, and have mtime at/after the current attempt timestamp (with a small tolerance for filesystem precision).
  • If CLI exits 0 but artifacts are stale, mark that attempt as failed and continue through fallback invocation strategies.
  • Keep existing move/copy fallback behavior for alternate output locations, but still enforce freshness and non-empty checks after relocation.

Tests and validation

  • Added integration regression coverage to ensure stale pre-existing artifacts are rejected during generation validation.
  • Local validation in this shell:
    • python3 -m py_compile app/server.py test_integration.py passed.
    • python3 test_integration.py could not run successfully in this environment because python3 is 3.9 and the project requires Python 3.11+ (datetime.UTC).

Files changed

  • app/server.py
  • test_integration.py

@zachyzissou zachyzissou marked this pull request as ready for review February 24, 2026 20:50
Copilot AI review requested due to automatic review settings February 24, 2026 20:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a stale-guide failure mode by tightening post-CLI artifact validation so refresh runs only succeed when the current attempt actually produces fresh index.m3u/index.xml outputs.

Changes:

  • Track a per-attempt attempt_started_at timestamp and validate generated artifacts are non-empty and refreshed (mtime >= attempt start, with tolerance).
  • Treat “CLI exited 0 but artifacts are stale” as an attempt failure and continue through fallback invocation strategies.
  • Add an integration regression test that pre-creates stale artifacts and asserts validation rejects them.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
app/server.py Adds freshness + non-empty validation keyed to an attempt start timestamp; improves failure handling when CLI exits successfully but doesn’t update outputs.
test_integration.py Adds regression coverage ensuring stale pre-existing artifacts are rejected by generation validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zachyzissou zachyzissou merged commit e910bd6 into main Feb 24, 2026
14 checks passed
@zachyzissou zachyzissou deleted the codex/fix-guide-refresh-stale-artifacts branch February 24, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants