Repository navigation
fix(atlas): preserve completed GitHub feed checkpoints across streams #13566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+181
−33
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
16 changes: 16 additions & 0 deletions
16
pkgs/atlas-search/crates/atlas-core/tests/github_comments_checkpoint.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| //! Exercise the production CLI across multiple runs using the synthetic gh fixture. | ||
| use std::process::Command; | ||
|
|
||
| #[test] | ||
| fn github_comments_checkpoint_preserves_eligible_records() { | ||
| let fixture = concat!( | ||
| env!("CARGO_MANIFEST_DIR"), | ||
| "/../../tests/test_github_comments_checkpoint.py" | ||
| ); | ||
| let status = Command::new("python3") | ||
| .arg(fixture) | ||
| .arg(env!("CARGO_BIN_EXE_atlas-github-comments")) | ||
| .status() | ||
| .expect("run Python 3 synthetic GitHub CLI fixture"); | ||
| assert!(status.success(), "checkpoint CLI oracle failed: {status}"); | ||
| } |
71 changes: 71 additions & 0 deletions
71
pkgs/atlas-search/tests/test_github_comments_checkpoint.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| """Offline CLI oracle: stable cutoff, independent review cursor, and handled-error recovery.""" | ||
| import json | ||
| import os | ||
| from pathlib import Path | ||
| import subprocess | ||
| import sys | ||
| import tempfile | ||
|
|
||
| REPO = "developing-today/atlas-fixture" | ||
| BASE = "2026-01-01T00:00:00Z" | ||
| FAKE_GH = """#!/usr/bin/env python3 | ||
| import json, os, sys | ||
| route = sys.argv[2].split("?")[0] | ||
| def stamp(n): | ||
| return f"2026-01-01T00:00:0{n}Z" | ||
| def record(n, key, thread): | ||
| return {"id":n, "user":{"login":"fixture"}, "body":"fixture", | ||
| "created_at":stamp(n), "submitted_at":stamp(n), "updated_at":stamp(n), | ||
| key:f"https://api.github.com/repos/developing-today/atlas-fixture/issues/{thread}"} | ||
| if route.endswith("/issues"): | ||
| rows = [{"number":n, "pull_request":{}, "labels":[]} for n in (1, 2)] | ||
| elif route.endswith("/issues/comments"): | ||
| rows = [record(5, "issue_url", 1)] | ||
| elif route.endswith("/pulls/comments"): | ||
| rows = [record(3, "pull_request_url", 2)] | ||
| elif route.endswith("/pulls/1/reviews"): | ||
| rows = [record(4, "unused", 1)] | ||
| elif route.endswith("/pulls/2/reviews"): | ||
| if os.environ.get("FIXTURE_FAILURE"): | ||
| sys.exit(1) | ||
| rows = [record(2, "unused", 2)] | ||
| else: | ||
| raise SystemExit("unexpected fixture route") | ||
| for row in rows: | ||
| print(json.dumps(row)) | ||
| """ | ||
|
|
||
|
|
||
| def exercise(directory, cli): | ||
| gh = directory / "gh" | ||
| gh.write_text(FAKE_GH) | ||
| gh.chmod(0o700) | ||
| state = directory / "state.json" | ||
| output = directory / "records.jsonl" | ||
| initial = json.dumps({"repos": {REPO: BASE}}) | ||
| state.write_text(initial) | ||
| output.write_text("") | ||
| env = dict(os.environ, PATH=f"{directory}:{os.environ['PATH']}") | ||
| cmd = [str(cli), "--repo", REPO, "--state", str(state), "--out", str(output), | ||
| "--observed-date", "2026-01-02"] | ||
|
|
||
| def ids(): | ||
| return [json.loads(line)["comment_id"] for line in output.read_text().splitlines()] | ||
|
|
||
| # Independent oracle: an unsuccessful last stream leaves the entire prior | ||
| # checkpoint and append unchanged. Successful retry emits every eligible ID. | ||
| failure = subprocess.run(cmd, env=dict(env, FIXTURE_FAILURE="1"), capture_output=True) | ||
| assert failure.returncode == 1 and b"rerun resumes" in failure.stderr | ||
| assert state.read_text() == initial and ids() == [] | ||
| subprocess.run(cmd + ["--skip-reviews"], env=env, check=True) | ||
| assert ids() == [5, 3] | ||
| assert json.loads(state.read_text())["reviews"][REPO] == BASE | ||
| subprocess.run(cmd, env=env, check=True) | ||
| assert ids() == [5, 3, 4, 2] | ||
| subprocess.run(cmd, env=env, check=True) | ||
| assert ids() == [5, 3, 4, 2] | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| with tempfile.TemporaryDirectory() as tmp: | ||
| exercise(Path(tmp), Path(sys.argv[1]).resolve()) | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new checkpoint behavior is covered only by a fixed fixture with four records and one failure position. The repository's Testing doctrine explicitly requires property-based tests for state-machine and serialization invariants; example-based acceptance tests do not replace them. Add
proptestcoverage generating timestamp orderings and skip/retry sequences, checking that cursors never regress, skipped reviews retain their cutoff, and failed repository passes preserve the prior checkpoint and output.proptestis already an atlas-core dev-dependency.AGENTS.md reference: AGENTS.md:L34-L39
Useful? React with 👍 / 👎.