[codex] fix guide refresh stale artifact validation#33
Merged
zachyzissou merged 4 commits intomainfrom Feb 24, 2026
Merged
Conversation
There was a problem hiding this comment.
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_attimestamp 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.m3uandindex.xmlfiles 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_updateto 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:
attempt_started_attimestamp before each CLI invocation.mtimeat/after the current attempt timestamp (with a small tolerance for filesystem precision).0but artifacts are stale, mark that attempt as failed and continue through fallback invocation strategies.Tests and validation
python3 -m py_compile app/server.py test_integration.pypassed.python3 test_integration.pycould not run successfully in this environment becausepython3is 3.9 and the project requires Python 3.11+ (datetime.UTC).Files changed
app/server.pytest_integration.py